dash-platform-sdk 1.6.0-dev.6 → 1.6.0-dev.8
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 +14 -14
- package/bundle.min.js +1 -1
- package/package.json +1 -1
- package/src/QueryExecutor.d.ts +40 -4
- package/src/QueryExecutor.js +61 -8
- package/src/constants.d.ts +7 -1
- package/src/constants.js +9 -2
- package/src/contestedResources/getContestedResourceVoteState.js +14 -6
- package/src/contestedResources/getVotePollsByEndDate.js +7 -2
- package/src/dataContracts/getDataContractByIdentifier.js +3 -3
- package/src/documents/index.d.ts +4 -1
- package/src/documents/index.js +6 -2
- package/src/documents/query.js +4 -4
- package/src/documents/queryAggregate.js +2 -3
- package/src/documents/queryJoined.js +6 -7
- package/src/documents/queryRanked.js +2 -3
- package/src/documents/v1.d.ts +2 -2
- package/src/documents/v1.js +2 -3
- package/src/grpcConnectionPool.d.ts +9 -2
- package/src/grpcConnectionPool.js +7 -8
- package/src/identities/getIdentityBalance.js +1 -2
- package/src/identities/getIdentityByIdentifier.js +1 -2
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +2 -3
- package/src/identities/getIdentityByPublicKeyHash.js +1 -2
- package/src/identities/getIdentityContractNonce.js +1 -2
- package/src/identities/getIdentityNonce.js +1 -2
- package/src/identities/getIdentityPublicKeys.js +1 -2
- package/src/names/index.d.ts +1 -1
- package/src/names/index.js +1 -1
- package/src/names/registerName.js +5 -2
- package/src/node/epochInfos.js +1 -2
- package/src/node/finalizedEpochInfos.js +1 -2
- package/src/node/getProtocolVersion.d.ts +9 -0
- package/src/node/getProtocolVersion.js +29 -0
- package/src/node/index.d.ts +9 -0
- package/src/node/index.js +11 -0
- package/src/node/totalCredits.js +3 -3
- package/src/platformAddresses/getAddressInfo.js +1 -2
- package/src/platformAddresses/getAddressesBranchState.js +1 -2
- package/src/platformAddresses/getAddressesInfos.js +1 -2
- package/src/platformAddresses/getAddressesTrunkState.js +1 -2
- package/src/platformAddresses/getRecentAddressBalanceChanges.js +2 -2
- package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.js +2 -2
- package/src/shielded/getMostRecentShieldedAnchor.js +1 -2
- package/src/shielded/getShieldedAnchors.js +1 -2
- package/src/shielded/getShieldedEncryptedNotes.js +2 -2
- package/src/shielded/getShieldedNotesCount.js +1 -2
- package/src/shielded/getShieldedNullifiers.js +1 -2
- package/src/shielded/getShieldedPoolState.js +1 -2
- package/src/stateTransitions/waitForStateTransitionResult.js +14 -12
- package/src/tokens/getIdentitiesTokenBalances.js +1 -2
- package/src/tokens/getIdentityTokensBalances.js +1 -2
- package/src/tokens/getTokenContractInfo.js +1 -2
- package/src/tokens/getTokenDirectPurchasePrices.js +1 -2
- package/src/tokens/getTokenTotalSupply.js +1 -2
- package/test/unit/SDK.spec.js +38 -0
|
@@ -3,7 +3,7 @@ import { PlatformClient } from '../proto/generated/platform.client.js';
|
|
|
3
3
|
import { GetStatusRequest } from '../proto/generated/platform.js';
|
|
4
4
|
import getCurrentQuorumsInfo from './node/getCurrentQuorumsInfo.js';
|
|
5
5
|
import { fetchWithDetails } from './utils/fetchWithDetails.js';
|
|
6
|
-
import { LATEST_PLATFORM_VERSION } from './constants.js';
|
|
6
|
+
import { LATEST_PLATFORM_VERSION, MIN_PROTOCOL_VERSION } from './constants.js';
|
|
7
7
|
import sleep from './utils/sleep.js';
|
|
8
8
|
const GRPC_DEFAULT_POOL_LIMIT = 15;
|
|
9
9
|
const GRPC_DEFAULT_CONNECT_RETRIES = 5;
|
|
@@ -106,12 +106,8 @@ const isNodeHealthy = async (url, minProtocolVersion) => {
|
|
|
106
106
|
if (protocol == null) {
|
|
107
107
|
return false;
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
else if (protocol.current < minProtocolVersion || protocol.current > Number(LATEST_PLATFORM_VERSION)) {
|
|
109
|
+
// the protocol version of the network is learned from the verified responses, so nodes of any supported version are used
|
|
110
|
+
if (protocol.current < (minProtocolVersion ?? 1) || protocol.current > Number(LATEST_PLATFORM_VERSION)) {
|
|
115
111
|
return false;
|
|
116
112
|
}
|
|
117
113
|
// chain is stalled, last block is too old relative to the node's own clock
|
|
@@ -143,6 +139,7 @@ export default class GRPCConnectionPool {
|
|
|
143
139
|
#minProtocolVersion;
|
|
144
140
|
retries;
|
|
145
141
|
proofs;
|
|
142
|
+
protocolVersion;
|
|
146
143
|
#nodeIndex = 0;
|
|
147
144
|
#initialization;
|
|
148
145
|
// ban state of nodes that failed with a retryable error, banned nodes are skipped on node selection
|
|
@@ -159,6 +156,8 @@ export default class GRPCConnectionPool {
|
|
|
159
156
|
throw new Error(`GRPC minProtocolVersion must be an integer from 1 to ${Number(LATEST_PLATFORM_VERSION)}, got ${String(minProtocolVersion)}`);
|
|
160
157
|
}
|
|
161
158
|
this.#minProtocolVersion = minProtocolVersion;
|
|
159
|
+
// nodes run at least `minProtocolVersion`, but the SDK never starts below the lowest version the network runs
|
|
160
|
+
this.protocolVersion = Math.max(minProtocolVersion ?? 0, MIN_PROTOCOL_VERSION[network]);
|
|
162
161
|
this.network = network;
|
|
163
162
|
this.#poolLimit = grpcOptions?.poolLimit ?? GRPC_DEFAULT_POOL_LIMIT;
|
|
164
163
|
this.#dapiUrl = grpcOptions?.dapiUrl;
|
|
@@ -209,7 +208,7 @@ export default class GRPCConnectionPool {
|
|
|
209
208
|
// fail the initialization, so it is retried on the next request
|
|
210
209
|
if (dapiUrls.length === 0) {
|
|
211
210
|
throw new Error(`None of the ${network} evonodes are available (${networkDAPIUrls.length} checked, ` +
|
|
212
|
-
`nodes must be synced and run protocol version ${this.#minProtocolVersion
|
|
211
|
+
`nodes must be synced and run protocol version ${this.#minProtocolVersion ?? 1}-${Number(LATEST_PLATFORM_VERSION)})`);
|
|
213
212
|
}
|
|
214
213
|
this.dapiUrls = dapiUrls.slice(0, this.#poolLimit);
|
|
215
214
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GetIdentityBalanceRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, verifyIdentityBalanceProof } from 'pshenmic-dpp';
|
|
3
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
4
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
5
4
|
export default async function getIdentityBalance(grpcPool, quorumKeyProvider, identifier) {
|
|
6
5
|
const id = new IdentifierWASM(identifier);
|
|
7
6
|
const getIdentityBalanceRequest = GetIdentityBalanceRequest.create({
|
|
@@ -15,7 +14,7 @@ export default async function getIdentityBalance(grpcPool, quorumKeyProvider, id
|
|
|
15
14
|
});
|
|
16
15
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
17
16
|
.setGrpcRequest('getIdentityBalance', getIdentityBalanceRequest)
|
|
18
|
-
.setProofVerifier(verifyIdentityBalanceProof, id.bytes(), true,
|
|
17
|
+
.setProofVerifier(verifyIdentityBalanceProof, (_, platformVersion) => [id.bytes(), true, platformVersion])
|
|
19
18
|
.mapResponse(data => {
|
|
20
19
|
const balance = data.proved ? data.verified.balance : BigInt(data.result.balance);
|
|
21
20
|
if (balance == null) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GetIdentityRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, IdentityWASM, verifyIdentityByIdentifierProof } from 'pshenmic-dpp';
|
|
3
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
4
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
5
4
|
export default async function getIdentityByIdentifier(grpcPool, quorumKeyProvider, identifier) {
|
|
6
5
|
const id = new IdentifierWASM(identifier);
|
|
7
6
|
const getIdentityRequest = GetIdentityRequest.create({
|
|
@@ -15,7 +14,7 @@ export default async function getIdentityByIdentifier(grpcPool, quorumKeyProvide
|
|
|
15
14
|
});
|
|
16
15
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
17
16
|
.setGrpcRequest('getIdentity', getIdentityRequest)
|
|
18
|
-
.setProofVerifier(verifyIdentityByIdentifierProof, id, true,
|
|
17
|
+
.setProofVerifier(verifyIdentityByIdentifierProof, (_, platformVersion) => [id, true, platformVersion])
|
|
19
18
|
.mapResponse(data => {
|
|
20
19
|
const identity = data.proved ? data.verified.identity : IdentityWASM.fromBytes(data.result.identity);
|
|
21
20
|
if (identity == null) {
|
|
@@ -2,7 +2,6 @@ import { GetIdentityByNonUniquePublicKeyHashRequest } from '../../proto/generate
|
|
|
2
2
|
import { IdentityWASM, verifyFullIdentityByNonUniquePublicKeyHashProof, verifyFullIdentityByNonUniquePublicKeyHashTwoProofs } from 'pshenmic-dpp';
|
|
3
3
|
import hexToBytes from '../utils/hexToBytes.js';
|
|
4
4
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
6
5
|
function getNonUniquePublicKeyHashProof({ version }) {
|
|
7
6
|
if (version.oneofKind !== 'v0') {
|
|
8
7
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -39,12 +38,12 @@ export default async function getIdentityByNonUniquePublicKeyHash(grpcPool, quor
|
|
|
39
38
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
40
39
|
.setGrpcRequest('getIdentityByNonUniquePublicKeyHash', getIdentityByNonUniquePublicKeyHashRequest)
|
|
41
40
|
.mapProof(getNonUniquePublicKeyHashProof)
|
|
42
|
-
.setProofVerifier(verifyNonUniquePublicKeyHashProof, ({ metadata, identityProof, twoProofs }) => [
|
|
41
|
+
.setProofVerifier(verifyNonUniquePublicKeyHashProof, ({ metadata, identityProof, twoProofs }, platformVersion) => [
|
|
43
42
|
identityProof,
|
|
44
43
|
twoProofs,
|
|
45
44
|
hexToBytes(hex),
|
|
46
45
|
metadata.protocolVersion,
|
|
47
|
-
|
|
46
|
+
platformVersion
|
|
48
47
|
])
|
|
49
48
|
.mapResponse(data => {
|
|
50
49
|
if (data.proved) {
|
|
@@ -2,7 +2,6 @@ import { GetIdentityByPublicKeyHashRequest } from '../../proto/generated/platfor
|
|
|
2
2
|
import { IdentityWASM, verifyIdentityByUniqueKeyHashProof } from 'pshenmic-dpp';
|
|
3
3
|
import hexToBytes from '../utils/hexToBytes.js';
|
|
4
4
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
6
5
|
export default async function getIdentityByPublicKeyHash(grpcPool, quorumKeyProvider, hex) {
|
|
7
6
|
const getIdentityByPublicKeyHashRequest = GetIdentityByPublicKeyHashRequest.create({
|
|
8
7
|
version: {
|
|
@@ -15,7 +14,7 @@ export default async function getIdentityByPublicKeyHash(grpcPool, quorumKeyProv
|
|
|
15
14
|
});
|
|
16
15
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
17
16
|
.setGrpcRequest('getIdentityByPublicKeyHash', getIdentityByPublicKeyHashRequest)
|
|
18
|
-
.setProofVerifier(verifyIdentityByUniqueKeyHashProof, hexToBytes(hex),
|
|
17
|
+
.setProofVerifier(verifyIdentityByUniqueKeyHashProof, (_, platformVersion) => [hexToBytes(hex), platformVersion])
|
|
19
18
|
.mapResponse(data => {
|
|
20
19
|
const identity = data.proved ? data.verified.identity : IdentityWASM.fromBytes(data.result.identity);
|
|
21
20
|
if (identity == null) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GetIdentityContractNonceRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, verifyIdentityContractNonceProof } from 'pshenmic-dpp';
|
|
3
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
4
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
5
4
|
const IDENTITY_CONTRACT_NONCE_VALUE_FILTER = BigInt(0xFFFFFFFFFF);
|
|
6
5
|
export default async function getIdentityContractNonce(grpcPool, quorumKeyProvider, identity, dataContract) {
|
|
7
6
|
const identityIdentifier = new IdentifierWASM(identity);
|
|
@@ -18,7 +17,7 @@ export default async function getIdentityContractNonce(grpcPool, quorumKeyProvid
|
|
|
18
17
|
});
|
|
19
18
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
20
19
|
.setGrpcRequest('getIdentityContractNonce', getIdentityContractNonceRequest)
|
|
21
|
-
.setProofVerifier(verifyIdentityContractNonceProof, identityIdentifier.bytes(), dataContractIdentifier.bytes(), true,
|
|
20
|
+
.setProofVerifier(verifyIdentityContractNonceProof, (_, platformVersion) => [identityIdentifier.bytes(), dataContractIdentifier.bytes(), true, platformVersion])
|
|
22
21
|
.mapResponse(data => {
|
|
23
22
|
const contractNonce = data.proved ? data.verified.contractNonce : BigInt(data.result.identityContractNonce);
|
|
24
23
|
return contractNonce != null ? contractNonce & IDENTITY_CONTRACT_NONCE_VALUE_FILTER : BigInt(0);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GetIdentityNonceRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, verifyIdentityNonceProof } from 'pshenmic-dpp';
|
|
3
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
4
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
5
4
|
const IDENTITY_NONCE_VALUE_FILTER = BigInt(0xFFFFFFFFFF);
|
|
6
5
|
export default async function getIdentityNonce(grpcPool, quorumKeyProvider, identifier) {
|
|
7
6
|
const id = new IdentifierWASM(identifier);
|
|
@@ -16,7 +15,7 @@ export default async function getIdentityNonce(grpcPool, quorumKeyProvider, iden
|
|
|
16
15
|
});
|
|
17
16
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
18
17
|
.setGrpcRequest('getIdentityNonce', getIdentityNonceRequest)
|
|
19
|
-
.setProofVerifier(verifyIdentityNonceProof, id.bytes(), true,
|
|
18
|
+
.setProofVerifier(verifyIdentityNonceProof, (_, platformVersion) => [id.bytes(), true, platformVersion])
|
|
20
19
|
.mapResponse(data => {
|
|
21
20
|
const nonce = data.proved ? data.verified.nonce : BigInt(data.result.identityNonce);
|
|
22
21
|
return nonce != null ? nonce & IDENTITY_NONCE_VALUE_FILTER : BigInt(0);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GetIdentityKeysRequest, KeyRequestType } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, IdentityPublicKeyWASM, verifyIdentityKeysByIdentifierProof } from 'pshenmic-dpp';
|
|
3
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
4
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
5
4
|
export default async function getIdentityPublicKeys(grpcPool, quorumKeyProvider, identifier, keyIds) {
|
|
6
5
|
const id = new IdentifierWASM(identifier);
|
|
7
6
|
let requestType = {
|
|
@@ -30,7 +29,7 @@ export default async function getIdentityPublicKeys(grpcPool, quorumKeyProvider,
|
|
|
30
29
|
});
|
|
31
30
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
32
31
|
.setGrpcRequest('getIdentityKeys', getIdentityKeysRequest)
|
|
33
|
-
.setProofVerifier(verifyIdentityKeysByIdentifierProof, id.bytes(), keyIds ?? null, false, false, true, null, null,
|
|
32
|
+
.setProofVerifier(verifyIdentityKeysByIdentifierProof, (_, platformVersion) => [id.bytes(), keyIds ?? null, false, false, true, null, null, platformVersion])
|
|
34
33
|
.mapResponse(data => {
|
|
35
34
|
const keys = data.proved
|
|
36
35
|
? data.verified.identity?.loadedPublicKeys
|
package/src/names/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare class NamesController {
|
|
|
47
47
|
* @param identityId {IdentifierLike} identity identifier
|
|
48
48
|
* @param privateKey {PrivateKeyWASM} Authentication / High private key from your identity
|
|
49
49
|
* @param preorderSalt {Uint8Array=} Optional 32 bytes salt of already existing preorder document. If provided, preorder step is skipped
|
|
50
|
-
* @param platformVersion {PlatformVersionLike=} Optional platform version used to create preorder and domain documents (
|
|
50
|
+
* @param platformVersion {PlatformVersionLike=} Optional platform version used to create preorder and domain documents (protocol version of the network by default)
|
|
51
51
|
*
|
|
52
52
|
* @return {Promise<Uint8Array>} preorder salt (also attached as `preorderSalt` to the error if domain broadcast fails)
|
|
53
53
|
*/
|
package/src/names/index.js
CHANGED
|
@@ -71,7 +71,7 @@ export class NamesController {
|
|
|
71
71
|
* @param identityId {IdentifierLike} identity identifier
|
|
72
72
|
* @param privateKey {PrivateKeyWASM} Authentication / High private key from your identity
|
|
73
73
|
* @param preorderSalt {Uint8Array=} Optional 32 bytes salt of already existing preorder document. If provided, preorder step is skipped
|
|
74
|
-
* @param platformVersion {PlatformVersionLike=} Optional platform version used to create preorder and domain documents (
|
|
74
|
+
* @param platformVersion {PlatformVersionLike=} Optional platform version used to create preorder and domain documents (protocol version of the network by default)
|
|
75
75
|
*
|
|
76
76
|
* @return {Promise<Uint8Array>} preorder salt (also attached as `preorderSalt` to the error if domain broadcast fails)
|
|
77
77
|
*/
|
|
@@ -8,6 +8,7 @@ import getIdentityContractNonce from '../identities/getIdentityContractNonce.js'
|
|
|
8
8
|
import broadcast from '../stateTransitions/broadcast.js';
|
|
9
9
|
import waitForStateTransitionResult from '../stateTransitions/waitForStateTransitionResult.js';
|
|
10
10
|
import testNameContested from './testNameContested.js';
|
|
11
|
+
import getProtocolVersion from '../node/getProtocolVersion.js';
|
|
11
12
|
import { DPNS_DATA_CONTRACT_ID } from '../constants.js';
|
|
12
13
|
export default async function registerName(grpcPool, quorumKeyProvider, name, identity, privateKey, preorderSalt, platformVersion) {
|
|
13
14
|
const [identityPublicKey] = identity.getPublicKeys().filter(identityPublicKey => identityPublicKey.getPublicKeyHash() === privateKey.getPublicKeyHash());
|
|
@@ -30,6 +31,8 @@ export default async function registerName(grpcPool, quorumKeyProvider, name, id
|
|
|
30
31
|
...new TextEncoder().encode(normalizedFullDomainName)
|
|
31
32
|
])));
|
|
32
33
|
const identityContractNonce = await getIdentityContractNonce(grpcPool, quorumKeyProvider, identity.id, DPNS_DATA_CONTRACT_ID);
|
|
34
|
+
// document ids are generated differently by the protocol versions, so the documents are created with the one of the network
|
|
35
|
+
const documentPlatformVersion = platformVersion ?? await getProtocolVersion(grpcPool, quorumKeyProvider);
|
|
33
36
|
// skip preorder if salt of existing preorder is provided
|
|
34
37
|
const domainNonce = identityContractNonce + BigInt(preorderSalt == null ? 2 : 1);
|
|
35
38
|
// salt is exposed in the error only once preorder exists (passed in or its broadcast accepted),
|
|
@@ -41,7 +44,7 @@ export default async function registerName(grpcPool, quorumKeyProvider, name, id
|
|
|
41
44
|
const preorderData = {
|
|
42
45
|
saltedDomainHash
|
|
43
46
|
};
|
|
44
|
-
const preorderDocument = createDocument(DPNS_DATA_CONTRACT_ID, 'preorder', preorderData, identity.id.base58(), identityContractNonce + BigInt(1), undefined, undefined,
|
|
47
|
+
const preorderDocument = createDocument(DPNS_DATA_CONTRACT_ID, 'preorder', preorderData, identity.id.base58(), identityContractNonce + BigInt(1), undefined, undefined, documentPlatformVersion);
|
|
45
48
|
const preorderStateTransition = createStateTransition(preorderDocument, 'create', { identityContractNonce: identityContractNonce + BigInt(1) });
|
|
46
49
|
await preorderStateTransition.sign(privateKey, identityPublicKey);
|
|
47
50
|
await broadcast(grpcPool, preorderStateTransition);
|
|
@@ -63,7 +66,7 @@ export default async function registerName(grpcPool, quorumKeyProvider, name, id
|
|
|
63
66
|
allowSubdomains: false
|
|
64
67
|
}
|
|
65
68
|
};
|
|
66
|
-
const domainDocument = createDocument(DPNS_DATA_CONTRACT_ID, 'domain', domainData, identity.id.base58(), domainNonce, undefined, undefined,
|
|
69
|
+
const domainDocument = createDocument(DPNS_DATA_CONTRACT_ID, 'domain', domainData, identity.id.base58(), domainNonce, undefined, undefined, documentPlatformVersion);
|
|
67
70
|
const domainStateTransition = createStateTransition(domainDocument, 'create', {
|
|
68
71
|
identityContractNonce: domainNonce,
|
|
69
72
|
// @ts-expect-error
|
package/src/node/epochInfos.js
CHANGED
|
@@ -2,7 +2,6 @@ import { GetEpochsInfoRequest } from '../../proto/generated/platform.js';
|
|
|
2
2
|
import { verifyEpochsInfoProof } from 'pshenmic-dpp';
|
|
3
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
4
4
|
import { UInt32Value } from '../../proto/generated/google/protobuf/wrappers.js';
|
|
5
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
6
5
|
export default async function epochInfos(grpcPool, quorumKeyProvider, count, ascending, start) {
|
|
7
6
|
const getEpochsInfoRequest = GetEpochsInfoRequest.create({
|
|
8
7
|
version: {
|
|
@@ -17,7 +16,7 @@ export default async function epochInfos(grpcPool, quorumKeyProvider, count, asc
|
|
|
17
16
|
});
|
|
18
17
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
19
18
|
.setGrpcRequest('getEpochsInfo', getEpochsInfoRequest)
|
|
20
|
-
.setProofVerifier(verifyEpochsInfoProof, ({ metadata }) => [metadata.epoch, start, count, ascending,
|
|
19
|
+
.setProofVerifier(verifyEpochsInfoProof, ({ metadata }, platformVersion) => [metadata.epoch, start, count, ascending, platformVersion])
|
|
21
20
|
.mapResponse(data => {
|
|
22
21
|
if (data.proved) {
|
|
23
22
|
return data.verified.epochsInfo.map(info => ({
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GetFinalizedEpochInfosRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, verifyFinalizedEpochInfosProof } from 'pshenmic-dpp';
|
|
3
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
4
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
5
4
|
export default async function getFinalizedEpochsInfo(grpcPool, quorumKeyProvider, startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded) {
|
|
6
5
|
const getEpochsInfoRequest = GetFinalizedEpochInfosRequest.create({
|
|
7
6
|
version: {
|
|
@@ -17,7 +16,7 @@ export default async function getFinalizedEpochsInfo(grpcPool, quorumKeyProvider
|
|
|
17
16
|
});
|
|
18
17
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
19
18
|
.setGrpcRequest('getFinalizedEpochInfos', getEpochsInfoRequest)
|
|
20
|
-
.setProofVerifier(verifyFinalizedEpochInfosProof, startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded,
|
|
19
|
+
.setProofVerifier(verifyFinalizedEpochInfosProof, (_, platformVersion) => [startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded, platformVersion])
|
|
21
20
|
.mapResponse(data => {
|
|
22
21
|
if (data.proved) {
|
|
23
22
|
return data.verified.epochInfos.map(info => ({
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PlatformVersionWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
3
|
+
import { QuorumKeyProvider } from '../quorumKeyProvider.js';
|
|
4
|
+
/**
|
|
5
|
+
* Returns the protocol version of the network learned from the verified responses.
|
|
6
|
+
* If no response was verified yet, the current epoch is requested with proof (even if proofs are disabled),
|
|
7
|
+
* so the protocol version is learned from its verified response
|
|
8
|
+
*/
|
|
9
|
+
export default function getProtocolVersion(grpcPool: GRPCPool, quorumKeyProvider: QuorumKeyProvider): Promise<PlatformVersionWASM>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { verifyEpochsInfoProof } from 'pshenmic-dpp';
|
|
2
|
+
import { GetEpochsInfoRequest } from '../../proto/generated/platform.js';
|
|
3
|
+
import QueryExecutor, { getPoolProtocolVersion, getVerifiedProtocolVersion } from '../QueryExecutor.js';
|
|
4
|
+
/**
|
|
5
|
+
* Returns the protocol version of the network learned from the verified responses.
|
|
6
|
+
* If no response was verified yet, the current epoch is requested with proof (even if proofs are disabled),
|
|
7
|
+
* so the protocol version is learned from its verified response
|
|
8
|
+
*/
|
|
9
|
+
export default async function getProtocolVersion(grpcPool, quorumKeyProvider) {
|
|
10
|
+
if (getVerifiedProtocolVersion(grpcPool) == null) {
|
|
11
|
+
const getEpochsInfoRequest = GetEpochsInfoRequest.create({
|
|
12
|
+
version: {
|
|
13
|
+
oneofKind: 'v0',
|
|
14
|
+
v0: {
|
|
15
|
+
count: 1,
|
|
16
|
+
ascending: false,
|
|
17
|
+
prove: true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
22
|
+
.setGrpcRequest('getEpochsInfo', getEpochsInfoRequest)
|
|
23
|
+
.setRequireProof(true)
|
|
24
|
+
.setProofVerifier(verifyEpochsInfoProof, ({ metadata }, platformVersion) => [metadata.epoch, undefined, 1, false, platformVersion])
|
|
25
|
+
.mapResponse(() => undefined)
|
|
26
|
+
.execute();
|
|
27
|
+
}
|
|
28
|
+
return getPoolProtocolVersion(grpcPool);
|
|
29
|
+
}
|
package/src/node/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { NodeStatus } from '../../types.js';
|
|
|
4
4
|
import { EpochInfo } from './epochInfos.js';
|
|
5
5
|
import { FinalizedEpochInfo } from './finalizedEpochInfos.js';
|
|
6
6
|
import { CurrentQuorumsInfo } from './getCurrentQuorumsInfo.js';
|
|
7
|
+
import { PlatformVersionWASM } from 'pshenmic-dpp';
|
|
7
8
|
/**
|
|
8
9
|
* Node controller for requesting information about DAPI node
|
|
9
10
|
*
|
|
@@ -28,6 +29,14 @@ export declare class NodeController {
|
|
|
28
29
|
* @return {Promise<bigint>}
|
|
29
30
|
*/
|
|
30
31
|
totalCredits(): Promise<bigint>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the protocol version of the network, used by default to verify proofs and to create documents.
|
|
34
|
+
* It is learned from the verified responses, if no response was verified yet, one proved request is made
|
|
35
|
+
* (even if proofs are disabled)
|
|
36
|
+
*
|
|
37
|
+
* @return {Promise<PlatformVersionWASM>}
|
|
38
|
+
*/
|
|
39
|
+
getProtocolVersion(): Promise<PlatformVersionWASM>;
|
|
31
40
|
/**
|
|
32
41
|
* Retrieves an info about epochs
|
|
33
42
|
* Includes information about first block height, time, fee multiplier, number
|
package/src/node/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import getEpochsInfo from './epochInfos.js';
|
|
|
3
3
|
import getFinalizedEpochsInfo from './finalizedEpochInfos.js';
|
|
4
4
|
import getTotalCredits from './totalCredits.js';
|
|
5
5
|
import getCurrentQuorumsInfo from './getCurrentQuorumsInfo.js';
|
|
6
|
+
import getProtocolVersion from './getProtocolVersion.js';
|
|
6
7
|
/**
|
|
7
8
|
* Node controller for requesting information about DAPI node
|
|
8
9
|
*
|
|
@@ -34,6 +35,16 @@ export class NodeController {
|
|
|
34
35
|
async totalCredits() {
|
|
35
36
|
return await getTotalCredits(this.grpcPool, this.quorumKeyProvider);
|
|
36
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the protocol version of the network, used by default to verify proofs and to create documents.
|
|
40
|
+
* It is learned from the verified responses, if no response was verified yet, one proved request is made
|
|
41
|
+
* (even if proofs are disabled)
|
|
42
|
+
*
|
|
43
|
+
* @return {Promise<PlatformVersionWASM>}
|
|
44
|
+
*/
|
|
45
|
+
async getProtocolVersion() {
|
|
46
|
+
return await getProtocolVersion(this.grpcPool, this.quorumKeyProvider);
|
|
47
|
+
}
|
|
37
48
|
/**
|
|
38
49
|
* Retrieves an info about epochs
|
|
39
50
|
* Includes information about first block height, time, fee multiplier, number
|
package/src/node/totalCredits.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GetTotalCreditsInPlatformRequest } from '../../proto/generated/platform.js';
|
|
2
|
-
import { HALVING_INTERVAL,
|
|
2
|
+
import { HALVING_INTERVAL, MAINNET_ACTIVATION_HEIGHT, TESTNET_ACTIVATION_HEIGHT } from '../constants.js';
|
|
3
3
|
import { verifyTotalCreditsProof } from 'pshenmic-dpp';
|
|
4
4
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
5
|
export default async function totalCredits(grpcPool, quorumKeyProvider) {
|
|
@@ -11,9 +11,9 @@ export default async function totalCredits(grpcPool, quorumKeyProvider) {
|
|
|
11
11
|
});
|
|
12
12
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
13
13
|
.setGrpcRequest('getTotalCreditsInPlatform', getTotalCreditsInPlatformRequest)
|
|
14
|
-
.setProofVerifier(verifyTotalCreditsProof, ({ metadata }) => {
|
|
14
|
+
.setProofVerifier(verifyTotalCreditsProof, ({ metadata }, platformVersion) => {
|
|
15
15
|
const activationHeight = grpcPool.network === 'testnet' ? TESTNET_ACTIVATION_HEIGHT : MAINNET_ACTIVATION_HEIGHT;
|
|
16
|
-
return [HALVING_INTERVAL, activationHeight, metadata.coreChainLockedHeight,
|
|
16
|
+
return [HALVING_INTERVAL, activationHeight, metadata.coreChainLockedHeight, platformVersion];
|
|
17
17
|
})
|
|
18
18
|
.mapResponse(data => data.proved ? data.verified.totalCredits : BigInt(data.result.credits))
|
|
19
19
|
.execute();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PlatformAddressWASM, verifyPlatformAddressInfo } from 'pshenmic-dpp';
|
|
2
2
|
import { GetAddressInfoRequest } from '../../proto/generated/platform.js';
|
|
3
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
4
|
export async function getAddressInfo(grpcPool, quorumKeyProvider, platformAddress) {
|
|
6
5
|
const platformAddressWASM = new PlatformAddressWASM(platformAddress);
|
|
@@ -15,7 +14,7 @@ export async function getAddressInfo(grpcPool, quorumKeyProvider, platformAddres
|
|
|
15
14
|
});
|
|
16
15
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
17
16
|
.setGrpcRequest('getAddressInfo', getAddressInfoRequest)
|
|
18
|
-
.setProofVerifier(verifyPlatformAddressInfo, platformAddressWASM, true,
|
|
17
|
+
.setProofVerifier(verifyPlatformAddressInfo, (_, platformVersion) => [platformAddressWASM, true, platformVersion])
|
|
19
18
|
.mapResponse(data => {
|
|
20
19
|
const balanceAndNonce = data.proved ? data.verified : data.result.addressInfoEntry.balanceAndNonce;
|
|
21
20
|
if (balanceAndNonce?.nonce == null || balanceAndNonce.balance == null) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { verifyAddressesBranchState } from 'pshenmic-dpp';
|
|
2
2
|
import { GetAddressesBranchStateRequest, Proof, ResponseMetadata } from '../../proto/generated/platform.js';
|
|
3
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
4
|
export async function getAddressesBranchState(grpcPool, quorumKeyProvider, key, depth, checkpointHeight, expectedRootHash) {
|
|
6
5
|
const getAddressesBranchStateRequest = GetAddressesBranchStateRequest.create({
|
|
@@ -23,7 +22,7 @@ export async function getAddressesBranchState(grpcPool, quorumKeyProvider, key,
|
|
|
23
22
|
}
|
|
24
23
|
return { proof: Proof.create({ grovedbProof: version.v0.merkProof }), metadata: ResponseMetadata.create() };
|
|
25
24
|
})
|
|
26
|
-
.setProofVerifier(verifyAddressesBranchState, key, depth, expectedRootHash,
|
|
25
|
+
.setProofVerifier(verifyAddressesBranchState, (_, platformVersion) => [key, depth, expectedRootHash, platformVersion])
|
|
27
26
|
.mapResponse(data => {
|
|
28
27
|
if (!data.proved) {
|
|
29
28
|
throw new Error('Addresses branch state can only be requested with proof');
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PlatformAddressWASM, verifyPlatformAddressesInfos } from 'pshenmic-dpp';
|
|
2
2
|
import { GetAddressesInfosRequest } from '../../proto/generated/platform.js';
|
|
3
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
4
|
export async function getAddressesInfos(grpcPool, quorumKeyProvider, platformAddresses) {
|
|
6
5
|
const platformAddressesWASM = platformAddresses.map(addr => new PlatformAddressWASM(addr));
|
|
@@ -15,7 +14,7 @@ export async function getAddressesInfos(grpcPool, quorumKeyProvider, platformAdd
|
|
|
15
14
|
});
|
|
16
15
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
17
16
|
.setGrpcRequest('getAddressesInfos', getAddressInfoRequest)
|
|
18
|
-
.setProofVerifier(verifyPlatformAddressesInfos, platformAddressesWASM, true,
|
|
17
|
+
.setProofVerifier(verifyPlatformAddressesInfos, (_, platformVersion) => [platformAddressesWASM, true, platformVersion])
|
|
19
18
|
.mapResponse(data => {
|
|
20
19
|
const infos = data.proved
|
|
21
20
|
? data.verified.infos
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { verifyAddressesTrunkState } from 'pshenmic-dpp';
|
|
2
2
|
import { GetAddressesTrunkStateRequest } from '../../proto/generated/platform.js';
|
|
3
|
-
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
4
|
export async function getAddressesTrunkState(grpcPool, quorumKeyProvider) {
|
|
6
5
|
const getAddressesTrunkStateRequest = GetAddressesTrunkStateRequest.create({
|
|
@@ -24,7 +23,7 @@ export async function getAddressesTrunkState(grpcPool, quorumKeyProvider) {
|
|
|
24
23
|
}
|
|
25
24
|
return { proof, metadata };
|
|
26
25
|
})
|
|
27
|
-
.setProofVerifier(verifyAddressesTrunkState,
|
|
26
|
+
.setProofVerifier(verifyAddressesTrunkState, (_, platformVersion) => [platformVersion])
|
|
28
27
|
.mapResponse(data => {
|
|
29
28
|
if (!data.proved) {
|
|
30
29
|
throw new Error('Addresses trunk state can only be requested with proof');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { verifyRecentAddressBalanceChanges, PlatformAddressWASM } from 'pshenmic-dpp';
|
|
2
2
|
import { GetRecentAddressBalanceChangesRequest } from '../../proto/generated/platform.js';
|
|
3
|
-
import {
|
|
3
|
+
import { RECENT_ADDRESS_BALANCE_CHANGES_LIMIT } from '../constants.js';
|
|
4
4
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
5
|
export async function getRecentAddressBalanceChanges(grpcPool, quorumKeyProvider, startHeight, startHeightExclusive = false) {
|
|
6
6
|
const getRecentAddressBalanceChangesRequest = GetRecentAddressBalanceChangesRequest.create({
|
|
@@ -15,7 +15,7 @@ export async function getRecentAddressBalanceChanges(grpcPool, quorumKeyProvider
|
|
|
15
15
|
});
|
|
16
16
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
17
17
|
.setGrpcRequest('getRecentAddressBalanceChanges', getRecentAddressBalanceChangesRequest)
|
|
18
|
-
.setProofVerifier(verifyRecentAddressBalanceChanges, startHeight, startHeightExclusive, RECENT_ADDRESS_BALANCE_CHANGES_LIMIT, true,
|
|
18
|
+
.setProofVerifier(verifyRecentAddressBalanceChanges, (_, platformVersion) => [startHeight, startHeightExclusive, RECENT_ADDRESS_BALANCE_CHANGES_LIMIT, true, platformVersion])
|
|
19
19
|
.mapResponse(data => {
|
|
20
20
|
if (data.proved) {
|
|
21
21
|
return data.verified.blocks;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { verifyRecentCompactedAddressBalanceChanges, PlatformAddressWASM } from 'pshenmic-dpp';
|
|
2
2
|
import { GetRecentCompactedAddressBalanceChangesRequest } from '../../proto/generated/platform.js';
|
|
3
|
-
import {
|
|
3
|
+
import { RECENT_COMPACTED_ADDRESS_BALANCE_CHANGES_LIMIT } from '../constants.js';
|
|
4
4
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
5
|
export async function getRecentCompactedAddressBalanceChanges(grpcPool, quorumKeyProvider, startBlockHeight) {
|
|
6
6
|
const getRecentCompactedAddressBalanceChangesRequest = GetRecentCompactedAddressBalanceChangesRequest.create({
|
|
@@ -14,7 +14,7 @@ export async function getRecentCompactedAddressBalanceChanges(grpcPool, quorumKe
|
|
|
14
14
|
});
|
|
15
15
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
16
16
|
.setGrpcRequest('getRecentCompactedAddressBalanceChanges', getRecentCompactedAddressBalanceChangesRequest)
|
|
17
|
-
.setProofVerifier(verifyRecentCompactedAddressBalanceChanges, startBlockHeight, RECENT_COMPACTED_ADDRESS_BALANCE_CHANGES_LIMIT,
|
|
17
|
+
.setProofVerifier(verifyRecentCompactedAddressBalanceChanges, (_, platformVersion) => [startBlockHeight, RECENT_COMPACTED_ADDRESS_BALANCE_CHANGES_LIMIT, platformVersion])
|
|
18
18
|
.mapResponse(data => {
|
|
19
19
|
if (data.proved) {
|
|
20
20
|
return data.verified.ranges;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GetMostRecentShieldedAnchorRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, verifyMostRecentShieldedAnchorProof } from 'pshenmic-dpp';
|
|
3
|
-
import { SHIELDED_PLATFORM_VERSION } from '../constants.js';
|
|
4
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
4
|
export default async function getMostRecentShieldedAnchor(grpcPool, quorumKeyProvider, tokenIdentifier) {
|
|
6
5
|
const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
|
|
@@ -15,7 +14,7 @@ export default async function getMostRecentShieldedAnchor(grpcPool, quorumKeyPro
|
|
|
15
14
|
});
|
|
16
15
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
17
16
|
.setGrpcRequest('getMostRecentShieldedAnchor', getMostRecentShieldedAnchorRequest)
|
|
18
|
-
.setProofVerifier(verifyMostRecentShieldedAnchorProof, true,
|
|
17
|
+
.setProofVerifier(verifyMostRecentShieldedAnchorProof, (_, platformVersion) => [true, platformVersion, tokenId])
|
|
19
18
|
.mapResponse(data => data.proved ? data.verified.anchor : data.result.anchor)
|
|
20
19
|
.execute();
|
|
21
20
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GetShieldedAnchorsRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, verifyShieldedAnchorsProof } from 'pshenmic-dpp';
|
|
3
|
-
import { SHIELDED_PLATFORM_VERSION } from '../constants.js';
|
|
4
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
4
|
export default async function getShieldedAnchors(grpcPool, quorumKeyProvider, tokenIdentifier) {
|
|
6
5
|
const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
|
|
@@ -15,7 +14,7 @@ export default async function getShieldedAnchors(grpcPool, quorumKeyProvider, to
|
|
|
15
14
|
});
|
|
16
15
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
17
16
|
.setGrpcRequest('getShieldedAnchors', getShieldedAnchorsRequest)
|
|
18
|
-
.setProofVerifier(verifyShieldedAnchorsProof, true,
|
|
17
|
+
.setProofVerifier(verifyShieldedAnchorsProof, (_, platformVersion) => [true, platformVersion, tokenId])
|
|
19
18
|
.mapResponse(data => data.proved ? data.verified.anchors : data.result.anchors.anchors)
|
|
20
19
|
.execute();
|
|
21
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetShieldedEncryptedNotesRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, verifyShieldedEncryptedNotesProof } from 'pshenmic-dpp';
|
|
3
|
-
import {
|
|
3
|
+
import { SHIELDED_MAX_NOTES_PER_QUERY } from '../constants.js';
|
|
4
4
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
5
|
export default async function getShieldedEncryptedNotes(grpcPool, quorumKeyProvider, startIndex, count, tokenIdentifier) {
|
|
6
6
|
const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
|
|
@@ -17,7 +17,7 @@ export default async function getShieldedEncryptedNotes(grpcPool, quorumKeyProvi
|
|
|
17
17
|
});
|
|
18
18
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
19
19
|
.setGrpcRequest('getShieldedEncryptedNotes', getShieldedEncryptedNotesRequest)
|
|
20
|
-
.setProofVerifier(verifyShieldedEncryptedNotesProof, startIndex, count, SHIELDED_MAX_NOTES_PER_QUERY, true,
|
|
20
|
+
.setProofVerifier(verifyShieldedEncryptedNotesProof, (_, platformVersion) => [startIndex, count, SHIELDED_MAX_NOTES_PER_QUERY, true, platformVersion, tokenId])
|
|
21
21
|
.mapResponse(data => {
|
|
22
22
|
const notes = data.proved ? data.verified.notes : data.result.encryptedNotes.entries;
|
|
23
23
|
return notes.map(note => ({
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GetShieldedNotesCountRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, verifyShieldedNotesCountProof } from 'pshenmic-dpp';
|
|
3
|
-
import { SHIELDED_PLATFORM_VERSION } from '../constants.js';
|
|
4
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
4
|
export default async function getShieldedNotesCount(grpcPool, quorumKeyProvider, tokenIdentifier) {
|
|
6
5
|
const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
|
|
@@ -15,7 +14,7 @@ export default async function getShieldedNotesCount(grpcPool, quorumKeyProvider,
|
|
|
15
14
|
});
|
|
16
15
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
17
16
|
.setGrpcRequest('getShieldedNotesCount', getShieldedNotesCountRequest)
|
|
18
|
-
.setProofVerifier(verifyShieldedNotesCountProof, true,
|
|
17
|
+
.setProofVerifier(verifyShieldedNotesCountProof, (_, platformVersion) => [true, platformVersion, tokenId])
|
|
19
18
|
.mapResponse(data => data.proved ? data.verified.count : BigInt(data.result.totalNotesCount))
|
|
20
19
|
.execute();
|
|
21
20
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GetShieldedNullifiersRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import { IdentifierWASM, verifyShieldedNullifiersProof } from 'pshenmic-dpp';
|
|
3
|
-
import { SHIELDED_PLATFORM_VERSION } from '../constants.js';
|
|
4
3
|
import QueryExecutor from '../QueryExecutor.js';
|
|
5
4
|
export default async function getShieldedNullifiers(grpcPool, quorumKeyProvider, nullifiers, tokenIdentifier) {
|
|
6
5
|
const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
|
|
@@ -16,7 +15,7 @@ export default async function getShieldedNullifiers(grpcPool, quorumKeyProvider,
|
|
|
16
15
|
});
|
|
17
16
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
18
17
|
.setGrpcRequest('getShieldedNullifiers', getShieldedNullifiersRequest)
|
|
19
|
-
.setProofVerifier(verifyShieldedNullifiersProof, nullifiers, true,
|
|
18
|
+
.setProofVerifier(verifyShieldedNullifiersProof, (_, platformVersion) => [nullifiers, true, platformVersion, tokenId])
|
|
20
19
|
.mapResponse(data => {
|
|
21
20
|
const nullifiersStatuses = data.proved ? data.verified.nullifiers : data.result.nullifierStatuses.entries;
|
|
22
21
|
return nullifiersStatuses.map(entry => ({
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GetShieldedPoolStateRequest } from '../../proto/generated/platform.js';
|
|
2
2
|
import QueryExecutor from '../QueryExecutor.js';
|
|
3
3
|
import { IdentifierWASM, verifyShieldedPoolStateProof } from 'pshenmic-dpp';
|
|
4
|
-
import { SHIELDED_PLATFORM_VERSION } from '../constants.js';
|
|
5
4
|
export default async function getShieldedPoolState(grpcPool, quorumKeyProvider, tokenIdentifier) {
|
|
6
5
|
const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
|
|
7
6
|
const getShieldedPoolStateRequest = GetShieldedPoolStateRequest.create({
|
|
@@ -15,7 +14,7 @@ export default async function getShieldedPoolState(grpcPool, quorumKeyProvider,
|
|
|
15
14
|
});
|
|
16
15
|
return await QueryExecutor.build(grpcPool, quorumKeyProvider)
|
|
17
16
|
.setGrpcRequest('getShieldedPoolState', getShieldedPoolStateRequest)
|
|
18
|
-
.setProofVerifier(verifyShieldedPoolStateProof, true,
|
|
17
|
+
.setProofVerifier(verifyShieldedPoolStateProof, (_, platformVersion) => [true, platformVersion, tokenId])
|
|
19
18
|
.mapResponse(data => data.proved ? data.verified.totalBalance : BigInt(data.result.totalBalance))
|
|
20
19
|
.execute();
|
|
21
20
|
}
|