dash-platform-sdk 1.3.2-dev.5 → 1.4.0-dev.10
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/bundle.min.js +17 -17
- package/package.json +2 -6
- package/proto/generated/platform.client.d.ts +20 -0
- package/proto/generated/platform.client.js +14 -0
- package/proto/generated/platform.d.ts +293 -0
- package/proto/generated/platform.js +603 -1
- package/src/DashPlatformSDK.d.ts +3 -1
- package/src/DashPlatformSDK.js +8 -5
- package/src/constants.js +1 -2
- package/src/contestedResources/getContestedResourceVoteState.js +5 -2
- package/src/dataContracts/create.d.ts +3 -3
- package/src/dataContracts/create.js +1 -1
- package/src/dataContracts/createStateTransition.js +0 -1
- package/src/dataContracts/getDataContractByIdentifier.d.ts +1 -2
- package/src/dataContracts/index.d.ts +3 -3
- package/src/documents/create.d.ts +1 -2
- package/src/documents/index.d.ts +3 -3
- package/src/documents/query.d.ts +2 -3
- package/src/documents/query.js +3 -4
- package/src/identities/getIdentityBalance.d.ts +1 -1
- package/src/identities/getIdentityByIdentifier.d.ts +1 -2
- package/src/identities/getIdentityContractNonce.d.ts +1 -1
- package/src/identities/getIdentityNonce.d.ts +1 -1
- package/src/identities/getIdentityPublicKeys.d.ts +1 -2
- package/src/identities/index.d.ts +2 -2
- package/src/identities/index.js +2 -3
- package/src/names/index.d.ts +1 -2
- package/src/node/index.d.ts +2 -3
- package/src/node/index.js +2 -4
- package/src/node/totalCredits.d.ts +1 -2
- package/src/node/totalCredits.js +2 -2
- package/src/platformAddresses/getAddressInfo.d.ts +4 -0
- package/src/platformAddresses/getAddressInfo.js +45 -0
- package/src/platformAddresses/getAddressesInfos.d.ts +4 -0
- package/src/platformAddresses/getAddressesInfos.js +43 -0
- package/src/platformAddresses/index.d.ts +22 -0
- package/src/platformAddresses/index.js +27 -0
- package/src/stateTransitions/broadcast.js +2 -3
- package/src/stateTransitions/waitForStateTransitionResult.js +8 -2
- package/src/tokens/getIdentitiesTokenBalances.d.ts +2 -3
- package/src/tokens/getIdentitiesTokenBalances.js +3 -3
- package/src/tokens/getIdentityTokensBalances.d.ts +2 -3
- package/src/tokens/getIdentityTokensBalances.js +3 -3
- package/src/tokens/getTokenContractInfo.d.ts +1 -2
- package/src/tokens/getTokenDirectPurchasePrices.d.ts +2 -1
- package/src/tokens/getTokenTotalSupply.d.ts +2 -1
- package/src/tokens/index.d.ts +2 -2
- package/src/utils/index.d.ts +1 -2
- package/src/voting/index.d.ts +2 -2
- package/test/unit/Document.spec.js +2 -31
- package/test/unit/Identity.spec.js +26 -26
- package/test/unit/Names.spec.js +2 -2
- package/test/unit/PlatformAddress.spec.d.ts +1 -0
- package/test/unit/PlatformAddress.spec.js +22 -0
- package/test/unit/Tokens.spec.js +3 -3
- package/types.d.ts +11 -7
- package/types.js +1 -1
package/src/DashPlatformSDK.js
CHANGED
|
@@ -10,6 +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 { PlatformAddressesController } from './platformAddresses/index.js';
|
|
13
14
|
/**
|
|
14
15
|
* Javascript SDK for that let you interact with a Dash Platform blockchain
|
|
15
16
|
*/
|
|
@@ -20,6 +21,7 @@ export class DashPlatformSDK {
|
|
|
20
21
|
/** @ignore **/
|
|
21
22
|
options;
|
|
22
23
|
contestedResources;
|
|
24
|
+
platformAddresses;
|
|
23
25
|
stateTransitions;
|
|
24
26
|
dataContracts;
|
|
25
27
|
identities;
|
|
@@ -49,7 +51,7 @@ export class DashPlatformSDK {
|
|
|
49
51
|
this.options.grpc = { dapiUrl: options.dapiUrl };
|
|
50
52
|
}
|
|
51
53
|
this.grpcPool = new GRPCConnectionPool(this.network, this.options?.grpc);
|
|
52
|
-
this._initialize(this.grpcPool
|
|
54
|
+
this._initialize(this.grpcPool);
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* @private
|
|
@@ -59,15 +61,16 @@ export class DashPlatformSDK {
|
|
|
59
61
|
* @param grpcPool
|
|
60
62
|
* @param network
|
|
61
63
|
*/
|
|
62
|
-
_initialize(grpcPool
|
|
64
|
+
_initialize(grpcPool) {
|
|
63
65
|
this.grpcPool = grpcPool;
|
|
64
|
-
this.stateTransitions = new StateTransitionsController(grpcPool);
|
|
65
66
|
this.contestedResources = new ContestedResourcesController(grpcPool);
|
|
67
|
+
this.platformAddresses = new PlatformAddressesController(grpcPool);
|
|
68
|
+
this.stateTransitions = new StateTransitionsController(grpcPool);
|
|
66
69
|
this.dataContracts = new DataContractsController(grpcPool);
|
|
67
70
|
this.identities = new IdentitiesController(grpcPool);
|
|
68
71
|
this.documents = new DocumentsController(grpcPool);
|
|
69
72
|
this.voting = new VotingController();
|
|
70
|
-
this.node = new NodeController(grpcPool
|
|
73
|
+
this.node = new NodeController(grpcPool);
|
|
71
74
|
this.tokens = new TokensController(grpcPool);
|
|
72
75
|
this.names = new NamesController(grpcPool);
|
|
73
76
|
this.keyPair = new KeyPairController();
|
|
@@ -91,6 +94,6 @@ export class DashPlatformSDK {
|
|
|
91
94
|
}
|
|
92
95
|
this.network = network;
|
|
93
96
|
const grpcPool = new GRPCConnectionPool(this.network, this.options?.grpc);
|
|
94
|
-
this._initialize(grpcPool
|
|
97
|
+
this._initialize(grpcPool);
|
|
95
98
|
}
|
|
96
99
|
}
|
package/src/constants.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PlatformVersionWASM } from 'pshenmic-dpp';
|
|
2
1
|
/**
|
|
3
2
|
* Default amount of documents to retrieve from DAPI
|
|
4
3
|
*/
|
|
@@ -9,4 +8,4 @@ export const MAINNET_ACTIVATION_HEIGHT = 2128896;
|
|
|
9
8
|
export const GRPC_DEFAULT_POOL_LIMIT = 5;
|
|
10
9
|
export const DPNS_DATA_CONTRACT_ID = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br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bG9uZ2VyIHRoYW4gMjUzIGNoYXJzIGxlbmd0aCBhcyBkZWZpbmVkIGJ5IFJGQyAxMDM1LiBEb21haW4gZG9jdW1lbnRzIGFyZSBpbW11dGFibGU6IG1vZGlmaWNhdGlvbiBhbmQgZGVsZXRpb24gYXJlIHJlc3RyaWN0ZWQIcHJlb3JkZXIWCBIQZG9jdW1lbnRzTXV0YWJsZRMAEgxjYW5CZURlbGV0ZWQTARIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQEWAxIEbmFtZRIKc2FsdGVkSGFzaBIKcHJvcGVydGllcxUBFgESEHNhbHRlZERvbWFpbkhhc2gSA2FzYxIGdW5pcXVlEwESCnByb3BlcnRpZXMWARIQc2FsdGVkRG9tYWluSGFzaBYGEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASCHBvc2l0aW9uAgASC2Rlc2NyaXB0aW9uEllEb3VibGUgc2hhLTI1NiBvZiB0aGUgY29uY2F0ZW5hdGlvbiBvZiBhIDMyIGJ5dGUgcmFuZG9tIHNhbHQgYW5kIGEgbm9ybWFsaXplZCBkb21haW4gbmFtZRIIcmVxdWlyZWQVARIQc2FsdGVkRG9tYWluSGFzaBIUYWRkaXRpb25hbFByb3BlcnRpZXMTABIIJGNvbW1lbnQSSlByZW9yZGVyIGRvY3VtZW50cyBhcmUgaW1tdXRhYmxlOiBtb2RpZmljYXRpb24gYW5kIGRlbGV0aW9uIGFyZSByZXN0cmljdGVkAAAAAAAAAAAAAA==';
|
|
12
|
-
export const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V11
|
|
11
|
+
export const LATEST_PLATFORM_VERSION = 11 /* PlatformVersionWASM.PLATFORM_V11 */;
|
|
@@ -40,7 +40,10 @@ export default async function getContestedResourceVoteState(grpcPool, contract,
|
|
|
40
40
|
if (metadata == null) {
|
|
41
41
|
throw new Error('Metadata not found');
|
|
42
42
|
}
|
|
43
|
-
const { rootHash, result } = verifyVotePollVoteStateProof(proof.grovedbProof, contract, documentTypeName, indexName, indexValues,
|
|
43
|
+
const { rootHash, result } = verifyVotePollVoteStateProof(proof.grovedbProof, contract, documentTypeName, indexName, indexValues,
|
|
44
|
+
// same enums
|
|
45
|
+
// @ts-expect-error
|
|
46
|
+
resultType, allowIncludeLockedAndAbstainingVoteTally, count, startAtIdentifierInfo, LATEST_PLATFORM_VERSION);
|
|
44
47
|
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
45
48
|
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
46
49
|
if (!verify) {
|
|
@@ -63,7 +66,7 @@ export default async function getContestedResourceVoteState(grpcPool, contract,
|
|
|
63
66
|
finishedVoteInfo: (winner != null)
|
|
64
67
|
? {
|
|
65
68
|
type: winner.type,
|
|
66
|
-
wonByIdentityId: winner.identityId != null ? new IdentifierWASM(winner.identityId) : undefined,
|
|
69
|
+
wonByIdentityId: 'identityId' in winner && winner.identityId != null ? new IdentifierWASM(winner.identityId) : undefined,
|
|
67
70
|
finishedAtBlockHeight: winner.blockInfo.height,
|
|
68
71
|
finishedAtCoreBlockHeight: winner.blockInfo.coreHeight,
|
|
69
72
|
finishedAtBlockTimeMs: winner.blockInfo.timeMs,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DataContractWASM,
|
|
2
|
-
import { DataContractConfig
|
|
3
|
-
export default function createDataContract(ownerId: IdentifierLike, identityNonce: bigint, schema: object, tokenConfiguration?:
|
|
1
|
+
import { DataContractTokens, DataContractWASM, IdentifierLike, PlatformVersionWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { DataContractConfig } from '../../types.js';
|
|
3
|
+
export default function createDataContract(ownerId: IdentifierLike, identityNonce: bigint, schema: object, tokenConfiguration?: DataContractTokens[], config?: DataContractConfig, fullValidation?: boolean | undefined, platformVersion?: PlatformVersionWASM | undefined): DataContractWASM;
|
|
@@ -4,7 +4,7 @@ export default function createDataContract(ownerId, identityNonce, schema, token
|
|
|
4
4
|
const id = new IdentifierWASM(ownerId);
|
|
5
5
|
const dataContract = new DataContractWASM(id, identityNonce, schema,
|
|
6
6
|
// we don't know what that param means yet
|
|
7
|
-
|
|
7
|
+
undefined, tokenConfiguration, fullValidation ?? true, platformVersion ?? LATEST_PLATFORM_VERSION);
|
|
8
8
|
if (config != null) {
|
|
9
9
|
dataContract.setConfig(config, platformVersion);
|
|
10
10
|
}
|
|
@@ -13,7 +13,6 @@ export default function createStateTransition(dataContract, type, identityNonce)
|
|
|
13
13
|
if (TransitionClass == null) {
|
|
14
14
|
throw new Error(`Unknown DataContract transition type: ${type}. Should be 'create' or 'update'.`);
|
|
15
15
|
}
|
|
16
|
-
// @ts-expect-error
|
|
17
16
|
const dataContractTransition = new TransitionClass(dataContract, identityNonce);
|
|
18
17
|
return dataContractTransition.toStateTransition();
|
|
19
18
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DataContractWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentifierLike } from '../../types.js';
|
|
1
|
+
import { DataContractWASM, IdentifierLike } from 'pshenmic-dpp';
|
|
3
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
3
|
export default function getByIdentifier(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<DataContractWASM>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DataContractWASM, PlatformVersionWASM, StateTransitionWASM, TokenConfigurationWASM } from 'pshenmic-dpp';
|
|
1
|
+
import { DataContractTokens, DataContractWASM, IdentifierLike, PlatformVersionWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
3
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
3
|
+
import { DataContractConfig } from '../../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Collection of methods necessary to work with Data Contracts in the network,
|
|
6
6
|
* such as data contract creation or retrieval
|
|
@@ -25,7 +25,7 @@ export declare class DataContractsController {
|
|
|
25
25
|
*
|
|
26
26
|
* @return {DataContractWASM}
|
|
27
27
|
*/
|
|
28
|
-
create(ownerId: IdentifierLike, identityNonce: bigint, schema: object, fullValidation?: boolean, tokenConfiguration?:
|
|
28
|
+
create(ownerId: IdentifierLike, identityNonce: bigint, schema: object, fullValidation?: boolean, tokenConfiguration?: DataContractTokens[], config?: DataContractConfig, platformVersion?: PlatformVersionWASM): DataContractWASM;
|
|
29
29
|
/**
|
|
30
30
|
* Retrieves a Data Contract by an identifier from the network
|
|
31
31
|
*
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { DocumentWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentifierLike } from '../../types.js';
|
|
1
|
+
import { DocumentWASM, IdentifierLike } from 'pshenmic-dpp';
|
|
3
2
|
export default function createDocument(dataContractId: IdentifierLike, documentType: string, data: object, owner: IdentifierLike, revision?: bigint, documentId?: IdentifierLike): DocumentWASM;
|
package/src/documents/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DocumentTransitionParams
|
|
2
|
-
import { DocumentWASM, IdentifierWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
1
|
+
import { DocumentTransitionParams } from '../../types.js';
|
|
2
|
+
import { DocumentWASM, IdentifierLike, IdentifierWASM, StateTransitionWASM, WhereClause } from 'pshenmic-dpp';
|
|
3
3
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
4
|
/**
|
|
5
5
|
* Collection of methods to work with documents like creation, querying or preparing a transition action
|
|
@@ -33,7 +33,7 @@ export declare class DocumentsController {
|
|
|
33
33
|
* @param startAt {IdentifierLike=} Optional offset, where startAt is an identifier of the document. Use identifier of last item in previous response
|
|
34
34
|
* @param startAfter {IdentifierLike=} Same as previous, but with exclusion. Cannot be set if startAt already provided
|
|
35
35
|
*/
|
|
36
|
-
query(dataContractId: IdentifierLike, documentType: string, where?:
|
|
36
|
+
query(dataContractId: IdentifierLike, documentType: string, where?: WhereClause[], orderBy?: string[][], limit?: number, startAt?: IdentifierWASM, startAfter?: IdentifierWASM): Promise<DocumentWASM[]>;
|
|
37
37
|
/**
|
|
38
38
|
* Helper function for creating {StateTransitionWASM} from documents. It may be used to create any of 6 Document Transition actions:
|
|
39
39
|
*
|
package/src/documents/query.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DocumentWASM, IdentifierWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentifierLike } from '../../types.js';
|
|
1
|
+
import { DocumentWASM, IdentifierLike, IdentifierWASM, WhereClause } from 'pshenmic-dpp';
|
|
3
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
|
-
export default function query(grpcPool: GRPCConnectionPool, dataContractId: IdentifierLike, documentTypeName: string, where?:
|
|
3
|
+
export default function query(grpcPool: GRPCConnectionPool, dataContractId: IdentifierLike, documentTypeName: string, where?: WhereClause[], orderBy?: string[][], limit?: number | undefined, startAt?: IdentifierWASM, startAfter?: IdentifierWASM): Promise<DocumentWASM[]>;
|
package/src/documents/query.js
CHANGED
|
@@ -11,13 +11,13 @@ export default async function query(grpcPool, dataContractId, documentTypeName,
|
|
|
11
11
|
if (startAt != null) {
|
|
12
12
|
start = {
|
|
13
13
|
oneofKind: 'startAt',
|
|
14
|
-
startAt: startAt.
|
|
14
|
+
startAt: startAt.base58()
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
if (startAfter != null) {
|
|
18
18
|
start = {
|
|
19
19
|
oneofKind: 'startAfter',
|
|
20
|
-
|
|
20
|
+
startAt: startAfter.base58()
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
const getDocumentsRequest = GetDocumentsRequest.create({
|
|
@@ -49,8 +49,7 @@ export default async function query(grpcPool, dataContractId, documentTypeName,
|
|
|
49
49
|
throw new Error('Metadata not found');
|
|
50
50
|
}
|
|
51
51
|
const startAtIncluded = startAt != null;
|
|
52
|
-
const
|
|
53
|
-
const { rootHash, documents } = verifyDocumentsProof(proof.grovedbProof, dataContract, documentTypeName, where, orderBy, limit, startIdentifier?.bytes(), startAtIncluded, BigInt(metadata?.timeMs), LATEST_PLATFORM_VERSION);
|
|
52
|
+
const { rootHash, documents } = verifyDocumentsProof(proof.grovedbProof, dataContract, documentTypeName, where, orderBy, limit, startAt?.bytes(), startAtIncluded, BigInt(metadata?.timeMs), LATEST_PLATFORM_VERSION);
|
|
54
53
|
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
55
54
|
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
56
55
|
if (!verify) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IdentifierLike } from '
|
|
1
|
+
import { IdentifierLike } from 'pshenmic-dpp';
|
|
2
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
3
3
|
export default function getIdentityBalance(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<bigint>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IdentityWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentifierLike } from '../../types.js';
|
|
1
|
+
import { IdentifierLike, IdentityWASM } from 'pshenmic-dpp';
|
|
3
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
3
|
export default function getIdentityByIdentifier(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<IdentityWASM>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IdentifierLike } from '
|
|
1
|
+
import { IdentifierLike } from 'pshenmic-dpp';
|
|
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 '
|
|
1
|
+
import { IdentifierLike } from 'pshenmic-dpp';
|
|
2
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
3
3
|
export default function getIdentityNonce(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<bigint>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IdentityPublicKeyWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentifierLike } from '../../types.js';
|
|
1
|
+
import { IdentifierLike, IdentityPublicKeyWASM } from 'pshenmic-dpp';
|
|
3
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
3
|
export default function getIdentityPublicKeys(grpcPool: GRPCConnectionPool, identifier: IdentifierLike, keyIds?: number[]): Promise<IdentityPublicKeyWASM[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IdentityTransitionParams } from '../../types.js';
|
|
2
2
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
3
|
-
import { IdentityPublicKeyWASM, IdentityWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
3
|
+
import { IdentifierLike, IdentityPublicKeyWASM, IdentityWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
4
4
|
/**
|
|
5
5
|
* Collection of methods to query identities and its related data
|
|
6
6
|
*
|
package/src/identities/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import getIdentityNonce from './getIdentityNonce.js';
|
|
|
4
4
|
import getIdentityBalance from './getIdentityBalance.js';
|
|
5
5
|
import getIdentityByPublicKeyHash from './getIdentityByPublicKeyHash.js';
|
|
6
6
|
import getIdentityByIdentifier from './getIdentityByIdentifier.js';
|
|
7
|
-
import { AssetLockProofWASM, ContractBoundsWASM, CoreScriptWASM, IdentifierWASM, IdentityPublicKeyInCreationWASM, OutPointWASM
|
|
7
|
+
import { AssetLockProofWASM, ContractBoundsWASM, CoreScriptWASM, IdentifierWASM, IdentityPublicKeyInCreationWASM, OutPointWASM } from 'pshenmic-dpp';
|
|
8
8
|
import createStateTransition from './createStateTransition.js';
|
|
9
9
|
import getIdentityByNonUniquePublicKeyHash from './getIdentityByNonUniquePublicKeyHash.js';
|
|
10
10
|
import hexToBytes from '../utils/hexToBytes.js';
|
|
@@ -144,8 +144,7 @@ export class IdentitiesController {
|
|
|
144
144
|
params.recipientId = new IdentifierWASM(params.recipientId);
|
|
145
145
|
}
|
|
146
146
|
if (type === 'withdrawal') {
|
|
147
|
-
|
|
148
|
-
params.pooling = params.pooling != null ? PoolingWASM[params.pooling] : PoolingWASM.Standard;
|
|
147
|
+
params.pooling = params.pooling ?? 'Standard';
|
|
149
148
|
params.coreFeePerByte = params.coreFeePerByte ?? 1;
|
|
150
149
|
params.outputScript = params.outputScript ?? (params.withdrawalAddress != null ? CoreScriptWASM.newP2PKH(base58.decode(params.withdrawalAddress).slice(1, 21)) : undefined);
|
|
151
150
|
}
|
package/src/names/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
import { DocumentWASM, PrivateKeyWASM } from 'pshenmic-dpp';
|
|
3
|
-
import { IdentifierLike } from '../../types.js';
|
|
2
|
+
import { DocumentWASM, IdentifierLike, PrivateKeyWASM } from 'pshenmic-dpp';
|
|
4
3
|
/**
|
|
5
4
|
* Functions related to DPNS names (usernames)
|
|
6
5
|
*
|
package/src/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
import {
|
|
2
|
+
import { NodeStatus } from '../../types.js';
|
|
3
3
|
import { EpochInfo } from './epochs.js';
|
|
4
4
|
/**
|
|
5
5
|
* Node controller for requesting information about DAPI node
|
|
@@ -9,8 +9,7 @@ import { EpochInfo } from './epochs.js';
|
|
|
9
9
|
export declare class NodeController {
|
|
10
10
|
/** @ignore **/
|
|
11
11
|
grpcPool: GRPCConnectionPool;
|
|
12
|
-
|
|
13
|
-
constructor(grpcPool: GRPCConnectionPool, network: Network);
|
|
12
|
+
constructor(grpcPool: GRPCConnectionPool);
|
|
14
13
|
/**
|
|
15
14
|
* Retrieves an info about node
|
|
16
15
|
* Includes information about genesis, chain, software versions
|
package/src/node/index.js
CHANGED
|
@@ -9,10 +9,8 @@ import getTotalCredits from './totalCredits.js';
|
|
|
9
9
|
export class NodeController {
|
|
10
10
|
/** @ignore **/
|
|
11
11
|
grpcPool;
|
|
12
|
-
|
|
13
|
-
constructor(grpcPool, network) {
|
|
12
|
+
constructor(grpcPool) {
|
|
14
13
|
this.grpcPool = grpcPool;
|
|
15
|
-
this.network = network;
|
|
16
14
|
}
|
|
17
15
|
/**
|
|
18
16
|
* Retrieves an info about node
|
|
@@ -29,7 +27,7 @@ export class NodeController {
|
|
|
29
27
|
* @return {Promise<bigint>}
|
|
30
28
|
*/
|
|
31
29
|
async totalCredits() {
|
|
32
|
-
return await getTotalCredits(this.grpcPool
|
|
30
|
+
return await getTotalCredits(this.grpcPool);
|
|
33
31
|
}
|
|
34
32
|
/**
|
|
35
33
|
* Retrieves an info about epochs
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
|
|
3
|
-
export default function totalCredits(grpcPool: GRPCConnectionPool, network: Network): Promise<bigint>;
|
|
2
|
+
export default function totalCredits(grpcPool: GRPCConnectionPool): Promise<bigint>;
|
package/src/node/totalCredits.js
CHANGED
|
@@ -4,7 +4,7 @@ import { verifyTotalCreditsProof } from 'pshenmic-dpp';
|
|
|
4
4
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
5
|
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
6
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
7
|
-
export default async function totalCredits(grpcPool
|
|
7
|
+
export default async function totalCredits(grpcPool) {
|
|
8
8
|
const getTotalCreditsInPlatformRequest = GetTotalCreditsInPlatformRequest.create({
|
|
9
9
|
version: {
|
|
10
10
|
oneofKind: 'v0',
|
|
@@ -24,7 +24,7 @@ export default async function totalCredits(grpcPool, network) {
|
|
|
24
24
|
if (metadata == null) {
|
|
25
25
|
throw new Error('Metadata not found');
|
|
26
26
|
}
|
|
27
|
-
const activationHeight = network === 'testnet' ? TESTNET_ACTIVATION_HEIGHT : MAINNET_ACTIVATION_HEIGHT;
|
|
27
|
+
const activationHeight = grpcPool.network === 'testnet' ? TESTNET_ACTIVATION_HEIGHT : MAINNET_ACTIVATION_HEIGHT;
|
|
28
28
|
const { rootHash, totalCredits } = verifyTotalCreditsProof(proof.grovedbProof, HALVING_INTERVAL, activationHeight, Number(metadata.height), LATEST_PLATFORM_VERSION);
|
|
29
29
|
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
30
30
|
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
+
import { PlatformAddressLike } from 'pshenmic-dpp';
|
|
3
|
+
import { PlatformAddressInfo } from '../../types.js';
|
|
4
|
+
export declare function getAddressInfo(grpcPool: GRPCConnectionPool, platformAddress: PlatformAddressLike): Promise<PlatformAddressInfo>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PlatformAddressWASM, verifyPlatformAddressInfo } from 'pshenmic-dpp';
|
|
2
|
+
import { GetAddressInfoRequest } from '../../proto/generated/platform.js';
|
|
3
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
7
|
+
export async function getAddressInfo(grpcPool, platformAddress) {
|
|
8
|
+
const platformAddressWASM = new PlatformAddressWASM(platformAddress);
|
|
9
|
+
const getAddressInfoRequest = GetAddressInfoRequest.create({
|
|
10
|
+
version: {
|
|
11
|
+
oneofKind: 'v0',
|
|
12
|
+
v0: {
|
|
13
|
+
address: platformAddressWASM.bytes(),
|
|
14
|
+
prove: true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const { response } = await grpcPool.getClient().getAddressInfo(getAddressInfoRequest);
|
|
19
|
+
const { version } = response;
|
|
20
|
+
if (version.oneofKind !== 'v0') {
|
|
21
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
22
|
+
}
|
|
23
|
+
const { v0 } = version;
|
|
24
|
+
if (v0.result.oneofKind !== 'proof') {
|
|
25
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
|
|
26
|
+
}
|
|
27
|
+
const { result: { proof }, metadata } = v0;
|
|
28
|
+
if (metadata == null) {
|
|
29
|
+
throw new Error('Metadata not found');
|
|
30
|
+
}
|
|
31
|
+
const { rootHash, address, nonce, balance } = verifyPlatformAddressInfo(proof.grovedbProof, platformAddressWASM, true, LATEST_PLATFORM_VERSION);
|
|
32
|
+
if (address == null || nonce == null || balance == null) {
|
|
33
|
+
throw new Error(`Failed to fetch info for address ${platformAddressWASM.toBech32m(grpcPool.network)}`);
|
|
34
|
+
}
|
|
35
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
36
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
37
|
+
if (!verify) {
|
|
38
|
+
throw new Error('Failed to verify query');
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
address,
|
|
42
|
+
nonce,
|
|
43
|
+
balance
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
+
import { PlatformAddressLike } from 'pshenmic-dpp';
|
|
3
|
+
import { PlatformAddressInfo } from '../../types.js';
|
|
4
|
+
export declare function getAddressesInfos(grpcPool: GRPCConnectionPool, platformAddresses: PlatformAddressLike[]): Promise<PlatformAddressInfo[]>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PlatformAddressWASM, verifyPlatformAddressesInfos } from 'pshenmic-dpp';
|
|
2
|
+
import { GetAddressesInfosRequest } from '../../proto/generated/platform.js';
|
|
3
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
7
|
+
export async function getAddressesInfos(grpcPool, platformAddresses) {
|
|
8
|
+
const platformAddressesWASM = platformAddresses.map(addr => new PlatformAddressWASM(addr));
|
|
9
|
+
const getAddressInfoRequest = GetAddressesInfosRequest.create({
|
|
10
|
+
version: {
|
|
11
|
+
oneofKind: 'v0',
|
|
12
|
+
v0: {
|
|
13
|
+
addresses: platformAddressesWASM.map(addr => addr.bytes()),
|
|
14
|
+
prove: true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const { response } = await grpcPool.getClient().getAddressesInfos(getAddressInfoRequest);
|
|
19
|
+
const { version } = response;
|
|
20
|
+
if (version.oneofKind !== 'v0') {
|
|
21
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
22
|
+
}
|
|
23
|
+
const { v0 } = version;
|
|
24
|
+
if (v0.result.oneofKind !== 'proof') {
|
|
25
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
|
|
26
|
+
}
|
|
27
|
+
const { result: { proof }, metadata } = v0;
|
|
28
|
+
if (metadata == null) {
|
|
29
|
+
throw new Error('Metadata not found');
|
|
30
|
+
}
|
|
31
|
+
const { rootHash, infos } = verifyPlatformAddressesInfos(proof.grovedbProof, platformAddressesWASM, true, LATEST_PLATFORM_VERSION);
|
|
32
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
33
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
34
|
+
if (!verify) {
|
|
35
|
+
throw new Error('Failed to verify query');
|
|
36
|
+
}
|
|
37
|
+
return infos
|
|
38
|
+
.map(info => ({
|
|
39
|
+
address: info.address,
|
|
40
|
+
nonce: info.nonce ?? 0,
|
|
41
|
+
balance: BigInt(info.balance ?? 0)
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
+
import { PlatformAddressLike } from 'pshenmic-dpp';
|
|
3
|
+
import { PlatformAddressInfo } from '../../types.js';
|
|
4
|
+
export declare class PlatformAddressesController {
|
|
5
|
+
/** @ignore **/
|
|
6
|
+
grpcPool: GRPCConnectionPool;
|
|
7
|
+
constructor(grpcPool: GRPCConnectionPool);
|
|
8
|
+
/**
|
|
9
|
+
* Makes a query for platform address info, returns an object with address, balance and nonce
|
|
10
|
+
*
|
|
11
|
+
* @param address {PlatformAddressLike}
|
|
12
|
+
* @return {Promise<PlatformAddressInfo>}
|
|
13
|
+
*/
|
|
14
|
+
getAddressInfo(address: PlatformAddressLike): Promise<PlatformAddressInfo>;
|
|
15
|
+
/**
|
|
16
|
+
* Makes a query for platform addresses infos, returns array with an object with address, balance and nonce
|
|
17
|
+
*
|
|
18
|
+
* @param addresses {PlatformAddressLike[]}
|
|
19
|
+
* @return {Promise<PlatformAddressInfo[]>}
|
|
20
|
+
*/
|
|
21
|
+
getAddressesInfos(addresses: PlatformAddressLike[]): Promise<PlatformAddressInfo[]>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getAddressInfo } from './getAddressInfo.js';
|
|
2
|
+
import { getAddressesInfos } from './getAddressesInfos.js';
|
|
3
|
+
export class PlatformAddressesController {
|
|
4
|
+
/** @ignore **/
|
|
5
|
+
grpcPool;
|
|
6
|
+
constructor(grpcPool) {
|
|
7
|
+
this.grpcPool = grpcPool;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Makes a query for platform address info, returns an object with address, balance and nonce
|
|
11
|
+
*
|
|
12
|
+
* @param address {PlatformAddressLike}
|
|
13
|
+
* @return {Promise<PlatformAddressInfo>}
|
|
14
|
+
*/
|
|
15
|
+
async getAddressInfo(address) {
|
|
16
|
+
return await getAddressInfo(this.grpcPool, address);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Makes a query for platform addresses infos, returns array with an object with address, balance and nonce
|
|
20
|
+
*
|
|
21
|
+
* @param addresses {PlatformAddressLike[]}
|
|
22
|
+
* @return {Promise<PlatformAddressInfo[]>}
|
|
23
|
+
*/
|
|
24
|
+
async getAddressesInfos(addresses) {
|
|
25
|
+
return await getAddressesInfos(this.grpcPool, addresses);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -11,9 +11,8 @@ export default async function broadcast(grpcPool, stateTransition) {
|
|
|
11
11
|
await grpcPool.getClient().broadcastStateTransition(broadcastStateTransitionRequest);
|
|
12
12
|
}
|
|
13
13
|
catch (err) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
throw new Error(deserializeConsensusError(errorBin));
|
|
14
|
+
if (err.meta?.['dash-serialized-consensus-error-bin']?.length !== 0) {
|
|
15
|
+
throw new Error(deserializeConsensusError(err.meta['dash-serialized-consensus-error-bin']));
|
|
17
16
|
}
|
|
18
17
|
else {
|
|
19
18
|
throw err;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchTransitionWASM,
|
|
1
|
+
import { BatchTransitionWASM, MasternodeVoteTransitionWASM, verifyStateTransitionResult } from 'pshenmic-dpp';
|
|
2
2
|
import hexToBytes from '../utils/hexToBytes.js';
|
|
3
3
|
import { WaitForStateTransitionResultRequest } from '../../proto/generated/platform.js';
|
|
4
4
|
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
@@ -45,7 +45,13 @@ export default async function waitForStateTransitionResult(grpcPool, stateTransi
|
|
|
45
45
|
const dataContract = await getDataContractByIdentifier(grpcPool, masternodeVote.vote.votePoll.contractId);
|
|
46
46
|
knownContracts.push(dataContract);
|
|
47
47
|
}
|
|
48
|
-
const
|
|
48
|
+
const blockInfo = {
|
|
49
|
+
timeMs: BigInt(timeMs),
|
|
50
|
+
height: BigInt(height),
|
|
51
|
+
coreHeight: coreChainLockedHeight,
|
|
52
|
+
epoch
|
|
53
|
+
};
|
|
54
|
+
const { rootHash, result } = verifyStateTransitionResult(proof.grovedbProof, stateTransition, blockInfo, knownContracts, LATEST_PLATFORM_VERSION);
|
|
49
55
|
if (result == null) {
|
|
50
56
|
throw new Error('State transition result was null');
|
|
51
57
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
import { IdentifierLike } from '
|
|
3
|
-
import { IdentifierWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { IdentifierLike, IdentifierWASM } from 'pshenmic-dpp';
|
|
4
3
|
export interface IdentitiesTokenBalances {
|
|
5
4
|
identityId: IdentifierWASM;
|
|
6
|
-
balance?:
|
|
5
|
+
balance?: bigint | undefined;
|
|
7
6
|
}
|
|
8
7
|
export default function getIdentitiesTokenBalances(grpcPool: GRPCConnectionPool, identifiers: IdentifierLike[], tokenIdentifier: IdentifierLike): Promise<IdentitiesTokenBalances[]>;
|
|
@@ -37,8 +37,8 @@ export default async function getIdentitiesTokenBalances(grpcPool, identifiers,
|
|
|
37
37
|
throw new Error('Failed to verify query');
|
|
38
38
|
}
|
|
39
39
|
return balances
|
|
40
|
-
.map((
|
|
41
|
-
identityId: new IdentifierWASM(
|
|
42
|
-
balance
|
|
40
|
+
.map(({ id, balance }) => ({
|
|
41
|
+
identityId: new IdentifierWASM(id),
|
|
42
|
+
balance
|
|
43
43
|
}));
|
|
44
44
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
import { IdentifierLike } from '
|
|
3
|
-
import { IdentifierWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { IdentifierLike, IdentifierWASM } from 'pshenmic-dpp';
|
|
4
3
|
export interface IdentityTokenBalances {
|
|
5
4
|
tokenId: IdentifierWASM;
|
|
6
|
-
balance?:
|
|
5
|
+
balance?: bigint | undefined;
|
|
7
6
|
}
|
|
8
7
|
export default function getIdentityTokensBalances(grpcPool: GRPCConnectionPool, identifier: IdentifierLike, tokenIdentifiers: IdentifierLike[]): Promise<IdentityTokenBalances[]>;
|
|
@@ -37,8 +37,8 @@ export default async function getIdentityTokensBalances(grpcPool, identifier, to
|
|
|
37
37
|
throw new Error('Failed to verify query');
|
|
38
38
|
}
|
|
39
39
|
return balances
|
|
40
|
-
.map((
|
|
41
|
-
tokenId: new IdentifierWASM(
|
|
42
|
-
balance
|
|
40
|
+
.map(({ id, balance }) => ({
|
|
41
|
+
tokenId: new IdentifierWASM(id),
|
|
42
|
+
balance
|
|
43
43
|
}));
|
|
44
44
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
import { IdentifierLike } from '
|
|
3
|
-
import { IdentifierWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { IdentifierLike, IdentifierWASM } from 'pshenmic-dpp';
|
|
4
3
|
export interface TokenContractInfo {
|
|
5
4
|
dataContractId: IdentifierWASM;
|
|
6
5
|
tokenContractPosition: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
import {
|
|
2
|
+
import { TokenDirectPurchasePrices } from '../../types.js';
|
|
3
|
+
import { IdentifierLike } from 'pshenmic-dpp';
|
|
3
4
|
export default function getTokenDirectPurchasePrices(grpcPool: GRPCConnectionPool, tokenIdentifiers: IdentifierLike[]): Promise<TokenDirectPurchasePrices[]>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
-
import {
|
|
2
|
+
import { TokenTotalSupply } from '../../types.js';
|
|
3
|
+
import { IdentifierLike } from 'pshenmic-dpp';
|
|
3
4
|
export default function getTokenTotalSupply(grpcPool: GRPCConnectionPool, tokenIdentifier: IdentifierLike): Promise<TokenTotalSupply>;
|