Skip to content

Commit

Permalink
Use latest cheqd node for tests (#489)
Browse files Browse the repository at this point in the history
* Use latest `cheqd` node

* Include `IMAGE_TAG`

* Include `IMAGE_TAG` in `turbo` call

* Modify the `SDK` to be compatible with the most recent `cheqd` node.

* Update snapshots

* Correct `IMAGE_TAG`

* Switch to `cjs` tag

* Bump up version

* Improve `filterObj`

* Enable cache for build
  • Loading branch information
olegnn authored Dec 4, 2024
1 parent 1125140 commit 75d555e
Show file tree
Hide file tree
Showing 24 changed files with 249 additions and 162 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cheqd-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +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
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand All @@ -14,4 +15,4 @@ jobs:
- run: yarn install --frozen-lockfile --ignore-scripts
- run: npm install -g [email protected]
- run: turbo telemetry disable
- run: CHEQD_MNEMONIC=$CHEQD_MNEMONIC turbo run test-with-node --filter @docknetwork/cheqd-blockchain-modules
- run: CHEQD_MNEMONIC=$CHEQD_MNEMONIC IMAGE_TAG=$IMAGE_TAG turbo run test-with-node --filter @docknetwork/cheqd-blockchain-modules
11 changes: 10 additions & 1 deletion examples/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @docknetwork/sdk-examples

## 0.6.1

### Patch Changes

- Updated dependencies
- @docknetwork/credential-sdk@0.15.0
- @docknetwork/dock-blockchain-api@0.8.1
- @docknetwork/dock-blockchain-modules@0.9.1

## 0.6.0

### Minor Changes
Expand All @@ -13,12 +22,12 @@
- @docknetwork/dock-blockchain-api@0.8.0
- @docknetwork/credential-sdk@0.14.0


## 0.5.2

### Patch Changes

- Updated dependencies

- @docknetwork/dock-blockchain-api@0.7.0
- @docknetwork/credential-sdk@0.13.0
- @docknetwork/dock-blockchain-modules@0.8.1
Expand Down
8 changes: 4 additions & 4 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@docknetwork/sdk-examples",
"private": true,
"type": "module",
"version": "0.6.0",
"version": "0.6.1",
"scripts": {
"bbs-dock-example": "babel-node ./bbs-dock.js",
"claim-deduction-example": "babel-node ./claim-deduction.js",
Expand All @@ -19,9 +19,9 @@
"lint": "eslint \"*.js\""
},
"dependencies": {
"@docknetwork/credential-sdk": "0.14.0",
"@docknetwork/dock-blockchain-api": "0.8.0",
"@docknetwork/dock-blockchain-modules": "0.9.0"
"@docknetwork/credential-sdk": "0.15.0",
"@docknetwork/dock-blockchain-api": "0.8.1",
"@docknetwork/dock-blockchain-modules": "0.9.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.16.0",
"version": "0.17.0",
"private": true,
"workspaces": [
"packages/*",
Expand Down
11 changes: 11 additions & 0 deletions packages/cheqd-blockchain-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @docknetwork/cheqd-blockchain-api

## 0.14.0

### Minor Changes

- Modify the `SDK` to be compatible with the most recent `cheqd` node.

### Patch Changes

- Updated dependencies
- @docknetwork/credential-sdk@0.15.0

## 0.13.0

### Minor Changes
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.13.0",
"version": "0.14.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.14.0"
"@docknetwork/credential-sdk": "0.15.0"
},
"devDependencies": {
"@babel/cli": "^7.24.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/cheqd-blockchain-modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @docknetwork/cheqd-blockchain-modules

## 0.11.1

### Patch Changes

- Updated dependencies
- @docknetwork/credential-sdk@0.15.0

## 0.11.0

### Minor 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.11.0",
"version": "0.11.1",
"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.14.0"
"@docknetwork/credential-sdk": "0.15.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.13.0",
"@docknetwork/cheqd-blockchain-api": "0.14.0",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^24.0.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/credential-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @docknetwork/credential-sdk

## 0.15.0

### Minor Changes

- Modify the `SDK` to be compatible with the most recent `cheqd` node.

## 0.14.0

### Minor Changes
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.14.0",
"version": "0.15.0",
"license": "MIT",
"type": "module",
"files": [
Expand Down
101 changes: 67 additions & 34 deletions packages/credential-sdk/src/types/did/document/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
TypedArray,
TypedMap,
TypedSet,
TypedString,
TypedStruct,
Expand All @@ -10,8 +11,9 @@ import { NamespaceDid } from '../onchain/typed-did';
import { DidKey, DidKeys } from '../onchain/did-key';
import { VerificationRelationship } from '../onchain/verification-relationship';
import { Service, CheqdService } from './service';
import { VerificationMethod, CheqdVerificationMethod, VerificationMethodRefWithDidKey } from './verification-method';
import VerificationMethodRefOrDidKey from './verification-method-ref-or-did-key';
import { VerificationMethod, CheqdVerificationMethod } from './verification-method';
import VerificationMethodRefOrCheqdVerificationMethod from './verification-method-ref-or-cheqd-verification-method';
import { Ed25519Verification2018Method } from './verification-method-type';
import VerificationMethodRef from './verification-method-ref';
import { ATTESTS_IRI, CONTEXT_URI } from './const';

Expand All @@ -33,6 +35,10 @@ class VerificationMethods extends TypedArray {
static Class = VerificationMethod;
}

class CheqdVerificationMethods extends TypedArray {
static Class = CheqdVerificationMethod;
}

export class Services extends TypedArray {
static Class = Service;
}
Expand All @@ -43,8 +49,8 @@ export class VerificationMethodReferences extends TypedArray {

export class VersionId extends TypedUUID {}

class AssertionMethod extends TypedArray {
static Class = VerificationMethodRefOrDidKey;
class CheqdAssertionMethod extends TypedArray {
static Class = VerificationMethodRefOrCheqdVerificationMethod;
}

export class DIDDocument extends TypedStruct {
Expand Down Expand Up @@ -225,14 +231,14 @@ export class DIDDocument extends TypedStruct {
capabilityInvocation,
} = this;

class VerificationMethodRefOrDidKeySet extends TypedSet {
static Class = VerificationMethodRefOrDidKey;
class VerificationMethodRefOrCheqdVerificationMethodSet extends TypedSet {
static Class = VerificationMethodRefOrCheqdVerificationMethod;
}

const auth = new VerificationMethodRefOrDidKeySet(authentication);
const assertion = new VerificationMethodRefOrDidKeySet(assertionMethod);
const keyAgr = new VerificationMethodRefOrDidKeySet(keyAgreement);
const capInv = new VerificationMethodRefOrDidKeySet(capabilityInvocation);
const auth = new VerificationMethodRefOrCheqdVerificationMethodSet(authentication);
const assertion = new VerificationMethodRefOrCheqdVerificationMethodSet(assertionMethod);
const keyAgr = new VerificationMethodRefOrCheqdVerificationMethodSet(keyAgreement);
const capInv = new VerificationMethodRefOrCheqdVerificationMethodSet(capabilityInvocation);

const keys = [...verificationMethod]
.map((method) => {
Expand Down Expand Up @@ -295,14 +301,12 @@ export class CheqdDIDDocument extends TypedStruct {
id: ID,
alsoKnownAs: AlsoKnownAs,
controller: Controllers,
verificationMethod: class CheqdVerificationMethods extends TypedArray {
static Class = CheqdVerificationMethod;
},
verificationMethod: CheqdVerificationMethods,
service: class CheqdServices extends TypedArray {
static Class = CheqdService;
},
authentication: VerificationMethodReferences,
assertionMethod: AssertionMethod,
assertionMethod: CheqdAssertionMethod,
keyAgreement: VerificationMethodReferences,
capabilityInvocation: VerificationMethodReferences,
capabilityDelegation: VerificationMethodReferences,
Expand All @@ -314,7 +318,7 @@ export class CheqdDIDDocument extends TypedStruct {
id,
alsoKnownAs,
controller,
rawVerificationMethodWithOffchainKeys,
rawVerificationMethod,
service,
authentication,
assertionMethodWithOffchainKeys,
Expand All @@ -323,29 +327,42 @@ export class CheqdDIDDocument extends TypedStruct {
capabilityDelegation,
versionId = TypedUUID.random(),
) {
const verificationMethodWithOffchainKeys = [...rawVerificationMethodWithOffchainKeys].map((verMethod) => CheqdVerificationMethod.from(verMethod));
const verificationMethod = CheqdVerificationMethods.from(rawVerificationMethod);
const mappedVerificationMethod = [...verificationMethod].map(
(verMethod) => {
if (verMethod.isOffchain()) {
return new CheqdVerificationMethod(
verMethod.id,
verMethod.controller,
new Ed25519Verification2018Method(),
Array(32).fill(0),
);
}

const offchainVerMethod = verificationMethodWithOffchainKeys.filter((verMethod) => verMethod.isOffchain());
const verificationMethod = verificationMethodWithOffchainKeys.filter(
(verMethod) => !verMethod.isOffchain(),
return verMethod;
},
);
const offchainVerMethod = verificationMethod.filter((verMethod) => verMethod.isOffchain());

const assertionMethod = [
...AssertionMethod.from(assertionMethodWithOffchainKeys).filter((ref) => !offchainVerMethod.some((verMethod) => verMethod.id.eq(ref))),
...[...offchainVerMethod].map((verMethod) => verMethod.toVerificationMethod().toVerificationMethodRefWithDidKey()),
...CheqdAssertionMethod.from(assertionMethodWithOffchainKeys.filter((ref) => !offchainVerMethod.some((verMethod) => verMethod.id.eq(ref)))),
...offchainVerMethod,
];

super(context,
super(
context,
id,
alsoKnownAs,
controller,
verificationMethod,
mappedVerificationMethod,
service,
authentication,
assertionMethod,
keyAgreement,
capabilityInvocation,
capabilityDelegation,
versionId);
versionId,
);
}

toDIDDocument() {
Expand All @@ -363,24 +380,40 @@ export class CheqdDIDDocument extends TypedStruct {
service,
} = this;

const offchainVerMethod = [
...assertionMethod.filter(
(keyRefOrKey) => keyRefOrKey instanceof VerificationMethodRefWithDidKey,
),
].map((verMethod) => verMethod.toVerificationMethod());
const assertionMethodWithoutOffchainKeys = [...assertionMethod].map(
(keyRefOrKey) => (keyRefOrKey instanceof VerificationMethodRefWithDidKey ? keyRefOrKey.ref : keyRefOrKey),
);
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 verificationMethodWithOffchainKeys = [...VerificationMethods.from(verificationMethod)].map((verMethod) => {
const offchain = assertionMethodOffchainKeys.get(verMethod.id);

if (offchain != null) {
return new VerificationMethod(
verMethod.id,
offchain.verificationMethodType,
verMethod.controller,
offchain.verificationMaterial,
);
}

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

return new DIDDocument(
context,
id,
alsoKnownAs,
controller,
[...verificationMethod, ...offchainVerMethod],
verificationMethodWithOffchainKeys,
service,
authentication,
assertionMethodWithoutOffchainKeys,
assertionMethodOnlyRefs,
keyAgreement,
capabilityInvocation,
capabilityDelegation,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import VerificationMethodRef from './verification-method-ref';
import { CheqdVerificationMethod } from './verification-method';
import { withFrom } from '../../generic';

export default class VerificationMethodRefOrCheqdVerificationMethod extends withFrom(
VerificationMethodRef,
(value, from) => {
try {
return class CheqdVerificationMethodToJSONString extends CheqdVerificationMethod {
toJSON() {
return JSON.stringify(JSON.stringify(super.toJSON()));
}

static from(obj) {
return typeof obj === 'string' ? super.fromJSON(JSON.parse(JSON.parse(obj))) : super.from(obj);
}
}.from(value);
} catch {
return from(value);
}
},
) {}

This file was deleted.

Loading

0 comments on commit 75d555e

Please sign in to comment.