@firmachain/firma-js 0.3.4 → 0.3.6-beta1

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 (246) hide show
  1. package/dist/index.js +5 -1
  2. package/dist/sdk/FirmaAuthzService.d.ts +8 -7
  3. package/dist/sdk/FirmaAuthzService.js +12 -22
  4. package/dist/sdk/FirmaBankService.js +2 -2
  5. package/dist/sdk/FirmaChainService.js +1 -1
  6. package/dist/sdk/FirmaContractService.d.ts +1 -1
  7. package/dist/sdk/FirmaContractService.js +6 -6
  8. package/dist/sdk/FirmaCosmWasmCw20.d.ts +2 -2
  9. package/dist/sdk/FirmaCosmWasmCw20.js +8 -8
  10. package/dist/sdk/FirmaCosmWasmCw721.d.ts +2 -2
  11. package/dist/sdk/FirmaCosmWasmCw721.js +12 -12
  12. package/dist/sdk/FirmaCosmWasmCwBridge.d.ts +1 -1
  13. package/dist/sdk/FirmaCosmWasmCwBridge.js +8 -8
  14. package/dist/sdk/FirmaCosmWasmCwMarketplace.d.ts +1 -1
  15. package/dist/sdk/FirmaCosmWasmCwMarketplace.js +5 -5
  16. package/dist/sdk/FirmaCosmWasmService.d.ts +1 -1
  17. package/dist/sdk/FirmaCosmWasmService.js +13 -13
  18. package/dist/sdk/FirmaDistributionService.d.ts +1 -1
  19. package/dist/sdk/FirmaDistributionService.js +6 -6
  20. package/dist/sdk/FirmaFeeGrantService.d.ts +7 -6
  21. package/dist/sdk/FirmaFeeGrantService.js +9 -26
  22. package/dist/sdk/FirmaGovService.d.ts +1 -1
  23. package/dist/sdk/FirmaGovService.js +14 -14
  24. package/dist/sdk/FirmaIbcService.d.ts +3 -3
  25. package/dist/sdk/FirmaIbcService.js +11 -8
  26. package/dist/sdk/FirmaIpfsService.js +1 -1
  27. package/dist/sdk/FirmaMintService.js +1 -1
  28. package/dist/sdk/FirmaNftService.d.ts +1 -1
  29. package/dist/sdk/FirmaNftService.js +6 -6
  30. package/dist/sdk/FirmaSlashingService.js +1 -1
  31. package/dist/sdk/FirmaStakingService.d.ts +3 -3
  32. package/dist/sdk/FirmaStakingService.js +6 -6
  33. package/dist/sdk/FirmaTokenService.d.ts +1 -1
  34. package/dist/sdk/FirmaTokenService.js +5 -5
  35. package/dist/sdk/FirmaUtil.d.ts +26 -23
  36. package/dist/sdk/FirmaUtil.js +157 -137
  37. package/dist/sdk/FirmaWalletService.d.ts +5 -9
  38. package/dist/sdk/FirmaWalletService.js +86 -52
  39. package/dist/sdk/firmachain/authz/AuthzQueryClient.js +4 -4
  40. package/dist/sdk/firmachain/authz/AuthzTxTypes.d.ts +8 -11
  41. package/dist/sdk/firmachain/authz/AuthzTxTypes.js +6 -10
  42. package/dist/sdk/firmachain/authz/index.js +5 -1
  43. package/dist/sdk/firmachain/bank/BankQueryClient.js +5 -5
  44. package/dist/sdk/firmachain/bank/index.js +5 -1
  45. package/dist/sdk/firmachain/common/ITxClient.d.ts +3 -3
  46. package/dist/sdk/firmachain/common/ITxClient.js +25 -83
  47. package/dist/sdk/firmachain/common/LedgerWallet.d.ts +19 -3
  48. package/dist/sdk/firmachain/common/LedgerWallet.js +138 -68
  49. package/dist/sdk/firmachain/common/TendermintQueryClient.js +1 -1
  50. package/dist/sdk/firmachain/common/TxCommon.d.ts +14 -30
  51. package/dist/sdk/firmachain/common/accounts.d.ts +1 -1
  52. package/dist/sdk/firmachain/common/accounts.js +7 -7
  53. package/dist/sdk/firmachain/common/events.js +2 -2
  54. package/dist/sdk/firmachain/common/fee.d.ts +2 -2
  55. package/dist/sdk/firmachain/common/fee.js +4 -2
  56. package/dist/sdk/firmachain/common/index.d.ts +0 -1
  57. package/dist/sdk/firmachain/common/index.js +5 -4
  58. package/dist/sdk/firmachain/common/signing.d.ts +13 -9
  59. package/dist/sdk/firmachain/common/signing.js +81 -36
  60. package/dist/sdk/firmachain/common/signingprotobufstargateclient.d.ts +34 -0
  61. package/dist/sdk/firmachain/common/signingprotobufstargateclient.js +319 -0
  62. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +21 -105
  63. package/dist/sdk/firmachain/common/signingstargateclient.js +120 -472
  64. package/dist/sdk/firmachain/common/{stargateclient.d.ts → stargateClient.d.ts} +11 -60
  65. package/dist/sdk/firmachain/common/{stargateclient.js → stargateClient.js} +109 -203
  66. package/dist/sdk/firmachain/{amino → common}/wallet.js +15 -11
  67. package/dist/sdk/firmachain/contract/ContractQueryClient.js +3 -3
  68. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +6 -6
  69. package/dist/sdk/firmachain/contract/index.js +5 -1
  70. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +9 -9
  71. package/dist/sdk/firmachain/cosmwasm/index.js +5 -1
  72. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +6 -6
  73. package/dist/sdk/firmachain/distribution/index.js +5 -1
  74. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +3 -3
  75. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +4 -45
  76. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +3 -82
  77. package/dist/sdk/firmachain/feegrant/index.js +5 -1
  78. package/dist/sdk/firmachain/google/protobuf/any.d.ts +3 -3
  79. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +29 -29
  80. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +3 -3
  81. package/dist/sdk/firmachain/gov/GovQueryClient.js +3 -3
  82. package/dist/sdk/firmachain/gov/index.js +5 -1
  83. package/dist/sdk/firmachain/ibc/IbcQueryClient.js +2 -2
  84. package/dist/sdk/firmachain/ibc/index.js +5 -1
  85. package/dist/sdk/firmachain/mint/MintQueryClient.js +1 -1
  86. package/dist/sdk/firmachain/mint/index.js +5 -1
  87. package/dist/sdk/firmachain/nft/NftQueryClient.js +1 -1
  88. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +8 -8
  89. package/dist/sdk/firmachain/nft/index.js +5 -1
  90. package/dist/sdk/firmachain/slashing/SlashingQueryClient.js +1 -1
  91. package/dist/sdk/firmachain/slashing/index.js +5 -1
  92. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +2 -2
  93. package/dist/sdk/firmachain/staking/StakingQueryClient.js +10 -9
  94. package/dist/sdk/firmachain/staking/index.js +5 -1
  95. package/dist/sdk/firmachain/token/TokenQueryClient.js +1 -1
  96. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +11 -11
  97. package/dist/sdk/firmachain/token/TokenTxTypes.js +1 -1
  98. package/dist/sdk/firmachain/token/index.js +5 -1
  99. package/dist/test/00.wallet.test.js +4 -4
  100. package/dist/test/01.contract_tx.test.js +5 -5
  101. package/dist/test/02.contract_query.test.js +15 -15
  102. package/dist/test/03.contract_scenario.test.js +28 -28
  103. package/dist/test/04.bank_tx.test.js +4 -4
  104. package/dist/test/05.bank_query.test.js +9 -9
  105. package/dist/test/06.feegrant_tx.test.js +59 -35
  106. package/dist/test/07.feegrant_query.test.js +18 -15
  107. package/dist/test/08.gas_estimate.test.js +110 -70
  108. package/dist/test/09.ipfs.test.js +4 -4
  109. package/dist/test/10.nft_tx.test.js +7 -7
  110. package/dist/test/11.nft_query.test.js +9 -9
  111. package/dist/test/12.staking_tx.test.js +27 -15
  112. package/dist/test/13.staking_query.test.js +20 -20
  113. package/dist/test/14.distribution_tx.test.js +8 -8
  114. package/dist/test/15.distribution_query.test.js +15 -15
  115. package/dist/test/16.gov_tx.test.js +17 -17
  116. package/dist/test/17.gov_query.test.js +19 -19
  117. package/dist/test/18.util.test.js +105 -63
  118. package/dist/test/19.chain.test.js +38 -38
  119. package/dist/test/20.slashing_query.test.js +25 -25
  120. package/dist/test/21.token_tx.test.js +6 -6
  121. package/dist/test/22.token_query.test.js +4 -4
  122. package/dist/test/23.authz_tx.test.js +77 -47
  123. package/dist/test/24.authz_query.test.js +66 -67
  124. package/dist/test/25.cosmwasm_tx.test.js +7 -7
  125. package/dist/test/26.cosmwasm_query.test.js +127 -59
  126. package/dist/test/{27.arbitary_sign.test.js → 27.arbitrary_sign.test.js} +41 -40
  127. package/dist/test/28.ibc_tx.test.js +8 -8
  128. package/dist/test/29.mint_query.test.js +2 -2
  129. package/dist/test/30.cw20_tx.test.js +20 -20
  130. package/dist/test/31.cw20_query.test.js +24 -24
  131. package/dist/test/32.cw721_tx.test.js +19 -19
  132. package/dist/test/33.cw721_query.test.js +32 -32
  133. package/dist/test/34.cw_bridge_tx.test.js +19 -19
  134. package/dist/test/35.cw_bridge_tx_low.test.js +13 -13
  135. package/dist/test/36.cw_bridge_query.test.js +20 -20
  136. package/dist/test/37.cw_marketplace_tx.test.js +32 -32
  137. package/dist/test/38.cw_marketplace_query.test.js +2 -2
  138. package/dist/test/config_test.d.ts +2 -2
  139. package/dist/test/config_test.js +22 -5
  140. package/package.json +9 -10
  141. package/dist/sdk/firmachain/amino/addresses.d.ts +0 -5
  142. package/dist/sdk/firmachain/amino/addresses.js +0 -46
  143. package/dist/sdk/firmachain/amino/aminomsgs.d.ts +0 -291
  144. package/dist/sdk/firmachain/amino/aminomsgs.js +0 -81
  145. package/dist/sdk/firmachain/amino/aminotypes.d.ts +0 -22
  146. package/dist/sdk/firmachain/amino/aminotypes.js +0 -538
  147. package/dist/sdk/firmachain/amino/coins.d.ts +0 -42
  148. package/dist/sdk/firmachain/amino/coins.js +0 -90
  149. package/dist/sdk/firmachain/amino/encoding.d.ts +0 -33
  150. package/dist/sdk/firmachain/amino/encoding.js +0 -252
  151. package/dist/sdk/firmachain/amino/multisig.d.ts +0 -10
  152. package/dist/sdk/firmachain/amino/multisig.js +0 -42
  153. package/dist/sdk/firmachain/amino/pubkeys.d.ts +0 -47
  154. package/dist/sdk/firmachain/amino/pubkeys.js +0 -29
  155. package/dist/sdk/firmachain/amino/signature.d.ts +0 -16
  156. package/dist/sdk/firmachain/amino/signature.js +0 -36
  157. package/dist/sdk/firmachain/amino/signdoc.d.ts +0 -44
  158. package/dist/sdk/firmachain/amino/signdoc.js +0 -68
  159. package/dist/sdk/firmachain/amino/signer.d.ts +0 -33
  160. package/dist/sdk/firmachain/amino/signer.js +0 -2
  161. package/dist/sdk/firmachain/amino/stdtx.d.ts +0 -15
  162. package/dist/sdk/firmachain/amino/stdtx.js +0 -17
  163. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +0 -22
  164. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +0 -170
  165. package/dist/sdk/firmachain/common/aminotypes.d.ts +0 -19
  166. package/dist/sdk/firmachain/common/aminotypes.js +0 -74
  167. package/dist/sdk/firmachain/common/modules/auth/queries.d.ts +0 -15
  168. package/dist/sdk/firmachain/common/modules/auth/queries.js +0 -64
  169. package/dist/sdk/firmachain/common/modules/authz/aminomessages.d.ts +0 -2
  170. package/dist/sdk/firmachain/common/modules/authz/aminomessages.js +0 -15
  171. package/dist/sdk/firmachain/common/modules/authz/messages.d.ts +0 -2
  172. package/dist/sdk/firmachain/common/modules/authz/messages.js +0 -9
  173. package/dist/sdk/firmachain/common/modules/authz/queries.d.ts +0 -10
  174. package/dist/sdk/firmachain/common/modules/authz/queries.js +0 -88
  175. package/dist/sdk/firmachain/common/modules/bank/aminomessages.d.ts +0 -35
  176. package/dist/sdk/firmachain/common/modules/bank/aminomessages.js +0 -85
  177. package/dist/sdk/firmachain/common/modules/bank/messages.d.ts +0 -8
  178. package/dist/sdk/firmachain/common/modules/bank/messages.js +0 -12
  179. package/dist/sdk/firmachain/common/modules/bank/queries.d.ts +0 -15
  180. package/dist/sdk/firmachain/common/modules/bank/queries.js +0 -128
  181. package/dist/sdk/firmachain/common/modules/crisis/aminomessages.d.ts +0 -14
  182. package/dist/sdk/firmachain/common/modules/crisis/aminomessages.js +0 -11
  183. package/dist/sdk/firmachain/common/modules/distribution/aminomessages.d.ts +0 -44
  184. package/dist/sdk/firmachain/common/modules/distribution/aminomessages.js +0 -113
  185. package/dist/sdk/firmachain/common/modules/distribution/messages.d.ts +0 -8
  186. package/dist/sdk/firmachain/common/modules/distribution/messages.js +0 -15
  187. package/dist/sdk/firmachain/common/modules/distribution/queries.d.ts +0 -16
  188. package/dist/sdk/firmachain/common/modules/distribution/queries.js +0 -171
  189. package/dist/sdk/firmachain/common/modules/evidence/aminomessages.d.ts +0 -18
  190. package/dist/sdk/firmachain/common/modules/evidence/aminomessages.js +0 -11
  191. package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.d.ts +0 -2
  192. package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.js +0 -14
  193. package/dist/sdk/firmachain/common/modules/feegrant/messages.d.ts +0 -2
  194. package/dist/sdk/firmachain/common/modules/feegrant/messages.js +0 -8
  195. package/dist/sdk/firmachain/common/modules/feegrant/queries.d.ts +0 -9
  196. package/dist/sdk/firmachain/common/modules/feegrant/queries.js +0 -81
  197. package/dist/sdk/firmachain/common/modules/gov/aminomessages.d.ts +0 -79
  198. package/dist/sdk/firmachain/common/modules/gov/aminomessages.js +0 -152
  199. package/dist/sdk/firmachain/common/modules/gov/messages.d.ts +0 -29
  200. package/dist/sdk/firmachain/common/modules/gov/messages.js +0 -39
  201. package/dist/sdk/firmachain/common/modules/gov/queries.d.ts +0 -19
  202. package/dist/sdk/firmachain/common/modules/gov/queries.js +0 -160
  203. package/dist/sdk/firmachain/common/modules/group/aminomessages.d.ts +0 -2
  204. package/dist/sdk/firmachain/common/modules/group/aminomessages.js +0 -8
  205. package/dist/sdk/firmachain/common/modules/group/messages.d.ts +0 -2
  206. package/dist/sdk/firmachain/common/modules/group/messages.js +0 -28
  207. package/dist/sdk/firmachain/common/modules/ibc/aminomessages.d.ts +0 -38
  208. package/dist/sdk/firmachain/common/modules/ibc/aminomessages.js +0 -55
  209. package/dist/sdk/firmachain/common/modules/ibc/messages.d.ts +0 -8
  210. package/dist/sdk/firmachain/common/modules/ibc/messages.js +0 -32
  211. package/dist/sdk/firmachain/common/modules/ibc/queries.d.ts +0 -58
  212. package/dist/sdk/firmachain/common/modules/ibc/queries.js +0 -576
  213. package/dist/sdk/firmachain/common/modules/index.d.ts +0 -32
  214. package/dist/sdk/firmachain/common/modules/index.js +0 -101
  215. package/dist/sdk/firmachain/common/modules/mint/queries.d.ts +0 -21
  216. package/dist/sdk/firmachain/common/modules/mint/queries.js +0 -95
  217. package/dist/sdk/firmachain/common/modules/slashing/aminomessages.d.ts +0 -12
  218. package/dist/sdk/firmachain/common/modules/slashing/aminomessages.js +0 -11
  219. package/dist/sdk/firmachain/common/modules/slashing/queries.d.ts +0 -10
  220. package/dist/sdk/firmachain/common/modules/slashing/queries.js +0 -88
  221. package/dist/sdk/firmachain/common/modules/staking/aminomessages.d.ts +0 -112
  222. package/dist/sdk/firmachain/common/modules/staking/aminomessages.js +0 -234
  223. package/dist/sdk/firmachain/common/modules/staking/messages.d.ts +0 -33
  224. package/dist/sdk/firmachain/common/modules/staking/messages.js +0 -37
  225. package/dist/sdk/firmachain/common/modules/staking/queries.d.ts +0 -23
  226. package/dist/sdk/firmachain/common/modules/staking/queries.js +0 -242
  227. package/dist/sdk/firmachain/common/modules/tx/queries.d.ts +0 -11
  228. package/dist/sdk/firmachain/common/modules/tx/queries.js +0 -103
  229. package/dist/sdk/firmachain/common/modules/vesting/aminomessages.d.ts +0 -16
  230. package/dist/sdk/firmachain/common/modules/vesting/aminomessages.js +0 -56
  231. package/dist/sdk/firmachain/common/modules/vesting/messages.d.ts +0 -2
  232. package/dist/sdk/firmachain/common/modules/vesting/messages.js +0 -7
  233. package/dist/sdk/firmachain/common/queryclient/index.d.ts +0 -2
  234. package/dist/sdk/firmachain/common/queryclient/index.js +0 -10
  235. package/dist/sdk/firmachain/common/queryclient/queryclient.d.ts +0 -75
  236. package/dist/sdk/firmachain/common/queryclient/queryclient.js +0 -157
  237. package/dist/sdk/firmachain/common/queryclient/utils.d.ts +0 -33
  238. package/dist/sdk/firmachain/common/queryclient/utils.js +0 -101
  239. package/dist/sdk/firmachain/common/search.d.ts +0 -10
  240. package/dist/sdk/firmachain/common/search.js +0 -7
  241. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +0 -110
  242. package/dist/sdk/firmachain/google/protobuf/timestamp.js +0 -108
  243. /package/dist/sdk/firmachain/{amino → common}/paths.d.ts +0 -0
  244. /package/dist/sdk/firmachain/{amino → common}/paths.js +0 -0
  245. /package/dist/sdk/firmachain/{amino → common}/wallet.d.ts +0 -0
  246. /package/dist/test/{27.arbitary_sign.test.d.ts → 27.arbitrary_sign.test.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { EncodeObject, Registry } from "@cosmjs/proto-signing";
2
2
  import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
3
- import { SignAndBroadcastOptions } from "../common";
3
+ import { SignAndBroadcastOptions } from "./TxCommon";
4
4
  export interface LedgerWalletInterface {
5
5
  getAddress(): Promise<string>;
6
6
  sign(message: string): Promise<Uint8Array>;
@@ -9,6 +9,22 @@ export interface LedgerWalletInterface {
9
9
  address: string;
10
10
  publicKey: Uint8Array;
11
11
  }>;
12
- showAddressOnDevice(): Promise<void>;
12
+ showAddressOnDevice?(): Promise<void>;
13
13
  }
14
- export declare function signFromLedger(ledger: LedgerWalletInterface, messages: EncodeObject[], option: SignAndBroadcastOptions, registry: Registry): Promise<TxRaw>;
14
+ export interface SignerData {
15
+ readonly account_number: number;
16
+ readonly sequence: number;
17
+ readonly chain_id: string;
18
+ }
19
+ /**
20
+ * Signs a protobuf-based Cosmos transaction using a general Signer
21
+ * compatible with SIGN_MODE_DIRECT (e.g. Ledger, Keplr, etc.)
22
+ *
23
+ * @param signer - SignerInterface instance
24
+ * @param messages - Cosmos transaction messages
25
+ * @param signerData - Chain ID, account number, sequence
26
+ * @param option - Fee, memo, granter info
27
+ * @param registry - Protobuf registry for message encoding
28
+ * @returns TxRaw - fully signed transaction
29
+ */
30
+ export declare function signWithSignerProtobuf(signer: LedgerWalletInterface, messages: EncodeObject[], signerData: SignerData, option: SignAndBroadcastOptions, registry: Registry): Promise<TxRaw>;
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -51,93 +51,163 @@ 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));
62
+ };
63
+ var __values = (this && this.__values) || function(o) {
64
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
65
+ if (m) return m.call(o);
66
+ if (o && typeof o.length === "number") return {
67
+ next: function () {
68
+ if (o && i >= o.length) o = void 0;
69
+ return { value: o && o[i++], done: !o };
70
+ }
71
+ };
72
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
58
73
  };
59
74
  Object.defineProperty(exports, "__esModule", { value: true });
60
- exports.signFromLedger = void 0;
61
- var proto_signing_1 = require("@cosmjs/proto-signing");
75
+ exports.signWithSignerProtobuf = void 0;
76
+ var signing_1 = require("cosmjs-types/cosmos/tx/signing/v1beta1/signing");
62
77
  var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
63
- var math_1 = require("@cosmjs/math");
64
78
  var encoding_1 = require("@cosmjs/encoding");
65
- var signdoc_1 = require("../amino/signdoc");
66
- var encoding_2 = require("../amino/encoding");
67
- var signdoc_2 = require("../amino/signdoc");
68
- var encoding_3 = require("@cosmjs/encoding");
69
- var signing_1 = require("cosmjs-types/cosmos/tx/signing/v1beta1/signing");
70
- var tx_2 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
71
- var FirmaUtil_1 = require("../../FirmaUtil");
72
- var stargate_1 = require("@cosmjs/stargate");
73
- function makeSignerInfos(signers, signMode) {
74
- return signers.map(function (_a) {
75
- var pubkey = _a.pubkey, sequence = _a.sequence;
76
- return ({
77
- publicKey: pubkey,
78
- modeInfo: {
79
- single: { mode: signMode },
80
- },
81
- sequence: BigInt(sequence),
82
- });
83
- });
84
- }
85
- function makeAuthInfoBytes(signers, feeAmount, gasLimit, granter, signMode) {
86
- if (signMode === void 0) { signMode = signing_1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON; }
79
+ var keys_1 = require("cosmjs-types/cosmos/crypto/secp256k1/keys");
80
+ // Creates AuthInfoBytes for "SIGN_MODE_DIRECT"
81
+ function makeAuthInfoBytesDirect(pubkey, feeAmount, gasLimit, sequence) {
82
+ var signerInfo = {
83
+ publicKey: pubkey,
84
+ modeInfo: {
85
+ single: { mode: signing_1.SignMode.SIGN_MODE_DIRECT },
86
+ },
87
+ sequence: BigInt(sequence),
88
+ };
87
89
  var authInfo = {
88
- signerInfos: makeSignerInfos(signers, signMode),
90
+ signerInfos: [signerInfo],
89
91
  fee: {
90
- amount: __spreadArray([], __read(feeAmount)),
92
+ amount: __spreadArray([], __read(feeAmount), false),
91
93
  gasLimit: BigInt(gasLimit),
92
- granter: granter,
93
94
  },
94
95
  };
95
96
  return tx_1.AuthInfo.encode(tx_1.AuthInfo.fromPartial(authInfo)).finish();
96
97
  }
97
- function signFromLedger(ledger, messages, option, registry) {
98
+ /**
99
+ * Signs a protobuf-based Cosmos transaction using a general Signer
100
+ * compatible with SIGN_MODE_DIRECT (e.g. Ledger, Keplr, etc.)
101
+ *
102
+ * @param signer - SignerInterface instance
103
+ * @param messages - Cosmos transaction messages
104
+ * @param signerData - Chain ID, account number, sequence
105
+ * @param option - Fee, memo, granter info
106
+ * @param registry - Protobuf registry for message encoding
107
+ * @returns TxRaw - fully signed transaction
108
+ */
109
+ function signWithSignerProtobuf(signer, messages, signerData, option, registry) {
98
110
  return __awaiter(this, void 0, void 0, function () {
99
- var _a, address, publicKey, signerData, pubkey, aminoTypes, msgs, chainId, accountNumber, sequence, memo, fee, signDoc, signMessage, ledgerSignature, signedTxBody, signedTxBodyEncodeObject, signedTxBodyBytes, signedGasLimit, signedAuthInfoBytes, txRaw;
111
+ var anyMsgs, txBody, bodyBytes, pubkey, pubkeyProto, feeAmount, authInfoBytes, signDoc, signDocBytes, base64SignBytes, signature, lastError, protobufAttempts, protobufAttempts_1, protobufAttempts_1_1, attempt, signError_1, e_1_1, errorMsg, txRaw;
112
+ var e_1, _a;
100
113
  return __generator(this, function (_b) {
101
114
  switch (_b.label) {
102
- case 0: return [4 /*yield*/, ledger.getAddressAndPublicKey()];
115
+ case 0:
116
+ anyMsgs = messages.map(function (msg) { return registry.encodeAsAny(msg); });
117
+ txBody = tx_1.TxBody.fromPartial({
118
+ messages: anyMsgs,
119
+ memo: option.memo || "",
120
+ });
121
+ bodyBytes = tx_1.TxBody.encode(txBody).finish();
122
+ return [4 /*yield*/, signer.getPublicKey()];
103
123
  case 1:
104
- _a = _b.sent(), address = _a.address, publicKey = _a.publicKey;
105
- return [4 /*yield*/, FirmaUtil_1.FirmaUtil.getSignerDataForLedger(address)];
124
+ pubkey = _b.sent();
125
+ pubkeyProto = {
126
+ typeUrl: "/cosmos.crypto.secp256k1.PubKey",
127
+ value: keys_1.PubKey.encode({ key: pubkey }).finish(),
128
+ };
129
+ feeAmount = option.fee.amount.map(function (a) { return ({
130
+ denom: a.denom,
131
+ amount: a.amount,
132
+ }); });
133
+ authInfoBytes = makeAuthInfoBytesDirect(pubkeyProto, feeAmount, option.fee.gasLimit, signerData.sequence);
134
+ signDoc = tx_1.SignDoc.fromPartial({
135
+ bodyBytes: bodyBytes,
136
+ authInfoBytes: authInfoBytes,
137
+ chainId: signerData.chain_id,
138
+ accountNumber: BigInt(signerData.account_number),
139
+ });
140
+ // Verify SignDoc has all required fields
141
+ if (!signDoc.chainId) {
142
+ throw new Error("SignDoc chainId is missing: ".concat(signDoc.chainId));
143
+ }
144
+ if (!signDoc.accountNumber) {
145
+ throw new Error("SignDoc accountNumber is missing: ".concat(signDoc.accountNumber));
146
+ }
147
+ signDocBytes = tx_1.SignDoc.encode(signDoc).finish();
148
+ base64SignBytes = (0, encoding_1.toBase64)(signDocBytes);
149
+ protobufAttempts = [
150
+ { name: "SignDoc Base64", data: base64SignBytes },
151
+ { name: "SignDoc Hex", data: Buffer.from(signDocBytes).toString('hex') },
152
+ { name: "SignDoc Hex with 0x", data: '0x' + Buffer.from(signDocBytes).toString('hex') },
153
+ ];
154
+ _b.label = 2;
106
155
  case 2:
107
- signerData = _b.sent();
108
- pubkey = proto_signing_1.encodePubkey(encoding_2.encodeSecp256k1Pubkey(publicKey));
109
- aminoTypes = new stargate_1.AminoTypes({});
110
- msgs = messages.map(function (msg) { return aminoTypes.toAmino(msg); });
111
- chainId = signerData.chain_id;
112
- accountNumber = Number.parseInt(signerData.account_number);
113
- sequence = Number.parseInt(signerData.sequence);
114
- memo = option.memo;
115
- fee = { amount: option.fee.amount, gas: option.fee.gas };
116
- signDoc = signdoc_2.makeSignDoc(msgs, fee, chainId, memo, accountNumber, sequence);
117
- signMessage = signdoc_1.serializeSignDoc(signDoc);
118
- return [4 /*yield*/, ledger.sign(encoding_3.fromUtf8(signMessage))];
156
+ _b.trys.push([2, 9, 10, 11]);
157
+ protobufAttempts_1 = __values(protobufAttempts), protobufAttempts_1_1 = protobufAttempts_1.next();
158
+ _b.label = 3;
119
159
  case 3:
120
- ledgerSignature = _b.sent();
121
- ;
122
- signedTxBody = {
123
- messages: signDoc.msgs.map(function (msg) { return aminoTypes.fromAmino(msg); }),
124
- memo: memo,
125
- };
126
- signedTxBodyEncodeObject = {
127
- typeUrl: "/cosmos.tx.v1beta1.TxBody",
128
- value: signedTxBody,
129
- };
130
- signedTxBodyBytes = registry.encode(signedTxBodyEncodeObject);
131
- signedGasLimit = math_1.Int53.fromString(option.fee.gas).toNumber();
132
- signedAuthInfoBytes = makeAuthInfoBytes([{ pubkey: pubkey, sequence: sequence }], option.fee.amount, signedGasLimit, option.fee.granter, signing_1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON);
133
- txRaw = tx_2.TxRaw.fromPartial({
134
- bodyBytes: signedTxBodyBytes,
135
- authInfoBytes: signedAuthInfoBytes,
136
- signatures: [encoding_1.fromBase64(Buffer.from(ledgerSignature).toString('base64'))],
160
+ if (!!protobufAttempts_1_1.done) return [3 /*break*/, 8];
161
+ attempt = protobufAttempts_1_1.value;
162
+ _b.label = 4;
163
+ case 4:
164
+ _b.trys.push([4, 6, , 7]);
165
+ return [4 /*yield*/, signer.sign(attempt.data)];
166
+ case 5:
167
+ signature = _b.sent();
168
+ if (signature && signature.length > 0) {
169
+ return [3 /*break*/, 8]; // Success! Exit loop
170
+ }
171
+ return [3 /*break*/, 7];
172
+ case 6:
173
+ signError_1 = _b.sent();
174
+ lastError = signError_1;
175
+ return [3 /*break*/, 7]; // Try next format
176
+ case 7:
177
+ protobufAttempts_1_1 = protobufAttempts_1.next();
178
+ return [3 /*break*/, 3];
179
+ case 8: return [3 /*break*/, 11];
180
+ case 9:
181
+ e_1_1 = _b.sent();
182
+ e_1 = { error: e_1_1 };
183
+ return [3 /*break*/, 11];
184
+ case 10:
185
+ try {
186
+ if (protobufAttempts_1_1 && !protobufAttempts_1_1.done && (_a = protobufAttempts_1.return)) _a.call(protobufAttempts_1);
187
+ }
188
+ finally { if (e_1) throw e_1.error; }
189
+ return [7 /*endfinally*/];
190
+ case 11:
191
+ // If all Protobuf attempts failed, provide guidance
192
+ if (!signature || signature.length === 0) {
193
+ errorMsg = lastError instanceof Error ? lastError.message : String(lastError);
194
+ throw new Error("FirmaChain Ledger app signing failed: ".concat(errorMsg, ". Please ensure FirmaChain app is properly installed and up to date."));
195
+ }
196
+ // Signature validation
197
+ if (!signature || signature.length === 0) {
198
+ throw new Error("Signature is empty. Please confirm that the transaction was approved on Ledger or check Ledger connection.");
199
+ }
200
+ if (signature.length !== 64) {
201
+ throw new Error("Unexpected signature length: ".concat(signature.length, " bytes (expected: 64 bytes)"));
202
+ }
203
+ txRaw = tx_1.TxRaw.fromPartial({
204
+ bodyBytes: bodyBytes,
205
+ authInfoBytes: authInfoBytes,
206
+ signatures: [signature],
137
207
  });
138
208
  return [2 /*return*/, txRaw];
139
209
  }
140
210
  });
141
211
  });
142
212
  }
143
- exports.signFromLedger = signFromLedger;
213
+ exports.signWithSignerProtobuf = signWithSignerProtobuf;
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -1,22 +1,4 @@
1
- import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
2
- import { Any } from "../google/protobuf/any";
3
- export interface StdFee {
4
- amount: Coin[];
5
- gas: string;
6
- granter: string;
7
- }
8
- export interface BasicFeeGrantOption {
9
- spendLimit?: number;
10
- expiration?: Date;
11
- }
12
- export interface PeriodicFeeGrantOption {
13
- basicSpendLimit?: number;
14
- basicExpiration?: Date;
15
- periodSeconds: number;
16
- periodSpendLimit: number;
17
- periodCanSpend: number;
18
- periodReset: Date;
19
- }
1
+ import { Fee } from "cosmjs-types/cosmos/tx/v1beta1/tx";
20
2
  export declare const DefaultBasicFeeGrantOption: {
21
3
  spendLimit: undefined;
22
4
  expiration: undefined;
@@ -28,7 +10,7 @@ export interface TxMisc {
28
10
  feeGranter?: string;
29
11
  }
30
12
  export interface SignAndBroadcastOptions {
31
- fee: StdFee;
13
+ fee: Fee;
32
14
  memo: string;
33
15
  }
34
16
  export interface MsgCreateValidator {
@@ -72,15 +54,17 @@ export declare enum VotingOption {
72
54
  VOTE_OPTION_NO_WITH_VETO = 4,
73
55
  UNRECOGNIZED = -1
74
56
  }
75
- export interface ParamChangeOption {
76
- subspace: string;
77
- key: string;
78
- value: string;
57
+ export interface ArbitraryVerifyData {
58
+ chainId: string;
59
+ accountNumber: string;
60
+ sequence: string;
61
+ bodyBytes: string;
62
+ authInfoBytes: string;
63
+ signerAddress: string;
64
+ pubkey: string;
65
+ signature: string;
79
66
  }
80
- export interface SoftwareUpgradePlan {
81
- name: string;
82
- time?: Date;
83
- height?: bigint;
84
- info?: string;
85
- upgradedClientState?: Any;
67
+ export interface MsgSignArbitraryData {
68
+ signer: string;
69
+ data: Uint8Array;
86
70
  }
@@ -11,7 +11,7 @@ export interface Account {
11
11
  * Represents a generic function that takes an `Any` encoded account from the chain
12
12
  * and extracts some common `Account` information from it.
13
13
  */
14
- export declare type AccountParser = (any: Any) => Account;
14
+ export type AccountParser = (any: Any) => Account;
15
15
  /**
16
16
  * Basic implementation of AccountParser. This is supposed to support the most relevant
17
17
  * common Cosmos SDK account types. If you need support for exotic account types,
@@ -11,7 +11,7 @@ function uint64FromProto(input) {
11
11
  }
12
12
  function accountFromBaseAccount(input) {
13
13
  var address = input.address, pubKey = input.pubKey, accountNumber = input.accountNumber, sequence = input.sequence;
14
- var pubkey = proto_signing_1.decodeOptionalPubkey(pubKey);
14
+ var pubkey = (0, proto_signing_1.decodeOptionalPubkey)(pubKey);
15
15
  return {
16
16
  address: address,
17
17
  pubkey: pubkey,
@@ -33,32 +33,32 @@ function accountFromAny(input) {
33
33
  return accountFromBaseAccount(auth_1.BaseAccount.decode(value));
34
34
  case "/cosmos.auth.v1beta1.ModuleAccount": {
35
35
  var baseAccount = auth_1.ModuleAccount.decode(value).baseAccount;
36
- utils_1.assert(baseAccount);
36
+ (0, utils_1.assert)(baseAccount);
37
37
  return accountFromBaseAccount(baseAccount);
38
38
  }
39
39
  // vesting
40
40
  case "/cosmos.vesting.v1beta1.BaseVestingAccount": {
41
41
  var baseAccount = (_a = vesting_1.BaseVestingAccount.decode(value)) === null || _a === void 0 ? void 0 : _a.baseAccount;
42
- utils_1.assert(baseAccount);
42
+ (0, utils_1.assert)(baseAccount);
43
43
  return accountFromBaseAccount(baseAccount);
44
44
  }
45
45
  case "/cosmos.vesting.v1beta1.ContinuousVestingAccount": {
46
46
  var baseAccount = (_c = (_b = vesting_1.ContinuousVestingAccount.decode(value)) === null || _b === void 0 ? void 0 : _b.baseVestingAccount) === null || _c === void 0 ? void 0 : _c.baseAccount;
47
- utils_1.assert(baseAccount);
47
+ (0, utils_1.assert)(baseAccount);
48
48
  return accountFromBaseAccount(baseAccount);
49
49
  }
50
50
  case "/cosmos.vesting.v1beta1.DelayedVestingAccount": {
51
51
  var baseAccount = (_e = (_d = vesting_1.DelayedVestingAccount.decode(value)) === null || _d === void 0 ? void 0 : _d.baseVestingAccount) === null || _e === void 0 ? void 0 : _e.baseAccount;
52
- utils_1.assert(baseAccount);
52
+ (0, utils_1.assert)(baseAccount);
53
53
  return accountFromBaseAccount(baseAccount);
54
54
  }
55
55
  case "/cosmos.vesting.v1beta1.PeriodicVestingAccount": {
56
56
  var baseAccount = (_g = (_f = vesting_1.PeriodicVestingAccount.decode(value)) === null || _f === void 0 ? void 0 : _f.baseVestingAccount) === null || _g === void 0 ? void 0 : _g.baseAccount;
57
- utils_1.assert(baseAccount);
57
+ (0, utils_1.assert)(baseAccount);
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;
@@ -10,8 +10,8 @@ function fromTendermintEvent(event) {
10
10
  return {
11
11
  type: event.type,
12
12
  attributes: event.attributes.map(function (attr) { return ({
13
- key: typeof attr.key == "string" ? attr.key : encoding_1.fromUtf8(attr.key, true),
14
- value: typeof attr.value == "string" ? attr.value : encoding_1.fromUtf8(attr.value, true),
13
+ key: typeof attr.key == "string" ? attr.key : (0, encoding_1.fromUtf8)(attr.key, true),
14
+ value: typeof attr.value == "string" ? attr.value : (0, encoding_1.fromUtf8)(attr.value, true),
15
15
  }); }),
16
16
  };
17
17
  }
@@ -1,5 +1,5 @@
1
- import { StdFee } from "@cosmjs/amino";
2
1
  import { Decimal } from "@cosmjs/math";
2
+ import { Fee } from "cosmjs-types/cosmos/tx/v1beta1/tx";
3
3
  /**
4
4
  * A gas price, i.e. the price of a single unit of gas. This is typically a fraction of
5
5
  * the smallest fee token unit, such as 0.012utoken.
@@ -23,4 +23,4 @@ export declare class GasPrice {
23
23
  */
24
24
  toString(): string;
25
25
  }
26
- export declare function calculateFee(gasLimit: number, gasPrice: GasPrice | string): StdFee;
26
+ export declare function calculateFee(gasLimit: number, gasPrice: GasPrice | string): Fee;
@@ -76,8 +76,10 @@ function calculateFee(gasLimit, gasPrice) {
76
76
  // which we handle by converting from Decimal to string without going through number.
77
77
  var amount = gasPriceAmount.multiply(new math_1.Uint53(gasLimit)).ceil().toString();
78
78
  return {
79
- amount: proto_signing_1.coins(amount, denom),
80
- gas: gasLimit.toString(),
79
+ gasLimit: BigInt(gasLimit),
80
+ amount: (0, proto_signing_1.coins)(amount, denom),
81
+ payer: "",
82
+ granter: ""
81
83
  };
82
84
  }
83
85
  exports.calculateFee = calculateFee;
@@ -1,3 +1,2 @@
1
1
  export * from './TxCommon';
2
2
  export * from './QueryCommon';
3
- export { AminoConverter, AminoConverters, AminoTypes } from "./aminotypes";
@@ -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];
@@ -10,8 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.AminoTypes = void 0;
14
17
  __exportStar(require("./TxCommon"), exports);
15
18
  __exportStar(require("./QueryCommon"), exports);
16
- var aminotypes_1 = require("./aminotypes");
17
- Object.defineProperty(exports, "AminoTypes", { enumerable: true, get: function () { return aminotypes_1.AminoTypes; } });
@@ -2,14 +2,18 @@ import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
2
2
  import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
3
3
  import { SignDoc } from "cosmjs-types/cosmos/tx/v1beta1/tx";
4
4
  import { Any } from "cosmjs-types/google/protobuf/any";
5
- /**
6
- * Creates and serializes an AuthInfo document.
7
- *
8
- * This implementation does not support different signing modes for the different signers.
9
- */
10
- export declare function makeAuthInfoBytes(signers: ReadonlyArray<{
5
+ export interface SignerData {
11
6
  readonly pubkey: Any;
12
- readonly sequence: bigint | number;
13
- }>, feeAmount: readonly Coin[], gasLimit: number, feeGranter: string | undefined, feePayer: string | undefined, signMode?: SignMode): Uint8Array;
7
+ readonly sequence: number;
8
+ }
9
+ export declare function makeAuthInfoBytes(signers: ReadonlyArray<SignerData>, feeAmount: readonly Coin[], gasLimit: number, granter?: string, payer?: string, signMode?: SignMode): Uint8Array;
14
10
  export declare function makeSignDoc(bodyBytes: Uint8Array, authInfoBytes: Uint8Array, chainId: string, accountNumber: number): SignDoc;
15
- export declare function makeSignBytes({ accountNumber, authInfoBytes, bodyBytes, chainId }: SignDoc): Uint8Array;
11
+ export declare function makeSignBytes(signDoc: SignDoc): Uint8Array;
12
+ /**
13
+ * Creates AuthInfo bytes for protobuf signing with enhanced type safety
14
+ */
15
+ export declare function makeAuthInfoBytesProtobuf(signers: ReadonlyArray<SignerData>, feeAmount: readonly Coin[], gasLimit: bigint | number, granter?: string, payer?: string): Uint8Array;
16
+ /**
17
+ * Creates a protobuf SignDoc with validation
18
+ */
19
+ export declare function makeSignDocProtobuf(bodyBytes: Uint8Array, authInfoBytes: Uint8Array, chainId: string, accountNumber: bigint | number): SignDoc;