@firmachain/firma-js 0.2.46 → 0.2.48
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/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 +3 -1
- package/dist/sdk/FirmaSDK.js +4 -1
- package/dist/sdk/FirmaStakingService.js +5 -5
- 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 +2 -2
- package/dist/sdk/firmachain/staking/StakingQueryClient.js +8 -8
- 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
- package/dist/test/00.wallet.test.d.ts +0 -1
- package/dist/test/00.wallet.test.js +0 -87
- package/dist/test/000./354/227/220/354/226/264/353/223/234/353/236/215_/353/246/254/354/212/244/355/205/214/354/235/264/355/201/254.test.d.ts +0 -1
- package/dist/test/000./354/227/220/354/226/264/353/223/234/353/236/215_/353/246/254/354/212/244/355/205/214/354/235/264/355/201/254.test.js +0 -302
- package/dist/test/000./354/236/254/353/213/250/352/264/200/353/240/250.test.d.ts +0 -1
- package/dist/test/000./354/236/254/353/213/250/352/264/200/353/240/250.test.js +0 -436
- package/dist/test/01.contract_tx.test.d.ts +0 -1
- package/dist/test/01.contract_tx.test.js +0 -146
- package/dist/test/02.contract_query.test.d.ts +0 -1
- package/dist/test/02.contract_query.test.js +0 -219
- package/dist/test/03.contract_scenario.test.d.ts +0 -1
- package/dist/test/03.contract_scenario.test.js +0 -559
- package/dist/test/04.bank_tx.test.d.ts +0 -1
- package/dist/test/04.bank_tx.test.js +0 -124
- package/dist/test/05.bank_query.test.d.ts +0 -1
- package/dist/test/05.bank_query.test.js +0 -164
- package/dist/test/06.feegrant_tx.test.d.ts +0 -1
- package/dist/test/06.feegrant_tx.test.js +0 -173
- package/dist/test/07.feegrant_query.test.d.ts +0 -1
- package/dist/test/07.feegrant_query.test.js +0 -81
- package/dist/test/08.gas_estimate.test.d.ts +0 -1
- package/dist/test/08.gas_estimate.test.js +0 -702
- package/dist/test/09.ipfs.test.d.ts +0 -1
- package/dist/test/09.ipfs.test.js +0 -69
- package/dist/test/10.nft_tx.test.d.ts +0 -1
- package/dist/test/10.nft_tx.test.js +0 -137
- package/dist/test/11.nft_query.test.d.ts +0 -1
- package/dist/test/11.nft_query.test.js +0 -167
- package/dist/test/12.staking_tx.test.d.ts +0 -1
- package/dist/test/12.staking_tx.test.js +0 -213
- package/dist/test/13.staking_query.test.d.ts +0 -1
- package/dist/test/13.staking_query.test.js +0 -206
- package/dist/test/14.distribution_tx.test.d.ts +0 -1
- package/dist/test/14.distribution_tx.test.js +0 -176
- package/dist/test/15.distribution_query.test.d.ts +0 -1
- package/dist/test/15.distribution_query.test.js +0 -216
- package/dist/test/16.gov_tx.test.d.ts +0 -1
- package/dist/test/16.gov_tx.test.js +0 -237
- package/dist/test/17.gov_query.test.d.ts +0 -1
- package/dist/test/17.gov_query.test.js +0 -115
- package/dist/test/18.util.test.d.ts +0 -1
- package/dist/test/18.util.test.js +0 -246
- package/dist/test/19.chain.test.d.ts +0 -1
- package/dist/test/19.chain.test.js +0 -67
- package/dist/test/20.slashing_query.test.d.ts +0 -1
- package/dist/test/20.slashing_query.test.js +0 -82
- package/dist/test/21.token_tx.test.d.ts +0 -1
- package/dist/test/21.token_tx.test.js +0 -154
- package/dist/test/22.token_query.test.d.ts +0 -1
- package/dist/test/22.token_query.test.js +0 -96
- package/dist/test/23.authz_tx.test.d.ts +0 -1
- package/dist/test/23.authz_tx.test.js +0 -468
- package/dist/test/24.authz_query.test.d.ts +0 -1
- package/dist/test/24.authz_query.test.js +0 -140
- package/dist/test/25.cosmwasm_tx.test.d.ts +0 -1
- package/dist/test/25.cosmwasm_tx.test.js +0 -188
- package/dist/test/26.cosmwasm_query.test.d.ts +0 -1
- package/dist/test/26.cosmwasm_query.test.js +0 -167
- package/dist/test/27.arbitary_sign.test.d.ts +0 -1
- package/dist/test/27.arbitary_sign.test.js +0 -164
- package/dist/test/28.ibc_tx.test.d.ts +0 -1
- package/dist/test/28.ibc_tx.test.js +0 -83
- package/dist/test/29.mint_query.copy.d.ts +0 -1
- package/dist/test/29.mint_query.copy.js +0 -54
- package/dist/test/config_test.d.ts +0 -5
- package/dist/test/config_test.js +0 -27
|
@@ -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,
|
|
@@ -15,14 +15,10 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
15
15
|
}
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
19
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
20
|
+
to[j] = from[i];
|
|
21
|
+
return to;
|
|
26
22
|
};
|
|
27
23
|
var __values = (this && this.__values) || function(o) {
|
|
28
24
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
@@ -47,58 +43,58 @@ function encodeSecp256k1Pubkey(pubkey) {
|
|
|
47
43
|
}
|
|
48
44
|
return {
|
|
49
45
|
type: pubkeys_1.pubkeyType.secp256k1,
|
|
50
|
-
value:
|
|
46
|
+
value: encoding_1.toBase64(pubkey),
|
|
51
47
|
};
|
|
52
48
|
}
|
|
53
49
|
exports.encodeSecp256k1Pubkey = encodeSecp256k1Pubkey;
|
|
54
50
|
// As discussed in https://github.com/binance-chain/javascript-sdk/issues/163
|
|
55
51
|
// Prefixes listed here: https://github.com/tendermint/tendermint/blob/d419fffe18531317c28c29a292ad7d253f6cafdf/docs/spec/blockchain/encoding.md#public-key-cryptography
|
|
56
52
|
// Last bytes is varint-encoded length prefix
|
|
57
|
-
var pubkeyAminoPrefixSecp256k1 =
|
|
58
|
-
var pubkeyAminoPrefixEd25519 =
|
|
59
|
-
var pubkeyAminoPrefixSr25519 =
|
|
53
|
+
var pubkeyAminoPrefixSecp256k1 = encoding_1.fromHex("eb5ae987" + "21" /* fixed length */);
|
|
54
|
+
var pubkeyAminoPrefixEd25519 = encoding_1.fromHex("1624de64" + "20" /* fixed length */);
|
|
55
|
+
var pubkeyAminoPrefixSr25519 = encoding_1.fromHex("0dfb1005" + "20" /* fixed length */);
|
|
60
56
|
/** See https://github.com/tendermint/tendermint/commit/38b401657e4ad7a7eeb3c30a3cbf512037df3740 */
|
|
61
|
-
var pubkeyAminoPrefixMultisigThreshold =
|
|
57
|
+
var pubkeyAminoPrefixMultisigThreshold = encoding_1.fromHex("22c1f7e2" /* variable length not included */);
|
|
62
58
|
/**
|
|
63
59
|
* Decodes a pubkey in the Amino binary format to a type/value object.
|
|
64
60
|
*/
|
|
65
61
|
function decodeAminoPubkey(data) {
|
|
66
|
-
if (
|
|
62
|
+
if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixSecp256k1)) {
|
|
67
63
|
var rest = data.slice(pubkeyAminoPrefixSecp256k1.length);
|
|
68
64
|
if (rest.length !== 33) {
|
|
69
65
|
throw new Error("Invalid rest data length. Expected 33 bytes (compressed secp256k1 pubkey).");
|
|
70
66
|
}
|
|
71
67
|
return {
|
|
72
68
|
type: pubkeys_1.pubkeyType.secp256k1,
|
|
73
|
-
value:
|
|
69
|
+
value: encoding_1.toBase64(rest),
|
|
74
70
|
};
|
|
75
71
|
}
|
|
76
|
-
else if (
|
|
72
|
+
else if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixEd25519)) {
|
|
77
73
|
var rest = data.slice(pubkeyAminoPrefixEd25519.length);
|
|
78
74
|
if (rest.length !== 32) {
|
|
79
75
|
throw new Error("Invalid rest data length. Expected 32 bytes (Ed25519 pubkey).");
|
|
80
76
|
}
|
|
81
77
|
return {
|
|
82
78
|
type: pubkeys_1.pubkeyType.ed25519,
|
|
83
|
-
value:
|
|
79
|
+
value: encoding_1.toBase64(rest),
|
|
84
80
|
};
|
|
85
81
|
}
|
|
86
|
-
else if (
|
|
82
|
+
else if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixSr25519)) {
|
|
87
83
|
var rest = data.slice(pubkeyAminoPrefixSr25519.length);
|
|
88
84
|
if (rest.length !== 32) {
|
|
89
85
|
throw new Error("Invalid rest data length. Expected 32 bytes (Sr25519 pubkey).");
|
|
90
86
|
}
|
|
91
87
|
return {
|
|
92
88
|
type: pubkeys_1.pubkeyType.sr25519,
|
|
93
|
-
value:
|
|
89
|
+
value: encoding_1.toBase64(rest),
|
|
94
90
|
};
|
|
95
91
|
}
|
|
96
|
-
else if (
|
|
92
|
+
else if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixMultisigThreshold)) {
|
|
97
93
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
98
94
|
return decodeMultisigPubkey(data);
|
|
99
95
|
}
|
|
100
96
|
else {
|
|
101
|
-
throw new Error("Unsupported public key type. Amino data starts with: " +
|
|
97
|
+
throw new Error("Unsupported public key type. Amino data starts with: " + encoding_1.toHex(data.slice(0, 5)));
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
exports.decodeAminoPubkey = decodeAminoPubkey;
|
|
@@ -137,7 +133,7 @@ function decodeMultisigPubkey(data) {
|
|
|
137
133
|
var reader = Array.from(data);
|
|
138
134
|
// remove multisig amino prefix;
|
|
139
135
|
var prefixFromReader = reader.splice(0, pubkeyAminoPrefixMultisigThreshold.length);
|
|
140
|
-
if (!
|
|
136
|
+
if (!utils_1.arrayContentStartsWith(prefixFromReader, pubkeyAminoPrefixMultisigThreshold)) {
|
|
141
137
|
throw new Error("Invalid multisig prefix.");
|
|
142
138
|
}
|
|
143
139
|
// remove 0x08 threshold prefix;
|
|
@@ -192,18 +188,18 @@ function encodeUvarint(value) {
|
|
|
192
188
|
*/
|
|
193
189
|
function encodeAminoPubkey(pubkey) {
|
|
194
190
|
var e_1, _a;
|
|
195
|
-
if (
|
|
191
|
+
if (pubkeys_1.isMultisigThresholdPubkey(pubkey)) {
|
|
196
192
|
var out = Array.from(pubkeyAminoPrefixMultisigThreshold);
|
|
197
193
|
out.push(0x08); // TODO: What is this?
|
|
198
194
|
out.push.apply(// TODO: What is this?
|
|
199
|
-
out, __spreadArray([], __read(encodeUvarint(pubkey.value.threshold))
|
|
195
|
+
out, __spreadArray([], __read(encodeUvarint(pubkey.value.threshold))));
|
|
200
196
|
try {
|
|
201
197
|
for (var _b = __values(pubkey.value.pubkeys.map(function (p) { return encodeAminoPubkey(p); })), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
202
198
|
var pubkeyData = _c.value;
|
|
203
199
|
out.push(0x12); // TODO: What is this?
|
|
204
200
|
out.push.apply(// TODO: What is this?
|
|
205
|
-
out, __spreadArray([], __read(encodeUvarint(pubkeyData.length))
|
|
206
|
-
out.push.apply(out, __spreadArray([], __read(pubkeyData)
|
|
201
|
+
out, __spreadArray([], __read(encodeUvarint(pubkeyData.length))));
|
|
202
|
+
out.push.apply(out, __spreadArray([], __read(pubkeyData)));
|
|
207
203
|
}
|
|
208
204
|
}
|
|
209
205
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -215,11 +211,11 @@ function encodeAminoPubkey(pubkey) {
|
|
|
215
211
|
}
|
|
216
212
|
return new Uint8Array(out);
|
|
217
213
|
}
|
|
218
|
-
else if (
|
|
219
|
-
return new Uint8Array(__spreadArray(__spreadArray([], __read(pubkeyAminoPrefixEd25519)
|
|
214
|
+
else if (pubkeys_1.isEd25519Pubkey(pubkey)) {
|
|
215
|
+
return new Uint8Array(__spreadArray(__spreadArray([], __read(pubkeyAminoPrefixEd25519)), __read(encoding_1.fromBase64(pubkey.value))));
|
|
220
216
|
}
|
|
221
|
-
else if (
|
|
222
|
-
return new Uint8Array(__spreadArray(__spreadArray([], __read(pubkeyAminoPrefixSecp256k1)
|
|
217
|
+
else if (pubkeys_1.isSecp256k1Pubkey(pubkey)) {
|
|
218
|
+
return new Uint8Array(__spreadArray(__spreadArray([], __read(pubkeyAminoPrefixSecp256k1)), __read(encoding_1.fromBase64(pubkey.value))));
|
|
223
219
|
}
|
|
224
220
|
else {
|
|
225
221
|
throw new Error("Unsupported pubkey type");
|
|
@@ -12,8 +12,8 @@ var addresses_1 = require("./addresses");
|
|
|
12
12
|
* Returns 0 if `a === b`.
|
|
13
13
|
*/
|
|
14
14
|
function compareArrays(a, b) {
|
|
15
|
-
var aHex =
|
|
16
|
-
var bHex =
|
|
15
|
+
var aHex = encoding_1.toHex(a);
|
|
16
|
+
var bHex = encoding_1.toHex(b);
|
|
17
17
|
return aHex === bHex ? 0 : aHex < bHex ? -1 : 1;
|
|
18
18
|
}
|
|
19
19
|
exports.compareArrays = compareArrays;
|
|
@@ -21,14 +21,14 @@ function createMultisigThresholdPubkey(pubkeys, threshold, nosort) {
|
|
|
21
21
|
if (nosort === void 0) { nosort = false; }
|
|
22
22
|
var uintThreshold = new math_1.Uint53(threshold);
|
|
23
23
|
if (uintThreshold.toNumber() > pubkeys.length) {
|
|
24
|
-
throw new Error("Threshold k = "
|
|
24
|
+
throw new Error("Threshold k = " + uintThreshold.toNumber() + " exceeds number of keys n = " + pubkeys.length);
|
|
25
25
|
}
|
|
26
26
|
var outPubkeys = nosort
|
|
27
27
|
? pubkeys
|
|
28
28
|
: Array.from(pubkeys).sort(function (lhs, rhs) {
|
|
29
29
|
// https://github.com/cosmos/cosmos-sdk/blob/v0.42.2/client/keys/add.go#L172-L174
|
|
30
|
-
var addressLhs =
|
|
31
|
-
var addressRhs =
|
|
30
|
+
var addressLhs = addresses_1.pubkeyToRawAddress(lhs);
|
|
31
|
+
var addressRhs = addresses_1.pubkeyToRawAddress(rhs);
|
|
32
32
|
return compareArrays(addressLhs, addressRhs);
|
|
33
33
|
});
|
|
34
34
|
return {
|
|
@@ -16,8 +16,8 @@ function encodeSecp256k1Signature(pubkey, signature) {
|
|
|
16
16
|
throw new Error("Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.");
|
|
17
17
|
}
|
|
18
18
|
return {
|
|
19
|
-
pub_key:
|
|
20
|
-
signature:
|
|
19
|
+
pub_key: encoding_2.encodeSecp256k1Pubkey(pubkey),
|
|
20
|
+
signature: encoding_1.toBase64(signature),
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
exports.encodeSecp256k1Signature = encodeSecp256k1Signature;
|
|
@@ -26,8 +26,8 @@ function decodeSignature(signature) {
|
|
|
26
26
|
// Note: please don't add cases here without writing additional unit tests
|
|
27
27
|
case pubkeys_1.pubkeyType.secp256k1:
|
|
28
28
|
return {
|
|
29
|
-
pubkey:
|
|
30
|
-
signature:
|
|
29
|
+
pubkey: encoding_1.fromBase64(signature.pub_key.value),
|
|
30
|
+
signature: encoding_1.fromBase64(signature.signature),
|
|
31
31
|
};
|
|
32
32
|
default:
|
|
33
33
|
throw new Error("Unsupported pubkey type");
|
|
@@ -37,6 +37,6 @@ function makeSignDoc(msgs, fee, chainId, memo, accountNumber, sequence) {
|
|
|
37
37
|
}
|
|
38
38
|
exports.makeSignDoc = makeSignDoc;
|
|
39
39
|
function serializeSignDoc(signDoc) {
|
|
40
|
-
return
|
|
40
|
+
return encoding_1.toUtf8(sortedJsonStringify(signDoc));
|
|
41
41
|
}
|
|
42
42
|
exports.serializeSignDoc = serializeSignDoc;
|
|
@@ -51,14 +51,10 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
51
51
|
}
|
|
52
52
|
return ar;
|
|
53
53
|
};
|
|
54
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
ar[i] = from[i];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
54
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
55
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
56
|
+
to[j] = from[i];
|
|
57
|
+
return to;
|
|
62
58
|
};
|
|
63
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
60
|
exports.decrypt = exports.encrypt = exports.supportedAlgorithms = exports.executeKdf = exports.cosmjsSalt = void 0;
|
|
@@ -69,7 +65,7 @@ var encoding_1 = require("@cosmjs/encoding");
|
|
|
69
65
|
* This reduces the scope of a potential rainbow attack to all CosmJS users.
|
|
70
66
|
* Must be 16 bytes due to implementation limitations.
|
|
71
67
|
*/
|
|
72
|
-
exports.cosmjsSalt =
|
|
68
|
+
exports.cosmjsSalt = encoding_1.toAscii("The CosmJS salt.");
|
|
73
69
|
function executeKdf(password, configuration) {
|
|
74
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
75
71
|
var options;
|
|
@@ -77,7 +73,7 @@ function executeKdf(password, configuration) {
|
|
|
77
73
|
switch (configuration.algorithm) {
|
|
78
74
|
case "argon2id": {
|
|
79
75
|
options = configuration.params;
|
|
80
|
-
if (!
|
|
76
|
+
if (!crypto_1.isArgon2idOptions(options))
|
|
81
77
|
throw new Error("Invalid format of argon2id params");
|
|
82
78
|
return [2 /*return*/, crypto_1.Argon2id.execute(password, exports.cosmjsSalt, options)];
|
|
83
79
|
}
|
|
@@ -106,12 +102,12 @@ function encrypt(plaintext, encryptionKey, config) {
|
|
|
106
102
|
case 1:
|
|
107
103
|
nonce = crypto_1.Random.getBytes(crypto_1.xchacha20NonceLength);
|
|
108
104
|
_b = Uint8Array.bind;
|
|
109
|
-
_c = [__spreadArray([], __read(nonce)
|
|
105
|
+
_c = [__spreadArray([], __read(nonce))];
|
|
110
106
|
return [4 /*yield*/, crypto_1.Xchacha20poly1305Ietf.encrypt(plaintext, encryptionKey, nonce)];
|
|
111
107
|
case 2:
|
|
112
108
|
// Prepend fixed-length nonce to ciphertext as suggested in the example from https://github.com/jedisct1/libsodium.js#api
|
|
113
|
-
return [2 /*return*/, new (_b.apply(Uint8Array, [void 0, __spreadArray.apply(void 0, _c.concat([__read.apply(void 0, [(_d.sent())])
|
|
114
|
-
case 3: throw new Error("Unsupported encryption algorithm: '"
|
|
109
|
+
return [2 /*return*/, new (_b.apply(Uint8Array, [void 0, __spreadArray.apply(void 0, _c.concat([__read.apply(void 0, [(_d.sent())])]))]))()];
|
|
110
|
+
case 3: throw new Error("Unsupported encryption algorithm: '" + config.algorithm + "'");
|
|
115
111
|
}
|
|
116
112
|
});
|
|
117
113
|
});
|
|
@@ -127,7 +123,7 @@ function decrypt(ciphertext, encryptionKey, config) {
|
|
|
127
123
|
return [2 /*return*/, crypto_1.Xchacha20poly1305Ietf.decrypt(ciphertext.slice(crypto_1.xchacha20NonceLength), encryptionKey, nonce)];
|
|
128
124
|
}
|
|
129
125
|
default:
|
|
130
|
-
throw new Error("Unsupported encryption algorithm: '"
|
|
126
|
+
throw new Error("Unsupported encryption algorithm: '" + config.algorithm + "'");
|
|
131
127
|
}
|
|
132
128
|
return [2 /*return*/];
|
|
133
129
|
});
|
|
@@ -60,7 +60,7 @@ var AuthzQueryClient = /** @class */ (function () {
|
|
|
60
60
|
switch (_a.label) {
|
|
61
61
|
case 0:
|
|
62
62
|
msgType = "/cosmos.bank.v1beta1.MsgSend";
|
|
63
|
-
path = "/cosmos/authz/v1beta1/grants?granter="
|
|
63
|
+
path = "/cosmos/authz/v1beta1/grants?granter=" + granterAddress + "&grantee=" + granteeAddress + "&msg_type_url=" + msgType;
|
|
64
64
|
return [4 /*yield*/, this.axios.get(path, { params: { "pagination.key": paginationKey } })];
|
|
65
65
|
case 1:
|
|
66
66
|
result = _a.sent();
|
|
@@ -84,7 +84,7 @@ var AuthzQueryClient = /** @class */ (function () {
|
|
|
84
84
|
return __generator(this, function (_a) {
|
|
85
85
|
switch (_a.label) {
|
|
86
86
|
case 0:
|
|
87
|
-
path = "/cosmos/authz/v1beta1/grants?granter="
|
|
87
|
+
path = "/cosmos/authz/v1beta1/grants?granter=" + granterAddress + "&grantee=" + granteeAddress + "&msg_type_url=" + msgType;
|
|
88
88
|
return [4 /*yield*/, this.axios.get(path, { params: { "pagination.key": paginationKey } })];
|
|
89
89
|
case 1:
|
|
90
90
|
result = _a.sent();
|
|
@@ -120,7 +120,7 @@ var AuthzQueryClient = /** @class */ (function () {
|
|
|
120
120
|
msgType = "/cosmos.staking.v1beta1.MsgBeginRedelegate";
|
|
121
121
|
break;
|
|
122
122
|
}
|
|
123
|
-
path = "/cosmos/authz/v1beta1/grants?granter="
|
|
123
|
+
path = "/cosmos/authz/v1beta1/grants?granter=" + granterAddress + "&grantee=" + granteeAddress + "&msg_type_url=" + msgType;
|
|
124
124
|
return [4 /*yield*/, this.axios.get(path, { params: { "pagination.key": paginationKey } })];
|
|
125
125
|
case 1:
|
|
126
126
|
result = _a.sent();
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -57,7 +57,7 @@ var BankQueryClient = /** @class */ (function () {
|
|
|
57
57
|
return __generator(this, function (_a) {
|
|
58
58
|
switch (_a.label) {
|
|
59
59
|
case 0:
|
|
60
|
-
path = "/cosmos/bank/v1beta1/supply/"
|
|
60
|
+
path = "/cosmos/bank/v1beta1/supply/" + denom;
|
|
61
61
|
return [4 /*yield*/, this.axios.get(path)];
|
|
62
62
|
case 1:
|
|
63
63
|
result = _a.sent();
|
|
@@ -72,7 +72,7 @@ var BankQueryClient = /** @class */ (function () {
|
|
|
72
72
|
return __generator(this, function (_a) {
|
|
73
73
|
switch (_a.label) {
|
|
74
74
|
case 0:
|
|
75
|
-
path = "/cosmos/bank/v1beta1/balances/"
|
|
75
|
+
path = "/cosmos/bank/v1beta1/balances/" + address + "/by_denom?denom=" + denom;
|
|
76
76
|
return [4 /*yield*/, this.axios.get(path)];
|
|
77
77
|
case 1:
|
|
78
78
|
result = _a.sent();
|
|
@@ -87,7 +87,7 @@ var BankQueryClient = /** @class */ (function () {
|
|
|
87
87
|
return __generator(this, function (_a) {
|
|
88
88
|
switch (_a.label) {
|
|
89
89
|
case 0:
|
|
90
|
-
path = "/cosmos/bank/v1beta1/balances/"
|
|
90
|
+
path = "/cosmos/bank/v1beta1/balances/" + address;
|
|
91
91
|
return [4 /*yield*/, this.axios.get(path)];
|
|
92
92
|
case 1:
|
|
93
93
|
result = _a.sent();
|
|
@@ -102,7 +102,7 @@ var BankQueryClient = /** @class */ (function () {
|
|
|
102
102
|
return __generator(this, function (_a) {
|
|
103
103
|
switch (_a.label) {
|
|
104
104
|
case 0:
|
|
105
|
-
path = "/cosmos/bank/v1beta1/balances/"
|
|
105
|
+
path = "/cosmos/bank/v1beta1/balances/" + address + "/by_denom?denom=" + denom;
|
|
106
106
|
return [4 /*yield*/, this.axios.get(path)];
|
|
107
107
|
case 1:
|
|
108
108
|
result = _a.sent();
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -135,7 +135,7 @@ var LedgerSigningStargateClient = /** @class */ (function (_super) {
|
|
|
135
135
|
case 0:
|
|
136
136
|
_a.trys.push([0, 2, , 3]);
|
|
137
137
|
accAddress = this.toAccAddress(address);
|
|
138
|
-
hexAccAddress = "0x01"
|
|
138
|
+
hexAccAddress = "0x01" + Buffer.from(accAddress).toString("hex");
|
|
139
139
|
axios = axios_1.default.create({
|
|
140
140
|
baseURL: LedgerSigningStargateClient._endpoint,
|
|
141
141
|
headers: {
|
|
@@ -149,7 +149,7 @@ var LedgerSigningStargateClient = /** @class */ (function (_super) {
|
|
|
149
149
|
result = _a.sent();
|
|
150
150
|
finalData = result.data.result.response.value;
|
|
151
151
|
account = any_1.Any.decode(Buffer.from(finalData, "base64"));
|
|
152
|
-
finalAccount =
|
|
152
|
+
finalAccount = accounts_1.accountFromAny(account);
|
|
153
153
|
return [2 /*return*/, finalAccount];
|
|
154
154
|
case 2:
|
|
155
155
|
error_1 = _a.sent();
|