@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/services/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { keyringService } from './keyring/service.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { blockchainService } from './blockchain/service.mjs';
|
|
3
3
|
import { substrateService } from './substrate/service.mjs';
|
|
4
4
|
import { walletService } from './wallet/service.mjs';
|
|
5
5
|
import { polkadotService } from './polkadot/service.mjs';
|
|
@@ -18,14 +18,18 @@ import 'assert';
|
|
|
18
18
|
import '../core/validation.mjs';
|
|
19
19
|
import 'bignumber.js';
|
|
20
20
|
import '../types.mjs';
|
|
21
|
-
import '@
|
|
21
|
+
import '@cosmjs/proto-signing';
|
|
22
|
+
import '@docknetwork/cheqd-blockchain-api';
|
|
23
|
+
import '@docknetwork/cheqd-blockchain-modules';
|
|
24
|
+
import '@docknetwork/credential-sdk/modules';
|
|
22
25
|
import '@docknetwork/credential-sdk/resolver';
|
|
23
|
-
import '@docknetwork/dock-blockchain-modules';
|
|
24
26
|
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
27
|
+
import '@docknetwork/dock-blockchain-api';
|
|
28
|
+
import '@docknetwork/dock-blockchain-modules';
|
|
25
29
|
import 'events';
|
|
26
30
|
import '../core/logger.mjs';
|
|
27
31
|
import '../modules/event-manager.mjs';
|
|
28
|
-
import '
|
|
32
|
+
import '@docknetwork/credential-sdk/types';
|
|
29
33
|
import 'bn.js';
|
|
30
34
|
import '../core/format-utils.mjs';
|
|
31
35
|
import './substrate/api-utils.mjs';
|
|
@@ -44,26 +48,19 @@ import '@polkadot/util';
|
|
|
44
48
|
import './util-crypto/configs.mjs';
|
|
45
49
|
import '@docknetwork/wallet-sdk-dids/lib';
|
|
46
50
|
import './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 './credential/utils.mjs';
|
|
56
|
-
import '@docknetwork/sdk/utils/vc/crypto/Bls12381G2KeyPairDock2022';
|
|
57
58
|
import '@docknetwork/credential-sdk/vc/crypto';
|
|
58
59
|
import './credential/config.mjs';
|
|
59
60
|
import '@docknetwork/crypto-wasm-ts';
|
|
60
61
|
import '@sphereon/oid4vci-client';
|
|
61
62
|
import '@sphereon/oid4vci-common';
|
|
62
|
-
import '@docknetwork/sdk/
|
|
63
|
-
import '@docknetwork/sdk/utils/vc/helpers';
|
|
64
|
-
import '@docknetwork/sdk/verifiable-presentation';
|
|
65
|
-
import '@docknetwork/sdk/presentation';
|
|
66
|
-
import '@docknetwork/sdk/utils/vc/credentials';
|
|
63
|
+
import '@docknetwork/credential-sdk/vc';
|
|
67
64
|
import '@sphereon/pex';
|
|
68
65
|
import './credential/bound-check.mjs';
|
|
69
66
|
import '@docknetwork/crypto-wasm-ts/lib/legosnark';
|
|
@@ -74,7 +71,6 @@ import './relay-service/configs.mjs';
|
|
|
74
71
|
import '@docknetwork/wallet-sdk-relay-service/lib';
|
|
75
72
|
import './pex/config.mjs';
|
|
76
73
|
import './trust-registry/configs.mjs';
|
|
77
|
-
import '@docknetwork/sdk/utils/did/typed-did/helpers';
|
|
78
74
|
import 'crypto';
|
|
79
75
|
import './edv/configs.mjs';
|
|
80
76
|
import '@docknetwork/universal-wallet/storage/edv-http-storage';
|
|
@@ -82,13 +78,14 @@ import './edv/hmac.mjs';
|
|
|
82
78
|
import 'base64url-universal';
|
|
83
79
|
import '@docknetwork/universal-wallet/crypto';
|
|
84
80
|
import '@digitalbazaar/ed25519-verification-key-2018';
|
|
81
|
+
import '@digitalbazaar/ed25519-verification-key-2020';
|
|
85
82
|
import '@digitalbazaar/x25519-key-agreement-key-2020';
|
|
86
83
|
import '@docknetwork/wallet-sdk-data-store/lib/logger';
|
|
87
84
|
import '@docknetwork/wallet-sdk-wasm/lib/services/keyring';
|
|
88
85
|
|
|
89
86
|
var services = [
|
|
90
87
|
keyringService,
|
|
91
|
-
|
|
88
|
+
blockchainService,
|
|
92
89
|
substrateService,
|
|
93
90
|
walletService,
|
|
94
91
|
polkadotService,
|
|
@@ -46,6 +46,18 @@ const validation = {
|
|
|
46
46
|
assert__default["default"](typeof meta === 'object', 'invalid meta');
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
+
createFromPair(params) {
|
|
50
|
+
const { pair, meta, type } = params;
|
|
51
|
+
assert__default["default"](typeof pair === 'object', 'invalid pair');
|
|
52
|
+
assert__default["default"](pair.publicKey instanceof Uint8Array, 'invalid publicKey');
|
|
53
|
+
assert__default["default"](pair.secretKey instanceof Uint8Array, 'invalid secretKey');
|
|
54
|
+
if (type) {
|
|
55
|
+
core_validation.assertKeyType(type);
|
|
56
|
+
}
|
|
57
|
+
if (meta) {
|
|
58
|
+
assert__default["default"](typeof meta === 'object', 'invalid meta');
|
|
59
|
+
}
|
|
60
|
+
},
|
|
49
61
|
signData(params) {
|
|
50
62
|
assert__default["default"](!!params.keyPair, 'invalid keypair');
|
|
51
63
|
assert__default["default"](!!params.data, 'invalid data');
|
|
@@ -38,6 +38,18 @@ const validation = {
|
|
|
38
38
|
assert(typeof meta === 'object', 'invalid meta');
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
+
createFromPair(params) {
|
|
42
|
+
const { pair, meta, type } = params;
|
|
43
|
+
assert(typeof pair === 'object', 'invalid pair');
|
|
44
|
+
assert(pair.publicKey instanceof Uint8Array, 'invalid publicKey');
|
|
45
|
+
assert(pair.secretKey instanceof Uint8Array, 'invalid secretKey');
|
|
46
|
+
if (type) {
|
|
47
|
+
assertKeyType(type);
|
|
48
|
+
}
|
|
49
|
+
if (meta) {
|
|
50
|
+
assert(typeof meta === 'object', 'invalid meta');
|
|
51
|
+
}
|
|
52
|
+
},
|
|
41
53
|
signData(params) {
|
|
42
54
|
assert(!!params.keyPair, 'invalid keypair');
|
|
43
55
|
assert(!!params.data, 'invalid data');
|
|
@@ -65,6 +65,11 @@ class KeyringService {
|
|
|
65
65
|
const { mnemonic, meta, type, derivePath = '' } = params;
|
|
66
66
|
return this.keyring.createFromUri(`${mnemonic.trim()}${derivePath}`, meta, type);
|
|
67
67
|
}
|
|
68
|
+
createFromPair(params) {
|
|
69
|
+
services_keyring_configs.validation.createFromPair(params);
|
|
70
|
+
const { pair, meta, type } = params;
|
|
71
|
+
return this.keyring.createFromPair(pair, meta, type);
|
|
72
|
+
}
|
|
68
73
|
getKeyringPairJSON(params) {
|
|
69
74
|
return this.getKeyringPair(params).toJson();
|
|
70
75
|
}
|
|
@@ -57,6 +57,11 @@ class KeyringService {
|
|
|
57
57
|
const { mnemonic, meta, type, derivePath = '' } = params;
|
|
58
58
|
return this.keyring.createFromUri(`${mnemonic.trim()}${derivePath}`, meta, type);
|
|
59
59
|
}
|
|
60
|
+
createFromPair(params) {
|
|
61
|
+
validation.createFromPair(params);
|
|
62
|
+
const { pair, meta, type } = params;
|
|
63
|
+
return this.keyring.createFromPair(pair, meta, type);
|
|
64
|
+
}
|
|
60
65
|
getKeyringPairJSON(params) {
|
|
61
66
|
return this.getKeyringPair(params).toJson();
|
|
62
67
|
}
|
|
@@ -16,36 +16,38 @@ const pex = new pex$1.PEX();
|
|
|
16
16
|
* This is a temporary workaround until the issue is fixed in the @sphereon/pex library
|
|
17
17
|
**/
|
|
18
18
|
function removeOptionalAttribute(presentationDefinition) {
|
|
19
|
-
presentationDefinition
|
|
19
|
+
// Deep clone the presentationDefinition to avoid mutating the original
|
|
20
|
+
const clonedPresentationDefinition = JSON.parse(JSON.stringify(presentationDefinition));
|
|
21
|
+
clonedPresentationDefinition.input_descriptors.forEach(inputDescriptor => {
|
|
20
22
|
if (!inputDescriptor.constraints?.fields?.length) {
|
|
21
23
|
return;
|
|
22
24
|
}
|
|
23
25
|
// Filter the optional fields
|
|
24
|
-
// If we include those fields, it might exclude few credentials from the resulsts
|
|
25
|
-
// e.g: Expiration date as optional, a credenntial without expiration date should be included
|
|
26
26
|
inputDescriptor.constraints.fields =
|
|
27
27
|
inputDescriptor.constraints.fields.filter(field => field.optional !== true);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
delete field.optional;
|
|
28
|
+
inputDescriptor.constraints.fields = inputDescriptor.constraints.fields.map(field => {
|
|
29
|
+
const updatedField = { ...field };
|
|
30
|
+
// Remove the optional attribute if it exists
|
|
31
|
+
if (updatedField.optional !== undefined) {
|
|
32
|
+
delete updatedField.optional;
|
|
34
33
|
}
|
|
34
|
+
// Remove the did format attribute if it exists
|
|
35
|
+
if (updatedField.filter?.format === 'did') {
|
|
36
|
+
delete updatedField.filter.format;
|
|
37
|
+
}
|
|
38
|
+
return updatedField;
|
|
35
39
|
});
|
|
36
|
-
//
|
|
37
|
-
// If we remove all fields, it will cause an error with PEX
|
|
38
|
-
// So, we add a placeholder field to avoid the error
|
|
40
|
+
// Handle case where all fields are optional
|
|
39
41
|
if (inputDescriptor.constraints.fields.length === 0) {
|
|
40
42
|
inputDescriptor.constraints.fields.push({
|
|
41
43
|
path: ['$.id'],
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
});
|
|
45
|
-
if (!
|
|
46
|
-
|
|
47
|
+
if (!clonedPresentationDefinition.id) {
|
|
48
|
+
clonedPresentationDefinition.id = 'id';
|
|
47
49
|
}
|
|
48
|
-
return
|
|
50
|
+
return clonedPresentationDefinition;
|
|
49
51
|
}
|
|
50
52
|
class PEXService {
|
|
51
53
|
name;
|
|
@@ -12,36 +12,38 @@ const pex = new PEX();
|
|
|
12
12
|
* This is a temporary workaround until the issue is fixed in the @sphereon/pex library
|
|
13
13
|
**/
|
|
14
14
|
function removeOptionalAttribute(presentationDefinition) {
|
|
15
|
-
presentationDefinition
|
|
15
|
+
// Deep clone the presentationDefinition to avoid mutating the original
|
|
16
|
+
const clonedPresentationDefinition = JSON.parse(JSON.stringify(presentationDefinition));
|
|
17
|
+
clonedPresentationDefinition.input_descriptors.forEach(inputDescriptor => {
|
|
16
18
|
if (!inputDescriptor.constraints?.fields?.length) {
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
21
|
// Filter the optional fields
|
|
20
|
-
// If we include those fields, it might exclude few credentials from the resulsts
|
|
21
|
-
// e.g: Expiration date as optional, a credenntial without expiration date should be included
|
|
22
22
|
inputDescriptor.constraints.fields =
|
|
23
23
|
inputDescriptor.constraints.fields.filter(field => field.optional !== true);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
delete field.optional;
|
|
24
|
+
inputDescriptor.constraints.fields = inputDescriptor.constraints.fields.map(field => {
|
|
25
|
+
const updatedField = { ...field };
|
|
26
|
+
// Remove the optional attribute if it exists
|
|
27
|
+
if (updatedField.optional !== undefined) {
|
|
28
|
+
delete updatedField.optional;
|
|
30
29
|
}
|
|
30
|
+
// Remove the did format attribute if it exists
|
|
31
|
+
if (updatedField.filter?.format === 'did') {
|
|
32
|
+
delete updatedField.filter.format;
|
|
33
|
+
}
|
|
34
|
+
return updatedField;
|
|
31
35
|
});
|
|
32
|
-
//
|
|
33
|
-
// If we remove all fields, it will cause an error with PEX
|
|
34
|
-
// So, we add a placeholder field to avoid the error
|
|
36
|
+
// Handle case where all fields are optional
|
|
35
37
|
if (inputDescriptor.constraints.fields.length === 0) {
|
|
36
38
|
inputDescriptor.constraints.fields.push({
|
|
37
39
|
path: ['$.id'],
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
});
|
|
41
|
-
if (!
|
|
42
|
-
|
|
43
|
+
if (!clonedPresentationDefinition.id) {
|
|
44
|
+
clonedPresentationDefinition.id = 'id';
|
|
43
45
|
}
|
|
44
|
-
return
|
|
46
|
+
return clonedPresentationDefinition;
|
|
45
47
|
}
|
|
46
48
|
class PEXService {
|
|
47
49
|
name;
|
|
@@ -5,13 +5,25 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var assert = require('assert');
|
|
6
6
|
var events = require('events');
|
|
7
7
|
var core_logger = require('../../core/logger.js');
|
|
8
|
-
var
|
|
9
|
-
require('@
|
|
8
|
+
var services_blockchain_service = require('../blockchain/service.js');
|
|
9
|
+
require('@cosmjs/proto-signing');
|
|
10
|
+
require('@docknetwork/cheqd-blockchain-api');
|
|
11
|
+
require('@docknetwork/cheqd-blockchain-modules');
|
|
12
|
+
require('@docknetwork/credential-sdk/modules');
|
|
10
13
|
require('@docknetwork/credential-sdk/resolver');
|
|
11
|
-
require('@docknetwork/dock-blockchain-modules');
|
|
12
14
|
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
15
|
+
require('@docknetwork/dock-blockchain-api');
|
|
16
|
+
require('@docknetwork/dock-blockchain-modules');
|
|
13
17
|
require('../../modules/event-manager.js');
|
|
14
|
-
require('../
|
|
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');
|
|
15
27
|
|
|
16
28
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
29
|
|
|
@@ -19,7 +31,7 @@ var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
|
|
|
19
31
|
|
|
20
32
|
// @ts-nocheck
|
|
21
33
|
const extrisicErrorsFilter = ({ event }) => {
|
|
22
|
-
return
|
|
34
|
+
return services_blockchain_service.blockchainService.dock.api.events.system.ExtrinsicFailed.is(event);
|
|
23
35
|
};
|
|
24
36
|
const mapEventToErrorMessage = ({ event }) => {
|
|
25
37
|
assert__default["default"](!!event, 'event is required');
|
|
@@ -27,7 +39,7 @@ const mapEventToErrorMessage = ({ event }) => {
|
|
|
27
39
|
assert__default["default"](!!error, 'error is required');
|
|
28
40
|
if (error.isModule) {
|
|
29
41
|
// for module errors, we have the section indexed, lookup
|
|
30
|
-
const decoded =
|
|
42
|
+
const decoded = services_blockchain_service.blockchainService.dock.api.registry.findMetaError(error.asModule);
|
|
31
43
|
const { docs, method, section } = decoded;
|
|
32
44
|
return `${section}.${method}: ${docs.join(' ')}`;
|
|
33
45
|
}
|
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { Logger } from '../../core/logger.mjs';
|
|
4
|
-
import {
|
|
5
|
-
import '@
|
|
4
|
+
import { blockchainService } from '../blockchain/service.mjs';
|
|
5
|
+
import '@cosmjs/proto-signing';
|
|
6
|
+
import '@docknetwork/cheqd-blockchain-api';
|
|
7
|
+
import '@docknetwork/cheqd-blockchain-modules';
|
|
8
|
+
import '@docknetwork/credential-sdk/modules';
|
|
6
9
|
import '@docknetwork/credential-sdk/resolver';
|
|
7
|
-
import '@docknetwork/dock-blockchain-modules';
|
|
8
10
|
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
11
|
+
import '@docknetwork/dock-blockchain-api';
|
|
12
|
+
import '@docknetwork/dock-blockchain-modules';
|
|
9
13
|
import '../../modules/event-manager.mjs';
|
|
10
|
-
import '../
|
|
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';
|
|
11
23
|
|
|
12
24
|
// @ts-nocheck
|
|
13
25
|
const extrisicErrorsFilter = ({ event }) => {
|
|
14
|
-
return
|
|
26
|
+
return blockchainService.dock.api.events.system.ExtrinsicFailed.is(event);
|
|
15
27
|
};
|
|
16
28
|
const mapEventToErrorMessage = ({ event }) => {
|
|
17
29
|
assert(!!event, 'event is required');
|
|
@@ -19,7 +31,7 @@ const mapEventToErrorMessage = ({ event }) => {
|
|
|
19
31
|
assert(!!error, 'error is required');
|
|
20
32
|
if (error.isModule) {
|
|
21
33
|
// for module errors, we have the section indexed, lookup
|
|
22
|
-
const decoded =
|
|
34
|
+
const decoded = blockchainService.dock.api.registry.findMetaError(error.asModule);
|
|
23
35
|
const { docs, method, section } = decoded;
|
|
24
36
|
return `${section}.${method}: ${docs.join(' ')}`;
|
|
25
37
|
}
|
|
@@ -9,20 +9,27 @@ require('bn.js');
|
|
|
9
9
|
require('../../core/format-utils.js');
|
|
10
10
|
require('../../core/validation.js');
|
|
11
11
|
require('../../types.js');
|
|
12
|
-
require('../
|
|
13
|
-
require('@
|
|
12
|
+
require('../blockchain/service.js');
|
|
13
|
+
require('@cosmjs/proto-signing');
|
|
14
|
+
require('@docknetwork/cheqd-blockchain-api');
|
|
15
|
+
require('@docknetwork/cheqd-blockchain-modules');
|
|
16
|
+
require('@docknetwork/credential-sdk/modules');
|
|
14
17
|
require('@docknetwork/credential-sdk/resolver');
|
|
15
|
-
require('@docknetwork/dock-blockchain-modules');
|
|
16
18
|
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
19
|
+
require('@docknetwork/dock-blockchain-api');
|
|
20
|
+
require('@docknetwork/dock-blockchain-modules');
|
|
17
21
|
require('events');
|
|
18
22
|
require('../../core/logger.js');
|
|
19
23
|
require('../../modules/event-manager.js');
|
|
20
|
-
require('../
|
|
24
|
+
require('../util-crypto/service.js');
|
|
25
|
+
require('@polkadot/keyring');
|
|
26
|
+
require('@polkadot/util');
|
|
27
|
+
require('@polkadot/util-crypto');
|
|
28
|
+
require('../util-crypto/configs.js');
|
|
29
|
+
require('@docknetwork/credential-sdk/types');
|
|
21
30
|
require('./api-utils.js');
|
|
22
31
|
require('./configs.js');
|
|
23
32
|
require('../keyring/service.js');
|
|
24
|
-
require('@polkadot/keyring');
|
|
25
|
-
require('@polkadot/util-crypto');
|
|
26
33
|
require('../keyring/configs.js');
|
|
27
34
|
|
|
28
35
|
|
|
@@ -5,18 +5,25 @@ import 'bn.js';
|
|
|
5
5
|
import '../../core/format-utils.mjs';
|
|
6
6
|
import '../../core/validation.mjs';
|
|
7
7
|
import '../../types.mjs';
|
|
8
|
-
import '../
|
|
9
|
-
import '@
|
|
8
|
+
import '../blockchain/service.mjs';
|
|
9
|
+
import '@cosmjs/proto-signing';
|
|
10
|
+
import '@docknetwork/cheqd-blockchain-api';
|
|
11
|
+
import '@docknetwork/cheqd-blockchain-modules';
|
|
12
|
+
import '@docknetwork/credential-sdk/modules';
|
|
10
13
|
import '@docknetwork/credential-sdk/resolver';
|
|
11
|
-
import '@docknetwork/dock-blockchain-modules';
|
|
12
14
|
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
15
|
+
import '@docknetwork/dock-blockchain-api';
|
|
16
|
+
import '@docknetwork/dock-blockchain-modules';
|
|
13
17
|
import 'events';
|
|
14
18
|
import '../../core/logger.mjs';
|
|
15
19
|
import '../../modules/event-manager.mjs';
|
|
16
|
-
import '../
|
|
20
|
+
import '../util-crypto/service.mjs';
|
|
21
|
+
import '@polkadot/keyring';
|
|
22
|
+
import '@polkadot/util';
|
|
23
|
+
import '@polkadot/util-crypto';
|
|
24
|
+
import '../util-crypto/configs.mjs';
|
|
25
|
+
import '@docknetwork/credential-sdk/types';
|
|
17
26
|
import './api-utils.mjs';
|
|
18
27
|
import './configs.mjs';
|
|
19
28
|
import '../keyring/service.mjs';
|
|
20
|
-
import '@polkadot/keyring';
|
|
21
|
-
import '@polkadot/util-crypto';
|
|
22
29
|
import '../keyring/configs.mjs';
|
|
@@ -6,22 +6,29 @@ var assert = require('assert');
|
|
|
6
6
|
var BigNumber = require('bignumber.js');
|
|
7
7
|
var BN = require('bn.js');
|
|
8
8
|
var core_formatUtils = require('../../core/format-utils.js');
|
|
9
|
-
var
|
|
9
|
+
var services_blockchain_service = require('../blockchain/service.js');
|
|
10
10
|
var services_substrate_apiUtils = require('./api-utils.js');
|
|
11
11
|
var services_substrate_configs = require('./configs.js');
|
|
12
12
|
var services_keyring_service = require('../keyring/service.js');
|
|
13
13
|
require('../../core/validation.js');
|
|
14
14
|
require('../../types.js');
|
|
15
|
-
require('@
|
|
15
|
+
require('@cosmjs/proto-signing');
|
|
16
|
+
require('@docknetwork/cheqd-blockchain-api');
|
|
17
|
+
require('@docknetwork/cheqd-blockchain-modules');
|
|
18
|
+
require('@docknetwork/credential-sdk/modules');
|
|
16
19
|
require('@docknetwork/credential-sdk/resolver');
|
|
17
|
-
require('@docknetwork/dock-blockchain-modules');
|
|
18
20
|
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
21
|
+
require('@docknetwork/dock-blockchain-api');
|
|
22
|
+
require('@docknetwork/dock-blockchain-modules');
|
|
19
23
|
require('events');
|
|
20
24
|
require('../../core/logger.js');
|
|
21
25
|
require('../../modules/event-manager.js');
|
|
22
|
-
require('../
|
|
26
|
+
require('../util-crypto/service.js');
|
|
23
27
|
require('@polkadot/keyring');
|
|
28
|
+
require('@polkadot/util');
|
|
24
29
|
require('@polkadot/util-crypto');
|
|
30
|
+
require('../util-crypto/configs.js');
|
|
31
|
+
require('@docknetwork/credential-sdk/types');
|
|
25
32
|
require('../keyring/configs.js');
|
|
26
33
|
|
|
27
34
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -48,9 +55,9 @@ class SubstrateService {
|
|
|
48
55
|
async getAccountBalance(params) {
|
|
49
56
|
services_substrate_configs.validation.getAccountBalance(params);
|
|
50
57
|
console.log('ensure dock ready');
|
|
51
|
-
await
|
|
58
|
+
await services_blockchain_service.blockchainService.ensureBlockchainReady();
|
|
52
59
|
console.log('ensure dock ready done');
|
|
53
|
-
const { data: { free }, } = await
|
|
60
|
+
const { data: { free }, } = await services_blockchain_service.blockchainService.dock.api.query.system.account(params.address);
|
|
54
61
|
return free.toNumber() / core_formatUtils.DOCK_TOKEN_UNIT;
|
|
55
62
|
}
|
|
56
63
|
async getFeeAmount(params) {
|
|
@@ -61,8 +68,8 @@ class SubstrateService {
|
|
|
61
68
|
jsonData: keyPair,
|
|
62
69
|
password: '',
|
|
63
70
|
});
|
|
64
|
-
|
|
65
|
-
const extrinsic =
|
|
71
|
+
services_blockchain_service.blockchainService.dock.setAccount(account);
|
|
72
|
+
const extrinsic = services_blockchain_service.blockchainService.dock.api.tx.balances.transfer(toAddress, amount);
|
|
66
73
|
const paymentInfo = await extrinsic.paymentInfo(account);
|
|
67
74
|
const fee = getFeeWithBuffer(paymentInfo.partialFee)
|
|
68
75
|
.dividedBy(core_formatUtils.DOCK_TOKEN_UNIT)
|
|
@@ -77,7 +84,7 @@ class SubstrateService {
|
|
|
77
84
|
jsonData: keyPair,
|
|
78
85
|
password: '',
|
|
79
86
|
});
|
|
80
|
-
const { dock } =
|
|
87
|
+
const { dock } = services_blockchain_service.blockchainService;
|
|
81
88
|
dock.setAccount(account);
|
|
82
89
|
if (params.transferAll) {
|
|
83
90
|
const api = dock.api;
|
|
@@ -2,22 +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 '@
|
|
11
|
+
import '@cosmjs/proto-signing';
|
|
12
|
+
import '@docknetwork/cheqd-blockchain-api';
|
|
13
|
+
import '@docknetwork/cheqd-blockchain-modules';
|
|
14
|
+
import '@docknetwork/credential-sdk/modules';
|
|
12
15
|
import '@docknetwork/credential-sdk/resolver';
|
|
13
|
-
import '@docknetwork/dock-blockchain-modules';
|
|
14
16
|
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
17
|
+
import '@docknetwork/dock-blockchain-api';
|
|
18
|
+
import '@docknetwork/dock-blockchain-modules';
|
|
15
19
|
import 'events';
|
|
16
20
|
import '../../core/logger.mjs';
|
|
17
21
|
import '../../modules/event-manager.mjs';
|
|
18
|
-
import '../
|
|
22
|
+
import '../util-crypto/service.mjs';
|
|
19
23
|
import '@polkadot/keyring';
|
|
24
|
+
import '@polkadot/util';
|
|
20
25
|
import '@polkadot/util-crypto';
|
|
26
|
+
import '../util-crypto/configs.mjs';
|
|
27
|
+
import '@docknetwork/credential-sdk/types';
|
|
21
28
|
import '../keyring/configs.mjs';
|
|
22
29
|
|
|
23
30
|
// @ts-nocheck
|
|
@@ -38,9 +45,9 @@ class SubstrateService {
|
|
|
38
45
|
async getAccountBalance(params) {
|
|
39
46
|
validation.getAccountBalance(params);
|
|
40
47
|
console.log('ensure dock ready');
|
|
41
|
-
await
|
|
48
|
+
await blockchainService.ensureBlockchainReady();
|
|
42
49
|
console.log('ensure dock ready done');
|
|
43
|
-
const { data: { free }, } = await
|
|
50
|
+
const { data: { free }, } = await blockchainService.dock.api.query.system.account(params.address);
|
|
44
51
|
return free.toNumber() / DOCK_TOKEN_UNIT;
|
|
45
52
|
}
|
|
46
53
|
async getFeeAmount(params) {
|
|
@@ -51,8 +58,8 @@ class SubstrateService {
|
|
|
51
58
|
jsonData: keyPair,
|
|
52
59
|
password: '',
|
|
53
60
|
});
|
|
54
|
-
|
|
55
|
-
const extrinsic =
|
|
61
|
+
blockchainService.dock.setAccount(account);
|
|
62
|
+
const extrinsic = blockchainService.dock.api.tx.balances.transfer(toAddress, amount);
|
|
56
63
|
const paymentInfo = await extrinsic.paymentInfo(account);
|
|
57
64
|
const fee = getFeeWithBuffer(paymentInfo.partialFee)
|
|
58
65
|
.dividedBy(DOCK_TOKEN_UNIT)
|
|
@@ -67,7 +74,7 @@ class SubstrateService {
|
|
|
67
74
|
jsonData: keyPair,
|
|
68
75
|
password: '',
|
|
69
76
|
});
|
|
70
|
-
const { dock } =
|
|
77
|
+
const { dock } = blockchainService;
|
|
71
78
|
dock.setAccount(account);
|
|
72
79
|
if (params.transferAll) {
|
|
73
80
|
const api = dock.api;
|