@firmachain/firma-js 0.2.32 → 0.2.35

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 (87) hide show
  1. package/dist/index.js +5 -1
  2. package/dist/sdk/FirmaAuthzService.js +20 -20
  3. package/dist/sdk/FirmaBankService.js +2 -2
  4. package/dist/sdk/FirmaContractService.js +14 -16
  5. package/dist/sdk/FirmaCosmWasmService.js +27 -29
  6. package/dist/sdk/FirmaDistributionService.js +10 -10
  7. package/dist/sdk/FirmaFeeGrantService.js +6 -6
  8. package/dist/sdk/FirmaGovService.js +26 -26
  9. package/dist/sdk/FirmaIbcService.js +4 -4
  10. package/dist/sdk/FirmaIpfsService.js +1 -1
  11. package/dist/sdk/FirmaNftService.js +9 -9
  12. package/dist/sdk/FirmaStakingService.js +10 -10
  13. package/dist/sdk/FirmaTokenService.js +16 -16
  14. package/dist/sdk/FirmaUtil.d.ts +13 -1
  15. package/dist/sdk/FirmaUtil.js +145 -14
  16. package/dist/sdk/FirmaWalletService.js +3 -3
  17. package/dist/sdk/firmachain/amino/addresses.js +11 -11
  18. package/dist/sdk/firmachain/amino/aminotypes.js +36 -32
  19. package/dist/sdk/firmachain/amino/encoding.js +30 -26
  20. package/dist/sdk/firmachain/amino/multisig.js +5 -5
  21. package/dist/sdk/firmachain/amino/signature.js +4 -4
  22. package/dist/sdk/firmachain/amino/signdoc.js +1 -1
  23. package/dist/sdk/firmachain/amino/wallet.js +14 -10
  24. package/dist/sdk/firmachain/authz/AuthzQueryClient.js +3 -3
  25. package/dist/sdk/firmachain/authz/AuthzTxClient.d.ts +5 -4
  26. package/dist/sdk/firmachain/authz/AuthzTxClient.js +6 -3
  27. package/dist/sdk/firmachain/authz/index.js +5 -1
  28. package/dist/sdk/firmachain/bank/BankQueryClient.js +4 -4
  29. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +4 -3
  30. package/dist/sdk/firmachain/bank/BankTxClient.js +5 -2
  31. package/dist/sdk/firmachain/bank/index.js +5 -1
  32. package/dist/sdk/firmachain/common/CommonTxClient.d.ts +7 -0
  33. package/dist/sdk/firmachain/common/CommonTxClient.js +79 -0
  34. package/dist/sdk/firmachain/common/ITxClient.d.ts +3 -3
  35. package/dist/sdk/firmachain/common/ITxClient.js +14 -8
  36. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +2 -2
  37. package/dist/sdk/firmachain/common/LedgerWallet.js +14 -10
  38. package/dist/sdk/firmachain/common/accounts.js +2 -2
  39. package/dist/sdk/firmachain/common/index.js +5 -1
  40. package/dist/sdk/firmachain/common/signing.js +9 -5
  41. package/dist/sdk/firmachain/common/signingaminostargateclient.js +16 -16
  42. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +15 -8
  43. package/dist/sdk/firmachain/common/signingstargateclient.js +82 -19
  44. package/dist/sdk/firmachain/common/stargateclient.js +6 -6
  45. package/dist/sdk/firmachain/contract/ContractQueryClient.js +2 -2
  46. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +4 -3
  47. package/dist/sdk/firmachain/contract/ContractTxClient.js +5 -2
  48. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +4 -4
  49. package/dist/sdk/firmachain/contract/index.js +5 -1
  50. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +7 -7
  51. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.d.ts +8 -7
  52. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.js +9 -6
  53. package/dist/sdk/firmachain/cosmwasm/index.js +5 -1
  54. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +5 -5
  55. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +6 -5
  56. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +7 -4
  57. package/dist/sdk/firmachain/distribution/index.js +5 -1
  58. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +2 -2
  59. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +4 -3
  60. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +5 -2
  61. package/dist/sdk/firmachain/feegrant/index.js +5 -1
  62. package/dist/sdk/firmachain/google/protobuf/any.d.ts +1 -1
  63. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +27 -27
  64. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +1 -1
  65. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +1 -1
  66. package/dist/sdk/firmachain/gov/GovQueryClient.js +2 -2
  67. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +5 -4
  68. package/dist/sdk/firmachain/gov/GovTxClient.js +6 -3
  69. package/dist/sdk/firmachain/gov/index.js +5 -1
  70. package/dist/sdk/firmachain/ibc/IbcQueryClient.js +1 -1
  71. package/dist/sdk/firmachain/ibc/IbcTxClient.d.ts +3 -2
  72. package/dist/sdk/firmachain/ibc/IbcTxClient.js +4 -1
  73. package/dist/sdk/firmachain/ibc/index.js +5 -1
  74. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +5 -4
  75. package/dist/sdk/firmachain/nft/NftTxClient.js +6 -3
  76. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +6 -6
  77. package/dist/sdk/firmachain/nft/index.js +5 -1
  78. package/dist/sdk/firmachain/slashing/index.js +5 -1
  79. package/dist/sdk/firmachain/staking/StakingQueryClient.js +8 -8
  80. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +7 -6
  81. package/dist/sdk/firmachain/staking/StakingTxClient.js +8 -5
  82. package/dist/sdk/firmachain/staking/index.js +5 -1
  83. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +6 -5
  84. package/dist/sdk/firmachain/token/TokenTxClient.js +7 -4
  85. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +8 -8
  86. package/dist/sdk/firmachain/token/index.js +5 -1
  87. package/package.json +2 -4
@@ -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;
@@ -51,10 +51,14 @@ 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
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
56
- to[j] = from[i];
57
- return to;
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
57
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
+ ar[i] = from[i];
59
+ }
60
+ }
61
+ return to.concat(ar || Array.prototype.slice.call(from));
58
62
  };
59
63
  Object.defineProperty(exports, "__esModule", { value: true });
60
64
  exports.decrypt = exports.encrypt = exports.supportedAlgorithms = exports.executeKdf = exports.cosmjsSalt = void 0;
@@ -65,7 +69,7 @@ var encoding_1 = require("@cosmjs/encoding");
65
69
  * This reduces the scope of a potential rainbow attack to all CosmJS users.
66
70
  * Must be 16 bytes due to implementation limitations.
67
71
  */
68
- exports.cosmjsSalt = encoding_1.toAscii("The CosmJS salt.");
72
+ exports.cosmjsSalt = (0, encoding_1.toAscii)("The CosmJS salt.");
69
73
  function executeKdf(password, configuration) {
70
74
  return __awaiter(this, void 0, void 0, function () {
71
75
  var options;
@@ -73,7 +77,7 @@ function executeKdf(password, configuration) {
73
77
  switch (configuration.algorithm) {
74
78
  case "argon2id": {
75
79
  options = configuration.params;
76
- if (!crypto_1.isArgon2idOptions(options))
80
+ if (!(0, crypto_1.isArgon2idOptions)(options))
77
81
  throw new Error("Invalid format of argon2id params");
78
82
  return [2 /*return*/, crypto_1.Argon2id.execute(password, exports.cosmjsSalt, options)];
79
83
  }
@@ -102,12 +106,12 @@ function encrypt(plaintext, encryptionKey, config) {
102
106
  case 1:
103
107
  nonce = crypto_1.Random.getBytes(crypto_1.xchacha20NonceLength);
104
108
  _b = Uint8Array.bind;
105
- _c = [__spreadArray([], __read(nonce))];
109
+ _c = [__spreadArray([], __read(nonce), false)];
106
110
  return [4 /*yield*/, crypto_1.Xchacha20poly1305Ietf.encrypt(plaintext, encryptionKey, nonce)];
107
111
  case 2:
108
112
  // Prepend fixed-length nonce to ciphertext as suggested in the example from https://github.com/jedisct1/libsodium.js#api
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 + "'");
113
+ return [2 /*return*/, new (_b.apply(Uint8Array, [void 0, __spreadArray.apply(void 0, _c.concat([__read.apply(void 0, [(_d.sent())]), false]))]))()];
114
+ case 3: throw new Error("Unsupported encryption algorithm: '".concat(config.algorithm, "'"));
111
115
  }
112
116
  });
113
117
  });
@@ -123,7 +127,7 @@ function decrypt(ciphertext, encryptionKey, config) {
123
127
  return [2 /*return*/, crypto_1.Xchacha20poly1305Ietf.decrypt(ciphertext.slice(crypto_1.xchacha20NonceLength), encryptionKey, nonce)];
124
128
  }
125
129
  default:
126
- throw new Error("Unsupported encryption algorithm: '" + config.algorithm + "'");
130
+ throw new Error("Unsupported encryption algorithm: '".concat(config.algorithm, "'"));
127
131
  }
128
132
  return [2 /*return*/];
129
133
  });
@@ -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=" + granterAddress + "&grantee=" + granteeAddress + "&msg_type_url=" + msgType;
63
+ path = "/cosmos/authz/v1beta1/grants?granter=".concat(granterAddress, "&grantee=").concat(granteeAddress, "&msg_type_url=").concat(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=" + granterAddress + "&grantee=" + granteeAddress + "&msg_type_url=" + msgType;
87
+ path = "/cosmos/authz/v1beta1/grants?granter=".concat(granterAddress, "&grantee=").concat(granteeAddress, "&msg_type_url=").concat(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=" + granterAddress + "&grantee=" + granteeAddress + "&msg_type_url=" + msgType;
123
+ path = "/cosmos/authz/v1beta1/grants?granter=".concat(granterAddress, "&grantee=").concat(granteeAddress, "&msg_type_url=").concat(msgType);
124
124
  return [4 /*yield*/, this.axios.get(path, { params: { "pagination.key": paginationKey } })];
125
125
  case 1:
126
126
  result = _a.sent();
@@ -1,4 +1,4 @@
1
- import { EncodeObject } from "@cosmjs/proto-signing";
1
+ import { Registry, EncodeObject } from "@cosmjs/proto-signing";
2
2
  import { MsgExec, MsgGrant, MsgRevoke } from "./AuthzTxTypes";
3
3
  import { ITxClient } from "../common/ITxClient";
4
4
  import { FirmaWalletService } from "../../FirmaWalletService";
@@ -16,7 +16,8 @@ export interface MsgRevokeAllowanceEncodeObject extends EncodeObject {
16
16
  }
17
17
  export declare class AuthzTxClient extends ITxClient {
18
18
  constructor(wallet: FirmaWalletService, serverUrl: string);
19
- msgExecAllowance(data: MsgExec): MsgExecAllowanceEncodeObject;
20
- msgGrantAllowance(data: MsgGrant): MsgGrantAllowanceEncodeObject;
21
- msgRevokeAllowance(data: MsgRevoke): MsgRevokeAllowanceEncodeObject;
19
+ static getRegistry(): Registry;
20
+ static msgExecAllowance(data: MsgExec): MsgExecAllowanceEncodeObject;
21
+ static msgGrantAllowance(data: MsgGrant): MsgGrantAllowanceEncodeObject;
22
+ static msgRevokeAllowance(data: MsgRevoke): MsgRevokeAllowanceEncodeObject;
22
23
  }
@@ -30,13 +30,16 @@ var AuthzTxClient = /** @class */ (function (_super) {
30
30
  function AuthzTxClient(wallet, serverUrl) {
31
31
  return _super.call(this, wallet, serverUrl, registry) || this;
32
32
  }
33
- AuthzTxClient.prototype.msgExecAllowance = function (data) {
33
+ AuthzTxClient.getRegistry = function () {
34
+ return registry;
35
+ };
36
+ AuthzTxClient.msgExecAllowance = function (data) {
34
37
  return { typeUrl: "/cosmos.authz.v1beta1.MsgExec", value: data };
35
38
  };
36
- AuthzTxClient.prototype.msgGrantAllowance = function (data) {
39
+ AuthzTxClient.msgGrantAllowance = function (data) {
37
40
  return { typeUrl: "/cosmos.authz.v1beta1.MsgGrant", value: data };
38
41
  };
39
- AuthzTxClient.prototype.msgRevokeAllowance = function (data) {
42
+ AuthzTxClient.msgRevokeAllowance = function (data) {
40
43
  return { typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", value: data };
41
44
  };
42
45
  return AuthzTxClient;
@@ -1,7 +1,11 @@
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
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  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/" + denom;
60
+ path = "/cosmos/bank/v1beta1/supply/".concat(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/" + address + "/by_denom?denom=" + denom;
75
+ path = "/cosmos/bank/v1beta1/balances/".concat(address, "/by_denom?denom=").concat(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/" + address;
90
+ path = "/cosmos/bank/v1beta1/balances/".concat(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/" + address + "/by_denom?denom=" + denom;
105
+ path = "/cosmos/bank/v1beta1/balances/".concat(address, "/by_denom?denom=").concat(denom);
106
106
  return [4 /*yield*/, this.axios.get(path)];
107
107
  case 1:
108
108
  result = _a.sent();
@@ -1,4 +1,4 @@
1
- import { EncodeObject } from "@cosmjs/proto-signing";
1
+ import { Registry, EncodeObject } from "@cosmjs/proto-signing";
2
2
  import { MsgSend, MsgMultiSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
3
3
  import { FirmaWalletService } from "../../FirmaWalletService";
4
4
  import { ITxClient } from "../common/ITxClient";
@@ -12,6 +12,7 @@ export interface MsgMultiSendEncodeObject extends EncodeObject {
12
12
  }
13
13
  export declare class BankTxClient extends ITxClient {
14
14
  constructor(wallet: FirmaWalletService, address: string);
15
- msgSend(data: MsgSend): MsgSendEncodeObject;
16
- msgMultiSend(data: MsgMultiSend): MsgMultiSendEncodeObject;
15
+ static getRegistry(): Registry;
16
+ static msgSend(data: MsgSend): MsgSendEncodeObject;
17
+ static msgMultiSend(data: MsgMultiSend): MsgMultiSendEncodeObject;
17
18
  }
@@ -29,10 +29,13 @@ var BankTxClient = /** @class */ (function (_super) {
29
29
  function BankTxClient(wallet, address) {
30
30
  return _super.call(this, wallet, address, registry) || this;
31
31
  }
32
- BankTxClient.prototype.msgSend = function (data) {
32
+ BankTxClient.getRegistry = function () {
33
+ return registry;
34
+ };
35
+ BankTxClient.msgSend = function (data) {
33
36
  return { typeUrl: "/cosmos.bank.v1beta1.MsgSend", value: data };
34
37
  };
35
- BankTxClient.prototype.msgMultiSend = function (data) {
38
+ BankTxClient.msgMultiSend = function (data) {
36
39
  return { typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", value: data };
37
40
  };
38
41
  return BankTxClient;
@@ -1,7 +1,11 @@
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
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -0,0 +1,7 @@
1
+ import { Registry } from "@cosmjs/proto-signing";
2
+ import { FirmaWalletService } from "../../FirmaWalletService";
3
+ import { ITxClient } from "./ITxClient";
4
+ export declare class CommonTxClient extends ITxClient {
5
+ constructor(wallet: FirmaWalletService, address: string);
6
+ static getRegistry(): Registry;
7
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CommonTxClient = void 0;
19
+ var proto_signing_1 = require("@cosmjs/proto-signing");
20
+ var tx_1 = require("cosmjs-types/cosmos/bank/v1beta1/tx");
21
+ var tx_2 = require("cosmjs-types/cosmos/distribution/v1beta1/tx");
22
+ var tx_3 = require("cosmjs-types/cosmos/gov/v1beta1/tx");
23
+ var tx_4 = require("cosmjs-types/cosmos/staking/v1beta1/tx");
24
+ var tx_5 = require("cosmjs-types/cosmwasm/wasm/v1/tx");
25
+ var AuthzTxTypes_1 = require("../authz/AuthzTxTypes");
26
+ var ContractTxTypes_1 = require("../contract/ContractTxTypes");
27
+ var FeeGrantTxTypes_1 = require("../feegrant/FeeGrantTxTypes");
28
+ var NftTxTypes_1 = require("../nft/NftTxTypes");
29
+ var TokenTxTypes_1 = require("../token/TokenTxTypes");
30
+ var ITxClient_1 = require("./ITxClient");
31
+ var types = [
32
+ ["/cosmos.authz.v1beta1.MsgExec", AuthzTxTypes_1.MsgExec],
33
+ ["/cosmos.authz.v1beta1.MsgGrant", AuthzTxTypes_1.MsgGrant],
34
+ ["/cosmos.authz.v1beta1.MsgRevoke", AuthzTxTypes_1.MsgRevoke],
35
+ ["/cosmos.bank.v1beta1.MsgSend", tx_1.MsgSend],
36
+ ["/cosmos.bank.v1beta1.MsgMultiSend", tx_1.MsgMultiSend],
37
+ ["/firmachain.firmachain.contract.MsgCreateContractFile", ContractTxTypes_1.MsgCreateContractFile],
38
+ ["/firmachain.firmachain.contract.MsgAddContractLog", ContractTxTypes_1.MsgAddContractLog],
39
+ ["/cosmwasm.wasm.v1.MsgStoreCode", tx_5.MsgStoreCode],
40
+ ["/cosmwasm.wasm.v1.MsgInstantiateContract", tx_5.MsgInstantiateContract],
41
+ ["/cosmwasm.wasm.v1.MsgExecuteContract", tx_5.MsgExecuteContract],
42
+ ["/cosmwasm.wasm.v1.MsgUpdateAdmin", tx_5.MsgUpdateAdmin],
43
+ ["/cosmwasm.wasm.v1.MsgClearAdmin", tx_5.MsgClearAdmin],
44
+ ["/cosmwasm.wasm.v1.MsgMigrateContract", tx_5.MsgMigrateContract],
45
+ ["/cosmos.distribution.v1beta1.MsgFundCommunityPool", tx_2.MsgFundCommunityPool],
46
+ ["/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", tx_2.MsgSetWithdrawAddress],
47
+ ["/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", tx_2.MsgWithdrawDelegatorReward],
48
+ ["/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", tx_2.MsgWithdrawValidatorCommission],
49
+ ["/cosmos.feegrant.v1beta1.MsgGrantAllowance", FeeGrantTxTypes_1.MsgGrantAllowance],
50
+ ["/cosmos.feegrant.v1beta1.MsgRevokeAllowance", FeeGrantTxTypes_1.MsgRevokeAllowance],
51
+ ["/cosmos.gov.v1beta1.MsgDeposit", tx_3.MsgDeposit],
52
+ ["/cosmos.gov.v1beta1.MsgSubmitProposal", tx_3.MsgSubmitProposal],
53
+ ["/cosmos.gov.v1beta1.MsgVote", tx_3.MsgVote],
54
+ ["/ibc.applications.transfer.v1.MsgTransfer", NftTxTypes_1.MsgTransfer],
55
+ ["/firmachain.firmachain.nft.MsgTransfer", NftTxTypes_1.MsgTransfer],
56
+ ["/firmachain.firmachain.nft.MsgMint", NftTxTypes_1.MsgMint],
57
+ ["/firmachain.firmachain.nft.MsgBurn", NftTxTypes_1.MsgBurn],
58
+ ["/cosmos.staking.v1beta1.MsgDelegate", tx_4.MsgDelegate],
59
+ ["/cosmos.staking.v1beta1.MsgUndelegate", tx_4.MsgUndelegate],
60
+ ["/cosmos.staking.v1beta1.MsgBeginRedelegate", tx_4.MsgBeginRedelegate],
61
+ ["/cosmos.staking.v1beta1.MsgEditValidator", tx_4.MsgEditValidator],
62
+ ["/cosmos.staking.v1beta1.MsgCreateValidator", tx_4.MsgCreateValidator],
63
+ ["/firmachain.firmachain.token.MsgCreateToken", TokenTxTypes_1.MsgCreateToken],
64
+ ["/firmachain.firmachain.token.MsgUpdateTokenURI", TokenTxTypes_1.MsgUpdateTokenURI],
65
+ ["/firmachain.firmachain.token.MsgMint", NftTxTypes_1.MsgMint],
66
+ ["/firmachain.firmachain.token.MsgBurn", NftTxTypes_1.MsgBurn]
67
+ ];
68
+ var registry = new proto_signing_1.Registry(types);
69
+ var CommonTxClient = /** @class */ (function (_super) {
70
+ __extends(CommonTxClient, _super);
71
+ function CommonTxClient(wallet, address) {
72
+ return _super.call(this, wallet, address, registry) || this;
73
+ }
74
+ CommonTxClient.getRegistry = function () {
75
+ return registry;
76
+ };
77
+ return CommonTxClient;
78
+ }(ITxClient_1.ITxClient));
79
+ exports.CommonTxClient = CommonTxClient;
@@ -1,18 +1,18 @@
1
1
  import { Registry, EncodeObject } from "@cosmjs/proto-signing";
2
2
  import { SignAndBroadcastOptions } from ".";
3
- import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
3
+ import { SignDoc, TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
4
+ import { TxRawExt } from "./signingstargateclient";
4
5
  import { BroadcastTxResponse } from "./stargateclient";
5
6
  import { FirmaWalletService } from "../../FirmaWalletService";
6
- import { Any } from "cosmjs-types/google/protobuf/any";
7
7
  export declare class ITxClient {
8
8
  private readonly wallet;
9
9
  private readonly serverUrl;
10
10
  private readonly registry;
11
11
  private rawWallet;
12
12
  constructor(wallet: FirmaWalletService, serverUrl: string, registry: Registry);
13
- getAnyData(message: EncodeObject): Any;
14
13
  getRegistry(): Registry;
15
14
  sign(msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions): Promise<TxRaw>;
16
15
  broadcast(txRaw: TxRaw): Promise<BroadcastTxResponse>;
17
16
  signAndBroadcast(msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions): Promise<BroadcastTxResponse>;
17
+ signDirectForSignDoc(signerAddress: string, signDoc: SignDoc): Promise<TxRawExt>;
18
18
  }
@@ -39,7 +39,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.ITxClient = void 0;
40
40
  var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
41
41
  var signingstargateclient_1 = require("./signingstargateclient");
42
- var any_1 = require("cosmjs-types/google/protobuf/any");
43
42
  var ITxClient = /** @class */ (function () {
44
43
  function ITxClient(wallet, serverUrl, registry) {
45
44
  this.wallet = wallet;
@@ -47,13 +46,6 @@ var ITxClient = /** @class */ (function () {
47
46
  this.registry = registry;
48
47
  this.rawWallet = wallet.getRawWallet();
49
48
  }
50
- ITxClient.prototype.getAnyData = function (message) {
51
- var anyData = any_1.Any.fromPartial({
52
- typeUrl: message.typeUrl,
53
- value: this.getRegistry().encode(message)
54
- });
55
- return anyData;
56
- };
57
49
  ITxClient.prototype.getRegistry = function () { return this.registry; };
58
50
  ITxClient.prototype.sign = function (msgs, _a) {
59
51
  var fee = _a.fee, memo = _a.memo;
@@ -106,6 +98,20 @@ var ITxClient = /** @class */ (function () {
106
98
  });
107
99
  });
108
100
  };
101
+ ITxClient.prototype.signDirectForSignDoc = function (signerAddress, signDoc) {
102
+ return __awaiter(this, void 0, void 0, function () {
103
+ var client;
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0: return [4 /*yield*/, signingstargateclient_1.SigningStargateClient.connectWithSigner(this.serverUrl, this.rawWallet, this.registry)];
107
+ case 1:
108
+ client = _a.sent();
109
+ return [4 /*yield*/, client.signDirectForSignDoc(signerAddress, signDoc)];
110
+ case 2: return [2 /*return*/, _a.sent()];
111
+ }
112
+ });
113
+ });
114
+ };
109
115
  return ITxClient;
110
116
  }());
111
117
  exports.ITxClient = ITxClient;
@@ -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" + Buffer.from(accAddress).toString("hex");
138
+ hexAccAddress = "0x01".concat(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 = accounts_1.accountFromAny(account);
152
+ finalAccount = (0, accounts_1.accountFromAny)(account);
153
153
  return [2 /*return*/, finalAccount];
154
154
  case 2:
155
155
  error_1 = _a.sent();
@@ -51,10 +51,14 @@ 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
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
56
- to[j] = from[i];
57
- return to;
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
57
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
+ ar[i] = from[i];
59
+ }
60
+ }
61
+ return to.concat(ar || Array.prototype.slice.call(from));
58
62
  };
59
63
  var __importDefault = (this && this.__importDefault) || function (mod) {
60
64
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -91,7 +95,7 @@ function makeAuthInfoBytes(signers, feeAmount, gasLimit, granter, signMode) {
91
95
  var authInfo = {
92
96
  signerInfos: makeSignerInfos(signers, signMode),
93
97
  fee: {
94
- amount: __spreadArray([], __read(feeAmount)),
98
+ amount: __spreadArray([], __read(feeAmount), false),
95
99
  gasLimit: long_1.default.fromNumber(gasLimit),
96
100
  granter: granter,
97
101
  },
@@ -109,7 +113,7 @@ function signFromLedger(ledger, messages, option, registry) {
109
113
  return [4 /*yield*/, FirmaUtil_1.FirmaUtil.getSignerDataForLedger(address)];
110
114
  case 2:
111
115
  signerData = _b.sent();
112
- pubkey = proto_signing_1.encodePubkey(encoding_2.encodeSecp256k1Pubkey(publicKey));
116
+ pubkey = (0, proto_signing_1.encodePubkey)((0, encoding_2.encodeSecp256k1Pubkey)(publicKey));
113
117
  aminoTypes = new aminotypes_1.AminoTypes({});
114
118
  msgs = messages.map(function (msg) { return aminoTypes.toAmino(msg); });
115
119
  chainId = signerData.chain_id;
@@ -117,9 +121,9 @@ function signFromLedger(ledger, messages, option, registry) {
117
121
  sequence = Number.parseInt(signerData.sequence);
118
122
  memo = option.memo;
119
123
  fee = { amount: option.fee.amount, gas: option.fee.gas };
120
- signDoc = signdoc_2.makeSignDoc(msgs, fee, chainId, memo, accountNumber, sequence);
121
- signMessage = signdoc_1.serializeSignDoc(signDoc);
122
- return [4 /*yield*/, ledger.sign(encoding_3.fromUtf8(signMessage))];
124
+ signDoc = (0, signdoc_2.makeSignDoc)(msgs, fee, chainId, memo, accountNumber, sequence);
125
+ signMessage = (0, signdoc_1.serializeSignDoc)(signDoc);
126
+ return [4 /*yield*/, ledger.sign((0, encoding_3.fromUtf8)(signMessage))];
123
127
  case 3:
124
128
  ledgerSignature = _b.sent();
125
129
  ;
@@ -137,7 +141,7 @@ function signFromLedger(ledger, messages, option, registry) {
137
141
  txRaw = tx_2.TxRaw.fromPartial({
138
142
  bodyBytes: signedTxBodyBytes,
139
143
  authInfoBytes: signedAuthInfoBytes,
140
- signatures: [encoding_1.fromBase64(Buffer.from(ledgerSignature).toString('base64'))],
144
+ signatures: [(0, encoding_1.fromBase64)(Buffer.from(ledgerSignature).toString('base64'))],
141
145
  });
142
146
  return [2 /*return*/, txRaw];
143
147
  }
@@ -10,7 +10,7 @@ function uint64FromProto(input) {
10
10
  }
11
11
  function accountFromBaseAccount(input) {
12
12
  var address = input.address, pubKey = input.pubKey, accountNumber = input.accountNumber, sequence = input.sequence;
13
- var pubkey = proto_signing_1.decodePubkey(pubKey);
13
+ var pubkey = (0, proto_signing_1.decodePubkey)(pubKey);
14
14
  return {
15
15
  address: address,
16
16
  pubkey: pubkey,
@@ -58,7 +58,7 @@ function accountFromAny(input) {
58
58
  return accountFromBaseAccount(baseAccount);
59
59
  }
60
60
  default:
61
- throw new Error("Unsupported type: '" + typeUrl + "'");
61
+ throw new Error("Unsupported type: '".concat(typeUrl, "'"));
62
62
  }
63
63
  }
64
64
  exports.accountFromAny = accountFromAny;
@@ -1,7 +1,11 @@
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
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -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 __importDefault = (this && this.__importDefault) || function (mod) {
24
28
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -45,7 +49,7 @@ function makeAuthInfoBytes(signers, feeAmount, gasLimit, granter, signMode) {
45
49
  var authInfo = {
46
50
  signerInfos: makeSignerInfos(signers, signMode),
47
51
  fee: {
48
- amount: __spreadArray([], __read(feeAmount)),
52
+ amount: __spreadArray([], __read(feeAmount), false),
49
53
  gasLimit: long_1.default.fromNumber(gasLimit),
50
54
  granter: granter,
51
55
  },