dash-platform-sdk 1.3.0-dev.13 → 1.3.0-dev.14

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 (43) hide show
  1. package/bundle.min.js +15 -15
  2. package/package.json +1 -1
  3. package/src/DashPlatformSDK.d.ts +1 -1
  4. package/src/contestedResources/getContestedResourceVoteState.d.ts +1 -1
  5. package/src/contestedResources/index.d.ts +1 -1
  6. package/src/dataContracts/create.d.ts +1 -1
  7. package/src/dataContracts/getDataContractByIdentifier.d.ts +1 -1
  8. package/src/dataContracts/index.d.ts +1 -1
  9. package/src/documents/create.d.ts +1 -1
  10. package/src/documents/createStateTransition.d.ts +1 -1
  11. package/src/documents/index.d.ts +1 -1
  12. package/src/documents/query.d.ts +1 -1
  13. package/src/grpcConnectionPool.d.ts +1 -1
  14. package/src/identities/createStateTransition.d.ts +1 -1
  15. package/src/identities/getIdentityBalance.d.ts +1 -1
  16. package/src/identities/getIdentityByIdentifier.d.ts +1 -1
  17. package/src/identities/getIdentityContractNonce.d.ts +1 -1
  18. package/src/identities/getIdentityNonce.d.ts +1 -1
  19. package/src/identities/getIdentityPublicKeys.d.ts +1 -1
  20. package/src/identities/getIdentityPublicKeys.js +1 -1
  21. package/src/identities/index.d.ts +1 -1
  22. package/src/keyPair/index.d.ts +1 -1
  23. package/src/names/index.d.ts +1 -1
  24. package/src/node/index.d.ts +1 -1
  25. package/src/node/status.d.ts +1 -1
  26. package/src/node/totalCredits.d.ts +1 -1
  27. package/src/stateTransitions/waitForStateTransitionResult.js +1 -1
  28. package/src/tokens/createStateTransition.d.ts +1 -1
  29. package/src/tokens/getIdentitiesTokenBalances.d.ts +1 -1
  30. package/src/tokens/getIdentityTokensBalances.d.ts +1 -1
  31. package/src/tokens/getTokenContractInfo.d.ts +1 -1
  32. package/src/tokens/getTokenDirectPurchasePrices.d.ts +1 -1
  33. package/src/tokens/getTokenTotalSupply.d.ts +1 -1
  34. package/src/tokens/index.d.ts +1 -1
  35. package/src/utils/getEvonodeList.d.ts +1 -1
  36. package/src/utils/index.d.ts +8 -0
  37. package/src/utils/index.js +17 -0
  38. package/src/voting/index.d.ts +1 -1
  39. package/test/unit/ContestedResources.spec.js +1 -1
  40. package/test/unit/DataContract.spec.js +1 -1
  41. package/test/unit/Identity.spec.js +1 -1
  42. package/{src/types.d.ts → types.d.ts} +2 -2
  43. package/{src/types.js → types.js} +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dash-platform-sdk",
3
- "version": "1.3.0-dev.13",
3
+ "version": "1.3.0-dev.14",
4
4
  "main": "index.js",
5
5
  "description": "Lightweight SDK for accessing Dash Platform blockchain",
6
6
  "ts-standard": {
@@ -10,7 +10,7 @@ import { DataContractsController } from './dataContracts/index.js';
10
10
  import { ContestedResourcesController } from './contestedResources/index.js';
11
11
  import { TokensController } from './tokens/index.js';
12
12
  import { VotingController } from './voting/index.js';
13
- import { Network } from './types.js';
13
+ import { Network } from '../types.js';
14
14
  export interface GRPCOptions {
15
15
  poolLimit: 5;
16
16
  dapiUrl?: string | string[];
@@ -1,4 +1,4 @@
1
- import { ContestedResourceVoteState, ContestedStateResultType } from '../types.js';
1
+ import { ContestedResourceVoteState, ContestedStateResultType } from '../../types.js';
2
2
  import GRPCConnectionPool from '../grpcConnectionPool.js';
3
3
  import { GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_StartAtIdentifierInfo } from '../../proto/generated/platform.js';
4
4
  import { DataContractWASM } from 'pshenmic-dpp';
@@ -1,5 +1,5 @@
1
1
  import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- import { ContestedResourceVoteState, ContestedStateResultType } from '../types.js';
2
+ import { ContestedResourceVoteState, ContestedStateResultType } from '../../types.js';
3
3
  import { DataContractWASM } from 'pshenmic-dpp';
4
4
  import { StartAtIdentifierInfo } from './getContestedResourceVoteState.js';
5
5
  /**
@@ -1,3 +1,3 @@
1
1
  import { DataContractWASM, PlatformVersionWASM, TokenConfigurationWASM } from 'pshenmic-dpp';
2
- import { DataContractConfig, IdentifierLike } from '../types.js';
2
+ import { DataContractConfig, IdentifierLike } from '../../types.js';
3
3
  export default function createDataContract(ownerId: IdentifierLike, identityNonce: bigint, schema: object, tokenConfiguration?: TokenConfigurationWASM, config?: DataContractConfig, fullValidation?: boolean | undefined, platformVersion?: PlatformVersionWASM | undefined): DataContractWASM;
@@ -1,4 +1,4 @@
1
1
  import { DataContractWASM } from 'pshenmic-dpp';
2
- import { IdentifierLike } from '../types.js';
2
+ import { IdentifierLike } from '../../types.js';
3
3
  import GRPCConnectionPool from '../grpcConnectionPool.js';
4
4
  export default function getByIdentifier(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<DataContractWASM>;
@@ -1,4 +1,4 @@
1
- import { DataContractConfig, IdentifierLike } from '../types.js';
1
+ import { DataContractConfig, IdentifierLike } from '../../types.js';
2
2
  import { DataContractWASM, PlatformVersionWASM, StateTransitionWASM, TokenConfigurationWASM } from 'pshenmic-dpp';
3
3
  import GRPCConnectionPool from '../grpcConnectionPool.js';
4
4
  /**
@@ -1,3 +1,3 @@
1
1
  import { DocumentWASM } from 'pshenmic-dpp';
2
- import { IdentifierLike } from '../types.js';
2
+ import { IdentifierLike } from '../../types.js';
3
3
  export default function createDocument(dataContractId: IdentifierLike, documentType: string, data: object, owner: IdentifierLike, revision?: bigint, documentId?: IdentifierLike): DocumentWASM;
@@ -1,3 +1,3 @@
1
1
  import { DocumentWASM, StateTransitionWASM } from 'pshenmic-dpp';
2
- import { DocumentTransitionParams } from '../types.js';
2
+ import { DocumentTransitionParams } from '../../types.js';
3
3
  export default function createStateTransition(document: DocumentWASM, type: 'create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase', params: DocumentTransitionParams): StateTransitionWASM;
@@ -1,4 +1,4 @@
1
- import { DocumentTransitionParams, IdentifierLike } from '../types.js';
1
+ import { DocumentTransitionParams, IdentifierLike } from '../../types.js';
2
2
  import { DocumentWASM, IdentifierWASM, StateTransitionWASM } from 'pshenmic-dpp';
3
3
  import GRPCConnectionPool from '../grpcConnectionPool.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
1
  import { DocumentWASM, IdentifierWASM } from 'pshenmic-dpp';
2
- import { IdentifierLike } from '../types.js';
2
+ import { IdentifierLike } from '../../types.js';
3
3
  import GRPCConnectionPool from '../grpcConnectionPool.js';
4
4
  export default function query(grpcPool: GRPCConnectionPool, dataContractId: IdentifierLike, documentTypeName: string, where?: ArrayLike<any>, orderBy?: ArrayLike<any>, limit?: number | undefined, startAt?: IdentifierWASM, startAfter?: IdentifierWASM): Promise<DocumentWASM[]>;
@@ -1,5 +1,5 @@
1
1
  import { PlatformClient } from '../proto/generated/platform.client.js';
2
- import { Network } from './types.js';
2
+ import { Network } from '../types.js';
3
3
  export type MasternodeList = Record<string, MasternodeInfo>;
4
4
  export interface GRPCOptions {
5
5
  poolLimit: 5;
@@ -1,3 +1,3 @@
1
1
  import { StateTransitionWASM } from 'pshenmic-dpp';
2
- import { IdentityTransitionParams } from '../types.js';
2
+ import { IdentityTransitionParams } from '../../types.js';
3
3
  export default function createStateTransition(type: 'create' | 'update' | 'topUp' | 'creditTransfer' | 'withdrawal', params: IdentityTransitionParams): StateTransitionWASM;
@@ -1,3 +1,3 @@
1
- import { IdentifierLike } from '../types.js';
1
+ import { IdentifierLike } from '../../types.js';
2
2
  import GRPCConnectionPool from '../grpcConnectionPool.js';
3
3
  export default function getIdentityBalance(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<bigint>;
@@ -1,4 +1,4 @@
1
1
  import { IdentityWASM } from 'pshenmic-dpp';
2
- import { IdentifierLike } from '../types.js';
2
+ import { IdentifierLike } from '../../types.js';
3
3
  import GRPCConnectionPool from '../grpcConnectionPool.js';
4
4
  export default function getIdentityByIdentifier(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<IdentityWASM>;
@@ -1,3 +1,3 @@
1
- import { IdentifierLike } from '../types.js';
1
+ import { IdentifierLike } from '../../types.js';
2
2
  import GRPCConnectionPool from '../grpcConnectionPool.js';
3
3
  export default function getIdentityContractNonce(grpcPool: GRPCConnectionPool, identity: IdentifierLike, dataContract: IdentifierLike): Promise<bigint>;
@@ -1,3 +1,3 @@
1
- import { IdentifierLike } from '../types.js';
1
+ import { IdentifierLike } from '../../types.js';
2
2
  import GRPCConnectionPool from '../grpcConnectionPool.js';
3
3
  export default function getIdentityNonce(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<bigint>;
@@ -1,4 +1,4 @@
1
1
  import { IdentityPublicKeyWASM } from 'pshenmic-dpp';
2
- import { IdentifierLike } from '../types.js';
2
+ import { IdentifierLike } from '../../types.js';
3
3
  import GRPCConnectionPool from '../grpcConnectionPool.js';
4
4
  export default function getIdentityPublicKeys(grpcPool: GRPCConnectionPool, identifier: IdentifierLike, keyIds?: number[]): Promise<IdentityPublicKeyWASM[]>;
@@ -3,7 +3,7 @@ import { IdentifierWASM, verifyIdentityKeysByIdentifierProof } from 'pshenmic-dp
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
+ import { LATEST_PLATFORM_VERSION } from '../constants.js';
7
7
  export default async function getIdentityPublicKeys(grpcPool, identifier, keyIds) {
8
8
  const id = new IdentifierWASM(identifier);
9
9
  let requestType = {
@@ -1,4 +1,4 @@
1
- import { IdentifierLike, IdentityTransitionParams } from '../types.js';
1
+ import { IdentifierLike, IdentityTransitionParams } from '../../types.js';
2
2
  import GRPCConnectionPool from '../grpcConnectionPool.js';
3
3
  import { IdentityPublicKeyWASM, IdentityWASM, StateTransitionWASM } from 'pshenmic-dpp';
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { HDKey } from '@scure/bip32';
2
- import { Network } from '../types.js';
2
+ import { Network } from '../../types.js';
3
3
  /**
4
4
  * Collection of functions to work with private keys and seed phrases
5
5
  *
@@ -1,6 +1,6 @@
1
1
  import GRPCConnectionPool from '../grpcConnectionPool.js';
2
2
  import { DocumentWASM, PrivateKeyWASM } from 'pshenmic-dpp';
3
- import { IdentifierLike } from '../types.js';
3
+ import { IdentifierLike } from '../../types.js';
4
4
  /**
5
5
  * Functions related to DPNS names (usernames)
6
6
  *
@@ -1,5 +1,5 @@
1
1
  import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- import { Network, NodeStatus } from '../types.js';
2
+ import { Network, NodeStatus } from '../../types.js';
3
3
  import { EpochInfo } from './epochs.js';
4
4
  /**
5
5
  * Node controller for requesting information about DAPI node
@@ -1,3 +1,3 @@
1
- import { NodeStatus } from '../types.js';
1
+ import { NodeStatus } from '../../types.js';
2
2
  import GRPCConnectionPool from '../grpcConnectionPool.js';
3
3
  export default function status(grpcPool: GRPCConnectionPool): Promise<NodeStatus>;
@@ -1,3 +1,3 @@
1
1
  import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- import { Network } from '../types.js';
2
+ import { Network } from '../../types.js';
3
3
  export default function totalCredits(grpcPool: GRPCConnectionPool, network: Network): Promise<bigint>;
@@ -43,7 +43,7 @@ export default async function waitForStateTransitionResult(grpcPool, stateTransi
43
43
  }
44
44
  else if (v0.result.oneofKind === 'error') {
45
45
  const { code, message, data } = v0.result.error;
46
- throw new Error(`State transition ${txHash} failed to execute with code ${code}, message: ${message}, data: ${base64.encode(data)}`);
46
+ throw new Error(`State transition ${txHash} failed to execute with code ${String(code)}, message: ${String(message)}, data: ${base64.encode(data)}`);
47
47
  }
48
48
  else {
49
49
  throw new Error('Unexpected oneOfKind returned for waitForStateTransitionResult');
@@ -1,3 +1,3 @@
1
1
  import { IdentifierWASM, StateTransitionWASM, TokenBaseTransitionWASM } from 'pshenmic-dpp';
2
- import { TokenTransitionParams, TokenTransitionType } from '../types.js';
2
+ import { TokenTransitionParams, TokenTransitionType } from '../../types.js';
3
3
  export default function createStateTransition(base: TokenBaseTransitionWASM, ownerId: IdentifierWASM, type: TokenTransitionType, params: TokenTransitionParams): StateTransitionWASM;
@@ -1,5 +1,5 @@
1
1
  import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- import { IdentifierLike } from '../types.js';
2
+ import { IdentifierLike } from '../../types.js';
3
3
  import { IdentifierWASM } from 'pshenmic-dpp';
4
4
  export interface IdentitiesTokenBalances {
5
5
  identityId: IdentifierWASM;
@@ -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 IdentityTokenBalances {
5
5
  tokenId: IdentifierWASM;
@@ -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,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,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,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,5 +1,5 @@
1
1
  import { DataContractWASM, PlatformVersionWASM, PrivateKeyWASM } from 'pshenmic-dpp';
2
- import { DashPlatformSDK, ContestedStateResultType } from '../../src/types.js';
2
+ import { DashPlatformSDK, ContestedStateResultType } from '../../types.js';
3
3
  import stringToIndexValueBytes from '../../src/utils/stringToIndexValueBytes.js';
4
4
  let sdk;
5
5
  let contract;
@@ -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;
@@ -1,5 +1,5 @@
1
1
  import { CoreScriptWASM, IdentityPublicKeyWASM, IdentityWASM, KeyType, PrivateKeyWASM, Purpose, SecurityLevel, StateTransitionWASM } from 'pshenmic-dpp';
2
- import { DashPlatformSDK } from '../../src/types.js';
2
+ import { DashPlatformSDK } from '../../types.js';
3
3
  import { base58 } from '@scure/base';
4
4
  let sdk;
5
5
  describe('Identity', () => {
@@ -1,8 +1,8 @@
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
7
  export interface DocumentTransitionParams {
8
8
  identityContractNonce: bigint;
@@ -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, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, 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";