@docknetwork/wallet-sdk-wasm 1.5.6 → 1.5.9
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-bf00e5c0.js → account-357ab05d.js} +1 -23
- package/lib/{account-e48dc9b6.js → account-399e6053.js} +1 -23
- package/lib/index.js +0 -9
- package/lib/index.mjs +0 -9
- package/lib/modules/account.js +5 -12
- package/lib/modules/account.mjs +5 -12
- package/lib/modules/accounts.js +4 -11
- package/lib/modules/accounts.mjs +4 -11
- package/lib/modules/network-manager.js +4 -4
- package/lib/modules/network-manager.mjs +4 -4
- package/lib/modules/wallet.js +1 -8
- package/lib/modules/wallet.mjs +1 -8
- package/lib/rpc-server.js +0 -9
- package/lib/rpc-server.mjs +0 -9
- package/lib/services/blockchain/index.js +0 -2
- package/lib/services/blockchain/index.mjs +0 -2
- package/lib/services/blockchain/service.js +33 -74
- package/lib/services/blockchain/service.mjs +34 -75
- package/lib/services/credential/bbs-revocation.js +0 -2
- package/lib/services/credential/bbs-revocation.mjs +0 -2
- package/lib/services/credential/index.js +0 -2
- package/lib/services/credential/index.mjs +0 -2
- package/lib/services/credential/service.js +0 -2
- package/lib/services/credential/service.mjs +0 -2
- package/lib/services/dids/index.js +0 -2
- package/lib/services/dids/index.mjs +0 -2
- package/lib/services/dids/service.js +1 -3
- package/lib/services/dids/service.mjs +1 -3
- package/lib/services/edv/hmac.js +1 -2
- package/lib/services/edv/hmac.mjs +1 -2
- package/lib/services/edv/index.js +1 -3
- package/lib/services/edv/index.mjs +1 -3
- package/lib/services/edv/service-rpc.js +4 -0
- package/lib/services/edv/service-rpc.mjs +4 -0
- package/lib/services/edv/service.js +9 -6
- package/lib/services/edv/service.mjs +9 -5
- package/lib/services/index.js +0 -12
- package/lib/services/index.mjs +0 -12
- package/lib/services/pex/service.js +2 -1
- package/lib/services/pex/service.mjs +2 -1
- package/lib/services/test-utils.js +3 -198
- package/lib/services/test-utils.mjs +4 -194
- package/lib/setup-nodejs.js +0 -9
- package/lib/setup-nodejs.mjs +0 -9
- package/lib/setup-tests.js +0 -9
- package/lib/setup-tests.mjs +0 -9
- package/lib/src/modules/accounts.d.ts +0 -1
- package/lib/src/modules/accounts.d.ts.map +1 -1
- package/lib/src/services/blockchain/service.d.ts +7 -3
- package/lib/src/services/blockchain/service.d.ts.map +1 -1
- package/lib/src/services/edv/hmac.d.ts +1 -1
- package/lib/src/services/edv/hmac.d.ts.map +1 -1
- package/lib/src/services/edv/service.d.ts +3 -1
- package/lib/src/services/edv/service.d.ts.map +1 -1
- package/lib/src/services/pex/service.d.ts.map +1 -1
- package/lib/test/setup-test-state.js +8 -20
- package/lib/test/setup-test-state.mjs +8 -20
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -8
- package/src/modules/accounts.test.js +0 -25
- package/src/modules/accounts.ts +0 -33
- package/src/modules/data-migration.test.js +0 -11
- package/src/modules/network-manager.ts +4 -4
- package/src/modules/wallet.test.js +0 -11
- package/src/modules/wallet.ts +1 -1
- package/src/services/blockchain/index.test.js +4 -15
- package/src/services/blockchain/service.ts +38 -98
- package/src/services/dids/index.test.js +1 -1
- package/src/services/dids/service.ts +1 -1
- package/src/services/edv/hmac.ts +2 -3
- package/src/services/edv/index.test.js +7 -2
- package/src/services/edv/service-rpc.js +4 -0
- package/src/services/edv/service.ts +9 -3
- package/src/services/index.js +0 -4
- package/src/services/pex/service.ts +7 -1
- package/src/services/test-utils.js +0 -178
- package/src/test/setup-test-state.js +1 -3
- package/lib/services/substrate/api-utils.js +0 -85
- package/lib/services/substrate/api-utils.mjs +0 -74
- package/lib/services/substrate/configs.js +0 -30
- package/lib/services/substrate/configs.mjs +0 -21
- package/lib/services/substrate/index.android.js +0 -22
- package/lib/services/substrate/index.android.mjs +0 -18
- package/lib/services/substrate/index.ios.js +0 -22
- package/lib/services/substrate/index.ios.mjs +0 -18
- package/lib/services/substrate/index.js +0 -37
- package/lib/services/substrate/index.mjs +0 -29
- package/lib/services/substrate/service-rpc.js +0 -37
- package/lib/services/substrate/service-rpc.mjs +0 -33
- package/lib/services/substrate/service.js +0 -115
- package/lib/services/substrate/service.mjs +0 -102
- package/lib/services/trust-registry/configs.js +0 -25
- package/lib/services/trust-registry/configs.mjs +0 -16
- package/lib/services/trust-registry/index.android.js +0 -19
- package/lib/services/trust-registry/index.android.mjs +0 -15
- package/lib/services/trust-registry/index.ios.js +0 -19
- package/lib/services/trust-registry/index.ios.mjs +0 -15
- package/lib/services/trust-registry/index.js +0 -33
- package/lib/services/trust-registry/index.mjs +0 -25
- package/lib/services/trust-registry/service-rpc.js +0 -29
- package/lib/services/trust-registry/service-rpc.mjs +0 -25
- package/lib/services/trust-registry/service.js +0 -89
- package/lib/services/trust-registry/service.mjs +0 -85
- package/lib/src/services/substrate/api-utils.d.ts +0 -14
- package/lib/src/services/substrate/api-utils.d.ts.map +0 -1
- package/lib/src/services/substrate/configs.d.ts +0 -16
- package/lib/src/services/substrate/configs.d.ts.map +0 -1
- package/lib/src/services/substrate/index.d.ts +0 -2
- package/lib/src/services/substrate/index.d.ts.map +0 -1
- package/lib/src/services/substrate/service.d.ts +0 -13
- package/lib/src/services/substrate/service.d.ts.map +0 -1
- package/lib/src/services/trust-registry/configs.d.ts +0 -6
- package/lib/src/services/trust-registry/configs.d.ts.map +0 -1
- package/lib/src/services/trust-registry/service.d.ts +0 -25
- package/lib/src/services/trust-registry/service.d.ts.map +0 -1
- package/src/services/substrate/api-utils.test.js +0 -73
- package/src/services/substrate/api-utils.ts +0 -66
- package/src/services/substrate/configs.ts +0 -34
- package/src/services/substrate/index.android.js +0 -3
- package/src/services/substrate/index.ios.js +0 -3
- package/src/services/substrate/index.js +0 -1
- package/src/services/substrate/index.test.js +0 -116
- package/src/services/substrate/service-rpc.js +0 -24
- package/src/services/substrate/service.ts +0 -117
- package/src/services/trust-registry/configs.ts +0 -14
- package/src/services/trust-registry/index.android.js +0 -3
- package/src/services/trust-registry/index.ios.js +0 -3
- package/src/services/trust-registry/index.js +0 -1
- package/src/services/trust-registry/index.test.js +0 -67
- package/src/services/trust-registry/service-rpc.js +0 -15
- package/src/services/trust-registry/service.ts +0 -94
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var assert = require('assert');
|
|
6
|
-
var BigNumber = require('bignumber.js');
|
|
7
|
-
var BN = require('bn.js');
|
|
8
|
-
var core_formatUtils = require('../../core/format-utils.js');
|
|
9
|
-
var services_blockchain_service = require('../blockchain/service.js');
|
|
10
|
-
var services_substrate_apiUtils = require('./api-utils.js');
|
|
11
|
-
var services_substrate_configs = require('./configs.js');
|
|
12
|
-
var services_keyring_service = require('../keyring/service.js');
|
|
13
|
-
require('../../core/validation.js');
|
|
14
|
-
require('../../types.js');
|
|
15
|
-
require('@cosmjs/proto-signing');
|
|
16
|
-
require('@docknetwork/cheqd-blockchain-api');
|
|
17
|
-
require('@docknetwork/cheqd-blockchain-modules');
|
|
18
|
-
require('@docknetwork/credential-sdk/modules');
|
|
19
|
-
require('@docknetwork/credential-sdk/resolver');
|
|
20
|
-
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
21
|
-
require('@docknetwork/dock-blockchain-api');
|
|
22
|
-
require('@docknetwork/dock-blockchain-modules');
|
|
23
|
-
require('events');
|
|
24
|
-
require('../../core/logger.js');
|
|
25
|
-
require('../../modules/event-manager.js');
|
|
26
|
-
require('../util-crypto/service.js');
|
|
27
|
-
require('@polkadot/keyring');
|
|
28
|
-
require('@polkadot/util');
|
|
29
|
-
require('@polkadot/util-crypto');
|
|
30
|
-
require('../util-crypto/configs.js');
|
|
31
|
-
require('@docknetwork/credential-sdk/types');
|
|
32
|
-
require('../keyring/configs.js');
|
|
33
|
-
|
|
34
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
35
|
-
|
|
36
|
-
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
|
|
37
|
-
var BigNumber__default = /*#__PURE__*/_interopDefaultLegacy(BigNumber);
|
|
38
|
-
var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
|
|
39
|
-
|
|
40
|
-
// @ts-nocheck
|
|
41
|
-
const FEE_ESTIMATION_BUFFER = 1.1;
|
|
42
|
-
function getFeeWithBuffer(paymentFee) {
|
|
43
|
-
assert__default["default"](!!paymentFee, 'paymentFee is required');
|
|
44
|
-
return new BigNumber__default["default"](paymentFee).multipliedBy(FEE_ESTIMATION_BUFFER);
|
|
45
|
-
}
|
|
46
|
-
class SubstrateService {
|
|
47
|
-
rpcMethods = [
|
|
48
|
-
SubstrateService.prototype.getAccountBalance,
|
|
49
|
-
SubstrateService.prototype.getFeeAmount,
|
|
50
|
-
SubstrateService.prototype.sendTokens,
|
|
51
|
-
];
|
|
52
|
-
constructor() {
|
|
53
|
-
this.name = services_substrate_configs.serviceName;
|
|
54
|
-
}
|
|
55
|
-
async getAccountBalance(params) {
|
|
56
|
-
services_substrate_configs.validation.getAccountBalance(params);
|
|
57
|
-
console.log('ensure dock ready');
|
|
58
|
-
await services_blockchain_service.blockchainService.ensureBlockchainReady();
|
|
59
|
-
console.log('ensure dock ready done');
|
|
60
|
-
const { data: { free }, } = await services_blockchain_service.blockchainService.dock.api.query.system.account(params.address);
|
|
61
|
-
return free.toNumber() / core_formatUtils.DOCK_TOKEN_UNIT;
|
|
62
|
-
}
|
|
63
|
-
async getFeeAmount(params) {
|
|
64
|
-
services_substrate_configs.validation.getFeeAmount(params);
|
|
65
|
-
const { toAddress, keyPair } = params;
|
|
66
|
-
const amount = core_formatUtils.getPlainDockAmount(params.amount).toNumber();
|
|
67
|
-
const account = services_keyring_service.keyringService.decryptKeyPair({
|
|
68
|
-
jsonData: keyPair,
|
|
69
|
-
password: '',
|
|
70
|
-
});
|
|
71
|
-
services_blockchain_service.blockchainService.dock.setAccount(account);
|
|
72
|
-
const extrinsic = services_blockchain_service.blockchainService.dock.api.tx.balances.transfer(toAddress, amount);
|
|
73
|
-
const paymentInfo = await extrinsic.paymentInfo(account);
|
|
74
|
-
const fee = getFeeWithBuffer(paymentInfo.partialFee)
|
|
75
|
-
.dividedBy(core_formatUtils.DOCK_TOKEN_UNIT)
|
|
76
|
-
.toNumber();
|
|
77
|
-
return fee;
|
|
78
|
-
}
|
|
79
|
-
async sendTokens(params) {
|
|
80
|
-
services_substrate_configs.validation.sendTokens(params);
|
|
81
|
-
let { toAddress, fromAddress, keyPair } = params;
|
|
82
|
-
let amount = core_formatUtils.getPlainDockAmount(params.amount).toNumber();
|
|
83
|
-
const account = services_keyring_service.keyringService.decryptKeyPair({
|
|
84
|
-
jsonData: keyPair,
|
|
85
|
-
password: '',
|
|
86
|
-
});
|
|
87
|
-
const { dock } = services_blockchain_service.blockchainService;
|
|
88
|
-
dock.setAccount(account);
|
|
89
|
-
if (params.transferAll) {
|
|
90
|
-
const api = dock.api;
|
|
91
|
-
const balances = await api.derive.balances.all(account.address);
|
|
92
|
-
await api.tx.balances
|
|
93
|
-
.transfer(fromAddress, balances.availableBalance)
|
|
94
|
-
.paymentInfo(account)
|
|
95
|
-
.then(async ({ partialFee }) => {
|
|
96
|
-
const adjFee = getFeeWithBuffer(partialFee);
|
|
97
|
-
let maxTransfer = balances.availableBalance.sub(new BN__default["default"](adjFee.toNumber()));
|
|
98
|
-
if (!maxTransfer.gt(api.consts.balances.existentialDeposit)) {
|
|
99
|
-
throw new Error('balance too low');
|
|
100
|
-
}
|
|
101
|
-
amount = maxTransfer;
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return new Promise((resolve, reject) => {
|
|
105
|
-
const extrinsic = dock.api.tx.balances.transfer(toAddress, amount);
|
|
106
|
-
services_substrate_apiUtils.signAndSend(account, extrinsic).on('done', resolve).on('error', reject);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const substrateService = new SubstrateService();
|
|
111
|
-
|
|
112
|
-
exports.FEE_ESTIMATION_BUFFER = FEE_ESTIMATION_BUFFER;
|
|
113
|
-
exports.SubstrateService = SubstrateService;
|
|
114
|
-
exports.getFeeWithBuffer = getFeeWithBuffer;
|
|
115
|
-
exports.substrateService = substrateService;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
import BigNumber from 'bignumber.js';
|
|
3
|
-
import BN from 'bn.js';
|
|
4
|
-
import { DOCK_TOKEN_UNIT, getPlainDockAmount } from '../../core/format-utils.mjs';
|
|
5
|
-
import { blockchainService } from '../blockchain/service.mjs';
|
|
6
|
-
import { signAndSend } from './api-utils.mjs';
|
|
7
|
-
import { serviceName, validation } from './configs.mjs';
|
|
8
|
-
import { keyringService } from '../keyring/service.mjs';
|
|
9
|
-
import '../../core/validation.mjs';
|
|
10
|
-
import '../../types.mjs';
|
|
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';
|
|
16
|
-
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
17
|
-
import '@docknetwork/dock-blockchain-api';
|
|
18
|
-
import '@docknetwork/dock-blockchain-modules';
|
|
19
|
-
import 'events';
|
|
20
|
-
import '../../core/logger.mjs';
|
|
21
|
-
import '../../modules/event-manager.mjs';
|
|
22
|
-
import '../util-crypto/service.mjs';
|
|
23
|
-
import '@polkadot/keyring';
|
|
24
|
-
import '@polkadot/util';
|
|
25
|
-
import '@polkadot/util-crypto';
|
|
26
|
-
import '../util-crypto/configs.mjs';
|
|
27
|
-
import '@docknetwork/credential-sdk/types';
|
|
28
|
-
import '../keyring/configs.mjs';
|
|
29
|
-
|
|
30
|
-
// @ts-nocheck
|
|
31
|
-
const FEE_ESTIMATION_BUFFER = 1.1;
|
|
32
|
-
function getFeeWithBuffer(paymentFee) {
|
|
33
|
-
assert(!!paymentFee, 'paymentFee is required');
|
|
34
|
-
return new BigNumber(paymentFee).multipliedBy(FEE_ESTIMATION_BUFFER);
|
|
35
|
-
}
|
|
36
|
-
class SubstrateService {
|
|
37
|
-
rpcMethods = [
|
|
38
|
-
SubstrateService.prototype.getAccountBalance,
|
|
39
|
-
SubstrateService.prototype.getFeeAmount,
|
|
40
|
-
SubstrateService.prototype.sendTokens,
|
|
41
|
-
];
|
|
42
|
-
constructor() {
|
|
43
|
-
this.name = serviceName;
|
|
44
|
-
}
|
|
45
|
-
async getAccountBalance(params) {
|
|
46
|
-
validation.getAccountBalance(params);
|
|
47
|
-
console.log('ensure dock ready');
|
|
48
|
-
await blockchainService.ensureBlockchainReady();
|
|
49
|
-
console.log('ensure dock ready done');
|
|
50
|
-
const { data: { free }, } = await blockchainService.dock.api.query.system.account(params.address);
|
|
51
|
-
return free.toNumber() / DOCK_TOKEN_UNIT;
|
|
52
|
-
}
|
|
53
|
-
async getFeeAmount(params) {
|
|
54
|
-
validation.getFeeAmount(params);
|
|
55
|
-
const { toAddress, keyPair } = params;
|
|
56
|
-
const amount = getPlainDockAmount(params.amount).toNumber();
|
|
57
|
-
const account = keyringService.decryptKeyPair({
|
|
58
|
-
jsonData: keyPair,
|
|
59
|
-
password: '',
|
|
60
|
-
});
|
|
61
|
-
blockchainService.dock.setAccount(account);
|
|
62
|
-
const extrinsic = blockchainService.dock.api.tx.balances.transfer(toAddress, amount);
|
|
63
|
-
const paymentInfo = await extrinsic.paymentInfo(account);
|
|
64
|
-
const fee = getFeeWithBuffer(paymentInfo.partialFee)
|
|
65
|
-
.dividedBy(DOCK_TOKEN_UNIT)
|
|
66
|
-
.toNumber();
|
|
67
|
-
return fee;
|
|
68
|
-
}
|
|
69
|
-
async sendTokens(params) {
|
|
70
|
-
validation.sendTokens(params);
|
|
71
|
-
let { toAddress, fromAddress, keyPair } = params;
|
|
72
|
-
let amount = getPlainDockAmount(params.amount).toNumber();
|
|
73
|
-
const account = keyringService.decryptKeyPair({
|
|
74
|
-
jsonData: keyPair,
|
|
75
|
-
password: '',
|
|
76
|
-
});
|
|
77
|
-
const { dock } = blockchainService;
|
|
78
|
-
dock.setAccount(account);
|
|
79
|
-
if (params.transferAll) {
|
|
80
|
-
const api = dock.api;
|
|
81
|
-
const balances = await api.derive.balances.all(account.address);
|
|
82
|
-
await api.tx.balances
|
|
83
|
-
.transfer(fromAddress, balances.availableBalance)
|
|
84
|
-
.paymentInfo(account)
|
|
85
|
-
.then(async ({ partialFee }) => {
|
|
86
|
-
const adjFee = getFeeWithBuffer(partialFee);
|
|
87
|
-
let maxTransfer = balances.availableBalance.sub(new BN(adjFee.toNumber()));
|
|
88
|
-
if (!maxTransfer.gt(api.consts.balances.existentialDeposit)) {
|
|
89
|
-
throw new Error('balance too low');
|
|
90
|
-
}
|
|
91
|
-
amount = maxTransfer;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
return new Promise((resolve, reject) => {
|
|
95
|
-
const extrinsic = dock.api.tx.balances.transfer(toAddress, amount);
|
|
96
|
-
signAndSend(account, extrinsic).on('done', resolve).on('error', reject);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const substrateService = new SubstrateService();
|
|
101
|
-
|
|
102
|
-
export { FEE_ESTIMATION_BUFFER, SubstrateService, getFeeWithBuffer, substrateService };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var assert = require('assert');
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
|
|
10
|
-
|
|
11
|
-
// @ts-nocheck
|
|
12
|
-
const serviceName = 'trust-registry';
|
|
13
|
-
const validation = {
|
|
14
|
-
getTrustRegistries: params => {
|
|
15
|
-
const { schemaId, issuerDID, verifierDID } = params;
|
|
16
|
-
assert__default["default"](!!schemaId || !!issuerDID || !!verifierDID, 'no query option provider');
|
|
17
|
-
},
|
|
18
|
-
getTrustRegistryVerifiers: params => {
|
|
19
|
-
const { trustRegistryId } = params;
|
|
20
|
-
assert__default["default"](!!trustRegistryId, 'trustRegistryId is required');
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports.serviceName = serviceName;
|
|
25
|
-
exports.validation = validation;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const serviceName = 'trust-registry';
|
|
5
|
-
const validation = {
|
|
6
|
-
getTrustRegistries: params => {
|
|
7
|
-
const { schemaId, issuerDID, verifierDID } = params;
|
|
8
|
-
assert(!!schemaId || !!issuerDID || !!verifierDID, 'no query option provider');
|
|
9
|
-
},
|
|
10
|
-
getTrustRegistryVerifiers: params => {
|
|
11
|
-
const { trustRegistryId } = params;
|
|
12
|
-
assert(!!trustRegistryId, 'trustRegistryId is required');
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { serviceName, validation };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var services_trustRegistry_serviceRpc = require('./service-rpc.js');
|
|
6
|
-
require('../rpc-service-client.js');
|
|
7
|
-
require('assert');
|
|
8
|
-
require('../../rpc-client.js');
|
|
9
|
-
require('json-rpc-2.0');
|
|
10
|
-
require('../../core/crypto.js');
|
|
11
|
-
require('crypto');
|
|
12
|
-
require('../../core/logger.js');
|
|
13
|
-
require('../../logger.js');
|
|
14
|
-
require('../../rpc-util.js');
|
|
15
|
-
require('./configs.js');
|
|
16
|
-
|
|
17
|
-
const trustRegistryService = new services_trustRegistry_serviceRpc.TrustRegistryServiceRpc();
|
|
18
|
-
|
|
19
|
-
exports.trustRegistryService = trustRegistryService;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TrustRegistryServiceRpc } from './service-rpc.mjs';
|
|
2
|
-
import '../rpc-service-client.mjs';
|
|
3
|
-
import 'assert';
|
|
4
|
-
import '../../rpc-client.mjs';
|
|
5
|
-
import 'json-rpc-2.0';
|
|
6
|
-
import '../../core/crypto.mjs';
|
|
7
|
-
import 'crypto';
|
|
8
|
-
import '../../core/logger.mjs';
|
|
9
|
-
import '../../logger.mjs';
|
|
10
|
-
import '../../rpc-util.mjs';
|
|
11
|
-
import './configs.mjs';
|
|
12
|
-
|
|
13
|
-
const trustRegistryService = new TrustRegistryServiceRpc();
|
|
14
|
-
|
|
15
|
-
export { trustRegistryService };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var services_trustRegistry_serviceRpc = require('./service-rpc.js');
|
|
6
|
-
require('../rpc-service-client.js');
|
|
7
|
-
require('assert');
|
|
8
|
-
require('../../rpc-client.js');
|
|
9
|
-
require('json-rpc-2.0');
|
|
10
|
-
require('../../core/crypto.js');
|
|
11
|
-
require('crypto');
|
|
12
|
-
require('../../core/logger.js');
|
|
13
|
-
require('../../logger.js');
|
|
14
|
-
require('../../rpc-util.js');
|
|
15
|
-
require('./configs.js');
|
|
16
|
-
|
|
17
|
-
const trustRegistryService = new services_trustRegistry_serviceRpc.TrustRegistryServiceRpc();
|
|
18
|
-
|
|
19
|
-
exports.trustRegistryService = trustRegistryService;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TrustRegistryServiceRpc } from './service-rpc.mjs';
|
|
2
|
-
import '../rpc-service-client.mjs';
|
|
3
|
-
import 'assert';
|
|
4
|
-
import '../../rpc-client.mjs';
|
|
5
|
-
import 'json-rpc-2.0';
|
|
6
|
-
import '../../core/crypto.mjs';
|
|
7
|
-
import 'crypto';
|
|
8
|
-
import '../../core/logger.mjs';
|
|
9
|
-
import '../../logger.mjs';
|
|
10
|
-
import '../../rpc-util.mjs';
|
|
11
|
-
import './configs.mjs';
|
|
12
|
-
|
|
13
|
-
const trustRegistryService = new TrustRegistryServiceRpc();
|
|
14
|
-
|
|
15
|
-
export { trustRegistryService };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var services_trustRegistry_service = require('./service.js');
|
|
6
|
-
require('./configs.js');
|
|
7
|
-
require('assert');
|
|
8
|
-
require('crypto');
|
|
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');
|
|
15
|
-
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
16
|
-
require('@docknetwork/dock-blockchain-api');
|
|
17
|
-
require('@docknetwork/dock-blockchain-modules');
|
|
18
|
-
require('events');
|
|
19
|
-
require('../../core/logger.js');
|
|
20
|
-
require('../../modules/event-manager.js');
|
|
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');
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
exports.trustRegistryService = services_trustRegistry_service.trustRegistryService;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export { trustRegistryService } from './service.mjs';
|
|
2
|
-
import './configs.mjs';
|
|
3
|
-
import 'assert';
|
|
4
|
-
import 'crypto';
|
|
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';
|
|
11
|
-
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
12
|
-
import '@docknetwork/dock-blockchain-api';
|
|
13
|
-
import '@docknetwork/dock-blockchain-modules';
|
|
14
|
-
import 'events';
|
|
15
|
-
import '../../core/logger.mjs';
|
|
16
|
-
import '../../modules/event-manager.mjs';
|
|
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';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var services_rpcServiceClient = require('../rpc-service-client.js');
|
|
6
|
-
var services_trustRegistry_configs = require('./configs.js');
|
|
7
|
-
require('assert');
|
|
8
|
-
require('../../rpc-client.js');
|
|
9
|
-
require('json-rpc-2.0');
|
|
10
|
-
require('../../core/crypto.js');
|
|
11
|
-
require('crypto');
|
|
12
|
-
require('../../core/logger.js');
|
|
13
|
-
require('../../logger.js');
|
|
14
|
-
require('../../rpc-util.js');
|
|
15
|
-
|
|
16
|
-
class TrustRegistryServiceRpc extends services_rpcServiceClient.RpcService {
|
|
17
|
-
constructor() {
|
|
18
|
-
super(services_trustRegistry_configs.serviceName);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async getTrustRegistries(params) {
|
|
22
|
-
return this.call('getTrustRegistries', params);
|
|
23
|
-
}
|
|
24
|
-
async getTrustRegistryVerifiers(params) {
|
|
25
|
-
return this.call('getTrustRegistryVerifiers', params);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
exports.TrustRegistryServiceRpc = TrustRegistryServiceRpc;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { RpcService } from '../rpc-service-client.mjs';
|
|
2
|
-
import { serviceName } from './configs.mjs';
|
|
3
|
-
import 'assert';
|
|
4
|
-
import '../../rpc-client.mjs';
|
|
5
|
-
import 'json-rpc-2.0';
|
|
6
|
-
import '../../core/crypto.mjs';
|
|
7
|
-
import 'crypto';
|
|
8
|
-
import '../../core/logger.mjs';
|
|
9
|
-
import '../../logger.mjs';
|
|
10
|
-
import '../../rpc-util.mjs';
|
|
11
|
-
|
|
12
|
-
class TrustRegistryServiceRpc extends RpcService {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(serviceName);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async getTrustRegistries(params) {
|
|
18
|
-
return this.call('getTrustRegistries', params);
|
|
19
|
-
}
|
|
20
|
-
async getTrustRegistryVerifiers(params) {
|
|
21
|
-
return this.call('getTrustRegistryVerifiers', params);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { TrustRegistryServiceRpc };
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var services_trustRegistry_configs = require('./configs.js');
|
|
6
|
-
var crypto = require('crypto');
|
|
7
|
-
var services_blockchain_service = require('../blockchain/service.js');
|
|
8
|
-
require('assert');
|
|
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');
|
|
14
|
-
require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
15
|
-
require('@docknetwork/dock-blockchain-api');
|
|
16
|
-
require('@docknetwork/dock-blockchain-modules');
|
|
17
|
-
require('events');
|
|
18
|
-
require('../../core/logger.js');
|
|
19
|
-
require('../../modules/event-manager.js');
|
|
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');
|
|
29
|
-
|
|
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
|
|
36
|
-
class TrustRegistryService {
|
|
37
|
-
constructor() {
|
|
38
|
-
this.name = services_trustRegistry_configs.serviceName;
|
|
39
|
-
}
|
|
40
|
-
rpcMethods = [
|
|
41
|
-
TrustRegistryService.prototype.getTrustRegistries,
|
|
42
|
-
TrustRegistryService.prototype.getTrustRegistryVerifiers,
|
|
43
|
-
];
|
|
44
|
-
async getTrustRegistries({ schemaId, issuerDID, verifierDID, }) {
|
|
45
|
-
services_trustRegistry_configs.validation.getTrustRegistries({ schemaId, issuerDID, verifierDID });
|
|
46
|
-
const queryOptions = {};
|
|
47
|
-
if (schemaId) {
|
|
48
|
-
const hashedId = crypto.createHash('sha256').update(schemaId).digest('hex');
|
|
49
|
-
const schemaIdHex = '0x' + hashedId;
|
|
50
|
-
queryOptions.schemaIds = {
|
|
51
|
-
AnyOf: [schemaIdHex],
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
if (issuerDID) {
|
|
55
|
-
const issuerDIDMethodKey = typedHexDID(services_blockchain_service.blockchainService.dock.api, issuerDID);
|
|
56
|
-
queryOptions.issuers = {
|
|
57
|
-
AnyOf: [issuerDIDMethodKey],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
if (verifierDID) {
|
|
61
|
-
const verifierDIDMethodKey = typedHexDID(services_blockchain_service.blockchainService.dock.api, verifierDID);
|
|
62
|
-
queryOptions.verifiers = {
|
|
63
|
-
AnyOf: [verifierDIDMethodKey],
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
const registryInfo = await services_blockchain_service.blockchainService.dock.trustRegistry?.registriesInfo(queryOptions);
|
|
67
|
-
return registryInfo;
|
|
68
|
-
}
|
|
69
|
-
async getTrustRegistryVerifiers({ schemaId, trustRegistryId, issuerDID }) {
|
|
70
|
-
services_trustRegistry_configs.validation.getTrustRegistryVerifiers({ schemaId, trustRegistryId });
|
|
71
|
-
const hashedId = crypto.createHash('sha256').update(schemaId).digest('hex');
|
|
72
|
-
const schemaIdHex = '0x' + hashedId;
|
|
73
|
-
const issuerDIDMethodKey = issuerDID
|
|
74
|
-
? typedHexDID(services_blockchain_service.blockchainService.dock.api, issuerDID)
|
|
75
|
-
: null;
|
|
76
|
-
const metadata = await services_blockchain_service.blockchainService.dock.trustRegistry.registrySchemasMetadata({
|
|
77
|
-
schemaIds: [schemaIdHex],
|
|
78
|
-
...(issuerDIDMethodKey && {
|
|
79
|
-
issuers: {
|
|
80
|
-
AnyOf: [issuerDIDMethodKey],
|
|
81
|
-
},
|
|
82
|
-
}),
|
|
83
|
-
}, trustRegistryId);
|
|
84
|
-
return metadata[schemaIdHex]?.verifiers;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const trustRegistryService = new TrustRegistryService();
|
|
88
|
-
|
|
89
|
-
exports.trustRegistryService = trustRegistryService;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { serviceName, validation } from './configs.mjs';
|
|
2
|
-
import { createHash } from 'crypto';
|
|
3
|
-
import { blockchainService } from '../blockchain/service.mjs';
|
|
4
|
-
import 'assert';
|
|
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';
|
|
10
|
-
import '@docknetwork/crypto-wasm-ts/lib/index';
|
|
11
|
-
import '@docknetwork/dock-blockchain-api';
|
|
12
|
-
import '@docknetwork/dock-blockchain-modules';
|
|
13
|
-
import 'events';
|
|
14
|
-
import '../../core/logger.mjs';
|
|
15
|
-
import '../../modules/event-manager.mjs';
|
|
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';
|
|
25
|
-
|
|
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
|
|
32
|
-
class TrustRegistryService {
|
|
33
|
-
constructor() {
|
|
34
|
-
this.name = serviceName;
|
|
35
|
-
}
|
|
36
|
-
rpcMethods = [
|
|
37
|
-
TrustRegistryService.prototype.getTrustRegistries,
|
|
38
|
-
TrustRegistryService.prototype.getTrustRegistryVerifiers,
|
|
39
|
-
];
|
|
40
|
-
async getTrustRegistries({ schemaId, issuerDID, verifierDID, }) {
|
|
41
|
-
validation.getTrustRegistries({ schemaId, issuerDID, verifierDID });
|
|
42
|
-
const queryOptions = {};
|
|
43
|
-
if (schemaId) {
|
|
44
|
-
const hashedId = createHash('sha256').update(schemaId).digest('hex');
|
|
45
|
-
const schemaIdHex = '0x' + hashedId;
|
|
46
|
-
queryOptions.schemaIds = {
|
|
47
|
-
AnyOf: [schemaIdHex],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
if (issuerDID) {
|
|
51
|
-
const issuerDIDMethodKey = typedHexDID(blockchainService.dock.api, issuerDID);
|
|
52
|
-
queryOptions.issuers = {
|
|
53
|
-
AnyOf: [issuerDIDMethodKey],
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (verifierDID) {
|
|
57
|
-
const verifierDIDMethodKey = typedHexDID(blockchainService.dock.api, verifierDID);
|
|
58
|
-
queryOptions.verifiers = {
|
|
59
|
-
AnyOf: [verifierDIDMethodKey],
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const registryInfo = await blockchainService.dock.trustRegistry?.registriesInfo(queryOptions);
|
|
63
|
-
return registryInfo;
|
|
64
|
-
}
|
|
65
|
-
async getTrustRegistryVerifiers({ schemaId, trustRegistryId, issuerDID }) {
|
|
66
|
-
validation.getTrustRegistryVerifiers({ schemaId, trustRegistryId });
|
|
67
|
-
const hashedId = createHash('sha256').update(schemaId).digest('hex');
|
|
68
|
-
const schemaIdHex = '0x' + hashedId;
|
|
69
|
-
const issuerDIDMethodKey = issuerDID
|
|
70
|
-
? typedHexDID(blockchainService.dock.api, issuerDID)
|
|
71
|
-
: null;
|
|
72
|
-
const metadata = await blockchainService.dock.trustRegistry.registrySchemasMetadata({
|
|
73
|
-
schemaIds: [schemaIdHex],
|
|
74
|
-
...(issuerDIDMethodKey && {
|
|
75
|
-
issuers: {
|
|
76
|
-
AnyOf: [issuerDIDMethodKey],
|
|
77
|
-
},
|
|
78
|
-
}),
|
|
79
|
-
}, trustRegistryId);
|
|
80
|
-
return metadata[schemaIdHex]?.verifiers;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const trustRegistryService = new TrustRegistryService();
|
|
84
|
-
|
|
85
|
-
export { trustRegistryService };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
export declare const extrisicErrorsFilter: ({ event }: {
|
|
4
|
-
event: any;
|
|
5
|
-
}) => any;
|
|
6
|
-
export declare const mapEventToErrorMessage: ({ event }: {
|
|
7
|
-
event: any;
|
|
8
|
-
}) => any;
|
|
9
|
-
export declare const getExtrinsicErrors: ({ status, events }: {
|
|
10
|
-
status: any;
|
|
11
|
-
events: any;
|
|
12
|
-
}) => any;
|
|
13
|
-
export declare function signAndSend(account: any, extrinsic: any): EventEmitter;
|
|
14
|
-
//# sourceMappingURL=api-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-utils.d.ts","sourceRoot":"","sources":["../../../../src/services/substrate/api-utils.ts"],"names":[],"mappings":";AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAIpC,eAAO,MAAM,oBAAoB;;SAEhC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;SAelC,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;SACkC,CAAC;AAElE,wBAAgB,WAAW,CAAC,OAAO,KAAA,EAAE,SAAS,EAAE,GAAG,GAAG,YAAY,CAmCjE"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const validation: {
|
|
2
|
-
getAccountBalance({ address }: GetAccountBalanceParams): void;
|
|
3
|
-
getFeeAmount: ({ toAddress, fromAddress, amount, }: TransactionParams) => void;
|
|
4
|
-
sendTokens: ({ toAddress, fromAddress, amount, }: TransactionParams) => void;
|
|
5
|
-
};
|
|
6
|
-
export declare const serviceName = "substrate";
|
|
7
|
-
export type GetAccountBalanceParams = {
|
|
8
|
-
address: string;
|
|
9
|
-
};
|
|
10
|
-
export type TransactionParams = {
|
|
11
|
-
toAddress: string;
|
|
12
|
-
fromAddress: string;
|
|
13
|
-
amount: number | string;
|
|
14
|
-
transferAll?: boolean;
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=configs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/services/substrate/configs.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,UAAU;mCACQ,uBAAuB;wDAPnD,iBAAiB;sDAAjB,iBAAiB;CAYnB,CAAC;AAEF,eAAO,MAAM,WAAW,cAAc,CAAC;AAEvC,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC"}
|