dash-platform-sdk 1.3.0-dev.4 → 1.3.0-dev.6
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 +21 -2
- package/index.js +2 -5
- package/package.json +30 -31
- package/proto/generated/google/protobuf/wrappers.d.ts +260 -29
- package/proto/generated/google/protobuf/wrappers.js +562 -345
- package/proto/generated/platform.client.d.ts +251 -0
- package/proto/generated/platform.client.js +175 -0
- package/proto/generated/platform.d.ts +3682 -1939
- package/proto/generated/platform.js +8119 -18366
- package/src/DashPlatformSDK.d.ts +5 -4
- package/src/DashPlatformSDK.js +56 -46
- package/src/constants.js +7 -10
- package/src/contestedResources/createStateTransition.d.ts +1 -2
- package/src/contestedResources/createStateTransition.js +4 -7
- package/src/contestedResources/getContestedResourceVoteState.js +67 -118
- package/src/contestedResources/index.js +9 -55
- package/src/dataContracts/create.js +5 -8
- package/src/dataContracts/createStateTransition.js +10 -14
- package/src/dataContracts/getDataContractByIdentifier.js +40 -83
- package/src/dataContracts/index.js +17 -63
- package/src/documents/create.js +3 -6
- package/src/documents/createStateTransition.js +19 -31
- package/src/documents/index.js +25 -72
- package/src/documents/query.js +58 -90
- package/src/grpcConnectionPool.d.ts +30 -8
- package/src/grpcConnectionPool.js +63 -121
- package/src/identities/createStateTransition.js +14 -26
- package/src/identities/getIdentityBalance.js +37 -80
- package/src/identities/getIdentityByIdentifier.js +37 -80
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +41 -82
- package/src/identities/getIdentityByPublicKeyHash.js +37 -80
- package/src/identities/getIdentityContractNonce.js +40 -83
- package/src/identities/getIdentityNonce.js +38 -81
- package/src/identities/getIdentityPublicKeys.js +43 -81
- package/src/identities/index.js +57 -153
- package/src/keyPair/deriveChild.d.ts +2 -2
- package/src/keyPair/deriveChild.js +2 -49
- package/src/keyPair/derivePath.d.ts +2 -2
- package/src/keyPair/derivePath.js +2 -49
- package/src/keyPair/index.d.ts +39 -114
- package/src/keyPair/index.js +62 -296
- package/src/keyPair/mnemonicToSeed.d.ts +1 -1
- package/src/keyPair/mnemonicToSeed.js +3 -46
- package/src/names/index.js +43 -111
- package/src/names/registerName.js +60 -127
- package/src/names/searchByIdentity.d.ts +1 -1
- package/src/names/searchByIdentity.js +4 -50
- package/src/names/searchByName.js +15 -63
- package/src/names/testNameContested.js +1 -4
- package/src/names/validateName.js +3 -6
- package/src/node/epochs.js +43 -85
- package/src/node/index.d.ts +3 -3
- package/src/node/index.js +18 -77
- package/src/node/status.js +37 -81
- package/src/node/totalCredits.d.ts +2 -1
- package/src/node/totalCredits.js +32 -73
- package/src/signer/AbstractSigner.js +1 -2
- package/src/signer/setSigner.js +1 -4
- package/src/stateTransitions/broadcast.js +7 -57
- package/src/stateTransitions/index.js +13 -66
- package/src/stateTransitions/waitForStateTransitionResult.js +6 -58
- package/src/tokens/createStateTransition.js +23 -35
- package/src/tokens/getIdentitiesTokenBalances.js +40 -83
- package/src/tokens/getIdentityTokensBalances.js +40 -83
- package/src/tokens/getTokenContractInfo.js +40 -83
- package/src/tokens/getTokenDirectPurchasePrices.js +37 -80
- package/src/tokens/getTokenTotalSupply.js +38 -81
- package/src/tokens/index.js +39 -124
- package/src/types.d.ts +6 -12
- package/src/types.js +6 -16
- package/src/utils/base58ToBytes.js +3 -6
- package/src/utils/bytesToHex.js +2 -5
- package/src/utils/bytesToTypedArray.d.ts +1 -0
- package/src/utils/bytesToTypedArray.js +3 -0
- package/src/utils/calculateMsgHash.d.ts +1 -1
- package/src/utils/calculateMsgHash.js +10 -13
- package/src/utils/calculateSignHash.d.ts +1 -1
- package/src/utils/calculateSignHash.js +7 -10
- package/src/utils/calculateStateIdHash.d.ts +1 -1
- package/src/utils/calculateStateIdHash.js +8 -10
- package/src/utils/convertToHomographSafeChars.js +2 -5
- package/src/utils/createVoterIdentityId.d.ts +1 -1
- package/src/utils/createVoterIdentityId.js +12 -11
- package/src/utils/getEvonodeList.d.ts +2 -2
- package/src/utils/getEvonodeList.js +10 -61
- package/src/utils/getQuorumPublicKey.js +15 -66
- package/src/utils/getRandomArrayItem.js +1 -4
- package/src/utils/getRandomBytes.js +2 -5
- package/src/utils/hexToBytes.js +2 -6
- package/src/utils/index.js +21 -28
- package/src/utils/indexBytesToString.js +2 -5
- package/src/utils/sha256.d.ts +1 -1
- package/src/utils/sha256.js +10 -8
- package/src/utils/signHash.d.ts +1 -1
- package/src/utils/signHash.js +9 -12
- package/src/utils/signRequestId.d.ts +1 -1
- package/src/utils/signRequestId.js +9 -12
- package/src/utils/sleep.js +2 -50
- package/src/utils/stringToIndexValueBytes.js +4 -7
- package/src/utils/verifyTenderdashProof.d.ts +1 -1
- package/src/utils/verifyTenderdashProof.js +13 -17
- package/src/voting/createStateTransition.d.ts +1 -2
- package/src/voting/createStateTransition.js +4 -7
- package/src/voting/createVote.js +4 -7
- package/src/voting/index.d.ts +3 -4
- package/src/voting/index.js +19 -26
- package/test/unit/ContestedResources.spec.js +92 -177
- package/test/unit/DataContract.spec.js +44 -111
- package/test/unit/Document.spec.js +93 -183
- package/test/unit/Identity.spec.js +221 -346
- package/test/unit/KeyPair.spec.js +30 -145
- package/test/unit/Names.spec.js +27 -90
- package/test/unit/Node.spec.js +55 -126
- package/test/unit/SDK.spec.js +7 -9
- package/test/unit/Tokens.spec.js +111 -278
- package/bundle.min.js.LICENSE.txt +0 -1
- package/src/keyPair/keyToPublicKey.d.ts +0 -2
- package/src/keyPair/keyToPublicKey.js +0 -47
- package/src/keyPair/keyToWalletId.d.ts +0 -2
- package/src/keyPair/keyToWalletId.js +0 -50
- package/src/keyPair/keyToXPrivateKey.d.ts +0 -3
- package/src/keyPair/keyToXPrivateKey.js +0 -50
- package/src/keyPair/keyToXPublicKey.d.ts +0 -3
- package/src/keyPair/keyToXPublicKey.js +0 -50
- package/src/keyPair/mnemonicToIdentityKey.d.ts +0 -3
- package/src/keyPair/mnemonicToIdentityKey.js +0 -57
- package/src/keyPair/mnemonicToWallet.d.ts +0 -2
- package/src/keyPair/mnemonicToWallet.js +0 -55
- package/src/keyPair/privateKeyToWif.d.ts +0 -2
- package/src/keyPair/privateKeyToWif.js +0 -50
- package/src/keyPair/publicKeyToAddress.d.ts +0 -2
- package/src/keyPair/publicKeyToAddress.js +0 -50
- package/src/keyPair/seedToWallet.d.ts +0 -2
- package/src/keyPair/seedToWallet.js +0 -50
- package/src/keyPair/walletToIdentityKey.d.ts +0 -3
- package/src/keyPair/walletToIdentityKey.js +0 -56
- package/src/keyPair/xkeyToHDXKey.d.ts +0 -2
- package/src/keyPair/xkeyToHDXKey.js +0 -50
package/src/DashPlatformSDK.d.ts
CHANGED
|
@@ -11,12 +11,13 @@ import { ContestedResourcesController } from './contestedResources';
|
|
|
11
11
|
import { TokensController } from './tokens';
|
|
12
12
|
import { AbstractSigner } from './signer/AbstractSigner';
|
|
13
13
|
import { VotingController } from './voting';
|
|
14
|
+
import { Network } from './types';
|
|
14
15
|
export interface GRPCOptions {
|
|
15
16
|
poolLimit: 5;
|
|
16
17
|
dapiUrl?: string | string[];
|
|
17
18
|
}
|
|
18
19
|
export interface SDKOptions {
|
|
19
|
-
network:
|
|
20
|
+
network: Network;
|
|
20
21
|
grpc?: GRPCOptions;
|
|
21
22
|
/** @deprecated Use {GRPCOptions} instead, will be removed in next major version **/
|
|
22
23
|
dapiUrl?: string | string[];
|
|
@@ -26,7 +27,7 @@ export interface SDKOptions {
|
|
|
26
27
|
* Javascript SDK for that let you interact with a Dash Platform blockchain
|
|
27
28
|
*/
|
|
28
29
|
export declare class DashPlatformSDK {
|
|
29
|
-
network:
|
|
30
|
+
network: Network;
|
|
30
31
|
/** @ignore **/
|
|
31
32
|
grpcPool: GRPCConnectionPool;
|
|
32
33
|
/** @ignore **/
|
|
@@ -58,7 +59,7 @@ export declare class DashPlatformSDK {
|
|
|
58
59
|
* @param grpcPool
|
|
59
60
|
* @param network
|
|
60
61
|
*/
|
|
61
|
-
_initialize(grpcPool: GRPCConnectionPool, network:
|
|
62
|
+
_initialize(grpcPool: GRPCConnectionPool, network: Network): void;
|
|
62
63
|
setSigner(signer: AbstractSigner): void;
|
|
63
64
|
/**
|
|
64
65
|
* Get currently used network
|
|
@@ -71,5 +72,5 @@ export declare class DashPlatformSDK {
|
|
|
71
72
|
*
|
|
72
73
|
* @param network {string}
|
|
73
74
|
*/
|
|
74
|
-
setNetwork(network:
|
|
75
|
+
setNetwork(network: Network): void;
|
|
75
76
|
}
|
package/src/DashPlatformSDK.js
CHANGED
|
@@ -1,43 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var contestedResources_1 = require("./contestedResources");
|
|
14
|
-
var tokens_1 = require("./tokens");
|
|
15
|
-
var voting_1 = require("./voting");
|
|
1
|
+
import GRPCConnectionPool from './grpcConnectionPool';
|
|
2
|
+
import { IdentitiesController } from './identities';
|
|
3
|
+
import { StateTransitionsController } from './stateTransitions';
|
|
4
|
+
import { DocumentsController } from './documents';
|
|
5
|
+
import { UtilsController } from './utils';
|
|
6
|
+
import { KeyPairController } from './keyPair';
|
|
7
|
+
import { NodeController } from './node';
|
|
8
|
+
import { NamesController } from './names';
|
|
9
|
+
import { DataContractsController } from './dataContracts';
|
|
10
|
+
import { ContestedResourcesController } from './contestedResources';
|
|
11
|
+
import { TokensController } from './tokens';
|
|
12
|
+
import { VotingController } from './voting';
|
|
16
13
|
/**
|
|
17
14
|
* Javascript SDK for that let you interact with a Dash Platform blockchain
|
|
18
15
|
*/
|
|
19
|
-
|
|
16
|
+
export class DashPlatformSDK {
|
|
17
|
+
network;
|
|
18
|
+
/** @ignore **/
|
|
19
|
+
grpcPool;
|
|
20
|
+
/** @ignore **/
|
|
21
|
+
options;
|
|
22
|
+
contestedResources;
|
|
23
|
+
stateTransitions;
|
|
24
|
+
dataContracts;
|
|
25
|
+
identities;
|
|
26
|
+
documents;
|
|
27
|
+
keyPair;
|
|
28
|
+
voting;
|
|
29
|
+
tokens;
|
|
30
|
+
utils;
|
|
31
|
+
names;
|
|
32
|
+
signer;
|
|
33
|
+
node;
|
|
20
34
|
/**
|
|
21
35
|
* Constructs a new DashPlatformSDK instance, optionally pass options
|
|
22
36
|
* if you want to configure the SDK instance (network, dapiUrl, signer)
|
|
23
37
|
*
|
|
24
38
|
* @param options {SDKOptions=}
|
|
25
39
|
*/
|
|
26
|
-
|
|
27
|
-
var _a, _b;
|
|
40
|
+
constructor(options) {
|
|
28
41
|
if (options != null && (options.network == null || !['testnet', 'mainnet'].includes(options.network))) {
|
|
29
42
|
throw new Error('If options is passed, network must be set (either mainnet or testnet)');
|
|
30
43
|
}
|
|
31
|
-
this.network =
|
|
32
|
-
this.signer = options
|
|
44
|
+
this.network = options?.network ?? 'mainnet';
|
|
45
|
+
this.signer = options?.signer;
|
|
33
46
|
this.options = options;
|
|
34
|
-
this.utils = new
|
|
47
|
+
this.utils = new UtilsController();
|
|
35
48
|
// Compatibility
|
|
36
|
-
if (
|
|
49
|
+
if (options?.dapiUrl != null && ((options?.grpc) == null)) {
|
|
37
50
|
// @ts-expect-error
|
|
38
51
|
this.options.grpc = { dapiUrl: options.dapiUrl };
|
|
39
52
|
}
|
|
40
|
-
this.grpcPool = new
|
|
53
|
+
this.grpcPool = new GRPCConnectionPool(this.network, this.options?.grpc);
|
|
41
54
|
this._initialize(this.grpcPool, this.network);
|
|
42
55
|
}
|
|
43
56
|
/**
|
|
@@ -48,44 +61,41 @@ var DashPlatformSDK = /** @class */ (function () {
|
|
|
48
61
|
* @param grpcPool
|
|
49
62
|
* @param network
|
|
50
63
|
*/
|
|
51
|
-
|
|
64
|
+
_initialize(grpcPool, network) {
|
|
52
65
|
this.grpcPool = grpcPool;
|
|
53
|
-
this.stateTransitions = new
|
|
54
|
-
this.contestedResources = new
|
|
55
|
-
this.dataContracts = new
|
|
56
|
-
this.identities = new
|
|
57
|
-
this.documents = new
|
|
58
|
-
this.voting = new
|
|
59
|
-
this.node = new
|
|
60
|
-
this.tokens = new
|
|
61
|
-
this.names = new
|
|
62
|
-
this.keyPair = new
|
|
63
|
-
}
|
|
64
|
-
|
|
66
|
+
this.stateTransitions = new StateTransitionsController(grpcPool);
|
|
67
|
+
this.contestedResources = new ContestedResourcesController(grpcPool);
|
|
68
|
+
this.dataContracts = new DataContractsController(grpcPool);
|
|
69
|
+
this.identities = new IdentitiesController(grpcPool);
|
|
70
|
+
this.documents = new DocumentsController(grpcPool);
|
|
71
|
+
this.voting = new VotingController();
|
|
72
|
+
this.node = new NodeController(grpcPool, network);
|
|
73
|
+
this.tokens = new TokensController(grpcPool);
|
|
74
|
+
this.names = new NamesController(grpcPool);
|
|
75
|
+
this.keyPair = new KeyPairController();
|
|
76
|
+
}
|
|
77
|
+
setSigner(signer) {
|
|
65
78
|
this.signer = signer;
|
|
66
|
-
}
|
|
79
|
+
}
|
|
67
80
|
/**
|
|
68
81
|
* Get currently used network
|
|
69
82
|
*
|
|
70
83
|
* @return {string}
|
|
71
84
|
*/
|
|
72
|
-
|
|
85
|
+
getNetwork() {
|
|
73
86
|
return this.network;
|
|
74
|
-
}
|
|
87
|
+
}
|
|
75
88
|
/**
|
|
76
89
|
* Switches a network that SDK is currently connected to
|
|
77
90
|
*
|
|
78
91
|
* @param network {string}
|
|
79
92
|
*/
|
|
80
|
-
|
|
81
|
-
var _a;
|
|
93
|
+
setNetwork(network) {
|
|
82
94
|
if (network !== 'testnet' && network !== 'mainnet') {
|
|
83
95
|
throw new Error('Unknown network, should be mainnet or testnet');
|
|
84
96
|
}
|
|
85
97
|
this.network = network;
|
|
86
|
-
|
|
98
|
+
const grpcPool = new GRPCConnectionPool(this.network, this.options?.grpc);
|
|
87
99
|
this._initialize(grpcPool, this.network);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}());
|
|
91
|
-
exports.DashPlatformSDK = DashPlatformSDK;
|
|
100
|
+
}
|
|
101
|
+
}
|
package/src/constants.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DPNS_DATA_CONTRACT_BYTES = exports.DPNS_DATA_CONTRACT_ID = exports.GRPC_DEFAULT_POOL_LIMIT = exports.MAINNET_ACTIVATION_HEIGHT = exports.TESTNET_ACTIVATION_HEIGHT = exports.HALVING_INTERVAL = exports.DAPI_DEFAULT_LIMIT = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Default amount of documents to retrieve from DAPI
|
|
6
3
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
export const DAPI_DEFAULT_LIMIT = 100;
|
|
5
|
+
export const HALVING_INTERVAL = 210240;
|
|
6
|
+
export const TESTNET_ACTIVATION_HEIGHT = 1066900;
|
|
7
|
+
export const MAINNET_ACTIVATION_HEIGHT = 2128896;
|
|
8
|
+
export const GRPC_DEFAULT_POOL_LIMIT = 5;
|
|
9
|
+
export const DPNS_DATA_CONTRACT_ID = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
10
|
+
export const DPNS_DATA_CONTRACT_BYTES = 'AeZoxlmvZq7h5ywYbd57W34KHXEqCcQNVyH2Ir9TxTFVAAAAAAABAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIGZG9tYWluFgsSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESDHRyYW5zZmVyYWJsZQIBEgl0cmFkZU1vZGUCARIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQIWBBIEbmFtZRIScGFyZW50TmFtZUFuZExhYmVsEgpwcm9wZXJ0aWVzFQIWARIabm9ybWFsaXplZFBhcmVudERvbWFpbk5hbWUSA2FzYxYBEg9ub3JtYWxpemVkTGFi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EgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASCHBvc2l0aW9uAgASC2Rlc2NyaXB0aW9uEllEb3VibGUgc2hhLTI1NiBvZiB0aGUgY29uY2F0ZW5hdGlvbiBvZiBhIDMyIGJ5dGUgcmFuZG9tIHNhbHQgYW5kIGEgbm9ybWFsaXplZCBkb21haW4gbmFtZRIIcmVxdWlyZWQVARIQc2FsdGVkRG9tYWluSGFzaBIUYWRkaXRpb25hbFByb3BlcnRpZXMTABIIJGNvbW1lbnQSSlByZW9yZGVyIGRvY3VtZW50cyBhcmUgaW1tdXRhYmxlOiBtb2RpZmljYXRpb24gYW5kIGRlbGV0aW9uIGFyZSByZXN0cmljdGVkAAAAAAAAAAAAAA==';
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { StateTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { VoteWASM } from 'pshenmic-dpp/dist/wasm/pshenmic_dpp';
|
|
1
|
+
import { StateTransitionWASM, VoteWASM } from 'pshenmic-dpp';
|
|
3
2
|
export default function createStateTransition(voteWASM: VoteWASM, proTxHash: string, identityNonce: bigint): StateTransitionWASM;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function createStateTransition(voteWASM, proTxHash, identityNonce) {
|
|
6
|
-
var voterIdentity = pshenmic_dpp_1.IdentifierWASM.fromHex(proTxHash);
|
|
7
|
-
var masternodeVoteTransition = new pshenmic_dpp_1.MasternodeVoteTransitionWASM(proTxHash, voterIdentity, voteWASM, identityNonce);
|
|
1
|
+
import { IdentifierWASM, MasternodeVoteTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
+
export default function createStateTransition(voteWASM, proTxHash, identityNonce) {
|
|
3
|
+
const voterIdentity = IdentifierWASM.fromHex(proTxHash);
|
|
4
|
+
const masternodeVoteTransition = new MasternodeVoteTransitionWASM(proTxHash, voterIdentity, voteWASM, identityNonce);
|
|
8
5
|
return masternodeVoteTransition.toStateTransition();
|
|
9
6
|
}
|
|
@@ -1,123 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { GetContestedResourceVoteStateRequest } from '../../proto/generated/platform';
|
|
2
|
+
import { DocumentWASM, IdentifierWASM, PlatformVersionWASM, verifyVotePollVoteStateProof } from 'pshenmic-dpp';
|
|
3
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof';
|
|
4
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey';
|
|
5
|
+
import bytesToHex from '../utils/bytesToHex';
|
|
6
|
+
export default async function getContestedResourceVoteState(grpcPool, contract, documentTypeName, indexName, indexValues, resultType, allowIncludeLockedAndAbstainingVoteTally, startAtIdentifierInfo, count) {
|
|
7
|
+
if (startAtIdentifierInfo != null) {
|
|
8
|
+
startAtIdentifierInfo = {
|
|
9
|
+
startIdentifier: (new IdentifierWASM(startAtIdentifierInfo.startIdentifier)).bytes(),
|
|
10
|
+
startIdentifierIncluded: startAtIdentifierInfo.startIdentifierIncluded
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const getContestedResourceVoteStateRequest = GetContestedResourceVoteStateRequest.create({
|
|
14
|
+
version: {
|
|
15
|
+
oneofKind: 'v0',
|
|
16
|
+
v0: {
|
|
17
|
+
contractId: contract.id.bytes(),
|
|
18
|
+
documentTypeName,
|
|
19
|
+
indexName,
|
|
20
|
+
indexValues,
|
|
21
|
+
resultType: resultType,
|
|
22
|
+
allowIncludeLockedAndAbstainingVoteTally,
|
|
23
|
+
startAtIdentifierInfo,
|
|
24
|
+
count,
|
|
25
|
+
prove: true
|
|
26
|
+
}
|
|
8
27
|
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
28
|
});
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
29
|
+
const { response } = await grpcPool.getClient().getContestedResourceVoteState(getContestedResourceVoteStateRequest);
|
|
30
|
+
const { version } = response;
|
|
31
|
+
if (version.oneofKind !== 'v0') {
|
|
32
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
33
|
+
}
|
|
34
|
+
const { v0 } = version;
|
|
35
|
+
if (v0.result.oneofKind !== 'proof') {
|
|
36
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
|
|
47
37
|
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
prove: true
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
return [4 /*yield*/, grpcPool.getClient().getContestedResourceVoteState(getContestedResourceVoteStateRequest)];
|
|
83
|
-
case 1:
|
|
84
|
-
v0 = (_e.sent()).v0;
|
|
85
|
-
_a = v0, proof = _a.proof, metadata = _a.metadata;
|
|
86
|
-
if (proof == null) {
|
|
87
|
-
throw new Error('Proof not found');
|
|
88
|
-
}
|
|
89
|
-
if (metadata == null) {
|
|
90
|
-
throw new Error('Metadata not found');
|
|
91
|
-
}
|
|
92
|
-
_b = (0, pshenmic_dpp_1.verifyVotePollVoteStateProof)(proof.grovedbProof, contract, documentTypeName, indexName, indexValues, resultType, allowIncludeLockedAndAbstainingVoteTally, count, startAtIdentifierInfo, pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V9), rootHash = _b.rootHash, result = _b.result;
|
|
93
|
-
return [4 /*yield*/, (0, getQuorumPublicKey_1.getQuorumPublicKey)(grpcPool.network, proof.quorumType, (0, bytesToHex_1.default)(proof.quorumHash))];
|
|
94
|
-
case 2:
|
|
95
|
-
quorumPublicKey = _e.sent();
|
|
96
|
-
verify = (0, verifyTenderdashProof_1.default)(proof, metadata, rootHash, quorumPublicKey);
|
|
97
|
-
if (!verify) {
|
|
98
|
-
throw new Error('Failed to verify query');
|
|
99
|
-
}
|
|
100
|
-
contenders = (result !== null && result !== void 0 ? result : { contenders: [] }).contenders;
|
|
101
|
-
winner = (result !== null && result !== void 0 ? result : { winner: undefined }).winner;
|
|
102
|
-
if (contenders.length === 0) {
|
|
103
|
-
throw new Error('Vote state not found');
|
|
104
|
-
}
|
|
105
|
-
return [2 /*return*/, {
|
|
106
|
-
contenders: contenders.map(function (contender) { return (__assign(__assign({}, contender), { identifier: contender.identityId, document: contender.serializedDocument != null ? pshenmic_dpp_1.DocumentWASM.fromBytes(contender.serializedDocument, contract, documentTypeName, pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V9) : undefined })); }),
|
|
107
|
-
abstainVoteTally: (_c = result === null || result === void 0 ? void 0 : result.abstainingVoteTally) !== null && _c !== void 0 ? _c : 0,
|
|
108
|
-
lockVoteTally: (_d = result === null || result === void 0 ? void 0 : result.lockedVoteTally) !== null && _d !== void 0 ? _d : 0,
|
|
109
|
-
finishedVoteInfo: (winner != null)
|
|
110
|
-
? {
|
|
111
|
-
type: winner.type,
|
|
112
|
-
wonByIdentityId: winner.identityId != null ? new pshenmic_dpp_1.IdentifierWASM(winner.identityId) : undefined,
|
|
113
|
-
finishedAtBlockHeight: winner.blockInfo.height,
|
|
114
|
-
finishedAtCoreBlockHeight: winner.blockInfo.coreHeight,
|
|
115
|
-
finishedAtBlockTimeMs: winner.blockInfo.timeMs,
|
|
116
|
-
finishedAtEpoch: winner.blockInfo.epoch
|
|
117
|
-
}
|
|
118
|
-
: undefined
|
|
119
|
-
}];
|
|
38
|
+
const { result: { proof }, metadata } = v0;
|
|
39
|
+
if (metadata == null) {
|
|
40
|
+
throw new Error('Metadata not found');
|
|
41
|
+
}
|
|
42
|
+
const { rootHash, result } = verifyVotePollVoteStateProof(proof.grovedbProof, contract, documentTypeName, indexName, indexValues, resultType, allowIncludeLockedAndAbstainingVoteTally, count, startAtIdentifierInfo, PlatformVersionWASM.PLATFORM_V9);
|
|
43
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
44
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
45
|
+
if (!verify) {
|
|
46
|
+
throw new Error('Failed to verify query');
|
|
47
|
+
}
|
|
48
|
+
const { contenders } = result ?? { contenders: [] };
|
|
49
|
+
const { winner } = result ?? { winner: undefined };
|
|
50
|
+
if (contenders.length === 0) {
|
|
51
|
+
throw new Error('Vote state not found');
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
contenders: contenders.map(contender => ({
|
|
55
|
+
...contender,
|
|
56
|
+
identifier: contender.identityId,
|
|
57
|
+
document: contender.serializedDocument != null ? DocumentWASM.fromBytes(contender.serializedDocument, contract, documentTypeName, PlatformVersionWASM.PLATFORM_V9) : undefined
|
|
58
|
+
})),
|
|
59
|
+
abstainVoteTally: result?.abstainingVoteTally ?? 0,
|
|
60
|
+
lockVoteTally: result?.lockedVoteTally ?? 0,
|
|
61
|
+
finishedVoteInfo: (winner != null)
|
|
62
|
+
? {
|
|
63
|
+
type: winner.type,
|
|
64
|
+
wonByIdentityId: winner.identityId != null ? new IdentifierWASM(winner.identityId) : undefined,
|
|
65
|
+
finishedAtBlockHeight: winner.blockInfo.height,
|
|
66
|
+
finishedAtCoreBlockHeight: winner.blockInfo.coreHeight,
|
|
67
|
+
finishedAtBlockTimeMs: winner.blockInfo.timeMs,
|
|
68
|
+
finishedAtEpoch: winner.blockInfo.epoch
|
|
120
69
|
}
|
|
121
|
-
|
|
122
|
-
}
|
|
70
|
+
: undefined
|
|
71
|
+
};
|
|
123
72
|
}
|
|
@@ -1,50 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.ContestedResourcesController = void 0;
|
|
40
|
-
var getContestedResourceVoteState_1 = require("./getContestedResourceVoteState");
|
|
1
|
+
import getContestedResourceVoteState from './getContestedResourceVoteState';
|
|
41
2
|
/**
|
|
42
3
|
* Contested Resources controller for requesting information about contested resources
|
|
43
4
|
*
|
|
44
5
|
* @hideconstructor
|
|
45
6
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
7
|
+
export class ContestedResourcesController {
|
|
8
|
+
/** @ignore **/
|
|
9
|
+
grpcPool;
|
|
10
|
+
constructor(grpcPool) {
|
|
48
11
|
this.grpcPool = grpcPool;
|
|
49
12
|
}
|
|
50
13
|
/**
|
|
@@ -61,16 +24,7 @@ var ContestedResourcesController = /** @class */ (function () {
|
|
|
61
24
|
*
|
|
62
25
|
* @return {Promise<ContestedResourceVoteState>}
|
|
63
26
|
*/
|
|
64
|
-
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
case 0: return [4 /*yield*/, (0, getContestedResourceVoteState_1.default)(this.grpcPool, contract, documentTypeName, indexName, indexValuesBytes, resultType, allowIncludeLockedAndAbstainingVoteTally, startAtIdentifierInfo, count)];
|
|
69
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
return ContestedResourcesController;
|
|
75
|
-
}());
|
|
76
|
-
exports.ContestedResourcesController = ContestedResourcesController;
|
|
27
|
+
async getContestedResourceVoteState(contract, documentTypeName, indexName, indexValuesBytes, resultType, allowIncludeLockedAndAbstainingVoteTally, startAtIdentifierInfo, count) {
|
|
28
|
+
return await getContestedResourceVoteState(this.grpcPool, contract, documentTypeName, indexName, indexValuesBytes, resultType, allowIncludeLockedAndAbstainingVoteTally, startAtIdentifierInfo, count);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function createDataContract(ownerId, identityNonce, schema, tokenConfiguration, config, fullValidation, platformVersion) {
|
|
6
|
-
var id = new pshenmic_dpp_1.IdentifierWASM(ownerId);
|
|
7
|
-
var dataContract = new pshenmic_dpp_1.DataContractWASM(id, identityNonce, schema,
|
|
1
|
+
import { DataContractWASM, IdentifierWASM, PlatformVersionWASM } from 'pshenmic-dpp';
|
|
2
|
+
export default function createDataContract(ownerId, identityNonce, schema, tokenConfiguration, config, fullValidation, platformVersion) {
|
|
3
|
+
const id = new IdentifierWASM(ownerId);
|
|
4
|
+
const dataContract = new DataContractWASM(id, identityNonce, schema,
|
|
8
5
|
// we don't know what that param means yet
|
|
9
|
-
null, tokenConfiguration, fullValidation
|
|
6
|
+
null, tokenConfiguration, fullValidation ?? true, platformVersion ?? PlatformVersionWASM.PLATFORM_V9);
|
|
10
7
|
if (config != null) {
|
|
11
8
|
dataContract.setConfig(config, platformVersion);
|
|
12
9
|
}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.DataContractTransitionType = void 0;
|
|
4
|
-
exports.default = createStateTransition;
|
|
5
|
-
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
6
|
-
var DataContractTransitionType;
|
|
1
|
+
import { DataContractCreateTransitionWASM, DataContractUpdateTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
+
export var DataContractTransitionType;
|
|
7
3
|
(function (DataContractTransitionType) {
|
|
8
4
|
DataContractTransitionType[DataContractTransitionType["Create"] = 0] = "Create";
|
|
9
5
|
DataContractTransitionType[DataContractTransitionType["Update"] = 1] = "Update";
|
|
10
|
-
})(DataContractTransitionType || (
|
|
11
|
-
|
|
12
|
-
create:
|
|
13
|
-
update:
|
|
6
|
+
})(DataContractTransitionType || (DataContractTransitionType = {}));
|
|
7
|
+
const dataContractTransitionsMap = {
|
|
8
|
+
create: DataContractCreateTransitionWASM,
|
|
9
|
+
update: DataContractUpdateTransitionWASM
|
|
14
10
|
};
|
|
15
|
-
function createStateTransition(dataContract, type, identityNonce) {
|
|
16
|
-
|
|
11
|
+
export default function createStateTransition(dataContract, type, identityNonce) {
|
|
12
|
+
const TransitionClass = dataContractTransitionsMap[type];
|
|
17
13
|
if (TransitionClass == null) {
|
|
18
|
-
throw new Error(
|
|
14
|
+
throw new Error(`Unknown DataContract transition type: ${type}. Should be 'create' or 'update'.`);
|
|
19
15
|
}
|
|
20
16
|
// @ts-expect-error
|
|
21
|
-
|
|
17
|
+
const dataContractTransition = new TransitionClass(dataContract, identityNonce);
|
|
22
18
|
return dataContractTransition.toStateTransition();
|
|
23
19
|
}
|