@firmachain/firma-js 0.2.27 → 0.2.30

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 (155) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.js +16 -0
  3. package/dist/sdk/FirmaBankService.d.ts +16 -0
  4. package/dist/sdk/FirmaBankService.js +233 -0
  5. package/dist/sdk/FirmaChainService.d.ts +8 -0
  6. package/dist/sdk/FirmaChainService.js +86 -0
  7. package/dist/sdk/FirmaConfig.d.ts +18 -0
  8. package/dist/sdk/FirmaConfig.js +63 -0
  9. package/dist/sdk/FirmaContractService.d.ts +31 -0
  10. package/dist/sdk/FirmaContractService.js +413 -0
  11. package/dist/sdk/FirmaDistributionService.d.ts +31 -0
  12. package/dist/sdk/FirmaDistributionService.js +524 -0
  13. package/dist/sdk/FirmaFeeGrantService.d.ts +21 -0
  14. package/dist/sdk/FirmaFeeGrantService.js +341 -0
  15. package/dist/sdk/FirmaGovService.d.ts +35 -0
  16. package/dist/sdk/FirmaGovService.js +775 -0
  17. package/dist/sdk/FirmaIpfsService.d.ts +12 -0
  18. package/dist/sdk/FirmaIpfsService.js +185 -0
  19. package/dist/sdk/FirmaMobileSDK.d.ts +27 -0
  20. package/dist/sdk/FirmaMobileSDK.js +45 -0
  21. package/dist/sdk/FirmaNftService.d.ts +31 -0
  22. package/dist/sdk/FirmaNftService.js +372 -0
  23. package/dist/sdk/FirmaSDK.d.ts +29 -0
  24. package/dist/sdk/FirmaSDK.js +48 -0
  25. package/dist/sdk/FirmaSlashingService.d.ts +9 -0
  26. package/dist/sdk/FirmaSlashingService.js +105 -0
  27. package/dist/sdk/FirmaStakingService.d.ts +34 -0
  28. package/dist/sdk/FirmaStakingService.js +604 -0
  29. package/dist/sdk/FirmaTokenService.d.ts +26 -0
  30. package/dist/sdk/FirmaTokenService.js +416 -0
  31. package/dist/sdk/FirmaUtil.d.ts +37 -0
  32. package/dist/sdk/FirmaUtil.js +232 -0
  33. package/dist/sdk/FirmaWalletService.d.ts +36 -0
  34. package/dist/sdk/FirmaWalletService.js +309 -0
  35. package/dist/sdk/firmachain/amino/addresses.d.ts +5 -0
  36. package/dist/sdk/firmachain/amino/addresses.js +46 -0
  37. package/dist/sdk/firmachain/amino/aminomsgs.d.ts +281 -0
  38. package/dist/sdk/firmachain/amino/aminomsgs.js +77 -0
  39. package/dist/sdk/firmachain/amino/aminotypes.d.ts +22 -0
  40. package/dist/sdk/firmachain/amino/aminotypes.js +521 -0
  41. package/dist/sdk/firmachain/amino/coins.d.ts +30 -0
  42. package/dist/sdk/firmachain/amino/coins.js +69 -0
  43. package/dist/sdk/firmachain/amino/encoding.d.ts +24 -0
  44. package/dist/sdk/firmachain/amino/encoding.js +234 -0
  45. package/dist/sdk/firmachain/amino/multisig.d.ts +10 -0
  46. package/dist/sdk/firmachain/amino/multisig.js +42 -0
  47. package/dist/sdk/firmachain/amino/paths.d.ts +6 -0
  48. package/dist/sdk/firmachain/amino/paths.js +18 -0
  49. package/dist/sdk/firmachain/amino/pubkeys.d.ts +47 -0
  50. package/dist/sdk/firmachain/amino/pubkeys.js +29 -0
  51. package/dist/sdk/firmachain/amino/secp256k1hdwallet.d.ts +94 -0
  52. package/dist/sdk/firmachain/amino/secp256k1hdwallet.js +437 -0
  53. package/dist/sdk/firmachain/amino/secp256k1wallet.d.ts +23 -0
  54. package/dist/sdk/firmachain/amino/secp256k1wallet.js +141 -0
  55. package/dist/sdk/firmachain/amino/signature.d.ts +16 -0
  56. package/dist/sdk/firmachain/amino/signature.js +36 -0
  57. package/dist/sdk/firmachain/amino/signdoc.d.ts +26 -0
  58. package/dist/sdk/firmachain/amino/signdoc.js +42 -0
  59. package/dist/sdk/firmachain/amino/signer.d.ts +33 -0
  60. package/dist/sdk/firmachain/amino/signer.js +2 -0
  61. package/dist/sdk/firmachain/amino/stdtx.d.ts +15 -0
  62. package/dist/sdk/firmachain/amino/stdtx.js +17 -0
  63. package/dist/sdk/firmachain/amino/wallet.d.ts +32 -0
  64. package/dist/sdk/firmachain/amino/wallet.js +132 -0
  65. package/dist/sdk/firmachain/bank/BankQueryClient.d.ts +12 -0
  66. package/dist/sdk/firmachain/bank/BankQueryClient.js +116 -0
  67. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +17 -0
  68. package/dist/sdk/firmachain/bank/BankTxClient.js +40 -0
  69. package/dist/sdk/firmachain/bank/index.d.ts +3 -0
  70. package/dist/sdk/firmachain/bank/index.js +15 -0
  71. package/dist/sdk/firmachain/common/ITxClient.d.ts +15 -0
  72. package/dist/sdk/firmachain/common/ITxClient.js +102 -0
  73. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +27 -0
  74. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +165 -0
  75. package/dist/sdk/firmachain/common/LedgerWallet.d.ts +14 -0
  76. package/dist/sdk/firmachain/common/LedgerWallet.js +147 -0
  77. package/dist/sdk/firmachain/common/QueryCommon.d.ts +4 -0
  78. package/dist/sdk/firmachain/common/QueryCommon.js +2 -0
  79. package/dist/sdk/firmachain/common/TendermintQueryClient.d.ts +42 -0
  80. package/dist/sdk/firmachain/common/TendermintQueryClient.js +111 -0
  81. package/dist/sdk/firmachain/common/TxCommon.d.ts +87 -0
  82. package/dist/sdk/firmachain/common/TxCommon.js +18 -0
  83. package/dist/sdk/firmachain/common/accounts.d.ts +16 -0
  84. package/dist/sdk/firmachain/common/accounts.js +64 -0
  85. package/dist/sdk/firmachain/common/index.d.ts +2 -0
  86. package/dist/sdk/firmachain/common/index.js +14 -0
  87. package/dist/sdk/firmachain/common/signing.d.ts +10 -0
  88. package/dist/sdk/firmachain/common/signing.js +75 -0
  89. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +37 -0
  90. package/dist/sdk/firmachain/common/signingstargateclient.js +298 -0
  91. package/dist/sdk/firmachain/common/stargateclient.d.ts +46 -0
  92. package/dist/sdk/firmachain/common/stargateclient.js +211 -0
  93. package/dist/sdk/firmachain/contract/ContractQueryClient.d.ts +32 -0
  94. package/dist/sdk/firmachain/contract/ContractQueryClient.js +156 -0
  95. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +17 -0
  96. package/dist/sdk/firmachain/contract/ContractTxClient.js +40 -0
  97. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +69 -0
  98. package/dist/sdk/firmachain/contract/ContractTxTypes.js +483 -0
  99. package/dist/sdk/firmachain/contract/index.d.ts +3 -0
  100. package/dist/sdk/firmachain/contract/index.js +15 -0
  101. package/dist/sdk/firmachain/distribution/DistributionQueryClient.d.ts +18 -0
  102. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +167 -0
  103. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +27 -0
  104. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +48 -0
  105. package/dist/sdk/firmachain/distribution/index.d.ts +3 -0
  106. package/dist/sdk/firmachain/distribution/index.js +15 -0
  107. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.d.ts +17 -0
  108. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +86 -0
  109. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +17 -0
  110. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +40 -0
  111. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +76 -0
  112. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +194 -0
  113. package/dist/sdk/firmachain/feegrant/index.d.ts +2 -0
  114. package/dist/sdk/firmachain/feegrant/index.js +15 -0
  115. package/dist/sdk/firmachain/google/protobuf/any.d.ts +128 -0
  116. package/dist/sdk/firmachain/google/protobuf/any.js +106 -0
  117. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +996 -0
  118. package/dist/sdk/firmachain/google/protobuf/descriptor.js +5329 -0
  119. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +91 -0
  120. package/dist/sdk/firmachain/google/protobuf/duration.js +107 -0
  121. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +109 -0
  122. package/dist/sdk/firmachain/google/protobuf/timestamp.js +107 -0
  123. package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +61 -0
  124. package/dist/sdk/firmachain/gov/GovQueryClient.js +152 -0
  125. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +22 -0
  126. package/dist/sdk/firmachain/gov/GovTxClient.js +44 -0
  127. package/dist/sdk/firmachain/gov/index.d.ts +3 -0
  128. package/dist/sdk/firmachain/gov/index.js +15 -0
  129. package/dist/sdk/firmachain/nft/NftQueryClient.d.ts +20 -0
  130. package/dist/sdk/firmachain/nft/NftQueryClient.js +125 -0
  131. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +22 -0
  132. package/dist/sdk/firmachain/nft/NftTxClient.js +44 -0
  133. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +86 -0
  134. package/dist/sdk/firmachain/nft/NftTxTypes.js +424 -0
  135. package/dist/sdk/firmachain/nft/index.d.ts +3 -0
  136. package/dist/sdk/firmachain/nft/index.js +15 -0
  137. package/dist/sdk/firmachain/slashing/SlashingQueryClient.d.ts +22 -0
  138. package/dist/sdk/firmachain/slashing/SlashingQueryClient.js +101 -0
  139. package/dist/sdk/firmachain/slashing/index.d.ts +2 -0
  140. package/dist/sdk/firmachain/slashing/index.js +14 -0
  141. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +93 -0
  142. package/dist/sdk/firmachain/staking/StakingQueryClient.js +223 -0
  143. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +32 -0
  144. package/dist/sdk/firmachain/staking/StakingTxClient.js +52 -0
  145. package/dist/sdk/firmachain/staking/index.d.ts +3 -0
  146. package/dist/sdk/firmachain/staking/index.js +15 -0
  147. package/dist/sdk/firmachain/token/TokenQueryClient.d.ts +24 -0
  148. package/dist/sdk/firmachain/token/TokenQueryClient.js +106 -0
  149. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +27 -0
  150. package/dist/sdk/firmachain/token/TokenTxClient.js +48 -0
  151. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +116 -0
  152. package/dist/sdk/firmachain/token/TokenTxTypes.js +685 -0
  153. package/dist/sdk/firmachain/token/index.d.ts +3 -0
  154. package/dist/sdk/firmachain/token/index.js +15 -0
  155. package/package.json +1 -1
@@ -0,0 +1,521 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __read = (this && this.__read) || function (o, n) {
14
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15
+ if (!m) return o;
16
+ var i = m.call(o), r, ar = [], e;
17
+ try {
18
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
+ }
20
+ catch (error) { e = { error: error }; }
21
+ finally {
22
+ try {
23
+ if (r && !r.done && (m = i["return"])) m.call(i);
24
+ }
25
+ finally { if (e) throw e.error; }
26
+ }
27
+ return ar;
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;
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.AminoTypes = void 0;
39
+ var encoding_1 = require("@cosmjs/encoding");
40
+ var utils_1 = require("@cosmjs/utils");
41
+ var gov_1 = require("cosmjs-types/cosmos/gov/v1beta1/gov");
42
+ var any_1 = require("cosmjs-types/google/protobuf/any");
43
+ var long_1 = __importDefault(require("long"));
44
+ var encoding_2 = require("./encoding");
45
+ function omitDefault(input) {
46
+ if (typeof input === "string") {
47
+ return input === "" ? undefined : input;
48
+ }
49
+ if (typeof input === "number") {
50
+ return input === 0 ? undefined : input;
51
+ }
52
+ if (long_1.default.isLong(input)) {
53
+ return input.isZero() ? undefined : input;
54
+ }
55
+ throw new Error("Got unsupported type '" + typeof input + "'");
56
+ }
57
+ function createDefaultTypes(prefix) {
58
+ return {
59
+ // bank
60
+ "/cosmos.bank.v1beta1.MsgSend": {
61
+ aminoType: "cosmos-sdk/MsgSend",
62
+ toAmino: function (_a) {
63
+ var fromAddress = _a.fromAddress, toAddress = _a.toAddress, amount = _a.amount;
64
+ return ({
65
+ from_address: fromAddress,
66
+ to_address: toAddress,
67
+ amount: __spreadArray([], __read(amount)),
68
+ });
69
+ },
70
+ fromAmino: function (_a) {
71
+ var from_address = _a.from_address, to_address = _a.to_address, amount = _a.amount;
72
+ return ({
73
+ fromAddress: from_address,
74
+ toAddress: to_address,
75
+ amount: __spreadArray([], __read(amount)),
76
+ });
77
+ },
78
+ },
79
+ "/cosmos.bank.v1beta1.MsgMultiSend": {
80
+ aminoType: "cosmos-sdk/MsgMultiSend",
81
+ toAmino: function (_a) {
82
+ var inputs = _a.inputs, outputs = _a.outputs;
83
+ return ({
84
+ inputs: inputs.map(function (input) { return ({
85
+ address: input.address,
86
+ coins: __spreadArray([], __read(input.coins)),
87
+ }); }),
88
+ outputs: outputs.map(function (output) { return ({
89
+ address: output.address,
90
+ coins: __spreadArray([], __read(output.coins)),
91
+ }); }),
92
+ });
93
+ },
94
+ fromAmino: function (_a) {
95
+ var inputs = _a.inputs, outputs = _a.outputs;
96
+ return ({
97
+ inputs: inputs.map(function (input) { return ({
98
+ address: input.address,
99
+ coins: __spreadArray([], __read(input.coins)),
100
+ }); }),
101
+ outputs: outputs.map(function (output) { return ({
102
+ address: output.address,
103
+ coins: __spreadArray([], __read(output.coins)),
104
+ }); }),
105
+ });
106
+ },
107
+ },
108
+ // distribution
109
+ "/cosmos.distribution.v1beta1.MsgFundCommunityPool": {
110
+ aminoType: "cosmos-sdk/MsgFundCommunityPool",
111
+ toAmino: function (_a) {
112
+ var amount = _a.amount, depositor = _a.depositor;
113
+ return ({
114
+ amount: __spreadArray([], __read(amount)),
115
+ depositor: depositor,
116
+ });
117
+ },
118
+ fromAmino: function (_a) {
119
+ var amount = _a.amount, depositor = _a.depositor;
120
+ return ({
121
+ amount: __spreadArray([], __read(amount)),
122
+ depositor: depositor,
123
+ });
124
+ },
125
+ },
126
+ "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress": {
127
+ aminoType: "cosmos-sdk/MsgModifyWithdrawAddress",
128
+ toAmino: function (_a) {
129
+ var delegatorAddress = _a.delegatorAddress, withdrawAddress = _a.withdrawAddress;
130
+ return ({
131
+ delegator_address: delegatorAddress,
132
+ withdraw_address: withdrawAddress,
133
+ });
134
+ },
135
+ fromAmino: function (_a) {
136
+ var delegator_address = _a.delegator_address, withdraw_address = _a.withdraw_address;
137
+ return ({
138
+ delegatorAddress: delegator_address,
139
+ withdrawAddress: withdraw_address,
140
+ });
141
+ },
142
+ },
143
+ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward": {
144
+ aminoType: "cosmos-sdk/MsgWithdrawDelegationReward",
145
+ toAmino: function (_a) {
146
+ var delegatorAddress = _a.delegatorAddress, validatorAddress = _a.validatorAddress;
147
+ return ({
148
+ delegator_address: delegatorAddress,
149
+ validator_address: validatorAddress,
150
+ });
151
+ },
152
+ fromAmino: function (_a) {
153
+ var delegator_address = _a.delegator_address, validator_address = _a.validator_address;
154
+ return ({
155
+ delegatorAddress: delegator_address,
156
+ validatorAddress: validator_address,
157
+ });
158
+ },
159
+ },
160
+ "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission": {
161
+ aminoType: "cosmos-sdk/MsgWithdrawValidatorCommission",
162
+ toAmino: function (_a) {
163
+ var validatorAddress = _a.validatorAddress;
164
+ return ({
165
+ validator_address: validatorAddress,
166
+ });
167
+ },
168
+ fromAmino: function (_a) {
169
+ var validator_address = _a.validator_address;
170
+ return ({
171
+ validatorAddress: validator_address,
172
+ });
173
+ },
174
+ },
175
+ // gov
176
+ "/cosmos.gov.v1beta1.MsgDeposit": {
177
+ aminoType: "cosmos-sdk/MsgDeposit",
178
+ toAmino: function (_a) {
179
+ var amount = _a.amount, depositor = _a.depositor, proposalId = _a.proposalId;
180
+ return {
181
+ amount: amount,
182
+ depositor: depositor,
183
+ proposal_id: proposalId.toString(),
184
+ };
185
+ },
186
+ fromAmino: function (_a) {
187
+ var amount = _a.amount, depositor = _a.depositor, proposal_id = _a.proposal_id;
188
+ return {
189
+ amount: Array.from(amount),
190
+ depositor: depositor,
191
+ proposalId: long_1.default.fromString(proposal_id),
192
+ };
193
+ },
194
+ },
195
+ "/cosmos.gov.v1beta1.MsgVote": {
196
+ aminoType: "cosmos-sdk/MsgVote",
197
+ toAmino: function (_a) {
198
+ var option = _a.option, proposalId = _a.proposalId, voter = _a.voter;
199
+ return {
200
+ option: option,
201
+ proposal_id: proposalId.toString(),
202
+ voter: voter,
203
+ };
204
+ },
205
+ fromAmino: function (_a) {
206
+ var option = _a.option, proposal_id = _a.proposal_id, voter = _a.voter;
207
+ return {
208
+ option: gov_1.voteOptionFromJSON(option),
209
+ proposalId: long_1.default.fromString(proposal_id),
210
+ voter: voter,
211
+ };
212
+ },
213
+ },
214
+ "/cosmos.gov.v1beta1.MsgSubmitProposal": {
215
+ aminoType: "cosmos-sdk/MsgSubmitProposal",
216
+ toAmino: function (_a) {
217
+ var initialDeposit = _a.initialDeposit, proposer = _a.proposer, content = _a.content;
218
+ utils_1.assertDefinedAndNotNull(content);
219
+ var proposal;
220
+ switch (content.typeUrl) {
221
+ case "/cosmos.gov.v1beta1.TextProposal": {
222
+ var textProposal = gov_1.TextProposal.decode(content.value);
223
+ proposal = {
224
+ type: "cosmos-sdk/TextProposal",
225
+ value: {
226
+ description: textProposal.description,
227
+ title: textProposal.title,
228
+ },
229
+ };
230
+ break;
231
+ }
232
+ default:
233
+ throw new Error("Unsupported proposal type: '" + content.typeUrl + "'");
234
+ }
235
+ return {
236
+ initial_deposit: initialDeposit,
237
+ proposer: proposer,
238
+ content: proposal,
239
+ };
240
+ },
241
+ fromAmino: function (_a) {
242
+ var initial_deposit = _a.initial_deposit, proposer = _a.proposer, content = _a.content;
243
+ var any_content;
244
+ switch (content.type) {
245
+ case "cosmos-sdk/TextProposal": {
246
+ var value = content.value;
247
+ utils_1.assert(utils_1.isNonNullObject(value));
248
+ var _b = value, title = _b.title, description = _b.description;
249
+ utils_1.assert(typeof title === "string");
250
+ utils_1.assert(typeof description === "string");
251
+ any_content = any_1.Any.fromPartial({
252
+ typeUrl: "/cosmos.gov.v1beta1.TextProposal",
253
+ value: gov_1.TextProposal.encode(gov_1.TextProposal.fromPartial({
254
+ title: title,
255
+ description: description,
256
+ })).finish(),
257
+ });
258
+ break;
259
+ }
260
+ default:
261
+ throw new Error("Unsupported proposal type: '" + content.type + "'");
262
+ }
263
+ return {
264
+ initialDeposit: Array.from(initial_deposit),
265
+ proposer: proposer,
266
+ content: any_content,
267
+ };
268
+ },
269
+ },
270
+ // staking
271
+ "/cosmos.staking.v1beta1.MsgBeginRedelegate": {
272
+ aminoType: "cosmos-sdk/MsgBeginRedelegate",
273
+ toAmino: function (_a) {
274
+ var delegatorAddress = _a.delegatorAddress, validatorSrcAddress = _a.validatorSrcAddress, validatorDstAddress = _a.validatorDstAddress, amount = _a.amount;
275
+ utils_1.assertDefinedAndNotNull(amount, "missing amount");
276
+ return {
277
+ delegator_address: delegatorAddress,
278
+ validator_src_address: validatorSrcAddress,
279
+ validator_dst_address: validatorDstAddress,
280
+ amount: amount,
281
+ };
282
+ },
283
+ fromAmino: function (_a) {
284
+ var delegator_address = _a.delegator_address, validator_src_address = _a.validator_src_address, validator_dst_address = _a.validator_dst_address, amount = _a.amount;
285
+ return ({
286
+ delegatorAddress: delegator_address,
287
+ validatorSrcAddress: validator_src_address,
288
+ validatorDstAddress: validator_dst_address,
289
+ amount: amount,
290
+ });
291
+ },
292
+ },
293
+ "/cosmos.staking.v1beta1.MsgCreateValidator": {
294
+ aminoType: "cosmos-sdk/MsgCreateValidator",
295
+ toAmino: function (_a) {
296
+ 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
+ return {
302
+ description: {
303
+ moniker: description.moniker,
304
+ identity: description.identity,
305
+ website: description.website,
306
+ security_contact: description.securityContact,
307
+ details: description.details,
308
+ },
309
+ commission: {
310
+ rate: commission.rate,
311
+ max_rate: commission.maxRate,
312
+ max_change_rate: commission.maxChangeRate,
313
+ },
314
+ min_self_delegation: minSelfDelegation,
315
+ delegator_address: delegatorAddress,
316
+ validator_address: validatorAddress,
317
+ pubkey: encoding_2.encodeBech32Pubkey({
318
+ type: "tendermint/PubKeySecp256k1",
319
+ value: encoding_1.toBase64(pubkey.value),
320
+ }, prefix),
321
+ value: value,
322
+ };
323
+ },
324
+ fromAmino: function (_a) {
325
+ var description = _a.description, commission = _a.commission, min_self_delegation = _a.min_self_delegation, delegator_address = _a.delegator_address, validator_address = _a.validator_address, pubkey = _a.pubkey, value = _a.value;
326
+ var decodedPubkey = encoding_2.decodeBech32Pubkey(pubkey);
327
+ if (decodedPubkey.type !== "tendermint/PubKeySecp256k1") {
328
+ throw new Error("Only Secp256k1 public keys are supported");
329
+ }
330
+ return {
331
+ description: {
332
+ moniker: description.moniker,
333
+ identity: description.identity,
334
+ website: description.website,
335
+ securityContact: description.security_contact,
336
+ details: description.details,
337
+ },
338
+ commission: {
339
+ rate: commission.rate,
340
+ maxRate: commission.max_rate,
341
+ maxChangeRate: commission.max_change_rate,
342
+ },
343
+ minSelfDelegation: min_self_delegation,
344
+ delegatorAddress: delegator_address,
345
+ validatorAddress: validator_address,
346
+ pubkey: {
347
+ typeUrl: "/cosmos.crypto.secp256k1.PubKey",
348
+ value: encoding_1.fromBase64(decodedPubkey.value),
349
+ },
350
+ value: value,
351
+ };
352
+ },
353
+ },
354
+ "/cosmos.staking.v1beta1.MsgDelegate": {
355
+ aminoType: "cosmos-sdk/MsgDelegate",
356
+ toAmino: function (_a) {
357
+ var delegatorAddress = _a.delegatorAddress, validatorAddress = _a.validatorAddress, amount = _a.amount;
358
+ utils_1.assertDefinedAndNotNull(amount, "missing amount");
359
+ return {
360
+ delegator_address: delegatorAddress,
361
+ validator_address: validatorAddress,
362
+ amount: amount,
363
+ };
364
+ },
365
+ fromAmino: function (_a) {
366
+ var delegator_address = _a.delegator_address, validator_address = _a.validator_address, amount = _a.amount;
367
+ return ({
368
+ delegatorAddress: delegator_address,
369
+ validatorAddress: validator_address,
370
+ amount: amount,
371
+ });
372
+ },
373
+ },
374
+ "/cosmos.staking.v1beta1.MsgEditValidator": {
375
+ aminoType: "cosmos-sdk/MsgEditValidator",
376
+ toAmino: function (_a) {
377
+ var description = _a.description, commissionRate = _a.commissionRate, minSelfDelegation = _a.minSelfDelegation, validatorAddress = _a.validatorAddress;
378
+ utils_1.assertDefinedAndNotNull(description, "missing description");
379
+ return {
380
+ description: {
381
+ moniker: description.moniker,
382
+ identity: description.identity,
383
+ website: description.website,
384
+ security_contact: description.securityContact,
385
+ details: description.details,
386
+ },
387
+ commission_rate: commissionRate,
388
+ min_self_delegation: minSelfDelegation,
389
+ validator_address: validatorAddress,
390
+ };
391
+ },
392
+ fromAmino: function (_a) {
393
+ var description = _a.description, commission_rate = _a.commission_rate, min_self_delegation = _a.min_self_delegation, validator_address = _a.validator_address;
394
+ return ({
395
+ description: {
396
+ moniker: description.moniker,
397
+ identity: description.identity,
398
+ website: description.website,
399
+ securityContact: description.security_contact,
400
+ details: description.details,
401
+ },
402
+ commissionRate: commission_rate,
403
+ minSelfDelegation: min_self_delegation,
404
+ validatorAddress: validator_address,
405
+ });
406
+ },
407
+ },
408
+ "/cosmos.staking.v1beta1.MsgUndelegate": {
409
+ aminoType: "cosmos-sdk/MsgUndelegate",
410
+ toAmino: function (_a) {
411
+ var delegatorAddress = _a.delegatorAddress, validatorAddress = _a.validatorAddress, amount = _a.amount;
412
+ utils_1.assertDefinedAndNotNull(amount, "missing amount");
413
+ return {
414
+ delegator_address: delegatorAddress,
415
+ validator_address: validatorAddress,
416
+ amount: amount,
417
+ };
418
+ },
419
+ fromAmino: function (_a) {
420
+ var delegator_address = _a.delegator_address, validator_address = _a.validator_address, amount = _a.amount;
421
+ return ({
422
+ delegatorAddress: delegator_address,
423
+ validatorAddress: validator_address,
424
+ amount: amount,
425
+ });
426
+ },
427
+ },
428
+ // ibc
429
+ "/ibc.applications.transfer.v1.MsgTransfer": {
430
+ aminoType: "cosmos-sdk/MsgTransfer",
431
+ toAmino: function (_a) {
432
+ var _b, _c, _d;
433
+ var sourcePort = _a.sourcePort, sourceChannel = _a.sourceChannel, token = _a.token, sender = _a.sender, receiver = _a.receiver, timeoutHeight = _a.timeoutHeight, timeoutTimestamp = _a.timeoutTimestamp;
434
+ return ({
435
+ source_port: sourcePort,
436
+ source_channel: sourceChannel,
437
+ token: token,
438
+ sender: sender,
439
+ receiver: receiver,
440
+ timeout_height: timeoutHeight
441
+ ? {
442
+ revision_height: (_b = omitDefault(timeoutHeight.revisionHeight)) === null || _b === void 0 ? void 0 : _b.toString(),
443
+ revision_number: (_c = omitDefault(timeoutHeight.revisionNumber)) === null || _c === void 0 ? void 0 : _c.toString(),
444
+ }
445
+ : {},
446
+ timeout_timestamp: (_d = omitDefault(timeoutTimestamp)) === null || _d === void 0 ? void 0 : _d.toString(),
447
+ });
448
+ },
449
+ fromAmino: function (_a) {
450
+ var source_port = _a.source_port, source_channel = _a.source_channel, token = _a.token, sender = _a.sender, receiver = _a.receiver, timeout_height = _a.timeout_height, timeout_timestamp = _a.timeout_timestamp;
451
+ return ({
452
+ sourcePort: source_port,
453
+ sourceChannel: source_channel,
454
+ token: token,
455
+ sender: sender,
456
+ receiver: receiver,
457
+ timeoutHeight: timeout_height
458
+ ? {
459
+ revisionHeight: long_1.default.fromString(timeout_height.revision_height || "0", true),
460
+ revisionNumber: long_1.default.fromString(timeout_height.revision_number || "0", true),
461
+ }
462
+ : undefined,
463
+ timeoutTimestamp: long_1.default.fromString(timeout_timestamp || "0", true),
464
+ });
465
+ },
466
+ },
467
+ };
468
+ }
469
+ /**
470
+ * A map from Stargate message types as used in the messages's `Any` type
471
+ * to Amino types.
472
+ */
473
+ var AminoTypes = /** @class */ (function () {
474
+ function AminoTypes(_a) {
475
+ var _b = _a === void 0 ? {} : _a, _c = _b.additions, additions = _c === void 0 ? {} : _c, _d = _b.prefix, prefix = _d === void 0 ? "cosmos" : _d;
476
+ var additionalAminoTypes = Object.values(additions);
477
+ var filteredDefaultTypes = Object.entries(createDefaultTypes(prefix)).reduce(function (acc, _a) {
478
+ var _b;
479
+ var _c = __read(_a, 2), key = _c[0], value = _c[1];
480
+ return additionalAminoTypes.find(function (_a) {
481
+ var aminoType = _a.aminoType;
482
+ return value.aminoType === aminoType;
483
+ })
484
+ ? acc
485
+ : __assign(__assign({}, acc), (_b = {}, _b[key] = value, _b));
486
+ }, {});
487
+ this.register = __assign(__assign({}, filteredDefaultTypes), additions);
488
+ }
489
+ AminoTypes.prototype.toAmino = function (_a) {
490
+ var typeUrl = _a.typeUrl, value = _a.value;
491
+ var converter = this.register[typeUrl];
492
+ if (!converter) {
493
+ throw new Error("Type URL does not exist in the Amino message type register. " +
494
+ "If you need support for this message type, you can pass in additional entries to the AminoTypes constructor. " +
495
+ "If you think this message type should be included by default, please open an issue at https://github.com/cosmos/cosmjs/issues.");
496
+ }
497
+ return {
498
+ type: converter.aminoType,
499
+ value: converter.toAmino(value),
500
+ };
501
+ };
502
+ AminoTypes.prototype.fromAmino = function (_a) {
503
+ var type = _a.type, value = _a.value;
504
+ var result = Object.entries(this.register).find(function (_a) {
505
+ var _b = __read(_a, 2), _typeUrl = _b[0], aminoType = _b[1].aminoType;
506
+ return aminoType === type;
507
+ });
508
+ if (!result) {
509
+ throw new Error("Type does not exist in the Amino message type register. " +
510
+ "If you need support for this message type, you can pass in additional entries to the AminoTypes constructor. " +
511
+ "If you think this message type should be included by default, please open an issue at https://github.com/cosmos/cosmjs/issues.");
512
+ }
513
+ var _b = __read(result, 2), typeUrl = _b[0], converter = _b[1];
514
+ return {
515
+ typeUrl: typeUrl,
516
+ value: converter.fromAmino(value),
517
+ };
518
+ };
519
+ return AminoTypes;
520
+ }());
521
+ exports.AminoTypes = AminoTypes;
@@ -0,0 +1,30 @@
1
+ export interface Coin {
2
+ readonly denom: string;
3
+ readonly amount: string;
4
+ }
5
+ /**
6
+ * Creates a coin.
7
+ *
8
+ * If your values do not exceed the safe integer range of JS numbers (53 bit),
9
+ * you can use the number type here. This is the case for all typical Cosmos SDK
10
+ * chains that use the default 6 decimals.
11
+ *
12
+ * In case you need to supportr larger values, use unsigned integer strings instead.
13
+ */
14
+ export declare function coin(amount: number | string, denom: string): Coin;
15
+ /**
16
+ * Creates a list of coins with one element.
17
+ */
18
+ export declare function coins(amount: number | string, denom: string): Coin[];
19
+ /**
20
+ * Takes a coins list like "819966000ucosm,700000000ustake" and parses it.
21
+ *
22
+ * A Stargate-ready variant of this function is available via:
23
+ *
24
+ * ```
25
+ * import { parseCoins } from "@cosmjs/proto-signing";
26
+ * // or
27
+ * import { parseCoins } from "@cosmjs/stargate";
28
+ * ```
29
+ */
30
+ export declare function parseCoins(input: string): Coin[];
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCoins = exports.coins = exports.coin = void 0;
4
+ var math_1 = require("@cosmjs/math");
5
+ /**
6
+ * Creates a coin.
7
+ *
8
+ * If your values do not exceed the safe integer range of JS numbers (53 bit),
9
+ * you can use the number type here. This is the case for all typical Cosmos SDK
10
+ * chains that use the default 6 decimals.
11
+ *
12
+ * In case you need to supportr larger values, use unsigned integer strings instead.
13
+ */
14
+ function coin(amount, denom) {
15
+ var outAmount;
16
+ if (typeof amount === "number") {
17
+ try {
18
+ outAmount = new math_1.Uint53(amount).toString();
19
+ }
20
+ catch (_err) {
21
+ throw new Error("Given amount is not a safe integer. Consider using a string instead to overcome the limitations of JS numbers.");
22
+ }
23
+ }
24
+ else {
25
+ if (!amount.match(/^[0-9]+$/)) {
26
+ throw new Error("Invalid unsigned integer string format");
27
+ }
28
+ outAmount = amount.replace(/^0*/, "") || "0";
29
+ }
30
+ return {
31
+ amount: outAmount,
32
+ denom: denom,
33
+ };
34
+ }
35
+ exports.coin = coin;
36
+ /**
37
+ * Creates a list of coins with one element.
38
+ */
39
+ function coins(amount, denom) {
40
+ return [coin(amount, denom)];
41
+ }
42
+ exports.coins = coins;
43
+ /**
44
+ * Takes a coins list like "819966000ucosm,700000000ustake" and parses it.
45
+ *
46
+ * A Stargate-ready variant of this function is available via:
47
+ *
48
+ * ```
49
+ * import { parseCoins } from "@cosmjs/proto-signing";
50
+ * // or
51
+ * import { parseCoins } from "@cosmjs/stargate";
52
+ * ```
53
+ */
54
+ function parseCoins(input) {
55
+ return input
56
+ .replace(/\s/g, "")
57
+ .split(",")
58
+ .filter(Boolean)
59
+ .map(function (part) {
60
+ var match = part.match(/^([0-9]+)([a-zA-Z]+)/);
61
+ if (!match)
62
+ throw new Error("Got an invalid coin string");
63
+ return {
64
+ amount: math_1.Uint64.fromString(match[1]).toString(),
65
+ denom: match[2],
66
+ };
67
+ });
68
+ }
69
+ exports.parseCoins = parseCoins;
@@ -0,0 +1,24 @@
1
+ import { Pubkey, Secp256k1Pubkey } from "./pubkeys";
2
+ export declare function encodeSecp256k1Pubkey(pubkey: Uint8Array): Secp256k1Pubkey;
3
+ /**
4
+ * Decodes a pubkey in the Amino binary format to a type/value object.
5
+ */
6
+ export declare function decodeAminoPubkey(data: Uint8Array): Pubkey;
7
+ /**
8
+ * Decodes a bech32 pubkey to Amino binary, which is then decoded to a type/value object.
9
+ * The bech32 prefix is ignored and discareded.
10
+ *
11
+ * @param bechEncoded the bech32 encoded pubkey
12
+ */
13
+ export declare function decodeBech32Pubkey(bechEncoded: string): Pubkey;
14
+ /**
15
+ * Encodes a public key to binary Amino.
16
+ */
17
+ export declare function encodeAminoPubkey(pubkey: Pubkey): Uint8Array;
18
+ /**
19
+ * Encodes a public key to binary Amino and then to bech32.
20
+ *
21
+ * @param pubkey the public key to encode
22
+ * @param prefix the bech32 prefix (human readable part)
23
+ */
24
+ export declare function encodeBech32Pubkey(pubkey: Pubkey, prefix: string): string;