dash-platform-sdk 1.5.2 → 1.6.0-dev.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.
Files changed (89) hide show
  1. package/README.md +15 -15
  2. package/bundle.min.js +1 -1
  3. package/package.json +3 -4
  4. package/proto/generated/platform.client.d.ts +20 -60
  5. package/proto/generated/platform.client.js +41 -69
  6. package/proto/generated/platform.d.ts +2330 -1650
  7. package/proto/generated/platform.js +4992 -3467
  8. package/src/DashPlatformSDK.d.ts +0 -8
  9. package/src/DashPlatformSDK.js +0 -10
  10. package/src/constants.d.ts +1 -1
  11. package/src/constants.js +1 -1
  12. package/src/contestedResources/getContestedResourceVoteState.js +1 -1
  13. package/src/dataContracts/getDataContractByIdentifier.js +1 -1
  14. package/src/documents/createStateTransition.d.ts +2 -2
  15. package/src/documents/createStateTransition.js +6 -6
  16. package/src/documents/getActionFeeAgreement.d.ts +4 -0
  17. package/src/documents/getActionFeeAgreement.js +21 -0
  18. package/src/documents/index.d.ts +97 -3
  19. package/src/documents/index.js +114 -1
  20. package/src/documents/query.js +13 -52
  21. package/src/documents/queryAggregate.d.ts +4 -0
  22. package/src/documents/queryAggregate.js +32 -0
  23. package/src/documents/queryJoined.d.ts +16 -0
  24. package/src/documents/queryJoined.js +44 -0
  25. package/src/documents/queryRanked.d.ts +12 -0
  26. package/src/documents/queryRanked.js +37 -0
  27. package/src/documents/v1.d.ts +33 -0
  28. package/src/documents/v1.js +233 -0
  29. package/src/grpcConnectionPool.d.ts +3 -6
  30. package/src/grpcConnectionPool.js +141 -47
  31. package/src/identities/getIdentityBalance.js +1 -1
  32. package/src/identities/getIdentityByIdentifier.js +1 -1
  33. package/src/identities/getIdentityByNonUniquePublicKeyHash.js +7 -11
  34. package/src/identities/getIdentityByPublicKeyHash.js +1 -1
  35. package/src/identities/getIdentityContractNonce.js +1 -1
  36. package/src/identities/getIdentityNonce.js +1 -1
  37. package/src/identities/getIdentityPublicKeys.js +1 -1
  38. package/src/node/epochInfos.js +1 -1
  39. package/src/node/finalizedEpochInfos.js +1 -1
  40. package/src/node/getCurrentQuorumsInfo.js +1 -1
  41. package/src/node/status.js +1 -1
  42. package/src/node/totalCredits.js +1 -1
  43. package/src/platformAddresses/getAddressInfo.js +1 -1
  44. package/src/platformAddresses/getAddressesBranchState.js +1 -1
  45. package/src/platformAddresses/getAddressesInfos.js +1 -1
  46. package/src/platformAddresses/getAddressesTrunkState.js +1 -1
  47. package/src/platformAddresses/getRecentAddressBalanceChanges.js +1 -1
  48. package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.js +1 -1
  49. package/src/shielded/getMostRecentShieldedAnchor.d.ts +2 -1
  50. package/src/shielded/getMostRecentShieldedAnchor.js +7 -5
  51. package/src/shielded/getShieldedAnchors.d.ts +2 -1
  52. package/src/shielded/getShieldedAnchors.js +7 -5
  53. package/src/shielded/getShieldedEncryptedNotes.d.ts +2 -1
  54. package/src/shielded/getShieldedEncryptedNotes.js +7 -5
  55. package/src/shielded/getShieldedNotesCount.d.ts +2 -1
  56. package/src/shielded/getShieldedNotesCount.js +7 -5
  57. package/src/shielded/getShieldedNullifiers.d.ts +2 -1
  58. package/src/shielded/getShieldedNullifiers.js +7 -5
  59. package/src/shielded/getShieldedPoolState.d.ts +2 -1
  60. package/src/shielded/getShieldedPoolState.js +7 -5
  61. package/src/shielded/index.d.ts +17 -7
  62. package/src/shielded/index.js +22 -12
  63. package/src/stateTransitions/broadcast.js +1 -1
  64. package/src/stateTransitions/index.d.ts +6 -2
  65. package/src/stateTransitions/index.js +5 -1
  66. package/src/stateTransitions/waitForStateTransitionResult.d.ts +1 -1
  67. package/src/stateTransitions/waitForStateTransitionResult.js +5 -3
  68. package/src/tokens/getIdentitiesTokenBalances.js +1 -1
  69. package/src/tokens/getIdentityTokensBalances.js +1 -1
  70. package/src/tokens/getTokenContractInfo.js +1 -1
  71. package/src/tokens/getTokenDirectPurchasePrices.js +1 -1
  72. package/src/tokens/getTokenTotalSupply.js +1 -1
  73. package/src/utils/verifyTenderdashProof.js +1 -1
  74. package/test/unit/ContestedResources.spec.js +0 -1
  75. package/test/unit/DataContract.spec.js +2 -2
  76. package/test/unit/Document.spec.js +0 -1
  77. package/test/unit/DocumentActionFees.spec.d.ts +1 -0
  78. package/test/unit/DocumentActionFees.spec.js +99 -0
  79. package/test/unit/DocumentQueries.spec.d.ts +1 -0
  80. package/test/unit/DocumentQueries.spec.js +178 -0
  81. package/test/unit/DocumentsV1.spec.d.ts +1 -0
  82. package/test/unit/DocumentsV1.spec.js +75 -0
  83. package/test/unit/Identity.spec.js +0 -1
  84. package/test/unit/Names.spec.js +0 -1
  85. package/test/unit/Node.spec.js +0 -1
  86. package/test/unit/PlatformAddress.spec.js +0 -1
  87. package/test/unit/Shielded.spec.js +0 -1
  88. package/test/unit/Tokens.spec.js +0 -1
  89. package/types.d.ts +20 -1
@@ -18,7 +18,7 @@ export default async function getIdentityContractNonce(grpcPool, identity, dataC
18
18
  }
19
19
  }
20
20
  });
21
- const { response } = await grpcPool.getClient().getIdentityContractNonce(getIdentityContractNonceRequest);
21
+ const { response } = await (await grpcPool.getClient()).getIdentityContractNonce(getIdentityContractNonceRequest);
22
22
  const { version } = response;
23
23
  if (version.oneofKind !== 'v0') {
24
24
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -16,7 +16,7 @@ export default async function getIdentityNonce(grpcPool, identifier) {
16
16
  }
17
17
  }
18
18
  });
19
- const { response } = await grpcPool.getClient().getIdentityNonce(getIdentityNonceRequest);
19
+ const { response } = await (await grpcPool.getClient()).getIdentityNonce(getIdentityNonceRequest);
20
20
  const { version } = response;
21
21
  if (version.oneofKind !== 'v0') {
22
22
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -30,7 +30,7 @@ export default async function getIdentityPublicKeys(grpcPool, identifier, keyIds
30
30
  }
31
31
  }
32
32
  });
33
- const { response } = await grpcPool.getClient().getIdentityKeys(getIdentityKeysRequest);
33
+ const { response } = await (await grpcPool.getClient()).getIdentityKeys(getIdentityKeysRequest);
34
34
  const { version } = response;
35
35
  if (version.oneofKind !== 'v0') {
36
36
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -17,7 +17,7 @@ export default async function epochInfos(grpcPool, count, ascending, start) {
17
17
  }
18
18
  }
19
19
  });
20
- const { response } = await grpcPool.getClient().getEpochsInfo(getEpochsInfoRequest);
20
+ const { response } = await (await grpcPool.getClient()).getEpochsInfo(getEpochsInfoRequest);
21
21
  const { version } = response;
22
22
  if (version.oneofKind !== 'v0') {
23
23
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -17,7 +17,7 @@ export default async function getFinalizedEpochsInfo(grpcPool, startEpochIndex,
17
17
  }
18
18
  }
19
19
  });
20
- const { response } = await grpcPool.getClient().getFinalizedEpochInfos(getEpochsInfoRequest);
20
+ const { response } = await (await grpcPool.getClient()).getFinalizedEpochInfos(getEpochsInfoRequest);
21
21
  const { version } = response;
22
22
  if (version.oneofKind !== 'v0') {
23
23
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -7,7 +7,7 @@ export default async function getCurrentQuorumsInfo(grpcPool) {
7
7
  v0: {}
8
8
  }
9
9
  });
10
- const { response } = await grpcPool.getClient().getCurrentQuorumsInfo(getCurrentQuorumsInfoRequest);
10
+ const { response } = await (await grpcPool.getClient()).getCurrentQuorumsInfo(getCurrentQuorumsInfoRequest);
11
11
  const { version } = response;
12
12
  if (version.oneofKind !== 'v0') {
13
13
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -7,7 +7,7 @@ export default async function status(grpcPool) {
7
7
  v0: {}
8
8
  }
9
9
  });
10
- const { response } = await grpcPool.getClient().getStatus(getStatusRequest);
10
+ const { response } = await (await grpcPool.getClient()).getStatus(getStatusRequest);
11
11
  const { version } = response;
12
12
  if (version.oneofKind !== 'v0') {
13
13
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -11,7 +11,7 @@ export default async function totalCredits(grpcPool) {
11
11
  v0: { prove: true }
12
12
  }
13
13
  });
14
- const { response } = await grpcPool.getClient().getTotalCreditsInPlatform(getTotalCreditsInPlatformRequest);
14
+ const { response } = await (await grpcPool.getClient()).getTotalCreditsInPlatform(getTotalCreditsInPlatformRequest);
15
15
  const { version } = response;
16
16
  if (version.oneofKind !== 'v0') {
17
17
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -15,7 +15,7 @@ export async function getAddressInfo(grpcPool, platformAddress) {
15
15
  }
16
16
  }
17
17
  });
18
- const { response } = await grpcPool.getClient().getAddressInfo(getAddressInfoRequest);
18
+ const { response } = await (await grpcPool.getClient()).getAddressInfo(getAddressInfoRequest);
19
19
  const { version } = response;
20
20
  if (version.oneofKind !== 'v0') {
21
21
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -12,7 +12,7 @@ export async function getAddressesBranchState(grpcPool, key, depth, checkpointHe
12
12
  }
13
13
  }
14
14
  });
15
- const { response } = await grpcPool.getClient().getAddressesBranchState(getAddressesBranchStateRequest);
15
+ const { response } = await (await grpcPool.getClient()).getAddressesBranchState(getAddressesBranchStateRequest);
16
16
  const { version } = response;
17
17
  if (version.oneofKind !== 'v0') {
18
18
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -15,7 +15,7 @@ export async function getAddressesInfos(grpcPool, platformAddresses) {
15
15
  }
16
16
  }
17
17
  });
18
- const { response } = await grpcPool.getClient().getAddressesInfos(getAddressInfoRequest);
18
+ const { response } = await (await grpcPool.getClient()).getAddressesInfos(getAddressInfoRequest);
19
19
  const { version } = response;
20
20
  if (version.oneofKind !== 'v0') {
21
21
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -11,7 +11,7 @@ export async function getAddressesTrunkState(grpcPool) {
11
11
  v0: {}
12
12
  }
13
13
  });
14
- const { response } = await grpcPool.getClient().getAddressesTrunkState(getAddressesTrunkStateRequest);
14
+ const { response } = await (await grpcPool.getClient()).getAddressesTrunkState(getAddressesTrunkStateRequest);
15
15
  const { version } = response;
16
16
  if (version.oneofKind !== 'v0') {
17
17
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -15,7 +15,7 @@ export async function getRecentAddressBalanceChanges(grpcPool, startHeight, star
15
15
  }
16
16
  }
17
17
  });
18
- const { response } = await grpcPool.getClient().getRecentAddressBalanceChanges(getRecentAddressBalanceChangesRequest);
18
+ const { response } = await (await grpcPool.getClient()).getRecentAddressBalanceChanges(getRecentAddressBalanceChangesRequest);
19
19
  const { version } = response;
20
20
  if (version.oneofKind !== 'v0') {
21
21
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -14,7 +14,7 @@ export async function getRecentCompactedAddressBalanceChanges(grpcPool, startBlo
14
14
  }
15
15
  }
16
16
  });
17
- const { response } = await grpcPool.getClient().getRecentCompactedAddressBalanceChanges(getRecentCompactedAddressBalanceChangesRequest);
17
+ const { response } = await (await grpcPool.getClient()).getRecentCompactedAddressBalanceChanges(getRecentCompactedAddressBalanceChangesRequest);
18
18
  const { version } = response;
19
19
  if (version.oneofKind !== 'v0') {
20
20
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -1,2 +1,3 @@
1
1
  import { GRPCPool } from '../grpcConnectionPool.js';
2
- export default function getMostRecentShieldedAnchor(grpcPool: GRPCPool): Promise<Uint8Array | undefined>;
2
+ import { IdentifierLike } from 'pshenmic-dpp';
3
+ export default function getMostRecentShieldedAnchor(grpcPool: GRPCPool, tokenIdentifier?: IdentifierLike): Promise<Uint8Array | undefined>;
@@ -1,19 +1,21 @@
1
1
  import { GetMostRecentShieldedAnchorRequest } from '../../proto/generated/platform.js';
2
- import { verifyMostRecentShieldedAnchorProof } from "pshenmic-dpp";
2
+ import { IdentifierWASM, verifyMostRecentShieldedAnchorProof } from 'pshenmic-dpp';
3
3
  import { LATEST_PLATFORM_VERSION } from "../constants.js";
4
4
  import { getQuorumPublicKey } from "../utils/getQuorumPublicKey.js";
5
5
  import bytesToHex from "../utils/bytesToHex.js";
6
6
  import verifyTenderdashProof from "../utils/verifyTenderdashProof.js";
7
- export default async function getMostRecentShieldedAnchor(grpcPool) {
7
+ export default async function getMostRecentShieldedAnchor(grpcPool, tokenIdentifier) {
8
+ const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
8
9
  const getMostRecentShieldedAnchorRequest = GetMostRecentShieldedAnchorRequest.create({
9
10
  version: {
10
11
  oneofKind: 'v0',
11
12
  v0: {
12
- prove: true
13
+ prove: true,
14
+ tokenId: tokenId?.bytes()
13
15
  }
14
16
  }
15
17
  });
16
- const { response } = await grpcPool.getClient().getMostRecentShieldedAnchor(getMostRecentShieldedAnchorRequest);
18
+ const { response } = await (await grpcPool.getClient()).getMostRecentShieldedAnchor(getMostRecentShieldedAnchorRequest);
17
19
  const { version } = response;
18
20
  if (version.oneofKind !== 'v0') {
19
21
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -26,7 +28,7 @@ export default async function getMostRecentShieldedAnchor(grpcPool) {
26
28
  if (metadata == null) {
27
29
  throw new Error('Metadata not found');
28
30
  }
29
- const { rootHash, anchor } = verifyMostRecentShieldedAnchorProof(proof.grovedbProof, true, LATEST_PLATFORM_VERSION);
31
+ const { rootHash, anchor } = verifyMostRecentShieldedAnchorProof(proof.grovedbProof, true, LATEST_PLATFORM_VERSION, tokenId);
30
32
  const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
31
33
  const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
32
34
  if (!verify) {
@@ -1,2 +1,3 @@
1
1
  import { GRPCPool } from '../grpcConnectionPool.js';
2
- export default function getShieldedAnchors(grpcPool: GRPCPool): Promise<Uint8Array[]>;
2
+ import { IdentifierLike } from 'pshenmic-dpp';
3
+ export default function getShieldedAnchors(grpcPool: GRPCPool, tokenIdentifier?: IdentifierLike): Promise<Uint8Array[]>;
@@ -1,19 +1,21 @@
1
1
  import { GetShieldedAnchorsRequest } from '../../proto/generated/platform.js';
2
- import { verifyShieldedAnchorsProof } from "pshenmic-dpp";
2
+ import { IdentifierWASM, verifyShieldedAnchorsProof } from 'pshenmic-dpp';
3
3
  import { LATEST_PLATFORM_VERSION } from "../constants.js";
4
4
  import { getQuorumPublicKey } from "../utils/getQuorumPublicKey.js";
5
5
  import bytesToHex from "../utils/bytesToHex.js";
6
6
  import verifyTenderdashProof from "../utils/verifyTenderdashProof.js";
7
- export default async function getShieldedAnchors(grpcPool) {
7
+ export default async function getShieldedAnchors(grpcPool, tokenIdentifier) {
8
+ const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
8
9
  const getShieldedAnchorsRequest = GetShieldedAnchorsRequest.create({
9
10
  version: {
10
11
  oneofKind: 'v0',
11
12
  v0: {
12
- prove: true
13
+ prove: true,
14
+ tokenId: tokenId?.bytes()
13
15
  }
14
16
  }
15
17
  });
16
- const { response } = await grpcPool.getClient().getShieldedAnchors(getShieldedAnchorsRequest);
18
+ const { response } = await (await grpcPool.getClient()).getShieldedAnchors(getShieldedAnchorsRequest);
17
19
  const { version } = response;
18
20
  if (version.oneofKind !== 'v0') {
19
21
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -26,7 +28,7 @@ export default async function getShieldedAnchors(grpcPool) {
26
28
  if (metadata == null) {
27
29
  throw new Error('Metadata not found');
28
30
  }
29
- const { rootHash, anchors } = verifyShieldedAnchorsProof(proof.grovedbProof, true, LATEST_PLATFORM_VERSION);
31
+ const { rootHash, anchors } = verifyShieldedAnchorsProof(proof.grovedbProof, true, LATEST_PLATFORM_VERSION, tokenId);
30
32
  const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
31
33
  const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
32
34
  if (!verify) {
@@ -1,3 +1,4 @@
1
1
  import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { ShieldedEncryptedNote } from '../../types.js';
3
- export default function getShieldedEncryptedNotes(grpcPool: GRPCPool, startIndex: bigint, count: number): Promise<ShieldedEncryptedNote[]>;
3
+ import { IdentifierLike } from 'pshenmic-dpp';
4
+ export default function getShieldedEncryptedNotes(grpcPool: GRPCPool, startIndex: bigint, count: number, tokenIdentifier?: IdentifierLike): Promise<ShieldedEncryptedNote[]>;
@@ -1,21 +1,23 @@
1
1
  import { GetShieldedEncryptedNotesRequest } from '../../proto/generated/platform.js';
2
- import { verifyShieldedEncryptedNotesProof } from "pshenmic-dpp";
2
+ import { IdentifierWASM, verifyShieldedEncryptedNotesProof } from 'pshenmic-dpp';
3
3
  import { LATEST_PLATFORM_VERSION, SHIELDED_MAX_NOTES_PER_QUERY } from "../constants.js";
4
4
  import { getQuorumPublicKey } from "../utils/getQuorumPublicKey.js";
5
5
  import bytesToHex from "../utils/bytesToHex.js";
6
6
  import verifyTenderdashProof from "../utils/verifyTenderdashProof.js";
7
- export default async function getShieldedEncryptedNotes(grpcPool, startIndex, count) {
7
+ export default async function getShieldedEncryptedNotes(grpcPool, startIndex, count, tokenIdentifier) {
8
+ const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
8
9
  const getShieldedEncryptedNotesRequest = GetShieldedEncryptedNotesRequest.create({
9
10
  version: {
10
11
  oneofKind: 'v0',
11
12
  v0: {
12
13
  startIndex: startIndex.toString(),
13
14
  count,
14
- prove: true
15
+ prove: true,
16
+ tokenId: tokenId?.bytes()
15
17
  }
16
18
  }
17
19
  });
18
- const { response } = await grpcPool.getClient().getShieldedEncryptedNotes(getShieldedEncryptedNotesRequest);
20
+ const { response } = await (await grpcPool.getClient()).getShieldedEncryptedNotes(getShieldedEncryptedNotesRequest);
19
21
  const { version } = response;
20
22
  if (version.oneofKind !== 'v0') {
21
23
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -28,7 +30,7 @@ export default async function getShieldedEncryptedNotes(grpcPool, startIndex, co
28
30
  if (metadata == null) {
29
31
  throw new Error('Metadata not found');
30
32
  }
31
- const { rootHash, notes } = verifyShieldedEncryptedNotesProof(proof.grovedbProof, startIndex, count, SHIELDED_MAX_NOTES_PER_QUERY, true, LATEST_PLATFORM_VERSION);
33
+ const { rootHash, notes } = verifyShieldedEncryptedNotesProof(proof.grovedbProof, startIndex, count, SHIELDED_MAX_NOTES_PER_QUERY, true, LATEST_PLATFORM_VERSION, tokenId);
32
34
  const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
33
35
  const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
34
36
  if (!verify) {
@@ -1,2 +1,3 @@
1
1
  import { GRPCPool } from '../grpcConnectionPool.js';
2
- export default function getShieldedNotesCount(grpcPool: GRPCPool): Promise<bigint | undefined>;
2
+ import { IdentifierLike } from 'pshenmic-dpp';
3
+ export default function getShieldedNotesCount(grpcPool: GRPCPool, tokenIdentifier?: IdentifierLike): Promise<bigint | undefined>;
@@ -1,19 +1,21 @@
1
1
  import { GetShieldedNotesCountRequest } from '../../proto/generated/platform.js';
2
- import { verifyShieldedNotesCountProof } from "pshenmic-dpp";
2
+ import { IdentifierWASM, verifyShieldedNotesCountProof } from 'pshenmic-dpp';
3
3
  import { LATEST_PLATFORM_VERSION } from "../constants.js";
4
4
  import { getQuorumPublicKey } from "../utils/getQuorumPublicKey.js";
5
5
  import bytesToHex from "../utils/bytesToHex.js";
6
6
  import verifyTenderdashProof from "../utils/verifyTenderdashProof.js";
7
- export default async function getShieldedNotesCount(grpcPool) {
7
+ export default async function getShieldedNotesCount(grpcPool, tokenIdentifier) {
8
+ const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
8
9
  const getShieldedNotesCountRequest = GetShieldedNotesCountRequest.create({
9
10
  version: {
10
11
  oneofKind: 'v0',
11
12
  v0: {
12
- prove: true
13
+ prove: true,
14
+ tokenId: tokenId?.bytes()
13
15
  }
14
16
  }
15
17
  });
16
- const { response } = await grpcPool.getClient().getShieldedNotesCount(getShieldedNotesCountRequest);
18
+ const { response } = await (await grpcPool.getClient()).getShieldedNotesCount(getShieldedNotesCountRequest);
17
19
  const { version } = response;
18
20
  if (version.oneofKind !== 'v0') {
19
21
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -26,7 +28,7 @@ export default async function getShieldedNotesCount(grpcPool) {
26
28
  if (metadata == null) {
27
29
  throw new Error('Metadata not found');
28
30
  }
29
- const { rootHash, count } = verifyShieldedNotesCountProof(proof.grovedbProof, true, LATEST_PLATFORM_VERSION);
31
+ const { rootHash, count } = verifyShieldedNotesCountProof(proof.grovedbProof, true, LATEST_PLATFORM_VERSION, tokenId);
30
32
  const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
31
33
  const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
32
34
  if (!verify) {
@@ -1,3 +1,4 @@
1
1
  import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { ShieldedNullifierStatus } from '../../types.js';
3
- export default function getShieldedNullifiers(grpcPool: GRPCPool, nullifiers: Uint8Array[]): Promise<ShieldedNullifierStatus[]>;
3
+ import { IdentifierLike } from 'pshenmic-dpp';
4
+ export default function getShieldedNullifiers(grpcPool: GRPCPool, nullifiers: Uint8Array[], tokenIdentifier?: IdentifierLike): Promise<ShieldedNullifierStatus[]>;
@@ -1,20 +1,22 @@
1
1
  import { GetShieldedNullifiersRequest } from '../../proto/generated/platform.js';
2
- import { verifyShieldedNullifiersProof } from "pshenmic-dpp";
2
+ import { IdentifierWASM, verifyShieldedNullifiersProof } from 'pshenmic-dpp';
3
3
  import { LATEST_PLATFORM_VERSION } from "../constants.js";
4
4
  import { getQuorumPublicKey } from "../utils/getQuorumPublicKey.js";
5
5
  import bytesToHex from "../utils/bytesToHex.js";
6
6
  import verifyTenderdashProof from "../utils/verifyTenderdashProof.js";
7
- export default async function getShieldedNullifiers(grpcPool, nullifiers) {
7
+ export default async function getShieldedNullifiers(grpcPool, nullifiers, tokenIdentifier) {
8
+ const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
8
9
  const getShieldedNullifiersRequest = GetShieldedNullifiersRequest.create({
9
10
  version: {
10
11
  oneofKind: 'v0',
11
12
  v0: {
12
13
  nullifiers,
13
- prove: true
14
+ prove: true,
15
+ tokenId: tokenId?.bytes()
14
16
  }
15
17
  }
16
18
  });
17
- const { response } = await grpcPool.getClient().getShieldedNullifiers(getShieldedNullifiersRequest);
19
+ const { response } = await (await grpcPool.getClient()).getShieldedNullifiers(getShieldedNullifiersRequest);
18
20
  const { version } = response;
19
21
  if (version.oneofKind !== 'v0') {
20
22
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -27,7 +29,7 @@ export default async function getShieldedNullifiers(grpcPool, nullifiers) {
27
29
  if (metadata == null) {
28
30
  throw new Error('Metadata not found');
29
31
  }
30
- const { rootHash, nullifiers: nullifiersStatuses } = verifyShieldedNullifiersProof(proof.grovedbProof, nullifiers, true, LATEST_PLATFORM_VERSION);
32
+ const { rootHash, nullifiers: nullifiersStatuses } = verifyShieldedNullifiersProof(proof.grovedbProof, nullifiers, true, LATEST_PLATFORM_VERSION, tokenId);
31
33
  const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
32
34
  const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
33
35
  if (!verify) {
@@ -1,2 +1,3 @@
1
1
  import { GRPCPool } from '../grpcConnectionPool.js';
2
- export default function getShieldedPoolState(grpcPool: GRPCPool): Promise<bigint | undefined>;
2
+ import { IdentifierLike } from 'pshenmic-dpp';
3
+ export default function getShieldedPoolState(grpcPool: GRPCPool, tokenIdentifier?: IdentifierLike): Promise<bigint | undefined>;
@@ -2,18 +2,20 @@ import { GetShieldedPoolStateRequest } from '../../proto/generated/platform.js';
2
2
  import { getQuorumPublicKey } from "../utils/getQuorumPublicKey.js";
3
3
  import bytesToHex from "../utils/bytesToHex.js";
4
4
  import verifyTenderdashProof from "../utils/verifyTenderdashProof.js";
5
- import { verifyShieldedPoolStateProof } from "pshenmic-dpp";
5
+ import { IdentifierWASM, verifyShieldedPoolStateProof } from 'pshenmic-dpp';
6
6
  import { LATEST_PLATFORM_VERSION } from "../constants.js";
7
- export default async function getShieldedPoolState(grpcPool) {
7
+ export default async function getShieldedPoolState(grpcPool, tokenIdentifier) {
8
+ const tokenId = tokenIdentifier != null ? new IdentifierWASM(tokenIdentifier) : undefined;
8
9
  const getShieldedPoolStateRequest = GetShieldedPoolStateRequest.create({
9
10
  version: {
10
11
  oneofKind: 'v0',
11
12
  v0: {
12
- prove: true
13
+ prove: true,
14
+ tokenId: tokenId?.bytes()
13
15
  }
14
16
  }
15
17
  });
16
- const { response } = await grpcPool.getClient().getShieldedPoolState(getShieldedPoolStateRequest);
18
+ const { response } = await (await grpcPool.getClient()).getShieldedPoolState(getShieldedPoolStateRequest);
17
19
  const { version } = response;
18
20
  if (version.oneofKind !== 'v0') {
19
21
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -26,7 +28,7 @@ export default async function getShieldedPoolState(grpcPool) {
26
28
  if (metadata == null) {
27
29
  throw new Error('Metadata not found');
28
30
  }
29
- const { rootHash, totalBalance } = verifyShieldedPoolStateProof(proof.grovedbProof, true, LATEST_PLATFORM_VERSION);
31
+ const { rootHash, totalBalance } = verifyShieldedPoolStateProof(proof.grovedbProof, true, LATEST_PLATFORM_VERSION, tokenId);
30
32
  const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
31
33
  const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
32
34
  if (!verify) {
@@ -1,6 +1,6 @@
1
1
  import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { ShieldedEncryptedNote, ShieldedNullifierStatus, ShieldedTransitionParamsMap, ShieldedTransitionType } from '../../types.js';
3
- import { RecoveredNoteWASM, ShieldedBuilderWASM, SpendableNoteWASM, StateTransitionWASM } from 'pshenmic-dpp';
3
+ import { IdentifierLike, RecoveredNoteWASM, ShieldedBuilderWASM, SpendableNoteWASM, StateTransitionWASM } from 'pshenmic-dpp';
4
4
  /**
5
5
  * Shielded controller for requesting information about shielded pool
6
6
  *
@@ -33,36 +33,45 @@ export declare class ShieldedController {
33
33
  *
34
34
  * @param startIndex {bigint} - index of the first note to fetch
35
35
  * @param count {number} - amount of notes to fetch
36
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
36
37
  *
37
38
  * @return {Promise<ShieldedEncryptedNote[]>}
38
39
  */
39
- getShieldedEncryptedNotes(startIndex: bigint, count: number): Promise<ShieldedEncryptedNote[]>;
40
+ getShieldedEncryptedNotes(startIndex: bigint, count: number, tokenIdentifier?: IdentifierLike): Promise<ShieldedEncryptedNote[]>;
40
41
  /**
41
42
  * Retrieves the set of valid anchors (note commitment tree roots) currently
42
43
  * accepted by the shielded pool.
43
44
  *
45
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
46
+ *
44
47
  * @return {Promise<Uint8Array[]>}
45
48
  */
46
- getShieldedAnchors(): Promise<Uint8Array[]>;
49
+ getShieldedAnchors(tokenIdentifier?: IdentifierLike): Promise<Uint8Array[]>;
47
50
  /**
48
51
  * Retrieves the most recent anchor (note commitment tree root) of the shielded pool.
49
52
  *
53
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
54
+ *
50
55
  * @return {Promise<Uint8Array>}
51
56
  */
52
- getMostRecentShieldedAnchor(): Promise<Uint8Array | undefined>;
57
+ getMostRecentShieldedAnchor(tokenIdentifier?: IdentifierLike): Promise<Uint8Array | undefined>;
53
58
  /**
54
59
  * Retrieves the total balance currently held in the shielded pool.
55
60
  *
61
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
62
+ *
56
63
  * @return {Promise<bigint>}
57
64
  */
58
- getShieldedPoolState(): Promise<bigint | undefined>;
65
+ getShieldedPoolState(tokenIdentifier?: IdentifierLike): Promise<bigint | undefined>;
59
66
  /**
60
67
  * Retrieves the total count of notes (leaves) in the shielded notes
61
68
  * commitment tree. Useful as a denominator for shielded sync progress.
62
69
  *
70
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
71
+ *
63
72
  * @return {Promise<bigint>}
64
73
  */
65
- getShieldedNotesCount(): Promise<bigint | undefined>;
74
+ getShieldedNotesCount(tokenIdentifier?: IdentifierLike): Promise<bigint | undefined>;
66
75
  /**
67
76
  * Checks the spent status of the given nullifiers in the shielded pool.
68
77
  *
@@ -70,10 +79,11 @@ export declare class ShieldedController {
70
79
  * it has already been spent.
71
80
  *
72
81
  * @param nullifiers {Uint8Array[]} - nullifiers to check
82
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
73
83
  *
74
84
  * @return {Promise<ShieldedNullifierStatus[]>}
75
85
  */
76
- getShieldedNullifiers(nullifiers: Uint8Array[]): Promise<ShieldedNullifierStatus[]>;
86
+ getShieldedNullifiers(nullifiers: Uint8Array[], tokenIdentifier?: IdentifierLike): Promise<ShieldedNullifierStatus[]>;
77
87
  /**
78
88
  * Recovers the notes owned by a wallet from a set of shielded encrypted notes
79
89
  * (as returned by {@link getShieldedEncryptedNotes}) by trial-decrypting each
@@ -49,45 +49,54 @@ export class ShieldedController {
49
49
  *
50
50
  * @param startIndex {bigint} - index of the first note to fetch
51
51
  * @param count {number} - amount of notes to fetch
52
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
52
53
  *
53
54
  * @return {Promise<ShieldedEncryptedNote[]>}
54
55
  */
55
- async getShieldedEncryptedNotes(startIndex, count) {
56
- return await getShieldedEncryptedNotes(this.grpcPool, startIndex, count);
56
+ async getShieldedEncryptedNotes(startIndex, count, tokenIdentifier) {
57
+ return await getShieldedEncryptedNotes(this.grpcPool, startIndex, count, tokenIdentifier);
57
58
  }
58
59
  /**
59
60
  * Retrieves the set of valid anchors (note commitment tree roots) currently
60
61
  * accepted by the shielded pool.
61
62
  *
63
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
64
+ *
62
65
  * @return {Promise<Uint8Array[]>}
63
66
  */
64
- async getShieldedAnchors() {
65
- return await getShieldedAnchors(this.grpcPool);
67
+ async getShieldedAnchors(tokenIdentifier) {
68
+ return await getShieldedAnchors(this.grpcPool, tokenIdentifier);
66
69
  }
67
70
  /**
68
71
  * Retrieves the most recent anchor (note commitment tree root) of the shielded pool.
69
72
  *
73
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
74
+ *
70
75
  * @return {Promise<Uint8Array>}
71
76
  */
72
- async getMostRecentShieldedAnchor() {
73
- return await getMostRecentShieldedAnchor(this.grpcPool);
77
+ async getMostRecentShieldedAnchor(tokenIdentifier) {
78
+ return await getMostRecentShieldedAnchor(this.grpcPool, tokenIdentifier);
74
79
  }
75
80
  /**
76
81
  * Retrieves the total balance currently held in the shielded pool.
77
82
  *
83
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
84
+ *
78
85
  * @return {Promise<bigint>}
79
86
  */
80
- async getShieldedPoolState() {
81
- return await getShieldedPoolState(this.grpcPool);
87
+ async getShieldedPoolState(tokenIdentifier) {
88
+ return await getShieldedPoolState(this.grpcPool, tokenIdentifier);
82
89
  }
83
90
  /**
84
91
  * Retrieves the total count of notes (leaves) in the shielded notes
85
92
  * commitment tree. Useful as a denominator for shielded sync progress.
86
93
  *
94
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
95
+ *
87
96
  * @return {Promise<bigint>}
88
97
  */
89
- async getShieldedNotesCount() {
90
- return await getShieldedNotesCount(this.grpcPool);
98
+ async getShieldedNotesCount(tokenIdentifier) {
99
+ return await getShieldedNotesCount(this.grpcPool, tokenIdentifier);
91
100
  }
92
101
  /**
93
102
  * Checks the spent status of the given nullifiers in the shielded pool.
@@ -96,11 +105,12 @@ export class ShieldedController {
96
105
  * it has already been spent.
97
106
  *
98
107
  * @param nullifiers {Uint8Array[]} - nullifiers to check
108
+ * @param tokenIdentifier {IdentifierLike=} - token id to query the token shielded pool instead of the credits pool
99
109
  *
100
110
  * @return {Promise<ShieldedNullifierStatus[]>}
101
111
  */
102
- async getShieldedNullifiers(nullifiers) {
103
- return await getShieldedNullifiers(this.grpcPool, nullifiers);
112
+ async getShieldedNullifiers(nullifiers, tokenIdentifier) {
113
+ return await getShieldedNullifiers(this.grpcPool, nullifiers, tokenIdentifier);
104
114
  }
105
115
  /**
106
116
  * Recovers the notes owned by a wallet from a set of shielded encrypted notes
@@ -8,7 +8,7 @@ export default async function broadcast(grpcPool, stateTransition) {
8
8
  const broadcastStateTransitionRequest = BroadcastStateTransitionRequest.create({
9
9
  stateTransition: stateTransition.bytes()
10
10
  });
11
- await grpcPool.getClient().broadcastStateTransition(broadcastStateTransitionRequest);
11
+ await (await grpcPool.getClient()).broadcastStateTransition(broadcastStateTransitionRequest);
12
12
  }
13
13
  catch (err) {
14
14
  const errorBin = err.meta?.['dash-serialized-consensus-error-bin'];
@@ -20,9 +20,13 @@ export declare class StateTransitionsController {
20
20
  /**
21
21
  * Waits for a given state transition to finalize in the network (usually 1-3 sec)
22
22
  *
23
+ * Returns the owner's credit balance after the transition executed, if the proof
24
+ * carries it (protocol v14+ owned, fee-paying transitions: document and token batches,
25
+ * contract create and update, identity update), otherwise undefined
26
+ *
23
27
  * @param stateTransition {StateTransitionWASM}
24
28
  *
25
- * @return {Promise<void>}
29
+ * @return {Promise<bigint | undefined>}
26
30
  */
27
- waitForStateTransitionResult(stateTransition: StateTransitionWASM): Promise<void>;
31
+ waitForStateTransitionResult(stateTransition: StateTransitionWASM): Promise<bigint | undefined>;
28
32
  }
@@ -24,9 +24,13 @@ export class StateTransitionsController {
24
24
  /**
25
25
  * Waits for a given state transition to finalize in the network (usually 1-3 sec)
26
26
  *
27
+ * Returns the owner's credit balance after the transition executed, if the proof
28
+ * carries it (protocol v14+ owned, fee-paying transitions: document and token batches,
29
+ * contract create and update, identity update), otherwise undefined
30
+ *
27
31
  * @param stateTransition {StateTransitionWASM}
28
32
  *
29
- * @return {Promise<void>}
33
+ * @return {Promise<bigint | undefined>}
30
34
  */
31
35
  async waitForStateTransitionResult(stateTransition) {
32
36
  return await waitForStateTransitionResult(this.grpcPool, stateTransition);
@@ -1,3 +1,3 @@
1
1
  import { StateTransitionWASM } from 'pshenmic-dpp';
2
2
  import { GRPCPool } from '../grpcConnectionPool.js';
3
- export default function waitForStateTransitionResult(grpcPool: GRPCPool, stateTransition: StateTransitionWASM): Promise<void>;
3
+ export default function waitForStateTransitionResult(grpcPool: GRPCPool, stateTransition: StateTransitionWASM): Promise<bigint | undefined>;