@docknetwork/wallet-sdk-wasm 1.5.9 → 1.5.11
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/core/format-utils.js +0 -28
- package/lib/core/format-utils.mjs +1 -24
- package/lib/core/validation.js +1 -24
- package/lib/core/validation.mjs +2 -21
- package/lib/index.js +13 -23
- package/lib/index.mjs +13 -23
- package/lib/rpc-server.js +13 -23
- package/lib/rpc-server.mjs +13 -23
- package/lib/rpc-util.js +14 -0
- package/lib/rpc-util.mjs +14 -0
- package/lib/services/blockchain/index.js +3 -6
- package/lib/services/blockchain/index.mjs +3 -6
- package/lib/services/blockchain/service.js +5 -9
- package/lib/services/blockchain/service.mjs +5 -9
- package/lib/services/credential/bbs-revocation.js +4 -7
- package/lib/services/credential/bbs-revocation.mjs +3 -6
- package/lib/services/credential/bound-check.js +9 -4
- package/lib/services/credential/bound-check.mjs +9 -4
- package/lib/services/credential/index.js +11 -13
- package/lib/services/credential/index.mjs +11 -13
- package/lib/services/credential/service.js +18 -18
- package/lib/services/credential/service.mjs +15 -15
- package/lib/services/credential/utils.js +59 -28
- package/lib/services/credential/utils.mjs +62 -32
- package/lib/services/dids/index.js +7 -25
- package/lib/services/dids/index.mjs +7 -25
- package/lib/services/dids/keypair-utils.js +142 -0
- package/lib/services/dids/keypair-utils.mjs +113 -0
- package/lib/services/dids/service-rpc.js +0 -3
- package/lib/services/dids/service-rpc.mjs +0 -3
- package/lib/services/dids/service.js +13 -55
- package/lib/services/dids/service.mjs +13 -54
- package/lib/services/edv/index.js +4 -25
- package/lib/services/edv/index.mjs +4 -25
- package/lib/services/edv/service.js +6 -33
- package/lib/services/edv/service.mjs +6 -33
- package/lib/services/index.js +13 -25
- package/lib/services/index.mjs +13 -25
- package/lib/services/relay-service/configs.js +0 -1
- package/lib/services/relay-service/configs.mjs +0 -1
- package/lib/services/relay-service/index.android.js +0 -1
- package/lib/services/relay-service/index.android.mjs +0 -1
- package/lib/services/relay-service/index.ios.js +0 -1
- package/lib/services/relay-service/index.ios.mjs +0 -1
- package/lib/services/relay-service/index.js +0 -1
- package/lib/services/relay-service/index.mjs +0 -1
- package/lib/services/relay-service/service-rpc.js +0 -1
- package/lib/services/relay-service/service-rpc.mjs +0 -1
- package/lib/services/relay-service/service.js +0 -1
- package/lib/services/relay-service/service.mjs +0 -1
- package/lib/services/test-utils.js +0 -44
- package/lib/services/test-utils.mjs +1 -44
- package/lib/services/util-crypto/configs.js +0 -12
- package/lib/services/util-crypto/configs.mjs +0 -12
- package/lib/services/util-crypto/index.android.js +0 -3
- package/lib/services/util-crypto/index.android.mjs +0 -3
- package/lib/services/util-crypto/index.ios.js +0 -3
- package/lib/services/util-crypto/index.ios.mjs +0 -3
- package/lib/services/util-crypto/index.js +4 -7
- package/lib/services/util-crypto/index.mjs +4 -7
- package/lib/services/util-crypto/service-rpc.js +2 -30
- package/lib/services/util-crypto/service-rpc.mjs +2 -30
- package/lib/services/util-crypto/service.js +68 -61
- package/lib/services/util-crypto/service.mjs +50 -59
- package/lib/services/wallet/configs.js +0 -63
- package/lib/services/wallet/configs.mjs +1 -64
- package/lib/services/wallet/index.android.js +0 -1
- package/lib/services/wallet/index.android.mjs +0 -1
- package/lib/services/wallet/index.ios.js +0 -1
- package/lib/services/wallet/index.ios.mjs +0 -1
- package/lib/services/wallet/index.js +2 -12
- package/lib/services/wallet/index.mjs +2 -12
- package/lib/services/wallet/service-rpc.js +0 -77
- package/lib/services/wallet/service-rpc.mjs +0 -77
- package/lib/services/wallet/service.js +1 -215
- package/lib/services/wallet/service.mjs +1 -211
- package/lib/setup-nodejs.js +13 -23
- package/lib/setup-nodejs.mjs +13 -23
- package/lib/setup-tests.js +13 -23
- package/lib/setup-tests.mjs +13 -23
- package/lib/src/core/format-utils.d.ts +0 -5
- package/lib/src/core/format-utils.d.ts.map +1 -1
- package/lib/src/core/validation.d.ts +0 -3
- package/lib/src/core/validation.d.ts.map +1 -1
- package/lib/src/rpc-util.d.ts.map +1 -1
- package/lib/src/services/blockchain/service.d.ts.map +1 -1
- package/lib/src/services/credential/bbs-revocation.d.ts.map +1 -1
- package/lib/src/services/credential/bound-check.d.ts +1 -1
- package/lib/src/services/credential/bound-check.d.ts.map +1 -1
- package/lib/src/services/credential/service.d.ts.map +1 -1
- package/lib/src/services/credential/utils.d.ts +2 -1
- package/lib/src/services/credential/utils.d.ts.map +1 -1
- package/lib/src/services/dids/keypair-utils.d.ts +15 -0
- package/lib/src/services/dids/keypair-utils.d.ts.map +1 -0
- package/lib/src/services/dids/service-rpc.d.ts +0 -1
- package/lib/src/services/dids/service-rpc.d.ts.map +1 -1
- package/lib/src/services/dids/service.d.ts +11 -8
- package/lib/src/services/dids/service.d.ts.map +1 -1
- package/lib/src/services/edv/service.d.ts.map +1 -1
- package/lib/src/services/util-crypto/configs.d.ts +0 -3
- package/lib/src/services/util-crypto/configs.d.ts.map +1 -1
- package/lib/src/services/util-crypto/service.d.ts +3 -8
- package/lib/src/services/util-crypto/service.d.ts.map +1 -1
- package/lib/src/services/wallet/configs.d.ts +13 -0
- package/lib/src/services/wallet/configs.d.ts.map +1 -0
- package/lib/src/services/wallet/service.d.ts +1 -44
- package/lib/src/services/wallet/service.d.ts.map +1 -1
- package/lib/test-utils.js +0 -4
- package/lib/test-utils.mjs +1 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -25
- package/readme.md +0 -61
- package/src/core/format-utils.test.js +1 -28
- package/src/core/format-utils.ts +0 -33
- package/src/core/validation.test.js +1 -33
- package/src/core/validation.ts +1 -25
- package/src/rpc-server.test.js +2 -9
- package/src/rpc-util.js +14 -0
- package/src/services/blockchain/service.ts +2 -3
- package/src/services/credential/bbs-revocation.ts +2 -1
- package/src/services/credential/bound-check.test.ts +6 -6
- package/src/services/credential/bound-check.ts +4 -4
- package/src/services/credential/index.test.js +0 -2
- package/src/services/credential/service.ts +5 -2
- package/src/services/credential/utils.js +65 -23
- package/src/services/dids/index.test.js +45 -33
- package/src/services/dids/keypair-utils.js +111 -0
- package/src/services/dids/service-rpc.ts +0 -3
- package/src/services/dids/service.ts +7 -34
- package/src/services/edv/service.ts +2 -9
- package/src/services/index.js +0 -4
- package/src/services/test-utils.js +0 -29
- package/src/services/util-crypto/configs.ts +0 -12
- package/src/services/util-crypto/index.test.js +6 -83
- package/src/services/util-crypto/service-rpc.js +2 -27
- package/src/services/util-crypto/service.ts +62 -75
- package/src/services/wallet/configs.ts +1 -113
- package/src/services/wallet/index.test.js +0 -159
- package/src/services/wallet/service-rpc.js +1 -88
- package/src/services/wallet/service.ts +0 -258
- package/src/test-utils.js +0 -13
- package/lib/account-357ab05d.js +0 -742
- package/lib/account-399e6053.js +0 -752
- package/lib/core/polkadot-utils.js +0 -119
- package/lib/core/polkadot-utils.mjs +0 -94
- package/lib/core/realm-schemas.js +0 -50
- package/lib/core/realm-schemas.mjs +0 -44
- package/lib/core/subscan.js +0 -75
- package/lib/core/subscan.mjs +0 -64
- package/lib/fixtures.js +0 -56
- package/lib/fixtures.mjs +0 -52
- package/lib/modules/account.js +0 -48
- package/lib/modules/account.mjs +0 -40
- package/lib/modules/accounts.js +0 -49
- package/lib/modules/accounts.mjs +0 -40
- package/lib/modules/data-migration.js +0 -72
- package/lib/modules/data-migration.mjs +0 -68
- package/lib/modules/wallet-backup.js +0 -82
- package/lib/modules/wallet-backup.mjs +0 -71
- package/lib/modules/wallet.js +0 -49
- package/lib/modules/wallet.mjs +0 -40
- package/lib/services/example/configs.js +0 -21
- package/lib/services/example/configs.mjs +0 -13
- package/lib/services/example/index.js +0 -18
- package/lib/services/example/index.mjs +0 -14
- package/lib/services/example/service-rpc.js +0 -25
- package/lib/services/example/service-rpc.mjs +0 -21
- package/lib/services/example/service.js +0 -25
- package/lib/services/example/service.mjs +0 -20
- package/lib/services/keyring/configs.js +0 -70
- package/lib/services/keyring/configs.mjs +0 -61
- package/lib/services/keyring/index.android.js +0 -22
- package/lib/services/keyring/index.android.mjs +0 -18
- package/lib/services/keyring/index.ios.js +0 -22
- package/lib/services/keyring/index.ios.mjs +0 -18
- package/lib/services/keyring/index.js +0 -16
- package/lib/services/keyring/index.mjs +0 -8
- package/lib/services/keyring/service-rpc.js +0 -65
- package/lib/services/keyring/service-rpc.mjs +0 -61
- package/lib/services/keyring/service.js +0 -84
- package/lib/services/keyring/service.mjs +0 -74
- package/lib/services/polkadot/configs.js +0 -17
- package/lib/services/polkadot/configs.mjs +0 -13
- package/lib/services/polkadot/index.android.js +0 -22
- package/lib/services/polkadot/index.android.mjs +0 -18
- package/lib/services/polkadot/index.ios.js +0 -22
- package/lib/services/polkadot/index.ios.mjs +0 -18
- package/lib/services/polkadot/index.js +0 -15
- package/lib/services/polkadot/index.mjs +0 -7
- package/lib/services/polkadot/service-rpc.js +0 -30
- package/lib/services/polkadot/service-rpc.mjs +0 -26
- package/lib/services/polkadot/service.js +0 -28
- package/lib/services/polkadot/service.mjs +0 -23
- package/lib/src/core/polkadot-utils.d.ts +0 -11
- package/lib/src/core/polkadot-utils.d.ts.map +0 -1
- package/lib/src/modules/account.d.ts +0 -60
- package/lib/src/modules/account.d.ts.map +0 -1
- package/lib/src/modules/accounts.d.ts +0 -48
- package/lib/src/modules/accounts.d.ts.map +0 -1
- package/lib/src/modules/data-migration.d.ts +0 -7
- package/lib/src/modules/data-migration.d.ts.map +0 -1
- package/lib/src/modules/wallet-backup.d.ts +0 -12
- package/lib/src/modules/wallet-backup.d.ts.map +0 -1
- package/lib/src/modules/wallet.d.ts +0 -134
- package/lib/src/modules/wallet.d.ts.map +0 -1
- package/lib/src/services/blockchain/index.d.ts +0 -2
- package/lib/src/services/blockchain/index.d.ts.map +0 -1
- package/lib/src/services/example/configs.d.ts +0 -9
- package/lib/src/services/example/configs.d.ts.map +0 -1
- package/lib/src/services/example/service.d.ts +0 -8
- package/lib/src/services/example/service.d.ts.map +0 -1
- package/lib/src/services/keyring/configs.d.ts +0 -39
- package/lib/src/services/keyring/configs.d.ts.map +0 -1
- package/lib/src/services/keyring/index.d.ts +0 -2
- package/lib/src/services/keyring/index.d.ts.map +0 -1
- package/lib/src/services/polkadot/configs.d.ts +0 -8
- package/lib/src/services/polkadot/configs.d.ts.map +0 -1
- package/lib/src/services/polkadot/index.d.ts +0 -2
- package/lib/src/services/polkadot/index.d.ts.map +0 -1
- package/lib/src/services/polkadot/service.d.ts +0 -8
- package/lib/src/services/polkadot/service.d.ts.map +0 -1
- package/lib/src/services/wallet/index.d.ts +0 -2
- package/lib/src/services/wallet/index.d.ts.map +0 -1
- package/lib/test/axiosMocks.js +0 -431
- package/lib/test/axiosMocks.mjs +0 -420
- package/lib/test/setup-test-state.js +0 -81
- package/lib/test/setup-test-state.mjs +0 -73
- package/src/core/polkadot-utils.js +0 -99
- package/src/core/realm-schemas.js +0 -42
- package/src/core/subscan.js +0 -62
- package/src/core/subscan.test.js +0 -56
- package/src/fixtures.js +0 -43
- package/src/modules/account.test.js +0 -56
- package/src/modules/account.ts +0 -128
- package/src/modules/accounts.test.js +0 -63
- package/src/modules/accounts.ts +0 -231
- package/src/modules/data-migration.test.js +0 -61
- package/src/modules/data-migration.ts +0 -86
- package/src/modules/wallet-backup.test.js +0 -24
- package/src/modules/wallet-backup.ts +0 -68
- package/src/modules/wallet.test.js +0 -216
- package/src/modules/wallet.ts +0 -424
- package/src/services/example/configs.js +0 -14
- package/src/services/example/index.js +0 -3
- package/src/services/example/index.test.js +0 -28
- package/src/services/example/service-rpc.js +0 -11
- package/src/services/example/service.ts +0 -18
- package/src/services/keyring/configs.ts +0 -110
- package/src/services/keyring/index.android.js +0 -3
- package/src/services/keyring/index.ios.js +0 -3
- package/src/services/keyring/index.js +0 -1
- package/src/services/keyring/index.test.js +0 -48
- package/src/services/keyring/service-rpc.js +0 -56
- package/src/services/keyring/service.ts +0 -111
- package/src/services/polkadot/configs.ts +0 -13
- package/src/services/polkadot/index.android.js +0 -3
- package/src/services/polkadot/index.ios.js +0 -3
- package/src/services/polkadot/index.js +0 -1
- package/src/services/polkadot/index.test.js +0 -52
- package/src/services/polkadot/service-rpc.js +0 -13
- package/src/services/polkadot/service.ts +0 -21
- package/src/test/axiosMocks.js +0 -20
- package/src/test/fixtures/subscan-failure.json +0 -5
- package/src/test/fixtures/subscan-success.json +0 -370
- package/src/test/fixtures/subscan-too-many-requests.json +0 -9
- package/src/test/setup-test-state.js +0 -35
- package/src/test/test-wallet.test.js +0 -15
|
@@ -3,24 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var services_wallet_service = require('./service.js');
|
|
6
|
-
require('assert');
|
|
7
|
-
require('uuid');
|
|
8
6
|
require('../../wallet/memory-storage-wallet.js');
|
|
9
7
|
require('@docknetwork/universal-wallet/storage-wallet');
|
|
10
8
|
require('../../wallet/memory-storage-interface.js');
|
|
11
9
|
require('@docknetwork/universal-wallet/storage/storage-interface');
|
|
12
|
-
require('
|
|
13
|
-
require('
|
|
14
|
-
require('../storage/service.js');
|
|
15
|
-
require('../../core/logger.js');
|
|
16
|
-
require('../keyring/service.js');
|
|
17
|
-
require('@polkadot/keyring');
|
|
18
|
-
require('@polkadot/util-crypto');
|
|
19
|
-
require('../keyring/configs.js');
|
|
10
|
+
require('./configs.js');
|
|
11
|
+
require('assert');
|
|
20
12
|
require('../../core/validation.js');
|
|
21
|
-
require('bignumber.js');
|
|
22
13
|
require('../../types.js');
|
|
23
|
-
require('./configs.js');
|
|
24
14
|
|
|
25
15
|
|
|
26
16
|
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
export { walletService } from './service.mjs';
|
|
2
|
-
import 'assert';
|
|
3
|
-
import 'uuid';
|
|
4
2
|
import '../../wallet/memory-storage-wallet.mjs';
|
|
5
3
|
import '@docknetwork/universal-wallet/storage-wallet';
|
|
6
4
|
import '../../wallet/memory-storage-interface.mjs';
|
|
7
5
|
import '@docknetwork/universal-wallet/storage/storage-interface';
|
|
8
|
-
import '
|
|
9
|
-
import '
|
|
10
|
-
import '../storage/service.mjs';
|
|
11
|
-
import '../../core/logger.mjs';
|
|
12
|
-
import '../keyring/service.mjs';
|
|
13
|
-
import '@polkadot/keyring';
|
|
14
|
-
import '@polkadot/util-crypto';
|
|
15
|
-
import '../keyring/configs.mjs';
|
|
6
|
+
import './configs.mjs';
|
|
7
|
+
import 'assert';
|
|
16
8
|
import '../../core/validation.mjs';
|
|
17
|
-
import 'bignumber.js';
|
|
18
9
|
import '../../types.mjs';
|
|
19
|
-
import './configs.mjs';
|
|
@@ -13,7 +13,6 @@ require('../../core/logger.js');
|
|
|
13
13
|
require('../../logger.js');
|
|
14
14
|
require('../../rpc-util.js');
|
|
15
15
|
require('../../core/validation.js');
|
|
16
|
-
require('bignumber.js');
|
|
17
16
|
require('../../types.js');
|
|
18
17
|
|
|
19
18
|
class WalletServiceRpc extends services_rpcServiceClient.RpcService {
|
|
@@ -21,82 +20,6 @@ class WalletServiceRpc extends services_rpcServiceClient.RpcService {
|
|
|
21
20
|
super(services_wallet_configs.serviceName);
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
getDocumentById(id ) {
|
|
25
|
-
services_wallet_configs.validation.getDocumentById(id);
|
|
26
|
-
return this.call('getDocumentById', id);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
create(params ) {
|
|
30
|
-
services_wallet_configs.validation.create(params);
|
|
31
|
-
return this.call('create', params);
|
|
32
|
-
}
|
|
33
|
-
load() {
|
|
34
|
-
return this.call('load');
|
|
35
|
-
}
|
|
36
|
-
sync() {
|
|
37
|
-
return this.call('sync');
|
|
38
|
-
}
|
|
39
|
-
lock(password) {
|
|
40
|
-
return this.call('lock');
|
|
41
|
-
}
|
|
42
|
-
healthCheck(timestamp) {
|
|
43
|
-
return this.call('healthCheck', timestamp);
|
|
44
|
-
}
|
|
45
|
-
unlock(password) {
|
|
46
|
-
return this.call('unlock');
|
|
47
|
-
}
|
|
48
|
-
status() {
|
|
49
|
-
return this.call('status');
|
|
50
|
-
}
|
|
51
|
-
toJSON() {
|
|
52
|
-
return this.call('toJSON');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
add(params ) {
|
|
56
|
-
services_wallet_configs.validation.add(params);
|
|
57
|
-
return this.call('add', params);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
remove(id ) {
|
|
61
|
-
services_wallet_configs.validation.remove(id);
|
|
62
|
-
return this.call('remove', id);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
update(params ) {
|
|
66
|
-
services_wallet_configs.validation.update(params);
|
|
67
|
-
return this.call('update', params);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
query(params ) {
|
|
71
|
-
services_wallet_configs.validation.query(params);
|
|
72
|
-
return this.call('query', params);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
exportWallet(password ) {
|
|
76
|
-
services_wallet_configs.validation.exportWallet(password);
|
|
77
|
-
return this.call('exportWallet', password);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
importWallet(params ) {
|
|
81
|
-
services_wallet_configs.validation.importWallet(params);
|
|
82
|
-
return this.call('importWallet', params);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
exportAccount(params ) {
|
|
86
|
-
services_wallet_configs.validation.exportAccount(params);
|
|
87
|
-
return this.call('exportAccount', params);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
createAccountDocuments(params ) {
|
|
91
|
-
services_wallet_configs.validation.createAccountDocuments(params);
|
|
92
|
-
return this.call('createAccountDocuments', params);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
resolveCorrelations(address ) {
|
|
96
|
-
services_wallet_configs.validation.resolveCorrelations(address);
|
|
97
|
-
return this.call('resolveCorrelations', address);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
23
|
getDocumentsFromEncryptedWallet(params ) {
|
|
101
24
|
services_wallet_configs.validation.getDocumentsFromEncryptedWallet(params);
|
|
102
25
|
return this.call('getDocumentsFromEncryptedWallet', params);
|
|
@@ -9,7 +9,6 @@ import '../../core/logger.mjs';
|
|
|
9
9
|
import '../../logger.mjs';
|
|
10
10
|
import '../../rpc-util.mjs';
|
|
11
11
|
import '../../core/validation.mjs';
|
|
12
|
-
import 'bignumber.js';
|
|
13
12
|
import '../../types.mjs';
|
|
14
13
|
|
|
15
14
|
class WalletServiceRpc extends RpcService {
|
|
@@ -17,82 +16,6 @@ class WalletServiceRpc extends RpcService {
|
|
|
17
16
|
super(serviceName);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
getDocumentById(id ) {
|
|
21
|
-
validation.getDocumentById(id);
|
|
22
|
-
return this.call('getDocumentById', id);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
create(params ) {
|
|
26
|
-
validation.create(params);
|
|
27
|
-
return this.call('create', params);
|
|
28
|
-
}
|
|
29
|
-
load() {
|
|
30
|
-
return this.call('load');
|
|
31
|
-
}
|
|
32
|
-
sync() {
|
|
33
|
-
return this.call('sync');
|
|
34
|
-
}
|
|
35
|
-
lock(password) {
|
|
36
|
-
return this.call('lock');
|
|
37
|
-
}
|
|
38
|
-
healthCheck(timestamp) {
|
|
39
|
-
return this.call('healthCheck', timestamp);
|
|
40
|
-
}
|
|
41
|
-
unlock(password) {
|
|
42
|
-
return this.call('unlock');
|
|
43
|
-
}
|
|
44
|
-
status() {
|
|
45
|
-
return this.call('status');
|
|
46
|
-
}
|
|
47
|
-
toJSON() {
|
|
48
|
-
return this.call('toJSON');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
add(params ) {
|
|
52
|
-
validation.add(params);
|
|
53
|
-
return this.call('add', params);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
remove(id ) {
|
|
57
|
-
validation.remove(id);
|
|
58
|
-
return this.call('remove', id);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
update(params ) {
|
|
62
|
-
validation.update(params);
|
|
63
|
-
return this.call('update', params);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
query(params ) {
|
|
67
|
-
validation.query(params);
|
|
68
|
-
return this.call('query', params);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
exportWallet(password ) {
|
|
72
|
-
validation.exportWallet(password);
|
|
73
|
-
return this.call('exportWallet', password);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
importWallet(params ) {
|
|
77
|
-
validation.importWallet(params);
|
|
78
|
-
return this.call('importWallet', params);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
exportAccount(params ) {
|
|
82
|
-
validation.exportAccount(params);
|
|
83
|
-
return this.call('exportAccount', params);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
createAccountDocuments(params ) {
|
|
87
|
-
validation.createAccountDocuments(params);
|
|
88
|
-
return this.call('createAccountDocuments', params);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
resolveCorrelations(address ) {
|
|
92
|
-
validation.resolveCorrelations(address);
|
|
93
|
-
return this.call('resolveCorrelations', address);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
19
|
getDocumentsFromEncryptedWallet(params ) {
|
|
97
20
|
validation.getDocumentsFromEncryptedWallet(params);
|
|
98
21
|
return this.call('getDocumentsFromEncryptedWallet', params);
|
|
@@ -2,241 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var assert = require('assert');
|
|
6
|
-
var uuid = require('uuid');
|
|
7
5
|
var wallet_memoryStorageWallet = require('../../wallet/memory-storage-wallet.js');
|
|
8
|
-
var wallet_rpcStorageWallet = require('../../wallet/rpc-storage-wallet.js');
|
|
9
|
-
var services_keyring_service = require('../keyring/service.js');
|
|
10
6
|
var services_wallet_configs = require('./configs.js');
|
|
11
|
-
var core_logger = require('../../core/logger.js');
|
|
12
7
|
require('@docknetwork/universal-wallet/storage-wallet');
|
|
13
8
|
require('../../wallet/memory-storage-interface.js');
|
|
14
9
|
require('@docknetwork/universal-wallet/storage/storage-interface');
|
|
15
|
-
require('
|
|
16
|
-
require('../storage/service.js');
|
|
17
|
-
require('@polkadot/keyring');
|
|
18
|
-
require('@polkadot/util-crypto');
|
|
19
|
-
require('../keyring/configs.js');
|
|
10
|
+
require('assert');
|
|
20
11
|
require('../../core/validation.js');
|
|
21
|
-
require('bignumber.js');
|
|
22
12
|
require('../../types.js');
|
|
23
13
|
|
|
24
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
25
|
-
|
|
26
|
-
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
|
|
27
|
-
|
|
28
14
|
/**
|
|
29
15
|
* WalletService
|
|
30
16
|
*/
|
|
31
17
|
class WalletService {
|
|
32
18
|
wallet;
|
|
33
19
|
rpcMethods = [
|
|
34
|
-
WalletService.prototype.create,
|
|
35
|
-
WalletService.prototype.add,
|
|
36
|
-
WalletService.prototype.exportWallet,
|
|
37
|
-
WalletService.prototype.importWallet,
|
|
38
|
-
WalletService.prototype.resolveCorrelations,
|
|
39
|
-
WalletService.prototype.createAccountDocuments,
|
|
40
|
-
WalletService.prototype.exportAccount,
|
|
41
|
-
WalletService.prototype.getDocumentById,
|
|
42
|
-
WalletService.prototype.load,
|
|
43
|
-
WalletService.prototype.lock,
|
|
44
|
-
WalletService.prototype.query,
|
|
45
|
-
WalletService.prototype.remove,
|
|
46
|
-
WalletService.prototype.status,
|
|
47
|
-
WalletService.prototype.toJSON,
|
|
48
|
-
WalletService.prototype.sync,
|
|
49
|
-
WalletService.prototype.unlock,
|
|
50
|
-
WalletService.prototype.update,
|
|
51
|
-
WalletService.prototype.healthCheck,
|
|
52
20
|
WalletService.prototype.getDocumentsFromEncryptedWallet,
|
|
53
21
|
WalletService.prototype.exportDocuments,
|
|
54
22
|
];
|
|
55
23
|
constructor() {
|
|
56
24
|
this.name = services_wallet_configs.serviceName;
|
|
57
25
|
}
|
|
58
|
-
create(params) {
|
|
59
|
-
const { walletId, type } = params;
|
|
60
|
-
core_logger.Logger.debug('Creating wallet', params);
|
|
61
|
-
if (type === 'memory') {
|
|
62
|
-
this.wallet = new wallet_memoryStorageWallet(walletId);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
this.wallet = new wallet_rpcStorageWallet(walletId);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
healthCheck(timestamp) {
|
|
69
|
-
return `${this.name}: ${timestamp}`;
|
|
70
|
-
}
|
|
71
|
-
load() {
|
|
72
|
-
this._assertWallet();
|
|
73
|
-
return this.wallet.load();
|
|
74
|
-
}
|
|
75
|
-
sync() {
|
|
76
|
-
this._assertWallet();
|
|
77
|
-
return this.wallet.sync();
|
|
78
|
-
}
|
|
79
|
-
lock(password) {
|
|
80
|
-
this._assertWallet();
|
|
81
|
-
return this.wallet.lock(password);
|
|
82
|
-
}
|
|
83
|
-
unlock(password) {
|
|
84
|
-
this._assertWallet();
|
|
85
|
-
return this.wallet.unlock(password);
|
|
86
|
-
}
|
|
87
|
-
status() {
|
|
88
|
-
this._assertWallet();
|
|
89
|
-
return this.wallet.status;
|
|
90
|
-
}
|
|
91
|
-
toJSON() {
|
|
92
|
-
this._assertWallet();
|
|
93
|
-
return this.wallet.toJSON();
|
|
94
|
-
}
|
|
95
|
-
add(content) {
|
|
96
|
-
this._assertWallet();
|
|
97
|
-
services_wallet_configs.validation.add(content);
|
|
98
|
-
return this.wallet.add(content);
|
|
99
|
-
}
|
|
100
|
-
remove(id) {
|
|
101
|
-
this._assertWallet();
|
|
102
|
-
services_wallet_configs.validation.remove(id);
|
|
103
|
-
return this.wallet.remove(id);
|
|
104
|
-
}
|
|
105
|
-
update(content) {
|
|
106
|
-
this._assertWallet();
|
|
107
|
-
services_wallet_configs.validation.update(content);
|
|
108
|
-
return this.wallet.update(content);
|
|
109
|
-
}
|
|
110
|
-
query(search) {
|
|
111
|
-
this._assertWallet();
|
|
112
|
-
services_wallet_configs.validation.query(search);
|
|
113
|
-
return this.wallet.query(search);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
*
|
|
117
|
-
* @param {*} password
|
|
118
|
-
* @returns
|
|
119
|
-
*/
|
|
120
|
-
exportWallet(password) {
|
|
121
|
-
this._assertWallet();
|
|
122
|
-
services_wallet_configs.validation.exportWallet(password);
|
|
123
|
-
return this.wallet.export(password);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
*
|
|
127
|
-
* @param {*} param0
|
|
128
|
-
* @returns
|
|
129
|
-
*/
|
|
130
|
-
importWallet(params) {
|
|
131
|
-
this._assertWallet();
|
|
132
|
-
services_wallet_configs.validation.importWallet(params);
|
|
133
|
-
const { json, password } = params;
|
|
134
|
-
return this.wallet.import(json, password);
|
|
135
|
-
}
|
|
136
|
-
async removeAll() {
|
|
137
|
-
this._assertWallet();
|
|
138
|
-
const documents = await this.wallet.query({});
|
|
139
|
-
for (let doc of documents) {
|
|
140
|
-
await this.wallet.remove(doc.id);
|
|
141
|
-
}
|
|
142
|
-
await this.wallet.sync();
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
146
|
-
* @param {*} params
|
|
147
|
-
* @returns
|
|
148
|
-
*/
|
|
149
|
-
async exportAccount(params) {
|
|
150
|
-
services_wallet_configs.validation.exportAccount(params);
|
|
151
|
-
const { address, password, keyPairDocument } = params;
|
|
152
|
-
let pair;
|
|
153
|
-
if (keyPairDocument) {
|
|
154
|
-
pair = services_keyring_service.keyringService.decryptKeyPair({
|
|
155
|
-
jsonData: keyPairDocument,
|
|
156
|
-
password: '',
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
pair = await this.getAccountKeypair(address);
|
|
161
|
-
}
|
|
162
|
-
return pair.toJson(password);
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
*
|
|
166
|
-
* @param {*} params
|
|
167
|
-
* @returns
|
|
168
|
-
*/
|
|
169
|
-
async createAccountDocuments(params) {
|
|
170
|
-
this._assertWallet();
|
|
171
|
-
services_wallet_configs.validation.createAccountDocuments(params);
|
|
172
|
-
const { name, type = 'sr25519', derivePath, mnemonic, json, password, hasBackup } = params;
|
|
173
|
-
const keyringPair = json
|
|
174
|
-
? services_keyring_service.keyringService.decryptKeyPair({ jsonData: json, password })
|
|
175
|
-
: services_keyring_service.keyringService.getKeyringPair({ mnemonic, derivePath, type });
|
|
176
|
-
const keyringJson = keyringPair.toJson();
|
|
177
|
-
const correlationDocs = [];
|
|
178
|
-
correlationDocs.push({
|
|
179
|
-
'@context': ['https://w3id.org/wallet/v1'],
|
|
180
|
-
id: uuid.v4(),
|
|
181
|
-
type: 'KeyringPair',
|
|
182
|
-
value: keyringJson,
|
|
183
|
-
});
|
|
184
|
-
correlationDocs.push({
|
|
185
|
-
'@context': ['https://w3id.org/wallet/v1'],
|
|
186
|
-
id: uuid.v4(),
|
|
187
|
-
type: 'Currency',
|
|
188
|
-
value: 0,
|
|
189
|
-
symbol: 'DOCK',
|
|
190
|
-
});
|
|
191
|
-
if (mnemonic) {
|
|
192
|
-
correlationDocs.push({
|
|
193
|
-
'@context': ['https://w3id.org/wallet/v1'],
|
|
194
|
-
id: uuid.v4(),
|
|
195
|
-
type: 'Mnemonic',
|
|
196
|
-
value: mnemonic,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
core_logger.Logger.info(`Account created: ${keyringPair.address}`);
|
|
200
|
-
const addressDocument = {
|
|
201
|
-
'@context': ['https://w3id.org/wallet/v1'],
|
|
202
|
-
id: keyringPair.address,
|
|
203
|
-
type: 'Address',
|
|
204
|
-
value: keyringPair.address,
|
|
205
|
-
address: keyringPair.address,
|
|
206
|
-
name,
|
|
207
|
-
correlation: correlationDocs.map(doc => doc.id),
|
|
208
|
-
hasBackup,
|
|
209
|
-
};
|
|
210
|
-
await this.wallet.add(addressDocument);
|
|
211
|
-
await Promise.all(correlationDocs.map(doc => this.wallet.add(doc)));
|
|
212
|
-
return [addressDocument, ...correlationDocs];
|
|
213
|
-
}
|
|
214
|
-
async resolveCorrelations(documentId) {
|
|
215
|
-
const document = await this.getDocumentById(documentId);
|
|
216
|
-
assert__default["default"](!!document, `Document ${documentId} not found`);
|
|
217
|
-
const correlation = await Promise.all((document.correlation || []).map(docId => this.getDocumentById(docId)));
|
|
218
|
-
const result = [document, ...correlation];
|
|
219
|
-
return result;
|
|
220
|
-
}
|
|
221
|
-
_assertWallet() {
|
|
222
|
-
assert__default["default"](!!this.wallet, 'wallet is not created');
|
|
223
|
-
}
|
|
224
|
-
async getAccountKeypair(accountId) {
|
|
225
|
-
const correlations = await this.resolveCorrelations(accountId);
|
|
226
|
-
const keyPairDocument = correlations.find(doc => doc.type === 'KeyringPair');
|
|
227
|
-
assert__default["default"](!!keyPairDocument, `Keypair document not found for account: ${accountId}`);
|
|
228
|
-
const pair = services_keyring_service.keyringService.decryptKeyPair({
|
|
229
|
-
jsonData: keyPairDocument.value,
|
|
230
|
-
password: '',
|
|
231
|
-
});
|
|
232
|
-
pair.unlock();
|
|
233
|
-
return pair;
|
|
234
|
-
}
|
|
235
|
-
getDocumentById(id) {
|
|
236
|
-
this._assertWallet();
|
|
237
|
-
services_wallet_configs.validation.getDocumentById(id);
|
|
238
|
-
return this.wallet.getStorageDocument({ id }).then(doc => doc.content);
|
|
239
|
-
}
|
|
240
26
|
async getDocumentsFromEncryptedWallet(params) {
|
|
241
27
|
services_wallet_configs.validation.getDocumentsFromEncryptedWallet(params);
|
|
242
28
|
const { encryptedJSONWallet, password } = params;
|