@firmachain/firma-js 0.2.20 → 0.2.24

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 (157) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +136 -136
  3. package/dist/index.d.ts +4 -4
  4. package/dist/index.js +16 -16
  5. package/dist/sdk/FirmaBankService.d.ts +15 -15
  6. package/dist/sdk/FirmaBankService.js +211 -211
  7. package/dist/sdk/FirmaChainService.d.ts +8 -8
  8. package/dist/sdk/FirmaChainService.js +86 -86
  9. package/dist/sdk/FirmaConfig.d.ts +18 -16
  10. package/dist/sdk/FirmaConfig.js +63 -55
  11. package/dist/sdk/FirmaContractService.d.ts +31 -30
  12. package/dist/sdk/FirmaContractService.js +413 -394
  13. package/dist/sdk/FirmaDistributionService.d.ts +31 -31
  14. package/dist/sdk/FirmaDistributionService.js +524 -524
  15. package/dist/sdk/FirmaFeeGrantService.d.ts +21 -21
  16. package/dist/sdk/FirmaFeeGrantService.js +341 -341
  17. package/dist/sdk/FirmaGovService.d.ts +35 -35
  18. package/dist/sdk/FirmaGovService.js +775 -775
  19. package/dist/sdk/FirmaIpfsService.d.ts +12 -12
  20. package/dist/sdk/FirmaIpfsService.js +185 -185
  21. package/dist/sdk/FirmaMobileSDK.d.ts +27 -27
  22. package/dist/sdk/FirmaMobileSDK.js +45 -45
  23. package/dist/sdk/FirmaNftService.d.ts +31 -28
  24. package/dist/sdk/FirmaNftService.js +372 -390
  25. package/dist/sdk/FirmaSDK.d.ts +29 -29
  26. package/dist/sdk/FirmaSDK.js +48 -48
  27. package/dist/sdk/FirmaSlashingService.d.ts +9 -9
  28. package/dist/sdk/FirmaSlashingService.js +105 -105
  29. package/dist/sdk/FirmaStakingService.d.ts +34 -34
  30. package/dist/sdk/FirmaStakingService.js +604 -604
  31. package/dist/sdk/FirmaTokenService.d.ts +26 -26
  32. package/dist/sdk/FirmaTokenService.js +416 -416
  33. package/dist/sdk/FirmaUtil.d.ts +37 -26
  34. package/dist/sdk/FirmaUtil.js +230 -210
  35. package/dist/sdk/FirmaWalletService.d.ts +36 -36
  36. package/dist/sdk/FirmaWalletService.js +309 -309
  37. package/dist/sdk/firmachain/amino/addresses.d.ts +5 -5
  38. package/dist/sdk/firmachain/amino/addresses.js +46 -46
  39. package/dist/sdk/firmachain/amino/aminomsgs.d.ts +281 -281
  40. package/dist/sdk/firmachain/amino/aminomsgs.js +77 -77
  41. package/dist/sdk/firmachain/amino/aminotypes.d.ts +22 -22
  42. package/dist/sdk/firmachain/amino/aminotypes.js +521 -521
  43. package/dist/sdk/firmachain/amino/coins.d.ts +30 -30
  44. package/dist/sdk/firmachain/amino/coins.js +69 -69
  45. package/dist/sdk/firmachain/amino/encoding.d.ts +24 -24
  46. package/dist/sdk/firmachain/amino/encoding.js +234 -234
  47. package/dist/sdk/firmachain/amino/multisig.d.ts +10 -10
  48. package/dist/sdk/firmachain/amino/multisig.js +42 -42
  49. package/dist/sdk/firmachain/amino/paths.d.ts +6 -6
  50. package/dist/sdk/firmachain/amino/paths.js +18 -18
  51. package/dist/sdk/firmachain/amino/pubkeys.d.ts +47 -47
  52. package/dist/sdk/firmachain/amino/pubkeys.js +29 -29
  53. package/dist/sdk/firmachain/amino/secp256k1hdwallet.d.ts +94 -94
  54. package/dist/sdk/firmachain/amino/secp256k1hdwallet.js +437 -437
  55. package/dist/sdk/firmachain/amino/secp256k1wallet.d.ts +23 -23
  56. package/dist/sdk/firmachain/amino/secp256k1wallet.js +141 -141
  57. package/dist/sdk/firmachain/amino/signature.d.ts +16 -16
  58. package/dist/sdk/firmachain/amino/signature.js +36 -36
  59. package/dist/sdk/firmachain/amino/signdoc.d.ts +26 -26
  60. package/dist/sdk/firmachain/amino/signdoc.js +42 -42
  61. package/dist/sdk/firmachain/amino/signer.d.ts +33 -33
  62. package/dist/sdk/firmachain/amino/signer.js +2 -2
  63. package/dist/sdk/firmachain/amino/stdtx.d.ts +15 -15
  64. package/dist/sdk/firmachain/amino/stdtx.js +17 -17
  65. package/dist/sdk/firmachain/amino/wallet.d.ts +32 -32
  66. package/dist/sdk/firmachain/amino/wallet.js +132 -132
  67. package/dist/sdk/firmachain/bank/BankQueryClient.d.ts +12 -12
  68. package/dist/sdk/firmachain/bank/BankQueryClient.js +116 -116
  69. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +17 -17
  70. package/dist/sdk/firmachain/bank/BankTxClient.js +40 -40
  71. package/dist/sdk/firmachain/bank/index.d.ts +3 -3
  72. package/dist/sdk/firmachain/bank/index.js +15 -15
  73. package/dist/sdk/firmachain/common/ITxClient.d.ts +15 -15
  74. package/dist/sdk/firmachain/common/ITxClient.js +102 -102
  75. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +27 -27
  76. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +165 -165
  77. package/dist/sdk/firmachain/common/LedgerWallet.d.ts +14 -14
  78. package/dist/sdk/firmachain/common/LedgerWallet.js +147 -147
  79. package/dist/sdk/firmachain/common/QueryCommon.d.ts +4 -4
  80. package/dist/sdk/firmachain/common/QueryCommon.js +2 -2
  81. package/dist/sdk/firmachain/common/TendermintQueryClient.d.ts +42 -42
  82. package/dist/sdk/firmachain/common/TendermintQueryClient.js +108 -108
  83. package/dist/sdk/firmachain/common/TxCommon.d.ts +87 -94
  84. package/dist/sdk/firmachain/common/TxCommon.js +18 -34
  85. package/dist/sdk/firmachain/common/accounts.d.ts +16 -16
  86. package/dist/sdk/firmachain/common/accounts.js +64 -64
  87. package/dist/sdk/firmachain/common/index.d.ts +2 -2
  88. package/dist/sdk/firmachain/common/index.js +14 -14
  89. package/dist/sdk/firmachain/common/signing.d.ts +10 -10
  90. package/dist/sdk/firmachain/common/signing.js +75 -75
  91. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +37 -37
  92. package/dist/sdk/firmachain/common/signingstargateclient.js +298 -298
  93. package/dist/sdk/firmachain/common/stargateclient.d.ts +46 -46
  94. package/dist/sdk/firmachain/common/stargateclient.js +211 -211
  95. package/dist/sdk/firmachain/contract/ContractQueryClient.d.ts +32 -31
  96. package/dist/sdk/firmachain/contract/ContractQueryClient.js +156 -141
  97. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +17 -17
  98. package/dist/sdk/firmachain/contract/ContractTxClient.js +40 -40
  99. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +69 -69
  100. package/dist/sdk/firmachain/contract/ContractTxTypes.js +483 -483
  101. package/dist/sdk/firmachain/contract/index.d.ts +3 -3
  102. package/dist/sdk/firmachain/contract/index.js +15 -15
  103. package/dist/sdk/firmachain/distribution/DistributionQueryClient.d.ts +18 -18
  104. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +167 -167
  105. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +27 -27
  106. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +48 -48
  107. package/dist/sdk/firmachain/distribution/index.d.ts +3 -3
  108. package/dist/sdk/firmachain/distribution/index.js +15 -15
  109. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.d.ts +17 -17
  110. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +86 -86
  111. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +17 -17
  112. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +40 -40
  113. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +76 -76
  114. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +194 -194
  115. package/dist/sdk/firmachain/feegrant/index.d.ts +2 -2
  116. package/dist/sdk/firmachain/feegrant/index.js +15 -15
  117. package/dist/sdk/firmachain/google/protobuf/any.d.ts +128 -128
  118. package/dist/sdk/firmachain/google/protobuf/any.js +106 -106
  119. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +996 -996
  120. package/dist/sdk/firmachain/google/protobuf/descriptor.js +5329 -5329
  121. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +91 -91
  122. package/dist/sdk/firmachain/google/protobuf/duration.js +107 -107
  123. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +109 -109
  124. package/dist/sdk/firmachain/google/protobuf/timestamp.js +107 -107
  125. package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +61 -61
  126. package/dist/sdk/firmachain/gov/GovQueryClient.js +152 -152
  127. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +22 -22
  128. package/dist/sdk/firmachain/gov/GovTxClient.js +44 -44
  129. package/dist/sdk/firmachain/gov/index.d.ts +3 -3
  130. package/dist/sdk/firmachain/gov/index.js +15 -15
  131. package/dist/sdk/firmachain/nft/NftQueryClient.d.ts +20 -17
  132. package/dist/sdk/firmachain/nft/NftQueryClient.js +125 -121
  133. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +22 -22
  134. package/dist/sdk/firmachain/nft/NftTxClient.js +44 -44
  135. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +86 -86
  136. package/dist/sdk/firmachain/nft/NftTxTypes.js +424 -424
  137. package/dist/sdk/firmachain/nft/index.d.ts +3 -3
  138. package/dist/sdk/firmachain/nft/index.js +15 -15
  139. package/dist/sdk/firmachain/slashing/SlashingQueryClient.d.ts +22 -22
  140. package/dist/sdk/firmachain/slashing/SlashingQueryClient.js +101 -101
  141. package/dist/sdk/firmachain/slashing/index.d.ts +2 -2
  142. package/dist/sdk/firmachain/slashing/index.js +14 -14
  143. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +93 -93
  144. package/dist/sdk/firmachain/staking/StakingQueryClient.js +223 -223
  145. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +32 -32
  146. package/dist/sdk/firmachain/staking/StakingTxClient.js +52 -52
  147. package/dist/sdk/firmachain/staking/index.d.ts +3 -3
  148. package/dist/sdk/firmachain/staking/index.js +15 -15
  149. package/dist/sdk/firmachain/token/TokenQueryClient.d.ts +24 -24
  150. package/dist/sdk/firmachain/token/TokenQueryClient.js +106 -106
  151. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +27 -27
  152. package/dist/sdk/firmachain/token/TokenTxClient.js +48 -48
  153. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +116 -116
  154. package/dist/sdk/firmachain/token/TokenTxTypes.js +685 -685
  155. package/dist/sdk/firmachain/token/index.d.ts +3 -3
  156. package/dist/sdk/firmachain/token/index.js +15 -15
  157. package/package.json +56 -55
@@ -1,521 +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;
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;