@docknetwork/wallet-sdk-wasm 0.4.22 → 1.5.0
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-614e6414.js → account-bf00e5c0.js} +5 -5
- package/lib/{account-ee524484.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 +16 -19
- package/lib/index.mjs +20 -23
- package/lib/modules/account.js +10 -5
- package/lib/modules/account.mjs +10 -5
- package/lib/modules/accounts.js +10 -5
- package/lib/modules/accounts.mjs +10 -5
- package/lib/modules/network-manager.js +4 -2
- package/lib/modules/network-manager.mjs +4 -2
- package/lib/modules/wallet.js +13 -8
- package/lib/modules/wallet.mjs +13 -8
- package/lib/rpc-server.js +16 -19
- package/lib/rpc-server.mjs +20 -23
- 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 +41 -60
- package/lib/services/credential/bbs-revocation.mjs +42 -57
- package/lib/services/credential/bound-check.js +0 -8
- package/lib/services/credential/bound-check.mjs +1 -5
- package/lib/services/credential/index.js +21 -24
- package/lib/services/credential/index.mjs +22 -25
- package/lib/services/credential/pex-helpers.js +134 -34
- package/lib/services/credential/pex-helpers.mjs +133 -35
- package/lib/services/credential/service.js +55 -56
- package/lib/services/credential/service.mjs +45 -43
- 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 +11 -10
- package/lib/services/dids/index.mjs +12 -11
- package/lib/services/dids/service-rpc.js +2 -2
- package/lib/services/dids/service-rpc.mjs +2 -2
- package/lib/services/dids/service.js +28 -36
- package/lib/services/dids/service.mjs +27 -33
- package/lib/services/edv/hmac.js +5 -0
- package/lib/services/edv/hmac.mjs +5 -0
- package/lib/services/edv/index.js +13 -11
- package/lib/services/edv/index.mjs +16 -14
- package/lib/services/edv/service-rpc.js +4 -0
- package/lib/services/edv/service-rpc.mjs +4 -0
- package/lib/services/edv/service.js +29 -13
- package/lib/services/edv/service.mjs +31 -16
- package/lib/services/example/service.js +3 -1
- package/lib/services/example/service.mjs +3 -1
- package/lib/services/index.js +14 -17
- package/lib/services/index.mjs +18 -21
- 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/relay-service/index.mjs +1 -1
- package/lib/services/relay-service/service.mjs +2 -2
- package/lib/services/substrate/api-utils.js +19 -6
- package/lib/services/substrate/api-utils.mjs +19 -6
- package/lib/services/substrate/index.js +14 -6
- package/lib/services/substrate/index.mjs +14 -6
- package/lib/services/substrate/service.js +17 -9
- package/lib/services/substrate/service.mjs +17 -9
- package/lib/services/test-utils.js +27 -17
- package/lib/services/test-utils.mjs +27 -17
- package/lib/services/trust-registry/index.js +17 -5
- package/lib/services/trust-registry/index.mjs +17 -5
- package/lib/services/trust-registry/service.js +27 -10
- package/lib/services/trust-registry/service.mjs +27 -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 +16 -19
- package/lib/setup-nodejs.mjs +20 -23
- package/lib/setup-tests.js +16 -19
- package/lib/setup-tests.mjs +20 -23
- 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/blockchain/service.d.ts +52 -0
- 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 -4
- 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 +11 -6
- package/lib/test/setup-test-state.mjs +11 -6
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -4
- 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 +41 -85
- 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 -23
- package/src/services/dids/service-rpc.ts +2 -2
- package/src/services/dids/service.ts +34 -44
- 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 -17
- package/lib/services/dock/index.mjs +0 -9
- package/lib/services/dock/service.js +0 -138
- package/lib/services/dock/service.mjs +0 -126
- 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 +0 -44
- 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 -154
|
@@ -2,21 +2,29 @@ import assert from 'assert';
|
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
4
|
import { DOCK_TOKEN_UNIT, getPlainDockAmount } from '../../core/format-utils.mjs';
|
|
5
|
-
import {
|
|
5
|
+
import { blockchainService } from '../blockchain/service.mjs';
|
|
6
6
|
import { signAndSend } from './api-utils.mjs';
|
|
7
7
|
import { serviceName, validation } from './configs.mjs';
|
|
8
8
|
import { keyringService } from '../keyring/service.mjs';
|
|
9
9
|
import '../../core/validation.mjs';
|
|
10
10
|
import '../../types.mjs';
|
|
11
|
-
import '@
|
|
12
|
-
import '@docknetwork/
|
|
11
|
+
import '@cosmjs/proto-signing';
|
|
12
|
+
import '@docknetwork/cheqd-blockchain-api';
|
|
13
|
+
import '@docknetwork/cheqd-blockchain-modules';
|
|
14
|
+
import '@docknetwork/credential-sdk/modules';
|
|
15
|
+
import '@docknetwork/credential-sdk/resolver';
|
|
13
16
|
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
17
|
+
import '@docknetwork/dock-blockchain-api';
|
|
18
|
+
import '@docknetwork/dock-blockchain-modules';
|
|
14
19
|
import 'events';
|
|
15
20
|
import '../../core/logger.mjs';
|
|
16
21
|
import '../../modules/event-manager.mjs';
|
|
17
|
-
import '../
|
|
22
|
+
import '../util-crypto/service.mjs';
|
|
18
23
|
import '@polkadot/keyring';
|
|
24
|
+
import '@polkadot/util';
|
|
19
25
|
import '@polkadot/util-crypto';
|
|
26
|
+
import '../util-crypto/configs.mjs';
|
|
27
|
+
import '@docknetwork/credential-sdk/types';
|
|
20
28
|
import '../keyring/configs.mjs';
|
|
21
29
|
|
|
22
30
|
// @ts-nocheck
|
|
@@ -37,9 +45,9 @@ class SubstrateService {
|
|
|
37
45
|
async getAccountBalance(params) {
|
|
38
46
|
validation.getAccountBalance(params);
|
|
39
47
|
console.log('ensure dock ready');
|
|
40
|
-
await
|
|
48
|
+
await blockchainService.ensureBlockchainReady();
|
|
41
49
|
console.log('ensure dock ready done');
|
|
42
|
-
const { data: { free }, } = await
|
|
50
|
+
const { data: { free }, } = await blockchainService.dock.api.query.system.account(params.address);
|
|
43
51
|
return free.toNumber() / DOCK_TOKEN_UNIT;
|
|
44
52
|
}
|
|
45
53
|
async getFeeAmount(params) {
|
|
@@ -50,8 +58,8 @@ class SubstrateService {
|
|
|
50
58
|
jsonData: keyPair,
|
|
51
59
|
password: '',
|
|
52
60
|
});
|
|
53
|
-
|
|
54
|
-
const extrinsic =
|
|
61
|
+
blockchainService.dock.setAccount(account);
|
|
62
|
+
const extrinsic = blockchainService.dock.api.tx.balances.transfer(toAddress, amount);
|
|
55
63
|
const paymentInfo = await extrinsic.paymentInfo(account);
|
|
56
64
|
const fee = getFeeWithBuffer(paymentInfo.partialFee)
|
|
57
65
|
.dividedBy(DOCK_TOKEN_UNIT)
|
|
@@ -66,7 +74,7 @@ class SubstrateService {
|
|
|
66
74
|
jsonData: keyPair,
|
|
67
75
|
password: '',
|
|
68
76
|
});
|
|
69
|
-
const { dock } =
|
|
77
|
+
const { dock } = blockchainService;
|
|
70
78
|
dock.setAccount(account);
|
|
71
79
|
if (params.transferAll) {
|
|
72
80
|
const api = dock.api;
|
|
@@ -8,22 +8,16 @@ var BigNumber = require('bignumber.js');
|
|
|
8
8
|
var core_formatUtils = require('../core/format-utils.js');
|
|
9
9
|
var fixtures = require('../fixtures.js');
|
|
10
10
|
var modules_networkManager = require('../modules/network-manager.js');
|
|
11
|
-
var services_dock_service = require('./dock/service.js');
|
|
12
11
|
var services_keyring_service = require('./keyring/service.js');
|
|
13
12
|
require('json-rpc-2.0');
|
|
14
13
|
require('../core/crypto.js');
|
|
15
14
|
require('../core/logger.js');
|
|
16
15
|
var services_wallet_service = require('./wallet/service.js');
|
|
17
16
|
var Keyring = require('@polkadot/keyring');
|
|
17
|
+
var services_blockchain_service = require('./blockchain/service.js');
|
|
18
18
|
require('../core/validation.js');
|
|
19
19
|
require('../types.js');
|
|
20
20
|
require('./keyring/configs.js');
|
|
21
|
-
require('@docknetwork/sdk');
|
|
22
|
-
require('@docknetwork/sdk/resolver');
|
|
23
|
-
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
24
|
-
require('events');
|
|
25
|
-
require('../modules/event-manager.js');
|
|
26
|
-
require('./dock/configs.js');
|
|
27
21
|
require('crypto');
|
|
28
22
|
require('uuid');
|
|
29
23
|
require('../wallet/memory-storage-wallet.js');
|
|
@@ -34,6 +28,20 @@ require('../wallet/rpc-storage-wallet.js');
|
|
|
34
28
|
require('../wallet/rpc-storage-interface.js');
|
|
35
29
|
require('./storage/service.js');
|
|
36
30
|
require('./wallet/configs.js');
|
|
31
|
+
require('@cosmjs/proto-signing');
|
|
32
|
+
require('@docknetwork/cheqd-blockchain-api');
|
|
33
|
+
require('@docknetwork/cheqd-blockchain-modules');
|
|
34
|
+
require('@docknetwork/credential-sdk/modules');
|
|
35
|
+
require('@docknetwork/credential-sdk/resolver');
|
|
36
|
+
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
37
|
+
require('@docknetwork/dock-blockchain-api');
|
|
38
|
+
require('@docknetwork/dock-blockchain-modules');
|
|
39
|
+
require('events');
|
|
40
|
+
require('../modules/event-manager.js');
|
|
41
|
+
require('./util-crypto/service.js');
|
|
42
|
+
require('@polkadot/util');
|
|
43
|
+
require('./util-crypto/configs.js');
|
|
44
|
+
require('@docknetwork/credential-sdk/types');
|
|
37
45
|
|
|
38
46
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
39
47
|
|
|
@@ -81,21 +89,21 @@ async function mockDockService() {
|
|
|
81
89
|
let sdkMock;
|
|
82
90
|
|
|
83
91
|
if (API_MOCK_DISABLED) {
|
|
84
|
-
return
|
|
92
|
+
return services_blockchain_service.blockchainService.init({
|
|
85
93
|
address: modules_networkManager.NetworkManager.getInstance().getNetworkInfo().substrateUrl,
|
|
86
94
|
});
|
|
87
95
|
} else {
|
|
88
96
|
sdkMock = mockDockSdkConnection();
|
|
89
|
-
await
|
|
97
|
+
await services_blockchain_service.blockchainService.init({
|
|
90
98
|
address: modules_networkManager.NetworkManager.getInstance().getNetworkInfo().substrateUrl,
|
|
91
99
|
});
|
|
92
100
|
}
|
|
93
101
|
|
|
94
|
-
const _dockSdk =
|
|
102
|
+
const _dockSdk = services_blockchain_service.blockchainService.dock;
|
|
95
103
|
|
|
96
|
-
|
|
104
|
+
services_blockchain_service.blockchainService.isDockReady = true;
|
|
97
105
|
|
|
98
|
-
|
|
106
|
+
services_blockchain_service.blockchainService.dock = {
|
|
99
107
|
api: {
|
|
100
108
|
events: {
|
|
101
109
|
system: {
|
|
@@ -156,11 +164,11 @@ async function mockDockService() {
|
|
|
156
164
|
};
|
|
157
165
|
|
|
158
166
|
return () => {
|
|
159
|
-
|
|
167
|
+
services_blockchain_service.blockchainService.dock = _dockSdk;
|
|
160
168
|
if (sdkMock) {
|
|
161
169
|
sdkMock.clear();
|
|
162
170
|
}
|
|
163
|
-
|
|
171
|
+
services_blockchain_service.blockchainService.disconnect();
|
|
164
172
|
};
|
|
165
173
|
}
|
|
166
174
|
|
|
@@ -195,7 +203,7 @@ async function setupTestWallet() {
|
|
|
195
203
|
|
|
196
204
|
function mockDockSdkConnection(connectionError) {
|
|
197
205
|
const result = 'result';
|
|
198
|
-
const dock =
|
|
206
|
+
const dock = services_blockchain_service.blockchainService.dock;
|
|
199
207
|
const mocks = [
|
|
200
208
|
jest.spyOn(dock, 'init').mockImplementation(() => {
|
|
201
209
|
if (connectionError) {
|
|
@@ -209,7 +217,7 @@ function mockDockSdkConnection(connectionError) {
|
|
|
209
217
|
|
|
210
218
|
let currentAccount;
|
|
211
219
|
|
|
212
|
-
|
|
220
|
+
services_blockchain_service.blockchainService.dock = {
|
|
213
221
|
...dock,
|
|
214
222
|
setAccount(account) {
|
|
215
223
|
currentAccount = account;
|
|
@@ -260,7 +268,7 @@ function mockDockSdkConnection(connectionError) {
|
|
|
260
268
|
return kr.createFromUri('//Alice');
|
|
261
269
|
}),
|
|
262
270
|
},
|
|
263
|
-
}
|
|
271
|
+
};
|
|
264
272
|
|
|
265
273
|
return {
|
|
266
274
|
result,
|
|
@@ -286,6 +294,8 @@ function assertRpcService(
|
|
|
286
294
|
const rpcService = new ServiceClass();
|
|
287
295
|
const validationTmp = {};
|
|
288
296
|
|
|
297
|
+
assert__default["default"](rpcService.serviceName === service.name, 'service name mismatch');
|
|
298
|
+
|
|
289
299
|
Object.keys(validation).forEach(key => {
|
|
290
300
|
validationTmp[key] = validation[key];
|
|
291
301
|
validation[key] = () => true;
|
|
@@ -4,22 +4,16 @@ import BigNumber from 'bignumber.js';
|
|
|
4
4
|
import { DOCK_TOKEN_UNIT } from '../core/format-utils.mjs';
|
|
5
5
|
import { TestFixtures } from '../fixtures.mjs';
|
|
6
6
|
import { NetworkManager } from '../modules/network-manager.mjs';
|
|
7
|
-
import { dockService, setDock, getDock } from './dock/service.mjs';
|
|
8
7
|
import { keyringService } from './keyring/service.mjs';
|
|
9
8
|
import 'json-rpc-2.0';
|
|
10
9
|
import '../core/crypto.mjs';
|
|
11
10
|
import '../core/logger.mjs';
|
|
12
11
|
import { walletService } from './wallet/service.mjs';
|
|
13
12
|
import Keyring from '@polkadot/keyring';
|
|
13
|
+
import { blockchainService } from './blockchain/service.mjs';
|
|
14
14
|
import '../core/validation.mjs';
|
|
15
15
|
import '../types.mjs';
|
|
16
16
|
import './keyring/configs.mjs';
|
|
17
|
-
import '@docknetwork/sdk';
|
|
18
|
-
import '@docknetwork/sdk/resolver';
|
|
19
|
-
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
20
|
-
import 'events';
|
|
21
|
-
import '../modules/event-manager.mjs';
|
|
22
|
-
import './dock/configs.mjs';
|
|
23
17
|
import 'crypto';
|
|
24
18
|
import 'uuid';
|
|
25
19
|
import '../wallet/memory-storage-wallet.mjs';
|
|
@@ -30,6 +24,20 @@ import '../wallet/rpc-storage-wallet.mjs';
|
|
|
30
24
|
import '../wallet/rpc-storage-interface.mjs';
|
|
31
25
|
import './storage/service.mjs';
|
|
32
26
|
import './wallet/configs.mjs';
|
|
27
|
+
import '@cosmjs/proto-signing';
|
|
28
|
+
import '@docknetwork/cheqd-blockchain-api';
|
|
29
|
+
import '@docknetwork/cheqd-blockchain-modules';
|
|
30
|
+
import '@docknetwork/credential-sdk/modules';
|
|
31
|
+
import '@docknetwork/credential-sdk/resolver';
|
|
32
|
+
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
33
|
+
import '@docknetwork/dock-blockchain-api';
|
|
34
|
+
import '@docknetwork/dock-blockchain-modules';
|
|
35
|
+
import 'events';
|
|
36
|
+
import '../modules/event-manager.mjs';
|
|
37
|
+
import './util-crypto/service.mjs';
|
|
38
|
+
import '@polkadot/util';
|
|
39
|
+
import './util-crypto/configs.mjs';
|
|
40
|
+
import '@docknetwork/credential-sdk/types';
|
|
33
41
|
|
|
34
42
|
async function initializeWalletService() {
|
|
35
43
|
await cryptoWaitReady();
|
|
@@ -71,21 +79,21 @@ async function mockDockService() {
|
|
|
71
79
|
let sdkMock;
|
|
72
80
|
|
|
73
81
|
if (API_MOCK_DISABLED) {
|
|
74
|
-
return
|
|
82
|
+
return blockchainService.init({
|
|
75
83
|
address: NetworkManager.getInstance().getNetworkInfo().substrateUrl,
|
|
76
84
|
});
|
|
77
85
|
} else {
|
|
78
86
|
sdkMock = mockDockSdkConnection();
|
|
79
|
-
await
|
|
87
|
+
await blockchainService.init({
|
|
80
88
|
address: NetworkManager.getInstance().getNetworkInfo().substrateUrl,
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
91
|
|
|
84
|
-
const _dockSdk =
|
|
92
|
+
const _dockSdk = blockchainService.dock;
|
|
85
93
|
|
|
86
|
-
|
|
94
|
+
blockchainService.isDockReady = true;
|
|
87
95
|
|
|
88
|
-
|
|
96
|
+
blockchainService.dock = {
|
|
89
97
|
api: {
|
|
90
98
|
events: {
|
|
91
99
|
system: {
|
|
@@ -146,11 +154,11 @@ async function mockDockService() {
|
|
|
146
154
|
};
|
|
147
155
|
|
|
148
156
|
return () => {
|
|
149
|
-
|
|
157
|
+
blockchainService.dock = _dockSdk;
|
|
150
158
|
if (sdkMock) {
|
|
151
159
|
sdkMock.clear();
|
|
152
160
|
}
|
|
153
|
-
|
|
161
|
+
blockchainService.disconnect();
|
|
154
162
|
};
|
|
155
163
|
}
|
|
156
164
|
|
|
@@ -185,7 +193,7 @@ async function setupTestWallet() {
|
|
|
185
193
|
|
|
186
194
|
function mockDockSdkConnection(connectionError) {
|
|
187
195
|
const result = 'result';
|
|
188
|
-
const dock =
|
|
196
|
+
const dock = blockchainService.dock;
|
|
189
197
|
const mocks = [
|
|
190
198
|
jest.spyOn(dock, 'init').mockImplementation(() => {
|
|
191
199
|
if (connectionError) {
|
|
@@ -199,7 +207,7 @@ function mockDockSdkConnection(connectionError) {
|
|
|
199
207
|
|
|
200
208
|
let currentAccount;
|
|
201
209
|
|
|
202
|
-
|
|
210
|
+
blockchainService.dock = {
|
|
203
211
|
...dock,
|
|
204
212
|
setAccount(account) {
|
|
205
213
|
currentAccount = account;
|
|
@@ -250,7 +258,7 @@ function mockDockSdkConnection(connectionError) {
|
|
|
250
258
|
return kr.createFromUri('//Alice');
|
|
251
259
|
}),
|
|
252
260
|
},
|
|
253
|
-
}
|
|
261
|
+
};
|
|
254
262
|
|
|
255
263
|
return {
|
|
256
264
|
result,
|
|
@@ -276,6 +284,8 @@ function assertRpcService(
|
|
|
276
284
|
const rpcService = new ServiceClass();
|
|
277
285
|
const validationTmp = {};
|
|
278
286
|
|
|
287
|
+
assert(rpcService.serviceName === service.name, 'service name mismatch');
|
|
288
|
+
|
|
279
289
|
Object.keys(validation).forEach(key => {
|
|
280
290
|
validationTmp[key] = validation[key];
|
|
281
291
|
validation[key] = () => true;
|
|
@@ -5,16 +5,28 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var services_trustRegistry_service = require('./service.js');
|
|
6
6
|
require('./configs.js');
|
|
7
7
|
require('assert');
|
|
8
|
-
require('@docknetwork/sdk/utils/did/typed-did/helpers');
|
|
9
8
|
require('crypto');
|
|
10
|
-
require('../
|
|
11
|
-
require('@
|
|
12
|
-
require('@docknetwork/
|
|
9
|
+
require('../blockchain/service.js');
|
|
10
|
+
require('@cosmjs/proto-signing');
|
|
11
|
+
require('@docknetwork/cheqd-blockchain-api');
|
|
12
|
+
require('@docknetwork/cheqd-blockchain-modules');
|
|
13
|
+
require('@docknetwork/credential-sdk/modules');
|
|
14
|
+
require('@docknetwork/credential-sdk/resolver');
|
|
13
15
|
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
16
|
+
require('@docknetwork/dock-blockchain-api');
|
|
17
|
+
require('@docknetwork/dock-blockchain-modules');
|
|
14
18
|
require('events');
|
|
15
19
|
require('../../core/logger.js');
|
|
16
20
|
require('../../modules/event-manager.js');
|
|
17
|
-
require('../
|
|
21
|
+
require('../util-crypto/service.js');
|
|
22
|
+
require('@polkadot/keyring');
|
|
23
|
+
require('@polkadot/util');
|
|
24
|
+
require('@polkadot/util-crypto');
|
|
25
|
+
require('../util-crypto/configs.js');
|
|
26
|
+
require('../../core/validation.js');
|
|
27
|
+
require('bignumber.js');
|
|
28
|
+
require('../../types.js');
|
|
29
|
+
require('@docknetwork/credential-sdk/types');
|
|
18
30
|
|
|
19
31
|
|
|
20
32
|
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
export { trustRegistryService } from './service.mjs';
|
|
2
2
|
import './configs.mjs';
|
|
3
3
|
import 'assert';
|
|
4
|
-
import '@docknetwork/sdk/utils/did/typed-did/helpers';
|
|
5
4
|
import 'crypto';
|
|
6
|
-
import '../
|
|
7
|
-
import '@
|
|
8
|
-
import '@docknetwork/
|
|
5
|
+
import '../blockchain/service.mjs';
|
|
6
|
+
import '@cosmjs/proto-signing';
|
|
7
|
+
import '@docknetwork/cheqd-blockchain-api';
|
|
8
|
+
import '@docknetwork/cheqd-blockchain-modules';
|
|
9
|
+
import '@docknetwork/credential-sdk/modules';
|
|
10
|
+
import '@docknetwork/credential-sdk/resolver';
|
|
9
11
|
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
12
|
+
import '@docknetwork/dock-blockchain-api';
|
|
13
|
+
import '@docknetwork/dock-blockchain-modules';
|
|
10
14
|
import 'events';
|
|
11
15
|
import '../../core/logger.mjs';
|
|
12
16
|
import '../../modules/event-manager.mjs';
|
|
13
|
-
import '../
|
|
17
|
+
import '../util-crypto/service.mjs';
|
|
18
|
+
import '@polkadot/keyring';
|
|
19
|
+
import '@polkadot/util';
|
|
20
|
+
import '@polkadot/util-crypto';
|
|
21
|
+
import '../util-crypto/configs.mjs';
|
|
22
|
+
import '../../core/validation.mjs';
|
|
23
|
+
import 'bignumber.js';
|
|
24
|
+
import '../../types.mjs';
|
|
25
|
+
import '@docknetwork/credential-sdk/types';
|
|
@@ -3,19 +3,36 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var services_trustRegistry_configs = require('./configs.js');
|
|
6
|
-
var helpers = require('@docknetwork/sdk/utils/did/typed-did/helpers');
|
|
7
6
|
var crypto = require('crypto');
|
|
8
|
-
var
|
|
7
|
+
var services_blockchain_service = require('../blockchain/service.js');
|
|
9
8
|
require('assert');
|
|
10
|
-
require('@
|
|
11
|
-
require('@docknetwork/
|
|
9
|
+
require('@cosmjs/proto-signing');
|
|
10
|
+
require('@docknetwork/cheqd-blockchain-api');
|
|
11
|
+
require('@docknetwork/cheqd-blockchain-modules');
|
|
12
|
+
require('@docknetwork/credential-sdk/modules');
|
|
13
|
+
require('@docknetwork/credential-sdk/resolver');
|
|
12
14
|
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
15
|
+
require('@docknetwork/dock-blockchain-api');
|
|
16
|
+
require('@docknetwork/dock-blockchain-modules');
|
|
13
17
|
require('events');
|
|
14
18
|
require('../../core/logger.js');
|
|
15
19
|
require('../../modules/event-manager.js');
|
|
16
|
-
require('../
|
|
20
|
+
require('../util-crypto/service.js');
|
|
21
|
+
require('@polkadot/keyring');
|
|
22
|
+
require('@polkadot/util');
|
|
23
|
+
require('@polkadot/util-crypto');
|
|
24
|
+
require('../util-crypto/configs.js');
|
|
25
|
+
require('../../core/validation.js');
|
|
26
|
+
require('bignumber.js');
|
|
27
|
+
require('../../types.js');
|
|
28
|
+
require('@docknetwork/credential-sdk/types');
|
|
17
29
|
|
|
18
30
|
// @ts-nocheck
|
|
31
|
+
// TODO: Implement this function when the Trust Registry support is added to the SDK
|
|
32
|
+
function typedHexDID(resolver, issuerDID) {
|
|
33
|
+
return issuerDID;
|
|
34
|
+
}
|
|
35
|
+
// Trust Registry Service is not supported in the current version of the SDK
|
|
19
36
|
class TrustRegistryService {
|
|
20
37
|
constructor() {
|
|
21
38
|
this.name = services_trustRegistry_configs.serviceName;
|
|
@@ -35,18 +52,18 @@ class TrustRegistryService {
|
|
|
35
52
|
};
|
|
36
53
|
}
|
|
37
54
|
if (issuerDID) {
|
|
38
|
-
const issuerDIDMethodKey =
|
|
55
|
+
const issuerDIDMethodKey = typedHexDID(services_blockchain_service.blockchainService.dock.api, issuerDID);
|
|
39
56
|
queryOptions.issuers = {
|
|
40
57
|
AnyOf: [issuerDIDMethodKey],
|
|
41
58
|
};
|
|
42
59
|
}
|
|
43
60
|
if (verifierDID) {
|
|
44
|
-
const verifierDIDMethodKey =
|
|
61
|
+
const verifierDIDMethodKey = typedHexDID(services_blockchain_service.blockchainService.dock.api, verifierDID);
|
|
45
62
|
queryOptions.verifiers = {
|
|
46
63
|
AnyOf: [verifierDIDMethodKey],
|
|
47
64
|
};
|
|
48
65
|
}
|
|
49
|
-
const registryInfo = await
|
|
66
|
+
const registryInfo = await services_blockchain_service.blockchainService.dock.trustRegistry?.registriesInfo(queryOptions);
|
|
50
67
|
return registryInfo;
|
|
51
68
|
}
|
|
52
69
|
async getTrustRegistryVerifiers({ schemaId, trustRegistryId, issuerDID }) {
|
|
@@ -54,9 +71,9 @@ class TrustRegistryService {
|
|
|
54
71
|
const hashedId = crypto.createHash('sha256').update(schemaId).digest('hex');
|
|
55
72
|
const schemaIdHex = '0x' + hashedId;
|
|
56
73
|
const issuerDIDMethodKey = issuerDID
|
|
57
|
-
?
|
|
74
|
+
? typedHexDID(services_blockchain_service.blockchainService.dock.api, issuerDID)
|
|
58
75
|
: null;
|
|
59
|
-
const metadata = await
|
|
76
|
+
const metadata = await services_blockchain_service.blockchainService.dock.trustRegistry.registrySchemasMetadata({
|
|
60
77
|
schemaIds: [schemaIdHex],
|
|
61
78
|
...(issuerDIDMethodKey && {
|
|
62
79
|
issuers: {
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import { serviceName, validation } from './configs.mjs';
|
|
2
|
-
import { typedHexDID } from '@docknetwork/sdk/utils/did/typed-did/helpers';
|
|
3
2
|
import { createHash } from 'crypto';
|
|
4
|
-
import {
|
|
3
|
+
import { blockchainService } from '../blockchain/service.mjs';
|
|
5
4
|
import 'assert';
|
|
6
|
-
import '@
|
|
7
|
-
import '@docknetwork/
|
|
5
|
+
import '@cosmjs/proto-signing';
|
|
6
|
+
import '@docknetwork/cheqd-blockchain-api';
|
|
7
|
+
import '@docknetwork/cheqd-blockchain-modules';
|
|
8
|
+
import '@docknetwork/credential-sdk/modules';
|
|
9
|
+
import '@docknetwork/credential-sdk/resolver';
|
|
8
10
|
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
11
|
+
import '@docknetwork/dock-blockchain-api';
|
|
12
|
+
import '@docknetwork/dock-blockchain-modules';
|
|
9
13
|
import 'events';
|
|
10
14
|
import '../../core/logger.mjs';
|
|
11
15
|
import '../../modules/event-manager.mjs';
|
|
12
|
-
import '../
|
|
16
|
+
import '../util-crypto/service.mjs';
|
|
17
|
+
import '@polkadot/keyring';
|
|
18
|
+
import '@polkadot/util';
|
|
19
|
+
import '@polkadot/util-crypto';
|
|
20
|
+
import '../util-crypto/configs.mjs';
|
|
21
|
+
import '../../core/validation.mjs';
|
|
22
|
+
import 'bignumber.js';
|
|
23
|
+
import '../../types.mjs';
|
|
24
|
+
import '@docknetwork/credential-sdk/types';
|
|
13
25
|
|
|
14
26
|
// @ts-nocheck
|
|
27
|
+
// TODO: Implement this function when the Trust Registry support is added to the SDK
|
|
28
|
+
function typedHexDID(resolver, issuerDID) {
|
|
29
|
+
return issuerDID;
|
|
30
|
+
}
|
|
31
|
+
// Trust Registry Service is not supported in the current version of the SDK
|
|
15
32
|
class TrustRegistryService {
|
|
16
33
|
constructor() {
|
|
17
34
|
this.name = serviceName;
|
|
@@ -31,18 +48,18 @@ class TrustRegistryService {
|
|
|
31
48
|
};
|
|
32
49
|
}
|
|
33
50
|
if (issuerDID) {
|
|
34
|
-
const issuerDIDMethodKey = typedHexDID(
|
|
51
|
+
const issuerDIDMethodKey = typedHexDID(blockchainService.dock.api, issuerDID);
|
|
35
52
|
queryOptions.issuers = {
|
|
36
53
|
AnyOf: [issuerDIDMethodKey],
|
|
37
54
|
};
|
|
38
55
|
}
|
|
39
56
|
if (verifierDID) {
|
|
40
|
-
const verifierDIDMethodKey = typedHexDID(
|
|
57
|
+
const verifierDIDMethodKey = typedHexDID(blockchainService.dock.api, verifierDID);
|
|
41
58
|
queryOptions.verifiers = {
|
|
42
59
|
AnyOf: [verifierDIDMethodKey],
|
|
43
60
|
};
|
|
44
61
|
}
|
|
45
|
-
const registryInfo = await
|
|
62
|
+
const registryInfo = await blockchainService.dock.trustRegistry?.registriesInfo(queryOptions);
|
|
46
63
|
return registryInfo;
|
|
47
64
|
}
|
|
48
65
|
async getTrustRegistryVerifiers({ schemaId, trustRegistryId, issuerDID }) {
|
|
@@ -50,9 +67,9 @@ class TrustRegistryService {
|
|
|
50
67
|
const hashedId = createHash('sha256').update(schemaId).digest('hex');
|
|
51
68
|
const schemaIdHex = '0x' + hashedId;
|
|
52
69
|
const issuerDIDMethodKey = issuerDID
|
|
53
|
-
? typedHexDID(
|
|
70
|
+
? typedHexDID(blockchainService.dock.api, issuerDID)
|
|
54
71
|
: null;
|
|
55
|
-
const metadata = await
|
|
72
|
+
const metadata = await blockchainService.dock.trustRegistry.registrySchemasMetadata({
|
|
56
73
|
schemaIds: [schemaIdHex],
|
|
57
74
|
...(issuerDIDMethodKey && {
|
|
58
75
|
issuers: {
|
|
@@ -24,6 +24,9 @@ const validation = {
|
|
|
24
24
|
assert__default["default"](typeof numWords === 'number', 'invalid number of words');
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
+
mnemonicToMiniSecret(phrase) {
|
|
28
|
+
assert__default["default"](typeof phrase === 'string', 'invalid mnemonic phrase');
|
|
29
|
+
},
|
|
27
30
|
mnemonicValidate(phrase) {
|
|
28
31
|
assert__default["default"](typeof phrase === 'string', 'invalid mnemonic phrase');
|
|
29
32
|
},
|
|
@@ -16,6 +16,9 @@ const validation = {
|
|
|
16
16
|
assert(typeof numWords === 'number', 'invalid number of words');
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
+
mnemonicToMiniSecret(phrase) {
|
|
20
|
+
assert(typeof phrase === 'string', 'invalid mnemonic phrase');
|
|
21
|
+
},
|
|
19
22
|
mnemonicValidate(phrase) {
|
|
20
23
|
assert(typeof phrase === 'string', 'invalid mnemonic phrase');
|
|
21
24
|
},
|
|
@@ -27,6 +27,12 @@ class UtilCryptoServiceRpc extends services_rpcServiceClient.RpcService {
|
|
|
27
27
|
return this.call('mnemonicGenerate', numWords);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
mnemonicToMiniSecret(phrase ) {
|
|
31
|
+
services_utilCrypto_configs.validation.mnemonicToMiniSecret(phrase);
|
|
32
|
+
|
|
33
|
+
return this.call('mnemonicToMiniSecret', phrase);
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
mnemonicValidate(phrase ) {
|
|
31
37
|
services_utilCrypto_configs.validation.mnemonicValidate(phrase);
|
|
32
38
|
|
|
@@ -23,6 +23,12 @@ class UtilCryptoServiceRpc extends RpcService {
|
|
|
23
23
|
return this.call('mnemonicGenerate', numWords);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
mnemonicToMiniSecret(phrase ) {
|
|
27
|
+
validation.mnemonicToMiniSecret(phrase);
|
|
28
|
+
|
|
29
|
+
return this.call('mnemonicToMiniSecret', phrase);
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
mnemonicValidate(phrase ) {
|
|
27
33
|
validation.mnemonicValidate(phrase);
|
|
28
34
|
|
|
@@ -19,6 +19,7 @@ var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
|
|
|
19
19
|
class UtilCryptoService {
|
|
20
20
|
rpcMethods = [
|
|
21
21
|
UtilCryptoService.prototype.mnemonicGenerate,
|
|
22
|
+
UtilCryptoService.prototype.mnemonicToMiniSecret,
|
|
22
23
|
UtilCryptoService.prototype.mnemonicValidate,
|
|
23
24
|
UtilCryptoService.prototype.cryptoWaitReady,
|
|
24
25
|
UtilCryptoService.prototype.cryptoIsReady,
|
|
@@ -34,6 +35,10 @@ class UtilCryptoService {
|
|
|
34
35
|
services_utilCrypto_configs.validation.mnemonicGenerate(numWords);
|
|
35
36
|
return utilCrypto.mnemonicGenerate(numWords);
|
|
36
37
|
}
|
|
38
|
+
mnemonicToMiniSecret(phrase) {
|
|
39
|
+
services_utilCrypto_configs.validation.mnemonicToMiniSecret(phrase);
|
|
40
|
+
return utilCrypto.mnemonicToMiniSecret(phrase);
|
|
41
|
+
}
|
|
37
42
|
isBase64(value) {
|
|
38
43
|
if (typeof value !== 'string') {
|
|
39
44
|
return false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decodeAddress, encodeAddress } from '@polkadot/keyring';
|
|
2
2
|
import { isHex, hexToU8a } from '@polkadot/util';
|
|
3
|
-
import { mnemonicGenerate, mnemonicValidate, cryptoWaitReady, cryptoIsReady, keyExtractSuri } from '@polkadot/util-crypto';
|
|
3
|
+
import { mnemonicGenerate, mnemonicToMiniSecret, mnemonicValidate, cryptoWaitReady, cryptoIsReady, keyExtractSuri } from '@polkadot/util-crypto';
|
|
4
4
|
import assert from 'assert';
|
|
5
5
|
import { validation } from './configs.mjs';
|
|
6
6
|
import '../../core/validation.mjs';
|
|
@@ -11,6 +11,7 @@ import '../../types.mjs';
|
|
|
11
11
|
class UtilCryptoService {
|
|
12
12
|
rpcMethods = [
|
|
13
13
|
UtilCryptoService.prototype.mnemonicGenerate,
|
|
14
|
+
UtilCryptoService.prototype.mnemonicToMiniSecret,
|
|
14
15
|
UtilCryptoService.prototype.mnemonicValidate,
|
|
15
16
|
UtilCryptoService.prototype.cryptoWaitReady,
|
|
16
17
|
UtilCryptoService.prototype.cryptoIsReady,
|
|
@@ -26,6 +27,10 @@ class UtilCryptoService {
|
|
|
26
27
|
validation.mnemonicGenerate(numWords);
|
|
27
28
|
return mnemonicGenerate(numWords);
|
|
28
29
|
}
|
|
30
|
+
mnemonicToMiniSecret(phrase) {
|
|
31
|
+
validation.mnemonicToMiniSecret(phrase);
|
|
32
|
+
return mnemonicToMiniSecret(phrase);
|
|
33
|
+
}
|
|
29
34
|
isBase64(value) {
|
|
30
35
|
if (typeof value !== 'string') {
|
|
31
36
|
return false;
|