@docknetwork/wallet-sdk-wasm 1.4.0 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{account-3c88155a.js → account-bf00e5c0.js} +5 -5
- package/lib/{account-8f5cbc4d.js → account-e48dc9b6.js} +5 -5
- package/lib/core/polkadot-utils.js +18 -4
- package/lib/core/polkadot-utils.mjs +15 -2
- package/lib/index.js +14 -17
- package/lib/index.mjs +14 -17
- package/lib/modules/account.js +9 -5
- package/lib/modules/account.mjs +9 -5
- package/lib/modules/accounts.js +9 -5
- package/lib/modules/accounts.mjs +9 -5
- package/lib/modules/network-manager.js +4 -2
- package/lib/modules/network-manager.mjs +4 -2
- package/lib/modules/wallet.js +12 -8
- package/lib/modules/wallet.mjs +12 -8
- package/lib/rpc-server.js +14 -17
- package/lib/rpc-server.mjs +14 -17
- package/lib/services/blockchain/configs.js +7 -0
- package/lib/services/blockchain/configs.mjs +3 -0
- package/lib/services/{dock → blockchain}/index.android.js +3 -4
- package/lib/services/{dock → blockchain}/index.android.mjs +3 -4
- package/lib/services/{dock → blockchain}/index.ios.js +3 -4
- package/lib/services/{dock → blockchain}/index.ios.mjs +3 -4
- package/lib/services/blockchain/index.js +30 -0
- package/lib/services/blockchain/index.mjs +22 -0
- package/lib/services/{dock → blockchain}/service-rpc.js +5 -7
- package/lib/services/{dock → blockchain}/service-rpc.mjs +5 -7
- package/lib/services/blockchain/service.js +212 -0
- package/lib/services/blockchain/service.mjs +206 -0
- package/lib/services/credential/bbs-revocation.js +33 -61
- package/lib/services/credential/bbs-revocation.mjs +34 -62
- package/lib/services/credential/bound-check.js +0 -8
- package/lib/services/credential/bound-check.mjs +1 -5
- package/lib/services/credential/index.js +20 -23
- package/lib/services/credential/index.mjs +20 -23
- package/lib/services/credential/pex-helpers.js +134 -34
- package/lib/services/credential/pex-helpers.mjs +133 -35
- package/lib/services/credential/service.js +54 -55
- package/lib/services/credential/service.mjs +43 -41
- package/lib/services/credential/utils.js +12 -18
- package/lib/services/credential/utils.mjs +11 -14
- package/lib/services/dids/config.js +8 -0
- package/lib/services/dids/config.mjs +8 -0
- package/lib/services/dids/index.js +8 -7
- package/lib/services/dids/index.mjs +8 -7
- package/lib/services/dids/service-rpc.js +2 -2
- package/lib/services/dids/service-rpc.mjs +2 -2
- package/lib/services/dids/service.js +22 -32
- package/lib/services/dids/service.mjs +22 -32
- package/lib/services/edv/hmac.js +5 -0
- package/lib/services/edv/hmac.mjs +5 -0
- package/lib/services/edv/index.js +10 -8
- package/lib/services/edv/index.mjs +10 -8
- package/lib/services/edv/service-rpc.js +4 -0
- package/lib/services/edv/service-rpc.mjs +4 -0
- package/lib/services/edv/service.js +26 -10
- package/lib/services/edv/service.mjs +25 -10
- package/lib/services/example/service.js +3 -1
- package/lib/services/example/service.mjs +3 -1
- package/lib/services/index.js +12 -15
- package/lib/services/index.mjs +12 -15
- package/lib/services/keyring/configs.js +12 -0
- package/lib/services/keyring/configs.mjs +12 -0
- package/lib/services/keyring/service.js +5 -0
- package/lib/services/keyring/service.mjs +5 -0
- package/lib/services/pex/service.js +17 -15
- package/lib/services/pex/service.mjs +17 -15
- package/lib/services/substrate/api-utils.js +18 -6
- package/lib/services/substrate/api-utils.mjs +18 -6
- package/lib/services/substrate/index.js +13 -6
- package/lib/services/substrate/index.mjs +13 -6
- package/lib/services/substrate/service.js +16 -9
- package/lib/services/substrate/service.mjs +16 -9
- package/lib/services/test-utils.js +27 -18
- package/lib/services/test-utils.mjs +27 -18
- package/lib/services/trust-registry/index.js +16 -5
- package/lib/services/trust-registry/index.mjs +16 -5
- package/lib/services/trust-registry/service.js +26 -10
- package/lib/services/trust-registry/service.mjs +26 -10
- package/lib/services/util-crypto/configs.js +3 -0
- package/lib/services/util-crypto/configs.mjs +3 -0
- package/lib/services/util-crypto/service-rpc.js +6 -0
- package/lib/services/util-crypto/service-rpc.mjs +6 -0
- package/lib/services/util-crypto/service.js +5 -0
- package/lib/services/util-crypto/service.mjs +6 -1
- package/lib/setup-nodejs.js +14 -17
- package/lib/setup-nodejs.mjs +14 -17
- package/lib/setup-tests.js +14 -17
- package/lib/setup-tests.mjs +14 -17
- package/lib/src/core/polkadot-utils.d.ts +1 -0
- package/lib/src/core/polkadot-utils.d.ts.map +1 -1
- package/lib/src/modules/network-manager.d.ts +1 -0
- package/lib/src/modules/network-manager.d.ts.map +1 -1
- package/lib/src/services/blockchain/configs.d.ts +8 -0
- package/lib/src/services/blockchain/configs.d.ts.map +1 -0
- package/lib/src/services/blockchain/index.d.ts +2 -0
- package/lib/src/services/blockchain/index.d.ts.map +1 -0
- package/lib/src/services/{dock → blockchain}/service.d.ts +12 -11
- package/lib/src/services/blockchain/service.d.ts.map +1 -0
- package/lib/src/services/credential/bbs-revocation.d.ts.map +1 -1
- package/lib/src/services/credential/bound-check.d.ts +0 -4
- package/lib/src/services/credential/bound-check.d.ts.map +1 -1
- package/lib/src/services/credential/index.d.ts +2 -7
- package/lib/src/services/credential/index.d.ts.map +1 -1
- package/lib/src/services/credential/pex-helpers.d.ts +5 -3
- package/lib/src/services/credential/pex-helpers.d.ts.map +1 -1
- package/lib/src/services/credential/service.d.ts +2 -7
- package/lib/src/services/credential/service.d.ts.map +1 -1
- package/lib/src/services/credential/utils.d.ts.map +1 -1
- package/lib/src/services/dids/config.d.ts +5 -0
- package/lib/src/services/dids/config.d.ts.map +1 -1
- package/lib/src/services/dids/service-rpc.d.ts +1 -1
- package/lib/src/services/dids/service-rpc.d.ts.map +1 -1
- package/lib/src/services/dids/service.d.ts +9 -7
- package/lib/src/services/dids/service.d.ts.map +1 -1
- package/lib/src/services/edv/hmac.d.ts +1 -0
- package/lib/src/services/edv/hmac.d.ts.map +1 -1
- package/lib/src/services/edv/service.d.ts +5 -0
- package/lib/src/services/edv/service.d.ts.map +1 -1
- package/lib/src/services/example/service.d.ts.map +1 -1
- package/lib/src/services/keyring/configs.d.ts +6 -0
- package/lib/src/services/keyring/configs.d.ts.map +1 -1
- package/lib/src/services/pex/service.d.ts.map +1 -1
- package/lib/src/services/trust-registry/service.d.ts.map +1 -1
- package/lib/src/services/util-crypto/configs.d.ts +1 -0
- package/lib/src/services/util-crypto/configs.d.ts.map +1 -1
- package/lib/src/services/util-crypto/service.d.ts +1 -0
- package/lib/src/services/util-crypto/service.d.ts.map +1 -1
- package/lib/test/setup-test-state.js +10 -6
- package/lib/test/setup-test-state.mjs +10 -6
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -7
- package/src/core/polkadot-utils.js +14 -3
- package/src/modules/network-manager.ts +5 -2
- package/src/modules/wallet.ts +5 -5
- package/src/services/blockchain/configs.ts +11 -0
- package/src/services/blockchain/index.android.js +3 -0
- package/src/services/blockchain/index.ios.js +3 -0
- package/src/services/blockchain/index.js +1 -0
- package/src/services/blockchain/index.test.js +34 -0
- package/src/services/{dock → blockchain}/service-rpc.js +5 -6
- package/src/services/blockchain/service.ts +261 -0
- package/src/services/credential/bbs-revocation.ts +42 -90
- package/src/services/credential/bound-check.test.ts +2 -5
- package/src/services/credential/bound-check.ts +0 -5
- package/src/services/credential/index.test.js +148 -7
- package/src/services/credential/pex-helpers.js +132 -34
- package/src/services/credential/pex-helpers.test.js +284 -27
- package/src/services/credential/service.ts +44 -27
- package/src/services/credential/utils.js +5 -14
- package/src/services/dids/config.ts +15 -0
- package/src/services/dids/index.test.js +5 -46
- package/src/services/dids/service-rpc.ts +2 -2
- package/src/services/dids/service.ts +17 -34
- package/src/services/edv/hmac.ts +13 -0
- package/src/services/edv/index.test.js +22 -0
- package/src/services/edv/service-rpc.js +4 -0
- package/src/services/edv/service.ts +22 -0
- package/src/services/example/service.ts +3 -1
- package/src/services/index.js +2 -2
- package/src/services/keyring/configs.ts +21 -0
- package/src/services/keyring/service.ts +13 -0
- package/src/services/pex/service.ts +29 -18
- package/src/services/pex/tests/pex-service.test.js +163 -6
- package/src/services/substrate/api-utils.test.js +7 -7
- package/src/services/substrate/api-utils.ts +3 -3
- package/src/services/substrate/service.ts +6 -6
- package/src/services/test-utils.js +13 -11
- package/src/services/trust-registry/index.test.js +6 -4
- package/src/services/trust-registry/service.ts +13 -7
- package/src/services/util-crypto/configs.ts +4 -0
- package/src/services/util-crypto/service-rpc.js +6 -0
- package/src/services/util-crypto/service.ts +8 -0
- package/src/test/setup-test-state.js +2 -2
- package/lib/services/dock/configs.js +0 -18
- package/lib/services/dock/configs.mjs +0 -10
- package/lib/services/dock/index.js +0 -18
- package/lib/services/dock/index.mjs +0 -10
- package/lib/services/dock/service.js +0 -136
- package/lib/services/dock/service.mjs +0 -128
- package/lib/src/services/dock/configs.d.ts +0 -7
- package/lib/src/services/dock/configs.d.ts.map +0 -1
- package/lib/src/services/dock/index.d.ts +0 -2
- package/lib/src/services/dock/index.d.ts.map +0 -1
- package/lib/src/services/dock/service.d.ts.map +0 -1
- package/src/services/dock/configs.ts +0 -12
- package/src/services/dock/index.android.js +0 -3
- package/src/services/dock/index.ios.js +0 -3
- package/src/services/dock/index.js +0 -1
- package/src/services/dock/index.test.js +0 -48
- package/src/services/dock/service.ts +0 -159
package/lib/rpc-server.mjs
CHANGED
|
@@ -12,14 +12,21 @@ import './services/keyring/configs.mjs';
|
|
|
12
12
|
import './core/validation.mjs';
|
|
13
13
|
import 'bignumber.js';
|
|
14
14
|
import './types.mjs';
|
|
15
|
-
import './services/
|
|
16
|
-
import '@
|
|
15
|
+
import './services/blockchain/service.mjs';
|
|
16
|
+
import '@cosmjs/proto-signing';
|
|
17
|
+
import '@docknetwork/cheqd-blockchain-api';
|
|
18
|
+
import '@docknetwork/cheqd-blockchain-modules';
|
|
19
|
+
import '@docknetwork/credential-sdk/modules';
|
|
17
20
|
import '@docknetwork/credential-sdk/resolver';
|
|
18
|
-
import '@docknetwork/dock-blockchain-modules';
|
|
19
21
|
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
22
|
+
import '@docknetwork/dock-blockchain-api';
|
|
23
|
+
import '@docknetwork/dock-blockchain-modules';
|
|
20
24
|
import 'events';
|
|
21
25
|
import './modules/event-manager.mjs';
|
|
22
|
-
import './services/
|
|
26
|
+
import './services/util-crypto/service.mjs';
|
|
27
|
+
import '@polkadot/util';
|
|
28
|
+
import './services/util-crypto/configs.mjs';
|
|
29
|
+
import '@docknetwork/credential-sdk/types';
|
|
23
30
|
import './services/substrate/service.mjs';
|
|
24
31
|
import 'bn.js';
|
|
25
32
|
import './core/format-utils.mjs';
|
|
@@ -38,33 +45,23 @@ import './services/wallet/configs.mjs';
|
|
|
38
45
|
import './services/polkadot/service.mjs';
|
|
39
46
|
import '@polkadot/ui-shared/cjs/icons/index';
|
|
40
47
|
import './services/polkadot/configs.mjs';
|
|
41
|
-
import './services/util-crypto/service.mjs';
|
|
42
|
-
import '@polkadot/util';
|
|
43
|
-
import './services/util-crypto/configs.mjs';
|
|
44
48
|
import './services/dids/service.mjs';
|
|
45
49
|
import '@docknetwork/wallet-sdk-dids/lib';
|
|
46
50
|
import './services/dids/config.mjs';
|
|
47
|
-
import '@docknetwork/credential-sdk/types';
|
|
48
|
-
import '@docknetwork/credential-sdk/keypairs';
|
|
49
51
|
import './core/polkadot-utils.mjs';
|
|
52
|
+
import '@docknetwork/credential-sdk/keypairs';
|
|
50
53
|
import '@polkadot/keyring/pair/decode';
|
|
51
|
-
import '@docknetwork/sdk/utils/misc';
|
|
52
54
|
import 'base58-universal';
|
|
53
55
|
import '@docknetwork/universal-wallet/methods/keypairs';
|
|
54
56
|
import 'base64url';
|
|
55
57
|
import './services/credential/utils.mjs';
|
|
56
|
-
import '@docknetwork/sdk/utils/vc/crypto/Bls12381G2KeyPairDock2022';
|
|
57
58
|
import '@docknetwork/credential-sdk/vc/crypto';
|
|
58
59
|
import './services/credential/service.mjs';
|
|
59
60
|
import './services/credential/config.mjs';
|
|
60
61
|
import '@docknetwork/crypto-wasm-ts';
|
|
61
62
|
import '@sphereon/oid4vci-client';
|
|
62
63
|
import '@sphereon/oid4vci-common';
|
|
63
|
-
import '@docknetwork/sdk/
|
|
64
|
-
import '@docknetwork/sdk/utils/vc/helpers';
|
|
65
|
-
import '@docknetwork/sdk/verifiable-presentation';
|
|
66
|
-
import '@docknetwork/sdk/presentation';
|
|
67
|
-
import '@docknetwork/sdk/utils/vc/credentials';
|
|
64
|
+
import '@docknetwork/credential-sdk/vc';
|
|
68
65
|
import '@sphereon/pex';
|
|
69
66
|
import './services/credential/bound-check.mjs';
|
|
70
67
|
import '@docknetwork/crypto-wasm-ts/lib/legosnark';
|
|
@@ -78,7 +75,6 @@ import './services/pex/service.mjs';
|
|
|
78
75
|
import './services/pex/config.mjs';
|
|
79
76
|
import './services/trust-registry/service.mjs';
|
|
80
77
|
import './services/trust-registry/configs.mjs';
|
|
81
|
-
import '@docknetwork/sdk/utils/did/typed-did/helpers';
|
|
82
78
|
import './services/edv/service.mjs';
|
|
83
79
|
import './services/edv/configs.mjs';
|
|
84
80
|
import '@docknetwork/universal-wallet/storage/edv-http-storage';
|
|
@@ -86,6 +82,7 @@ import './services/edv/hmac.mjs';
|
|
|
86
82
|
import 'base64url-universal';
|
|
87
83
|
import '@docknetwork/universal-wallet/crypto';
|
|
88
84
|
import '@digitalbazaar/ed25519-verification-key-2018';
|
|
85
|
+
import '@digitalbazaar/ed25519-verification-key-2020';
|
|
89
86
|
import '@digitalbazaar/x25519-key-agreement-key-2020';
|
|
90
87
|
import '@docknetwork/wallet-sdk-data-store/lib/logger';
|
|
91
88
|
import '@docknetwork/wallet-sdk-wasm/lib/services/keyring';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var services_blockchain_serviceRpc = require('./service-rpc.js');
|
|
6
6
|
require('../rpc-service-client.js');
|
|
7
7
|
require('assert');
|
|
8
8
|
require('../../rpc-client.js');
|
|
@@ -12,8 +12,7 @@ require('crypto');
|
|
|
12
12
|
require('../../core/logger.js');
|
|
13
13
|
require('../../logger.js');
|
|
14
14
|
require('../../rpc-util.js');
|
|
15
|
-
require('./configs.js');
|
|
16
15
|
|
|
17
|
-
const
|
|
16
|
+
const blockchainService = new services_blockchain_serviceRpc.BlockchainServiceRpc();
|
|
18
17
|
|
|
19
|
-
exports.
|
|
18
|
+
exports.blockchainService = blockchainService;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockchainServiceRpc } from './service-rpc.mjs';
|
|
2
2
|
import '../rpc-service-client.mjs';
|
|
3
3
|
import 'assert';
|
|
4
4
|
import '../../rpc-client.mjs';
|
|
@@ -8,8 +8,7 @@ import 'crypto';
|
|
|
8
8
|
import '../../core/logger.mjs';
|
|
9
9
|
import '../../logger.mjs';
|
|
10
10
|
import '../../rpc-util.mjs';
|
|
11
|
-
import './configs.mjs';
|
|
12
11
|
|
|
13
|
-
const
|
|
12
|
+
const blockchainService = new BlockchainServiceRpc();
|
|
14
13
|
|
|
15
|
-
export {
|
|
14
|
+
export { blockchainService };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var services_blockchain_serviceRpc = require('./service-rpc.js');
|
|
6
6
|
require('../rpc-service-client.js');
|
|
7
7
|
require('assert');
|
|
8
8
|
require('../../rpc-client.js');
|
|
@@ -12,8 +12,7 @@ require('crypto');
|
|
|
12
12
|
require('../../core/logger.js');
|
|
13
13
|
require('../../logger.js');
|
|
14
14
|
require('../../rpc-util.js');
|
|
15
|
-
require('./configs.js');
|
|
16
15
|
|
|
17
|
-
const
|
|
16
|
+
const blockchainService = new services_blockchain_serviceRpc.BlockchainServiceRpc();
|
|
18
17
|
|
|
19
|
-
exports.
|
|
18
|
+
exports.blockchainService = blockchainService;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockchainServiceRpc } from './service-rpc.mjs';
|
|
2
2
|
import '../rpc-service-client.mjs';
|
|
3
3
|
import 'assert';
|
|
4
4
|
import '../../rpc-client.mjs';
|
|
@@ -8,8 +8,7 @@ import 'crypto';
|
|
|
8
8
|
import '../../core/logger.mjs';
|
|
9
9
|
import '../../logger.mjs';
|
|
10
10
|
import '../../rpc-util.mjs';
|
|
11
|
-
import './configs.mjs';
|
|
12
11
|
|
|
13
|
-
const
|
|
12
|
+
const blockchainService = new BlockchainServiceRpc();
|
|
14
13
|
|
|
15
|
-
export {
|
|
14
|
+
export { blockchainService };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var services_blockchain_service = require('./service.js');
|
|
6
|
+
require('@cosmjs/proto-signing');
|
|
7
|
+
require('@docknetwork/cheqd-blockchain-api');
|
|
8
|
+
require('@docknetwork/cheqd-blockchain-modules');
|
|
9
|
+
require('@docknetwork/credential-sdk/modules');
|
|
10
|
+
require('@docknetwork/credential-sdk/resolver');
|
|
11
|
+
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
12
|
+
require('@docknetwork/dock-blockchain-api');
|
|
13
|
+
require('@docknetwork/dock-blockchain-modules');
|
|
14
|
+
require('events');
|
|
15
|
+
require('../../core/logger.js');
|
|
16
|
+
require('../../modules/event-manager.js');
|
|
17
|
+
require('assert');
|
|
18
|
+
require('../util-crypto/service.js');
|
|
19
|
+
require('@polkadot/keyring');
|
|
20
|
+
require('@polkadot/util');
|
|
21
|
+
require('@polkadot/util-crypto');
|
|
22
|
+
require('../util-crypto/configs.js');
|
|
23
|
+
require('../../core/validation.js');
|
|
24
|
+
require('bignumber.js');
|
|
25
|
+
require('../../types.js');
|
|
26
|
+
require('@docknetwork/credential-sdk/types');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
exports.blockchainService = services_blockchain_service.blockchainService;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { blockchainService } from './service.mjs';
|
|
2
|
+
import '@cosmjs/proto-signing';
|
|
3
|
+
import '@docknetwork/cheqd-blockchain-api';
|
|
4
|
+
import '@docknetwork/cheqd-blockchain-modules';
|
|
5
|
+
import '@docknetwork/credential-sdk/modules';
|
|
6
|
+
import '@docknetwork/credential-sdk/resolver';
|
|
7
|
+
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
8
|
+
import '@docknetwork/dock-blockchain-api';
|
|
9
|
+
import '@docknetwork/dock-blockchain-modules';
|
|
10
|
+
import 'events';
|
|
11
|
+
import '../../core/logger.mjs';
|
|
12
|
+
import '../../modules/event-manager.mjs';
|
|
13
|
+
import 'assert';
|
|
14
|
+
import '../util-crypto/service.mjs';
|
|
15
|
+
import '@polkadot/keyring';
|
|
16
|
+
import '@polkadot/util';
|
|
17
|
+
import '@polkadot/util-crypto';
|
|
18
|
+
import '../util-crypto/configs.mjs';
|
|
19
|
+
import '../../core/validation.mjs';
|
|
20
|
+
import 'bignumber.js';
|
|
21
|
+
import '../../types.mjs';
|
|
22
|
+
import '@docknetwork/credential-sdk/types';
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var services_rpcServiceClient = require('../rpc-service-client.js');
|
|
6
|
-
var services_dock_configs = require('./configs.js');
|
|
7
6
|
require('assert');
|
|
8
7
|
require('../../rpc-client.js');
|
|
9
8
|
require('json-rpc-2.0');
|
|
@@ -16,9 +15,9 @@ require('../../rpc-util.js');
|
|
|
16
15
|
/**
|
|
17
16
|
*
|
|
18
17
|
*/
|
|
19
|
-
class
|
|
18
|
+
class BlockchainServiceRpc extends services_rpcServiceClient.RpcService {
|
|
20
19
|
constructor() {
|
|
21
|
-
super('
|
|
20
|
+
super('blockchain');
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -31,15 +30,14 @@ class DockServiceRpc extends services_rpcServiceClient.RpcService {
|
|
|
31
30
|
/**
|
|
32
31
|
*
|
|
33
32
|
*/
|
|
34
|
-
|
|
35
|
-
return this.call('
|
|
33
|
+
ensureBlockchainReady() {
|
|
34
|
+
return this.call('ensureBlockchainReady');
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
*
|
|
40
39
|
*/
|
|
41
40
|
init(params ) {
|
|
42
|
-
services_dock_configs.validation.init(params);
|
|
43
41
|
return this.call('init', params);
|
|
44
42
|
}
|
|
45
43
|
|
|
@@ -55,4 +53,4 @@ class DockServiceRpc extends services_rpcServiceClient.RpcService {
|
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
exports.
|
|
56
|
+
exports.BlockchainServiceRpc = BlockchainServiceRpc;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RpcService } from '../rpc-service-client.mjs';
|
|
2
|
-
import { validation } from './configs.mjs';
|
|
3
2
|
import 'assert';
|
|
4
3
|
import '../../rpc-client.mjs';
|
|
5
4
|
import 'json-rpc-2.0';
|
|
@@ -12,9 +11,9 @@ import '../../rpc-util.mjs';
|
|
|
12
11
|
/**
|
|
13
12
|
*
|
|
14
13
|
*/
|
|
15
|
-
class
|
|
14
|
+
class BlockchainServiceRpc extends RpcService {
|
|
16
15
|
constructor() {
|
|
17
|
-
super('
|
|
16
|
+
super('blockchain');
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
/**
|
|
@@ -27,15 +26,14 @@ class DockServiceRpc extends RpcService {
|
|
|
27
26
|
/**
|
|
28
27
|
*
|
|
29
28
|
*/
|
|
30
|
-
|
|
31
|
-
return this.call('
|
|
29
|
+
ensureBlockchainReady() {
|
|
30
|
+
return this.call('ensureBlockchainReady');
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
34
|
*
|
|
36
35
|
*/
|
|
37
36
|
init(params ) {
|
|
38
|
-
validation.init(params);
|
|
39
37
|
return this.call('init', params);
|
|
40
38
|
}
|
|
41
39
|
|
|
@@ -51,4 +49,4 @@ class DockServiceRpc extends RpcService {
|
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
export {
|
|
52
|
+
export { BlockchainServiceRpc };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var protoSigning = require('@cosmjs/proto-signing');
|
|
6
|
+
var cheqdBlockchainApi = require('@docknetwork/cheqd-blockchain-api');
|
|
7
|
+
var cheqdBlockchainModules = require('@docknetwork/cheqd-blockchain-modules');
|
|
8
|
+
var modules = require('@docknetwork/credential-sdk/modules');
|
|
9
|
+
var resolver = require('@docknetwork/credential-sdk/resolver');
|
|
10
|
+
var index = require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
11
|
+
var dockBlockchainApi = require('@docknetwork/dock-blockchain-api');
|
|
12
|
+
var dockBlockchainModules = require('@docknetwork/dock-blockchain-modules');
|
|
13
|
+
var events = require('events');
|
|
14
|
+
var core_logger = require('../../core/logger.js');
|
|
15
|
+
var modules_eventManager = require('../../modules/event-manager.js');
|
|
16
|
+
var services_utilCrypto_service = require('../util-crypto/service.js');
|
|
17
|
+
var types = require('@docknetwork/credential-sdk/types');
|
|
18
|
+
require('assert');
|
|
19
|
+
require('@polkadot/keyring');
|
|
20
|
+
require('@polkadot/util');
|
|
21
|
+
require('@polkadot/util-crypto');
|
|
22
|
+
require('../util-crypto/configs.js');
|
|
23
|
+
require('../../core/validation.js');
|
|
24
|
+
require('bignumber.js');
|
|
25
|
+
require('../../types.js');
|
|
26
|
+
|
|
27
|
+
// @ts-nocheck
|
|
28
|
+
const universalResolverUrl = 'https://uniresolver.truvera.io';
|
|
29
|
+
class AnyDIDResolver extends resolver.ResolverRouter {
|
|
30
|
+
method = resolver.WILDCARD;
|
|
31
|
+
}
|
|
32
|
+
const { AccumulatorModule: AccumulatorModuleDock } = dockBlockchainModules.DockCoreModules;
|
|
33
|
+
const { AccumulatorModule: AccumulatorModuleCheqd } = cheqdBlockchainModules.CheqdCoreModules;
|
|
34
|
+
const TYPES_FOR_DID = {
|
|
35
|
+
dock: {
|
|
36
|
+
PublicKey: types.DockAccumulatorPublicKey,
|
|
37
|
+
AccumulatorId: types.DockAccumulatorId,
|
|
38
|
+
AccumulatorCommon: types.DockAccumulatorCommon,
|
|
39
|
+
AccumulatorModule: AccumulatorModuleDock,
|
|
40
|
+
},
|
|
41
|
+
cheqd: {
|
|
42
|
+
PublicKey: types.CheqdAccumulatorPublicKey,
|
|
43
|
+
AccumulatorId: types.CheqdAccumulatorId,
|
|
44
|
+
AccumulatorCommon: types.CheqdAccumulatorCommon,
|
|
45
|
+
AccumulatorModule: AccumulatorModuleCheqd,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
class BlockchainService {
|
|
52
|
+
dock;
|
|
53
|
+
modules;
|
|
54
|
+
didModule;
|
|
55
|
+
cheqdApi;
|
|
56
|
+
isBlockchainReady = false;
|
|
57
|
+
resolver;
|
|
58
|
+
dockEnabled;
|
|
59
|
+
static Events = {
|
|
60
|
+
BLOCKCHAIN_READY: 'blockchain-ready',
|
|
61
|
+
};
|
|
62
|
+
rpcMethods = [
|
|
63
|
+
BlockchainService.prototype.disconnect,
|
|
64
|
+
BlockchainService.prototype.ensureBlockchainReady,
|
|
65
|
+
BlockchainService.prototype.init,
|
|
66
|
+
BlockchainService.prototype.isApiConnected,
|
|
67
|
+
BlockchainService.prototype.getAddress,
|
|
68
|
+
];
|
|
69
|
+
constructor() {
|
|
70
|
+
this.name = 'blockchain';
|
|
71
|
+
this.dock = new dockBlockchainApi.DockAPI();
|
|
72
|
+
this.cheqdApi = new cheqdBlockchainApi.CheqdAPI();
|
|
73
|
+
this.didModule = new dockBlockchainModules.DockDIDModule(this.dock);
|
|
74
|
+
this.dockModules = new dockBlockchainModules.DockCoreModules(this.dock);
|
|
75
|
+
this.cheqdModules = new cheqdBlockchainModules.CheqdCoreModules(this.cheqdApi);
|
|
76
|
+
this.modules = new modules.MultiApiCoreModules(this.dockEnabled
|
|
77
|
+
? [this.dockModules, this.cheqdModules]
|
|
78
|
+
: [this.cheqdModules]);
|
|
79
|
+
this.emitter = new events.EventEmitter();
|
|
80
|
+
this.resolver = this.createDIDResolver();
|
|
81
|
+
}
|
|
82
|
+
getTypesForDIDOrAccumulator(didOrRegistryId) {
|
|
83
|
+
const didType = didOrRegistryId
|
|
84
|
+
.replace('dock:accumulator:', 'accumulator:dock:')
|
|
85
|
+
.split(':')[1];
|
|
86
|
+
const chainDidType = !this.dock && didType === 'dock' ? 'cheqd' : didType;
|
|
87
|
+
const types = TYPES_FOR_DID[chainDidType];
|
|
88
|
+
if (!types) {
|
|
89
|
+
throw new APIError(`Unable to use DID type ${didType} for this operation`);
|
|
90
|
+
}
|
|
91
|
+
return types;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
async ensureBlockchainReady() {
|
|
98
|
+
if (this.isBlockchainReady) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
return modules_eventManager.once(this.emitter, BlockchainService.Events.BLOCKCHAIN_READY);
|
|
102
|
+
}
|
|
103
|
+
createDIDResolver() {
|
|
104
|
+
return new AnyDIDResolver([
|
|
105
|
+
new resolver.DIDKeyResolver(),
|
|
106
|
+
new resolver.CoreResolver(this.modules),
|
|
107
|
+
new resolver.UniversalResolver(universalResolverUrl),
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @param {*} params
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
async init(params) {
|
|
116
|
+
if (this.dock.isConnected) {
|
|
117
|
+
await this.dock.disconnect();
|
|
118
|
+
}
|
|
119
|
+
if (this.cheqdApi && this.cheqdApi.isInitialized()) {
|
|
120
|
+
await this.cheqdApi.disconnect();
|
|
121
|
+
}
|
|
122
|
+
core_logger.Logger.info(`Attempt to initialized substrate at: ${params.address}`);
|
|
123
|
+
this.dockEnabled = !!params.substrateUrl;
|
|
124
|
+
if (this.dockEnabled) {
|
|
125
|
+
await this.dock.init({
|
|
126
|
+
address: params.substrateUrl,
|
|
127
|
+
});
|
|
128
|
+
core_logger.Logger.info(`Substrate initialized at: ${params.address}`);
|
|
129
|
+
}
|
|
130
|
+
this.modules = new modules.MultiApiCoreModules(this.dockEnabled
|
|
131
|
+
? [this.dockModules, this.cheqdModules]
|
|
132
|
+
: [this.cheqdModules]);
|
|
133
|
+
if (params?.cheqdApiUrl) {
|
|
134
|
+
const checkdApiUrl = params?.cheqdApiUrl;
|
|
135
|
+
const cheqdNetworkId = params?.networkId;
|
|
136
|
+
const cheqdMnemonic = params?.cheqdMnemonic || (await services_utilCrypto_service.utilCryptoService.mnemonicGenerate(12));
|
|
137
|
+
const wallet = await protoSigning.DirectSecp256k1HdWallet.fromMnemonic(cheqdMnemonic, {
|
|
138
|
+
prefix: 'cheqd',
|
|
139
|
+
});
|
|
140
|
+
const walletAccounts = await wallet.getAccounts();
|
|
141
|
+
const [{ address }] = walletAccounts;
|
|
142
|
+
console.log('Using cheqd account:', address);
|
|
143
|
+
core_logger.Logger.info(`Attempt to initialized cheqd at: ${checkdApiUrl} with networkId: ${cheqdNetworkId}`);
|
|
144
|
+
core_logger.Logger.info(`Using cheqd account: ${address}`);
|
|
145
|
+
try {
|
|
146
|
+
await this.cheqdApi.init({
|
|
147
|
+
wallet,
|
|
148
|
+
url: checkdApiUrl,
|
|
149
|
+
network: cheqdNetworkId,
|
|
150
|
+
});
|
|
151
|
+
core_logger.Logger.info(`Cheqd initialized at: ${checkdApiUrl}`);
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
core_logger.Logger.error(`Failed to initialize cheqd at: ${checkdApiUrl}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
this.address = params.address;
|
|
158
|
+
this.resolver = this.createDIDResolver();
|
|
159
|
+
if (process.env.NODE_ENV !== 'test' ||
|
|
160
|
+
process.env.API_MOCK_DISABLED === 'true') {
|
|
161
|
+
await index.initializeWasm();
|
|
162
|
+
}
|
|
163
|
+
this._setBlockchainReady(true);
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
*
|
|
168
|
+
* @returns
|
|
169
|
+
*/
|
|
170
|
+
async disconnect() {
|
|
171
|
+
let result;
|
|
172
|
+
if (this.dockEnabled) {
|
|
173
|
+
result = await this.dock.disconnect();
|
|
174
|
+
}
|
|
175
|
+
if (this.cheqdApi && this.cheqdApi.isInitialized()) {
|
|
176
|
+
result = await this.cheqdApi.disconnect();
|
|
177
|
+
}
|
|
178
|
+
this._setBlockchainReady(false);
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
async waitBlockchainReady() {
|
|
182
|
+
return new Promise(resolve => {
|
|
183
|
+
if (this.isBlockchainReady) {
|
|
184
|
+
resolve();
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
this.emitter.once(BlockchainService.Events.BLOCKCHAIN_READY, resolve);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
*
|
|
193
|
+
* @returns
|
|
194
|
+
*/
|
|
195
|
+
async isApiConnected() {
|
|
196
|
+
return this.cheqdApi.isInitialized();
|
|
197
|
+
}
|
|
198
|
+
async getAddress() {
|
|
199
|
+
return this.dock.address;
|
|
200
|
+
}
|
|
201
|
+
_setBlockchainReady(isBlockchainReady) {
|
|
202
|
+
this.isBlockchainReady = isBlockchainReady;
|
|
203
|
+
if (isBlockchainReady) {
|
|
204
|
+
this.emitter.emit(BlockchainService.Events.BLOCKCHAIN_READY);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const blockchainService = new BlockchainService();
|
|
209
|
+
|
|
210
|
+
exports.BlockchainService = BlockchainService;
|
|
211
|
+
exports.blockchainService = blockchainService;
|
|
212
|
+
exports.universalResolverUrl = universalResolverUrl;
|