@firmachain/firma-js 0.2.33 → 0.2.36

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.
Files changed (63) hide show
  1. package/dist/index.js +5 -1
  2. package/dist/sdk/FirmaAuthzService.js +5 -5
  3. package/dist/sdk/FirmaBankService.js +1 -1
  4. package/dist/sdk/FirmaContractService.d.ts +1 -0
  5. package/dist/sdk/FirmaContractService.js +31 -8
  6. package/dist/sdk/FirmaCosmWasmService.js +9 -9
  7. package/dist/sdk/FirmaDistributionService.js +5 -5
  8. package/dist/sdk/FirmaFeeGrantService.js +3 -3
  9. package/dist/sdk/FirmaGovService.js +7 -7
  10. package/dist/sdk/FirmaIbcService.js +1 -1
  11. package/dist/sdk/FirmaIpfsService.js +1 -1
  12. package/dist/sdk/FirmaNftService.js +3 -3
  13. package/dist/sdk/FirmaStakingService.js +5 -5
  14. package/dist/sdk/FirmaTokenService.js +4 -4
  15. package/dist/sdk/FirmaUtil.d.ts +4 -2
  16. package/dist/sdk/FirmaUtil.js +19 -14
  17. package/dist/sdk/FirmaWalletService.js +3 -3
  18. package/dist/sdk/firmachain/amino/addresses.js +11 -11
  19. package/dist/sdk/firmachain/amino/aminotypes.js +36 -32
  20. package/dist/sdk/firmachain/amino/encoding.js +30 -26
  21. package/dist/sdk/firmachain/amino/multisig.js +5 -5
  22. package/dist/sdk/firmachain/amino/signature.js +4 -4
  23. package/dist/sdk/firmachain/amino/signdoc.js +1 -1
  24. package/dist/sdk/firmachain/amino/wallet.js +14 -10
  25. package/dist/sdk/firmachain/authz/AuthzQueryClient.js +3 -3
  26. package/dist/sdk/firmachain/authz/index.js +5 -1
  27. package/dist/sdk/firmachain/bank/BankQueryClient.js +4 -4
  28. package/dist/sdk/firmachain/bank/index.js +5 -1
  29. package/dist/sdk/firmachain/common/CommonTxClient.d.ts +7 -0
  30. package/dist/sdk/firmachain/common/CommonTxClient.js +79 -0
  31. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +2 -2
  32. package/dist/sdk/firmachain/common/LedgerWallet.js +14 -10
  33. package/dist/sdk/firmachain/common/accounts.js +2 -2
  34. package/dist/sdk/firmachain/common/index.js +5 -1
  35. package/dist/sdk/firmachain/common/signing.js +9 -5
  36. package/dist/sdk/firmachain/common/signingaminostargateclient.js +16 -16
  37. package/dist/sdk/firmachain/common/signingstargateclient.js +18 -14
  38. package/dist/sdk/firmachain/common/stargateclient.js +6 -6
  39. package/dist/sdk/firmachain/contract/ContractQueryClient.js +2 -2
  40. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +4 -4
  41. package/dist/sdk/firmachain/contract/index.js +5 -1
  42. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +7 -7
  43. package/dist/sdk/firmachain/cosmwasm/index.js +5 -1
  44. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +5 -5
  45. package/dist/sdk/firmachain/distribution/index.js +5 -1
  46. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +2 -2
  47. package/dist/sdk/firmachain/feegrant/index.js +5 -1
  48. package/dist/sdk/firmachain/google/protobuf/any.d.ts +1 -1
  49. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +27 -27
  50. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +1 -1
  51. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +1 -1
  52. package/dist/sdk/firmachain/gov/GovQueryClient.js +2 -2
  53. package/dist/sdk/firmachain/gov/index.js +5 -1
  54. package/dist/sdk/firmachain/ibc/IbcQueryClient.js +1 -1
  55. package/dist/sdk/firmachain/ibc/index.js +5 -1
  56. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +6 -6
  57. package/dist/sdk/firmachain/nft/index.js +5 -1
  58. package/dist/sdk/firmachain/slashing/index.js +5 -1
  59. package/dist/sdk/firmachain/staking/StakingQueryClient.js +8 -8
  60. package/dist/sdk/firmachain/staking/index.js +5 -1
  61. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +8 -8
  62. package/dist/sdk/firmachain/token/index.js +5 -1
  63. package/package.json +1 -1
@@ -64,6 +64,7 @@ var proto_signing_1 = require("@cosmjs/proto-signing");
64
64
  var signingstargateclient_1 = require("./firmachain/common/signingstargateclient");
65
65
  var any_1 = require("./firmachain/google/protobuf/any");
66
66
  var long_1 = __importDefault(require("long"));
67
+ var CommonTxClient_1 = require("./firmachain/common/CommonTxClient");
67
68
  var CryptoJS = require("crypto-js");
68
69
  var sha1 = require("crypto-js/sha1");
69
70
  var sha256 = require("crypto-js/sha256");
@@ -224,12 +225,12 @@ var FirmaUtil = /** @class */ (function () {
224
225
  case 0:
225
226
  _a.trys.push([0, 2, , 3]);
226
227
  encodedTx = Uint8Array.from(tx_1.TxRaw.encode(txRaw).finish());
227
- hexTx = "0x" + Buffer.from(encodedTx).toString("hex");
228
+ hexTx = "0x".concat(Buffer.from(encodedTx).toString("hex"));
228
229
  queryClient = new TendermintQueryClient_1.TendermintQueryClient(FirmaUtil.config.rpcAddress);
229
230
  return [4 /*yield*/, queryClient.queryEstimateGas(hexTx)];
230
231
  case 1:
231
232
  gas = _a.sent();
232
- multiplier = 1.25;
233
+ multiplier = 1.15;
233
234
  return [2 /*return*/, Math.ceil(gas * multiplier)];
234
235
  case 2:
235
236
  error_2 = _a.sent();
@@ -248,7 +249,7 @@ var FirmaUtil = /** @class */ (function () {
248
249
  case 0:
249
250
  _a.trys.push([0, 2, , 3]);
250
251
  encodedTx = Uint8Array.from(txRaw);
251
- hexTx = "0x" + Buffer.from(encodedTx).toString("hex");
252
+ hexTx = "0x".concat(Buffer.from(encodedTx).toString("hex"));
252
253
  console.log("hexTx:" + hexTx);
253
254
  queryClient = new TendermintQueryClient_1.TendermintQueryClient(FirmaUtil.config.rpcAddress);
254
255
  return [4 /*yield*/, queryClient.queryEstimateGas(hexTx)];
@@ -268,7 +269,7 @@ var FirmaUtil = /** @class */ (function () {
268
269
  FirmaUtil.printLog = function (log) {
269
270
  if (FirmaUtil.config.isShowLog === false)
270
271
  return;
271
- console.log("[FirmaSDK] " + log);
272
+ console.log("[FirmaSDK] ".concat(log));
272
273
  };
273
274
  FirmaUtil.experimentalAdr36Sign = function (wallet, data) {
274
275
  return __awaiter(this, void 0, void 0, function () {
@@ -323,7 +324,7 @@ var FirmaUtil = /** @class */ (function () {
323
324
  if (recoveryIndex > 3) {
324
325
  throw new Error('Invalid recovery index');
325
326
  }
326
- sig = crypto_1.Secp256k1Signature.fromFixedLength(encoding_2.fromBase64(signature));
327
+ sig = crypto_1.Secp256k1Signature.fromFixedLength((0, encoding_2.fromBase64)(signature));
327
328
  extendedSig = new crypto_1.ExtendedSecp256k1Signature(sig.r(), sig.s(), recoveryIndex);
328
329
  _b.label = 1;
329
330
  case 1:
@@ -331,9 +332,9 @@ var FirmaUtil = /** @class */ (function () {
331
332
  return [4 /*yield*/, crypto_1.Secp256k1.recoverPubkey(extendedSig, hash)];
332
333
  case 2:
333
334
  recoveredPubKey = _b.sent();
334
- return [2 /*return*/, amino_1.pubkeyToAddress({
335
+ return [2 /*return*/, (0, amino_1.pubkeyToAddress)({
335
336
  type: 'tendermint/PubKeySecp256k1',
336
- value: encoding_2.toBase64(crypto_1.Secp256k1.compressPubkey(recoveredPubKey)),
337
+ value: (0, encoding_2.toBase64)(crypto_1.Secp256k1.compressPubkey(recoveredPubKey)),
337
338
  }, 'firma')];
338
339
  case 3:
339
340
  _a = _b.sent();
@@ -369,39 +370,40 @@ var FirmaUtil = /** @class */ (function () {
369
370
  });
370
371
  };
371
372
  FirmaUtil.verifyDirectSignature = function (address, signature, signDoc) {
372
- var messageHash = crypto_1.sha256(proto_signing_1.makeSignBytes(signDoc));
373
+ var messageHash = (0, crypto_1.sha256)((0, proto_signing_1.makeSignBytes)(signDoc));
373
374
  return this.verifySignature(address, signature, messageHash);
374
375
  };
375
376
  ;
376
377
  FirmaUtil.parseSignDocValues = function (signDocString) {
377
- return __assign(__assign({}, signDocString), { bodyBytes: encoding_2.fromHex(signDocString.bodyBytes), authInfoBytes: encoding_2.fromHex(signDocString.authInfoBytes), accountNumber: new long_1.default(signDocString.accountNumber) });
378
+ return __assign(__assign({}, signDocString), { bodyBytes: (0, encoding_2.fromHex)(signDocString.bodyBytes), authInfoBytes: (0, encoding_2.fromHex)(signDocString.authInfoBytes), accountNumber: new long_1.default(signDocString.accountNumber) });
378
379
  };
379
380
  FirmaUtil.stringifySignDocValues = function (signDoc) {
380
- return __assign(__assign({}, signDoc), { bodyBytes: encoding_2.toHex(signDoc.bodyBytes), authInfoBytes: encoding_2.toHex(signDoc.authInfoBytes), accountNumber: signDoc.accountNumber.toString(16) });
381
+ return __assign(__assign({}, signDoc), { bodyBytes: (0, encoding_2.toHex)(signDoc.bodyBytes), authInfoBytes: (0, encoding_2.toHex)(signDoc.authInfoBytes), accountNumber: signDoc.accountNumber.toString(16) });
381
382
  };
382
- FirmaUtil.makeSignDoc = function (registry, signerAddress, messages, txMisc) {
383
+ FirmaUtil.makeSignDoc = function (signerAddress, messages, txMisc) {
383
384
  if (txMisc === void 0) { txMisc = exports.DefaultTxMisc; }
384
385
  return __awaiter(this, void 0, void 0, function () {
385
- var result, chainID, serverUrl;
386
+ var result, chainID, serverUrl, registry;
386
387
  return __generator(this, function (_a) {
387
388
  switch (_a.label) {
388
389
  case 0:
389
390
  result = FirmaUtil.getSignAndBroadcastOption(FirmaUtil.config.denom, txMisc);
390
391
  chainID = FirmaUtil.config.chainID;
391
392
  serverUrl = FirmaUtil.config.rpcAddress;
393
+ registry = CommonTxClient_1.CommonTxClient.getRegistry();
392
394
  return [4 /*yield*/, signingstargateclient_1.SigningStargateClient.makeSignDocForSend(signerAddress, messages, result.fee, result.memo, serverUrl, chainID, registry)];
393
395
  case 1: return [2 /*return*/, _a.sent()];
394
396
  }
395
397
  });
396
398
  });
397
399
  };
398
- FirmaUtil.makeSignDocWithStringify = function (registry, signerAddress, messages, txMisc) {
400
+ FirmaUtil.makeSignDocWithStringify = function (signerAddress, messages, txMisc) {
399
401
  if (txMisc === void 0) { txMisc = exports.DefaultTxMisc; }
400
402
  return __awaiter(this, void 0, void 0, function () {
401
403
  var signDoc, stringSignDoc;
402
404
  return __generator(this, function (_a) {
403
405
  switch (_a.label) {
404
- case 0: return [4 /*yield*/, this.makeSignDoc(registry, signerAddress, messages, txMisc)];
406
+ case 0: return [4 /*yield*/, this.makeSignDoc(signerAddress, messages, txMisc)];
405
407
  case 1:
406
408
  signDoc = _a.sent();
407
409
  stringSignDoc = this.stringifySignDocValues(signDoc);
@@ -417,6 +419,9 @@ var FirmaUtil = /** @class */ (function () {
417
419
  });
418
420
  return anyData;
419
421
  };
422
+ FirmaUtil.getCommonTxClient = function (aliceWallet) {
423
+ return new CommonTxClient_1.CommonTxClient(aliceWallet, FirmaUtil.config.rpcAddress);
424
+ };
420
425
  FirmaUtil.FctDecimal = 6;
421
426
  return FirmaUtil;
422
427
  }());
@@ -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*/, LedgerWallet_1.signFromLedger(this.ledger, messages, option, registry)];
95
+ case 0: return [4 /*yield*/, (0, LedgerWallet_1.signFromLedger)(this.ledger, messages, option, registry)];
96
96
  case 1: return [2 /*return*/, _a.sent()];
97
97
  }
98
98
  });
@@ -123,7 +123,7 @@ var FirmaWalletService = /** @class */ (function () {
123
123
  };
124
124
  FirmaWalletService.getHdPath = function (hdPath, accountIndex) {
125
125
  try {
126
- return [crypto_1.stringToPath(hdPath + accountIndex + "'/0/0")];
126
+ return [(0, crypto_1.stringToPath)(hdPath + accountIndex + "'/0/0")];
127
127
  }
128
128
  catch (error) {
129
129
  FirmaUtil_1.FirmaUtil.printLog(error);
@@ -169,7 +169,7 @@ var FirmaWalletService = /** @class */ (function () {
169
169
  seed = _a.sent();
170
170
  hdpath = FirmaWalletService.getHdPath(this.getHdPath(), accountIndex);
171
171
  privkey = crypto_1.Slip10.derivePath(crypto_1.Slip10Curve.Secp256k1, seed, hdpath[0]).privkey;
172
- privateKey = "0x" + Buffer.from(privkey).toString("hex");
172
+ privateKey = "0x".concat(Buffer.from(privkey).toString("hex"));
173
173
  return [2 /*return*/, privateKey];
174
174
  case 2:
175
175
  error_3 = _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: " + pubkeyData.length);
11
+ throw new Error("Invalid Ed25519 pubkey length: ".concat(pubkeyData.length));
12
12
  }
13
- return crypto_1.sha256(pubkeyData).slice(0, 20);
13
+ return (0, 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): " + pubkeyData.length);
18
+ throw new Error("Invalid Secp256k1 pubkey length (compressed): ".concat(pubkeyData.length));
19
19
  }
20
- return crypto_1.ripemd160(crypto_1.sha256(pubkeyData));
20
+ return (0, crypto_1.ripemd160)((0, 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 (pubkeys_1.isSecp256k1Pubkey(pubkey)) {
26
- var pubkeyData = encoding_1.fromBase64(pubkey.value);
25
+ if ((0, pubkeys_1.isSecp256k1Pubkey)(pubkey)) {
26
+ var pubkeyData = (0, encoding_1.fromBase64)(pubkey.value);
27
27
  return rawSecp256k1PubkeyToRawAddress(pubkeyData);
28
28
  }
29
- else if (pubkeys_1.isEd25519Pubkey(pubkey)) {
30
- var pubkeyData = encoding_1.fromBase64(pubkey.value);
29
+ else if ((0, pubkeys_1.isEd25519Pubkey)(pubkey)) {
30
+ var pubkeyData = (0, encoding_1.fromBase64)(pubkey.value);
31
31
  return rawEd25519PubkeyToRawAddress(pubkeyData);
32
32
  }
33
- else if (pubkeys_1.isMultisigThresholdPubkey(pubkey)) {
33
+ else if ((0, pubkeys_1.isMultisigThresholdPubkey)(pubkey)) {
34
34
  // https://github.com/tendermint/tendermint/blob/38b401657e4ad7a7eeb3c30a3cbf512037df3740/crypto/multisig/threshold_pubkey.go#L71-L74
35
- var pubkeyData = encoding_2.encodeAminoPubkey(pubkey);
36
- return crypto_1.sha256(pubkeyData).slice(0, 20);
35
+ var pubkeyData = (0, encoding_2.encodeAminoPubkey)(pubkey);
36
+ return (0, crypto_1.sha256)(pubkeyData).slice(0, 20);
37
37
  }
38
38
  else {
39
39
  throw new Error("Unsupported public key type");
@@ -26,10 +26,14 @@ 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
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
31
- to[j] = from[i];
32
- return to;
29
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
30
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31
+ if (ar || !(i in from)) {
32
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33
+ ar[i] = from[i];
34
+ }
35
+ }
36
+ return to.concat(ar || Array.prototype.slice.call(from));
33
37
  };
34
38
  var __importDefault = (this && this.__importDefault) || function (mod) {
35
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -52,7 +56,7 @@ function omitDefault(input) {
52
56
  if (long_1.default.isLong(input)) {
53
57
  return input.isZero() ? undefined : input;
54
58
  }
55
- throw new Error("Got unsupported type '" + typeof input + "'");
59
+ throw new Error("Got unsupported type '".concat(typeof input, "'"));
56
60
  }
57
61
  function createDefaultTypes(prefix) {
58
62
  return {
@@ -64,7 +68,7 @@ function createDefaultTypes(prefix) {
64
68
  return ({
65
69
  from_address: fromAddress,
66
70
  to_address: toAddress,
67
- amount: __spreadArray([], __read(amount)),
71
+ amount: __spreadArray([], __read(amount), false),
68
72
  });
69
73
  },
70
74
  fromAmino: function (_a) {
@@ -72,7 +76,7 @@ function createDefaultTypes(prefix) {
72
76
  return ({
73
77
  fromAddress: from_address,
74
78
  toAddress: to_address,
75
- amount: __spreadArray([], __read(amount)),
79
+ amount: __spreadArray([], __read(amount), false),
76
80
  });
77
81
  },
78
82
  },
@@ -83,11 +87,11 @@ function createDefaultTypes(prefix) {
83
87
  return ({
84
88
  inputs: inputs.map(function (input) { return ({
85
89
  address: input.address,
86
- coins: __spreadArray([], __read(input.coins)),
90
+ coins: __spreadArray([], __read(input.coins), false),
87
91
  }); }),
88
92
  outputs: outputs.map(function (output) { return ({
89
93
  address: output.address,
90
- coins: __spreadArray([], __read(output.coins)),
94
+ coins: __spreadArray([], __read(output.coins), false),
91
95
  }); }),
92
96
  });
93
97
  },
@@ -96,11 +100,11 @@ function createDefaultTypes(prefix) {
96
100
  return ({
97
101
  inputs: inputs.map(function (input) { return ({
98
102
  address: input.address,
99
- coins: __spreadArray([], __read(input.coins)),
103
+ coins: __spreadArray([], __read(input.coins), false),
100
104
  }); }),
101
105
  outputs: outputs.map(function (output) { return ({
102
106
  address: output.address,
103
- coins: __spreadArray([], __read(output.coins)),
107
+ coins: __spreadArray([], __read(output.coins), false),
104
108
  }); }),
105
109
  });
106
110
  },
@@ -111,14 +115,14 @@ function createDefaultTypes(prefix) {
111
115
  toAmino: function (_a) {
112
116
  var amount = _a.amount, depositor = _a.depositor;
113
117
  return ({
114
- amount: __spreadArray([], __read(amount)),
118
+ amount: __spreadArray([], __read(amount), false),
115
119
  depositor: depositor,
116
120
  });
117
121
  },
118
122
  fromAmino: function (_a) {
119
123
  var amount = _a.amount, depositor = _a.depositor;
120
124
  return ({
121
- amount: __spreadArray([], __read(amount)),
125
+ amount: __spreadArray([], __read(amount), false),
122
126
  depositor: depositor,
123
127
  });
124
128
  },
@@ -205,7 +209,7 @@ function createDefaultTypes(prefix) {
205
209
  fromAmino: function (_a) {
206
210
  var option = _a.option, proposal_id = _a.proposal_id, voter = _a.voter;
207
211
  return {
208
- option: gov_1.voteOptionFromJSON(option),
212
+ option: (0, gov_1.voteOptionFromJSON)(option),
209
213
  proposalId: long_1.default.fromString(proposal_id),
210
214
  voter: voter,
211
215
  };
@@ -215,7 +219,7 @@ function createDefaultTypes(prefix) {
215
219
  aminoType: "cosmos-sdk/MsgSubmitProposal",
216
220
  toAmino: function (_a) {
217
221
  var initialDeposit = _a.initialDeposit, proposer = _a.proposer, content = _a.content;
218
- utils_1.assertDefinedAndNotNull(content);
222
+ (0, utils_1.assertDefinedAndNotNull)(content);
219
223
  var proposal;
220
224
  switch (content.typeUrl) {
221
225
  case "/cosmos.gov.v1beta1.TextProposal": {
@@ -230,7 +234,7 @@ function createDefaultTypes(prefix) {
230
234
  break;
231
235
  }
232
236
  default:
233
- throw new Error("Unsupported proposal type: '" + content.typeUrl + "'");
237
+ throw new Error("Unsupported proposal type: '".concat(content.typeUrl, "'"));
234
238
  }
235
239
  return {
236
240
  initial_deposit: initialDeposit,
@@ -244,10 +248,10 @@ function createDefaultTypes(prefix) {
244
248
  switch (content.type) {
245
249
  case "cosmos-sdk/TextProposal": {
246
250
  var value = content.value;
247
- utils_1.assert(utils_1.isNonNullObject(value));
251
+ (0, utils_1.assert)((0, utils_1.isNonNullObject)(value));
248
252
  var _b = value, title = _b.title, description = _b.description;
249
- utils_1.assert(typeof title === "string");
250
- utils_1.assert(typeof description === "string");
253
+ (0, utils_1.assert)(typeof title === "string");
254
+ (0, utils_1.assert)(typeof description === "string");
251
255
  any_content = any_1.Any.fromPartial({
252
256
  typeUrl: "/cosmos.gov.v1beta1.TextProposal",
253
257
  value: gov_1.TextProposal.encode(gov_1.TextProposal.fromPartial({
@@ -258,7 +262,7 @@ function createDefaultTypes(prefix) {
258
262
  break;
259
263
  }
260
264
  default:
261
- throw new Error("Unsupported proposal type: '" + content.type + "'");
265
+ throw new Error("Unsupported proposal type: '".concat(content.type, "'"));
262
266
  }
263
267
  return {
264
268
  initialDeposit: Array.from(initial_deposit),
@@ -272,7 +276,7 @@ function createDefaultTypes(prefix) {
272
276
  aminoType: "cosmos-sdk/MsgBeginRedelegate",
273
277
  toAmino: function (_a) {
274
278
  var delegatorAddress = _a.delegatorAddress, validatorSrcAddress = _a.validatorSrcAddress, validatorDstAddress = _a.validatorDstAddress, amount = _a.amount;
275
- utils_1.assertDefinedAndNotNull(amount, "missing amount");
279
+ (0, utils_1.assertDefinedAndNotNull)(amount, "missing amount");
276
280
  return {
277
281
  delegator_address: delegatorAddress,
278
282
  validator_src_address: validatorSrcAddress,
@@ -294,10 +298,10 @@ function createDefaultTypes(prefix) {
294
298
  aminoType: "cosmos-sdk/MsgCreateValidator",
295
299
  toAmino: function (_a) {
296
300
  var description = _a.description, commission = _a.commission, minSelfDelegation = _a.minSelfDelegation, delegatorAddress = _a.delegatorAddress, validatorAddress = _a.validatorAddress, pubkey = _a.pubkey, value = _a.value;
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");
301
+ (0, utils_1.assertDefinedAndNotNull)(description, "missing description");
302
+ (0, utils_1.assertDefinedAndNotNull)(commission, "missing commission");
303
+ (0, utils_1.assertDefinedAndNotNull)(pubkey, "missing pubkey");
304
+ (0, utils_1.assertDefinedAndNotNull)(value, "missing value");
301
305
  return {
302
306
  description: {
303
307
  moniker: description.moniker,
@@ -314,16 +318,16 @@ function createDefaultTypes(prefix) {
314
318
  min_self_delegation: minSelfDelegation,
315
319
  delegator_address: delegatorAddress,
316
320
  validator_address: validatorAddress,
317
- pubkey: encoding_2.encodeBech32Pubkey({
321
+ pubkey: (0, encoding_2.encodeBech32Pubkey)({
318
322
  type: "tendermint/PubKeySecp256k1",
319
- value: encoding_1.toBase64(pubkey.value),
323
+ value: (0, encoding_1.toBase64)(pubkey.value),
320
324
  }, prefix),
321
325
  value: value,
322
326
  };
323
327
  },
324
328
  fromAmino: function (_a) {
325
329
  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;
326
- var decodedPubkey = encoding_2.decodeBech32Pubkey(pubkey);
330
+ var decodedPubkey = (0, encoding_2.decodeBech32Pubkey)(pubkey);
327
331
  if (decodedPubkey.type !== "tendermint/PubKeySecp256k1") {
328
332
  throw new Error("Only Secp256k1 public keys are supported");
329
333
  }
@@ -345,7 +349,7 @@ function createDefaultTypes(prefix) {
345
349
  validatorAddress: validator_address,
346
350
  pubkey: {
347
351
  typeUrl: "/cosmos.crypto.secp256k1.PubKey",
348
- value: encoding_1.fromBase64(decodedPubkey.value),
352
+ value: (0, encoding_1.fromBase64)(decodedPubkey.value),
349
353
  },
350
354
  value: value,
351
355
  };
@@ -355,7 +359,7 @@ function createDefaultTypes(prefix) {
355
359
  aminoType: "cosmos-sdk/MsgDelegate",
356
360
  toAmino: function (_a) {
357
361
  var delegatorAddress = _a.delegatorAddress, validatorAddress = _a.validatorAddress, amount = _a.amount;
358
- utils_1.assertDefinedAndNotNull(amount, "missing amount");
362
+ (0, utils_1.assertDefinedAndNotNull)(amount, "missing amount");
359
363
  return {
360
364
  delegator_address: delegatorAddress,
361
365
  validator_address: validatorAddress,
@@ -375,7 +379,7 @@ function createDefaultTypes(prefix) {
375
379
  aminoType: "cosmos-sdk/MsgEditValidator",
376
380
  toAmino: function (_a) {
377
381
  var description = _a.description, commissionRate = _a.commissionRate, minSelfDelegation = _a.minSelfDelegation, validatorAddress = _a.validatorAddress;
378
- utils_1.assertDefinedAndNotNull(description, "missing description");
382
+ (0, utils_1.assertDefinedAndNotNull)(description, "missing description");
379
383
  return {
380
384
  description: {
381
385
  moniker: description.moniker,
@@ -409,7 +413,7 @@ function createDefaultTypes(prefix) {
409
413
  aminoType: "cosmos-sdk/MsgUndelegate",
410
414
  toAmino: function (_a) {
411
415
  var delegatorAddress = _a.delegatorAddress, validatorAddress = _a.validatorAddress, amount = _a.amount;
412
- utils_1.assertDefinedAndNotNull(amount, "missing amount");
416
+ (0, utils_1.assertDefinedAndNotNull)(amount, "missing amount");
413
417
  return {
414
418
  delegator_address: delegatorAddress,
415
419
  validator_address: validatorAddress,
@@ -15,10 +15,14 @@ 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
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
20
- to[j] = from[i];
21
- return to;
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
22
26
  };
23
27
  var __values = (this && this.__values) || function(o) {
24
28
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
@@ -43,58 +47,58 @@ function encodeSecp256k1Pubkey(pubkey) {
43
47
  }
44
48
  return {
45
49
  type: pubkeys_1.pubkeyType.secp256k1,
46
- value: encoding_1.toBase64(pubkey),
50
+ value: (0, encoding_1.toBase64)(pubkey),
47
51
  };
48
52
  }
49
53
  exports.encodeSecp256k1Pubkey = encodeSecp256k1Pubkey;
50
54
  // As discussed in https://github.com/binance-chain/javascript-sdk/issues/163
51
55
  // Prefixes listed here: https://github.com/tendermint/tendermint/blob/d419fffe18531317c28c29a292ad7d253f6cafdf/docs/spec/blockchain/encoding.md#public-key-cryptography
52
56
  // Last bytes is varint-encoded length prefix
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 */);
57
+ var pubkeyAminoPrefixSecp256k1 = (0, encoding_1.fromHex)("eb5ae987" + "21" /* fixed length */);
58
+ var pubkeyAminoPrefixEd25519 = (0, encoding_1.fromHex)("1624de64" + "20" /* fixed length */);
59
+ var pubkeyAminoPrefixSr25519 = (0, encoding_1.fromHex)("0dfb1005" + "20" /* fixed length */);
56
60
  /** See https://github.com/tendermint/tendermint/commit/38b401657e4ad7a7eeb3c30a3cbf512037df3740 */
57
- var pubkeyAminoPrefixMultisigThreshold = encoding_1.fromHex("22c1f7e2" /* variable length not included */);
61
+ var pubkeyAminoPrefixMultisigThreshold = (0, encoding_1.fromHex)("22c1f7e2" /* variable length not included */);
58
62
  /**
59
63
  * Decodes a pubkey in the Amino binary format to a type/value object.
60
64
  */
61
65
  function decodeAminoPubkey(data) {
62
- if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixSecp256k1)) {
66
+ if ((0, utils_1.arrayContentStartsWith)(data, pubkeyAminoPrefixSecp256k1)) {
63
67
  var rest = data.slice(pubkeyAminoPrefixSecp256k1.length);
64
68
  if (rest.length !== 33) {
65
69
  throw new Error("Invalid rest data length. Expected 33 bytes (compressed secp256k1 pubkey).");
66
70
  }
67
71
  return {
68
72
  type: pubkeys_1.pubkeyType.secp256k1,
69
- value: encoding_1.toBase64(rest),
73
+ value: (0, encoding_1.toBase64)(rest),
70
74
  };
71
75
  }
72
- else if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixEd25519)) {
76
+ else if ((0, utils_1.arrayContentStartsWith)(data, pubkeyAminoPrefixEd25519)) {
73
77
  var rest = data.slice(pubkeyAminoPrefixEd25519.length);
74
78
  if (rest.length !== 32) {
75
79
  throw new Error("Invalid rest data length. Expected 32 bytes (Ed25519 pubkey).");
76
80
  }
77
81
  return {
78
82
  type: pubkeys_1.pubkeyType.ed25519,
79
- value: encoding_1.toBase64(rest),
83
+ value: (0, encoding_1.toBase64)(rest),
80
84
  };
81
85
  }
82
- else if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixSr25519)) {
86
+ else if ((0, utils_1.arrayContentStartsWith)(data, pubkeyAminoPrefixSr25519)) {
83
87
  var rest = data.slice(pubkeyAminoPrefixSr25519.length);
84
88
  if (rest.length !== 32) {
85
89
  throw new Error("Invalid rest data length. Expected 32 bytes (Sr25519 pubkey).");
86
90
  }
87
91
  return {
88
92
  type: pubkeys_1.pubkeyType.sr25519,
89
- value: encoding_1.toBase64(rest),
93
+ value: (0, encoding_1.toBase64)(rest),
90
94
  };
91
95
  }
92
- else if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixMultisigThreshold)) {
96
+ else if ((0, utils_1.arrayContentStartsWith)(data, pubkeyAminoPrefixMultisigThreshold)) {
93
97
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
94
98
  return decodeMultisigPubkey(data);
95
99
  }
96
100
  else {
97
- throw new Error("Unsupported public key type. Amino data starts with: " + encoding_1.toHex(data.slice(0, 5)));
101
+ throw new Error("Unsupported public key type. Amino data starts with: " + (0, encoding_1.toHex)(data.slice(0, 5)));
98
102
  }
99
103
  }
100
104
  exports.decodeAminoPubkey = decodeAminoPubkey;
@@ -133,7 +137,7 @@ function decodeMultisigPubkey(data) {
133
137
  var reader = Array.from(data);
134
138
  // remove multisig amino prefix;
135
139
  var prefixFromReader = reader.splice(0, pubkeyAminoPrefixMultisigThreshold.length);
136
- if (!utils_1.arrayContentStartsWith(prefixFromReader, pubkeyAminoPrefixMultisigThreshold)) {
140
+ if (!(0, utils_1.arrayContentStartsWith)(prefixFromReader, pubkeyAminoPrefixMultisigThreshold)) {
137
141
  throw new Error("Invalid multisig prefix.");
138
142
  }
139
143
  // remove 0x08 threshold prefix;
@@ -188,18 +192,18 @@ function encodeUvarint(value) {
188
192
  */
189
193
  function encodeAminoPubkey(pubkey) {
190
194
  var e_1, _a;
191
- if (pubkeys_1.isMultisigThresholdPubkey(pubkey)) {
195
+ if ((0, pubkeys_1.isMultisigThresholdPubkey)(pubkey)) {
192
196
  var out = Array.from(pubkeyAminoPrefixMultisigThreshold);
193
197
  out.push(0x08); // TODO: What is this?
194
198
  out.push.apply(// TODO: What is this?
195
- out, __spreadArray([], __read(encodeUvarint(pubkey.value.threshold))));
199
+ out, __spreadArray([], __read(encodeUvarint(pubkey.value.threshold)), false));
196
200
  try {
197
201
  for (var _b = __values(pubkey.value.pubkeys.map(function (p) { return encodeAminoPubkey(p); })), _c = _b.next(); !_c.done; _c = _b.next()) {
198
202
  var pubkeyData = _c.value;
199
203
  out.push(0x12); // TODO: What is this?
200
204
  out.push.apply(// TODO: What is this?
201
- out, __spreadArray([], __read(encodeUvarint(pubkeyData.length))));
202
- out.push.apply(out, __spreadArray([], __read(pubkeyData)));
205
+ out, __spreadArray([], __read(encodeUvarint(pubkeyData.length)), false));
206
+ out.push.apply(out, __spreadArray([], __read(pubkeyData), false));
203
207
  }
204
208
  }
205
209
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -211,11 +215,11 @@ function encodeAminoPubkey(pubkey) {
211
215
  }
212
216
  return new Uint8Array(out);
213
217
  }
214
- else if (pubkeys_1.isEd25519Pubkey(pubkey)) {
215
- return new Uint8Array(__spreadArray(__spreadArray([], __read(pubkeyAminoPrefixEd25519)), __read(encoding_1.fromBase64(pubkey.value))));
218
+ else if ((0, pubkeys_1.isEd25519Pubkey)(pubkey)) {
219
+ return new Uint8Array(__spreadArray(__spreadArray([], __read(pubkeyAminoPrefixEd25519), false), __read((0, encoding_1.fromBase64)(pubkey.value)), false));
216
220
  }
217
- else if (pubkeys_1.isSecp256k1Pubkey(pubkey)) {
218
- return new Uint8Array(__spreadArray(__spreadArray([], __read(pubkeyAminoPrefixSecp256k1)), __read(encoding_1.fromBase64(pubkey.value))));
221
+ else if ((0, pubkeys_1.isSecp256k1Pubkey)(pubkey)) {
222
+ return new Uint8Array(__spreadArray(__spreadArray([], __read(pubkeyAminoPrefixSecp256k1), false), __read((0, encoding_1.fromBase64)(pubkey.value)), false));
219
223
  }
220
224
  else {
221
225
  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 = encoding_1.toHex(a);
16
- var bHex = encoding_1.toHex(b);
15
+ var aHex = (0, encoding_1.toHex)(a);
16
+ var bHex = (0, 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 = " + uintThreshold.toNumber() + " exceeds number of keys n = " + pubkeys.length);
24
+ throw new Error("Threshold k = ".concat(uintThreshold.toNumber(), " exceeds number of keys n = ").concat(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 = addresses_1.pubkeyToRawAddress(lhs);
31
- var addressRhs = addresses_1.pubkeyToRawAddress(rhs);
30
+ var addressLhs = (0, addresses_1.pubkeyToRawAddress)(lhs);
31
+ var addressRhs = (0, 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: encoding_2.encodeSecp256k1Pubkey(pubkey),
20
- signature: encoding_1.toBase64(signature),
19
+ pub_key: (0, encoding_2.encodeSecp256k1Pubkey)(pubkey),
20
+ signature: (0, 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: encoding_1.fromBase64(signature.pub_key.value),
30
- signature: encoding_1.fromBase64(signature.signature),
29
+ pubkey: (0, encoding_1.fromBase64)(signature.pub_key.value),
30
+ signature: (0, 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 encoding_1.toUtf8(sortedJsonStringify(signDoc));
40
+ return (0, encoding_1.toUtf8)(sortedJsonStringify(signDoc));
41
41
  }
42
42
  exports.serializeSignDoc = serializeSignDoc;