dash-platform-sdk 1.5.0 → 1.5.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.
- package/README.md +15 -15
- package/bundle.min.js +1 -1
- package/index.d.ts +4 -1
- package/index.js +3 -1
- package/package.json +1 -1
- package/proto/generated/platform.client.d.ts +10 -0
- package/proto/generated/platform.client.js +25 -18
- package/proto/generated/platform.d.ts +162 -0
- package/proto/generated/platform.js +351 -0
- package/src/DashPlatformSDK.d.ts +19 -7
- package/src/DashPlatformSDK.js +33 -3
- package/src/contestedResources/getContestedResourceVoteState.d.ts +2 -2
- package/src/contestedResources/index.d.ts +3 -3
- package/src/dataContracts/getDataContractByIdentifier.d.ts +2 -2
- package/src/dataContracts/index.d.ts +3 -3
- package/src/documents/index.d.ts +3 -3
- package/src/documents/query.d.ts +2 -2
- package/src/grpcConnectionPool.d.ts +19 -2
- package/src/grpcConnectionPool.js +44 -16
- package/src/identities/getIdentityBalance.d.ts +2 -2
- package/src/identities/getIdentityByIdentifier.d.ts +2 -2
- package/src/identities/getIdentityByNonUniquePublicKeyHash.d.ts +2 -2
- package/src/identities/getIdentityByPublicKeyHash.d.ts +2 -2
- package/src/identities/getIdentityContractNonce.d.ts +2 -2
- package/src/identities/getIdentityNonce.d.ts +2 -2
- package/src/identities/getIdentityPublicKeys.d.ts +2 -2
- package/src/identities/index.d.ts +3 -3
- package/src/names/index.d.ts +3 -3
- package/src/names/registerName.d.ts +2 -2
- package/src/names/searchByIdentity.d.ts +2 -2
- package/src/names/searchByName.d.ts +2 -2
- package/src/node/epochInfos.d.ts +2 -2
- package/src/node/finalizedEpochInfos.d.ts +2 -2
- package/src/node/getCurrentQuorumsInfo.d.ts +19 -0
- package/src/node/getCurrentQuorumsInfo.js +31 -0
- package/src/node/index.d.ts +11 -3
- package/src/node/index.js +10 -0
- package/src/node/status.d.ts +2 -2
- package/src/node/totalCredits.d.ts +2 -2
- package/src/platformAddresses/getAddressInfo.d.ts +2 -2
- package/src/platformAddresses/getAddressesBranchState.d.ts +2 -2
- package/src/platformAddresses/getAddressesInfos.d.ts +2 -2
- package/src/platformAddresses/getAddressesTrunkState.d.ts +2 -2
- package/src/platformAddresses/getRecentAddressBalanceChanges.d.ts +2 -2
- package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.d.ts +2 -2
- package/src/platformAddresses/index.d.ts +3 -3
- package/src/shielded/getMostRecentShieldedAnchor.d.ts +2 -2
- package/src/shielded/getShieldedAnchors.d.ts +2 -2
- package/src/shielded/getShieldedEncryptedNotes.d.ts +2 -2
- package/src/shielded/getShieldedNotesCount.d.ts +2 -2
- package/src/shielded/getShieldedNullifiers.d.ts +2 -2
- package/src/shielded/getShieldedPoolState.d.ts +2 -2
- package/src/shielded/index.d.ts +3 -3
- package/src/stateTransitions/broadcast.d.ts +2 -2
- package/src/stateTransitions/index.d.ts +3 -3
- package/src/stateTransitions/waitForStateTransitionResult.d.ts +2 -2
- package/src/tokens/getIdentitiesTokenBalances.d.ts +2 -2
- package/src/tokens/getIdentityTokensBalances.d.ts +2 -2
- package/src/tokens/getTokenContractInfo.d.ts +2 -2
- package/src/tokens/getTokenDirectPurchasePrices.d.ts +2 -2
- package/src/tokens/getTokenTotalSupply.d.ts +2 -2
- package/src/tokens/index.d.ts +3 -3
- package/src/utils/fetchWithDetails.d.ts +24 -0
- package/src/utils/fetchWithDetails.js +71 -0
- package/src/utils/getQuorumPublicKey.js +2 -1
- package/test/unit/ContestedResources.spec.js +2 -1
- package/test/unit/DataContract.spec.js +2 -1
- package/test/unit/Document.spec.js +2 -1
- package/test/unit/Identity.spec.js +2 -1
- package/test/unit/Names.spec.js +2 -1
- package/test/unit/Node.spec.js +20 -1
- package/test/unit/PlatformAddress.spec.js +2 -1
- package/test/unit/Shielded.spec.js +1 -0
- package/test/unit/Tokens.spec.js +2 -1
- package/src/utils/getEvonodeList.d.ts +0 -2
- package/src/utils/getEvonodeList.js +0 -12
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport';
|
|
2
2
|
import { PlatformClient } from '../proto/generated/platform.client.js';
|
|
3
|
-
import getEvonodeList from './utils/getEvonodeList.js';
|
|
4
3
|
import { GetStatusRequest } from '../proto/generated/platform.js';
|
|
4
|
+
import getCurrentQuorumsInfo from './node/getCurrentQuorumsInfo.js';
|
|
5
5
|
import getRandomArrayItem from './utils/getRandomArrayItem.js';
|
|
6
|
+
import { fetchWithDetails } from './utils/fetchWithDetails.js';
|
|
6
7
|
const GRPC_DEFAULT_POOL_LIMIT = 5;
|
|
7
8
|
const seedNodes = {
|
|
8
9
|
testnet: [
|
|
9
10
|
// seed-1.pshenmic.dev
|
|
10
|
-
'https://158.160.14.115:1443'
|
|
11
|
+
'https://158.160.14.115:1443',
|
|
12
|
+
'https://62.84.119.150:1443',
|
|
13
|
+
// validator
|
|
14
|
+
'https://68.67.122.26:1443'
|
|
11
15
|
],
|
|
12
16
|
mainnet: [
|
|
13
17
|
// seed-1.pshenmic.dev
|
|
14
|
-
'https://158.160.14.115:443'
|
|
18
|
+
'https://158.160.14.115:443',
|
|
19
|
+
'https://62.84.119.150:443',
|
|
20
|
+
// validator
|
|
21
|
+
'https://95.216.146.18:443',
|
|
15
22
|
// mainnet dcg seeds
|
|
16
23
|
// 'https://158.160.14.115',
|
|
17
24
|
// 'https://3.0.60.103',
|
|
18
25
|
// 'https://34.211.174.194'
|
|
19
26
|
]
|
|
20
27
|
};
|
|
21
|
-
const
|
|
28
|
+
const DAPI_PORTS = {
|
|
29
|
+
testnet: 1443,
|
|
30
|
+
mainnet: 443
|
|
31
|
+
};
|
|
32
|
+
export const createClient = (url, abortController) => {
|
|
22
33
|
return new PlatformClient(new GrpcWebFetchTransport({
|
|
23
34
|
baseUrl: url,
|
|
24
|
-
abort: abortController?.signal
|
|
35
|
+
abort: abortController?.signal,
|
|
36
|
+
fetch: fetchWithDetails
|
|
25
37
|
}));
|
|
26
38
|
};
|
|
27
39
|
export default class GRPCConnectionPool {
|
|
28
40
|
dapiUrls;
|
|
29
41
|
network;
|
|
42
|
+
#initialization;
|
|
30
43
|
constructor(network, grpcOptions) {
|
|
31
44
|
const grpcPoolLimit = grpcOptions?.poolLimit ?? GRPC_DEFAULT_POOL_LIMIT;
|
|
32
45
|
this.network = network;
|
|
33
|
-
this._initialize(network, grpcPoolLimit, grpcOptions?.dapiUrl).catch(console.error);
|
|
46
|
+
this.#initialization = this._initialize(network, grpcPoolLimit, grpcOptions?.dapiUrl).catch(console.error);
|
|
34
47
|
}
|
|
35
48
|
async _initialize(network, poolLimit, dapiUrl) {
|
|
36
49
|
if (typeof dapiUrl === 'string') {
|
|
@@ -45,17 +58,24 @@ export default class GRPCConnectionPool {
|
|
|
45
58
|
throw new Error('Unrecognized DAPI URL');
|
|
46
59
|
}
|
|
47
60
|
// Add default seed nodes
|
|
48
|
-
this.dapiUrls = seedNodes[network];
|
|
49
|
-
// retrieve
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
this.dapiUrls = [...seedNodes[network]];
|
|
62
|
+
// retrieve evonodes from current validator sets through the first responding seed node,
|
|
63
|
+
// seed nodes that failed to respond are removed from the pool
|
|
64
|
+
const seedRequests = seedNodes[network].map(async (seed) => {
|
|
65
|
+
try {
|
|
66
|
+
return await getCurrentQuorumsInfo({ network, getClient: () => createClient(seed) });
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
this.dapiUrls = this.dapiUrls.filter(url => url !== seed);
|
|
70
|
+
throw e;
|
|
71
|
+
}
|
|
58
72
|
});
|
|
73
|
+
const { validatorSets } = await Promise.any(seedRequests);
|
|
74
|
+
// map it to array of dapiUrls
|
|
75
|
+
const networkDAPIUrls = [...new Set(validatorSets
|
|
76
|
+
.flatMap(validatorSet => validatorSet.members)
|
|
77
|
+
.filter(member => !member.isBanned)
|
|
78
|
+
.map(member => `https://${member.nodeIp}:${DAPI_PORTS[network]}`))];
|
|
59
79
|
// healthcheck nodes
|
|
60
80
|
for (const url of networkDAPIUrls) {
|
|
61
81
|
if (this.dapiUrls.length > poolLimit) {
|
|
@@ -71,6 +91,14 @@ export default class GRPCConnectionPool {
|
|
|
71
91
|
catch (e) {
|
|
72
92
|
}
|
|
73
93
|
}
|
|
94
|
+
// wait until every seed node responded or failed, so dead ones are removed from the pool
|
|
95
|
+
await Promise.allSettled(seedRequests);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Resolves when the pool initialization (seed nodes check and evonodes discovery) is finished
|
|
99
|
+
*/
|
|
100
|
+
async waitForInit() {
|
|
101
|
+
await this.#initialization;
|
|
74
102
|
}
|
|
75
103
|
getClient(abortController) {
|
|
76
104
|
const dapiUrl = getRandomArrayItem(this.dapiUrls);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IdentifierLike } from 'pshenmic-dpp';
|
|
2
|
-
import
|
|
3
|
-
export default function getIdentityBalance(grpcPool:
|
|
2
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
3
|
+
export default function getIdentityBalance(grpcPool: GRPCPool, identifier: IdentifierLike): Promise<bigint>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IdentifierLike, IdentityWASM } from 'pshenmic-dpp';
|
|
2
|
-
import
|
|
3
|
-
export default function getIdentityByIdentifier(grpcPool:
|
|
2
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
3
|
+
export default function getIdentityByIdentifier(grpcPool: GRPCPool, identifier: IdentifierLike): Promise<IdentityWASM>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IdentityWASM } from 'pshenmic-dpp';
|
|
2
|
-
import
|
|
3
|
-
export default function getIdentityByNonUniquePublicKeyHash(grpcPool:
|
|
2
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
3
|
+
export default function getIdentityByNonUniquePublicKeyHash(grpcPool: GRPCPool, hex: string): Promise<IdentityWASM>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IdentityWASM } from 'pshenmic-dpp';
|
|
2
|
-
import
|
|
3
|
-
export default function getIdentityByPublicKeyHash(grpcPool:
|
|
2
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
3
|
+
export default function getIdentityByPublicKeyHash(grpcPool: GRPCPool, hex: string): Promise<IdentityWASM>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IdentifierLike } from 'pshenmic-dpp';
|
|
2
|
-
import
|
|
3
|
-
export default function getIdentityContractNonce(grpcPool:
|
|
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
|
|
3
|
-
export default function getIdentityNonce(grpcPool:
|
|
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
|
|
3
|
-
export default function getIdentityPublicKeys(grpcPool:
|
|
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
|
|
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:
|
|
12
|
-
constructor(grpcPool:
|
|
11
|
+
grpcPool: GRPCPool;
|
|
12
|
+
constructor(grpcPool: GRPCPool);
|
|
13
13
|
/**
|
|
14
14
|
* Get current balance of your Identity by identifier
|
|
15
15
|
*
|
package/src/names/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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:
|
|
11
|
-
constructor(grpcPool:
|
|
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
|
|
3
|
-
export default function registerName(grpcPool:
|
|
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
|
|
3
|
-
export default function searchByIdentity(grpcPool:
|
|
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
|
|
3
|
-
export default function search(grpcPool:
|
|
2
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
3
|
+
export default function search(grpcPool: GRPCPool, name: string): Promise<DocumentWASM[]>;
|
package/src/node/epochInfos.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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:
|
|
10
|
+
export default function epochInfos(grpcPool: GRPCPool, count: number, ascending: boolean, start?: number): Promise<EpochInfo[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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:
|
|
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
|
+
}
|
package/src/node/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
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:
|
|
13
|
-
constructor(grpcPool:
|
|
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
|
}
|
package/src/node/status.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { NodeStatus } from '../../types.js';
|
|
2
|
-
import
|
|
3
|
-
export default function status(grpcPool:
|
|
2
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
3
|
+
export default function status(grpcPool: GRPCPool): Promise<NodeStatus>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default function totalCredits(grpcPool:
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
|
+
export default function totalCredits(grpcPool: GRPCPool): Promise<bigint>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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:
|
|
4
|
+
export declare function getAddressInfo(grpcPool: GRPCPool, platformAddress: PlatformAddressLike): Promise<PlatformAddressInfo>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
2
|
import { VerifiedAddressesBranchState } from 'pshenmic-dpp';
|
|
3
|
-
export declare function getAddressesBranchState(grpcPool:
|
|
3
|
+
export declare function getAddressesBranchState(grpcPool: GRPCPool, key: Uint8Array, depth: number, checkpointHeight: bigint, expectedRootHash: Uint8Array): Promise<VerifiedAddressesBranchState>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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:
|
|
4
|
+
export declare function getAddressesInfos(grpcPool: GRPCPool, platformAddresses: PlatformAddressLike[]): Promise<PlatformAddressInfo[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
2
|
import { PlatformAddressesTrunkState } from '../../types.js';
|
|
3
|
-
export declare function getAddressesTrunkState(grpcPool:
|
|
3
|
+
export declare function getAddressesTrunkState(grpcPool: GRPCPool): Promise<PlatformAddressesTrunkState>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
2
|
import { BlockAddressBalanceChanges } from 'pshenmic-dpp';
|
|
3
|
-
export declare function getRecentAddressBalanceChanges(grpcPool:
|
|
3
|
+
export declare function getRecentAddressBalanceChanges(grpcPool: GRPCPool, startHeight: bigint, startHeightExclusive?: boolean): Promise<BlockAddressBalanceChanges[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
2
|
import { CompactedBlockAddressBalanceChanges } from 'pshenmic-dpp';
|
|
3
|
-
export declare function getRecentCompactedAddressBalanceChanges(grpcPool:
|
|
3
|
+
export declare function getRecentCompactedAddressBalanceChanges(grpcPool: GRPCPool, startBlockHeight: bigint): Promise<CompactedBlockAddressBalanceChanges[]>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
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:
|
|
7
|
-
constructor(grpcPool:
|
|
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
|
|
2
|
-
export default function getMostRecentShieldedAnchor(grpcPool:
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
|
+
export default function getMostRecentShieldedAnchor(grpcPool: GRPCPool): Promise<Uint8Array | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default function getShieldedAnchors(grpcPool:
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
|
+
export default function getShieldedAnchors(grpcPool: GRPCPool): Promise<Uint8Array[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
2
|
import { ShieldedEncryptedNote } from '../../types.js';
|
|
3
|
-
export default function getShieldedEncryptedNotes(grpcPool:
|
|
3
|
+
export default function getShieldedEncryptedNotes(grpcPool: GRPCPool, startIndex: bigint, count: number): Promise<ShieldedEncryptedNote[]>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default function getShieldedNotesCount(grpcPool:
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
|
+
export default function getShieldedNotesCount(grpcPool: GRPCPool): Promise<bigint | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
2
|
import { ShieldedNullifierStatus } from '../../types.js';
|
|
3
|
-
export default function getShieldedNullifiers(grpcPool:
|
|
3
|
+
export default function getShieldedNullifiers(grpcPool: GRPCPool, nullifiers: Uint8Array[]): Promise<ShieldedNullifierStatus[]>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default function getShieldedPoolState(grpcPool:
|
|
1
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
2
|
+
export default function getShieldedPoolState(grpcPool: GRPCPool): Promise<bigint | undefined>;
|
package/src/shielded/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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:
|
|
11
|
+
grpcPool: GRPCPool;
|
|
12
12
|
/** @ignore **/
|
|
13
13
|
shieldedBuilder?: ShieldedBuilderWASM;
|
|
14
|
-
constructor(grpcPool:
|
|
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
|
|
3
|
-
export default function broadcast(grpcPool:
|
|
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
|
|
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:
|
|
11
|
-
constructor(grpcPool:
|
|
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
|
|
3
|
-
export default function waitForStateTransitionResult(grpcPool:
|
|
2
|
+
import { GRPCPool } from '../grpcConnectionPool.js';
|
|
3
|
+
export default function waitForStateTransitionResult(grpcPool: GRPCPool, stateTransition: StateTransitionWASM): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
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:
|
|
7
|
+
export default function getIdentitiesTokenBalances(grpcPool: GRPCPool, identifiers: IdentifierLike[], tokenIdentifier: IdentifierLike): Promise<IdentitiesTokenBalances[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
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:
|
|
7
|
+
export default function getIdentityTokensBalances(grpcPool: GRPCPool, identifier: IdentifierLike, tokenIdentifiers: IdentifierLike[]): Promise<IdentityTokenBalances[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
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:
|
|
7
|
+
export default function getTokenContractInfo(grpcPool: GRPCPool, tokenIdentifier: IdentifierLike): Promise<TokenContractInfo>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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:
|
|
4
|
+
export default function getTokenDirectPurchasePrices(grpcPool: GRPCPool, tokenIdentifiers: IdentifierLike[]): Promise<TokenDirectPurchasePrices[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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:
|
|
4
|
+
export default function getTokenTotalSupply(grpcPool: GRPCPool, tokenIdentifier: IdentifierLike): Promise<TokenTotalSupply>;
|
package/src/tokens/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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:
|
|
15
|
-
constructor(grpcPool:
|
|
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;
|