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/identities/index.js
CHANGED
|
@@ -1,59 +1,22 @@
|
|
|
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.IdentitiesController = void 0;
|
|
40
|
-
var getIdentityContractNonce_1 = require("./getIdentityContractNonce");
|
|
41
|
-
var getIdentityPublicKeys_1 = require("./getIdentityPublicKeys");
|
|
42
|
-
var getIdentityNonce_1 = require("./getIdentityNonce");
|
|
43
|
-
var getIdentityBalance_1 = require("./getIdentityBalance");
|
|
44
|
-
var getIdentityByPublicKeyHash_1 = require("./getIdentityByPublicKeyHash");
|
|
45
|
-
var getIdentityByIdentifier_1 = require("./getIdentityByIdentifier");
|
|
46
|
-
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
47
|
-
var createStateTransition_1 = require("./createStateTransition");
|
|
48
|
-
var getIdentityByNonUniquePublicKeyHash_1 = require("./getIdentityByNonUniquePublicKeyHash");
|
|
49
|
-
var hexToBytes_1 = require("../utils/hexToBytes");
|
|
1
|
+
import getIdentityContractNonce from './getIdentityContractNonce';
|
|
2
|
+
import getIdentityPublicKeys from './getIdentityPublicKeys';
|
|
3
|
+
import getIdentityNonce from './getIdentityNonce';
|
|
4
|
+
import getIdentityBalance from './getIdentityBalance';
|
|
5
|
+
import getIdentityByPublicKeyHash from './getIdentityByPublicKeyHash';
|
|
6
|
+
import getIdentityByIdentifier from './getIdentityByIdentifier';
|
|
7
|
+
import { AssetLockProofWASM, ContractBoundsWASM, IdentifierWASM, IdentityPublicKeyInCreationWASM, OutPointWASM } from 'pshenmic-dpp';
|
|
8
|
+
import createStateTransition from './createStateTransition';
|
|
9
|
+
import getIdentityByNonUniquePublicKeyHash from './getIdentityByNonUniquePublicKeyHash';
|
|
10
|
+
import hexToBytes from '../utils/hexToBytes';
|
|
50
11
|
/**
|
|
51
12
|
* Collection of methods to query identities and its related data
|
|
52
13
|
*
|
|
53
14
|
* @hideconstructor
|
|
54
15
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
16
|
+
export class IdentitiesController {
|
|
17
|
+
/** @ignore */
|
|
18
|
+
grpcPool;
|
|
19
|
+
constructor(grpcPool) {
|
|
57
20
|
this.grpcPool = grpcPool;
|
|
58
21
|
}
|
|
59
22
|
/**
|
|
@@ -63,16 +26,9 @@ var IdentitiesController = /** @class */ (function () {
|
|
|
63
26
|
*
|
|
64
27
|
* @return {Promise<bigint>}
|
|
65
28
|
*/
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
switch (_a.label) {
|
|
70
|
-
case 0: return [4 /*yield*/, (0, getIdentityBalance_1.default)(this.grpcPool, identifier)];
|
|
71
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
};
|
|
29
|
+
async getIdentityBalance(identifier) {
|
|
30
|
+
return await getIdentityBalance(this.grpcPool, identifier);
|
|
31
|
+
}
|
|
76
32
|
/**
|
|
77
33
|
* Retrieves an Identity from the network by give public key hash
|
|
78
34
|
*
|
|
@@ -80,20 +36,12 @@ var IdentitiesController = /** @class */ (function () {
|
|
|
80
36
|
*
|
|
81
37
|
* @return {Promise<IdentityWASM>}
|
|
82
38
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
throw new Error('Public key hash should equal 40');
|
|
90
|
-
}
|
|
91
|
-
return [4 /*yield*/, (0, getIdentityByPublicKeyHash_1.default)(this.grpcPool, hex)];
|
|
92
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
};
|
|
39
|
+
async getIdentityByPublicKeyHash(hex) {
|
|
40
|
+
if (hex.length !== 40) {
|
|
41
|
+
throw new Error('Public key hash should equal 40');
|
|
42
|
+
}
|
|
43
|
+
return await getIdentityByPublicKeyHash(this.grpcPool, hex);
|
|
44
|
+
}
|
|
97
45
|
/**
|
|
98
46
|
* Retrieves an Identity from the network by non-unique public key hash (like Voter Identity, SHA160)
|
|
99
47
|
*
|
|
@@ -101,50 +49,28 @@ var IdentitiesController = /** @class */ (function () {
|
|
|
101
49
|
*
|
|
102
50
|
* @return {Promise<IdentityWASM>}
|
|
103
51
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
throw new Error('Public key hash should equal 40');
|
|
111
|
-
}
|
|
112
|
-
return [4 /*yield*/, (0, getIdentityByNonUniquePublicKeyHash_1.default)(this.grpcPool, hex)];
|
|
113
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
};
|
|
52
|
+
async getIdentityByNonUniquePublicKeyHash(hex) {
|
|
53
|
+
if (hex.length !== 40) {
|
|
54
|
+
throw new Error('Public key hash should equal 40');
|
|
55
|
+
}
|
|
56
|
+
return await getIdentityByNonUniquePublicKeyHash(this.grpcPool, hex);
|
|
57
|
+
}
|
|
118
58
|
/**
|
|
119
59
|
* Retrieves Identity by identifier from the network
|
|
120
60
|
* @param identifier {IdentifierLike} identifier
|
|
121
61
|
*
|
|
122
62
|
* @return {Promise<IdentityWASM>}
|
|
123
63
|
*/
|
|
124
|
-
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
switch (_a.label) {
|
|
128
|
-
case 0: return [4 /*yield*/, (0, getIdentityByIdentifier_1.default)(this.grpcPool, identifier)];
|
|
129
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
};
|
|
64
|
+
async getIdentityByIdentifier(identifier) {
|
|
65
|
+
return await getIdentityByIdentifier(this.grpcPool, identifier);
|
|
66
|
+
}
|
|
134
67
|
/**
|
|
135
68
|
* Get Identity Nonce (usually used by Identity transitions)
|
|
136
69
|
* @param identifier
|
|
137
70
|
*/
|
|
138
|
-
|
|
139
|
-
return
|
|
140
|
-
|
|
141
|
-
switch (_a.label) {
|
|
142
|
-
case 0: return [4 /*yield*/, (0, getIdentityNonce_1.default)(this.grpcPool, identifier)];
|
|
143
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
};
|
|
71
|
+
async getIdentityNonce(identifier) {
|
|
72
|
+
return await getIdentityNonce(this.grpcPool, identifier);
|
|
73
|
+
}
|
|
148
74
|
/**
|
|
149
75
|
* Get Identity Contract Nonce (usually used by Document transitions)
|
|
150
76
|
* @param identifier
|
|
@@ -152,32 +78,18 @@ var IdentitiesController = /** @class */ (function () {
|
|
|
152
78
|
*
|
|
153
79
|
* @return {Promise<bigint>}
|
|
154
80
|
*/
|
|
155
|
-
|
|
156
|
-
return
|
|
157
|
-
|
|
158
|
-
switch (_a.label) {
|
|
159
|
-
case 0: return [4 /*yield*/, (0, getIdentityContractNonce_1.default)(this.grpcPool, identifier, dataContract)];
|
|
160
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
};
|
|
81
|
+
async getIdentityContractNonce(identifier, dataContract) {
|
|
82
|
+
return await getIdentityContractNonce(this.grpcPool, identifier, dataContract);
|
|
83
|
+
}
|
|
165
84
|
/**
|
|
166
85
|
* Retrieve given Identity's public keys
|
|
167
86
|
* @param identifier
|
|
168
87
|
*
|
|
169
88
|
* @return {Promise<IdentityPublicKeyWASM[]>}
|
|
170
89
|
*/
|
|
171
|
-
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
switch (_a.label) {
|
|
175
|
-
case 0: return [4 /*yield*/, (0, getIdentityPublicKeys_1.default)(this.grpcPool, identifier)];
|
|
176
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
};
|
|
90
|
+
async getIdentityPublicKeys(identifier) {
|
|
91
|
+
return await getIdentityPublicKeys(this.grpcPool, identifier);
|
|
92
|
+
}
|
|
181
93
|
/**
|
|
182
94
|
* Helper function for creating {StateTransitionWASM} for Identity transitions
|
|
183
95
|
*
|
|
@@ -188,50 +100,42 @@ var IdentitiesController = /** @class */ (function () {
|
|
|
188
100
|
* @param type {string} type of transition, must be a one of ('create' | 'update' | 'topUp')
|
|
189
101
|
* @param params {IdentityTransitionParams} params
|
|
190
102
|
*/
|
|
191
|
-
|
|
103
|
+
createStateTransition(type, params) {
|
|
192
104
|
if (params.identityId != null) {
|
|
193
|
-
params.identityId = new
|
|
105
|
+
params.identityId = new IdentifierWASM(params.identityId);
|
|
194
106
|
}
|
|
195
107
|
if (params.disablePublicKeyIds == null) {
|
|
196
108
|
params.disablePublicKeyIds = [];
|
|
197
109
|
}
|
|
198
110
|
if (params.assetLockProof != null) {
|
|
199
|
-
|
|
200
|
-
if (
|
|
201
|
-
|
|
111
|
+
const { type } = params.assetLockProof;
|
|
112
|
+
if (type === 'chainLock') {
|
|
113
|
+
const { txid, outputIndex, coreChainLockedHeight } = params.assetLockProof;
|
|
202
114
|
// @ts-expect-error
|
|
203
|
-
params.assetLockProof =
|
|
115
|
+
params.assetLockProof = AssetLockProofWASM.createChainAssetLockProof(coreChainLockedHeight, new OutPointWASM(txid, outputIndex));
|
|
204
116
|
}
|
|
205
|
-
else if (
|
|
206
|
-
|
|
117
|
+
else if (type === 'instantLock') {
|
|
118
|
+
const { transaction, outputIndex, instantLock } = params.assetLockProof;
|
|
207
119
|
// @ts-expect-error
|
|
208
|
-
params.assetLockProof =
|
|
120
|
+
params.assetLockProof = AssetLockProofWASM.createInstantAssetLockProof(hexToBytes(instantLock), hexToBytes(transaction), outputIndex);
|
|
209
121
|
}
|
|
210
|
-
else if (
|
|
122
|
+
else if (type == null) {
|
|
211
123
|
throw new Error('Missing Asset Lock type in the params');
|
|
212
124
|
}
|
|
213
125
|
else {
|
|
214
|
-
throw new Error(
|
|
126
|
+
throw new Error(`Unknown Asset Lock type: ${type}`);
|
|
215
127
|
}
|
|
216
128
|
}
|
|
217
129
|
if (params.addPublicKeys != null) {
|
|
218
130
|
// @ts-expect-error
|
|
219
131
|
params.addPublicKeys = params.addPublicKeys
|
|
220
|
-
.map(
|
|
221
|
-
var id = _a.id, purpose = _a.purpose, securityLevel = _a.securityLevel, keyType = _a.keyType, readOnly = _a.readOnly, data = _a.data, signature = _a.signature, contractBounds = _a.contractBounds;
|
|
222
|
-
return new pshenmic_dpp_1.IdentityPublicKeyInCreationWASM(id, purpose, securityLevel, keyType, readOnly, data, signature, (contractBounds != null) ? new pshenmic_dpp_1.ContractBoundsWASM(contractBounds.dataContractId, contractBounds.documentType) : undefined);
|
|
223
|
-
});
|
|
132
|
+
.map(({ id, purpose, securityLevel, keyType, readOnly, data, signature, contractBounds }) => new IdentityPublicKeyInCreationWASM(id, purpose, securityLevel, keyType, readOnly, data, signature, (contractBounds != null) ? new ContractBoundsWASM(contractBounds.dataContractId, contractBounds.documentType) : undefined));
|
|
224
133
|
}
|
|
225
134
|
if (params.publicKeys != null) {
|
|
226
135
|
// @ts-expect-error
|
|
227
136
|
params.publicKeys = params.publicKeys
|
|
228
|
-
.map(
|
|
229
|
-
var id = _a.id, purpose = _a.purpose, securityLevel = _a.securityLevel, keyType = _a.keyType, readOnly = _a.readOnly, data = _a.data, signature = _a.signature, contractBounds = _a.contractBounds;
|
|
230
|
-
return new pshenmic_dpp_1.IdentityPublicKeyInCreationWASM(id, purpose, securityLevel, keyType, readOnly, data, signature, (contractBounds != null) ? new pshenmic_dpp_1.ContractBoundsWASM(contractBounds.dataContractId, contractBounds.documentType) : undefined);
|
|
231
|
-
});
|
|
137
|
+
.map(({ id, purpose, securityLevel, keyType, readOnly, data, signature, contractBounds }) => new IdentityPublicKeyInCreationWASM(id, purpose, securityLevel, keyType, readOnly, data, signature, (contractBounds != null) ? new ContractBoundsWASM(contractBounds.dataContractId, contractBounds.documentType) : undefined));
|
|
232
138
|
}
|
|
233
|
-
return (
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
}());
|
|
237
|
-
exports.IdentitiesController = IdentitiesController;
|
|
139
|
+
return createStateTransition(type, params);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HDKey } from '
|
|
2
|
-
export default function deriveChild(
|
|
1
|
+
import { HDKey } from '@scure/bip32';
|
|
2
|
+
export default function deriveChild(hdKey: HDKey, index: number): HDKey;
|
|
@@ -1,50 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.default = deriveChild;
|
|
40
|
-
var DashHD = require("dashhd");
|
|
41
|
-
function deriveChild(parent, index, hardened) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
return __generator(this, function (_a) {
|
|
44
|
-
switch (_a.label) {
|
|
45
|
-
case 0: return [4 /*yield*/, DashHD.deriveChild(parent, index, hardened)];
|
|
46
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
1
|
+
export default function deriveChild(hdKey, index) {
|
|
2
|
+
return hdKey.deriveChild(index);
|
|
50
3
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HDKey } from '
|
|
2
|
-
export default function derivePath(
|
|
1
|
+
import { HDKey } from '@scure/bip32';
|
|
2
|
+
export default function derivePath(hdKey: HDKey, path: string): HDKey;
|
|
@@ -1,50 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.default = derivePath;
|
|
40
|
-
var DashHD = require("dashhd");
|
|
41
|
-
function derivePath(parent, path) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
return __generator(this, function (_a) {
|
|
44
|
-
switch (_a.label) {
|
|
45
|
-
case 0: return [4 /*yield*/, DashHD.derivePath(parent, path)];
|
|
46
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
1
|
+
export default function derivePath(hdKey, path) {
|
|
2
|
+
return hdKey.derive(path);
|
|
50
3
|
}
|
package/src/keyPair/index.d.ts
CHANGED
|
@@ -1,142 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { HDKey } from '@scure/bip32';
|
|
2
|
+
import { Network } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Collection of functions to work with private keys and seed phrases
|
|
5
5
|
*
|
|
6
6
|
* @hideconstructor
|
|
7
7
|
*/
|
|
8
8
|
export declare class KeyPairController {
|
|
9
|
-
/**
|
|
10
|
-
* Allows to derive child HD Key
|
|
11
|
-
*
|
|
12
|
-
* @param parent {HDKey} - The HDKey parent instance
|
|
13
|
-
* @param index {number} - Index of child
|
|
14
|
-
* @param hardened {boolean} - hardened or no
|
|
15
|
-
*
|
|
16
|
-
* @return {Promise<HDKey>} A promise that resolves child key
|
|
17
|
-
*/
|
|
18
|
-
deriveChild(parent: HDKey, index: number, hardened: boolean): Promise<HDKey>;
|
|
19
|
-
/**
|
|
20
|
-
* Allows to derive HD key by path
|
|
21
|
-
*
|
|
22
|
-
* @param parent {HDKey} - The HDKey parent instance
|
|
23
|
-
* @param path {string} - Path of children
|
|
24
|
-
*
|
|
25
|
-
* @return {Promise<HDKey>} A promise that resolves key by path
|
|
26
|
-
*/
|
|
27
|
-
derivePath(parent: HDKey, path: string): Promise<HDKey>;
|
|
28
|
-
/**
|
|
29
|
-
* Convert a HDKey to a public key
|
|
30
|
-
*
|
|
31
|
-
* @param hdKey {HDKey} - The HDKey to be converted into a public key
|
|
32
|
-
* @param opts {NetworkVersion=} - Network version
|
|
33
|
-
*
|
|
34
|
-
* @return {Promise<Uint8Array>} - converted public key
|
|
35
|
-
*/
|
|
36
|
-
keyToPublicKey(hdKey: HDKey, opts?: NetworkVersion): Promise<Uint8Array>;
|
|
37
|
-
/**
|
|
38
|
-
* Converts a HDKey to a wallet ID
|
|
39
|
-
*
|
|
40
|
-
* @param hdKey {HDKey} - The HDKey to be converted into a wallet id.
|
|
41
|
-
*
|
|
42
|
-
* @return {Promise<string>} Wallet id from used key
|
|
43
|
-
*/
|
|
44
|
-
keyToWalletId(hdKey: HDKey): Promise<string>;
|
|
45
|
-
/**
|
|
46
|
-
* Converts an HDKey instance to an extended private key (xprv)
|
|
47
|
-
*
|
|
48
|
-
* @param hdKey {HDKey} - The HDKey instance to convert
|
|
49
|
-
* @param opts {NetworkVersion=} - Optional, containing the version
|
|
50
|
-
*
|
|
51
|
-
* @returns {Promise<string>} A promise that resolves to the xPrivateKey string
|
|
52
|
-
*/
|
|
53
|
-
keyToXPrivateKey(hdKey: HDKey, opts?: NetworkVersion): Promise<string>;
|
|
54
|
-
/**
|
|
55
|
-
* Convert a HDKey to a xPublicKey
|
|
56
|
-
* @param hdKey {HDKey} - The HDKey instance to convert
|
|
57
|
-
* @param opts {NetworkVersion=} - Optional, containing the version
|
|
58
|
-
*
|
|
59
|
-
* @return {Promise<Uint8Array>}
|
|
60
|
-
*/
|
|
61
|
-
keyToXPublicKey(hdKey: HDKey, opts?: NetworkVersion): Promise<Uint8Array>;
|
|
62
|
-
/**
|
|
63
|
-
* Derives an Identity HDKey from a mnemonic phrase.
|
|
64
|
-
*
|
|
65
|
-
* @param mnemonic {string} - The BIP39 mnemonic phrase.
|
|
66
|
-
* @param identityIndex {number} - The identity index (default: 0).
|
|
67
|
-
* @param keyIndex {number} - The key index within the identity (default: 0).
|
|
68
|
-
* @param salt {string=} - Optional salt for seed derivation.
|
|
69
|
-
* @param verify {boolean=} - Whether to verify the mnemonic during derivation.
|
|
70
|
-
* @param opts {(HDFromSeedOptions & WalletToIdentityKeyOpts)=} - Additional options for HD seed derivation and wallet-to-identity conversion.
|
|
71
|
-
*
|
|
72
|
-
* @returns {Promise<HDKey>} A promise that resolves to the derived identity HDKey.
|
|
73
|
-
*/
|
|
74
|
-
mnemonicToIdentityKey(mnemonic: string, identityIndex?: number, keyIndex?: number, salt?: string, verify?: boolean, opts?: HDFromSeedOptions & WalletToIdentityKeyOpts): Promise<HDKey>;
|
|
75
9
|
/**
|
|
76
10
|
* Returns seed from mnemonic phrase
|
|
77
11
|
*
|
|
78
12
|
* @param mnemonic {string} - The BIP39 mnemonic phrase.
|
|
79
13
|
* @param salt {string=} - Optional salt for seed derivation.
|
|
80
|
-
* @param verify {boolean=} - Whether to verify the mnemonic during derivation.
|
|
81
14
|
*
|
|
82
|
-
* @return {
|
|
15
|
+
* @return {Uint8Array} Seed bytes
|
|
83
16
|
*/
|
|
84
|
-
mnemonicToSeed(mnemonic: string, salt?: string
|
|
17
|
+
mnemonicToSeed(mnemonic: string, salt?: string): Uint8Array;
|
|
85
18
|
/**
|
|
86
|
-
* Returns
|
|
19
|
+
* Returns seed from mnemonic phrase
|
|
87
20
|
*
|
|
88
|
-
* @param
|
|
89
|
-
* @param
|
|
90
|
-
* @param verify {boolean=} - Whether to verify the mnemonic during derivation.
|
|
91
|
-
* @param opts {HDFromSeedOptions=} - Optional derivation settings
|
|
21
|
+
* @param seed {Uint8Array}
|
|
22
|
+
* @param network {Network} network
|
|
92
23
|
*
|
|
93
|
-
* @return {
|
|
24
|
+
* @return {HDKey} HDKey
|
|
94
25
|
*/
|
|
95
|
-
|
|
26
|
+
seedToHdKey(seed: Uint8Array, network?: Network): HDKey;
|
|
96
27
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
28
|
+
* Allows to derive child HD Key
|
|
29
|
+
*
|
|
30
|
+
* @param hdKey {HDKey} - The HDKey parent instance
|
|
31
|
+
* @param index {number} - Index of child
|
|
32
|
+
*
|
|
33
|
+
* @return {Promise<HDKey>} A promise that resolves child key
|
|
34
|
+
*/
|
|
35
|
+
deriveChild(hdKey: HDKey, index: number): Promise<HDKey>;
|
|
105
36
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
37
|
+
* Allows to derive HD key by path
|
|
38
|
+
*
|
|
39
|
+
* @param hdKey {HDKey} - The HDKey parent instance
|
|
40
|
+
* @param path {string} - Path of children
|
|
41
|
+
*
|
|
42
|
+
* @return {Promise<HDKey>} A promise that resolves key by path
|
|
43
|
+
*/
|
|
44
|
+
derivePath(hdKey: HDKey, path: string): Promise<HDKey>;
|
|
114
45
|
/**
|
|
115
|
-
*
|
|
46
|
+
* Derives an {HDKey} child by identity index and key index from an {HDKey}
|
|
116
47
|
*
|
|
117
|
-
*
|
|
118
|
-
* @param opts {HDFromSeedOptions?} - Optional options with network version
|
|
48
|
+
* Usually used to get a identity private key from seed
|
|
119
49
|
*
|
|
120
|
-
* @
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
* Returns identity key from wallet
|
|
50
|
+
* @param hdKey {HDKey}
|
|
51
|
+
* @param identityIndex {number}
|
|
52
|
+
* @param keyIndex {number}
|
|
53
|
+
* @param network {Network}
|
|
125
54
|
*
|
|
126
|
-
* @
|
|
127
|
-
* @param identityIndex {number} - index of identity for wallet
|
|
128
|
-
* @param keyIndex {number} - index of key for identity
|
|
129
|
-
* @param opts {WalletToIdentityKeyOpts=} - optional options
|
|
130
|
-
*
|
|
131
|
-
* @return {Promise<HDKey>}
|
|
55
|
+
* @returns {HDKey}
|
|
132
56
|
*/
|
|
133
|
-
|
|
57
|
+
deriveIdentityPrivateKey(hdKey: HDKey, identityIndex: number, keyIndex: number, network: Network): HDKey;
|
|
134
58
|
/**
|
|
135
|
-
*
|
|
59
|
+
* Converts {PublicKey} to a Dash network address (P2PKH)
|
|
60
|
+
*
|
|
61
|
+
* @param publicKey {Uint8Array}
|
|
62
|
+
* @param network {Network}
|
|
136
63
|
*
|
|
137
|
-
* @
|
|
138
|
-
* @param opts {HDFromXKeyOptions=} - Optional options
|
|
139
|
-
* @return {Promise<HDXKey>}
|
|
64
|
+
* @returns {string}
|
|
140
65
|
*/
|
|
141
|
-
|
|
66
|
+
p2pkhAddress(publicKey: Uint8Array, network: Network): string;
|
|
142
67
|
}
|