Skip to content

Commit

Permalink
Align with the latest cheqd node version (3.1.4) (#502)
Browse files Browse the repository at this point in the history
* Align with the latest `cheqd` node version (`3.1.1`)

* Lints + snapshots

* Align with the latest version of `cheqd` node

* Tweaks

* Switch dependency back

* Corrections

* Improvements

* Update `package.json`

* `cheqd` suppots `dock:` idents

* Update snapshots

* Bump up image tag

* Filter out placeholders
  • Loading branch information
olegnn authored Jan 17, 2025
1 parent 8250f38 commit c35c609
Show file tree
Hide file tree
Showing 33 changed files with 608 additions and 388 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cheqd-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
env:
CHEQD_MNEMONIC: "steak come surprise obvious remain black trouble measure design volume retreat float coach amused match album moment radio stuff crack orphan ranch dose endorse"
IMAGE_TAG: 3.0.1
IMAGE_TAG: 3.1.4
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand Down
11 changes: 8 additions & 3 deletions examples/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

## 0.7.0

### Minor Changes
### Patch Changes

- ld.dock.io -> ld.truvera.io
- @docknetwork/credential-sdk@0.23.0
- @docknetwork/dock-blockchain-api@0.9.1
- @docknetwork/dock-blockchain-modules@0.12.1

### Patch Changes
## 0.6.9

### Minor Changes

- ld.dock.io -> ld.truvera.io
- Updated dependencies
- @docknetwork/dock-blockchain-modules@0.13.0
- @docknetwork/credential-sdk@0.23.0
Expand Down
6 changes: 3 additions & 3 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"lint": "eslint \"*.js\""
},
"dependencies": {
"@docknetwork/credential-sdk": "0.23.0",
"@docknetwork/dock-blockchain-api": "0.9.1",
"@docknetwork/dock-blockchain-modules": "0.13.0"
"@docknetwork/credential-sdk": "0.24.0",
"@docknetwork/dock-blockchain-api": "0.9.2",
"@docknetwork/dock-blockchain-modules": "0.13.1"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "root",
"version": "0.24.0",
"version": "0.25.0",
"private": true,
"workspaces": [
"packages/*",
Expand Down
8 changes: 8 additions & 0 deletions packages/cheqd-blockchain-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @docknetwork/cheqd-blockchain-api

## 0.18.0

### Minor Changes

- Align with the latest `cheqd` node version (`3.1.3`)

## 0.17.1

### Patch Changes
Expand All @@ -9,6 +15,8 @@

## 0.17.0

### Minor Changes

- Implementation of the `cheqd` migration and the associated identifier mappers.
- Updated dependencies
- @docknetwork/credential-sdk@0.22.0
Expand Down
4 changes: 2 additions & 2 deletions packages/cheqd-blockchain-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/cheqd-blockchain-api",
"version": "0.17.1",
"version": "0.18.0",
"license": "MIT",
"main": "./dist/esm/index.js",
"type": "module",
Expand Down Expand Up @@ -34,7 +34,7 @@
},
"dependencies": {
"@cheqd/sdk": "cjs",
"@docknetwork/credential-sdk": "0.23.0"
"@docknetwork/credential-sdk": "0.24.0"
},
"devDependencies": {
"@babel/cli": "^7.24.1",
Expand Down
20 changes: 18 additions & 2 deletions packages/cheqd-blockchain-api/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
CheqdMainnetOffchainSignatureKeyRef,
CheqdTestnetAccumulator,
CheqdMainnetAccumulator,
DockDidOrDidMethodKey,
} from '@docknetwork/credential-sdk/types';
import { TypedEnum } from '@docknetwork/credential-sdk/types/generic';

Expand Down Expand Up @@ -160,7 +161,6 @@ export class CheqdAPI extends AbstractApiProvider {
*/
async disconnect() {
this.ensureInitialized();

delete this.sdk;

return this;
Expand All @@ -181,6 +181,7 @@ export class CheqdAPI extends AbstractApiProvider {
* @returns {Promise<Uint8Array>}
*/
async stateChangeBytes(method, payload) {
this.ensureInitialized();
const { [method]: Payloads } = this.constructor.Payloads;
if (Payloads == null) {
throw new Error(
Expand Down Expand Up @@ -212,6 +213,7 @@ export class CheqdAPI extends AbstractApiProvider {
* @returns {Promise<*>}
*/
async signAndSend(tx, { from, fee, memo } = {}) {
this.ensureInitialized();
const { PayloadWrappers, Prefixes, Fees } = this.constructor;
const { typeUrl } = tx;

Expand All @@ -226,7 +228,7 @@ export class CheqdAPI extends AbstractApiProvider {
const sender = from ?? (await this.sdk.options.wallet.getAccounts())[0].address;
const payment = {
amount: [amount],
gas: '3600000', // TODO: dynamically calculate needed amount
gas: '1200000', // TODO: dynamically calculate needed amount
payer: sender,
};

Expand Down Expand Up @@ -262,6 +264,7 @@ export class CheqdAPI extends AbstractApiProvider {
return ['cheqd'];
}

// eslint-disable-next-line
supportsIdentifier(id) {
this.ensureInitialized();
const { network } = this.sdk.options;
Expand All @@ -282,6 +285,19 @@ export class CheqdAPI extends AbstractApiProvider {
return true;
}

// Dock identifiers
if (id instanceof NamespaceDid) {
return id.isDock || id.isDidMethodKey;
} else if (id instanceof DockDidOrDidMethodKey) {
return true;
} else if (id instanceof DidRef) {
return this.supportsIdentifier(id[0]);
} else if (id instanceof TypedEnum) {
return this.supportsIdentifier(id.value);
} else if (String(id).includes(':dock:')) {
return true;
}

return false;
}
}
Expand Down
6 changes: 6 additions & 0 deletions packages/cheqd-blockchain-modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @docknetwork/cheqd-blockchain-modules

## 0.15.0

### Minor Changes

- Align with the latest `cheqd` node version (`3.1.3`)

## 0.14.1

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/cheqd-blockchain-modules/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/cheqd-blockchain-modules",
"version": "0.14.1",
"version": "0.15.0",
"type": "module",
"license": "MIT",
"main": "./dist/esm/index.js",
Expand Down Expand Up @@ -33,7 +33,7 @@
"node": ">=18.0.0"
},
"dependencies": {
"@docknetwork/credential-sdk": "0.23.0"
"@docknetwork/credential-sdk": "0.24.0"
},
"devDependencies": {
"@babel/cli": "^7.24.1",
Expand All @@ -42,7 +42,7 @@
"@babel/plugin-syntax-import-attributes": "^7.25.6",
"@babel/plugin-transform-modules-commonjs": "^7.24.1",
"@babel/preset-env": "^7.24.3",
"@docknetwork/cheqd-blockchain-api": "0.17.1",
"@docknetwork/cheqd-blockchain-api": "0.18.0",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^24.0.0",
Expand Down
11 changes: 7 additions & 4 deletions packages/cheqd-blockchain-modules/src/common/inject-params.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { TypedMap } from '@docknetwork/credential-sdk/types/generic';
import { TypedMap, TypedUUID } from '@docknetwork/credential-sdk/types/generic';
import {
withExtendedStaticProperties,
u8aToString,
} from '@docknetwork/credential-sdk/utils';
import { CheqdCreateResource } from '@docknetwork/credential-sdk/types';
import {
CheqdCreateResource,
CheqdDid,
} from '@docknetwork/credential-sdk/types';
import createInternalCheqdModule from './create-internal-cheqd-module';
import { validateResource } from './resource';

Expand All @@ -12,8 +15,8 @@ const methods = {
const { ParamsName, ParamsType, Params } = this.constructor;

return new CheqdCreateResource(
did.value.value,
id,
CheqdDid.from(did).value.value,
TypedUUID.from(id),
'1.0',
[],
ParamsName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { TypedMap } from '@docknetwork/credential-sdk/types/generic';
import { TypedMap, TypedUUID } from '@docknetwork/credential-sdk/types/generic';
import {
u8aToString,
withExtendedStaticProperties,
} from '@docknetwork/credential-sdk/utils';
import { CheqdCreateResource } from '@docknetwork/credential-sdk/types';
import {
CheqdCreateResource,
CheqdDid,
} from '@docknetwork/credential-sdk/types';
import createInternalCheqdModule from './create-internal-cheqd-module';
import { validateResource } from './resource';

const methods = {
addPublicKey(id, publicKey, did) {
return new CheqdCreateResource(
did.value.value,
id,
CheqdDid.from(did).value.value,
TypedUUID.from(id),
'1.0',
[],
this.constructor.PublicKeyName,
Expand Down
4 changes: 2 additions & 2 deletions packages/cheqd-blockchain-modules/src/common/with-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export default function withParams(klass) {
* @param didKeypair - The signer DID's keypair.
* @returns {Promise<*>}
*/
async addParamsTx(id, param, targetDid, didKeypair) {
async addParamsTx(id, params, targetDid, didKeypair) {
return await this.cheqdOnly.tx.addParams(
id,
param,
params,
targetDid,
didKeypair,
);
Expand Down
6 changes: 5 additions & 1 deletion packages/credential-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# @docknetwork/credential-sdk

## 0.23.0
## 0.24.0

### Minor Changes

- Align with the latest `cheqd` node version (`3.1.3`)

## 0.23.0

- ld.dock.io -> ld.truvera.io

## 0.22.0
Expand Down
2 changes: 1 addition & 1 deletion packages/credential-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/credential-sdk",
"version": "0.23.0",
"version": "0.24.0",
"license": "MIT",
"type": "module",
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function generateOffchainSignatureModuleTests(
new BBSPlusPublicKeyValue(TypedBytes.random(100), bbsPlusParamsRef),
);
const psKey = new PSPublicKey(
new PSPublicKeyValue(TypedBytes.random(1000), psParamsRef),
new PSPublicKeyValue(TypedBytes.random(100), psParamsRef),
);

const document = DIDDocument.create(did, [
Expand Down
52 changes: 13 additions & 39 deletions packages/credential-sdk/src/types/did/document/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
TypedArray,
TypedMap,
TypedNumber,
TypedSet,
TypedString,
Expand Down Expand Up @@ -29,7 +28,6 @@ import {
CheqdVerificationMethodRefOrCheqdMainnetVerificationMethod,
CheqdVerificationMethodRefOrCheqdTestnetVerificationMethod,
} from './verification-method-ref-or-cheqd-verification-method';
import { Ed25519Verification2018Method } from './verification-method-type';
import {
VerificationMethodRef,
CheqdVerificationMethodRef,
Expand Down Expand Up @@ -153,7 +151,7 @@ export class DIDDocument extends withFrom(
context = [CONTEXT_URI],
alsoKnownAs = [],
capabilityDelegation = [],
[ATTESTS_IRI]: attests = null,
attests = null,
} = {},
) {
const doc = new this(
Expand Down Expand Up @@ -397,18 +395,10 @@ export class CheqdDIDDocument extends TypedStruct {

const { verificationMethod } = this;

this.verificationMethod = [...verificationMethod].map((verMethod) => {
if (verMethod.isOffchain()) {
return new verMethod.constructor(
verMethod.id,
verMethod.controller,
new Ed25519Verification2018Method(),
Array(32).fill(0),
);
}

return verMethod;
});
this.verificationMethod = verificationMethod.filter(
(verMethod) => !verMethod.isOffchain()
&& !verMethod.verificationMaterial.bytes.every((item) => !item),
);
const offchainVerMethod = verificationMethod.filter((verMethod) => verMethod.isOffchain());

this.assertionMethod = [
Expand All @@ -434,32 +424,16 @@ export class CheqdDIDDocument extends TypedStruct {
service,
} = this;

const assertionMethodOffchainKeys = new (class extends TypedMap {
static KeyClass = VerificationMethodRef;

static ValueClass = CheqdVerificationMethod;
})(
[...assertionMethod]
.map((keyRefOrKey) => (keyRefOrKey instanceof CheqdVerificationMethod
? [keyRefOrKey.id, keyRefOrKey]
: null))
.filter(Boolean),
const assertionMethodOffchainKeys = [...assertionMethod].filter(
(keyRefOrKey) => keyRefOrKey.id,
);
const verificationMethodWithOffchainKeys = [
...VerificationMethods.from(verificationMethod),
].map((verMethod) => {
const offchain = assertionMethodOffchainKeys.get(verMethod.id);
if (offchain != null) {
return offchain.toVerificationMethod();
}

return verMethod;
});
const assertionMethodOnlyRefs = [...assertionMethod]
.map((keyRefOrKey) => (keyRefOrKey instanceof CheqdVerificationMethod
? keyRefOrKey.id
: keyRefOrKey))
.filter(Boolean);
...verificationMethod,
...assertionMethodOffchainKeys,
];
const assertionMethodOnlyRefs = [...assertionMethod].map(
(keyRefOrKey) => keyRefOrKey.id ?? keyRefOrKey,
);

return new DIDDocument(
context,
Expand Down
Loading

0 comments on commit c35c609

Please sign in to comment.