Skip to content

Commit d52ddcd

Browse files
authored
Merge pull request #310 from docknetwork/feat/cheqd-migration
cheqd migration
2 parents 4ab356d + 15f1b3e commit d52ddcd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1103
-314
lines changed

.github/workflows/integration-tests.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup node
2222
uses: actions/setup-node@v4
2323
with:
24-
node-version: '18.17.1'
24+
node-version: '20.2.0'
2525

2626
- name: Install GitHub CLI
2727
run: |

.github/workflows/lint-and-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup node
1717
uses: actions/setup-node@v1
1818
with:
19-
node-version: '18.17.1'
19+
node-version: '20.2.0'
2020

2121
- name: Cache dependencies
2222
uses: actions/cache@v2

.github/workflows/npm-audit.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
audit:
1818
runs-on: ubuntu-latest
1919
env:
20-
NODE_VERSION: 18.x
20+
NODE_VERSION: '20.2.0'
2121
AVOID_LICENSES: "AGPL;GPL;AGPL-3.0"
2222
IGNORE_PACKAGES: ""
2323

.github/workflows/npm-publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v1
1414
- uses: actions/setup-node@v1
1515
with:
16-
node-version: '18.x'
16+
node-version: '20.2.0'
1717
registry-url: https://registry.npmjs.org/
1818
- run: yarn install
1919
- run: yarn build

examples/verify-credential.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const {
66
didServiceRPC,
77
} = require('@docknetwork/wallet-sdk-wasm/src/services/dids');
88

9-
const {dockService} = require('@docknetwork/wallet-sdk-wasm/src/services/dock');
9+
const {blockchainService} = require('@docknetwork/wallet-sdk-wasm/src/services/blockchain');
1010

1111
const exampleCredential = require('./example-credential.json');
1212
const presentationDefinition = require('./presentation-definition.json');
@@ -19,7 +19,7 @@ async function main() {
1919

2020
console.log('Connecting to dock network');
2121

22-
await dockService.ensureDockReady();
22+
await blockchainService.ensureBlockchainReady();
2323

2424
// generate new DID
2525
const keyDoc = await didServiceRPC.generateKeyDoc({});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { IWallet } from '@docknetwork/wallet-sdk-core/lib/types';
2+
import { createVerificationController } from '@docknetwork/wallet-sdk-core/src/verification-controller';
3+
import { CheqdCredentialNonZKP, CheqdCredentialZKP } from './data/credentials/cheqd-credentials';
4+
import { closeWallet, createNewWallet, getCredentialProvider, getWallet } from './helpers';
5+
import { ProofTemplateIds, createProofRequest } from './helpers/certs-helpers';
6+
7+
describe('Cheq integration tests', () => {
8+
beforeAll(async () => {
9+
await createNewWallet();
10+
});
11+
12+
it('should verify a non ZKP cheqd credential', async () => {
13+
const wallet: IWallet = await getWallet();
14+
15+
getCredentialProvider().addCredential(CheqdCredentialNonZKP);
16+
17+
const proofRequest = await createProofRequest(
18+
ProofTemplateIds.ANY_CREDENTIAL,
19+
);
20+
21+
const result: any = await getCredentialProvider().isValid(CheqdCredentialNonZKP);
22+
23+
expect(result).toBeTruthy();
24+
25+
const controller = await createVerificationController({
26+
wallet,
27+
});
28+
29+
await controller.start({
30+
template: proofRequest,
31+
});
32+
33+
controller.selectedCredentials.set(CheqdCredentialNonZKP.id, {
34+
credential: CheqdCredentialNonZKP,
35+
});
36+
37+
const presentation = await controller.createPresentation();
38+
console.log('Presentation generated');
39+
console.log(JSON.stringify(presentation, null, 2));
40+
console.log('Sending presentation to Certs API');
41+
42+
let certsResponse;
43+
try {
44+
certsResponse = await controller.submitPresentation(presentation);
45+
console.log('CERTS response');
46+
console.log(JSON.stringify(certsResponse, null, 2));
47+
} catch (err) {
48+
certsResponse = err.response.data;
49+
console.log('Certs API returned an error');
50+
console.log(JSON.stringify(certsResponse, null, 2));
51+
}
52+
53+
expect(certsResponse.verified).toBe(true);
54+
});
55+
56+
afterAll(() => closeWallet());
57+
});

integration-tests/data/credentials/cheqd-credentials.js

+113
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration-tests/helpers/wallet-helpers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
ICredentialProvider,
2525
createCredentialProvider,
2626
} from '@docknetwork/wallet-sdk-core/src/credential-provider';
27-
import {dockService} from '@docknetwork/wallet-sdk-wasm/src/services/dock';
27+
import {blockchainService} from '@docknetwork/wallet-sdk-wasm/src/services/blockchain';
2828
import {createDataStore} from '@docknetwork/wallet-sdk-data-store-typeorm/src';
2929
import {DataStore} from '@docknetwork/wallet-sdk-data-store/src/types';
3030

@@ -131,7 +131,7 @@ export async function closeWallet(wallet?: IWallet) {
131131
setTimeout(async () => {
132132
try {
133133
wallet.dataStore.db.destroy();
134-
await dockService.disconnect();
134+
await blockchainService.disconnect();
135135
} catch (err) {
136136
console.error(err);
137137
}

integration-tests/verification-flow/bbs-plus-expired.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {createVerificationController} from '@docknetwork/wallet-sdk-core/src/ver
44
import {verifyPresentation} from '@docknetwork/sdk/utils/vc/presentations';
55
import assert from 'assert';
66
import {initializeWasm} from '@docknetwork/crypto-wasm-ts/lib/index';
7-
import { dockService } from '@docknetwork/wallet-sdk-wasm/src/services/dock';
7+
import { blockchainService } from '@docknetwork/wallet-sdk-wasm/src/services/blockchain';
88

99
const testAPIURL = process.env.TESTING_API_URL || null;
1010

@@ -129,7 +129,7 @@ describe('BBS+ presentations', () => {
129129

130130
const verificationResults = await verifyPresentation(presentation, {
131131
compactProof: true,
132-
resolver: dockService.resolver,
132+
resolver: blockchainService.resolver,
133133
challenge: proofRequest.nonce,
134134
unsignedPresentation: true,
135135
domain: 'dock.io',

integration-tests/verification-flow/bbs-plus-valid.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {IWallet} from '@docknetwork/wallet-sdk-core/lib/types';
22
import {closeWallet, getWallet} from '../helpers/wallet-helpers';
33
import {createVerificationController} from '@docknetwork/wallet-sdk-core/src/verification-controller';
44
import {verifyPresentation} from '@docknetwork/sdk/utils/vc/presentations';
5-
import { dockService } from '@docknetwork/wallet-sdk-wasm/src/services/dock';
5+
import { blockchainService } from '@docknetwork/wallet-sdk-wasm/src/services/blockchain';
66

77
const credential = {
88
'@context': [
@@ -135,7 +135,7 @@ describe('BBS+ presentations', () => {
135135

136136
const verificationResults = await verifyPresentation(presentation, {
137137
compactProof: true,
138-
resolver: dockService.resolver,
138+
resolver: blockchainService.resolver,
139139
challenge: proofRequest.nonce,
140140
unsignedPresentation: true,
141141
domain: 'dock.io',

integration-tests/verification-flow/sales-demo-auto-loan.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {IWallet} from '@docknetwork/wallet-sdk-core/lib/types';
22
import {closeWallet, getWallet} from '../helpers/wallet-helpers';
33
import {createVerificationController} from '@docknetwork/wallet-sdk-core/src/verification-controller';
44
import {verifyPresentation} from '@docknetwork/sdk/utils/vc/presentations';
5-
import {dockService} from '@docknetwork/wallet-sdk-wasm/src/services/dock';
5+
import {blockchainService} from '@docknetwork/wallet-sdk-wasm/src/services/blockchain';
66
import {autoLoanProofRequest} from './proof-requests';
77

88
const biometricCredential = {
@@ -344,7 +344,7 @@ describe('BBS+ presentations', () => {
344344

345345
const verificationResults = await verifyPresentation(presentation, {
346346
compactProof: true,
347-
resolver: dockService.resolver,
347+
resolver: blockchainService.resolver,
348348
challenge: proofRequest.nonce,
349349
unsignedPresentation: true,
350350
domain: 'dock.io',

integration-tests/wallet-backup.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {closeWallet, createNewWallet} from './helpers';
22
import {WalletBackupJSON, WalletBackupPasssword} from './data/wallet-backup';
3-
import { dockService } from '@docknetwork/wallet-sdk-wasm/lib/services/dock';
3+
import {blockchainService} from '@docknetwork/wallet-sdk-wasm/lib/services/blockchain';
44

55
describe('Wallet backups', () => {
66
it('expect to import wallet from backup', async () => {
@@ -15,7 +15,7 @@ describe('Wallet backups', () => {
1515

1616
const documents = await wallet.getAllDocuments();
1717

18-
expect(documents.length).toBe(6);
18+
expect(documents.length).toBe(7);
1919
});
2020

2121
it('expect to export wallet backup', async () => {
@@ -34,7 +34,7 @@ describe('Wallet backups', () => {
3434
});
3535

3636
afterEach(async () => {
37-
await dockService.disconnect();
37+
await blockchainService.disconnect();
3838
})
3939

4040
afterAll(() => closeWallet());

integration-tests/wallet-snapshot-v1.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Wallet Snapshot V1', () => {
2727

2828
it('expect to have load all documents', async () => {
2929
const documents = await wallet.query({});
30-
expect(documents.length).toBe(9);
30+
expect(documents.length).toBe(10);
3131
});
3232

3333
it('expect to have load accounts', async () => {

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@
108108
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
109109
"@babel/preset-flow": "^7.16.7",
110110
"@babel/preset-typescript": "^7.22.5",
111+
"@cosmjs/proto-signing": "^0.32.4",
111112
"@digitalbazaar/x25519-key-agreement-key-2020": "2.1.0",
113+
"@docknetwork/cheqd-blockchain-api": "0.14.1",
114+
"@docknetwork/cheqd-blockchain-modules": "0.11.2",
112115
"@docknetwork/credential-sdk": "0.16.0",
113116
"@docknetwork/dock-blockchain-api": "0.8.2",
114117
"@docknetwork/dock-blockchain-modules": "0.9.2",
+13-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Command} from 'commander';
22
import {typedHexDID} from '@docknetwork/sdk/utils/did/typed-did/helpers';
3-
import {dockService} from '@docknetwork/wallet-sdk-wasm/src/services/dock/service';
3+
import {blockchainService} from '@docknetwork/wallet-sdk-wasm/src/services/blockchain/service';
44
import {getWallet} from '../helpers';
55
import {getDIDKeyPairs} from '@docknetwork/wallet-sdk-core/src/did-provider';
66
import {randomAsHex} from '@polkadot/util-crypto';
@@ -18,50 +18,50 @@ ecosystemCommands
1818
const didKeyPairs = await getDIDKeyPairs({wallet});
1919
const didKeyPair = didKeyPairs[0];
2020

21-
await dockService.init({
21+
await blockchainService.init({
2222
address: 'wss://knox-1.dock.io',
2323
});
2424

25-
await dockService.waitDockReady();
26-
await dockService.ensureDockReady();
25+
await blockchainService.waitBlockchainReady();
26+
await blockchainService.ensureBlockchainReady();
2727

2828
const trustRegistryId = randomAsHex(32);
2929

30-
const trustRegistry = await dockService.dock.trustRegistry.initOrUpdate(
30+
const trustRegistry = await blockchainService.dock.trustRegistry.initOrUpdate(
3131
didKeyPair.id,
3232
trustRegistryId,
3333
'Test Registry II',
3434
'Gov framework II',
3535
didKeyPair,
36-
dockService.dock,
36+
blockchainService.dock,
3737
);
3838
console.log(trustRegistry);
3939

40-
await dockService.disconnect();
40+
await blockchainService.disconnect();
4141
});
4242

4343
ecosystemCommands
4444
.command('getEcosystemFromDID')
4545
.option('-d, --did <did>', 'DID')
4646
.description('Get ecosystem from issuer DID')
4747
.action(async ({did}) => {
48-
await dockService.init({
48+
await blockchainService.init({
4949
address: 'wss://knox-1.dock.io',
5050
});
5151

52-
await dockService.waitDockReady();
53-
await dockService.ensureDockReady();
52+
await blockchainService.waitBlockchainReady();
53+
await blockchainService.ensureBlockchainReady();
5454

5555
const issuerDIDMethodKey = typedHexDID(
56-
dockService.dock.api,
56+
blockchainService.dock.api,
5757
did,
5858
);
59-
const registryInfo = await dockService.dock.trustRegistry?.registriesInfo({
59+
const registryInfo = await blockchainService.dock.trustRegistry?.registriesInfo({
6060
Issuer: issuerDIDMethodKey,
6161
});
6262
console.log(registryInfo);
6363

64-
await dockService.disconnect();
64+
await blockchainService.disconnect();
6565
});
6666

6767
export {ecosystemCommands};

packages/core/src/credential-provider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {credentialServiceRPC} from '@docknetwork/wallet-sdk-wasm/src/services/credential';
22
import {IWallet} from './types';
33
import assert from 'assert';
4-
import {dockService} from '@docknetwork/wallet-sdk-wasm/src/services/dock';
4+
import {blockchainService} from '@docknetwork/wallet-sdk-wasm/src/services/blockchain';
55
import {acquireOpenIDCredentialFromURI} from './credentials/oidvc';
66
import {IDIDProvider} from './did-provider';
77

@@ -259,7 +259,7 @@ async function syncCredentialStatus({
259259
}
260260

261261
if (!isApiConnected) {
262-
await dockService.ensureDockReady();
262+
await blockchainService.ensureBlockchainReady();
263263
isApiConnected = true;
264264
}
265265

packages/core/src/ecosystem-tools.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import {dockService} from '@docknetwork/wallet-sdk-wasm/src/services/dock';
2-
import {trustRegistryService} from '@docknetwork/wallet-sdk-wasm/src/services/trust-registry';
31
import assert from 'assert';
42
import axios from 'axios';
53

0 commit comments

Comments
 (0)