dash-platform-sdk 1.5.0 → 1.5.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 (68) hide show
  1. package/README.md +15 -15
  2. package/bundle.min.js +1 -1
  3. package/index.d.ts +4 -1
  4. package/index.js +3 -1
  5. package/package.json +1 -1
  6. package/proto/generated/platform.client.d.ts +10 -0
  7. package/proto/generated/platform.client.js +25 -18
  8. package/proto/generated/platform.d.ts +162 -0
  9. package/proto/generated/platform.js +351 -0
  10. package/src/DashPlatformSDK.d.ts +11 -7
  11. package/src/DashPlatformSDK.js +23 -3
  12. package/src/contestedResources/getContestedResourceVoteState.d.ts +2 -2
  13. package/src/contestedResources/index.d.ts +3 -3
  14. package/src/dataContracts/getDataContractByIdentifier.d.ts +2 -2
  15. package/src/dataContracts/index.d.ts +3 -3
  16. package/src/documents/index.d.ts +3 -3
  17. package/src/documents/query.d.ts +2 -2
  18. package/src/grpcConnectionPool.d.ts +13 -2
  19. package/src/grpcConnectionPool.js +16 -13
  20. package/src/identities/getIdentityBalance.d.ts +2 -2
  21. package/src/identities/getIdentityByIdentifier.d.ts +2 -2
  22. package/src/identities/getIdentityByNonUniquePublicKeyHash.d.ts +2 -2
  23. package/src/identities/getIdentityByPublicKeyHash.d.ts +2 -2
  24. package/src/identities/getIdentityContractNonce.d.ts +2 -2
  25. package/src/identities/getIdentityNonce.d.ts +2 -2
  26. package/src/identities/getIdentityPublicKeys.d.ts +2 -2
  27. package/src/identities/index.d.ts +3 -3
  28. package/src/names/index.d.ts +3 -3
  29. package/src/names/registerName.d.ts +2 -2
  30. package/src/names/searchByIdentity.d.ts +2 -2
  31. package/src/names/searchByName.d.ts +2 -2
  32. package/src/node/epochInfos.d.ts +2 -2
  33. package/src/node/finalizedEpochInfos.d.ts +2 -2
  34. package/src/node/getCurrentQuorumsInfo.d.ts +19 -0
  35. package/src/node/getCurrentQuorumsInfo.js +31 -0
  36. package/src/node/index.d.ts +11 -3
  37. package/src/node/index.js +10 -0
  38. package/src/node/status.d.ts +2 -2
  39. package/src/node/totalCredits.d.ts +2 -2
  40. package/src/platformAddresses/getAddressInfo.d.ts +2 -2
  41. package/src/platformAddresses/getAddressesBranchState.d.ts +2 -2
  42. package/src/platformAddresses/getAddressesInfos.d.ts +2 -2
  43. package/src/platformAddresses/getAddressesTrunkState.d.ts +2 -2
  44. package/src/platformAddresses/getRecentAddressBalanceChanges.d.ts +2 -2
  45. package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.d.ts +2 -2
  46. package/src/platformAddresses/index.d.ts +3 -3
  47. package/src/shielded/getMostRecentShieldedAnchor.d.ts +2 -2
  48. package/src/shielded/getShieldedAnchors.d.ts +2 -2
  49. package/src/shielded/getShieldedEncryptedNotes.d.ts +2 -2
  50. package/src/shielded/getShieldedNotesCount.d.ts +2 -2
  51. package/src/shielded/getShieldedNullifiers.d.ts +2 -2
  52. package/src/shielded/getShieldedPoolState.d.ts +2 -2
  53. package/src/shielded/index.d.ts +3 -3
  54. package/src/stateTransitions/broadcast.d.ts +2 -2
  55. package/src/stateTransitions/index.d.ts +3 -3
  56. package/src/stateTransitions/waitForStateTransitionResult.d.ts +2 -2
  57. package/src/tokens/getIdentitiesTokenBalances.d.ts +2 -2
  58. package/src/tokens/getIdentityTokensBalances.d.ts +2 -2
  59. package/src/tokens/getTokenContractInfo.d.ts +2 -2
  60. package/src/tokens/getTokenDirectPurchasePrices.d.ts +2 -2
  61. package/src/tokens/getTokenTotalSupply.d.ts +2 -2
  62. package/src/tokens/index.d.ts +3 -3
  63. package/src/utils/fetchWithDetails.d.ts +24 -0
  64. package/src/utils/fetchWithDetails.js +71 -0
  65. package/src/utils/getQuorumPublicKey.js +2 -1
  66. package/test/unit/Node.spec.js +18 -0
  67. package/src/utils/getEvonodeList.d.ts +0 -2
  68. package/src/utils/getEvonodeList.js +0 -12
@@ -1,3 +1,3 @@
1
1
  import { IdentifierLike } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function getIdentityContractNonce(grpcPool: GRPCConnectionPool, identity: IdentifierLike, dataContract: IdentifierLike): Promise<bigint>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function getIdentityContractNonce(grpcPool: GRPCPool, identity: IdentifierLike, dataContract: IdentifierLike): Promise<bigint>;
@@ -1,3 +1,3 @@
1
1
  import { IdentifierLike } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function getIdentityNonce(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<bigint>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function getIdentityNonce(grpcPool: GRPCPool, identifier: IdentifierLike): Promise<bigint>;
@@ -1,3 +1,3 @@
1
1
  import { IdentifierLike, IdentityPublicKeyWASM } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function getIdentityPublicKeys(grpcPool: GRPCConnectionPool, identifier: IdentifierLike, keyIds?: number[]): Promise<IdentityPublicKeyWASM[]>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function getIdentityPublicKeys(grpcPool: GRPCPool, identifier: IdentifierLike, keyIds?: number[]): Promise<IdentityPublicKeyWASM[]>;
@@ -1,5 +1,5 @@
1
1
  import { IdentityTransitionParams } from '../../types.js';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
3
  import { IdentifierLike, IdentityPublicKeyWASM, IdentityWASM, StateTransitionWASM } from 'pshenmic-dpp';
4
4
  /**
5
5
  * Collection of methods to query identities and its related data
@@ -8,8 +8,8 @@ import { IdentifierLike, IdentityPublicKeyWASM, IdentityWASM, StateTransitionWAS
8
8
  */
9
9
  export declare class IdentitiesController {
10
10
  /** @ignore */
11
- grpcPool: GRPCConnectionPool;
12
- constructor(grpcPool: GRPCConnectionPool);
11
+ grpcPool: GRPCPool;
12
+ constructor(grpcPool: GRPCPool);
13
13
  /**
14
14
  * Get current balance of your Identity by identifier
15
15
  *
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { DocumentWASM, IdentifierLike, PrivateKeyWASM } from 'pshenmic-dpp';
3
3
  /**
4
4
  * Functions related to DPNS names (usernames)
@@ -7,8 +7,8 @@ import { DocumentWASM, IdentifierLike, PrivateKeyWASM } from 'pshenmic-dpp';
7
7
  */
8
8
  export declare class NamesController {
9
9
  /** @ignore **/
10
- grpcPool: GRPCConnectionPool;
11
- constructor(grpcPool: GRPCConnectionPool);
10
+ grpcPool: GRPCPool;
11
+ constructor(grpcPool: GRPCPool);
12
12
  /**
13
13
  * Searches for a registered DPNS name in the network
14
14
  *
@@ -1,3 +1,3 @@
1
1
  import { IdentityWASM, PrivateKeyWASM } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function registerName(grpcPool: GRPCConnectionPool, name: string, identity: IdentityWASM, privateKey: PrivateKeyWASM): Promise<void>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function registerName(grpcPool: GRPCPool, name: string, identity: IdentityWASM, privateKey: PrivateKeyWASM): Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import { DocumentWASM, IdentifierWASM } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function searchByIdentity(grpcPool: GRPCConnectionPool, identifier: IdentifierWASM): Promise<DocumentWASM[]>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function searchByIdentity(grpcPool: GRPCPool, identifier: IdentifierWASM): Promise<DocumentWASM[]>;
@@ -1,3 +1,3 @@
1
1
  import { DocumentWASM } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function search(grpcPool: GRPCConnectionPool, name: string): Promise<DocumentWASM[]>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function search(grpcPool: GRPCPool, name: string): Promise<DocumentWASM[]>;
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  export interface EpochInfo {
3
3
  number: number;
4
4
  firstBlockHeight: number;
@@ -7,4 +7,4 @@ export interface EpochInfo {
7
7
  feeMultiplier: bigint;
8
8
  protocolVersion: 9;
9
9
  }
10
- export default function epochInfos(grpcPool: GRPCConnectionPool, count: number, ascending: boolean, start?: number): Promise<EpochInfo[]>;
10
+ export default function epochInfos(grpcPool: GRPCPool, count: number, ascending: boolean, start?: number): Promise<EpochInfo[]>;
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { IdentifierWASM } from 'pshenmic-dpp';
3
3
  export interface FinalizedEpochInfo {
4
4
  epochIndex: number;
@@ -18,4 +18,4 @@ export interface FinalizedEpochInfo {
18
18
  feeMultiplier: bigint;
19
19
  protocolVersion: number;
20
20
  }
21
- export default function getFinalizedEpochsInfo(grpcPool: GRPCConnectionPool, startEpochIndex: number, startEpochIndexIncluded: boolean, endEpochIndex: number, endEpochIndexIncluded: boolean): Promise<FinalizedEpochInfo[]>;
21
+ export default function getFinalizedEpochsInfo(grpcPool: GRPCPool, startEpochIndex: number, startEpochIndexIncluded: boolean, endEpochIndex: number, endEpochIndexIncluded: boolean): Promise<FinalizedEpochInfo[]>;
@@ -0,0 +1,19 @@
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
+ export interface Validator {
3
+ proTxHash: string;
4
+ nodeIp: string;
5
+ isBanned: boolean;
6
+ }
7
+ export interface ValidatorSet {
8
+ quorumHash: string;
9
+ coreHeight: number;
10
+ members: Validator[];
11
+ thresholdPublicKey: string;
12
+ }
13
+ export interface CurrentQuorumsInfo {
14
+ quorumHashes: string[];
15
+ currentQuorumHash: string;
16
+ validatorSets: ValidatorSet[];
17
+ lastBlockProposer: string;
18
+ }
19
+ export default function getCurrentQuorumsInfo(grpcPool: GRPCPool): Promise<CurrentQuorumsInfo>;
@@ -0,0 +1,31 @@
1
+ import { GetCurrentQuorumsInfoRequest } from '../../proto/generated/platform.js';
2
+ import bytesToHex from '../utils/bytesToHex.js';
3
+ export default async function getCurrentQuorumsInfo(grpcPool) {
4
+ const getCurrentQuorumsInfoRequest = GetCurrentQuorumsInfoRequest.create({
5
+ version: {
6
+ oneofKind: 'v0',
7
+ v0: {}
8
+ }
9
+ });
10
+ const { response } = await grpcPool.getClient().getCurrentQuorumsInfo(getCurrentQuorumsInfoRequest);
11
+ const { version } = response;
12
+ if (version.oneofKind !== 'v0') {
13
+ throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
14
+ }
15
+ const { v0 } = version;
16
+ return {
17
+ quorumHashes: v0.quorumHashes.map(bytesToHex),
18
+ currentQuorumHash: bytesToHex(v0.currentQuorumHash),
19
+ validatorSets: v0.validatorSets.map(validatorSet => ({
20
+ quorumHash: bytesToHex(validatorSet.quorumHash),
21
+ coreHeight: validatorSet.coreHeight,
22
+ members: validatorSet.members.map(member => ({
23
+ proTxHash: bytesToHex(member.proTxHash),
24
+ nodeIp: member.nodeIp,
25
+ isBanned: member.isBanned
26
+ })),
27
+ thresholdPublicKey: bytesToHex(validatorSet.thresholdPublicKey)
28
+ })),
29
+ lastBlockProposer: bytesToHex(v0.lastBlockProposer)
30
+ };
31
+ }
@@ -1,7 +1,8 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { NodeStatus } from '../../types.js';
3
3
  import { EpochInfo } from './epochInfos.js';
4
4
  import { FinalizedEpochInfo } from './finalizedEpochInfos.js';
5
+ import { CurrentQuorumsInfo } from './getCurrentQuorumsInfo.js';
5
6
  /**
6
7
  * Node controller for requesting information about DAPI node
7
8
  *
@@ -9,8 +10,8 @@ import { FinalizedEpochInfo } from './finalizedEpochInfos.js';
9
10
  */
10
11
  export declare class NodeController {
11
12
  /** @ignore **/
12
- grpcPool: GRPCConnectionPool;
13
- constructor(grpcPool: GRPCConnectionPool);
13
+ grpcPool: GRPCPool;
14
+ constructor(grpcPool: GRPCPool);
14
15
  /**
15
16
  * Retrieves an info about node
16
17
  * Includes information about genesis, chain, software versions
@@ -38,4 +39,11 @@ export declare class NodeController {
38
39
  * @return {Promise<FinalizedEpochInfo[]>}
39
40
  */
40
41
  getFinalizedEpochsInfo(startEpochIndex: number, startEpochIndexIncluded: boolean, endEpochIndex: number, endEpochIndexIncluded: boolean): Promise<FinalizedEpochInfo[]>;
42
+ /**
43
+ * Retrieves an info about current validator sets (quorums)
44
+ * Includes quorum hashes, members of validator sets with their IPs and last block proposer
45
+ *
46
+ * @return {Promise<CurrentQuorumsInfo>}
47
+ */
48
+ getCurrentQuorumsInfo(): Promise<CurrentQuorumsInfo>;
41
49
  }
package/src/node/index.js CHANGED
@@ -2,6 +2,7 @@ import getStatus from './status.js';
2
2
  import getEpochsInfo from './epochInfos.js';
3
3
  import getFinalizedEpochsInfo from './finalizedEpochInfos.js';
4
4
  import getTotalCredits from './totalCredits.js';
5
+ import getCurrentQuorumsInfo from './getCurrentQuorumsInfo.js';
5
6
  /**
6
7
  * Node controller for requesting information about DAPI node
7
8
  *
@@ -48,4 +49,13 @@ export class NodeController {
48
49
  async getFinalizedEpochsInfo(startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded) {
49
50
  return await getFinalizedEpochsInfo(this.grpcPool, startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded);
50
51
  }
52
+ /**
53
+ * Retrieves an info about current validator sets (quorums)
54
+ * Includes quorum hashes, members of validator sets with their IPs and last block proposer
55
+ *
56
+ * @return {Promise<CurrentQuorumsInfo>}
57
+ */
58
+ async getCurrentQuorumsInfo() {
59
+ return await getCurrentQuorumsInfo(this.grpcPool);
60
+ }
51
61
  }
@@ -1,3 +1,3 @@
1
1
  import { NodeStatus } from '../../types.js';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function status(grpcPool: GRPCConnectionPool): Promise<NodeStatus>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function status(grpcPool: GRPCPool): Promise<NodeStatus>;
@@ -1,2 +1,2 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- export default function totalCredits(grpcPool: GRPCConnectionPool): Promise<bigint>;
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
+ export default function totalCredits(grpcPool: GRPCPool): Promise<bigint>;
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { PlatformAddressLike } from 'pshenmic-dpp';
3
3
  import { PlatformAddressInfo } from '../../types.js';
4
- export declare function getAddressInfo(grpcPool: GRPCConnectionPool, platformAddress: PlatformAddressLike): Promise<PlatformAddressInfo>;
4
+ export declare function getAddressInfo(grpcPool: GRPCPool, platformAddress: PlatformAddressLike): Promise<PlatformAddressInfo>;
@@ -1,3 +1,3 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { VerifiedAddressesBranchState } from 'pshenmic-dpp';
3
- export declare function getAddressesBranchState(grpcPool: GRPCConnectionPool, key: Uint8Array, depth: number, checkpointHeight: bigint, expectedRootHash: Uint8Array): Promise<VerifiedAddressesBranchState>;
3
+ export declare function getAddressesBranchState(grpcPool: GRPCPool, key: Uint8Array, depth: number, checkpointHeight: bigint, expectedRootHash: Uint8Array): Promise<VerifiedAddressesBranchState>;
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { PlatformAddressLike } from 'pshenmic-dpp';
3
3
  import { PlatformAddressInfo } from '../../types.js';
4
- export declare function getAddressesInfos(grpcPool: GRPCConnectionPool, platformAddresses: PlatformAddressLike[]): Promise<PlatformAddressInfo[]>;
4
+ export declare function getAddressesInfos(grpcPool: GRPCPool, platformAddresses: PlatformAddressLike[]): Promise<PlatformAddressInfo[]>;
@@ -1,3 +1,3 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { PlatformAddressesTrunkState } from '../../types.js';
3
- export declare function getAddressesTrunkState(grpcPool: GRPCConnectionPool): Promise<PlatformAddressesTrunkState>;
3
+ export declare function getAddressesTrunkState(grpcPool: GRPCPool): Promise<PlatformAddressesTrunkState>;
@@ -1,3 +1,3 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { BlockAddressBalanceChanges } from 'pshenmic-dpp';
3
- export declare function getRecentAddressBalanceChanges(grpcPool: GRPCConnectionPool, startHeight: bigint, startHeightExclusive?: boolean): Promise<BlockAddressBalanceChanges[]>;
3
+ export declare function getRecentAddressBalanceChanges(grpcPool: GRPCPool, startHeight: bigint, startHeightExclusive?: boolean): Promise<BlockAddressBalanceChanges[]>;
@@ -1,3 +1,3 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { CompactedBlockAddressBalanceChanges } from 'pshenmic-dpp';
3
- export declare function getRecentCompactedAddressBalanceChanges(grpcPool: GRPCConnectionPool, startBlockHeight: bigint): Promise<CompactedBlockAddressBalanceChanges[]>;
3
+ export declare function getRecentCompactedAddressBalanceChanges(grpcPool: GRPCPool, startBlockHeight: bigint): Promise<CompactedBlockAddressBalanceChanges[]>;
@@ -1,10 +1,10 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { BlockAddressBalanceChanges, CompactedBlockAddressBalanceChanges, PlatformAddressLike, StateTransitionWASM, VerifiedAddressesBranchState } from 'pshenmic-dpp';
3
3
  import { PlatformAddressesTrunkState, PlatformAddressInfo, PlatformAddressTransitionParamsMap, PlatformAddressTransitionType } from '../../types.js';
4
4
  export declare class PlatformAddressesController {
5
5
  /** @ignore **/
6
- grpcPool: GRPCConnectionPool;
7
- constructor(grpcPool: GRPCConnectionPool);
6
+ grpcPool: GRPCPool;
7
+ constructor(grpcPool: GRPCPool);
8
8
  /**
9
9
  * Makes a query for platform address info, returns an object with address, balance and nonce
10
10
  *
@@ -1,2 +1,2 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- export default function getMostRecentShieldedAnchor(grpcPool: GRPCConnectionPool): Promise<Uint8Array | undefined>;
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
+ export default function getMostRecentShieldedAnchor(grpcPool: GRPCPool): Promise<Uint8Array | undefined>;
@@ -1,2 +1,2 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- export default function getShieldedAnchors(grpcPool: GRPCConnectionPool): Promise<Uint8Array[]>;
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
+ export default function getShieldedAnchors(grpcPool: GRPCPool): Promise<Uint8Array[]>;
@@ -1,3 +1,3 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { ShieldedEncryptedNote } from '../../types.js';
3
- export default function getShieldedEncryptedNotes(grpcPool: GRPCConnectionPool, startIndex: bigint, count: number): Promise<ShieldedEncryptedNote[]>;
3
+ export default function getShieldedEncryptedNotes(grpcPool: GRPCPool, startIndex: bigint, count: number): Promise<ShieldedEncryptedNote[]>;
@@ -1,2 +1,2 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- export default function getShieldedNotesCount(grpcPool: GRPCConnectionPool): Promise<bigint | undefined>;
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
+ export default function getShieldedNotesCount(grpcPool: GRPCPool): Promise<bigint | undefined>;
@@ -1,3 +1,3 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { ShieldedNullifierStatus } from '../../types.js';
3
- export default function getShieldedNullifiers(grpcPool: GRPCConnectionPool, nullifiers: Uint8Array[]): Promise<ShieldedNullifierStatus[]>;
3
+ export default function getShieldedNullifiers(grpcPool: GRPCPool, nullifiers: Uint8Array[]): Promise<ShieldedNullifierStatus[]>;
@@ -1,2 +1,2 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
2
- export default function getShieldedPoolState(grpcPool: GRPCConnectionPool): Promise<bigint | undefined>;
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
+ export default function getShieldedPoolState(grpcPool: GRPCPool): Promise<bigint | undefined>;
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { ShieldedEncryptedNote, ShieldedNullifierStatus, ShieldedTransitionParamsMap, ShieldedTransitionType } from '../../types.js';
3
3
  import { RecoveredNoteWASM, ShieldedBuilderWASM, SpendableNoteWASM, StateTransitionWASM } from 'pshenmic-dpp';
4
4
  /**
@@ -8,10 +8,10 @@ import { RecoveredNoteWASM, ShieldedBuilderWASM, SpendableNoteWASM, StateTransit
8
8
  */
9
9
  export declare class ShieldedController {
10
10
  /** @ignore **/
11
- grpcPool: GRPCConnectionPool;
11
+ grpcPool: GRPCPool;
12
12
  /** @ignore **/
13
13
  shieldedBuilder?: ShieldedBuilderWASM;
14
- constructor(grpcPool: GRPCConnectionPool);
14
+ constructor(grpcPool: GRPCPool);
15
15
  /**
16
16
  * Set bindings instance of builder
17
17
  * Needed for custom builder load, because ShieldedBuilderWASM inits very slow on old hardware
@@ -1,3 +1,3 @@
1
1
  import { StateTransitionWASM } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function broadcast(grpcPool: GRPCConnectionPool, stateTransition: StateTransitionWASM): Promise<void>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function broadcast(grpcPool: GRPCPool, stateTransition: StateTransitionWASM): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { StateTransitionWASM } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
3
  /**
4
4
  * Collection of methods to perform state transitions (transactions) such like broadcast, wait for state transition result
5
5
  *
@@ -7,8 +7,8 @@ import GRPCConnectionPool from '../grpcConnectionPool.js';
7
7
  */
8
8
  export declare class StateTransitionsController {
9
9
  /** @ignore **/
10
- grpcPool: GRPCConnectionPool;
11
- constructor(grpcPool: GRPCConnectionPool);
10
+ grpcPool: GRPCPool;
11
+ constructor(grpcPool: GRPCPool);
12
12
  /**
13
13
  * Broadcasts a state transition to a network
14
14
  *
@@ -1,3 +1,3 @@
1
1
  import { StateTransitionWASM } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function waitForStateTransitionResult(grpcPool: GRPCConnectionPool, stateTransition: StateTransitionWASM): Promise<void>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function waitForStateTransitionResult(grpcPool: GRPCPool, stateTransition: StateTransitionWASM): Promise<void>;
@@ -1,7 +1,7 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { IdentifierLike, IdentifierWASM } from 'pshenmic-dpp';
3
3
  export interface IdentitiesTokenBalances {
4
4
  identityId: IdentifierWASM;
5
5
  balance?: bigint | undefined;
6
6
  }
7
- export default function getIdentitiesTokenBalances(grpcPool: GRPCConnectionPool, identifiers: IdentifierLike[], tokenIdentifier: IdentifierLike): Promise<IdentitiesTokenBalances[]>;
7
+ export default function getIdentitiesTokenBalances(grpcPool: GRPCPool, identifiers: IdentifierLike[], tokenIdentifier: IdentifierLike): Promise<IdentitiesTokenBalances[]>;
@@ -1,7 +1,7 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { IdentifierLike, IdentifierWASM } from 'pshenmic-dpp';
3
3
  export interface IdentityTokenBalances {
4
4
  tokenId: IdentifierWASM;
5
5
  balance?: bigint | undefined;
6
6
  }
7
- export default function getIdentityTokensBalances(grpcPool: GRPCConnectionPool, identifier: IdentifierLike, tokenIdentifiers: IdentifierLike[]): Promise<IdentityTokenBalances[]>;
7
+ export default function getIdentityTokensBalances(grpcPool: GRPCPool, identifier: IdentifierLike, tokenIdentifiers: IdentifierLike[]): Promise<IdentityTokenBalances[]>;
@@ -1,7 +1,7 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { IdentifierLike, IdentifierWASM } from 'pshenmic-dpp';
3
3
  export interface TokenContractInfo {
4
4
  dataContractId: IdentifierWASM;
5
5
  tokenContractPosition: number;
6
6
  }
7
- export default function getTokenContractInfo(grpcPool: GRPCConnectionPool, tokenIdentifier: IdentifierLike): Promise<TokenContractInfo>;
7
+ export default function getTokenContractInfo(grpcPool: GRPCPool, tokenIdentifier: IdentifierLike): Promise<TokenContractInfo>;
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { TokenDirectPurchasePrices } from '../../types.js';
3
3
  import { IdentifierLike } from 'pshenmic-dpp';
4
- export default function getTokenDirectPurchasePrices(grpcPool: GRPCConnectionPool, tokenIdentifiers: IdentifierLike[]): Promise<TokenDirectPurchasePrices[]>;
4
+ export default function getTokenDirectPurchasePrices(grpcPool: GRPCPool, tokenIdentifiers: IdentifierLike[]): Promise<TokenDirectPurchasePrices[]>;
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { TokenTotalSupply } from '../../types.js';
3
3
  import { IdentifierLike } from 'pshenmic-dpp';
4
- export default function getTokenTotalSupply(grpcPool: GRPCConnectionPool, tokenIdentifier: IdentifierLike): Promise<TokenTotalSupply>;
4
+ export default function getTokenTotalSupply(grpcPool: GRPCPool, tokenIdentifier: IdentifierLike): Promise<TokenTotalSupply>;
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { TokenDirectPurchasePrices, TokenTotalSupply, TokenTransitionParams, TokenTransitionType } from '../../types.js';
3
3
  import { IdentitiesTokenBalances } from './getIdentitiesTokenBalances.js';
4
4
  import { IdentityTokenBalances } from './getIdentityTokensBalances.js';
@@ -11,8 +11,8 @@ import { IdentifierLike, StateTransitionWASM, TokenBaseTransitionWASM } from 'ps
11
11
  */
12
12
  export declare class TokensController {
13
13
  /** @ignore **/
14
- grpcPool: GRPCConnectionPool;
15
- constructor(grpcPool: GRPCConnectionPool);
14
+ grpcPool: GRPCPool;
15
+ constructor(grpcPool: GRPCPool);
16
16
  /**
17
17
  * Retrieves a token balances for identities
18
18
  *
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Collects human-readable details from a fetch error and its nested causes.
3
+ * Node.js (undici) throws a generic `TypeError: fetch failed` and puts the real
4
+ * reason (ECONNREFUSED, ENOTFOUND, certificate errors, timeouts...) in `error.cause`,
5
+ * which may itself be nested or an AggregateError
6
+ *
7
+ * @param error {unknown}
8
+ * @return {string[]}
9
+ */
10
+ export declare function decodeFetchErrorDetails(error: unknown): string[];
11
+ /**
12
+ * Wraps an error thrown by fetch into a new Error that includes the
13
+ * request url and all nested causes in its message, keeping the original as `cause`
14
+ *
15
+ * @param error {unknown}
16
+ * @param url {string}
17
+ * @return {Error}
18
+ */
19
+ export declare function decodeFetchError(error: unknown, url: string): Error;
20
+ /**
21
+ * Drop-in replacement for global fetch that rethrows network errors
22
+ * with decoded details instead of opaque `fetch failed`
23
+ */
24
+ export declare const fetchWithDetails: typeof globalThis.fetch;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Collects human-readable details from a fetch error and its nested causes.
3
+ * Node.js (undici) throws a generic `TypeError: fetch failed` and puts the real
4
+ * reason (ECONNREFUSED, ENOTFOUND, certificate errors, timeouts...) in `error.cause`,
5
+ * which may itself be nested or an AggregateError
6
+ *
7
+ * @param error {unknown}
8
+ * @return {string[]}
9
+ */
10
+ export function decodeFetchErrorDetails(error) {
11
+ const details = [];
12
+ const seen = new Set();
13
+ const visit = (err) => {
14
+ if (err == null || seen.has(err)) {
15
+ return;
16
+ }
17
+ seen.add(err);
18
+ if (typeof err !== 'object') {
19
+ details.push(String(err));
20
+ return;
21
+ }
22
+ const { code, message, cause, errors } = err;
23
+ const detail = [code, message]
24
+ .filter(e => e != null && e !== '')
25
+ .map(String)
26
+ .filter((e, i, arr) => arr.indexOf(e) === i)
27
+ .join(': ');
28
+ if (detail !== '' && !details.includes(detail)) {
29
+ details.push(detail);
30
+ }
31
+ if (Array.isArray(errors)) {
32
+ errors.forEach(visit);
33
+ }
34
+ visit(cause);
35
+ };
36
+ visit(error);
37
+ return details;
38
+ }
39
+ /**
40
+ * Wraps an error thrown by fetch into a new Error that includes the
41
+ * request url and all nested causes in its message, keeping the original as `cause`
42
+ *
43
+ * @param error {unknown}
44
+ * @param url {string}
45
+ * @return {Error}
46
+ */
47
+ export function decodeFetchError(error, url) {
48
+ const [message, ...causes] = decodeFetchErrorDetails(error);
49
+ const decoded = new Error(`${message ?? 'fetch failed'} (${url})${causes.length > 0 ? `: ${causes.join(' <- ')}` : ''}`, { cause: error });
50
+ if (error instanceof Error) {
51
+ decoded.name = error.name;
52
+ }
53
+ return decoded;
54
+ }
55
+ /**
56
+ * Drop-in replacement for global fetch that rethrows network errors
57
+ * with decoded details instead of opaque `fetch failed`
58
+ */
59
+ export const fetchWithDetails = async (input, init) => {
60
+ try {
61
+ return await globalThis.fetch(input, init);
62
+ }
63
+ catch (e) {
64
+ // keep abort errors untouched so callers can detect cancellation
65
+ if (e instanceof Error && e.name === 'AbortError') {
66
+ throw e;
67
+ }
68
+ const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
69
+ throw decodeFetchError(e, url);
70
+ }
71
+ };
@@ -1,3 +1,4 @@
1
+ import { fetchWithDetails } from './fetchWithDetails.js';
1
2
  const cache = {};
2
3
  export async function getQuorumPublicKey(network, quorumType, quorumHash) {
3
4
  const cached = cache[`${quorumType}_${quorumHash}`];
@@ -5,7 +6,7 @@ export async function getQuorumPublicKey(network, quorumType, quorumHash) {
5
6
  return cached;
6
7
  }
7
8
  const url = `https://${network === 'mainnet' ? '' : 'testnet.'}platform-explorer.pshenmic.dev/quorum/info?quorumType=${quorumType}&quorumHash=${quorumHash}`;
8
- const resp = await fetch(url, {
9
+ const resp = await fetchWithDetails(url, {
9
10
  method: 'GET'
10
11
  });
11
12
  if (resp.status !== 200) {
@@ -61,4 +61,22 @@ describe('Node', () => {
61
61
  const totalCredits = await sdk.node.totalCredits();
62
62
  expect(Number(totalCredits)).toBeGreaterThan(0);
63
63
  });
64
+ test('should be able to call getCurrentQuorumsInfo', async () => {
65
+ const quorumsInfo = await sdk.node.getCurrentQuorumsInfo();
66
+ expect(quorumsInfo.quorumHashes.length).toBeGreaterThan(0);
67
+ expect(quorumsInfo.currentQuorumHash).toMatch(/^[0-9a-f]{64}$/);
68
+ expect(quorumsInfo.lastBlockProposer).toMatch(/^[0-9a-f]{64}$/);
69
+ expect(quorumsInfo.validatorSets.length).toBeGreaterThan(0);
70
+ for (const validatorSet of quorumsInfo.validatorSets) {
71
+ expect(validatorSet.quorumHash).toMatch(/^[0-9a-f]{64}$/);
72
+ expect(validatorSet.coreHeight).toBeGreaterThan(0);
73
+ expect(validatorSet.thresholdPublicKey).toMatch(/^[0-9a-f]{96}$/);
74
+ expect(validatorSet.members.length).toBeGreaterThan(0);
75
+ for (const member of validatorSet.members) {
76
+ expect(member.proTxHash).toMatch(/^[0-9a-f]{64}$/);
77
+ expect(member.nodeIp).toEqual(expect.any(String));
78
+ expect(member.isBanned).toEqual(expect.any(Boolean));
79
+ }
80
+ }
81
+ });
64
82
  });
@@ -1,2 +0,0 @@
1
- import { MasternodeList, Network } from '../../types.js';
2
- export default function getDAPINodeList(network: Network): Promise<MasternodeList>;
@@ -1,12 +0,0 @@
1
- export default async function getDAPINodeList(network) {
2
- const url = `https://${network === 'mainnet' ? '' : 'testnet.'}platform-explorer.pshenmic.dev/validators?isActive=true`;
3
- const resp = await fetch(url);
4
- if (resp.status !== 200) {
5
- throw new Error('Failed to query Platform Explorer for active validators');
6
- }
7
- const { resultSet } = await resp.json();
8
- return resultSet
9
- // eslint-disable-next-line
10
- .map((validator) => validator?.proTxInfo?.state?.service ? `https://${validator.proTxInfo.state.service.split(':')[0]}${network === 'mainnet' ? '' : ':1443'}` : undefined)
11
- .filter(e => e != null);
12
- }