@firmachain/firma-js 0.2.47 → 0.2.49
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/dist/index.js +1 -5
- package/dist/sdk/FirmaAuthzService.js +5 -5
- package/dist/sdk/FirmaBankService.js +1 -1
- package/dist/sdk/FirmaChainService.d.ts +5 -0
- package/dist/sdk/FirmaChainService.js +44 -0
- package/dist/sdk/FirmaContractService.js +5 -5
- package/dist/sdk/FirmaCosmWasmCw20.d.ts +17 -0
- package/dist/sdk/FirmaCosmWasmCw20.js +269 -0
- package/dist/sdk/FirmaCosmWasmCw721.d.ts +43 -0
- package/dist/sdk/FirmaCosmWasmCw721.js +318 -0
- package/dist/sdk/FirmaCosmWasmService.js +9 -9
- package/dist/sdk/FirmaDistributionService.js +5 -5
- package/dist/sdk/FirmaFeeGrantService.js +3 -3
- package/dist/sdk/FirmaGovService.js +7 -7
- package/dist/sdk/FirmaIbcService.js +1 -1
- package/dist/sdk/FirmaNftService.js +5 -5
- package/dist/sdk/FirmaSDK.d.ts +5 -1
- package/dist/sdk/FirmaSDK.js +7 -1
- package/dist/sdk/FirmaStakingService.d.ts +7 -1
- package/dist/sdk/FirmaStakingService.js +16 -8
- package/dist/sdk/FirmaTokenService.js +4 -4
- package/dist/sdk/FirmaUtil.js +16 -20
- package/dist/sdk/FirmaWalletService.js +3 -3
- package/dist/sdk/firmachain/amino/addresses.js +11 -11
- package/dist/sdk/firmachain/amino/aminotypes.js +32 -36
- package/dist/sdk/firmachain/amino/encoding.js +26 -30
- package/dist/sdk/firmachain/amino/multisig.js +5 -5
- package/dist/sdk/firmachain/amino/signature.js +4 -4
- package/dist/sdk/firmachain/amino/signdoc.js +1 -1
- package/dist/sdk/firmachain/amino/wallet.js +10 -14
- package/dist/sdk/firmachain/authz/AuthzQueryClient.js +3 -3
- package/dist/sdk/firmachain/authz/index.js +1 -5
- package/dist/sdk/firmachain/bank/BankQueryClient.js +4 -4
- package/dist/sdk/firmachain/bank/index.js +1 -5
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +2 -2
- package/dist/sdk/firmachain/common/LedgerWallet.js +10 -14
- package/dist/sdk/firmachain/common/accounts.js +2 -2
- package/dist/sdk/firmachain/common/index.js +1 -5
- package/dist/sdk/firmachain/common/signing.js +5 -9
- package/dist/sdk/firmachain/common/signingaminostargateclient.js +16 -16
- package/dist/sdk/firmachain/common/signingstargateclient.js +14 -18
- package/dist/sdk/firmachain/common/stargateclient.js +6 -6
- package/dist/sdk/firmachain/contract/ContractQueryClient.js +2 -2
- package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +4 -4
- package/dist/sdk/firmachain/contract/index.js +1 -5
- package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +8 -8
- package/dist/sdk/firmachain/cosmwasm/index.js +1 -5
- package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +5 -5
- package/dist/sdk/firmachain/distribution/index.js +1 -5
- package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +2 -2
- package/dist/sdk/firmachain/feegrant/index.js +1 -5
- package/dist/sdk/firmachain/google/protobuf/any.d.ts +1 -1
- package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +27 -27
- package/dist/sdk/firmachain/google/protobuf/duration.d.ts +1 -1
- package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +1 -1
- package/dist/sdk/firmachain/gov/GovQueryClient.js +2 -2
- package/dist/sdk/firmachain/gov/index.js +1 -5
- package/dist/sdk/firmachain/ibc/IbcQueryClient.js +1 -1
- package/dist/sdk/firmachain/ibc/index.js +1 -5
- package/dist/sdk/firmachain/mint/index.js +1 -5
- package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +6 -6
- package/dist/sdk/firmachain/nft/index.js +1 -5
- package/dist/sdk/firmachain/slashing/index.js +1 -5
- package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +3 -3
- package/dist/sdk/firmachain/staking/StakingQueryClient.js +13 -13
- package/dist/sdk/firmachain/staking/index.js +1 -5
- package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +8 -8
- package/dist/sdk/firmachain/token/index.js +1 -5
- package/package.json +24 -24
|
@@ -4,6 +4,12 @@ import { FirmaConfig } from "./FirmaConfig";
|
|
|
4
4
|
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
5
5
|
import { Description } from "cosmjs-types/cosmos/staking/v1beta1/staking";
|
|
6
6
|
import { MsgCreateValidator } from "cosmjs-types/cosmos/staking/v1beta1/tx";
|
|
7
|
+
export declare enum StakingValidatorStatus {
|
|
8
|
+
ALL = "",
|
|
9
|
+
BONDED = "BOND_STATUS_BONDED",
|
|
10
|
+
UNBONDED = "BOND_STATUS_UNBONDED",
|
|
11
|
+
UNBONDING = "BOND_STATUS_UNBONDING"
|
|
12
|
+
}
|
|
7
13
|
export declare class FirmaStakingService {
|
|
8
14
|
private readonly config;
|
|
9
15
|
constructor(config: FirmaConfig);
|
|
@@ -40,7 +46,7 @@ export declare class FirmaStakingService {
|
|
|
40
46
|
getParams(): Promise<ParamsDataType>;
|
|
41
47
|
getPool(): Promise<PoolDataType>;
|
|
42
48
|
getValidator(valoperAddress: string): Promise<ValidatorDataType>;
|
|
43
|
-
getValidatorList(paginationKey?: string): Promise<{
|
|
49
|
+
getValidatorList(status?: StakingValidatorStatus, paginationKey?: string): Promise<{
|
|
44
50
|
dataList: ValidatorDataType[];
|
|
45
51
|
pagination: Pagination;
|
|
46
52
|
}>;
|
|
@@ -36,9 +36,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.FirmaStakingService = void 0;
|
|
39
|
+
exports.FirmaStakingService = exports.StakingValidatorStatus = void 0;
|
|
40
40
|
var staking_1 = require("./firmachain/staking");
|
|
41
41
|
var FirmaUtil_1 = require("./FirmaUtil");
|
|
42
|
+
var StakingValidatorStatus;
|
|
43
|
+
(function (StakingValidatorStatus) {
|
|
44
|
+
StakingValidatorStatus["ALL"] = "";
|
|
45
|
+
StakingValidatorStatus["BONDED"] = "BOND_STATUS_BONDED";
|
|
46
|
+
StakingValidatorStatus["UNBONDED"] = "BOND_STATUS_UNBONDED";
|
|
47
|
+
StakingValidatorStatus["UNBONDING"] = "BOND_STATUS_UNBONDING";
|
|
48
|
+
})(StakingValidatorStatus = exports.StakingValidatorStatus || (exports.StakingValidatorStatus = {}));
|
|
42
49
|
var FirmaStakingService = /** @class */ (function () {
|
|
43
50
|
function FirmaStakingService(config) {
|
|
44
51
|
this.config = config;
|
|
@@ -130,7 +137,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
130
137
|
validatorAddress: validatorAddres,
|
|
131
138
|
amount: sendAmount
|
|
132
139
|
});
|
|
133
|
-
return [4 /*yield*/, txClient.sign([message],
|
|
140
|
+
return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
134
141
|
case 2: return [2 /*return*/, _a.sent()];
|
|
135
142
|
case 3:
|
|
136
143
|
error_4 = _a.sent();
|
|
@@ -159,7 +166,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
159
166
|
validatorAddress: validatorAddres,
|
|
160
167
|
amount: sendAmount
|
|
161
168
|
});
|
|
162
|
-
return [4 /*yield*/, txClient.sign([message],
|
|
169
|
+
return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
163
170
|
case 2: return [2 /*return*/, _a.sent()];
|
|
164
171
|
case 3:
|
|
165
172
|
error_5 = _a.sent();
|
|
@@ -189,7 +196,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
189
196
|
validatorDstAddress: validatorDstAddress,
|
|
190
197
|
amount: sendAmount
|
|
191
198
|
});
|
|
192
|
-
return [4 /*yield*/, txClient.sign([message],
|
|
199
|
+
return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
193
200
|
case 2: return [2 /*return*/, _a.sent()];
|
|
194
201
|
case 3:
|
|
195
202
|
error_6 = _a.sent();
|
|
@@ -218,7 +225,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
218
225
|
pubkey: validatorInfo.pubkey,
|
|
219
226
|
value: validatorInfo.value
|
|
220
227
|
});
|
|
221
|
-
return [4 /*yield*/, txClient.sign([message],
|
|
228
|
+
return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
222
229
|
case 1: return [2 /*return*/, _a.sent()];
|
|
223
230
|
case 2:
|
|
224
231
|
error_7 = _a.sent();
|
|
@@ -244,7 +251,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
244
251
|
commissionRate: commissionRate,
|
|
245
252
|
minSelfDelegation: minSelfDelegation
|
|
246
253
|
});
|
|
247
|
-
return [4 /*yield*/, txClient.sign([message],
|
|
254
|
+
return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
248
255
|
case 1: return [2 /*return*/, _a.sent()];
|
|
249
256
|
case 2:
|
|
250
257
|
error_8 = _a.sent();
|
|
@@ -584,7 +591,8 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
584
591
|
});
|
|
585
592
|
});
|
|
586
593
|
};
|
|
587
|
-
FirmaStakingService.prototype.getValidatorList = function (paginationKey) {
|
|
594
|
+
FirmaStakingService.prototype.getValidatorList = function (status, paginationKey) {
|
|
595
|
+
if (status === void 0) { status = StakingValidatorStatus.ALL; }
|
|
588
596
|
if (paginationKey === void 0) { paginationKey = ""; }
|
|
589
597
|
return __awaiter(this, void 0, void 0, function () {
|
|
590
598
|
var queryClient, result, error_24;
|
|
@@ -593,7 +601,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
593
601
|
case 0:
|
|
594
602
|
_a.trys.push([0, 2, , 3]);
|
|
595
603
|
queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
|
|
596
|
-
return [4 /*yield*/, queryClient.queryValidators(paginationKey)];
|
|
604
|
+
return [4 /*yield*/, queryClient.queryValidators(status.toString(), paginationKey)];
|
|
597
605
|
case 1:
|
|
598
606
|
result = _a.sent();
|
|
599
607
|
return [2 /*return*/, result];
|
|
@@ -151,7 +151,7 @@ var TokenService = /** @class */ (function () {
|
|
|
151
151
|
tokenURI: tokenURI
|
|
152
152
|
});
|
|
153
153
|
txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
|
|
154
|
-
return [4 /*yield*/, txClient.sign([message],
|
|
154
|
+
return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
155
155
|
case 2: return [2 /*return*/, _a.sent()];
|
|
156
156
|
case 3:
|
|
157
157
|
error_5 = _a.sent();
|
|
@@ -179,7 +179,7 @@ var TokenService = /** @class */ (function () {
|
|
|
179
179
|
amount: amount
|
|
180
180
|
});
|
|
181
181
|
txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
|
|
182
|
-
return [4 /*yield*/, txClient.sign([message],
|
|
182
|
+
return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
183
183
|
case 2: return [2 /*return*/, _a.sent()];
|
|
184
184
|
case 3:
|
|
185
185
|
error_6 = _a.sent();
|
|
@@ -208,7 +208,7 @@ var TokenService = /** @class */ (function () {
|
|
|
208
208
|
toAddress: toAddress
|
|
209
209
|
});
|
|
210
210
|
txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
|
|
211
|
-
return [4 /*yield*/, txClient.sign([message],
|
|
211
|
+
return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
212
212
|
case 2: return [2 /*return*/, _a.sent()];
|
|
213
213
|
case 3:
|
|
214
214
|
error_7 = _a.sent();
|
|
@@ -241,7 +241,7 @@ var TokenService = /** @class */ (function () {
|
|
|
241
241
|
burnable: isBurnable
|
|
242
242
|
});
|
|
243
243
|
txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
|
|
244
|
-
return [4 /*yield*/, txClient.sign([message],
|
|
244
|
+
return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
245
245
|
case 2: return [2 /*return*/, _a.sent()];
|
|
246
246
|
case 3:
|
|
247
247
|
error_8 = _a.sent();
|
package/dist/sdk/FirmaUtil.js
CHANGED
|
@@ -62,14 +62,10 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
62
62
|
}
|
|
63
63
|
return ar;
|
|
64
64
|
};
|
|
65
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
ar[i] = from[i];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
65
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
66
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
67
|
+
to[j] = from[i];
|
|
68
|
+
return to;
|
|
73
69
|
};
|
|
74
70
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
75
71
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -212,7 +208,7 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
212
208
|
return false;
|
|
213
209
|
};
|
|
214
210
|
FirmaUtil.buf2hex = function (buffer) {
|
|
215
|
-
return __spreadArray([], __read(new Uint8Array(buffer))
|
|
211
|
+
return __spreadArray([], __read(new Uint8Array(buffer))).map(function (x) { return x.toString(16).padStart(2, '0'); })
|
|
216
212
|
.join('');
|
|
217
213
|
};
|
|
218
214
|
// for evm address support
|
|
@@ -225,8 +221,8 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
225
221
|
return encoding_1.Bech32.encode(FirmaUtil.config.prefix + "valoper", data);
|
|
226
222
|
};
|
|
227
223
|
FirmaUtil.getValConsAddressFromAccAddress = function (consensusPubkey) {
|
|
228
|
-
var ed25519PubkeyRaw =
|
|
229
|
-
var addressData =
|
|
224
|
+
var ed25519PubkeyRaw = encoding_2.fromBase64(consensusPubkey);
|
|
225
|
+
var addressData = crypto_1.sha256(ed25519PubkeyRaw).slice(0, 20);
|
|
230
226
|
return encoding_1.Bech32.encode(FirmaUtil.config.prefix + "valcons", addressData);
|
|
231
227
|
};
|
|
232
228
|
FirmaUtil.getAccAddressFromValOperAddress = function (address) {
|
|
@@ -264,7 +260,7 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
264
260
|
case 0:
|
|
265
261
|
_a.trys.push([0, 2, , 3]);
|
|
266
262
|
encodedTx = Uint8Array.from(tx_1.TxRaw.encode(txRaw).finish());
|
|
267
|
-
hexTx = "0x"
|
|
263
|
+
hexTx = "0x" + Buffer.from(encodedTx).toString("hex");
|
|
268
264
|
queryClient = new TendermintQueryClient_1.TendermintQueryClient(FirmaUtil.config.rpcAddress);
|
|
269
265
|
return [4 /*yield*/, queryClient.queryEstimateGas(hexTx)];
|
|
270
266
|
case 1:
|
|
@@ -288,7 +284,7 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
288
284
|
case 0:
|
|
289
285
|
_a.trys.push([0, 2, , 3]);
|
|
290
286
|
encodedTx = Uint8Array.from(txRaw);
|
|
291
|
-
hexTx = "0x"
|
|
287
|
+
hexTx = "0x" + Buffer.from(encodedTx).toString("hex");
|
|
292
288
|
console.log("hexTx:" + hexTx);
|
|
293
289
|
queryClient = new TendermintQueryClient_1.TendermintQueryClient(FirmaUtil.config.rpcAddress);
|
|
294
290
|
return [4 /*yield*/, queryClient.queryEstimateGas(hexTx)];
|
|
@@ -308,7 +304,7 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
308
304
|
FirmaUtil.printLog = function (log) {
|
|
309
305
|
if (FirmaUtil.config.isShowLog === false)
|
|
310
306
|
return;
|
|
311
|
-
console.log("[FirmaSDK] "
|
|
307
|
+
console.log("[FirmaSDK] " + log);
|
|
312
308
|
};
|
|
313
309
|
FirmaUtil.experimentalAdr36Sign = function (wallet, data) {
|
|
314
310
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -363,7 +359,7 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
363
359
|
if (recoveryIndex > 3) {
|
|
364
360
|
throw new Error('Invalid recovery index');
|
|
365
361
|
}
|
|
366
|
-
sig = crypto_1.Secp256k1Signature.fromFixedLength(
|
|
362
|
+
sig = crypto_1.Secp256k1Signature.fromFixedLength(encoding_2.fromBase64(signature));
|
|
367
363
|
extendedSig = new crypto_1.ExtendedSecp256k1Signature(sig.r(), sig.s(), recoveryIndex);
|
|
368
364
|
_b.label = 1;
|
|
369
365
|
case 1:
|
|
@@ -371,9 +367,9 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
371
367
|
return [4 /*yield*/, crypto_1.Secp256k1.recoverPubkey(extendedSig, hash)];
|
|
372
368
|
case 2:
|
|
373
369
|
recoveredPubKey = _b.sent();
|
|
374
|
-
return [2 /*return*/,
|
|
370
|
+
return [2 /*return*/, amino_1.pubkeyToAddress({
|
|
375
371
|
type: 'tendermint/PubKeySecp256k1',
|
|
376
|
-
value:
|
|
372
|
+
value: encoding_2.toBase64(crypto_1.Secp256k1.compressPubkey(recoveredPubKey)),
|
|
377
373
|
}, 'firma')];
|
|
378
374
|
case 3:
|
|
379
375
|
_a = _b.sent();
|
|
@@ -409,16 +405,16 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
409
405
|
});
|
|
410
406
|
};
|
|
411
407
|
FirmaUtil.verifyDirectSignature = function (address, signature, signDoc) {
|
|
412
|
-
var messageHash =
|
|
408
|
+
var messageHash = crypto_1.sha256(proto_signing_1.makeSignBytes(signDoc));
|
|
413
409
|
return this.verifySignature(address, signature, messageHash);
|
|
414
410
|
};
|
|
415
411
|
;
|
|
416
412
|
FirmaUtil.parseSignDocValues = function (signDocString) {
|
|
417
413
|
var signDoc = JSON.parse(signDocString);
|
|
418
|
-
return __assign(__assign({}, signDoc), { bodyBytes:
|
|
414
|
+
return __assign(__assign({}, signDoc), { bodyBytes: encoding_2.fromHex(signDoc.bodyBytes), authInfoBytes: encoding_2.fromHex(signDoc.authInfoBytes), accountNumber: long_1.default.fromString(signDoc.accountNumber) });
|
|
419
415
|
};
|
|
420
416
|
FirmaUtil.stringifySignDocValues = function (signDoc) {
|
|
421
|
-
return JSON.stringify(__assign(__assign({}, signDoc), { bodyBytes:
|
|
417
|
+
return JSON.stringify(__assign(__assign({}, signDoc), { bodyBytes: encoding_2.toHex(signDoc.bodyBytes), authInfoBytes: encoding_2.toHex(signDoc.authInfoBytes), accountNumber: signDoc.accountNumber.toString() }));
|
|
422
418
|
};
|
|
423
419
|
FirmaUtil.makeSignDoc = function (signerAddress, pubkey, messages, txMisc) {
|
|
424
420
|
if (txMisc === void 0) { txMisc = exports.DefaultTxMisc; }
|
|
@@ -92,7 +92,7 @@ var FirmaWalletService = /** @class */ (function () {
|
|
|
92
92
|
return __awaiter(this, void 0, void 0, function () {
|
|
93
93
|
return __generator(this, function (_a) {
|
|
94
94
|
switch (_a.label) {
|
|
95
|
-
case 0: return [4 /*yield*/,
|
|
95
|
+
case 0: return [4 /*yield*/, LedgerWallet_1.signFromLedger(this.ledger, messages, option, registry)];
|
|
96
96
|
case 1: return [2 /*return*/, _a.sent()];
|
|
97
97
|
}
|
|
98
98
|
});
|
|
@@ -147,7 +147,7 @@ var FirmaWalletService = /** @class */ (function () {
|
|
|
147
147
|
};
|
|
148
148
|
FirmaWalletService.getHdPath = function (hdPath, accountIndex) {
|
|
149
149
|
try {
|
|
150
|
-
return [
|
|
150
|
+
return [crypto_1.stringToPath(hdPath + accountIndex + "'/0/0")];
|
|
151
151
|
}
|
|
152
152
|
catch (error) {
|
|
153
153
|
FirmaUtil_1.FirmaUtil.printLog(error);
|
|
@@ -193,7 +193,7 @@ var FirmaWalletService = /** @class */ (function () {
|
|
|
193
193
|
seed = _a.sent();
|
|
194
194
|
hdpath = FirmaWalletService.getHdPath(this.getHdPath(), accountIndex);
|
|
195
195
|
privkey = crypto_1.Slip10.derivePath(crypto_1.Slip10Curve.Secp256k1, seed, hdpath[0]).privkey;
|
|
196
|
-
privateKey = "0x"
|
|
196
|
+
privateKey = "0x" + Buffer.from(privkey).toString("hex");
|
|
197
197
|
return [2 /*return*/, privateKey];
|
|
198
198
|
case 2:
|
|
199
199
|
error_4 = _a.sent();
|
|
@@ -8,32 +8,32 @@ var encoding_2 = require("./encoding");
|
|
|
8
8
|
var pubkeys_1 = require("./pubkeys");
|
|
9
9
|
function rawEd25519PubkeyToRawAddress(pubkeyData) {
|
|
10
10
|
if (pubkeyData.length !== 32) {
|
|
11
|
-
throw new Error("Invalid Ed25519 pubkey length: "
|
|
11
|
+
throw new Error("Invalid Ed25519 pubkey length: " + pubkeyData.length);
|
|
12
12
|
}
|
|
13
|
-
return
|
|
13
|
+
return crypto_1.sha256(pubkeyData).slice(0, 20);
|
|
14
14
|
}
|
|
15
15
|
exports.rawEd25519PubkeyToRawAddress = rawEd25519PubkeyToRawAddress;
|
|
16
16
|
function rawSecp256k1PubkeyToRawAddress(pubkeyData) {
|
|
17
17
|
if (pubkeyData.length !== 33) {
|
|
18
|
-
throw new Error("Invalid Secp256k1 pubkey length (compressed): "
|
|
18
|
+
throw new Error("Invalid Secp256k1 pubkey length (compressed): " + pubkeyData.length);
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return crypto_1.ripemd160(crypto_1.sha256(pubkeyData));
|
|
21
21
|
}
|
|
22
22
|
exports.rawSecp256k1PubkeyToRawAddress = rawSecp256k1PubkeyToRawAddress;
|
|
23
23
|
// For secp256k1 this assumes we already have a compressed pubkey.
|
|
24
24
|
function pubkeyToRawAddress(pubkey) {
|
|
25
|
-
if (
|
|
26
|
-
var pubkeyData =
|
|
25
|
+
if (pubkeys_1.isSecp256k1Pubkey(pubkey)) {
|
|
26
|
+
var pubkeyData = encoding_1.fromBase64(pubkey.value);
|
|
27
27
|
return rawSecp256k1PubkeyToRawAddress(pubkeyData);
|
|
28
28
|
}
|
|
29
|
-
else if (
|
|
30
|
-
var pubkeyData =
|
|
29
|
+
else if (pubkeys_1.isEd25519Pubkey(pubkey)) {
|
|
30
|
+
var pubkeyData = encoding_1.fromBase64(pubkey.value);
|
|
31
31
|
return rawEd25519PubkeyToRawAddress(pubkeyData);
|
|
32
32
|
}
|
|
33
|
-
else if (
|
|
33
|
+
else if (pubkeys_1.isMultisigThresholdPubkey(pubkey)) {
|
|
34
34
|
// https://github.com/tendermint/tendermint/blob/38b401657e4ad7a7eeb3c30a3cbf512037df3740/crypto/multisig/threshold_pubkey.go#L71-L74
|
|
35
|
-
var pubkeyData =
|
|
36
|
-
return
|
|
35
|
+
var pubkeyData = encoding_2.encodeAminoPubkey(pubkey);
|
|
36
|
+
return crypto_1.sha256(pubkeyData).slice(0, 20);
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
39
|
throw new Error("Unsupported public key type");
|
|
@@ -26,14 +26,10 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
26
26
|
}
|
|
27
27
|
return ar;
|
|
28
28
|
};
|
|
29
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ar[i] = from[i];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
29
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
30
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
31
|
+
to[j] = from[i];
|
|
32
|
+
return to;
|
|
37
33
|
};
|
|
38
34
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -56,7 +52,7 @@ function omitDefault(input) {
|
|
|
56
52
|
if (long_1.default.isLong(input)) {
|
|
57
53
|
return input.isZero() ? undefined : input;
|
|
58
54
|
}
|
|
59
|
-
throw new Error("Got unsupported type '"
|
|
55
|
+
throw new Error("Got unsupported type '" + typeof input + "'");
|
|
60
56
|
}
|
|
61
57
|
function createDefaultTypes(prefix) {
|
|
62
58
|
return {
|
|
@@ -68,7 +64,7 @@ function createDefaultTypes(prefix) {
|
|
|
68
64
|
return ({
|
|
69
65
|
from_address: fromAddress,
|
|
70
66
|
to_address: toAddress,
|
|
71
|
-
amount: __spreadArray([], __read(amount)
|
|
67
|
+
amount: __spreadArray([], __read(amount)),
|
|
72
68
|
});
|
|
73
69
|
},
|
|
74
70
|
fromAmino: function (_a) {
|
|
@@ -76,7 +72,7 @@ function createDefaultTypes(prefix) {
|
|
|
76
72
|
return ({
|
|
77
73
|
fromAddress: from_address,
|
|
78
74
|
toAddress: to_address,
|
|
79
|
-
amount: __spreadArray([], __read(amount)
|
|
75
|
+
amount: __spreadArray([], __read(amount)),
|
|
80
76
|
});
|
|
81
77
|
},
|
|
82
78
|
},
|
|
@@ -87,11 +83,11 @@ function createDefaultTypes(prefix) {
|
|
|
87
83
|
return ({
|
|
88
84
|
inputs: inputs.map(function (input) { return ({
|
|
89
85
|
address: input.address,
|
|
90
|
-
coins: __spreadArray([], __read(input.coins)
|
|
86
|
+
coins: __spreadArray([], __read(input.coins)),
|
|
91
87
|
}); }),
|
|
92
88
|
outputs: outputs.map(function (output) { return ({
|
|
93
89
|
address: output.address,
|
|
94
|
-
coins: __spreadArray([], __read(output.coins)
|
|
90
|
+
coins: __spreadArray([], __read(output.coins)),
|
|
95
91
|
}); }),
|
|
96
92
|
});
|
|
97
93
|
},
|
|
@@ -100,11 +96,11 @@ function createDefaultTypes(prefix) {
|
|
|
100
96
|
return ({
|
|
101
97
|
inputs: inputs.map(function (input) { return ({
|
|
102
98
|
address: input.address,
|
|
103
|
-
coins: __spreadArray([], __read(input.coins)
|
|
99
|
+
coins: __spreadArray([], __read(input.coins)),
|
|
104
100
|
}); }),
|
|
105
101
|
outputs: outputs.map(function (output) { return ({
|
|
106
102
|
address: output.address,
|
|
107
|
-
coins: __spreadArray([], __read(output.coins)
|
|
103
|
+
coins: __spreadArray([], __read(output.coins)),
|
|
108
104
|
}); }),
|
|
109
105
|
});
|
|
110
106
|
},
|
|
@@ -115,14 +111,14 @@ function createDefaultTypes(prefix) {
|
|
|
115
111
|
toAmino: function (_a) {
|
|
116
112
|
var amount = _a.amount, depositor = _a.depositor;
|
|
117
113
|
return ({
|
|
118
|
-
amount: __spreadArray([], __read(amount)
|
|
114
|
+
amount: __spreadArray([], __read(amount)),
|
|
119
115
|
depositor: depositor,
|
|
120
116
|
});
|
|
121
117
|
},
|
|
122
118
|
fromAmino: function (_a) {
|
|
123
119
|
var amount = _a.amount, depositor = _a.depositor;
|
|
124
120
|
return ({
|
|
125
|
-
amount: __spreadArray([], __read(amount)
|
|
121
|
+
amount: __spreadArray([], __read(amount)),
|
|
126
122
|
depositor: depositor,
|
|
127
123
|
});
|
|
128
124
|
},
|
|
@@ -209,7 +205,7 @@ function createDefaultTypes(prefix) {
|
|
|
209
205
|
fromAmino: function (_a) {
|
|
210
206
|
var option = _a.option, proposal_id = _a.proposal_id, voter = _a.voter;
|
|
211
207
|
return {
|
|
212
|
-
option:
|
|
208
|
+
option: gov_1.voteOptionFromJSON(option),
|
|
213
209
|
proposalId: long_1.default.fromString(proposal_id),
|
|
214
210
|
voter: voter,
|
|
215
211
|
};
|
|
@@ -219,7 +215,7 @@ function createDefaultTypes(prefix) {
|
|
|
219
215
|
aminoType: "cosmos-sdk/MsgSubmitProposal",
|
|
220
216
|
toAmino: function (_a) {
|
|
221
217
|
var initialDeposit = _a.initialDeposit, proposer = _a.proposer, content = _a.content;
|
|
222
|
-
|
|
218
|
+
utils_1.assertDefinedAndNotNull(content);
|
|
223
219
|
var proposal;
|
|
224
220
|
switch (content.typeUrl) {
|
|
225
221
|
case "/cosmos.gov.v1beta1.TextProposal": {
|
|
@@ -234,7 +230,7 @@ function createDefaultTypes(prefix) {
|
|
|
234
230
|
break;
|
|
235
231
|
}
|
|
236
232
|
default:
|
|
237
|
-
throw new Error("Unsupported proposal type: '"
|
|
233
|
+
throw new Error("Unsupported proposal type: '" + content.typeUrl + "'");
|
|
238
234
|
}
|
|
239
235
|
return {
|
|
240
236
|
initial_deposit: initialDeposit,
|
|
@@ -248,10 +244,10 @@ function createDefaultTypes(prefix) {
|
|
|
248
244
|
switch (content.type) {
|
|
249
245
|
case "cosmos-sdk/TextProposal": {
|
|
250
246
|
var value = content.value;
|
|
251
|
-
|
|
247
|
+
utils_1.assert(utils_1.isNonNullObject(value));
|
|
252
248
|
var _b = value, title = _b.title, description = _b.description;
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
utils_1.assert(typeof title === "string");
|
|
250
|
+
utils_1.assert(typeof description === "string");
|
|
255
251
|
any_content = any_1.Any.fromPartial({
|
|
256
252
|
typeUrl: "/cosmos.gov.v1beta1.TextProposal",
|
|
257
253
|
value: gov_1.TextProposal.encode(gov_1.TextProposal.fromPartial({
|
|
@@ -262,7 +258,7 @@ function createDefaultTypes(prefix) {
|
|
|
262
258
|
break;
|
|
263
259
|
}
|
|
264
260
|
default:
|
|
265
|
-
throw new Error("Unsupported proposal type: '"
|
|
261
|
+
throw new Error("Unsupported proposal type: '" + content.type + "'");
|
|
266
262
|
}
|
|
267
263
|
return {
|
|
268
264
|
initialDeposit: Array.from(initial_deposit),
|
|
@@ -276,7 +272,7 @@ function createDefaultTypes(prefix) {
|
|
|
276
272
|
aminoType: "cosmos-sdk/MsgBeginRedelegate",
|
|
277
273
|
toAmino: function (_a) {
|
|
278
274
|
var delegatorAddress = _a.delegatorAddress, validatorSrcAddress = _a.validatorSrcAddress, validatorDstAddress = _a.validatorDstAddress, amount = _a.amount;
|
|
279
|
-
|
|
275
|
+
utils_1.assertDefinedAndNotNull(amount, "missing amount");
|
|
280
276
|
return {
|
|
281
277
|
delegator_address: delegatorAddress,
|
|
282
278
|
validator_src_address: validatorSrcAddress,
|
|
@@ -298,10 +294,10 @@ function createDefaultTypes(prefix) {
|
|
|
298
294
|
aminoType: "cosmos-sdk/MsgCreateValidator",
|
|
299
295
|
toAmino: function (_a) {
|
|
300
296
|
var description = _a.description, commission = _a.commission, minSelfDelegation = _a.minSelfDelegation, delegatorAddress = _a.delegatorAddress, validatorAddress = _a.validatorAddress, pubkey = _a.pubkey, value = _a.value;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
297
|
+
utils_1.assertDefinedAndNotNull(description, "missing description");
|
|
298
|
+
utils_1.assertDefinedAndNotNull(commission, "missing commission");
|
|
299
|
+
utils_1.assertDefinedAndNotNull(pubkey, "missing pubkey");
|
|
300
|
+
utils_1.assertDefinedAndNotNull(value, "missing value");
|
|
305
301
|
return {
|
|
306
302
|
description: {
|
|
307
303
|
moniker: description.moniker,
|
|
@@ -318,16 +314,16 @@ function createDefaultTypes(prefix) {
|
|
|
318
314
|
min_self_delegation: minSelfDelegation,
|
|
319
315
|
delegator_address: delegatorAddress,
|
|
320
316
|
validator_address: validatorAddress,
|
|
321
|
-
pubkey:
|
|
317
|
+
pubkey: encoding_2.encodeBech32Pubkey({
|
|
322
318
|
type: "tendermint/PubKeySecp256k1",
|
|
323
|
-
value:
|
|
319
|
+
value: encoding_1.toBase64(pubkey.value),
|
|
324
320
|
}, prefix),
|
|
325
321
|
value: value,
|
|
326
322
|
};
|
|
327
323
|
},
|
|
328
324
|
fromAmino: function (_a) {
|
|
329
325
|
var description = _a.description, commission = _a.commission, min_self_delegation = _a.min_self_delegation, delegator_address = _a.delegator_address, validator_address = _a.validator_address, pubkey = _a.pubkey, value = _a.value;
|
|
330
|
-
var decodedPubkey =
|
|
326
|
+
var decodedPubkey = encoding_2.decodeBech32Pubkey(pubkey);
|
|
331
327
|
if (decodedPubkey.type !== "tendermint/PubKeySecp256k1") {
|
|
332
328
|
throw new Error("Only Secp256k1 public keys are supported");
|
|
333
329
|
}
|
|
@@ -349,7 +345,7 @@ function createDefaultTypes(prefix) {
|
|
|
349
345
|
validatorAddress: validator_address,
|
|
350
346
|
pubkey: {
|
|
351
347
|
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
|
352
|
-
value:
|
|
348
|
+
value: encoding_1.fromBase64(decodedPubkey.value),
|
|
353
349
|
},
|
|
354
350
|
value: value,
|
|
355
351
|
};
|
|
@@ -359,7 +355,7 @@ function createDefaultTypes(prefix) {
|
|
|
359
355
|
aminoType: "cosmos-sdk/MsgDelegate",
|
|
360
356
|
toAmino: function (_a) {
|
|
361
357
|
var delegatorAddress = _a.delegatorAddress, validatorAddress = _a.validatorAddress, amount = _a.amount;
|
|
362
|
-
|
|
358
|
+
utils_1.assertDefinedAndNotNull(amount, "missing amount");
|
|
363
359
|
return {
|
|
364
360
|
delegator_address: delegatorAddress,
|
|
365
361
|
validator_address: validatorAddress,
|
|
@@ -379,7 +375,7 @@ function createDefaultTypes(prefix) {
|
|
|
379
375
|
aminoType: "cosmos-sdk/MsgEditValidator",
|
|
380
376
|
toAmino: function (_a) {
|
|
381
377
|
var description = _a.description, commissionRate = _a.commissionRate, minSelfDelegation = _a.minSelfDelegation, validatorAddress = _a.validatorAddress;
|
|
382
|
-
|
|
378
|
+
utils_1.assertDefinedAndNotNull(description, "missing description");
|
|
383
379
|
return {
|
|
384
380
|
description: {
|
|
385
381
|
moniker: description.moniker,
|
|
@@ -413,7 +409,7 @@ function createDefaultTypes(prefix) {
|
|
|
413
409
|
aminoType: "cosmos-sdk/MsgUndelegate",
|
|
414
410
|
toAmino: function (_a) {
|
|
415
411
|
var delegatorAddress = _a.delegatorAddress, validatorAddress = _a.validatorAddress, amount = _a.amount;
|
|
416
|
-
|
|
412
|
+
utils_1.assertDefinedAndNotNull(amount, "missing amount");
|
|
417
413
|
return {
|
|
418
414
|
delegator_address: delegatorAddress,
|
|
419
415
|
validator_address: validatorAddress,
|