@firmachain/firma-js 0.2.16 → 0.2.20
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.
- package/dist/sdk/FirmaBankService.js +3 -3
- package/dist/sdk/FirmaContractService.js +8 -8
- package/dist/sdk/FirmaDistributionService.js +10 -10
- package/dist/sdk/FirmaFeeGrantService.js +6 -6
- package/dist/sdk/FirmaGovService.js +15 -15
- package/dist/sdk/FirmaNftService.js +6 -6
- package/dist/sdk/FirmaStakingService.js +10 -10
- package/dist/sdk/FirmaTokenService.js +8 -8
- package/dist/sdk/FirmaUtil.d.ts +4 -0
- package/dist/sdk/FirmaUtil.js +65 -6
- package/dist/sdk/FirmaWalletService.d.ts +9 -1
- package/dist/sdk/FirmaWalletService.js +39 -5
- package/dist/sdk/firmachain/amino/addresses.d.ts +5 -0
- package/dist/sdk/firmachain/amino/addresses.js +46 -0
- package/dist/sdk/firmachain/amino/aminomsgs.d.ts +281 -0
- package/dist/sdk/firmachain/amino/aminomsgs.js +77 -0
- package/dist/sdk/firmachain/amino/aminotypes.d.ts +22 -0
- package/dist/sdk/firmachain/amino/aminotypes.js +521 -0
- package/dist/sdk/firmachain/amino/coins.d.ts +30 -0
- package/dist/sdk/firmachain/amino/coins.js +69 -0
- package/dist/sdk/firmachain/amino/encoding.d.ts +24 -0
- package/dist/sdk/firmachain/amino/encoding.js +234 -0
- package/dist/sdk/firmachain/amino/multisig.d.ts +10 -0
- package/dist/sdk/firmachain/amino/multisig.js +42 -0
- package/dist/sdk/firmachain/amino/paths.d.ts +6 -0
- package/dist/sdk/firmachain/amino/paths.js +18 -0
- package/dist/sdk/firmachain/amino/pubkeys.d.ts +47 -0
- package/dist/sdk/firmachain/amino/pubkeys.js +29 -0
- package/dist/sdk/firmachain/amino/secp256k1hdwallet.d.ts +94 -0
- package/dist/sdk/firmachain/amino/secp256k1hdwallet.js +437 -0
- package/dist/sdk/firmachain/amino/secp256k1wallet.d.ts +23 -0
- package/dist/sdk/firmachain/amino/secp256k1wallet.js +141 -0
- package/dist/sdk/firmachain/amino/signature.d.ts +16 -0
- package/dist/sdk/firmachain/amino/signature.js +36 -0
- package/dist/sdk/firmachain/amino/signdoc.d.ts +26 -0
- package/dist/sdk/firmachain/amino/signdoc.js +42 -0
- package/dist/sdk/firmachain/amino/signer.d.ts +33 -0
- package/dist/sdk/firmachain/amino/signer.js +2 -0
- package/dist/sdk/firmachain/amino/stdtx.d.ts +15 -0
- package/dist/sdk/firmachain/amino/stdtx.js +17 -0
- package/dist/sdk/firmachain/amino/wallet.d.ts +32 -0
- package/dist/sdk/firmachain/amino/wallet.js +132 -0
- package/dist/sdk/firmachain/bank/BankTxClient.d.ts +3 -2
- package/dist/sdk/firmachain/common/ITxClient.d.ts +4 -2
- package/dist/sdk/firmachain/common/ITxClient.js +10 -6
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +27 -0
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +165 -0
- package/dist/sdk/firmachain/common/LedgerWallet.d.ts +14 -0
- package/dist/sdk/firmachain/common/LedgerWallet.js +147 -0
- package/dist/sdk/firmachain/common/signing.js +17 -1
- package/dist/sdk/firmachain/common/signingstargateclient.js +19 -3
- package/dist/sdk/firmachain/common/stargateclient.js +5 -2
- package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +3 -2
- package/dist/sdk/firmachain/contract/ContractTxTypes.js +50 -9
- package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +3 -2
- package/dist/sdk/firmachain/distribution/index.js +0 -1
- package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +3 -2
- package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +63 -13
- package/dist/sdk/firmachain/google/protobuf/any.js +3 -2
- package/dist/sdk/firmachain/google/protobuf/descriptor.js +1364 -324
- package/dist/sdk/firmachain/gov/GovTxClient.d.ts +3 -2
- package/dist/sdk/firmachain/gov/index.js +0 -1
- package/dist/sdk/firmachain/nft/NftTxClient.d.ts +3 -2
- package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +3 -2
- package/dist/sdk/firmachain/token/TokenTxClient.d.ts +3 -2
- 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;
|