dash-platform-sdk 1.5.0-dev.1 → 1.5.0-dev.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/README.md +15 -14
- package/bundle.min.js +1 -21
- package/package.json +5 -4
- package/proto/generated/platform.client.d.ts +50 -0
- package/proto/generated/platform.client.js +53 -18
- package/proto/generated/platform.d.ts +888 -0
- package/proto/generated/platform.js +2216 -417
- package/src/constants.d.ts +1 -1
- package/src/constants.js +1 -1
- package/src/documents/query.js +1 -1
- package/src/identities/createStateTransition.js +2 -2
- package/src/keyPair/index.d.ts +63 -1
- package/src/keyPair/index.js +96 -1
- package/src/node/{epochs.d.ts → epochInfos.d.ts} +1 -1
- package/src/node/{epochs.js → epochInfos.js} +1 -1
- package/src/node/finalizedEpochInfos.d.ts +21 -0
- package/src/node/finalizedEpochInfos.js +54 -0
- package/src/node/index.d.ts +9 -1
- package/src/node/index.js +11 -1
- package/src/platformAddresses/createStateTransition.d.ts +12 -0
- package/src/platformAddresses/createStateTransition.js +62 -0
- package/src/platformAddresses/getAddressesBranchState.d.ts +3 -0
- package/src/platformAddresses/getAddressesBranchState.js +21 -0
- package/src/platformAddresses/getAddressesTrunkState.d.ts +3 -0
- package/src/platformAddresses/getAddressesTrunkState.js +33 -0
- package/src/platformAddresses/getRecentAddressBalanceChanges.d.ts +3 -0
- package/src/platformAddresses/getRecentAddressBalanceChanges.js +38 -0
- package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.d.ts +3 -0
- package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.js +37 -0
- package/src/platformAddresses/index.d.ts +63 -2
- package/src/platformAddresses/index.js +76 -0
- package/src/shielded/createStateTransition.d.ts +1 -1
- package/src/shielded/createStateTransition.js +7 -2
- package/src/shielded/index.d.ts +7 -6
- package/src/shielded/index.js +10 -8
- package/src/utils/verifyTenderdashProof.js +3 -0
- package/test/unit/Identity.spec.js +1 -1
- package/test/unit/KeyPair.spec.js +49 -1
- package/test/unit/Node.spec.js +6 -0
- package/test/unit/PlatformAddress.spec.js +155 -1
- package/test/unit/Shielded.spec.js +17 -16
- package/types.d.ts +69 -2
- package/types.js +1 -1
package/src/constants.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export declare const MAINNET_ACTIVATION_HEIGHT = 2128896;
|
|
|
10
10
|
export declare const GRPC_DEFAULT_POOL_LIMIT = 5;
|
|
11
11
|
export declare const DPNS_DATA_CONTRACT_ID = "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec";
|
|
12
12
|
export declare const DPNS_DATA_CONTRACT_BYTES = "AeZoxlmvZq7h5ywYbd57W34KHXEqCcQNVyH2Ir9TxTFVAAAAAAABAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIGZG9tYWluFgsSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESDHRyYW5zZmVyYWJsZQIBEgl0cmFkZU1vZGUCARIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQIWBBIEbmFtZRIScGFyZW50TmFtZUFuZExhYmVsEgpwcm9wZXJ0aWVzFQIWARIabm9ybWFsaXplZFBhcmVudERvbWFpbk5hbWUSA2FzYxYBEg9ub3JtYWxpemVkTGFiZWwSA2FzYxIGdW5pcXVlEwESCWNvbnRlc3RlZBYDEgxmaWVsZE1hdGNoZXMVARYCEgVmaWVsZBIPbm9ybWFsaXplZExhYmVsEgxyZWdleFBhdHRlcm4SE15bYS16QS1aMDEtXXszLDE5fSQSCnJlc29sdXRpb24CABILZGVzY3JpcHRpb24SqklmIHRoZSBub3JtYWxpemVkIGxhYmVsIHBhcnQgb2YgdGhpcyBpbmRleCBpcyBsZXNzIHRoYW4gMjAgY2hhcmFjdGVycyAoYWxsIGFscGhhYmV0IGEteiwgQS1aLCAwLCAxLCBhbmQgLSkgdGhlbiBhIG1hc3Rlcm5vZGUgdm90ZSBjb250ZXN0IHRha2VzIHBsYWNlI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IGRlbGV0aW9uIGFyZSByZXN0cmljdGVkAAAAAAAAAAAAAA==";
|
|
13
|
-
export declare const LATEST_PLATFORM_VERSION = PlatformVersionWASM.
|
|
13
|
+
export declare const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V13;
|
package/src/constants.js
CHANGED
|
@@ -10,4 +10,4 @@ export const MAINNET_ACTIVATION_HEIGHT = 2128896;
|
|
|
10
10
|
export const GRPC_DEFAULT_POOL_LIMIT = 5;
|
|
11
11
|
export const DPNS_DATA_CONTRACT_ID = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
12
12
|
export const DPNS_DATA_CONTRACT_BYTES = 'AeZoxlmvZq7h5ywYbd57W34KHXEqCcQNVyH2Ir9TxTFVAAAAAAABAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIGZG9tYWluFgsSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESDHRyYW5zZmVyYWJsZQIBEgl0cmFkZU1vZGUCARIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQIWBBIEbmFtZRIScGFyZW50TmFtZUFuZExhYmVsEgpwcm9wZXJ0aWVzFQIWARIabm9ybWFsaXplZFBhcmVudERvbWFpbk5hbWUSA2FzYxYBEg9ub3JtYWxpemVkTGFiZWwSA2FzYxIGdW5pcXVlEwESCWNvbnRlc3RlZBYDEgxmaWVsZE1hdGNoZXMVARYCEgVmaWVsZBIPbm9ybWFsaXplZExhYmVsEgxyZWdleFBhdHRlcm4SE15bYS16QS1aMDEtXXszLDE5fSQSCnJlc29sdXRpb24CABILZGVzY3JpcHRpb24SqklmIHRoZSBub3JtYWxpemVkIGxhYmVsIHBhcnQgb2YgdGhpcyBpbmRleCBpcyBsZXNzIHRoYW4gMjAgY2hhcmFjdGVycyAoYWxsIGFscGhhYmV0IGEteiwgQS1aLCAwLCAxLCBhbmQgLSkgdGhlbiBhIG1hc3Rlcm5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UgaW1tdXRhYmxlOiBtb2RpZmljYXRpb24gYW5kIGRlbGV0aW9uIGFyZSByZXN0cmljdGVkAAAAAAAAAAAAAA==';
|
|
13
|
-
export const LATEST_PLATFORM_VERSION = PlatformVersionWASM.
|
|
13
|
+
export const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V13;
|
package/src/documents/query.js
CHANGED
|
@@ -4,7 +4,7 @@ import { DAPI_DEFAULT_LIMIT, LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
|
4
4
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
5
|
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
6
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
7
|
-
import { encode } from '
|
|
7
|
+
import { encode } from 'cbor2';
|
|
8
8
|
import getDataContractByIdentifier from '../dataContracts/getDataContractByIdentifier.js';
|
|
9
9
|
export default async function query(grpcPool, dataContractId, documentTypeName, where, orderBy, limit = 100, startAt, startAfter) {
|
|
10
10
|
let start;
|
|
@@ -23,7 +23,7 @@ const identityTransitionsMap = {
|
|
|
23
23
|
withdrawal: {
|
|
24
24
|
class: IdentityCreditWithdrawalTransitionWASM,
|
|
25
25
|
arguments: ['identityId', 'amount', 'coreFeePerByte', 'pooling', 'identityNonce', 'outputScript'],
|
|
26
|
-
optionalArguments: ['userFeeIncrease']
|
|
26
|
+
optionalArguments: ['outputScript', 'userFeeIncrease']
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
export default function createStateTransition(type, params) {
|
|
@@ -35,7 +35,7 @@ export default function createStateTransition(type, params) {
|
|
|
35
35
|
.filter((classArgument) => params[classArgument] == null &&
|
|
36
36
|
!(optionalArguments).includes(classArgument));
|
|
37
37
|
if (missingArgument != null) {
|
|
38
|
-
throw new Error(`
|
|
38
|
+
throw new Error(`Transition param "${missingArgument}" is missing`);
|
|
39
39
|
}
|
|
40
40
|
const transitionParams = classArguments.map((classArgument) => params[classArgument]);
|
|
41
41
|
// @ts-expect-error
|
package/src/keyPair/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HDKey } from '@scure/bip32';
|
|
2
2
|
import { Network } from '../../types.js';
|
|
3
|
-
import { OrchardAddressWASM } from 'pshenmic-dpp';
|
|
3
|
+
import { OrchardAddressWASM, PlatformAddressWASM, PrivateKeyWASM } from 'pshenmic-dpp';
|
|
4
4
|
/**
|
|
5
5
|
* Collection of functions to work with private keys and seed phrases
|
|
6
6
|
*
|
|
@@ -65,6 +65,16 @@ export declare class KeyPairController {
|
|
|
65
65
|
* @returns {string}
|
|
66
66
|
*/
|
|
67
67
|
p2pkhAddress(publicKey: Uint8Array, network: Network): string;
|
|
68
|
+
/**
|
|
69
|
+
* Converts a public key to a transparent platform P2PKH address (DIP-18):
|
|
70
|
+
* the canonical `variantByte || Hash160(pubkey)` PlatformAddress.
|
|
71
|
+
*
|
|
72
|
+
* @param publicKey {Uint8Array}
|
|
73
|
+
* @param network {Network}
|
|
74
|
+
*
|
|
75
|
+
* @returns {PlatformAddressWASM}
|
|
76
|
+
*/
|
|
77
|
+
platformAddress(publicKey: Uint8Array, network: Network): PlatformAddressWASM;
|
|
68
78
|
/**
|
|
69
79
|
* Derives a shielded (Orchard) address from a BIP-39 seed via ZIP-32
|
|
70
80
|
* (m/32'/coinType'/account').
|
|
@@ -89,4 +99,56 @@ export declare class KeyPairController {
|
|
|
89
99
|
* @returns {Uint8Array} 32-byte outgoing viewing key
|
|
90
100
|
*/
|
|
91
101
|
deriveShieldedOutgoingViewingKey(seed: Uint8Array, network: Network, account: number): Uint8Array;
|
|
102
|
+
/**
|
|
103
|
+
* Derives the DIP-17 account-level extended public key (xpub) for the
|
|
104
|
+
* clear-funds key class: m/9'/coinType'/17'/account'/0'. The seed is only
|
|
105
|
+
* needed once per account — the returned xpub derives every address index
|
|
106
|
+
* publicly (see {@link derivePlatformAddressFromXpub}), with no further access
|
|
107
|
+
* to the seed.
|
|
108
|
+
*
|
|
109
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
110
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
111
|
+
* @param account {number} - DIP-17 account index
|
|
112
|
+
*
|
|
113
|
+
* @returns {Promise<string>} account-level extended public key
|
|
114
|
+
*/
|
|
115
|
+
derivePlatformAccountXpub(seed: Uint8Array, network: Network, account: number): Promise<string>;
|
|
116
|
+
/**
|
|
117
|
+
* Derives a transparent platform P2PKH address from a BIP-39 seed via DIP-17
|
|
118
|
+
* (m/9'/coinType'/17'/account'/0'/index).
|
|
119
|
+
*
|
|
120
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
121
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
122
|
+
* @param account {number} - DIP-17 account index
|
|
123
|
+
* @param index {number} - address index
|
|
124
|
+
*
|
|
125
|
+
* @returns {Promise<PlatformAddressWASM>}
|
|
126
|
+
*/
|
|
127
|
+
derivePlatformAddress(seed: Uint8Array, network: Network, account: number, index: number): Promise<PlatformAddressWASM>;
|
|
128
|
+
/**
|
|
129
|
+
* Derives a transparent platform P2PKH address from an account-level xpub (see
|
|
130
|
+
* {@link derivePlatformAccountXpub}). The address index is non-hardened, so
|
|
131
|
+
* public-only derivation reproduces the exact same address as the seed-based
|
|
132
|
+
* path — no seed required.
|
|
133
|
+
*
|
|
134
|
+
* @param xpub {string} - account-level extended public key
|
|
135
|
+
* @param network {Network} - network (selects the extended-key version bytes)
|
|
136
|
+
* @param index {number} - address index
|
|
137
|
+
*
|
|
138
|
+
* @returns {PlatformAddressWASM}
|
|
139
|
+
*/
|
|
140
|
+
derivePlatformAddressFromXpub(xpub: string, network: Network, index: number): PlatformAddressWASM;
|
|
141
|
+
/**
|
|
142
|
+
* Derives the private key for a DIP-17 platform address by its index
|
|
143
|
+
* (m/9'/coinType'/17'/account'/0'/index). Used to sign a transfer that spends
|
|
144
|
+
* from that address.
|
|
145
|
+
*
|
|
146
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
147
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
148
|
+
* @param account {number} - DIP-17 account index
|
|
149
|
+
* @param index {number} - address index
|
|
150
|
+
*
|
|
151
|
+
* @returns {Promise<PrivateKeyWASM>}
|
|
152
|
+
*/
|
|
153
|
+
derivePlatformAddressPrivateKey(seed: Uint8Array, network: Network, account: number, index: number): Promise<PrivateKeyWASM>;
|
|
92
154
|
}
|
package/src/keyPair/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import mnemonicToSeed from './mnemonicToSeed.js';
|
|
|
3
3
|
import deriveChild from './deriveChild.js';
|
|
4
4
|
import derivePath from './derivePath.js';
|
|
5
5
|
import { p2pkh } from '@scure/btc-signer';
|
|
6
|
-
import { OrchardAddressWASM, orchardOvkFromSeed } from 'pshenmic-dpp';
|
|
6
|
+
import { OrchardAddressWASM, orchardOvkFromSeed, PlatformAddressWASM, PrivateKeyWASM } from 'pshenmic-dpp';
|
|
7
7
|
const DASH_VERSIONS = {
|
|
8
8
|
mainnet: { pubKeyHash: 0x4c, scriptHash: 0x10, bech32: 'dc', wif: 0xcc, private: 0x0488ade4, public: 0x0488b21e },
|
|
9
9
|
testnet: { pubKeyHash: 0x8c, scriptHash: 0x13, bech32: 'dc', wif: 0xef, private: 0x04358394, public: 0x043587cf }
|
|
@@ -87,6 +87,20 @@ export class KeyPairController {
|
|
|
87
87
|
const P2PKH = p2pkh(publicKey, DASH_VERSIONS[network]);
|
|
88
88
|
return P2PKH.address;
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Converts a public key to a transparent platform P2PKH address (DIP-18):
|
|
92
|
+
* the canonical `variantByte || Hash160(pubkey)` PlatformAddress.
|
|
93
|
+
*
|
|
94
|
+
* @param publicKey {Uint8Array}
|
|
95
|
+
* @param network {Network}
|
|
96
|
+
*
|
|
97
|
+
* @returns {PlatformAddressWASM}
|
|
98
|
+
*/
|
|
99
|
+
platformAddress(publicKey, network) {
|
|
100
|
+
const { hash } = p2pkh(publicKey, DASH_VERSIONS[network]);
|
|
101
|
+
// variant byte 0x00 = P2PKH
|
|
102
|
+
return PlatformAddressWASM.fromBytes(Uint8Array.from([0x00, ...hash]));
|
|
103
|
+
}
|
|
90
104
|
/**
|
|
91
105
|
* Derives a shielded (Orchard) address from a BIP-39 seed via ZIP-32
|
|
92
106
|
* (m/32'/coinType'/account').
|
|
@@ -119,4 +133,85 @@ export class KeyPairController {
|
|
|
119
133
|
const coinType = network === 'mainnet' ? 5 : 1;
|
|
120
134
|
return orchardOvkFromSeed(seed, coinType, account);
|
|
121
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Derives the DIP-17 account-level extended public key (xpub) for the
|
|
138
|
+
* clear-funds key class: m/9'/coinType'/17'/account'/0'. The seed is only
|
|
139
|
+
* needed once per account — the returned xpub derives every address index
|
|
140
|
+
* publicly (see {@link derivePlatformAddressFromXpub}), with no further access
|
|
141
|
+
* to the seed.
|
|
142
|
+
*
|
|
143
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
144
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
145
|
+
* @param account {number} - DIP-17 account index
|
|
146
|
+
*
|
|
147
|
+
* @returns {Promise<string>} account-level extended public key
|
|
148
|
+
*/
|
|
149
|
+
async derivePlatformAccountXpub(seed, network, account) {
|
|
150
|
+
const coinType = network === 'mainnet' ? 5 : 1;
|
|
151
|
+
const hdKey = this.seedToHdKey(seed, network);
|
|
152
|
+
const accountNode = await this.derivePath(hdKey, `m/9'/${coinType}'/17'/${account}'/0'`);
|
|
153
|
+
return accountNode.publicExtendedKey;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Derives a transparent platform P2PKH address from a BIP-39 seed via DIP-17
|
|
157
|
+
* (m/9'/coinType'/17'/account'/0'/index).
|
|
158
|
+
*
|
|
159
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
160
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
161
|
+
* @param account {number} - DIP-17 account index
|
|
162
|
+
* @param index {number} - address index
|
|
163
|
+
*
|
|
164
|
+
* @returns {Promise<PlatformAddressWASM>}
|
|
165
|
+
*/
|
|
166
|
+
async derivePlatformAddress(seed, network, account, index) {
|
|
167
|
+
const coinType = network === 'mainnet' ? 5 : 1;
|
|
168
|
+
const hdKey = this.seedToHdKey(seed, network);
|
|
169
|
+
const childNode = await this.derivePath(hdKey, `m/9'/${coinType}'/17'/${account}'/0'/${index}`);
|
|
170
|
+
if (childNode.publicKey == null) {
|
|
171
|
+
throw new Error(`Could not derive platform address public key at index ${index}`);
|
|
172
|
+
}
|
|
173
|
+
return this.platformAddress(childNode.publicKey, network);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Derives a transparent platform P2PKH address from an account-level xpub (see
|
|
177
|
+
* {@link derivePlatformAccountXpub}). The address index is non-hardened, so
|
|
178
|
+
* public-only derivation reproduces the exact same address as the seed-based
|
|
179
|
+
* path — no seed required.
|
|
180
|
+
*
|
|
181
|
+
* @param xpub {string} - account-level extended public key
|
|
182
|
+
* @param network {Network} - network (selects the extended-key version bytes)
|
|
183
|
+
* @param index {number} - address index
|
|
184
|
+
*
|
|
185
|
+
* @returns {PlatformAddressWASM}
|
|
186
|
+
*/
|
|
187
|
+
derivePlatformAddressFromXpub(xpub, network, index) {
|
|
188
|
+
const accountNode = HDKey.fromExtendedKey(xpub, DASH_VERSIONS[network]);
|
|
189
|
+
const childNode = accountNode.deriveChild(index);
|
|
190
|
+
if (childNode.publicKey == null) {
|
|
191
|
+
throw new Error(`Could not derive platform address public key at index ${index}`);
|
|
192
|
+
}
|
|
193
|
+
return this.platformAddress(childNode.publicKey, network);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Derives the private key for a DIP-17 platform address by its index
|
|
197
|
+
* (m/9'/coinType'/17'/account'/0'/index). Used to sign a transfer that spends
|
|
198
|
+
* from that address.
|
|
199
|
+
*
|
|
200
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
201
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
202
|
+
* @param account {number} - DIP-17 account index
|
|
203
|
+
* @param index {number} - address index
|
|
204
|
+
*
|
|
205
|
+
* @returns {Promise<PrivateKeyWASM>}
|
|
206
|
+
*/
|
|
207
|
+
async derivePlatformAddressPrivateKey(seed, network, account, index) {
|
|
208
|
+
const coinType = network === 'mainnet' ? 5 : 1;
|
|
209
|
+
const hdKey = this.seedToHdKey(seed, network);
|
|
210
|
+
const path = `m/9'/${coinType}'/17'/${account}'/0'/${index}`;
|
|
211
|
+
const { privateKey } = await this.derivePath(hdKey, path);
|
|
212
|
+
if (privateKey == null) {
|
|
213
|
+
throw new Error(`Could not derive platform address key at ${path}`);
|
|
214
|
+
}
|
|
215
|
+
return PrivateKeyWASM.fromBytes(privateKey, network);
|
|
216
|
+
}
|
|
122
217
|
}
|
|
@@ -7,4 +7,4 @@ export interface EpochInfo {
|
|
|
7
7
|
feeMultiplier: bigint;
|
|
8
8
|
protocolVersion: 9;
|
|
9
9
|
}
|
|
10
|
-
export default function
|
|
10
|
+
export default function epochInfos(grpcPool: GRPCConnectionPool, count: number, ascending: boolean, start?: number): Promise<EpochInfo[]>;
|
|
@@ -5,7 +5,7 @@ import bytesToHex from '../utils/bytesToHex.js';
|
|
|
5
5
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
6
|
import { UInt32Value } from '../../proto/generated/google/protobuf/wrappers.js';
|
|
7
7
|
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
8
|
-
export default async function
|
|
8
|
+
export default async function epochInfos(grpcPool, count, ascending, start) {
|
|
9
9
|
const getEpochsInfoRequest = GetEpochsInfoRequest.create({
|
|
10
10
|
version: {
|
|
11
11
|
oneofKind: 'v0',
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
+
import { IdentifierWASM } from 'pshenmic-dpp';
|
|
3
|
+
export interface FinalizedEpochInfo {
|
|
4
|
+
epochIndex: number;
|
|
5
|
+
firstBlockTime: Date;
|
|
6
|
+
firstBlockHeight: bigint;
|
|
7
|
+
totalBlocksInEpoch: bigint;
|
|
8
|
+
firstCoreBlockHeight: number;
|
|
9
|
+
nextEpochStartCoreBlockHeight: number;
|
|
10
|
+
totalProcessingFees: bigint;
|
|
11
|
+
totalDistributedStorageFees: bigint;
|
|
12
|
+
totalCreatedStorageFees: bigint;
|
|
13
|
+
coreBlockRewards: bigint;
|
|
14
|
+
blockProposers: {
|
|
15
|
+
proposer: IdentifierWASM;
|
|
16
|
+
count: bigint;
|
|
17
|
+
}[];
|
|
18
|
+
feeMultiplier: bigint;
|
|
19
|
+
protocolVersion: number;
|
|
20
|
+
}
|
|
21
|
+
export default function getFinalizedEpochsInfo(grpcPool: GRPCConnectionPool, startEpochIndex: number, startEpochIndexIncluded: boolean, endEpochIndex: number, endEpochIndexIncluded: boolean): Promise<FinalizedEpochInfo[]>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { GetFinalizedEpochInfosRequest } from '../../proto/generated/platform.js';
|
|
2
|
+
import { verifyFinalizedEpochInfosProof } from 'pshenmic-dpp';
|
|
3
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
5
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
7
|
+
export default async function getFinalizedEpochsInfo(grpcPool, startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded) {
|
|
8
|
+
const getEpochsInfoRequest = GetFinalizedEpochInfosRequest.create({
|
|
9
|
+
version: {
|
|
10
|
+
oneofKind: 'v0',
|
|
11
|
+
v0: {
|
|
12
|
+
startEpochIndex,
|
|
13
|
+
startEpochIndexIncluded,
|
|
14
|
+
endEpochIndex,
|
|
15
|
+
endEpochIndexIncluded,
|
|
16
|
+
prove: true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const { response } = await grpcPool.getClient().getFinalizedEpochInfos(getEpochsInfoRequest);
|
|
21
|
+
const { version } = response;
|
|
22
|
+
if (version.oneofKind !== 'v0') {
|
|
23
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
24
|
+
}
|
|
25
|
+
const { v0 } = version;
|
|
26
|
+
if (v0.result.oneofKind !== 'proof') {
|
|
27
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
|
|
28
|
+
}
|
|
29
|
+
const { result: { proof }, metadata } = v0;
|
|
30
|
+
if (metadata == null) {
|
|
31
|
+
throw new Error('Metadata not found');
|
|
32
|
+
}
|
|
33
|
+
const { rootHash, epochInfos } = verifyFinalizedEpochInfosProof(proof.grovedbProof, startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded, LATEST_PLATFORM_VERSION);
|
|
34
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
35
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
36
|
+
if (!verify) {
|
|
37
|
+
throw new Error('Failed to verify query');
|
|
38
|
+
}
|
|
39
|
+
return epochInfos.map(info => ({
|
|
40
|
+
epochIndex: info.epochIndex,
|
|
41
|
+
firstBlockTime: info.firstBlockTime,
|
|
42
|
+
firstBlockHeight: info.firstBlockHeight,
|
|
43
|
+
totalBlocksInEpoch: info.totalBlocksInEpoch,
|
|
44
|
+
firstCoreBlockHeight: info.firstCoreBlockHeight,
|
|
45
|
+
nextEpochStartCoreBlockHeight: info.nextEpochStartCoreBlockHeight,
|
|
46
|
+
totalProcessingFees: info.totalProcessingFees,
|
|
47
|
+
totalDistributedStorageFees: info.totalDistributedStorageFees,
|
|
48
|
+
totalCreatedStorageFees: info.totalCreatedStorageFees,
|
|
49
|
+
coreBlockRewards: info.coreBlockRewards,
|
|
50
|
+
blockProposers: info.blockProposers,
|
|
51
|
+
feeMultiplier: info.feeMultiplierPermille,
|
|
52
|
+
protocolVersion: info.protocolVersion
|
|
53
|
+
}));
|
|
54
|
+
}
|
package/src/node/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
2
|
import { NodeStatus } from '../../types.js';
|
|
3
|
-
import { EpochInfo } from './
|
|
3
|
+
import { EpochInfo } from './epochInfos.js';
|
|
4
|
+
import { FinalizedEpochInfo } from './finalizedEpochInfos.js';
|
|
4
5
|
/**
|
|
5
6
|
* Node controller for requesting information about DAPI node
|
|
6
7
|
*
|
|
@@ -30,4 +31,11 @@ export declare class NodeController {
|
|
|
30
31
|
* @return {Promise<EpochInfo[]>}
|
|
31
32
|
*/
|
|
32
33
|
getEpochsInfo(count: number, ascending: boolean, start?: number): Promise<EpochInfo[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves an finalized info about epochs
|
|
36
|
+
* Includes information about first block height, time, fee multiplier, number
|
|
37
|
+
*
|
|
38
|
+
* @return {Promise<FinalizedEpochInfo[]>}
|
|
39
|
+
*/
|
|
40
|
+
getFinalizedEpochsInfo(startEpochIndex: number, startEpochIndexIncluded: boolean, endEpochIndex: number, endEpochIndexIncluded: boolean): Promise<FinalizedEpochInfo[]>;
|
|
33
41
|
}
|
package/src/node/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import getStatus from './status.js';
|
|
2
|
-
import getEpochsInfo from './
|
|
2
|
+
import getEpochsInfo from './epochInfos.js';
|
|
3
|
+
import getFinalizedEpochsInfo from './finalizedEpochInfos.js';
|
|
3
4
|
import getTotalCredits from './totalCredits.js';
|
|
4
5
|
/**
|
|
5
6
|
* Node controller for requesting information about DAPI node
|
|
@@ -38,4 +39,13 @@ export class NodeController {
|
|
|
38
39
|
async getEpochsInfo(count, ascending, start) {
|
|
39
40
|
return await getEpochsInfo(this.grpcPool, count, ascending, start);
|
|
40
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves an finalized info about epochs
|
|
44
|
+
* Includes information about first block height, time, fee multiplier, number
|
|
45
|
+
*
|
|
46
|
+
* @return {Promise<FinalizedEpochInfo[]>}
|
|
47
|
+
*/
|
|
48
|
+
async getFinalizedEpochsInfo(startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded) {
|
|
49
|
+
return await getFinalizedEpochsInfo(this.grpcPool, startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded);
|
|
50
|
+
}
|
|
41
51
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StateTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { PlatformAddressTransitionParamsMap, PlatformAddressTransitionType } from '../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Helper function that assembles a {StateTransitionWASM} for Platform Address transitions
|
|
5
|
+
* out of already-built params. The builder is pure: it does not sign, broadcast or
|
|
6
|
+
* mutate the passed params. Producing witnesses / signatures stays the caller's
|
|
7
|
+
* responsibility (they are passed in via the `inputWitness` / `signature` params).
|
|
8
|
+
*
|
|
9
|
+
* @param type {string} type of transition
|
|
10
|
+
* @param params {PlatformAddressTransitionParamsMap[K]} params required by that transition type
|
|
11
|
+
*/
|
|
12
|
+
export default function createStateTransition<K extends PlatformAddressTransitionType>(type: K, params: PlatformAddressTransitionParamsMap[K]): StateTransitionWASM;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { IdentityCreditTransferToAddressesTransitionWASM, IdentityCreateFromAddressesTransitionWASM, IdentityTopUpFromAddressesTransitionWASM, AddressFundsTransferTransitionWASM, AddressFundingFromAssetLockTransitionWASM, AddressCreditWithdrawalTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
+
const platformAddressTransitionsMap = {
|
|
3
|
+
identityCreditTransferToAddresses: {
|
|
4
|
+
class: IdentityCreditTransferToAddressesTransitionWASM,
|
|
5
|
+
arguments: ['identityId', 'recipients', 'nonce', 'userFeeIncrease'],
|
|
6
|
+
optionalArguments: ['userFeeIncrease']
|
|
7
|
+
},
|
|
8
|
+
identityCreateFromAddresses: {
|
|
9
|
+
class: IdentityCreateFromAddressesTransitionWASM,
|
|
10
|
+
arguments: ['publicKeys', 'inputs', 'feeStrategy', 'userFeeIncrease', 'inputWitness', 'output'],
|
|
11
|
+
optionalArguments: ['userFeeIncrease', 'output']
|
|
12
|
+
},
|
|
13
|
+
identityTopUpFromAddresses: {
|
|
14
|
+
class: IdentityTopUpFromAddressesTransitionWASM,
|
|
15
|
+
arguments: ['identityId', 'inputs', 'feeStrategy', 'userFeeIncrease', 'inputWitness', 'output'],
|
|
16
|
+
optionalArguments: ['userFeeIncrease', 'output']
|
|
17
|
+
},
|
|
18
|
+
addressFundsTransfer: {
|
|
19
|
+
class: AddressFundsTransferTransitionWASM,
|
|
20
|
+
arguments: ['inputs', 'feeStrategy', 'userFeeIncrease', 'inputWitness', 'outputs'],
|
|
21
|
+
optionalArguments: ['userFeeIncrease']
|
|
22
|
+
},
|
|
23
|
+
addressFundingFromAssetLock: {
|
|
24
|
+
class: AddressFundingFromAssetLockTransitionWASM,
|
|
25
|
+
arguments: ['assetLockProof', 'inputs', 'feeStrategy', 'userFeeIncrease', 'inputWitness', 'outputs'],
|
|
26
|
+
optionalArguments: ['userFeeIncrease']
|
|
27
|
+
},
|
|
28
|
+
addressCreditWithdrawal: {
|
|
29
|
+
class: AddressCreditWithdrawalTransitionWASM,
|
|
30
|
+
arguments: ['inputs', 'feeStrategy', 'coreFeePerByte', 'pooling', 'outputScript', 'userFeeIncrease', 'inputWitness', 'output'],
|
|
31
|
+
optionalArguments: ['userFeeIncrease', 'output']
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Helper function that assembles a {StateTransitionWASM} for Platform Address transitions
|
|
36
|
+
* out of already-built params. The builder is pure: it does not sign, broadcast or
|
|
37
|
+
* mutate the passed params. Producing witnesses / signatures stays the caller's
|
|
38
|
+
* responsibility (they are passed in via the `inputWitness` / `signature` params).
|
|
39
|
+
*
|
|
40
|
+
* @param type {string} type of transition
|
|
41
|
+
* @param params {PlatformAddressTransitionParamsMap[K]} params required by that transition type
|
|
42
|
+
*/
|
|
43
|
+
export default function createStateTransition(type, params) {
|
|
44
|
+
const { class: TransitionClass, arguments: classArguments, optionalArguments } = platformAddressTransitionsMap[type] ?? {};
|
|
45
|
+
if (TransitionClass == null) {
|
|
46
|
+
throw new Error(`Unimplemented transition type: ${type}`);
|
|
47
|
+
}
|
|
48
|
+
const [missingArgument] = classArguments
|
|
49
|
+
.filter((classArgument) => params[classArgument] == null &&
|
|
50
|
+
!optionalArguments.includes(classArgument));
|
|
51
|
+
if (missingArgument != null) {
|
|
52
|
+
throw new Error(`Platform address transition param "${missingArgument}" is missing`);
|
|
53
|
+
}
|
|
54
|
+
// userFeeIncrease is a required positional `number` in every WASM constructor,
|
|
55
|
+
// so coerce a missing value to 0 to keep the positional order intact.
|
|
56
|
+
const transitionParams = classArguments.map((classArgument) => classArgument === 'userFeeIncrease'
|
|
57
|
+
? (params[classArgument] ?? 0)
|
|
58
|
+
: params[classArgument]);
|
|
59
|
+
// @ts-expect-error
|
|
60
|
+
const platformAddressTransition = new TransitionClass(...transitionParams);
|
|
61
|
+
return platformAddressTransition.toStateTransition();
|
|
62
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
+
import { VerifiedAddressesBranchState } from 'pshenmic-dpp';
|
|
3
|
+
export declare function getAddressesBranchState(grpcPool: GRPCConnectionPool, key: Uint8Array, depth: number, checkpointHeight: bigint, expectedRootHash: Uint8Array): Promise<VerifiedAddressesBranchState>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { verifyAddressesBranchState } from 'pshenmic-dpp';
|
|
2
|
+
import { GetAddressesBranchStateRequest } from '../../proto/generated/platform.js';
|
|
3
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
|
+
export async function getAddressesBranchState(grpcPool, key, depth, checkpointHeight, expectedRootHash) {
|
|
5
|
+
const getAddressesBranchStateRequest = GetAddressesBranchStateRequest.create({
|
|
6
|
+
version: {
|
|
7
|
+
oneofKind: 'v0',
|
|
8
|
+
v0: {
|
|
9
|
+
key,
|
|
10
|
+
depth,
|
|
11
|
+
checkpointHeight: checkpointHeight.toString()
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const { response } = await grpcPool.getClient().getAddressesBranchState(getAddressesBranchStateRequest);
|
|
16
|
+
const { version } = response;
|
|
17
|
+
if (version.oneofKind !== 'v0') {
|
|
18
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
19
|
+
}
|
|
20
|
+
return verifyAddressesBranchState(version.v0.merkProof, key, depth, expectedRootHash, LATEST_PLATFORM_VERSION);
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { verifyAddressesTrunkState } from 'pshenmic-dpp';
|
|
2
|
+
import { GetAddressesTrunkStateRequest } from '../../proto/generated/platform.js';
|
|
3
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
7
|
+
export async function getAddressesTrunkState(grpcPool) {
|
|
8
|
+
const getAddressesTrunkStateRequest = GetAddressesTrunkStateRequest.create({
|
|
9
|
+
version: {
|
|
10
|
+
oneofKind: 'v0',
|
|
11
|
+
v0: {}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const { response } = await grpcPool.getClient().getAddressesTrunkState(getAddressesTrunkStateRequest);
|
|
15
|
+
const { version } = response;
|
|
16
|
+
if (version.oneofKind !== 'v0') {
|
|
17
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
18
|
+
}
|
|
19
|
+
const { v0: { proof, metadata } } = version;
|
|
20
|
+
if (proof == null) {
|
|
21
|
+
throw new Error('Proof not found');
|
|
22
|
+
}
|
|
23
|
+
if (metadata == null) {
|
|
24
|
+
throw new Error('Metadata not found');
|
|
25
|
+
}
|
|
26
|
+
const trunk = verifyAddressesTrunkState(proof.grovedbProof, LATEST_PLATFORM_VERSION);
|
|
27
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
28
|
+
const verify = await verifyTenderdashProof(proof, metadata, trunk.rootHash, quorumPublicKey);
|
|
29
|
+
if (!verify) {
|
|
30
|
+
throw new Error('Failed to verify query');
|
|
31
|
+
}
|
|
32
|
+
return { trunk, metadata };
|
|
33
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
+
import { BlockAddressBalanceChanges } from 'pshenmic-dpp';
|
|
3
|
+
export declare function getRecentAddressBalanceChanges(grpcPool: GRPCConnectionPool, startHeight: bigint, startHeightExclusive?: boolean): Promise<BlockAddressBalanceChanges[]>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { verifyRecentAddressBalanceChanges } from 'pshenmic-dpp';
|
|
2
|
+
import { GetRecentAddressBalanceChangesRequest } from '../../proto/generated/platform.js';
|
|
3
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
7
|
+
export async function getRecentAddressBalanceChanges(grpcPool, startHeight, startHeightExclusive = false) {
|
|
8
|
+
const getRecentAddressBalanceChangesRequest = GetRecentAddressBalanceChangesRequest.create({
|
|
9
|
+
version: {
|
|
10
|
+
oneofKind: 'v0',
|
|
11
|
+
v0: {
|
|
12
|
+
startHeight: startHeight.toString(),
|
|
13
|
+
prove: true,
|
|
14
|
+
startHeightExclusive
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const { response } = await grpcPool.getClient().getRecentAddressBalanceChanges(getRecentAddressBalanceChangesRequest);
|
|
19
|
+
const { version } = response;
|
|
20
|
+
if (version.oneofKind !== 'v0') {
|
|
21
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
22
|
+
}
|
|
23
|
+
const { v0 } = version;
|
|
24
|
+
if (v0.result.oneofKind !== 'proof') {
|
|
25
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
|
|
26
|
+
}
|
|
27
|
+
const { result: { proof }, metadata } = v0;
|
|
28
|
+
if (metadata == null) {
|
|
29
|
+
throw new Error('Metadata not found');
|
|
30
|
+
}
|
|
31
|
+
const { rootHash, blocks } = verifyRecentAddressBalanceChanges(proof.grovedbProof, startHeight, startHeightExclusive, undefined, true, LATEST_PLATFORM_VERSION);
|
|
32
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
33
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
34
|
+
if (!verify) {
|
|
35
|
+
throw new Error('Failed to verify query');
|
|
36
|
+
}
|
|
37
|
+
return blocks;
|
|
38
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
+
import { CompactedBlockAddressBalanceChanges } from 'pshenmic-dpp';
|
|
3
|
+
export declare function getRecentCompactedAddressBalanceChanges(grpcPool: GRPCConnectionPool, startBlockHeight: bigint): Promise<CompactedBlockAddressBalanceChanges[]>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { verifyRecentCompactedAddressBalanceChanges } from 'pshenmic-dpp';
|
|
2
|
+
import { GetRecentCompactedAddressBalanceChangesRequest } from '../../proto/generated/platform.js';
|
|
3
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
7
|
+
export async function getRecentCompactedAddressBalanceChanges(grpcPool, startBlockHeight) {
|
|
8
|
+
const getRecentCompactedAddressBalanceChangesRequest = GetRecentCompactedAddressBalanceChangesRequest.create({
|
|
9
|
+
version: {
|
|
10
|
+
oneofKind: 'v0',
|
|
11
|
+
v0: {
|
|
12
|
+
startBlockHeight: startBlockHeight.toString(),
|
|
13
|
+
prove: true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const { response } = await grpcPool.getClient().getRecentCompactedAddressBalanceChanges(getRecentCompactedAddressBalanceChangesRequest);
|
|
18
|
+
const { version } = response;
|
|
19
|
+
if (version.oneofKind !== 'v0') {
|
|
20
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
21
|
+
}
|
|
22
|
+
const { v0 } = version;
|
|
23
|
+
if (v0.result.oneofKind !== 'proof') {
|
|
24
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
|
|
25
|
+
}
|
|
26
|
+
const { result: { proof }, metadata } = v0;
|
|
27
|
+
if (metadata == null) {
|
|
28
|
+
throw new Error('Metadata not found');
|
|
29
|
+
}
|
|
30
|
+
const { rootHash, ranges } = verifyRecentCompactedAddressBalanceChanges(proof.grovedbProof, startBlockHeight, undefined, LATEST_PLATFORM_VERSION);
|
|
31
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
32
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
33
|
+
if (!verify) {
|
|
34
|
+
throw new Error('Failed to verify query');
|
|
35
|
+
}
|
|
36
|
+
return ranges;
|
|
37
|
+
}
|