dash-platform-sdk 1.3.0-dev.9 → 1.4.0-dev.2
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/bundle.min.js +17 -17
- package/package.json +2 -5
- package/proto/generated/platform.client.d.ts +10 -0
- package/proto/generated/platform.client.js +7 -0
- package/proto/generated/platform.d.ts +114 -0
- package/proto/generated/platform.js +224 -1
- package/src/DashPlatformSDK.d.ts +1 -5
- package/src/DashPlatformSDK.js +0 -5
- package/src/constants.d.ts +2 -0
- package/src/constants.js +1 -0
- package/src/contestedResources/getContestedResourceVoteState.d.ts +1 -1
- package/src/contestedResources/getContestedResourceVoteState.js +10 -5
- package/src/contestedResources/index.d.ts +1 -1
- package/src/dataContracts/create.d.ts +3 -3
- package/src/dataContracts/create.js +3 -2
- package/src/dataContracts/createStateTransition.js +0 -1
- package/src/dataContracts/getDataContractByIdentifier.d.ts +1 -1
- package/src/dataContracts/getDataContractByIdentifier.js +3 -3
- package/src/dataContracts/index.d.ts +3 -3
- package/src/documents/create.d.ts +1 -1
- package/src/documents/create.js +1 -1
- package/src/documents/createStateTransition.d.ts +1 -1
- package/src/documents/index.d.ts +3 -3
- package/src/documents/query.d.ts +3 -3
- package/src/documents/query.js +3 -3
- package/src/grpcConnectionPool.d.ts +1 -1
- package/src/identities/createStateTransition.d.ts +1 -1
- package/src/identities/getIdentityBalance.d.ts +1 -1
- package/src/identities/getIdentityBalance.js +3 -2
- package/src/identities/getIdentityByIdentifier.d.ts +1 -1
- package/src/identities/getIdentityByIdentifier.js +3 -2
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +3 -2
- package/src/identities/getIdentityByPublicKeyHash.js +3 -2
- package/src/identities/getIdentityContractNonce.d.ts +1 -1
- package/src/identities/getIdentityContractNonce.js +3 -2
- package/src/identities/getIdentityNonce.d.ts +1 -1
- package/src/identities/getIdentityNonce.js +3 -2
- package/src/identities/getIdentityPublicKeys.d.ts +2 -2
- package/src/identities/getIdentityPublicKeys.js +19 -9
- package/src/identities/index.d.ts +4 -3
- package/src/identities/index.js +6 -6
- package/src/keyPair/index.d.ts +1 -1
- package/src/names/index.d.ts +1 -1
- package/src/node/epochs.js +3 -2
- package/src/node/index.d.ts +1 -1
- package/src/node/status.d.ts +1 -1
- package/src/node/totalCredits.d.ts +1 -1
- package/src/node/totalCredits.js +3 -3
- package/src/stateTransitions/broadcast.js +1 -1
- package/src/stateTransitions/waitForStateTransitionResult.js +68 -5
- package/src/tokens/createStateTransition.d.ts +1 -1
- package/src/tokens/getIdentitiesTokenBalances.d.ts +2 -2
- package/src/tokens/getIdentitiesTokenBalances.js +6 -5
- package/src/tokens/getIdentityTokensBalances.d.ts +2 -2
- package/src/tokens/getIdentityTokensBalances.js +6 -5
- package/src/tokens/getTokenContractInfo.d.ts +1 -1
- package/src/tokens/getTokenContractInfo.js +3 -2
- package/src/tokens/getTokenDirectPurchasePrices.d.ts +1 -1
- package/src/tokens/getTokenDirectPurchasePrices.js +3 -2
- package/src/tokens/getTokenTotalSupply.d.ts +1 -1
- package/src/tokens/getTokenTotalSupply.js +3 -2
- package/src/tokens/index.d.ts +1 -1
- package/src/utils/getEvonodeList.d.ts +1 -1
- package/src/utils/index.d.ts +8 -0
- package/src/utils/index.js +17 -0
- package/src/voting/index.d.ts +1 -1
- package/test/unit/ContestedResources.spec.js +5 -3
- package/test/unit/DataContract.spec.js +4 -3
- package/test/unit/Document.spec.js +2 -2
- package/test/unit/Identity.spec.js +27 -27
- package/test/unit/Names.spec.js +2 -0
- package/test/unit/Tokens.spec.js +3 -3
- package/{src/types.d.ts → types.d.ts} +8 -7
- package/{src/types.js → types.js} +2 -2
- package/src/signer/AbstractSigner.d.ts +0 -12
- package/src/signer/AbstractSigner.js +0 -1
- package/src/signer/PrivateKeySigner.d.ts +0 -1
- package/src/signer/PrivateKeySigner.js +0 -65
- package/src/signer/setSigner.d.ts +0 -2
- package/src/signer/setSigner.js +0 -5
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DataContractWASM, IdentifierWASM,
|
|
1
|
+
import { DataContractWASM, IdentifierWASM, verifyContractProof } from 'pshenmic-dpp';
|
|
2
2
|
import { GetDataContractRequest } from '../../proto/generated/platform.js';
|
|
3
3
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
4
|
import bytesToHex from '../utils/bytesToHex.js';
|
|
5
5
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
|
-
import { DPNS_DATA_CONTRACT_BYTES, DPNS_DATA_CONTRACT_ID } from '../constants.js';
|
|
6
|
+
import { DPNS_DATA_CONTRACT_BYTES, DPNS_DATA_CONTRACT_ID, LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
7
7
|
export default async function getByIdentifier(grpcPool, identifier) {
|
|
8
8
|
const id = new IdentifierWASM(identifier);
|
|
9
9
|
if (id.base58() === DPNS_DATA_CONTRACT_ID) {
|
|
@@ -31,7 +31,7 @@ export default async function getByIdentifier(grpcPool, identifier) {
|
|
|
31
31
|
if (metadata == null) {
|
|
32
32
|
throw new Error('Metadata not found');
|
|
33
33
|
}
|
|
34
|
-
const { rootHash, dataContract } = verifyContractProof(proof.grovedbProof, undefined, false, false, id.bytes(),
|
|
34
|
+
const { rootHash, dataContract } = verifyContractProof(proof.grovedbProof, undefined, false, false, id.bytes(), LATEST_PLATFORM_VERSION);
|
|
35
35
|
if (dataContract == null) {
|
|
36
36
|
throw new Error(`Data Contract with identifier ${id.base58()} not found`);
|
|
37
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataContractConfig, IdentifierLike } from '
|
|
2
|
-
import { DataContractWASM, PlatformVersionWASM, StateTransitionWASM
|
|
1
|
+
import { DataContractConfig, IdentifierLike } from '../../types.js';
|
|
2
|
+
import { DataContractTokens, DataContractWASM, PlatformVersionWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
3
3
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
4
|
/**
|
|
5
5
|
* Collection of methods necessary to work with Data Contracts in the network,
|
|
@@ -25,7 +25,7 @@ export declare class DataContractsController {
|
|
|
25
25
|
*
|
|
26
26
|
* @return {DataContractWASM}
|
|
27
27
|
*/
|
|
28
|
-
create(ownerId: IdentifierLike, identityNonce: bigint, schema: object, fullValidation?: boolean, tokenConfiguration?:
|
|
28
|
+
create(ownerId: IdentifierLike, identityNonce: bigint, schema: object, fullValidation?: boolean, tokenConfiguration?: DataContractTokens[], config?: DataContractConfig, platformVersion?: PlatformVersionWASM): DataContractWASM;
|
|
29
29
|
/**
|
|
30
30
|
* Retrieves a Data Contract by an identifier from the network
|
|
31
31
|
*
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DocumentWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentifierLike } from '
|
|
2
|
+
import { IdentifierLike } from '../../types.js';
|
|
3
3
|
export default function createDocument(dataContractId: IdentifierLike, documentType: string, data: object, owner: IdentifierLike, revision?: bigint, documentId?: IdentifierLike): DocumentWASM;
|
package/src/documents/create.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DocumentWASM } from 'pshenmic-dpp';
|
|
2
2
|
export default function createDocument(dataContractId, documentType, data, owner, revision, documentId) {
|
|
3
|
-
return new DocumentWASM(data, documentType, revision ?? BigInt(1), dataContractId, owner, documentId);
|
|
3
|
+
return new DocumentWASM(data, documentType, revision ?? BigInt(1), dataContractId, owner, documentId, owner);
|
|
4
4
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DocumentWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { DocumentTransitionParams } from '
|
|
2
|
+
import { DocumentTransitionParams } from '../../types.js';
|
|
3
3
|
export default function createStateTransition(document: DocumentWASM, type: 'create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase', params: DocumentTransitionParams): StateTransitionWASM;
|
package/src/documents/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DocumentTransitionParams, IdentifierLike } from '
|
|
2
|
-
import { DocumentWASM, IdentifierWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
1
|
+
import { DocumentTransitionParams, IdentifierLike } from '../../types.js';
|
|
2
|
+
import { DocumentWASM, IdentifierWASM, StateTransitionWASM, WhereClause } from 'pshenmic-dpp';
|
|
3
3
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
4
|
/**
|
|
5
5
|
* Collection of methods to work with documents like creation, querying or preparing a transition action
|
|
@@ -33,7 +33,7 @@ export declare class DocumentsController {
|
|
|
33
33
|
* @param startAt {IdentifierLike=} Optional offset, where startAt is an identifier of the document. Use identifier of last item in previous response
|
|
34
34
|
* @param startAfter {IdentifierLike=} Same as previous, but with exclusion. Cannot be set if startAt already provided
|
|
35
35
|
*/
|
|
36
|
-
query(dataContractId: IdentifierLike, documentType: string, where?:
|
|
36
|
+
query(dataContractId: IdentifierLike, documentType: string, where?: WhereClause[], orderBy?: string[][], limit?: number, startAt?: IdentifierWASM, startAfter?: IdentifierWASM): Promise<DocumentWASM[]>;
|
|
37
37
|
/**
|
|
38
38
|
* Helper function for creating {StateTransitionWASM} from documents. It may be used to create any of 6 Document Transition actions:
|
|
39
39
|
*
|
package/src/documents/query.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DocumentWASM, IdentifierWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentifierLike } from '
|
|
1
|
+
import { DocumentWASM, IdentifierWASM, WhereClause } from 'pshenmic-dpp';
|
|
2
|
+
import { IdentifierLike } from '../../types.js';
|
|
3
3
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
|
-
export default function query(grpcPool: GRPCConnectionPool, dataContractId: IdentifierLike, documentTypeName: string, where?:
|
|
4
|
+
export default function query(grpcPool: GRPCConnectionPool, dataContractId: IdentifierLike, documentTypeName: string, where?: WhereClause[], orderBy?: string[][], limit?: number | undefined, startAt?: IdentifierWASM, startAfter?: IdentifierWASM): Promise<DocumentWASM[]>;
|
package/src/documents/query.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetDocumentsRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import { IdentifierWASM,
|
|
3
|
-
import { DAPI_DEFAULT_LIMIT } from '../constants.js';
|
|
2
|
+
import { IdentifierWASM, verifyDocumentsProof } from 'pshenmic-dpp';
|
|
3
|
+
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';
|
|
@@ -52,7 +52,7 @@ export default async function query(grpcPool, dataContractId, documentTypeName,
|
|
|
52
52
|
throw new Error('Metadata not found');
|
|
53
53
|
}
|
|
54
54
|
const startAtIncluded = startAt != null;
|
|
55
|
-
const { rootHash, documents } = verifyDocumentsProof(proof.grovedbProof, dataContract, documentTypeName, where, orderBy, limit, startAt?.bytes(), startAtIncluded, BigInt(metadata?.timeMs),
|
|
55
|
+
const { rootHash, documents } = verifyDocumentsProof(proof.grovedbProof, dataContract, documentTypeName, where, orderBy, limit, startAt?.bytes(), startAtIncluded, BigInt(metadata?.timeMs), LATEST_PLATFORM_VERSION);
|
|
56
56
|
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
57
57
|
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
58
58
|
if (!verify) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StateTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentityTransitionParams } from '
|
|
2
|
+
import { IdentityTransitionParams } from '../../types.js';
|
|
3
3
|
export default function createStateTransition(type: 'create' | 'update' | 'topUp' | 'creditTransfer' | 'withdrawal', params: IdentityTransitionParams): StateTransitionWASM;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IdentifierLike } from '
|
|
1
|
+
import { IdentifierLike } from '../../types.js';
|
|
2
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
3
3
|
export default function getIdentityBalance(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<bigint>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetIdentityBalanceRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import { IdentifierWASM,
|
|
2
|
+
import { IdentifierWASM, verifyIdentityBalanceProof } from 'pshenmic-dpp';
|
|
3
3
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
4
4
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
5
|
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
6
7
|
export default async function getIdentityBalance(grpcPool, identifier) {
|
|
7
8
|
const id = new IdentifierWASM(identifier);
|
|
8
9
|
const getIdentityBalanceRequest = GetIdentityBalanceRequest.create({
|
|
@@ -27,7 +28,7 @@ export default async function getIdentityBalance(grpcPool, identifier) {
|
|
|
27
28
|
if (metadata == null) {
|
|
28
29
|
throw new Error('Metadata not found');
|
|
29
30
|
}
|
|
30
|
-
const { rootHash, balance } = verifyIdentityBalanceProof(proof.grovedbProof, id.bytes(), true,
|
|
31
|
+
const { rootHash, balance } = verifyIdentityBalanceProof(proof.grovedbProof, id.bytes(), true, LATEST_PLATFORM_VERSION);
|
|
31
32
|
if (balance == null) {
|
|
32
33
|
throw new Error(`Failed to fetch balance for identifier ${id.base58()}`);
|
|
33
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IdentityWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentifierLike } from '
|
|
2
|
+
import { IdentifierLike } from '../../types.js';
|
|
3
3
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
4
|
export default function getIdentityByIdentifier(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<IdentityWASM>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetIdentityRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import { IdentifierWASM,
|
|
2
|
+
import { IdentifierWASM, verifyIdentityByIdentifierProof } from 'pshenmic-dpp';
|
|
3
3
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
4
|
import bytesToHex from '../utils/bytesToHex.js';
|
|
5
5
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
6
7
|
export default async function getIdentityByIdentifier(grpcPool, identifier) {
|
|
7
8
|
const id = new IdentifierWASM(identifier);
|
|
8
9
|
const getIdentityRequest = GetIdentityRequest.create({
|
|
@@ -27,7 +28,7 @@ export default async function getIdentityByIdentifier(grpcPool, identifier) {
|
|
|
27
28
|
if (metadata == null) {
|
|
28
29
|
throw new Error('Metadata not found');
|
|
29
30
|
}
|
|
30
|
-
const { rootHash, identity } = verifyIdentityByIdentifierProof(proof.grovedbProof, id, true,
|
|
31
|
+
const { rootHash, identity } = verifyIdentityByIdentifierProof(proof.grovedbProof, id, true, LATEST_PLATFORM_VERSION);
|
|
31
32
|
if (identity == null) {
|
|
32
33
|
throw new Error(`Identity with identifier ${id.base58()} not found`);
|
|
33
34
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { GetIdentityByNonUniquePublicKeyHashRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import {
|
|
2
|
+
import { verifyIdentifierByNonUniquePublicKeyHashProof } from 'pshenmic-dpp';
|
|
3
3
|
import hexToBytes from '../utils/hexToBytes.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
7
|
import getIdentityByIdentifier from './getIdentityByIdentifier.js';
|
|
8
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
8
9
|
export default async function getIdentityByNonUniquePublicKeyHash(grpcPool, hex) {
|
|
9
10
|
const getIdentityByNonUniquePublicKeyHashRequest = GetIdentityByNonUniquePublicKeyHashRequest.create({
|
|
10
11
|
version: {
|
|
@@ -31,7 +32,7 @@ export default async function getIdentityByNonUniquePublicKeyHash(grpcPool, hex)
|
|
|
31
32
|
if (proof.grovedbIdentityPublicKeyHashProof == null) {
|
|
32
33
|
throw new Error('GroveDB proof not found for identity by non unique public key request');
|
|
33
34
|
}
|
|
34
|
-
const { rootHash, identifier } = verifyIdentifierByNonUniquePublicKeyHashProof(proof.grovedbIdentityPublicKeyHashProof.grovedbProof, false, hexToBytes(hex), undefined,
|
|
35
|
+
const { rootHash, identifier } = verifyIdentifierByNonUniquePublicKeyHashProof(proof.grovedbIdentityPublicKeyHashProof.grovedbProof, false, hexToBytes(hex), undefined, LATEST_PLATFORM_VERSION);
|
|
35
36
|
if (identifier == null) {
|
|
36
37
|
throw new Error(`Identity with non unique public key hash ${hex} not found`);
|
|
37
38
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { GetIdentityByPublicKeyHashRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import {
|
|
2
|
+
import { verifyIdentityByUniqueKeyHashProof } from 'pshenmic-dpp';
|
|
3
3
|
import hexToBytes from '../utils/hexToBytes.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 { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
7
8
|
export default async function getIdentityByPublicKeyHash(grpcPool, hex) {
|
|
8
9
|
const getIdentityByPublicKeyHashRequest = GetIdentityByPublicKeyHashRequest.create({
|
|
9
10
|
version: {
|
|
@@ -27,7 +28,7 @@ export default async function getIdentityByPublicKeyHash(grpcPool, hex) {
|
|
|
27
28
|
if (metadata == null) {
|
|
28
29
|
throw new Error('Metadata not found');
|
|
29
30
|
}
|
|
30
|
-
const { rootHash, identity } = verifyIdentityByUniqueKeyHashProof(proof.grovedbProof, hexToBytes(hex),
|
|
31
|
+
const { rootHash, identity } = verifyIdentityByUniqueKeyHashProof(proof.grovedbProof, hexToBytes(hex), LATEST_PLATFORM_VERSION);
|
|
31
32
|
if (identity == null) {
|
|
32
33
|
throw new Error(`Identity with public key hash ${hex} not found`);
|
|
33
34
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IdentifierLike } from '
|
|
1
|
+
import { IdentifierLike } from '../../types.js';
|
|
2
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
3
3
|
export default function getIdentityContractNonce(grpcPool: GRPCConnectionPool, identity: IdentifierLike, dataContract: IdentifierLike): Promise<bigint>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetIdentityContractNonceRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import { IdentifierWASM,
|
|
2
|
+
import { IdentifierWASM, verifyIdentityContractNonceProof } from 'pshenmic-dpp';
|
|
3
3
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
4
|
import bytesToHex from '../utils/bytesToHex.js';
|
|
5
5
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
6
7
|
const IDENTITY_CONTRACT_NONCE_VALUE_FILTER = BigInt(0xFFFFFFFFFF);
|
|
7
8
|
export default async function getIdentityContractNonce(grpcPool, identity, dataContract) {
|
|
8
9
|
const identityIdentifier = new IdentifierWASM(identity);
|
|
@@ -30,7 +31,7 @@ export default async function getIdentityContractNonce(grpcPool, identity, dataC
|
|
|
30
31
|
if (metadata == null) {
|
|
31
32
|
throw new Error('Metadata not found');
|
|
32
33
|
}
|
|
33
|
-
const { rootHash, contractNonce } = verifyIdentityContractNonceProof(proof.grovedbProof, identityIdentifier.bytes(), dataContractIdentifier.bytes(), true,
|
|
34
|
+
const { rootHash, contractNonce } = verifyIdentityContractNonceProof(proof.grovedbProof, identityIdentifier.bytes(), dataContractIdentifier.bytes(), true, LATEST_PLATFORM_VERSION);
|
|
34
35
|
if (contractNonce == null) {
|
|
35
36
|
return BigInt(0);
|
|
36
37
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IdentifierLike } from '
|
|
1
|
+
import { IdentifierLike } from '../../types.js';
|
|
2
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
3
3
|
export default function getIdentityNonce(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<bigint>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetIdentityNonceRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import { IdentifierWASM,
|
|
2
|
+
import { IdentifierWASM, verifyIdentityNonceProof } from 'pshenmic-dpp';
|
|
3
3
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
4
|
import bytesToHex from '../utils/bytesToHex.js';
|
|
5
5
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
6
7
|
const IDENTITY_NONCE_VALUE_FILTER = BigInt(0xFFFFFFFFFF);
|
|
7
8
|
export default async function getIdentityNonce(grpcPool, identifier) {
|
|
8
9
|
const id = new IdentifierWASM(identifier);
|
|
@@ -28,7 +29,7 @@ export default async function getIdentityNonce(grpcPool, identifier) {
|
|
|
28
29
|
if (metadata == null) {
|
|
29
30
|
throw new Error('Metadata not found');
|
|
30
31
|
}
|
|
31
|
-
const { rootHash, nonce } = verifyIdentityNonceProof(proof.grovedbProof, id.bytes(), true,
|
|
32
|
+
const { rootHash, nonce } = verifyIdentityNonceProof(proof.grovedbProof, id.bytes(), true, LATEST_PLATFORM_VERSION);
|
|
32
33
|
if (nonce == null) {
|
|
33
34
|
return BigInt(0);
|
|
34
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IdentityPublicKeyWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentifierLike } from '
|
|
2
|
+
import { IdentifierLike } from '../../types.js';
|
|
3
3
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
|
-
export default function getIdentityPublicKeys(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<IdentityPublicKeyWASM[]>;
|
|
4
|
+
export default function getIdentityPublicKeys(grpcPool: GRPCConnectionPool, identifier: IdentifierLike, keyIds?: number[]): Promise<IdentityPublicKeyWASM[]>;
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
import { GetIdentityKeysRequest, KeyRequestType } from '../../proto/generated/platform.js';
|
|
2
|
-
import { IdentifierWASM,
|
|
2
|
+
import { IdentifierWASM, verifyIdentityKeysByIdentifierProof } from 'pshenmic-dpp';
|
|
3
3
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
4
|
import bytesToHex from '../utils/bytesToHex.js';
|
|
5
5
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
|
-
|
|
6
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
7
|
+
export default async function getIdentityPublicKeys(grpcPool, identifier, keyIds) {
|
|
7
8
|
const id = new IdentifierWASM(identifier);
|
|
9
|
+
let requestType = {
|
|
10
|
+
request: {
|
|
11
|
+
oneofKind: 'allKeys',
|
|
12
|
+
allKeys: {}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
if (keyIds != null) {
|
|
16
|
+
requestType = {
|
|
17
|
+
request: {
|
|
18
|
+
oneofKind: 'specificKeys',
|
|
19
|
+
specificKeys: { keyIds }
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
8
23
|
const getIdentityKeysRequest = GetIdentityKeysRequest.create({
|
|
9
24
|
version: {
|
|
10
25
|
oneofKind: 'v0',
|
|
11
26
|
v0: {
|
|
12
27
|
identityId: id.bytes(),
|
|
13
|
-
requestType: KeyRequestType.create(
|
|
14
|
-
request: {
|
|
15
|
-
oneofKind: 'allKeys',
|
|
16
|
-
allKeys: {}
|
|
17
|
-
}
|
|
18
|
-
}),
|
|
28
|
+
requestType: KeyRequestType.create(requestType),
|
|
19
29
|
prove: true
|
|
20
30
|
}
|
|
21
31
|
}
|
|
@@ -33,7 +43,7 @@ export default async function getIdentityPublicKeys(grpcPool, identifier) {
|
|
|
33
43
|
if (metadata == null) {
|
|
34
44
|
throw new Error('Metadata not found');
|
|
35
45
|
}
|
|
36
|
-
const { rootHash, identity } = verifyIdentityKeysByIdentifierProof(proof.grovedbProof, id.bytes(), null, false, false, true, null, null,
|
|
46
|
+
const { rootHash, identity } = verifyIdentityKeysByIdentifierProof(proof.grovedbProof, id.bytes(), keyIds != null ? keyIds : null, false, false, true, null, null, LATEST_PLATFORM_VERSION);
|
|
37
47
|
if (identity == null) {
|
|
38
48
|
throw new Error(`Identity with identifier ${id.base58()} not found`);
|
|
39
49
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IdentifierLike, IdentityTransitionParams } from '
|
|
1
|
+
import { IdentifierLike, IdentityTransitionParams } from '../../types.js';
|
|
2
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
3
3
|
import { IdentityPublicKeyWASM, IdentityWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
4
4
|
/**
|
|
@@ -56,11 +56,12 @@ export declare class IdentitiesController {
|
|
|
56
56
|
getIdentityContractNonce(identifier: IdentifierLike, dataContract: IdentifierLike): Promise<bigint>;
|
|
57
57
|
/**
|
|
58
58
|
* Retrieve given Identity's public keys
|
|
59
|
-
* @param identifier
|
|
59
|
+
* @param identifier {IdentifierLike}
|
|
60
|
+
* @param keyIds {=number[]} optional, specific keyIds to request
|
|
60
61
|
*
|
|
61
62
|
* @return {Promise<IdentityPublicKeyWASM[]>}
|
|
62
63
|
*/
|
|
63
|
-
getIdentityPublicKeys(identifier: IdentifierLike): Promise<IdentityPublicKeyWASM[]>;
|
|
64
|
+
getIdentityPublicKeys(identifier: IdentifierLike, keyIds?: number[]): Promise<IdentityPublicKeyWASM[]>;
|
|
64
65
|
/**
|
|
65
66
|
* Helper function for creating {StateTransitionWASM} for Identity transitions
|
|
66
67
|
*
|
package/src/identities/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import getIdentityNonce from './getIdentityNonce.js';
|
|
|
4
4
|
import getIdentityBalance from './getIdentityBalance.js';
|
|
5
5
|
import getIdentityByPublicKeyHash from './getIdentityByPublicKeyHash.js';
|
|
6
6
|
import getIdentityByIdentifier from './getIdentityByIdentifier.js';
|
|
7
|
-
import { AssetLockProofWASM, ContractBoundsWASM, CoreScriptWASM, IdentifierWASM, IdentityPublicKeyInCreationWASM, OutPointWASM
|
|
7
|
+
import { AssetLockProofWASM, ContractBoundsWASM, CoreScriptWASM, IdentifierWASM, IdentityPublicKeyInCreationWASM, OutPointWASM } from 'pshenmic-dpp';
|
|
8
8
|
import createStateTransition from './createStateTransition.js';
|
|
9
9
|
import getIdentityByNonUniquePublicKeyHash from './getIdentityByNonUniquePublicKeyHash.js';
|
|
10
10
|
import hexToBytes from '../utils/hexToBytes.js';
|
|
@@ -84,12 +84,13 @@ export class IdentitiesController {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Retrieve given Identity's public keys
|
|
87
|
-
* @param identifier
|
|
87
|
+
* @param identifier {IdentifierLike}
|
|
88
|
+
* @param keyIds {=number[]} optional, specific keyIds to request
|
|
88
89
|
*
|
|
89
90
|
* @return {Promise<IdentityPublicKeyWASM[]>}
|
|
90
91
|
*/
|
|
91
|
-
async getIdentityPublicKeys(identifier) {
|
|
92
|
-
return await getIdentityPublicKeys(this.grpcPool, identifier);
|
|
92
|
+
async getIdentityPublicKeys(identifier, keyIds) {
|
|
93
|
+
return await getIdentityPublicKeys(this.grpcPool, identifier, keyIds);
|
|
93
94
|
}
|
|
94
95
|
/**
|
|
95
96
|
* Helper function for creating {StateTransitionWASM} for Identity transitions
|
|
@@ -143,8 +144,7 @@ export class IdentitiesController {
|
|
|
143
144
|
params.recipientId = new IdentifierWASM(params.recipientId);
|
|
144
145
|
}
|
|
145
146
|
if (type === 'withdrawal') {
|
|
146
|
-
|
|
147
|
-
params.pooling = params.pooling != null ? PoolingWASM[params.pooling] : PoolingWASM.Standard;
|
|
147
|
+
params.pooling = params.pooling ?? 'Standard';
|
|
148
148
|
params.coreFeePerByte = params.coreFeePerByte ?? 1;
|
|
149
149
|
params.outputScript = params.outputScript ?? (params.withdrawalAddress != null ? CoreScriptWASM.newP2PKH(base58.decode(params.withdrawalAddress).slice(1, 21)) : undefined);
|
|
150
150
|
}
|
package/src/keyPair/index.d.ts
CHANGED
package/src/names/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
2
|
import { DocumentWASM, PrivateKeyWASM } from 'pshenmic-dpp';
|
|
3
|
-
import { IdentifierLike } from '
|
|
3
|
+
import { IdentifierLike } from '../../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Functions related to DPNS names (usernames)
|
|
6
6
|
*
|
package/src/node/epochs.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { GetEpochsInfoRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import {
|
|
2
|
+
import { verifyEpochsInfoProof } from 'pshenmic-dpp';
|
|
3
3
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
4
|
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
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
7
8
|
export default async function epochs(grpcPool, count, ascending, start) {
|
|
8
9
|
const getEpochsInfoRequest = GetEpochsInfoRequest.create({
|
|
9
10
|
version: {
|
|
@@ -29,7 +30,7 @@ export default async function epochs(grpcPool, count, ascending, start) {
|
|
|
29
30
|
if (metadata == null) {
|
|
30
31
|
throw new Error('Metadata not found');
|
|
31
32
|
}
|
|
32
|
-
const { rootHash, epochsInfo } = verifyEpochsInfoProof(proof.grovedbProof, metadata.epoch, start, count, ascending,
|
|
33
|
+
const { rootHash, epochsInfo } = verifyEpochsInfoProof(proof.grovedbProof, metadata.epoch, start, count, ascending, LATEST_PLATFORM_VERSION);
|
|
33
34
|
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
34
35
|
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
35
36
|
if (!verify) {
|
package/src/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
import { Network, NodeStatus } from '
|
|
2
|
+
import { Network, NodeStatus } from '../../types.js';
|
|
3
3
|
import { EpochInfo } from './epochs.js';
|
|
4
4
|
/**
|
|
5
5
|
* Node controller for requesting information about DAPI node
|
package/src/node/status.d.ts
CHANGED
package/src/node/totalCredits.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetTotalCreditsInPlatformRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import { HALVING_INTERVAL, MAINNET_ACTIVATION_HEIGHT, TESTNET_ACTIVATION_HEIGHT } from '../constants.js';
|
|
3
|
-
import {
|
|
2
|
+
import { HALVING_INTERVAL, LATEST_PLATFORM_VERSION, MAINNET_ACTIVATION_HEIGHT, TESTNET_ACTIVATION_HEIGHT } from '../constants.js';
|
|
3
|
+
import { verifyTotalCreditsProof } from 'pshenmic-dpp';
|
|
4
4
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
5
|
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
6
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
@@ -25,7 +25,7 @@ export default async function totalCredits(grpcPool, network) {
|
|
|
25
25
|
throw new Error('Metadata not found');
|
|
26
26
|
}
|
|
27
27
|
const activationHeight = network === 'testnet' ? TESTNET_ACTIVATION_HEIGHT : MAINNET_ACTIVATION_HEIGHT;
|
|
28
|
-
const { rootHash, totalCredits } = verifyTotalCreditsProof(proof.grovedbProof, HALVING_INTERVAL, activationHeight, Number(metadata.height),
|
|
28
|
+
const { rootHash, totalCredits } = verifyTotalCreditsProof(proof.grovedbProof, HALVING_INTERVAL, activationHeight, Number(metadata.height), LATEST_PLATFORM_VERSION);
|
|
29
29
|
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
30
30
|
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
31
31
|
if (!verify) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BroadcastStateTransitionRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
export default async function broadcast(grpcPool, stateTransition) {
|
|
3
|
-
if (stateTransition.signature
|
|
3
|
+
if (stateTransition.signature?.length === 0) {
|
|
4
4
|
throw new Error('State Transition is not signed');
|
|
5
5
|
}
|
|
6
6
|
const broadcastStateTransitionRequest = BroadcastStateTransitionRequest.create({
|
|
@@ -1,8 +1,71 @@
|
|
|
1
|
+
import { BatchTransitionWASM, MasternodeVoteTransitionWASM, verifyStateTransitionResult } from 'pshenmic-dpp';
|
|
2
|
+
import hexToBytes from '../utils/hexToBytes.js';
|
|
3
|
+
import { WaitForStateTransitionResultRequest } from '../../proto/generated/platform.js';
|
|
4
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
7
|
+
import { base64 } from '@scure/base';
|
|
8
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
9
|
+
import getDataContractByIdentifier from '../dataContracts/getDataContractByIdentifier.js';
|
|
1
10
|
export default async function waitForStateTransitionResult(grpcPool, stateTransition) {
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
const txHash = stateTransition.hash(false);
|
|
12
|
+
const waitForStateTransitionResultRequest = WaitForStateTransitionResultRequest.create({
|
|
13
|
+
version: {
|
|
14
|
+
oneofKind: 'v0',
|
|
15
|
+
v0: {
|
|
16
|
+
stateTransitionHash: hexToBytes(txHash),
|
|
17
|
+
prove: true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const { response } = await grpcPool.getClient().waitForStateTransitionResult(waitForStateTransitionResultRequest);
|
|
22
|
+
const { version } = response;
|
|
23
|
+
if (version.oneofKind !== 'v0') {
|
|
24
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
25
|
+
}
|
|
26
|
+
const { v0 } = version;
|
|
27
|
+
if (v0.result.oneofKind !== 'proof' && v0.result.oneofKind !== 'error') {
|
|
28
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
|
|
29
|
+
}
|
|
30
|
+
if (v0.result.oneofKind === 'proof') {
|
|
31
|
+
const { result: { proof }, metadata } = v0;
|
|
32
|
+
if (metadata == null) {
|
|
33
|
+
throw new Error('Metadata not found');
|
|
34
|
+
}
|
|
35
|
+
const { timeMs, height, coreChainLockedHeight, epoch } = metadata;
|
|
36
|
+
const knownContracts = [];
|
|
37
|
+
if (stateTransition.getActionType() === 'BATCH') {
|
|
38
|
+
const batchTransition = BatchTransitionWASM.fromStateTransition(stateTransition);
|
|
39
|
+
const [transition] = batchTransition.transitions;
|
|
40
|
+
const dataContract = await getDataContractByIdentifier(grpcPool, transition.dataContractId);
|
|
41
|
+
knownContracts.push(dataContract);
|
|
42
|
+
}
|
|
43
|
+
if (stateTransition.getActionType() === 'MASTERNODE_VOTE') {
|
|
44
|
+
const masternodeVote = MasternodeVoteTransitionWASM.fromStateTransition(stateTransition);
|
|
45
|
+
const dataContract = await getDataContractByIdentifier(grpcPool, masternodeVote.vote.votePoll.contractId);
|
|
46
|
+
knownContracts.push(dataContract);
|
|
47
|
+
}
|
|
48
|
+
const blockInfo = {
|
|
49
|
+
timeMs: BigInt(timeMs),
|
|
50
|
+
height: BigInt(height),
|
|
51
|
+
coreHeight: coreChainLockedHeight,
|
|
52
|
+
epoch
|
|
53
|
+
};
|
|
54
|
+
const { rootHash, result } = verifyStateTransitionResult(proof.grovedbProof, stateTransition, blockInfo, knownContracts, LATEST_PLATFORM_VERSION);
|
|
55
|
+
if (result == null) {
|
|
56
|
+
throw new Error('State transition result was null');
|
|
57
|
+
}
|
|
58
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
59
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
60
|
+
if (!verify) {
|
|
61
|
+
throw new Error('Failed to verify wait for state transition result query');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (v0.result.oneofKind === 'error') {
|
|
65
|
+
const { code, message, data } = v0.result.error;
|
|
66
|
+
throw new Error(`State transition ${txHash} failed to execute with code ${String(code)}, message: ${String(message)}, data: ${base64.encode(data)}`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error('Unexpected oneOfKind returned for waitForStateTransitionResult');
|
|
7
70
|
}
|
|
8
71
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IdentifierWASM, StateTransitionWASM, TokenBaseTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { TokenTransitionParams, TokenTransitionType } from '
|
|
2
|
+
import { TokenTransitionParams, TokenTransitionType } from '../../types.js';
|
|
3
3
|
export default function createStateTransition(base: TokenBaseTransitionWASM, ownerId: IdentifierWASM, type: TokenTransitionType, params: TokenTransitionParams): StateTransitionWASM;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
import { IdentifierLike } from '
|
|
2
|
+
import { IdentifierLike } from '../../types.js';
|
|
3
3
|
import { IdentifierWASM } from 'pshenmic-dpp';
|
|
4
4
|
export interface IdentitiesTokenBalances {
|
|
5
5
|
identityId: IdentifierWASM;
|
|
6
|
-
balance?:
|
|
6
|
+
balance?: bigint | undefined;
|
|
7
7
|
}
|
|
8
8
|
export default function getIdentitiesTokenBalances(grpcPool: GRPCConnectionPool, identifiers: IdentifierLike[], tokenIdentifier: IdentifierLike): Promise<IdentitiesTokenBalances[]>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetIdentitiesTokenBalancesRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import { IdentifierWASM,
|
|
2
|
+
import { IdentifierWASM, verifyTokenBalancesForIdentitiesProof } from 'pshenmic-dpp';
|
|
3
3
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
4
|
import bytesToHex from '../utils/bytesToHex.js';
|
|
5
5
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
6
7
|
export default async function getIdentitiesTokenBalances(grpcPool, identifiers, tokenIdentifier) {
|
|
7
8
|
const ids = identifiers.map(identifier => new IdentifierWASM(identifier));
|
|
8
9
|
const tokenId = new IdentifierWASM(tokenIdentifier);
|
|
@@ -29,15 +30,15 @@ export default async function getIdentitiesTokenBalances(grpcPool, identifiers,
|
|
|
29
30
|
if (metadata == null) {
|
|
30
31
|
throw new Error('Metadata not found');
|
|
31
32
|
}
|
|
32
|
-
const { rootHash, balances } = verifyTokenBalancesForIdentitiesProof(proof.grovedbProof, tokenId, true, ids,
|
|
33
|
+
const { rootHash, balances } = verifyTokenBalancesForIdentitiesProof(proof.grovedbProof, tokenId, true, ids, LATEST_PLATFORM_VERSION);
|
|
33
34
|
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
34
35
|
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
35
36
|
if (!verify) {
|
|
36
37
|
throw new Error('Failed to verify query');
|
|
37
38
|
}
|
|
38
39
|
return balances
|
|
39
|
-
.map((
|
|
40
|
-
identityId: new IdentifierWASM(
|
|
41
|
-
balance
|
|
40
|
+
.map(({ id, balance }) => ({
|
|
41
|
+
identityId: new IdentifierWASM(id),
|
|
42
|
+
balance
|
|
42
43
|
}));
|
|
43
44
|
}
|