dash-platform-sdk 1.3.0-dev.1 → 1.3.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 +21 -2
- package/index.d.ts +1 -1
- package/index.js +2 -5
- package/package.json +32 -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 +18 -19
- package/src/DashPlatformSDK.js +52 -45
- package/src/constants.d.ts +2 -0
- package/src/constants.js +7 -8
- package/src/contestedResources/createStateTransition.d.ts +2 -0
- package/src/contestedResources/createStateTransition.js +6 -0
- package/src/contestedResources/getContestedResourceVoteState.d.ts +3 -3
- package/src/contestedResources/getContestedResourceVoteState.js +67 -118
- package/src/contestedResources/index.d.ts +3 -3
- package/src/contestedResources/index.js +9 -55
- package/src/dataContracts/create.d.ts +1 -1
- package/src/dataContracts/create.js +5 -8
- package/src/dataContracts/createStateTransition.js +10 -14
- package/src/dataContracts/getDataContractByIdentifier.d.ts +2 -2
- package/src/dataContracts/getDataContractByIdentifier.js +40 -79
- package/src/dataContracts/index.d.ts +2 -2
- package/src/dataContracts/index.js +17 -63
- package/src/documents/create.d.ts +1 -1
- package/src/documents/create.js +3 -6
- package/src/documents/createStateTransition.d.ts +1 -1
- package/src/documents/createStateTransition.js +19 -31
- package/src/documents/index.d.ts +2 -2
- package/src/documents/index.js +25 -72
- package/src/documents/query.d.ts +2 -2
- package/src/documents/query.js +58 -90
- package/src/grpcConnectionPool.d.ts +30 -8
- package/src/grpcConnectionPool.js +63 -121
- package/src/identities/createStateTransition.d.ts +2 -2
- package/src/identities/createStateTransition.js +24 -26
- package/src/identities/getIdentityBalance.d.ts +2 -2
- package/src/identities/getIdentityBalance.js +37 -80
- package/src/identities/getIdentityByIdentifier.d.ts +2 -2
- package/src/identities/getIdentityByIdentifier.js +37 -80
- package/src/identities/getIdentityByNonUniquePublicKeyHash.d.ts +1 -1
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +41 -82
- package/src/identities/getIdentityByPublicKeyHash.d.ts +1 -1
- package/src/identities/getIdentityByPublicKeyHash.js +37 -80
- package/src/identities/getIdentityContractNonce.d.ts +2 -2
- package/src/identities/getIdentityContractNonce.js +40 -83
- package/src/identities/getIdentityNonce.d.ts +2 -2
- package/src/identities/getIdentityNonce.js +38 -81
- package/src/identities/getIdentityPublicKeys.d.ts +2 -2
- package/src/identities/getIdentityPublicKeys.js +43 -81
- package/src/identities/index.d.ts +6 -4
- package/src/identities/index.js +70 -154
- 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.d.ts +44 -3
- package/src/names/index.js +81 -69
- package/src/names/registerName.d.ts +3 -0
- package/src/names/registerName.js +64 -0
- package/src/names/searchByIdentity.d.ts +3 -0
- package/src/names/searchByIdentity.js +5 -0
- package/src/names/searchByName.d.ts +3 -0
- package/src/names/searchByName.js +16 -0
- package/src/names/testNameContested.d.ts +1 -0
- package/src/names/testNameContested.js +3 -0
- package/src/names/validateName.d.ts +1 -0
- package/src/names/validateName.js +11 -0
- package/src/node/epochs.d.ts +1 -1
- package/src/node/epochs.js +43 -85
- package/src/node/index.d.ts +5 -5
- package/src/node/index.js +18 -77
- package/src/node/status.d.ts +2 -2
- package/src/node/status.js +37 -81
- package/src/node/totalCredits.d.ts +3 -2
- package/src/node/totalCredits.js +32 -73
- package/src/stateTransitions/broadcast.d.ts +1 -1
- package/src/stateTransitions/broadcast.js +7 -57
- package/src/stateTransitions/index.d.ts +1 -1
- package/src/stateTransitions/index.js +13 -66
- package/src/stateTransitions/waitForStateTransitionResult.d.ts +1 -1
- package/src/stateTransitions/waitForStateTransitionResult.js +6 -62
- package/src/tokens/createStateTransition.d.ts +1 -1
- package/src/tokens/createStateTransition.js +23 -35
- package/src/tokens/getIdentitiesTokenBalances.d.ts +2 -2
- package/src/tokens/getIdentitiesTokenBalances.js +40 -83
- package/src/tokens/getIdentityTokensBalances.d.ts +2 -2
- package/src/tokens/getIdentityTokensBalances.js +40 -83
- package/src/tokens/getTokenContractInfo.d.ts +2 -2
- package/src/tokens/getTokenContractInfo.js +40 -83
- package/src/tokens/getTokenDirectPurchasePrices.d.ts +3 -0
- package/src/tokens/getTokenDirectPurchasePrices.js +40 -0
- package/src/tokens/getTokenTotalSupply.d.ts +2 -2
- package/src/tokens/getTokenTotalSupply.js +38 -81
- package/src/tokens/index.d.ts +13 -5
- package/src/tokens/index.js +46 -113
- package/src/types.d.ts +20 -16
- 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 +2 -2
- package/src/utils/calculateSignHash.js +7 -10
- package/src/utils/calculateStateIdHash.d.ts +2 -2
- package/src/utils/calculateStateIdHash.js +8 -10
- package/src/utils/convertToHomographSafeChars.d.ts +0 -4
- package/src/utils/convertToHomographSafeChars.js +2 -9
- package/src/utils/createMasternodeIdentityId.d.ts +2 -0
- package/src/utils/createMasternodeIdentityId.js +4 -0
- package/src/utils/createVoterIdentityId.d.ts +2 -0
- package/src/utils/createVoterIdentityId.js +13 -0
- 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.d.ts +1 -0
- package/src/utils/getRandomBytes.js +4 -0
- package/src/utils/hexToBytes.js +2 -6
- package/src/utils/index.d.ts +19 -3
- package/src/utils/index.js +45 -31
- 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.d.ts +1 -0
- package/src/utils/sleep.js +3 -0
- package/src/utils/stringToIndexValueBytes.js +4 -7
- package/src/utils/verifyTenderdashProof.d.ts +2 -2
- package/src/utils/verifyTenderdashProof.js +13 -17
- package/src/voting/createStateTransition.d.ts +2 -0
- package/src/voting/createStateTransition.js +6 -0
- package/src/voting/createVote.d.ts +2 -0
- package/src/voting/createVote.js +5 -0
- package/src/voting/index.d.ts +37 -0
- package/src/voting/index.js +55 -0
- package/test/unit/ContestedResources.spec.js +91 -90
- package/test/unit/DataContract.spec.js +44 -111
- package/test/unit/Document.spec.js +93 -183
- package/test/unit/Identity.spec.js +254 -357
- package/test/unit/KeyPair.spec.js +30 -145
- package/test/unit/Names.spec.d.ts +1 -0
- package/test/unit/Names.spec.js +33 -0
- package/test/unit/Node.spec.js +55 -126
- package/test/unit/SDK.spec.js +7 -9
- package/test/unit/Tokens.spec.js +112 -262
- 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/names/search.d.ts +0 -3
- package/src/names/search.js +0 -63
- package/src/signer/AbstractSigner.d.ts +0 -12
- package/src/signer/AbstractSigner.js +0 -2
- package/src/signer/PrivateKeySigner.d.ts +0 -0
- package/src/signer/PrivateKeySigner.js +0 -64
- package/src/signer/setSigner.d.ts +0 -2
- package/src/signer/setSigner.js +0 -8
package/src/tokens/index.js
CHANGED
|
@@ -1,56 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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.TokensController = void 0;
|
|
40
|
-
var getIdentitiesTokenBalances_1 = require("./getIdentitiesTokenBalances");
|
|
41
|
-
var getIdentityTokensBalances_1 = require("./getIdentityTokensBalances");
|
|
42
|
-
var getTokenContractInfo_1 = require("./getTokenContractInfo");
|
|
43
|
-
var getTokenTotalSupply_1 = require("./getTokenTotalSupply");
|
|
44
|
-
var createStateTransition_1 = require("./createStateTransition");
|
|
45
|
-
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
46
|
-
var getIdentityContractNonce_1 = require("../identities/getIdentityContractNonce");
|
|
1
|
+
import getIdentitiesTokenBalances from './getIdentitiesTokenBalances.js';
|
|
2
|
+
import getIdentityTokensBalances from './getIdentityTokensBalances.js';
|
|
3
|
+
import getTokenContractInfo from './getTokenContractInfo.js';
|
|
4
|
+
import getTokenTotalSupply from './getTokenTotalSupply.js';
|
|
5
|
+
import createStateTransition from './createStateTransition.js';
|
|
6
|
+
import { IdentifierWASM, TokenBaseTransitionWASM, TokenPricingScheduleWASM } from 'pshenmic-dpp';
|
|
7
|
+
import getIdentityContractNonce from '../identities/getIdentityContractNonce.js';
|
|
8
|
+
import getTokenDirectPurchasePrices from './getTokenDirectPurchasePrices.js';
|
|
47
9
|
/**
|
|
48
10
|
* Tokens controller for requesting information about tokens and tokens holders
|
|
49
11
|
*
|
|
50
12
|
* @hideconstructor
|
|
51
13
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
14
|
+
export class TokensController {
|
|
15
|
+
/** @ignore **/
|
|
16
|
+
grpcPool;
|
|
17
|
+
constructor(grpcPool) {
|
|
54
18
|
this.grpcPool = grpcPool;
|
|
55
19
|
}
|
|
56
20
|
/**
|
|
@@ -61,16 +25,9 @@ var TokensController = /** @class */ (function () {
|
|
|
61
25
|
*
|
|
62
26
|
* @return {Promise<IdentitiesTokenBalances>}
|
|
63
27
|
*/
|
|
64
|
-
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
switch (_a.label) {
|
|
68
|
-
case 0: return [4 /*yield*/, (0, getIdentitiesTokenBalances_1.default)(this.grpcPool, identifiers, tokenIdentifier)];
|
|
69
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
};
|
|
28
|
+
async getIdentitiesTokenBalances(identifiers, tokenIdentifier) {
|
|
29
|
+
return await getIdentitiesTokenBalances(this.grpcPool, identifiers, tokenIdentifier);
|
|
30
|
+
}
|
|
74
31
|
/**
|
|
75
32
|
* Retrieves a tokens balances for identity
|
|
76
33
|
*
|
|
@@ -79,16 +36,9 @@ var TokensController = /** @class */ (function () {
|
|
|
79
36
|
*
|
|
80
37
|
* @return {Promise<IdentityTokenBalances>}
|
|
81
38
|
*/
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
switch (_a.label) {
|
|
86
|
-
case 0: return [4 /*yield*/, (0, getIdentityTokensBalances_1.default)(this.grpcPool, identifier, tokenIdentifiers)];
|
|
87
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
39
|
+
async getIdentityTokensBalances(identifier, tokenIdentifiers) {
|
|
40
|
+
return await getIdentityTokensBalances(this.grpcPool, identifier, tokenIdentifiers);
|
|
41
|
+
}
|
|
92
42
|
/**
|
|
93
43
|
* Retrieves a tokens contract info by id
|
|
94
44
|
*
|
|
@@ -96,16 +46,9 @@ var TokensController = /** @class */ (function () {
|
|
|
96
46
|
*
|
|
97
47
|
* @return {Promise<TokenContractInfo>}
|
|
98
48
|
*/
|
|
99
|
-
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
switch (_a.label) {
|
|
103
|
-
case 0: return [4 /*yield*/, (0, getTokenContractInfo_1.default)(this.grpcPool, tokenIdentifier)];
|
|
104
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
49
|
+
async getTokenContractInfo(tokenIdentifier) {
|
|
50
|
+
return await getTokenContractInfo(this.grpcPool, tokenIdentifier);
|
|
51
|
+
}
|
|
109
52
|
/**
|
|
110
53
|
* Retrieves a token total supply
|
|
111
54
|
*
|
|
@@ -113,16 +56,19 @@ var TokensController = /** @class */ (function () {
|
|
|
113
56
|
*
|
|
114
57
|
* @return {Promise<TokenTotalSupply>}
|
|
115
58
|
*/
|
|
116
|
-
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
59
|
+
async getTokenTotalSupply(tokenIdentifier) {
|
|
60
|
+
return await getTokenTotalSupply(this.grpcPool, tokenIdentifier);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves a tokens prices
|
|
64
|
+
*
|
|
65
|
+
* @param tokenIdentifiers {IdentifierLike[]} - token ids which price we need
|
|
66
|
+
*
|
|
67
|
+
* @return {Promise<TokenDirectPurchasePrices[]>}
|
|
68
|
+
*/
|
|
69
|
+
async getTokensDirectPurchasePrice(tokenIdentifiers) {
|
|
70
|
+
return await getTokenDirectPurchasePrices(this.grpcPool, tokenIdentifiers);
|
|
71
|
+
}
|
|
126
72
|
/**
|
|
127
73
|
* Creates a Token Base Transition that contains base information about token transition
|
|
128
74
|
*
|
|
@@ -131,22 +77,11 @@ var TokensController = /** @class */ (function () {
|
|
|
131
77
|
*
|
|
132
78
|
* @return {TokenBaseTransitionWASM}
|
|
133
79
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
case 0: return [4 /*yield*/, (0, getTokenContractInfo_1.default)(this.grpcPool, tokenId)];
|
|
140
|
-
case 1:
|
|
141
|
-
_a = _b.sent(), dataContractId = _a.dataContractId, tokenContractPosition = _a.tokenContractPosition;
|
|
142
|
-
return [4 /*yield*/, (0, getIdentityContractNonce_1.default)(this.grpcPool, ownerId, dataContractId)];
|
|
143
|
-
case 2:
|
|
144
|
-
identityContractNonce = _b.sent();
|
|
145
|
-
return [2 /*return*/, new pshenmic_dpp_1.TokenBaseTransitionWASM(identityContractNonce + BigInt(1), tokenContractPosition, dataContractId, tokenId, undefined)];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
};
|
|
80
|
+
async createBaseTransition(tokenId, ownerId) {
|
|
81
|
+
const { dataContractId, tokenContractPosition } = await getTokenContractInfo(this.grpcPool, tokenId);
|
|
82
|
+
const identityContractNonce = await getIdentityContractNonce(this.grpcPool, ownerId, dataContractId);
|
|
83
|
+
return new TokenBaseTransitionWASM(identityContractNonce + BigInt(1), tokenContractPosition, dataContractId, tokenId, undefined);
|
|
84
|
+
}
|
|
150
85
|
/**
|
|
151
86
|
* Helper function for creation of a token state transition to be broadcasted in the network
|
|
152
87
|
*
|
|
@@ -160,16 +95,14 @@ var TokensController = /** @class */ (function () {
|
|
|
160
95
|
*
|
|
161
96
|
* @return {StateTransitionWASM}
|
|
162
97
|
*/
|
|
163
|
-
|
|
164
|
-
|
|
98
|
+
createStateTransition(base, ownerId, type, params) {
|
|
99
|
+
const owner = new IdentifierWASM(ownerId);
|
|
165
100
|
if (params.identityId != null) {
|
|
166
|
-
params.identityId = new
|
|
101
|
+
params.identityId = new IdentifierWASM(params.identityId);
|
|
167
102
|
}
|
|
168
103
|
if (params.price != null && typeof params.price === 'bigint') {
|
|
169
|
-
params.price =
|
|
104
|
+
params.price = TokenPricingScheduleWASM.SinglePrice(params.price);
|
|
170
105
|
}
|
|
171
|
-
return (
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
}());
|
|
175
|
-
exports.TokensController = TokensController;
|
|
106
|
+
return createStateTransition(base, owner, type, params);
|
|
107
|
+
}
|
|
108
|
+
}
|
package/src/types.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM } from 'pshenmic-dpp';
|
|
2
|
-
|
|
3
|
-
export { IdentifierWASM, IdentityWASM, DocumentWASM, DataContractWASM, StateTransitionWASM, IdentityPublicKeyWASM } from 'pshenmic-dpp';
|
|
1
|
+
import { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM } from 'pshenmic-dpp';
|
|
2
|
+
export { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM } from 'pshenmic-dpp';
|
|
4
3
|
export type IdentifierLike = IdentifierWASM | string | Uint8Array;
|
|
5
|
-
export
|
|
4
|
+
export type Network = 'mainnet' | 'testnet';
|
|
5
|
+
export { DashPlatformSDK } from './DashPlatformSDK.js';
|
|
6
6
|
export type MasternodeList = Record<string, MasternodeInfo>;
|
|
7
|
-
export { AbstractSigner } from './signer/AbstractSigner';
|
|
8
|
-
export interface WalletToIdentityKeyOpts {
|
|
9
|
-
network?: 'mainnet' | 'testnet';
|
|
10
|
-
}
|
|
11
|
-
export interface NetworkVersion {
|
|
12
|
-
version: Versions;
|
|
13
|
-
}
|
|
14
7
|
export interface DocumentTransitionParams {
|
|
15
8
|
identityContractNonce: bigint;
|
|
16
9
|
amount?: bigint;
|
|
@@ -48,17 +41,17 @@ export interface MasternodeInfo {
|
|
|
48
41
|
}
|
|
49
42
|
export interface NodeStatus {
|
|
50
43
|
version: {
|
|
51
|
-
software
|
|
44
|
+
software?: {
|
|
52
45
|
dapi: string;
|
|
53
46
|
drive?: string | undefined;
|
|
54
47
|
tenderdash?: string | undefined;
|
|
55
48
|
} | undefined;
|
|
56
|
-
protocol
|
|
57
|
-
tenderdash
|
|
58
|
-
|
|
49
|
+
protocol?: {
|
|
50
|
+
tenderdash?: {
|
|
51
|
+
p2P: number;
|
|
59
52
|
block: number;
|
|
60
53
|
} | undefined;
|
|
61
|
-
drive
|
|
54
|
+
drive?: {
|
|
62
55
|
latest: number;
|
|
63
56
|
current: number;
|
|
64
57
|
} | undefined;
|
|
@@ -192,7 +185,13 @@ export interface IdentityTransitionParams {
|
|
|
192
185
|
disablePublicKeyIds?: number[];
|
|
193
186
|
revision?: bigint;
|
|
194
187
|
identityNonce?: bigint;
|
|
188
|
+
amount?: bigint;
|
|
195
189
|
identityId?: IdentifierLike;
|
|
190
|
+
recipientId?: IdentifierLike;
|
|
191
|
+
withdrawalAddress?: string;
|
|
192
|
+
outputScript?: CoreScriptWASM;
|
|
193
|
+
pooling?: 'Standard' | 'Never' | 'IfAvailable';
|
|
194
|
+
coreFeePerByte?: number;
|
|
196
195
|
userFeeIncrease?: number;
|
|
197
196
|
}
|
|
198
197
|
export interface TokenTotalSupply {
|
|
@@ -200,3 +199,8 @@ export interface TokenTotalSupply {
|
|
|
200
199
|
totalSystemAmount: bigint;
|
|
201
200
|
totalAggregatedAmountInUserAccounts: bigint;
|
|
202
201
|
}
|
|
202
|
+
export interface TokenDirectPurchasePrices {
|
|
203
|
+
tokenId: IdentifierWASM;
|
|
204
|
+
price: TokenPricingScheduleWASM;
|
|
205
|
+
}
|
|
206
|
+
export type ResourceVoteChoice = IdentifierLike | 'lock' | 'abstain';
|
package/src/types.js
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
5
|
-
Object.defineProperty(exports, "IdentifierWASM", { enumerable: true, get: function () { return pshenmic_dpp_1.IdentifierWASM; } });
|
|
6
|
-
Object.defineProperty(exports, "IdentityWASM", { enumerable: true, get: function () { return pshenmic_dpp_1.IdentityWASM; } });
|
|
7
|
-
Object.defineProperty(exports, "DocumentWASM", { enumerable: true, get: function () { return pshenmic_dpp_1.DocumentWASM; } });
|
|
8
|
-
Object.defineProperty(exports, "DataContractWASM", { enumerable: true, get: function () { return pshenmic_dpp_1.DataContractWASM; } });
|
|
9
|
-
Object.defineProperty(exports, "StateTransitionWASM", { enumerable: true, get: function () { return pshenmic_dpp_1.StateTransitionWASM; } });
|
|
10
|
-
Object.defineProperty(exports, "IdentityPublicKeyWASM", { enumerable: true, get: function () { return pshenmic_dpp_1.IdentityPublicKeyWASM; } });
|
|
11
|
-
var DashPlatformSDK_1 = require("./DashPlatformSDK");
|
|
12
|
-
Object.defineProperty(exports, "DashPlatformSDK", { enumerable: true, get: function () { return DashPlatformSDK_1.DashPlatformSDK; } });
|
|
13
|
-
var ContestedStateResultType;
|
|
1
|
+
export { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM } from 'pshenmic-dpp';
|
|
2
|
+
export { DashPlatformSDK } from './DashPlatformSDK.js';
|
|
3
|
+
export var ContestedStateResultType;
|
|
14
4
|
(function (ContestedStateResultType) {
|
|
15
5
|
ContestedStateResultType[ContestedStateResultType["DOCUMENTS"] = 0] = "DOCUMENTS";
|
|
16
6
|
ContestedStateResultType[ContestedStateResultType["VOTE_TALLY"] = 1] = "VOTE_TALLY";
|
|
17
7
|
ContestedStateResultType[ContestedStateResultType["DOCUMENTS_AND_VOTE_TALLY"] = 2] = "DOCUMENTS_AND_VOTE_TALLY";
|
|
18
|
-
})(ContestedStateResultType || (
|
|
19
|
-
var FinishedVoteOutcome;
|
|
8
|
+
})(ContestedStateResultType || (ContestedStateResultType = {}));
|
|
9
|
+
export var FinishedVoteOutcome;
|
|
20
10
|
(function (FinishedVoteOutcome) {
|
|
21
11
|
FinishedVoteOutcome[FinishedVoteOutcome["TOWARDS_IDENTITY"] = 0] = "TOWARDS_IDENTITY";
|
|
22
12
|
FinishedVoteOutcome[FinishedVoteOutcome["LOCKED"] = 1] = "LOCKED";
|
|
23
13
|
FinishedVoteOutcome[FinishedVoteOutcome["NO_PREVIOUS_WINNER"] = 2] = "NO_PREVIOUS_WINNER";
|
|
24
14
|
FinishedVoteOutcome[FinishedVoteOutcome["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
25
|
-
})(FinishedVoteOutcome || (
|
|
15
|
+
})(FinishedVoteOutcome || (FinishedVoteOutcome = {}));
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var base_1 = require("@scure/base");
|
|
5
|
-
function base58ToBytes(str) {
|
|
6
|
-
return base_1.base58.decode(str);
|
|
1
|
+
import { base58 } from '@scure/base';
|
|
2
|
+
export default function base58ToBytes(str) {
|
|
3
|
+
return base58.decode(str);
|
|
7
4
|
}
|
package/src/utils/bytesToHex.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.default = bytesToHex;
|
|
4
|
-
function bytesToHex(bytes) {
|
|
5
|
-
return Array.prototype.map.call(bytes, function (x) { return ('00' + x.toString(16)).slice(-2); }).join('');
|
|
1
|
+
export default function bytesToHex(bytes) {
|
|
2
|
+
return Array.prototype.map.call(bytes, (x) => ('00' + x.toString(16)).slice(-2)).join('');
|
|
6
3
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function typedArrayToBuffer(bytes: Uint8Array): ArrayBuffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function calculateMsgHash(chainId: string, height: bigint, round: number, type: number, blockId: Uint8Array, stateId: Uint8Array): Uint8Array
|
|
1
|
+
export declare function calculateMsgHash(chainId: string, height: bigint, round: number, type: number, blockId: Uint8Array, stateId: Uint8Array): Promise<Uint8Array>;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var view = new DataView(buffer);
|
|
11
|
-
var uint8View = new Uint8Array(buffer);
|
|
12
|
-
var offset = 0;
|
|
1
|
+
import sha256 from './sha256.js';
|
|
2
|
+
export async function calculateMsgHash(chainId, height, round, type, blockId, stateId) {
|
|
3
|
+
const fixedSize = 4 + 8 + 8 + 32 + 32;
|
|
4
|
+
const chainIdBytes = new TextEncoder().encode(chainId);
|
|
5
|
+
const totalSize = fixedSize + chainIdBytes.length;
|
|
6
|
+
const buffer = new ArrayBuffer(totalSize);
|
|
7
|
+
const view = new DataView(buffer);
|
|
8
|
+
const uint8View = new Uint8Array(buffer);
|
|
9
|
+
let offset = 0;
|
|
13
10
|
// Write type as 32-bit little-endian integer
|
|
14
11
|
view.setInt32(offset, type, true);
|
|
15
12
|
offset += 4;
|
|
@@ -30,5 +27,5 @@ function calculateMsgHash(chainId, height, round, type, blockId, stateId) {
|
|
|
30
27
|
}
|
|
31
28
|
// Copy chainId bytes
|
|
32
29
|
uint8View.set(chainIdBytes, offset);
|
|
33
|
-
return
|
|
30
|
+
return await sha256(uint8View);
|
|
34
31
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CanonicalVote } from '../../proto/generated/platform';
|
|
2
|
-
export declare function calculateSignHash(commit: CanonicalVote, chainId: string, quorumType: number, quorumHash: Uint8Array, height: bigint, round: number): Uint8Array
|
|
1
|
+
import { CanonicalVote } from '../../proto/generated/platform.js';
|
|
2
|
+
export declare function calculateSignHash(commit: CanonicalVote, chainId: string, quorumType: number, quorumHash: Uint8Array, height: bigint, round: number): Promise<Uint8Array>;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var requestId = (0, signRequestId_1.default)('dpbvote', height, round);
|
|
9
|
-
var signBytesHash = (0, calculateMsgHash_1.calculateMsgHash)(chainId, height, round, commit.type, commit.blockId, commit.stateId);
|
|
10
|
-
return (0, signHash_1.default)(quorumType, quorumHash, requestId, signBytesHash);
|
|
1
|
+
import { calculateMsgHash } from './calculateMsgHash.js';
|
|
2
|
+
import signRequestId from './signRequestId.js';
|
|
3
|
+
import signHash from './signHash.js';
|
|
4
|
+
export async function calculateSignHash(commit, chainId, quorumType, quorumHash, height, round) {
|
|
5
|
+
const requestId = await signRequestId('dpbvote', height, round);
|
|
6
|
+
const signBytesHash = await calculateMsgHash(chainId, height, round, commit.type, commit.blockId, commit.stateId);
|
|
7
|
+
return await signHash(quorumType, quorumHash, requestId, signBytesHash);
|
|
11
8
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StateId } from '../../proto/generated/platform';
|
|
2
|
-
export declare function calculateStateIdHash(stateId: StateId): Uint8Array
|
|
1
|
+
import { StateId } from '../../proto/generated/platform.js';
|
|
2
|
+
export declare function calculateStateIdHash(stateId: StateId): Promise<Uint8Array>;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var encoded = platform_1.StateId.encode(stateId).finish();
|
|
9
|
-
var writer = new wire_1.BinaryWriter();
|
|
1
|
+
import { StateId } from '../../proto/generated/platform.js';
|
|
2
|
+
import sha256 from './sha256.js';
|
|
3
|
+
import { BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
4
|
+
export async function calculateStateIdHash(stateId) {
|
|
5
|
+
const writer = new BinaryWriter();
|
|
6
|
+
// @ts-expect-error
|
|
7
|
+
const encoded = StateId.internalBinaryWrite(stateId, writer, { writeUnknownFields: false }).finish();
|
|
10
8
|
writer.bytes(encoded);
|
|
11
|
-
return
|
|
9
|
+
return await sha256(writer.finish());
|
|
12
10
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.default = convertToHomographSafeChars;
|
|
4
|
-
/**
|
|
5
|
-
* @param {string} input
|
|
6
|
-
* @return {string}
|
|
7
|
-
*/
|
|
8
|
-
function convertToHomographSafeChars(input) {
|
|
9
|
-
return input.toLowerCase().replace(/[oli]/g, function (match) {
|
|
1
|
+
export default function convertToHomographSafeChars(input) {
|
|
2
|
+
return input.toLowerCase().replace(/[oli]/g, (match) => {
|
|
10
3
|
if (match === 'o') {
|
|
11
4
|
return '0';
|
|
12
5
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IdentifierWASM } from 'pshenmic-dpp';
|
|
2
|
+
import sha256 from './sha256.js';
|
|
3
|
+
import bytesToHex from './bytesToHex.js';
|
|
4
|
+
import hexToBytes from './hexToBytes.js';
|
|
5
|
+
export async function createVoterIdentityId(proTxHash, publicKeyHash) {
|
|
6
|
+
const proTxHashBytes = hexToBytes(proTxHash);
|
|
7
|
+
const publicKeyHashBytes = hexToBytes(publicKeyHash);
|
|
8
|
+
const mergedArray = new Uint8Array(proTxHashBytes.length + publicKeyHashBytes.length);
|
|
9
|
+
mergedArray.set(proTxHashBytes);
|
|
10
|
+
mergedArray.set(publicKeyHashBytes, proTxHashBytes.length);
|
|
11
|
+
const voterIdentifierBytes = await sha256(mergedArray);
|
|
12
|
+
return IdentifierWASM.fromHex(bytesToHex(voterIdentifierBytes));
|
|
13
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MasternodeList } from '../types';
|
|
2
|
-
export default function getDAPINodeList(network:
|
|
1
|
+
import { MasternodeList, Network } from '../types.js';
|
|
2
|
+
export default function getDAPINodeList(network: Network): Promise<MasternodeList>;
|
|
@@ -1,63 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 };
|
|
1
|
+
export default async function getDAPINodeList(network) {
|
|
2
|
+
const url = `https://${network === 'mainnet' ? '' : 'testnet.'}platform-explorer.pshenmic.dev/validators?isActive=true`;
|
|
3
|
+
const resp = await fetch(url);
|
|
4
|
+
if (resp.status !== 200) {
|
|
5
|
+
throw new Error('Failed to query Platform Explorer for active validators');
|
|
36
6
|
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var url, resp, resultSet;
|
|
43
|
-
return __generator(this, function (_a) {
|
|
44
|
-
switch (_a.label) {
|
|
45
|
-
case 0:
|
|
46
|
-
url = "https://".concat(network === 'mainnet' ? '' : 'testnet.', "platform-explorer.pshenmic.dev/validators?isActive=true");
|
|
47
|
-
return [4 /*yield*/, fetch(url)];
|
|
48
|
-
case 1:
|
|
49
|
-
resp = _a.sent();
|
|
50
|
-
if (resp.status !== 200) {
|
|
51
|
-
throw new Error('Failed to query Platform Explorer for active validators');
|
|
52
|
-
}
|
|
53
|
-
return [4 /*yield*/, resp.json()];
|
|
54
|
-
case 2:
|
|
55
|
-
resultSet = (_a.sent()).resultSet;
|
|
56
|
-
return [2 /*return*/, resultSet
|
|
57
|
-
// eslint-disable-next-line
|
|
58
|
-
.map(function (validator) { var _a, _b; return ((_b = (_a = validator === null || validator === void 0 ? void 0 : validator.proTxInfo) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.service) ? "https://".concat(validator.proTxInfo.state.service.split(':')[0]).concat(network === 'mainnet' ? '' : ':1443') : undefined; })
|
|
59
|
-
.filter(function (e) { return e != null; })];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
7
|
+
const { resultSet } = await resp.json();
|
|
8
|
+
return resultSet
|
|
9
|
+
// eslint-disable-next-line
|
|
10
|
+
.map((validator) => validator?.proTxInfo?.state?.service ? `https://${validator.proTxInfo.state.service.split(':')[0]}${network === 'mainnet' ? '' : ':1443'}` : undefined)
|
|
11
|
+
.filter(e => e != null);
|
|
63
12
|
}
|