dash-platform-sdk 1.3.0-dev.9 → 1.4.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/bundle.min.js +17 -17
  2. package/package.json +2 -5
  3. package/proto/generated/platform.client.d.ts +10 -0
  4. package/proto/generated/platform.client.js +7 -0
  5. package/proto/generated/platform.d.ts +114 -0
  6. package/proto/generated/platform.js +224 -1
  7. package/src/DashPlatformSDK.d.ts +1 -5
  8. package/src/DashPlatformSDK.js +0 -5
  9. package/src/constants.d.ts +2 -0
  10. package/src/constants.js +1 -0
  11. package/src/contestedResources/getContestedResourceVoteState.d.ts +1 -1
  12. package/src/contestedResources/getContestedResourceVoteState.js +10 -5
  13. package/src/contestedResources/index.d.ts +1 -1
  14. package/src/dataContracts/create.d.ts +3 -3
  15. package/src/dataContracts/create.js +3 -2
  16. package/src/dataContracts/createStateTransition.js +0 -1
  17. package/src/dataContracts/getDataContractByIdentifier.d.ts +1 -1
  18. package/src/dataContracts/getDataContractByIdentifier.js +3 -3
  19. package/src/dataContracts/index.d.ts +3 -3
  20. package/src/documents/create.d.ts +1 -1
  21. package/src/documents/create.js +1 -1
  22. package/src/documents/createStateTransition.d.ts +1 -1
  23. package/src/documents/index.d.ts +3 -3
  24. package/src/documents/query.d.ts +3 -3
  25. package/src/documents/query.js +3 -3
  26. package/src/grpcConnectionPool.d.ts +1 -1
  27. package/src/identities/createStateTransition.d.ts +1 -1
  28. package/src/identities/getIdentityBalance.d.ts +1 -1
  29. package/src/identities/getIdentityBalance.js +3 -2
  30. package/src/identities/getIdentityByIdentifier.d.ts +1 -1
  31. package/src/identities/getIdentityByIdentifier.js +3 -2
  32. package/src/identities/getIdentityByNonUniquePublicKeyHash.js +3 -2
  33. package/src/identities/getIdentityByPublicKeyHash.js +3 -2
  34. package/src/identities/getIdentityContractNonce.d.ts +1 -1
  35. package/src/identities/getIdentityContractNonce.js +3 -2
  36. package/src/identities/getIdentityNonce.d.ts +1 -1
  37. package/src/identities/getIdentityNonce.js +3 -2
  38. package/src/identities/getIdentityPublicKeys.d.ts +2 -2
  39. package/src/identities/getIdentityPublicKeys.js +19 -9
  40. package/src/identities/index.d.ts +4 -3
  41. package/src/identities/index.js +6 -6
  42. package/src/keyPair/index.d.ts +1 -1
  43. package/src/names/index.d.ts +1 -1
  44. package/src/node/epochs.js +3 -2
  45. package/src/node/index.d.ts +1 -1
  46. package/src/node/status.d.ts +1 -1
  47. package/src/node/totalCredits.d.ts +1 -1
  48. package/src/node/totalCredits.js +3 -3
  49. package/src/stateTransitions/broadcast.js +1 -1
  50. package/src/stateTransitions/waitForStateTransitionResult.js +68 -5
  51. package/src/tokens/createStateTransition.d.ts +1 -1
  52. package/src/tokens/getIdentitiesTokenBalances.d.ts +2 -2
  53. package/src/tokens/getIdentitiesTokenBalances.js +6 -5
  54. package/src/tokens/getIdentityTokensBalances.d.ts +2 -2
  55. package/src/tokens/getIdentityTokensBalances.js +6 -5
  56. package/src/tokens/getTokenContractInfo.d.ts +1 -1
  57. package/src/tokens/getTokenContractInfo.js +3 -2
  58. package/src/tokens/getTokenDirectPurchasePrices.d.ts +1 -1
  59. package/src/tokens/getTokenDirectPurchasePrices.js +3 -2
  60. package/src/tokens/getTokenTotalSupply.d.ts +1 -1
  61. package/src/tokens/getTokenTotalSupply.js +3 -2
  62. package/src/tokens/index.d.ts +1 -1
  63. package/src/utils/getEvonodeList.d.ts +1 -1
  64. package/src/utils/index.d.ts +8 -0
  65. package/src/utils/index.js +17 -0
  66. package/src/voting/index.d.ts +1 -1
  67. package/test/unit/ContestedResources.spec.js +5 -3
  68. package/test/unit/DataContract.spec.js +4 -3
  69. package/test/unit/Document.spec.js +2 -2
  70. package/test/unit/Identity.spec.js +27 -27
  71. package/test/unit/Names.spec.js +2 -0
  72. package/test/unit/Tokens.spec.js +3 -3
  73. package/{src/types.d.ts → types.d.ts} +8 -7
  74. package/{src/types.js → types.js} +2 -2
  75. package/src/signer/AbstractSigner.d.ts +0 -12
  76. package/src/signer/AbstractSigner.js +0 -1
  77. package/src/signer/PrivateKeySigner.d.ts +0 -1
  78. package/src/signer/PrivateKeySigner.js +0 -65
  79. package/src/signer/setSigner.d.ts +0 -2
  80. package/src/signer/setSigner.js +0 -5
@@ -1,8 +1,8 @@
1
1
  import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- import { IdentifierLike } from '../types.js';
2
+ import { IdentifierLike } from '../../types.js';
3
3
  import { IdentifierWASM } from 'pshenmic-dpp';
4
4
  export interface IdentityTokenBalances {
5
5
  tokenId: IdentifierWASM;
6
- balance?: string | undefined;
6
+ balance?: bigint | undefined;
7
7
  }
8
8
  export default function getIdentityTokensBalances(grpcPool: GRPCConnectionPool, identifier: IdentifierLike, tokenIdentifiers: IdentifierLike[]): Promise<IdentityTokenBalances[]>;
@@ -1,8 +1,9 @@
1
- import { IdentifierWASM, PlatformVersionWASM, verifyTokensBalancesForIdentityProof } from 'pshenmic-dpp';
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,15 +30,15 @@ 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, PlatformVersionWASM.PLATFORM_V9);
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) {
36
37
  throw new Error('Failed to verify query');
37
38
  }
38
39
  return balances
39
- .map((tokenBalance) => ({
40
- tokenId: new IdentifierWASM(tokenBalance.tokenId),
41
- balance: tokenBalance.balance
40
+ .map(({ id, balance }) => ({
41
+ tokenId: new IdentifierWASM(id),
42
+ balance
42
43
  }));
43
44
  }
@@ -1,5 +1,5 @@
1
1
  import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- import { IdentifierLike } from '../types.js';
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, PlatformVersionWASM, verifyTokenContractInfoProof } from 'pshenmic-dpp';
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, PlatformVersionWASM.PLATFORM_V9);
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 '../types.js';
2
+ import { IdentifierLike, TokenDirectPurchasePrices } from '../../types.js';
3
3
  export default function getTokenDirectPurchasePrices(grpcPool: GRPCConnectionPool, tokenIdentifiers: IdentifierLike[]): Promise<TokenDirectPurchasePrices[]>;
@@ -1,8 +1,9 @@
1
- import { IdentifierWASM, PlatformVersionWASM, verifyTokenDirectPurchasePrices } from 'pshenmic-dpp';
1
+ import { IdentifierWASM, verifyTokenDirectPurchasePrices } from 'pshenmic-dpp';
2
2
  import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
3
3
  import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
4
4
  import bytesToHex from '../utils/bytesToHex.js';
5
5
  import { GetTokenDirectPurchasePricesRequest } from '../../proto/generated/platform.js';
6
+ import { LATEST_PLATFORM_VERSION } from '../constants.js';
6
7
  export default async function getTokenDirectPurchasePrices(grpcPool, tokenIdentifiers) {
7
8
  const tokenIds = tokenIdentifiers.map(tokenId => new IdentifierWASM(tokenId).bytes());
8
9
  const request = GetTokenDirectPurchasePricesRequest.create({
@@ -27,7 +28,7 @@ export default async function getTokenDirectPurchasePrices(grpcPool, tokenIdenti
27
28
  if (metadata == null) {
28
29
  throw new Error('Metadata not found');
29
30
  }
30
- const { rootHash, prices } = verifyTokenDirectPurchasePrices(proof.grovedbProof, tokenIds, true, PlatformVersionWASM.PLATFORM_V9);
31
+ const { rootHash, prices } = verifyTokenDirectPurchasePrices(proof.grovedbProof, tokenIds, true, LATEST_PLATFORM_VERSION);
31
32
  if (prices == null) {
32
33
  throw new Error('Prices not found');
33
34
  }
@@ -1,3 +1,3 @@
1
1
  import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- import { IdentifierLike, TokenTotalSupply } from '../types.js';
2
+ import { IdentifierLike, TokenTotalSupply } from '../../types.js';
3
3
  export default function getTokenTotalSupply(grpcPool: GRPCConnectionPool, tokenIdentifier: IdentifierLike): Promise<TokenTotalSupply>;
@@ -1,8 +1,9 @@
1
1
  import { GetTokenTotalSupplyRequest } from '../../proto/generated/platform.js';
2
- import { IdentifierWASM, PlatformVersionWASM, verifyTokenTotalSupplyProof } from 'pshenmic-dpp';
2
+ import { IdentifierWASM, verifyTokenTotalSupplyProof } 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 getTokenTotalSupply(grpcPool, tokenIdentifier) {
7
8
  const tokenId = new IdentifierWASM(tokenIdentifier);
8
9
  const getTokenTotalSupplyRequest = GetTokenTotalSupplyRequest.create({
@@ -27,7 +28,7 @@ export default async function getTokenTotalSupply(grpcPool, tokenIdentifier) {
27
28
  if (metadata == null) {
28
29
  throw new Error('Metadata not found');
29
30
  }
30
- const { rootHash, totalBalance } = verifyTokenTotalSupplyProof(proof.grovedbProof, tokenId, true, PlatformVersionWASM.PLATFORM_V9);
31
+ const { rootHash, totalBalance } = verifyTokenTotalSupplyProof(proof.grovedbProof, tokenId, true, LATEST_PLATFORM_VERSION);
31
32
  const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
32
33
  const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
33
34
  if (!verify) {
@@ -1,5 +1,5 @@
1
1
  import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- import { IdentifierLike, TokenDirectPurchasePrices, TokenTotalSupply, TokenTransitionParams, TokenTransitionType } from '../types.js';
2
+ import { IdentifierLike, TokenDirectPurchasePrices, TokenTotalSupply, TokenTransitionParams, TokenTransitionType } from '../../types.js';
3
3
  import { IdentitiesTokenBalances } from './getIdentitiesTokenBalances.js';
4
4
  import { IdentityTokenBalances } from './getIdentityTokensBalances.js';
5
5
  import { TokenContractInfo } from './getTokenContractInfo.js';
@@ -1,2 +1,2 @@
1
- import { MasternodeList, Network } from '../types.js';
1
+ import { MasternodeList, Network } from '../../types.js';
2
2
  export default function getDAPINodeList(network: Network): Promise<MasternodeList>;
@@ -1,4 +1,5 @@
1
1
  import { IdentifierWASM } from 'pshenmic-dpp';
2
+ import { IdentifierLike } from '../../types.js';
2
3
  /**
3
4
  * Collection of conversion functions
4
5
  *
@@ -62,4 +63,11 @@ export declare class UtilsController {
62
63
  * @return {string}
63
64
  * */
64
65
  createMasternodeIdentifier(proTxHash: string): IdentifierWASM;
66
+ /**
67
+ * Validates an identifier, accepts string or buffer
68
+ *
69
+ * @param identifier {IdentifierLike} identifier to test
70
+ * @return {boolean}
71
+ * */
72
+ validateIdentifier(identifier: IdentifierLike): boolean;
65
73
  }
@@ -3,6 +3,7 @@ import { base58 } from '@scure/base';
3
3
  import hexToBytes from './hexToBytes.js';
4
4
  import bytesToHex from './bytesToHex.js';
5
5
  import { createVoterIdentityId } from './createVoterIdentityId.js';
6
+ import { IdentifierWASM } from 'pshenmic-dpp';
6
7
  import { createMasternodeIdentityId } from './createMasternodeIdentityId.js';
7
8
  /**
8
9
  * Collection of conversion functions
@@ -81,4 +82,20 @@ export class UtilsController {
81
82
  createMasternodeIdentifier(proTxHash) {
82
83
  return createMasternodeIdentityId(proTxHash);
83
84
  }
85
+ /**
86
+ * Validates an identifier, accepts string or buffer
87
+ *
88
+ * @param identifier {IdentifierLike} identifier to test
89
+ * @return {boolean}
90
+ * */
91
+ validateIdentifier(identifier) {
92
+ try {
93
+ // eslint-disable-next-line
94
+ new IdentifierWASM(identifier);
95
+ return true;
96
+ }
97
+ catch (e) {
98
+ return false;
99
+ }
100
+ }
84
101
  }
@@ -1,4 +1,4 @@
1
- import { IdentifierLike, ResourceVoteChoice } from '../types.js';
1
+ import { IdentifierLike, ResourceVoteChoice } from '../../types.js';
2
2
  import { IdentifierWASM, StateTransitionWASM, VoteWASM } from 'pshenmic-dpp';
3
3
  /**
4
4
  * Voting controller for performing masternode votes
@@ -1,6 +1,7 @@
1
- import { DataContractWASM, PlatformVersionWASM, PrivateKeyWASM } from 'pshenmic-dpp';
2
- import { DashPlatformSDK, ContestedStateResultType } from '../../src/types.js';
1
+ import { DataContractWASM, PrivateKeyWASM } from 'pshenmic-dpp';
2
+ import { DashPlatformSDK, ContestedStateResultType } from '../../types.js';
3
3
  import stringToIndexValueBytes from '../../src/utils/stringToIndexValueBytes.js';
4
+ import { LATEST_PLATFORM_VERSION } from '../../src/constants.js';
4
5
  let sdk;
5
6
  let contract;
6
7
  describe('Contested Resources', () => {
@@ -171,7 +172,7 @@ describe('Contested Resources', () => {
171
172
  documentsMutable: false,
172
173
  additionalProperties: false
173
174
  }
174
- }, undefined, undefined, true, PlatformVersionWASM.PLATFORM_V9);
175
+ }, undefined, undefined, true, LATEST_PLATFORM_VERSION);
175
176
  contract.id = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
176
177
  });
177
178
  test('should be able to get contested resource vote state with finishedVoteInfo', async () => {
@@ -184,6 +185,7 @@ describe('Contested Resources', () => {
184
185
  expect(voteState.contenders.length).toBeGreaterThan(0);
185
186
  expect(voteState.abstainVoteTally).toBeDefined();
186
187
  expect(voteState.lockVoteTally).toBeDefined();
188
+ expect(voteState.skipped).toBeDefined();
187
189
  });
188
190
  test('should be able to get contested resource vote state for incorrect values', async () => {
189
191
  try {
@@ -1,5 +1,5 @@
1
1
  import { DataContractWASM, StateTransitionWASM } from 'pshenmic-dpp';
2
- import { DashPlatformSDK } from '../../src/types.js';
2
+ import { DashPlatformSDK } from '../../types.js';
3
3
  let sdk;
4
4
  let ownerIdentifier;
5
5
  let identityNonce;
@@ -11,7 +11,7 @@ describe('DataContract', () => {
11
11
  ownerIdentifier = 'GARSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
12
12
  identityNonce = BigInt(11);
13
13
  config = {
14
- $format_version: '0',
14
+ $format_version: '1',
15
15
  canBeDeleted: true,
16
16
  readonly: true,
17
17
  keepsHistory: false,
@@ -19,7 +19,8 @@ describe('DataContract', () => {
19
19
  documentsMutableContractDefault: false,
20
20
  documentsCanBeDeletedContractDefault: true,
21
21
  requiresIdentityEncryptionBoundedKey: null,
22
- requiresIdentityDecryptionBoundedKey: null
22
+ requiresIdentityDecryptionBoundedKey: null,
23
+ sizedIntegerTypes: true
23
24
  };
24
25
  schema = {
25
26
  note: {
@@ -1,4 +1,4 @@
1
- import { DocumentWASM, GasFeesPaidByWASM, StateTransitionWASM } from 'pshenmic-dpp';
1
+ import { DocumentWASM, StateTransitionWASM } from 'pshenmic-dpp';
2
2
  import { DashPlatformSDK } from '../../src/DashPlatformSDK.js';
3
3
  let sdk;
4
4
  let dataContract;
@@ -67,7 +67,7 @@ describe('Document', () => {
67
67
  tokenContractPosition: 0,
68
68
  minimumTokenCost: BigInt(1000),
69
69
  maximumTokenCost: BigInt(100000),
70
- gasFeesPaidBy: GasFeesPaidByWASM.ContractOwner
70
+ gasFeesPaidBy: 1 /* GasFeesPaidByWASM.ContractOwner */
71
71
  };
72
72
  const stateTransition = sdk.documents.createStateTransition(document, 'create', { identityContractNonce, tokenPaymentInfo });
73
73
  expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
@@ -1,5 +1,5 @@
1
- import { CoreScriptWASM, IdentityPublicKeyWASM, IdentityWASM, KeyType, PrivateKeyWASM, Purpose, SecurityLevel, StateTransitionWASM } from 'pshenmic-dpp';
2
- import { DashPlatformSDK } from '../../src/types.js';
1
+ import { CoreScriptWASM, IdentityPublicKeyWASM, IdentityWASM, PrivateKeyWASM, StateTransitionWASM } from 'pshenmic-dpp';
2
+ import { DashPlatformSDK } from '../../types.js';
3
3
  import { base58 } from '@scure/base';
4
4
  let sdk;
5
5
  describe('Identity', () => {
@@ -50,18 +50,18 @@ describe('Identity', () => {
50
50
  const privateKey1 = PrivateKeyWASM.fromHex('a1286dd195e2b8e1f6bdc946c56a53e0c544750d6452ddc0f4c593ef311f21af', 'testnet');
51
51
  const identityPublicKeyInCreation1 = {
52
52
  id: 0,
53
- purpose: Purpose.AUTHENTICATION,
54
- securityLevel: SecurityLevel.MASTER,
55
- keyType: KeyType.ECDSA_SECP256K1,
53
+ purpose: 0 /* Purpose.AUTHENTICATION */,
54
+ securityLevel: 0 /* SecurityLevel.MASTER */,
55
+ keyType: 0 /* KeyType.ECDSA_SECP256K1 */,
56
56
  readOnly: false,
57
57
  data: privateKey1.getPublicKey().bytes()
58
58
  };
59
59
  const privateKey2 = PrivateKeyWASM.fromHex('44a8195e242364b935e9d7ff2106ed109e9baf3800907f5e58a259fdfd1ca5e5', 'testnet');
60
60
  const identityPublicKeyInCreation2 = {
61
61
  id: 1,
62
- purpose: Purpose.AUTHENTICATION,
63
- securityLevel: SecurityLevel.HIGH,
64
- keyType: KeyType.ECDSA_SECP256K1,
62
+ purpose: 0 /* Purpose.AUTHENTICATION */,
63
+ securityLevel: 2 /* SecurityLevel.HIGH */,
64
+ keyType: 0 /* KeyType.ECDSA_SECP256K1 */,
65
65
  readOnly: false,
66
66
  data: privateKey2.getPublicKey().bytes()
67
67
  };
@@ -76,7 +76,7 @@ describe('Identity', () => {
76
76
  type: 'chainLock'
77
77
  }
78
78
  });
79
- identityCreateStateTransition.signByPrivateKey(privateKey1, KeyType.ECDSA_SECP256K1);
79
+ identityCreateStateTransition.signByPrivateKey(privateKey1, 0 /* KeyType.ECDSA_SECP256K1 */);
80
80
  identityPublicKeyInCreation1.signature = identityCreateStateTransition.signature;
81
81
  // Set identity public key signature for public key 1
82
82
  identityCreateStateTransition = sdk.identities.createStateTransition('create', {
@@ -88,7 +88,7 @@ describe('Identity', () => {
88
88
  type: 'chainLock'
89
89
  }
90
90
  });
91
- identityCreateStateTransition.signByPrivateKey(privateKey2, KeyType.ECDSA_SECP256K1);
91
+ identityCreateStateTransition.signByPrivateKey(privateKey2, 0 /* KeyType.ECDSA_SECP256K1 */);
92
92
  identityPublicKeyInCreation2.signature = identityCreateStateTransition.signature;
93
93
  // Finalize
94
94
  identityCreateStateTransition = sdk.identities.createStateTransition('create', {
@@ -100,7 +100,7 @@ describe('Identity', () => {
100
100
  type: 'chainLock'
101
101
  }
102
102
  });
103
- identityCreateStateTransition.signByPrivateKey(assetLockPrivateKey, KeyType.ECDSA_SECP256K1);
103
+ identityCreateStateTransition.signByPrivateKey(assetLockPrivateKey, 0 /* KeyType.ECDSA_SECP256K1 */);
104
104
  });
105
105
  test('should be able to create IdentityCreateTransition via InstantSend', async () => {
106
106
  const assetLockPrivateKey = PrivateKeyWASM.fromHex('edd04a71bddb31e530f6c2314fd42ada333f6656bb853ece13f0577a8fd30612', 'testnet');
@@ -110,18 +110,18 @@ describe('Identity', () => {
110
110
  const privateKey1 = PrivateKeyWASM.fromHex('a1286dd195e2b8e1f6bdc946c56a53e0c544750d6452ddc0f4c593ef311f21af', 'testnet');
111
111
  const identityPublicKeyInCreation1 = {
112
112
  id: 0,
113
- purpose: Purpose.AUTHENTICATION,
114
- securityLevel: SecurityLevel.MASTER,
115
- keyType: KeyType.ECDSA_SECP256K1,
113
+ purpose: 0 /* Purpose.AUTHENTICATION */,
114
+ securityLevel: 0 /* SecurityLevel.MASTER */,
115
+ keyType: 0 /* KeyType.ECDSA_SECP256K1 */,
116
116
  readOnly: false,
117
117
  data: privateKey1.getPublicKey().bytes()
118
118
  };
119
119
  const privateKey2 = PrivateKeyWASM.fromHex('44a8195e242364b935e9d7ff2106ed109e9baf3800907f5e58a259fdfd1ca5e5', 'testnet');
120
120
  const identityPublicKeyInCreation2 = {
121
121
  id: 1,
122
- purpose: Purpose.AUTHENTICATION,
123
- securityLevel: SecurityLevel.HIGH,
124
- keyType: KeyType.ECDSA_SECP256K1,
122
+ purpose: 0 /* Purpose.AUTHENTICATION */,
123
+ securityLevel: 2 /* SecurityLevel.HIGH */,
124
+ keyType: 0 /* KeyType.ECDSA_SECP256K1 */,
125
125
  readOnly: false,
126
126
  data: privateKey2.getPublicKey().bytes()
127
127
  };
@@ -136,7 +136,7 @@ describe('Identity', () => {
136
136
  type: 'instantLock'
137
137
  }
138
138
  });
139
- identityCreateStateTransition.signByPrivateKey(privateKey1, KeyType.ECDSA_SECP256K1);
139
+ identityCreateStateTransition.signByPrivateKey(privateKey1, 0 /* KeyType.ECDSA_SECP256K1 */);
140
140
  identityPublicKeyInCreation1.signature = identityCreateStateTransition.signature;
141
141
  // Set identity public key signature for public key 1
142
142
  identityCreateStateTransition = sdk.identities.createStateTransition('create', {
@@ -148,7 +148,7 @@ describe('Identity', () => {
148
148
  type: 'instantLock'
149
149
  }
150
150
  });
151
- identityCreateStateTransition.signByPrivateKey(privateKey2, KeyType.ECDSA_SECP256K1);
151
+ identityCreateStateTransition.signByPrivateKey(privateKey2, 0 /* KeyType.ECDSA_SECP256K1 */);
152
152
  identityPublicKeyInCreation2.signature = identityCreateStateTransition.signature;
153
153
  // Finalize
154
154
  identityCreateStateTransition = sdk.identities.createStateTransition('create', {
@@ -160,7 +160,7 @@ describe('Identity', () => {
160
160
  type: 'instantLock'
161
161
  }
162
162
  });
163
- identityCreateStateTransition.signByPrivateKey(assetLockPrivateKey, KeyType.ECDSA_SECP256K1);
163
+ identityCreateStateTransition.signByPrivateKey(assetLockPrivateKey, 0 /* KeyType.ECDSA_SECP256K1 */);
164
164
  });
165
165
  test('should be able to create IdentityTopUpTransition via InstantSend', async () => {
166
166
  const transaction = '03000800011a468e6a7cf1c5111b09b7bca6743f2571a9bf13d2ff6d21d3d230fd1dea1e97000000006b483045022100fceb25c45e77e1a273660e4f4c9a09042fb858a57704806e14bf80a734af232a02201929893dd720cf5855e31dda577cda16df29520a9774b4f3e813a4cc468fe086012103e16ede6dc5c99f28e3a5733f47a7494992bc6ce4f98551c092645910b9888b8fffffffff0200e1f50500000000026a004054fa02000000001976a91416bbe230f46eea86fc4bf4dd550be45dc9adfcb488ac0000000024010100e1f505000000001976a9147f78813975a3282e09e284d97d93c083b202e34188ac';
@@ -177,7 +177,7 @@ describe('Identity', () => {
177
177
  type: 'instantLock'
178
178
  }
179
179
  });
180
- identityTopUpTransaction.signByPrivateKey(assetLockPrivateKey, undefined, KeyType.ECDSA_SECP256K1);
180
+ identityTopUpTransaction.signByPrivateKey(assetLockPrivateKey, undefined, 0 /* KeyType.ECDSA_SECP256K1 */);
181
181
  });
182
182
  test('should be able to create IdentityTopUpTransition via ChainLock', async () => {
183
183
  const txid = '61aede830477254876d435a317241ad46753c4b1350dc991a45ebcf19ab80a11';
@@ -194,7 +194,7 @@ describe('Identity', () => {
194
194
  type: 'chainLock'
195
195
  }
196
196
  });
197
- identityTopUpTransaction.signByPrivateKey(assetLockPrivateKey, undefined, KeyType.ECDSA_SECP256K1);
197
+ identityTopUpTransaction.signByPrivateKey(assetLockPrivateKey, undefined, 0 /* KeyType.ECDSA_SECP256K1 */);
198
198
  });
199
199
  test('should be able to create IdentityUpdateTransition', async () => {
200
200
  const identityId = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
@@ -207,9 +207,9 @@ describe('Identity', () => {
207
207
  const identityPrivateKey = PrivateKeyWASM.fromHex('16f614c6242580628d849e3616491dda1eccce99642a85667eb9a364dc85324a', 'testnet');
208
208
  const identityPublicKeyInCreation = {
209
209
  id: keyId,
210
- purpose: Purpose.AUTHENTICATION,
211
- securityLevel: SecurityLevel.HIGH,
212
- keyType: KeyType.ECDSA_SECP256K1,
210
+ purpose: 0 /* Purpose.AUTHENTICATION */,
211
+ securityLevel: 2 /* SecurityLevel.HIGH */,
212
+ keyType: 0 /* KeyType.ECDSA_SECP256K1 */,
213
213
  readOnly: false,
214
214
  data: identityPrivateKey.getPublicKey().bytes()
215
215
  };
@@ -219,7 +219,7 @@ describe('Identity', () => {
219
219
  identityNonce,
220
220
  addPublicKeys: [identityPublicKeyInCreation]
221
221
  });
222
- identityUpdateTransition.signByPrivateKey(masterPrivateKey, masterKeyId, KeyType.ECDSA_SECP256K1);
222
+ identityUpdateTransition.signByPrivateKey(masterPrivateKey, masterKeyId, 0 /* KeyType.ECDSA_SECP256K1 */);
223
223
  identityPublicKeyInCreation.signature = identityUpdateTransition.signature;
224
224
  identityUpdateTransition = sdk.identities.createStateTransition('update', {
225
225
  identityId,
@@ -227,7 +227,7 @@ describe('Identity', () => {
227
227
  identityNonce,
228
228
  addPublicKeys: [identityPublicKeyInCreation]
229
229
  });
230
- identityUpdateTransition.signByPrivateKey(masterPrivateKey, masterKeyId, KeyType.ECDSA_SECP256K1);
230
+ identityUpdateTransition.signByPrivateKey(masterPrivateKey, masterKeyId, 0 /* KeyType.ECDSA_SECP256K1 */);
231
231
  });
232
232
  test('should able be create credit transfer transition', async () => {
233
233
  const identityId = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
@@ -2,6 +2,7 @@ import broadcast from '../../src/stateTransitions/broadcast.js';
2
2
  import { DocumentWASM, PrivateKeyWASM } from 'pshenmic-dpp';
3
3
  import { DashPlatformSDK } from '../../src/DashPlatformSDK.js';
4
4
  import sleep from '../../src/utils/sleep.js';
5
+ jest.mock('../../src/stateTransitions/waitForStateTransitionResult');
5
6
  jest.mock('../../src/stateTransitions/broadcast');
6
7
  jest.mock('../../src/utils/sleep');
7
8
  let sdk;
@@ -11,6 +12,7 @@ describe('DPNS names', () => {
11
12
  // @ts-expect-error
12
13
  sleep.mockReturnValue(Promise.resolve());
13
14
  sdk.stateTransitions.broadcast = jest.fn();
15
+ sdk.stateTransitions.waitForStateTransitionResult = jest.fn();
14
16
  });
15
17
  test('should be able to search names by DPNS name', async () => {
16
18
  const documents = await sdk.names.searchByName('xyz.dash');
@@ -1,4 +1,4 @@
1
- import { StateTransitionWASM, TokenBaseTransitionWASM, TokenEmergencyActionWASM } from 'pshenmic-dpp';
1
+ import { StateTransitionWASM, TokenBaseTransitionWASM } from 'pshenmic-dpp';
2
2
  import { DashPlatformSDK } from '../../src/DashPlatformSDK.js';
3
3
  let sdk;
4
4
  describe('Tokens', () => {
@@ -29,7 +29,7 @@ describe('Tokens', () => {
29
29
  ]);
30
30
  expect(tokensPrices.length).toEqual(2);
31
31
  expect(tokensPrices[0].tokenId).toBeTruthy();
32
- expect(tokensPrices[0].price).toBeTruthy();
32
+ expect(tokensPrices[0].pricingSchedule).toBeTruthy();
33
33
  });
34
34
  test('should be able to get tokens direct purchase prices', async () => {
35
35
  const tokensIdentityBalance = await sdk.tokens.getIdentitiesTokenBalances(['8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc'], '9YxdbQUjJmQsmVPen95HjAU3Esj7tVkWSY2EQWT84ZQP');
@@ -95,7 +95,7 @@ describe('Tokens', () => {
95
95
  test('should be able to create emergency action transition', async () => {
96
96
  const tokenId = '6niNoQpsT9zyVDJtXcbpV3tR3qEGi6BC6xoDdJyx1u7C';
97
97
  const owner = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
98
- const emergencyAction = TokenEmergencyActionWASM.Pause;
98
+ const emergencyAction = 0 /* TokenEmergencyActionWASM.Pause */;
99
99
  const tokenBaseTransition = await sdk.tokens.createBaseTransition(tokenId, owner);
100
100
  const stateTransition = sdk.tokens.createStateTransition(tokenBaseTransition, owner, 'emergencyAction', { emergencyAction });
101
101
  expect(stateTransition).toBeInstanceOf(StateTransitionWASM);
@@ -1,10 +1,9 @@
1
1
  import { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM } from 'pshenmic-dpp';
2
- export { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM } from 'pshenmic-dpp';
2
+ export { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM, StateTransitionWASM, BatchTransitionWASM, IdentityPublicKeyWASM, PrivateKeyWASM, DataContractUpdateTransitionWASM, IdentityWASM, IdentityUpdateTransitionWASM, IdentityCreditTransferWASM, MasternodeVoteTransitionWASM } from 'pshenmic-dpp';
3
3
  export type IdentifierLike = IdentifierWASM | string | Uint8Array;
4
4
  export type Network = 'mainnet' | 'testnet';
5
- export { DashPlatformSDK } from './DashPlatformSDK.js';
5
+ export { DashPlatformSDK } from './src/DashPlatformSDK.js';
6
6
  export type MasternodeList = Record<string, MasternodeInfo>;
7
- export { AbstractSigner } from './signer/AbstractSigner.js';
8
7
  export interface DocumentTransitionParams {
9
8
  identityContractNonce: bigint;
10
9
  amount?: bigint;
@@ -114,15 +113,16 @@ export interface Contender {
114
113
  export interface FinishedVoteInfo {
115
114
  type: string;
116
115
  wonByIdentityId?: IdentifierWASM | undefined;
117
- finishedAtBlockHeight: string;
116
+ finishedAtBlockHeight: bigint;
118
117
  finishedAtCoreBlockHeight: number;
119
- finishedAtBlockTimeMs: string;
120
- finishedAtEpoch: number;
118
+ finishedAtBlockTimeMs: bigint;
119
+ finishedAtEpoch?: number;
121
120
  }
122
121
  export interface ContestedResourceVoteState {
123
122
  contenders: Contender[];
124
123
  abstainVoteTally?: number | undefined;
125
124
  lockVoteTally?: number | undefined;
125
+ skipped: boolean;
126
126
  finishedVoteInfo?: FinishedVoteInfo;
127
127
  }
128
128
  export interface DataContractConfig {
@@ -135,6 +135,7 @@ export interface DataContractConfig {
135
135
  documentsCanBeDeletedContractDefault: boolean;
136
136
  requiresIdentityEncryptionBoundedKey?: number | null;
137
137
  requiresIdentityDecryptionBoundedKey?: number | null;
138
+ sizedIntegerTypes: boolean;
138
139
  }
139
140
  export type TokenTransitionType = 'burn' | 'mint' | 'transfer' | 'freeze' | 'unfreeze' | 'destroyFrozenFunds' | 'emergencyAction' | 'directPurchase' | 'setPriceForDirectPurchase';
140
141
  export interface TokenTransitionParams {
@@ -202,6 +203,6 @@ export interface TokenTotalSupply {
202
203
  }
203
204
  export interface TokenDirectPurchasePrices {
204
205
  tokenId: IdentifierWASM;
205
- price: TokenPricingScheduleWASM;
206
+ pricingSchedule?: TokenPricingScheduleWASM | undefined;
206
207
  }
207
208
  export type ResourceVoteChoice = IdentifierLike | 'lock' | 'abstain';
@@ -1,5 +1,5 @@
1
- export { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM } from 'pshenmic-dpp';
2
- export { DashPlatformSDK } from './DashPlatformSDK.js';
1
+ export { CoreScriptWASM, DocumentWASM, IdentifierWASM, TokenPricingScheduleWASM, StateTransitionWASM, BatchTransitionWASM, IdentityPublicKeyWASM, PrivateKeyWASM, DataContractUpdateTransitionWASM, IdentityWASM, IdentityUpdateTransitionWASM, IdentityCreditTransferWASM, MasternodeVoteTransitionWASM } from 'pshenmic-dpp';
2
+ export { DashPlatformSDK } from './src/DashPlatformSDK.js';
3
3
  export var ContestedStateResultType;
4
4
  (function (ContestedStateResultType) {
5
5
  ContestedStateResultType[ContestedStateResultType["DOCUMENTS"] = 0] = "DOCUMENTS";
@@ -1,12 +0,0 @@
1
- import { StateTransitionWASM } from 'pshenmic-dpp';
2
- export interface WalletInfo {
3
- identities: string[];
4
- currentIdentity: string | null;
5
- }
6
- /**
7
- * Abstract interface for custom signer implementation
8
- */
9
- export interface AbstractSigner {
10
- connect: () => Promise<WalletInfo>;
11
- signAndBroadcast: (stateTransition: StateTransitionWASM) => Promise<StateTransitionWASM>;
12
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,65 +0,0 @@
1
- export {};
2
- // import { IdentityWASM, NetworkWASM, PrivateKeyWASM, StateTransitionWASM } from 'pshenmic-dpp'
3
- // import { base64 } from '@scure/base'
4
- // import { IdentitiesController } from '../identities'
5
- // import {AbstractSigner} from "./AbstractSigner";
6
- //
7
- // export class PrivateKeySigner implements AbstractSigner {
8
- // privateKey: PrivateKeyWASM
9
- // identity: IdentityWASM
10
- // identities: IdentitiesController
11
- //
12
- // constructor (identitiesController: IdentitiesController, privateKey: string | PrivateKeyWASM, network?: NetworkWASM | string) {
13
- // this.identities = identitiesController
14
- //
15
- // if (typeof privateKey === 'string') {
16
- // let privateKeyWASM
17
- //
18
- // try {
19
- // privateKeyWASM = PrivateKeyWASM.fromWIF(privateKey)
20
- // } catch (e) {
21
- // }
22
- //
23
- // if (privateKey.length === 64 && !network) {
24
- // throw new Error('Network must be specified if hex or base64 private key being used')
25
- // }
26
- //
27
- // try {
28
- // privateKeyWASM = PrivateKeyWASM.fromHex(privateKey, network)
29
- // } catch (e) {
30
- // }
31
- //
32
- // try {
33
- // privateKeyWASM = PrivateKeyWASM.fromBytes(base64.decode(privateKey), network)
34
- // } catch (e) {
35
- // }
36
- //
37
- // if (privateKeyWASM == null) {
38
- // throw new Error('Could not decode private key')
39
- // }
40
- // } else if (privateKey?.__type === 'PrivateKeyWASM') {
41
- // this.privateKey = privateKey
42
- // } else {
43
- // throw new Error('Unrecognized private key type')
44
- // }
45
- // }
46
- //
47
- // async connect (): Promise<void> {
48
- // this.identity = await this.identities.getIdentityByPublicKeyHash(this.privateKey.getPublicKeyHash())
49
- // }
50
- //
51
- // getCurrentIdentity (): IdentityWASM {
52
- // return this.identity
53
- // }
54
- //
55
- // signStateTransition (stateTransition: StateTransitionWASM): void {
56
- // const [identityPublicKey] = this.identity.getPublicKeys()
57
- // .filter(identityPublicKey => identityPublicKey.getPublicKeyHash() === this.privateKey.getPublicKeyHash())
58
- //
59
- // if (identityPublicKey == null) {
60
- // throw new Error('Could not find an identity public key of identity matching this private key')
61
- // }
62
- //
63
- // stateTransition.sign(this.privateKey, identityPublicKey)
64
- // }
65
- // }
@@ -1,2 +0,0 @@
1
- import { AbstractSigner } from './AbstractSigner.js';
2
- export default function setSigner(signer: AbstractSigner): void;
@@ -1,5 +0,0 @@
1
- export default function setSigner(signer) {
2
- this.signer = signer;
3
- this.signer.identities = this.identities;
4
- this.signer.setSigner = setSigner;
5
- }