dash-platform-sdk 1.3.0-dev.9 → 1.3.1
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 +4 -3
- 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 +2 -0
- package/src/contestedResources/getContestedResourceVoteState.d.ts +1 -1
- package/src/contestedResources/getContestedResourceVoteState.js +6 -4
- package/src/contestedResources/index.d.ts +1 -1
- package/src/dataContracts/create.d.ts +1 -1
- package/src/dataContracts/create.js +3 -2
- package/src/dataContracts/getDataContractByIdentifier.d.ts +1 -1
- package/src/dataContracts/getDataContractByIdentifier.js +3 -3
- package/src/dataContracts/index.d.ts +1 -1
- 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 +1 -1
- package/src/documents/query.d.ts +1 -1
- 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 +4 -3
- 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 +17 -6
- package/src/stateTransitions/waitForStateTransitionResult.js +62 -5
- package/src/tokens/createStateTransition.d.ts +1 -1
- package/src/tokens/getIdentitiesTokenBalances.d.ts +1 -1
- package/src/tokens/getIdentitiesTokenBalances.js +3 -2
- package/src/tokens/getIdentityTokensBalances.d.ts +1 -1
- package/src/tokens/getIdentityTokensBalances.js +3 -2
- 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/deserializeConsensusError.d.ts +1 -0
- package/src/utils/deserializeConsensusError.js +17 -0
- package/src/utils/getEvonodeList.d.ts +1 -1
- package/src/utils/index.d.ts +15 -0
- package/src/utils/index.js +27 -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/Identity.spec.js +1 -1
- package/test/unit/Names.spec.js +4 -2
- package/test/unit/SDK.spec.js +4 -0
- package/{src/types.d.ts → types.d.ts} +4 -3
- 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,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,4 +1,4 @@
|
|
|
1
|
-
import { DocumentTransitionParams, IdentifierLike } from '
|
|
1
|
+
import { DocumentTransitionParams, IdentifierLike } from '../../types.js';
|
|
2
2
|
import { DocumentWASM, IdentifierWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
3
3
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
4
|
/**
|
package/src/documents/query.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DocumentWASM, IdentifierWASM } 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 query(grpcPool: GRPCConnectionPool, dataContractId: IdentifierLike, documentTypeName: string, where?: ArrayLike<any>, orderBy?: ArrayLike<any>, 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
|
@@ -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
|
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,10 +1,21 @@
|
|
|
1
1
|
import { BroadcastStateTransitionRequest } from '../../proto/generated/platform.js';
|
|
2
|
+
import { deserializeConsensusError } from '../utils/deserializeConsensusError.js';
|
|
2
3
|
export default async function broadcast(grpcPool, stateTransition) {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
try {
|
|
5
|
+
if (stateTransition.signature?.length === 0) {
|
|
6
|
+
throw new Error('State Transition is not signed');
|
|
7
|
+
}
|
|
8
|
+
const broadcastStateTransitionRequest = BroadcastStateTransitionRequest.create({
|
|
9
|
+
stateTransition: stateTransition.bytes()
|
|
10
|
+
});
|
|
11
|
+
await grpcPool.getClient().broadcastStateTransition(broadcastStateTransitionRequest);
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
if (err.meta?.['dash-serialized-consensus-error-bin']?.length !== 0) {
|
|
15
|
+
throw new Error(deserializeConsensusError(err.meta['dash-serialized-consensus-error-bin']));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
throw err;
|
|
19
|
+
}
|
|
5
20
|
}
|
|
6
|
-
const broadcastStateTransitionRequest = BroadcastStateTransitionRequest.create({
|
|
7
|
-
stateTransition: stateTransition.bytes()
|
|
8
|
-
});
|
|
9
|
-
await grpcPool.getClient().broadcastStateTransition(broadcastStateTransitionRequest);
|
|
10
21
|
}
|
|
@@ -1,8 +1,65 @@
|
|
|
1
|
+
import { BatchTransitionWASM, BlockInfoWASM, 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 { rootHash, result } = verifyStateTransitionResult(proof.grovedbProof, stateTransition, new BlockInfoWASM(BigInt(timeMs), BigInt(height), coreChainLockedHeight, epoch), knownContracts, LATEST_PLATFORM_VERSION);
|
|
49
|
+
if (result == null) {
|
|
50
|
+
throw new Error('State transition result was null');
|
|
51
|
+
}
|
|
52
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
53
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
54
|
+
if (!verify) {
|
|
55
|
+
throw new Error('Failed to verify wait for state transition result query');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (v0.result.oneofKind === 'error') {
|
|
59
|
+
const { code, message, data } = v0.result.error;
|
|
60
|
+
throw new Error(`State transition ${txHash} failed to execute with code ${String(code)}, message: ${String(message)}, data: ${base64.encode(data)}`);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error('Unexpected oneOfKind returned for waitForStateTransitionResult');
|
|
7
64
|
}
|
|
8
65
|
}
|
|
@@ -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,5 +1,5 @@
|
|
|
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;
|
|
@@ -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,7 +30,7 @@ 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) {
|
|
@@ -1,5 +1,5 @@
|
|
|
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 IdentityTokenBalances {
|
|
5
5
|
tokenId: IdentifierWASM;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { IdentifierWASM,
|
|
1
|
+
import { IdentifierWASM, verifyTokensBalancesForIdentityProof } from 'pshenmic-dpp';
|
|
2
2
|
import { GetIdentityTokenBalancesRequest } 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 { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
6
7
|
export default async function getIdentityTokensBalances(grpcPool, identifier, tokenIdentifiers) {
|
|
7
8
|
const id = new IdentifierWASM(identifier);
|
|
8
9
|
const tokenIds = tokenIdentifiers.map(tokenIdentifier => new IdentifierWASM(tokenIdentifier));
|
|
@@ -29,7 +30,7 @@ export default async function getIdentityTokensBalances(grpcPool, identifier, to
|
|
|
29
30
|
if (metadata == null) {
|
|
30
31
|
throw new Error('Metadata not found');
|
|
31
32
|
}
|
|
32
|
-
const { rootHash, balances } = verifyTokensBalancesForIdentityProof(proof.grovedbProof, tokenIds, id, true,
|
|
33
|
+
const { rootHash, balances } = verifyTokensBalancesForIdentityProof(proof.grovedbProof, tokenIds, id, true, 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) {
|
|
@@ -1,5 +1,5 @@
|
|
|
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 TokenContractInfo {
|
|
5
5
|
dataContractId: IdentifierWASM;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetTokenContractInfoRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import { IdentifierWASM,
|
|
2
|
+
import { IdentifierWASM, verifyTokenContractInfoProof } 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 getTokenContractInfo(grpcPool, tokenIdentifier) {
|
|
7
8
|
const tokenId = new IdentifierWASM(tokenIdentifier);
|
|
8
9
|
const getTokenContractInfoRequest = GetTokenContractInfoRequest.create({
|
|
@@ -27,7 +28,7 @@ export default async function getTokenContractInfo(grpcPool, tokenIdentifier) {
|
|
|
27
28
|
if (metadata == null) {
|
|
28
29
|
throw new Error('Metadata not found');
|
|
29
30
|
}
|
|
30
|
-
const { rootHash, contractInfo } = verifyTokenContractInfoProof(proof.grovedbProof, tokenId, true,
|
|
31
|
+
const { rootHash, contractInfo } = verifyTokenContractInfoProof(proof.grovedbProof, tokenId, true, LATEST_PLATFORM_VERSION);
|
|
31
32
|
if (contractInfo == null) {
|
|
32
33
|
throw new Error('ContractInfo not found');
|
|
33
34
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
import { IdentifierLike, TokenDirectPurchasePrices } from '
|
|
2
|
+
import { IdentifierLike, TokenDirectPurchasePrices } from '../../types.js';
|
|
3
3
|
export default function getTokenDirectPurchasePrices(grpcPool: GRPCConnectionPool, tokenIdentifiers: IdentifierLike[]): Promise<TokenDirectPurchasePrices[]>;
|