dash-platform-sdk 1.3.0-dev.3 → 1.3.0-dev.5
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/package.json +30 -31
- package/proto/generated/google/protobuf/wrappers.d.ts +260 -29
- package/proto/generated/platform.client.d.ts +251 -0
- package/proto/generated/platform.d.ts +3682 -1939
- package/src/DashPlatformSDK.d.ts +5 -4
- package/src/contestedResources/createStateTransition.d.ts +1 -2
- package/src/grpcConnectionPool.d.ts +30 -8
- package/src/keyPair/deriveChild.d.ts +2 -2
- package/src/keyPair/derivePath.d.ts +2 -2
- package/src/keyPair/index.d.ts +39 -114
- package/src/keyPair/mnemonicToSeed.d.ts +1 -1
- package/src/names/searchByIdentity.d.ts +1 -1
- package/src/node/index.d.ts +3 -3
- package/src/node/totalCredits.d.ts +2 -1
- package/src/tokens/getTokenDirectPurchasePrices.d.ts +3 -0
- package/src/tokens/index.d.ts +9 -1
- package/src/types.d.ts +10 -12
- package/src/utils/bytesToTypedArray.d.ts +1 -0
- package/src/utils/calculateMsgHash.d.ts +1 -1
- package/src/utils/calculateSignHash.d.ts +1 -1
- package/src/utils/calculateStateIdHash.d.ts +1 -1
- package/src/utils/createVoterIdentityId.d.ts +1 -1
- package/src/utils/getEvonodeList.d.ts +2 -2
- package/src/utils/sha256.d.ts +1 -1
- package/src/utils/signHash.d.ts +1 -1
- package/src/utils/signRequestId.d.ts +1 -1
- package/src/utils/verifyTenderdashProof.d.ts +1 -1
- package/src/voting/createStateTransition.d.ts +1 -2
- package/src/voting/index.d.ts +3 -4
- package/bundle.min.js.LICENSE.txt +0 -1
- package/index.js +0 -5
- package/proto/generated/google/protobuf/wrappers.js +0 -398
- package/proto/generated/platform.js +0 -18524
- package/src/DashPlatformSDK.js +0 -91
- package/src/constants.js +0 -13
- package/src/contestedResources/createStateTransition.js +0 -9
- package/src/contestedResources/getContestedResourceVoteState.js +0 -123
- package/src/contestedResources/index.js +0 -76
- package/src/dataContracts/create.js +0 -14
- package/src/dataContracts/createStateTransition.js +0 -23
- package/src/dataContracts/getDataContractByIdentifier.js +0 -87
- package/src/dataContracts/index.js +0 -103
- package/src/documents/create.js +0 -7
- package/src/documents/createStateTransition.js +0 -64
- package/src/documents/index.js +0 -130
- package/src/documents/query.js +0 -94
- package/src/grpcConnectionPool.js +0 -137
- package/src/identities/createStateTransition.js +0 -46
- package/src/identities/getIdentityBalance.js +0 -83
- package/src/identities/getIdentityByIdentifier.js +0 -83
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +0 -85
- package/src/identities/getIdentityByPublicKeyHash.js +0 -83
- package/src/identities/getIdentityContractNonce.js +0 -86
- package/src/identities/getIdentityNonce.js +0 -84
- package/src/identities/getIdentityPublicKeys.js +0 -85
- package/src/identities/index.js +0 -237
- package/src/keyPair/deriveChild.js +0 -50
- package/src/keyPair/derivePath.js +0 -50
- package/src/keyPair/index.js +0 -323
- 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/mnemonicToSeed.js +0 -47
- 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/index.js +0 -170
- package/src/names/registerName.js +0 -131
- package/src/names/searchByIdentity.js +0 -51
- package/src/names/searchByName.js +0 -64
- package/src/names/testNameContested.js +0 -6
- package/src/names/validateName.js +0 -14
- package/src/node/epochs.js +0 -88
- package/src/node/index.js +0 -102
- package/src/node/status.js +0 -85
- package/src/node/totalCredits.js +0 -76
- 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.js +0 -8
- package/src/stateTransitions/broadcast.js +0 -60
- package/src/stateTransitions/index.js +0 -87
- package/src/stateTransitions/waitForStateTransitionResult.js +0 -60
- package/src/tokens/createStateTransition.js +0 -79
- package/src/tokens/getIdentitiesTokenBalances.js +0 -86
- package/src/tokens/getIdentityTokensBalances.js +0 -86
- package/src/tokens/getTokenContractInfo.js +0 -86
- package/src/tokens/getTokenTotalSupply.js +0 -84
- package/src/tokens/index.js +0 -175
- package/src/types.js +0 -25
- package/src/utils/base58ToBytes.js +0 -7
- package/src/utils/bytesToHex.js +0 -6
- package/src/utils/calculateMsgHash.js +0 -34
- package/src/utils/calculateSignHash.js +0 -11
- package/src/utils/calculateStateIdHash.js +0 -12
- package/src/utils/convertToHomographSafeChars.js +0 -14
- package/src/utils/createVoterIdentityId.js +0 -12
- package/src/utils/getEvonodeList.js +0 -63
- package/src/utils/getQuorumPublicKey.js +0 -69
- package/src/utils/getRandomArrayItem.js +0 -6
- package/src/utils/getRandomBytes.js +0 -7
- package/src/utils/hexToBytes.js +0 -7
- package/src/utils/index.js +0 -68
- package/src/utils/indexBytesToString.js +0 -7
- package/src/utils/sha256.js +0 -13
- package/src/utils/signHash.js +0 -25
- package/src/utils/signRequestId.js +0 -22
- package/src/utils/sleep.js +0 -51
- package/src/utils/stringToIndexValueBytes.js +0 -13
- package/src/utils/verifyTenderdashProof.js +0 -30
- package/src/voting/createStateTransition.js +0 -9
- package/src/voting/createVote.js +0 -8
- package/src/voting/index.js +0 -62
- package/test/unit/ContestedResources.spec.js +0 -338
- package/test/unit/DataContract.spec.js +0 -142
- package/test/unit/Document.spec.js +0 -199
- package/test/unit/Identity.spec.js +0 -357
- package/test/unit/KeyPair.spec.js +0 -149
- package/test/unit/Names.spec.js +0 -96
- package/test/unit/Node.spec.js +0 -129
- package/test/unit/SDK.spec.js +0 -12
- package/test/unit/Tokens.spec.js +0 -271
package/src/identities/index.js
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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.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");
|
|
50
|
-
/**
|
|
51
|
-
* Collection of methods to query identities and its related data
|
|
52
|
-
*
|
|
53
|
-
* @hideconstructor
|
|
54
|
-
*/
|
|
55
|
-
var IdentitiesController = /** @class */ (function () {
|
|
56
|
-
function IdentitiesController(grpcPool) {
|
|
57
|
-
this.grpcPool = grpcPool;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get current balance of your Identity by identifier
|
|
61
|
-
*
|
|
62
|
-
* @param identifier {IdentifierLike} Identifier of an identity
|
|
63
|
-
*
|
|
64
|
-
* @return {Promise<bigint>}
|
|
65
|
-
*/
|
|
66
|
-
IdentitiesController.prototype.getIdentityBalance = function (identifier) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
-
return __generator(this, function (_a) {
|
|
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
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Retrieves an Identity from the network by give public key hash
|
|
78
|
-
*
|
|
79
|
-
* @param hex {string} public key hash value in hex, should be a length of 40
|
|
80
|
-
*
|
|
81
|
-
* @return {Promise<IdentityWASM>}
|
|
82
|
-
*/
|
|
83
|
-
IdentitiesController.prototype.getIdentityByPublicKeyHash = function (hex) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
return __generator(this, function (_a) {
|
|
86
|
-
switch (_a.label) {
|
|
87
|
-
case 0:
|
|
88
|
-
if (hex.length !== 40) {
|
|
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
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Retrieves an Identity from the network by non-unique public key hash (like Voter Identity, SHA160)
|
|
99
|
-
*
|
|
100
|
-
* @param hex {string} public key hash value in hex, should be a length of 40
|
|
101
|
-
*
|
|
102
|
-
* @return {Promise<IdentityWASM>}
|
|
103
|
-
*/
|
|
104
|
-
IdentitiesController.prototype.getIdentityByNonUniquePublicKeyHash = function (hex) {
|
|
105
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
return __generator(this, function (_a) {
|
|
107
|
-
switch (_a.label) {
|
|
108
|
-
case 0:
|
|
109
|
-
if (hex.length !== 40) {
|
|
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
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Retrieves Identity by identifier from the network
|
|
120
|
-
* @param identifier {IdentifierLike} identifier
|
|
121
|
-
*
|
|
122
|
-
* @return {Promise<IdentityWASM>}
|
|
123
|
-
*/
|
|
124
|
-
IdentitiesController.prototype.getIdentityByIdentifier = function (identifier) {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
-
return __generator(this, function (_a) {
|
|
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
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Get Identity Nonce (usually used by Identity transitions)
|
|
136
|
-
* @param identifier
|
|
137
|
-
*/
|
|
138
|
-
IdentitiesController.prototype.getIdentityNonce = function (identifier) {
|
|
139
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
-
return __generator(this, function (_a) {
|
|
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
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* Get Identity Contract Nonce (usually used by Document transitions)
|
|
150
|
-
* @param identifier
|
|
151
|
-
* @param dataContract
|
|
152
|
-
*
|
|
153
|
-
* @return {Promise<bigint>}
|
|
154
|
-
*/
|
|
155
|
-
IdentitiesController.prototype.getIdentityContractNonce = function (identifier, dataContract) {
|
|
156
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
157
|
-
return __generator(this, function (_a) {
|
|
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
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* Retrieve given Identity's public keys
|
|
167
|
-
* @param identifier
|
|
168
|
-
*
|
|
169
|
-
* @return {Promise<IdentityPublicKeyWASM[]>}
|
|
170
|
-
*/
|
|
171
|
-
IdentitiesController.prototype.getIdentityPublicKeys = function (identifier) {
|
|
172
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
-
return __generator(this, function (_a) {
|
|
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
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Helper function for creating {StateTransitionWASM} for Identity transitions
|
|
183
|
-
*
|
|
184
|
-
* To create an IdentityCreateTransition, you should pass a params.assetLockProof object containing
|
|
185
|
-
* all necessary AssetLockProof data to make the transaction.
|
|
186
|
-
* Both InstantSend and ChainLock AssetLock proofs supported
|
|
187
|
-
*
|
|
188
|
-
* @param type {string} type of transition, must be a one of ('create' | 'update' | 'topUp')
|
|
189
|
-
* @param params {IdentityTransitionParams} params
|
|
190
|
-
*/
|
|
191
|
-
IdentitiesController.prototype.createStateTransition = function (type, params) {
|
|
192
|
-
if (params.identityId != null) {
|
|
193
|
-
params.identityId = new pshenmic_dpp_1.IdentifierWASM(params.identityId);
|
|
194
|
-
}
|
|
195
|
-
if (params.disablePublicKeyIds == null) {
|
|
196
|
-
params.disablePublicKeyIds = [];
|
|
197
|
-
}
|
|
198
|
-
if (params.assetLockProof != null) {
|
|
199
|
-
var type_1 = params.assetLockProof.type;
|
|
200
|
-
if (type_1 === 'chainLock') {
|
|
201
|
-
var _a = params.assetLockProof, txid = _a.txid, outputIndex = _a.outputIndex, coreChainLockedHeight = _a.coreChainLockedHeight;
|
|
202
|
-
// @ts-expect-error
|
|
203
|
-
params.assetLockProof = pshenmic_dpp_1.AssetLockProofWASM.createChainAssetLockProof(coreChainLockedHeight, new pshenmic_dpp_1.OutPointWASM(txid, outputIndex));
|
|
204
|
-
}
|
|
205
|
-
else if (type_1 === 'instantLock') {
|
|
206
|
-
var _b = params.assetLockProof, transaction = _b.transaction, outputIndex = _b.outputIndex, instantLock = _b.instantLock;
|
|
207
|
-
// @ts-expect-error
|
|
208
|
-
params.assetLockProof = pshenmic_dpp_1.AssetLockProofWASM.createInstantAssetLockProof((0, hexToBytes_1.default)(instantLock), (0, hexToBytes_1.default)(transaction), outputIndex);
|
|
209
|
-
}
|
|
210
|
-
else if (type_1 == null) {
|
|
211
|
-
throw new Error('Missing Asset Lock type in the params');
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
throw new Error("Unknown Asset Lock type: ".concat(type_1));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (params.addPublicKeys != null) {
|
|
218
|
-
// @ts-expect-error
|
|
219
|
-
params.addPublicKeys = params.addPublicKeys
|
|
220
|
-
.map(function (_a) {
|
|
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
|
-
});
|
|
224
|
-
}
|
|
225
|
-
if (params.publicKeys != null) {
|
|
226
|
-
// @ts-expect-error
|
|
227
|
-
params.publicKeys = params.publicKeys
|
|
228
|
-
.map(function (_a) {
|
|
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
|
-
});
|
|
232
|
-
}
|
|
233
|
-
return (0, createStateTransition_1.default)(type, params);
|
|
234
|
-
};
|
|
235
|
-
return IdentitiesController;
|
|
236
|
-
}());
|
|
237
|
-
exports.IdentitiesController = IdentitiesController;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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.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
|
-
});
|
|
50
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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.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
|
-
});
|
|
50
|
-
}
|
package/src/keyPair/index.js
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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.KeyPairController = void 0;
|
|
40
|
-
var deriveChild_1 = require("./deriveChild");
|
|
41
|
-
var derivePath_1 = require("./derivePath");
|
|
42
|
-
var keyToXPublicKey_1 = require("./keyToXPublicKey");
|
|
43
|
-
var keyToWalletId_1 = require("./keyToWalletId");
|
|
44
|
-
var keyToXPrivateKey_1 = require("./keyToXPrivateKey");
|
|
45
|
-
var mnemonicToIdentityKey_1 = require("./mnemonicToIdentityKey");
|
|
46
|
-
var mnemonicToSeed_1 = require("./mnemonicToSeed");
|
|
47
|
-
var mnemonicToWallet_1 = require("./mnemonicToWallet");
|
|
48
|
-
var privateKeyToWif_1 = require("./privateKeyToWif");
|
|
49
|
-
var publicKeyToAddress_1 = require("./publicKeyToAddress");
|
|
50
|
-
var seedToWallet_1 = require("./seedToWallet");
|
|
51
|
-
var walletToIdentityKey_1 = require("./walletToIdentityKey");
|
|
52
|
-
var xkeyToHDXKey_1 = require("./xkeyToHDXKey");
|
|
53
|
-
/**
|
|
54
|
-
* Collection of functions to work with private keys and seed phrases
|
|
55
|
-
*
|
|
56
|
-
* @hideconstructor
|
|
57
|
-
*/
|
|
58
|
-
var KeyPairController = /** @class */ (function () {
|
|
59
|
-
function KeyPairController() {
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Allows to derive child HD Key
|
|
63
|
-
*
|
|
64
|
-
* @param parent {HDKey} - The HDKey parent instance
|
|
65
|
-
* @param index {number} - Index of child
|
|
66
|
-
* @param hardened {boolean} - hardened or no
|
|
67
|
-
*
|
|
68
|
-
* @return {Promise<HDKey>} A promise that resolves child key
|
|
69
|
-
*/
|
|
70
|
-
KeyPairController.prototype.deriveChild = function (parent, index, hardened) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
return __generator(this, function (_a) {
|
|
73
|
-
switch (_a.label) {
|
|
74
|
-
case 0: return [4 /*yield*/, (0, deriveChild_1.default)(parent, index, hardened)];
|
|
75
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Allows to derive HD key by path
|
|
82
|
-
*
|
|
83
|
-
* @param parent {HDKey} - The HDKey parent instance
|
|
84
|
-
* @param path {string} - Path of children
|
|
85
|
-
*
|
|
86
|
-
* @return {Promise<HDKey>} A promise that resolves key by path
|
|
87
|
-
*/
|
|
88
|
-
KeyPairController.prototype.derivePath = function (parent, path) {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
-
return __generator(this, function (_a) {
|
|
91
|
-
switch (_a.label) {
|
|
92
|
-
case 0: return [4 /*yield*/, (0, derivePath_1.default)(parent, path)];
|
|
93
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Convert a HDKey to a public key
|
|
100
|
-
*
|
|
101
|
-
* @param hdKey {HDKey} - The HDKey to be converted into a public key
|
|
102
|
-
* @param opts {NetworkVersion=} - Network version
|
|
103
|
-
*
|
|
104
|
-
* @return {Promise<Uint8Array>} - converted public key
|
|
105
|
-
*/
|
|
106
|
-
KeyPairController.prototype.keyToPublicKey = function (hdKey, opts) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
return __generator(this, function (_a) {
|
|
109
|
-
switch (_a.label) {
|
|
110
|
-
case 0: return [4 /*yield*/, (0, keyToXPublicKey_1.default)(hdKey, opts)];
|
|
111
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* Converts a HDKey to a wallet ID
|
|
118
|
-
*
|
|
119
|
-
* @param hdKey {HDKey} - The HDKey to be converted into a wallet id.
|
|
120
|
-
*
|
|
121
|
-
* @return {Promise<string>} Wallet id from used key
|
|
122
|
-
*/
|
|
123
|
-
KeyPairController.prototype.keyToWalletId = function (hdKey) {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
-
return __generator(this, function (_a) {
|
|
126
|
-
switch (_a.label) {
|
|
127
|
-
case 0: return [4 /*yield*/, (0, keyToWalletId_1.default)(hdKey)];
|
|
128
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Converts an HDKey instance to an extended private key (xprv)
|
|
135
|
-
*
|
|
136
|
-
* @param hdKey {HDKey} - The HDKey instance to convert
|
|
137
|
-
* @param opts {NetworkVersion=} - Optional, containing the version
|
|
138
|
-
*
|
|
139
|
-
* @returns {Promise<string>} A promise that resolves to the xPrivateKey string
|
|
140
|
-
*/
|
|
141
|
-
KeyPairController.prototype.keyToXPrivateKey = function (hdKey, opts) {
|
|
142
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
143
|
-
return __generator(this, function (_a) {
|
|
144
|
-
switch (_a.label) {
|
|
145
|
-
case 0: return [4 /*yield*/, (0, keyToXPrivateKey_1.default)(hdKey, opts)];
|
|
146
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Convert a HDKey to a xPublicKey
|
|
153
|
-
* @param hdKey {HDKey} - The HDKey instance to convert
|
|
154
|
-
* @param opts {NetworkVersion=} - Optional, containing the version
|
|
155
|
-
*
|
|
156
|
-
* @return {Promise<Uint8Array>}
|
|
157
|
-
*/
|
|
158
|
-
KeyPairController.prototype.keyToXPublicKey = function (hdKey, opts) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
-
return __generator(this, function (_a) {
|
|
161
|
-
switch (_a.label) {
|
|
162
|
-
case 0: return [4 /*yield*/, (0, keyToXPublicKey_1.default)(hdKey, opts)];
|
|
163
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* Derives an Identity HDKey from a mnemonic phrase.
|
|
170
|
-
*
|
|
171
|
-
* @param mnemonic {string} - The BIP39 mnemonic phrase.
|
|
172
|
-
* @param identityIndex {number} - The identity index (default: 0).
|
|
173
|
-
* @param keyIndex {number} - The key index within the identity (default: 0).
|
|
174
|
-
* @param salt {string=} - Optional salt for seed derivation.
|
|
175
|
-
* @param verify {boolean=} - Whether to verify the mnemonic during derivation.
|
|
176
|
-
* @param opts {(HDFromSeedOptions & WalletToIdentityKeyOpts)=} - Additional options for HD seed derivation and wallet-to-identity conversion.
|
|
177
|
-
*
|
|
178
|
-
* @returns {Promise<HDKey>} A promise that resolves to the derived identity HDKey.
|
|
179
|
-
*/
|
|
180
|
-
KeyPairController.prototype.mnemonicToIdentityKey = function (mnemonic, identityIndex, keyIndex, salt, verify, opts) {
|
|
181
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
return __generator(this, function (_a) {
|
|
183
|
-
switch (_a.label) {
|
|
184
|
-
case 0: return [4 /*yield*/, (0, mnemonicToIdentityKey_1.default)(mnemonic, identityIndex !== null && identityIndex !== void 0 ? identityIndex : 0, keyIndex !== null && keyIndex !== void 0 ? keyIndex : 0, salt, verify, opts)];
|
|
185
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* Returns seed from mnemonic phrase
|
|
192
|
-
*
|
|
193
|
-
* @param mnemonic {string} - The BIP39 mnemonic phrase.
|
|
194
|
-
* @param salt {string=} - Optional salt for seed derivation.
|
|
195
|
-
* @param verify {boolean=} - Whether to verify the mnemonic during derivation.
|
|
196
|
-
*
|
|
197
|
-
* @return {Promise<Uint8Array>} Seed bytes
|
|
198
|
-
*/
|
|
199
|
-
KeyPairController.prototype.mnemonicToSeed = function (mnemonic, salt, verify) {
|
|
200
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
-
return __generator(this, function (_a) {
|
|
202
|
-
switch (_a.label) {
|
|
203
|
-
case 0: return [4 /*yield*/, (0, mnemonicToSeed_1.default)(mnemonic, salt, verify)];
|
|
204
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* Returns wallet from mnemonic phrase
|
|
211
|
-
*
|
|
212
|
-
* @param mnemonic {string} - The BIP39 mnemonic phrase.
|
|
213
|
-
* @param salt {string=} - Optional salt for seed derivation.
|
|
214
|
-
* @param verify {boolean=} - Whether to verify the mnemonic during derivation.
|
|
215
|
-
* @param opts {HDFromSeedOptions=} - Optional derivation settings
|
|
216
|
-
*
|
|
217
|
-
* @return {Promise<HDWallet>} Wallet from mnemonic
|
|
218
|
-
*/
|
|
219
|
-
KeyPairController.prototype.mnemonicToWallet = function (mnemonic, salt, verify, opts) {
|
|
220
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
221
|
-
return __generator(this, function (_a) {
|
|
222
|
-
switch (_a.label) {
|
|
223
|
-
case 0: return [4 /*yield*/, (0, mnemonicToWallet_1.default)(mnemonic, salt, verify, opts)];
|
|
224
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
/**
|
|
230
|
-
* Convert a private key to WIF
|
|
231
|
-
*
|
|
232
|
-
* @param privateKeyBytes {Uint8Array} - Private key bytes
|
|
233
|
-
* @param opts {NetworkVersion=} - Optional options with network version
|
|
234
|
-
*
|
|
235
|
-
* @return {Promise<string>} WIF
|
|
236
|
-
*/
|
|
237
|
-
KeyPairController.prototype.privateKeyToWif = function (privateKeyBytes, opts) {
|
|
238
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
-
return __generator(this, function (_a) {
|
|
240
|
-
switch (_a.label) {
|
|
241
|
-
case 0: return [4 /*yield*/, (0, privateKeyToWif_1.default)(privateKeyBytes, opts)];
|
|
242
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
};
|
|
247
|
-
/**
|
|
248
|
-
* Convert public key to address
|
|
249
|
-
*
|
|
250
|
-
* @param publicKeyBytes {Uint8Array} - Bytes of public key
|
|
251
|
-
* @param opts {NetworkVersion=} - Optional options with network version
|
|
252
|
-
*
|
|
253
|
-
* @return {Promise<string>} address string
|
|
254
|
-
*/
|
|
255
|
-
KeyPairController.prototype.publicKeyToAddress = function (publicKeyBytes, opts) {
|
|
256
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
257
|
-
return __generator(this, function (_a) {
|
|
258
|
-
switch (_a.label) {
|
|
259
|
-
case 0: return [4 /*yield*/, (0, publicKeyToAddress_1.default)(publicKeyBytes, opts)];
|
|
260
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* Convert seed bytes to wallet
|
|
267
|
-
*
|
|
268
|
-
* @param seed {Uint8Array} - seed bytes
|
|
269
|
-
* @param opts {HDFromSeedOptions?} - Optional options with network version
|
|
270
|
-
*
|
|
271
|
-
* @return {Promise<HDWallet>}
|
|
272
|
-
*/
|
|
273
|
-
KeyPairController.prototype.seedToWallet = function (seed, opts) {
|
|
274
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
275
|
-
return __generator(this, function (_a) {
|
|
276
|
-
switch (_a.label) {
|
|
277
|
-
case 0: return [4 /*yield*/, (0, seedToWallet_1.default)(seed, opts)];
|
|
278
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
};
|
|
283
|
-
/**
|
|
284
|
-
* Returns identity key from wallet
|
|
285
|
-
*
|
|
286
|
-
* @param wallet {HDWallet | HDKey} - wallet that will be used
|
|
287
|
-
* @param identityIndex {number} - index of identity for wallet
|
|
288
|
-
* @param keyIndex {number} - index of key for identity
|
|
289
|
-
* @param opts {WalletToIdentityKeyOpts=} - optional options
|
|
290
|
-
*
|
|
291
|
-
* @return {Promise<HDKey>}
|
|
292
|
-
*/
|
|
293
|
-
KeyPairController.prototype.walletToIdentityKey = function (wallet_1, identityIndex_1, keyIndex_1) {
|
|
294
|
-
return __awaiter(this, arguments, void 0, function (wallet, identityIndex, keyIndex, opts) {
|
|
295
|
-
if (opts === void 0) { opts = { network: 'testnet' }; }
|
|
296
|
-
return __generator(this, function (_a) {
|
|
297
|
-
switch (_a.label) {
|
|
298
|
-
case 0: return [4 /*yield*/, (0, walletToIdentityKey_1.default)(wallet, identityIndex, keyIndex, opts)];
|
|
299
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Allows to convert xKey to HDXKey
|
|
306
|
-
*
|
|
307
|
-
* @param xKey {string} - String with xKey
|
|
308
|
-
* @param opts {HDFromXKeyOptions=} - Optional options
|
|
309
|
-
* @return {Promise<HDXKey>}
|
|
310
|
-
*/
|
|
311
|
-
KeyPairController.prototype.xKeyToHDXKey = function (xKey, opts) {
|
|
312
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
313
|
-
return __generator(this, function (_a) {
|
|
314
|
-
switch (_a.label) {
|
|
315
|
-
case 0: return [4 /*yield*/, (0, xkeyToHDXKey_1.default)(xKey, opts)];
|
|
316
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
return KeyPairController;
|
|
322
|
-
}());
|
|
323
|
-
exports.KeyPairController = KeyPairController;
|