@firmachain/firma-js 0.3.4 → 0.3.6-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -1
- package/dist/sdk/FirmaAuthzService.d.ts +8 -7
- package/dist/sdk/FirmaAuthzService.js +12 -22
- package/dist/sdk/FirmaBankService.js +2 -2
- package/dist/sdk/FirmaChainService.js +1 -1
- package/dist/sdk/FirmaContractService.d.ts +1 -1
- package/dist/sdk/FirmaContractService.js +6 -6
- package/dist/sdk/FirmaCosmWasmCw20.d.ts +2 -2
- package/dist/sdk/FirmaCosmWasmCw20.js +8 -8
- package/dist/sdk/FirmaCosmWasmCw721.d.ts +2 -2
- package/dist/sdk/FirmaCosmWasmCw721.js +12 -12
- package/dist/sdk/FirmaCosmWasmCwBridge.d.ts +1 -1
- package/dist/sdk/FirmaCosmWasmCwBridge.js +8 -8
- package/dist/sdk/FirmaCosmWasmCwMarketplace.d.ts +1 -1
- package/dist/sdk/FirmaCosmWasmCwMarketplace.js +5 -5
- package/dist/sdk/FirmaCosmWasmService.d.ts +1 -1
- package/dist/sdk/FirmaCosmWasmService.js +13 -13
- package/dist/sdk/FirmaDistributionService.d.ts +1 -1
- package/dist/sdk/FirmaDistributionService.js +6 -6
- package/dist/sdk/FirmaFeeGrantService.d.ts +7 -6
- package/dist/sdk/FirmaFeeGrantService.js +9 -26
- package/dist/sdk/FirmaGovService.d.ts +1 -1
- package/dist/sdk/FirmaGovService.js +14 -14
- package/dist/sdk/FirmaIbcService.d.ts +3 -3
- package/dist/sdk/FirmaIbcService.js +11 -8
- package/dist/sdk/FirmaIpfsService.js +1 -1
- package/dist/sdk/FirmaMintService.js +1 -1
- package/dist/sdk/FirmaNftService.d.ts +1 -1
- package/dist/sdk/FirmaNftService.js +6 -6
- package/dist/sdk/FirmaSlashingService.js +1 -1
- package/dist/sdk/FirmaStakingService.d.ts +3 -3
- package/dist/sdk/FirmaStakingService.js +6 -6
- package/dist/sdk/FirmaTokenService.d.ts +1 -1
- package/dist/sdk/FirmaTokenService.js +5 -5
- package/dist/sdk/FirmaUtil.d.ts +26 -23
- package/dist/sdk/FirmaUtil.js +157 -137
- package/dist/sdk/FirmaWalletService.d.ts +5 -9
- package/dist/sdk/FirmaWalletService.js +86 -52
- package/dist/sdk/firmachain/authz/AuthzQueryClient.js +4 -4
- package/dist/sdk/firmachain/authz/AuthzTxTypes.d.ts +8 -11
- package/dist/sdk/firmachain/authz/AuthzTxTypes.js +6 -10
- package/dist/sdk/firmachain/authz/index.js +5 -1
- package/dist/sdk/firmachain/bank/BankQueryClient.js +5 -5
- package/dist/sdk/firmachain/bank/index.js +5 -1
- package/dist/sdk/firmachain/common/ITxClient.d.ts +3 -3
- package/dist/sdk/firmachain/common/ITxClient.js +25 -83
- package/dist/sdk/firmachain/common/LedgerWallet.d.ts +19 -3
- package/dist/sdk/firmachain/common/LedgerWallet.js +138 -68
- package/dist/sdk/firmachain/common/TendermintQueryClient.js +1 -1
- package/dist/sdk/firmachain/common/TxCommon.d.ts +14 -30
- package/dist/sdk/firmachain/common/accounts.d.ts +1 -1
- package/dist/sdk/firmachain/common/accounts.js +7 -7
- package/dist/sdk/firmachain/common/events.js +2 -2
- package/dist/sdk/firmachain/common/fee.d.ts +2 -2
- package/dist/sdk/firmachain/common/fee.js +4 -2
- package/dist/sdk/firmachain/common/index.d.ts +0 -1
- package/dist/sdk/firmachain/common/index.js +5 -4
- package/dist/sdk/firmachain/common/signing.d.ts +13 -9
- package/dist/sdk/firmachain/common/signing.js +81 -36
- package/dist/sdk/firmachain/common/signingprotobufstargateclient.d.ts +34 -0
- package/dist/sdk/firmachain/common/signingprotobufstargateclient.js +319 -0
- package/dist/sdk/firmachain/common/signingstargateclient.d.ts +21 -105
- package/dist/sdk/firmachain/common/signingstargateclient.js +120 -472
- package/dist/sdk/firmachain/common/{stargateclient.d.ts → stargateClient.d.ts} +11 -60
- package/dist/sdk/firmachain/common/{stargateclient.js → stargateClient.js} +109 -203
- package/dist/sdk/firmachain/{amino → common}/wallet.js +15 -11
- package/dist/sdk/firmachain/contract/ContractQueryClient.js +3 -3
- package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +6 -6
- package/dist/sdk/firmachain/contract/index.js +5 -1
- package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +9 -9
- package/dist/sdk/firmachain/cosmwasm/index.js +5 -1
- package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +6 -6
- package/dist/sdk/firmachain/distribution/index.js +5 -1
- package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +3 -3
- package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +4 -45
- package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +3 -82
- package/dist/sdk/firmachain/feegrant/index.js +5 -1
- package/dist/sdk/firmachain/google/protobuf/any.d.ts +3 -3
- package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +29 -29
- package/dist/sdk/firmachain/google/protobuf/duration.d.ts +3 -3
- package/dist/sdk/firmachain/gov/GovQueryClient.js +3 -3
- package/dist/sdk/firmachain/gov/index.js +5 -1
- package/dist/sdk/firmachain/ibc/IbcQueryClient.js +2 -2
- package/dist/sdk/firmachain/ibc/index.js +5 -1
- package/dist/sdk/firmachain/mint/MintQueryClient.js +1 -1
- package/dist/sdk/firmachain/mint/index.js +5 -1
- package/dist/sdk/firmachain/nft/NftQueryClient.js +1 -1
- package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +8 -8
- package/dist/sdk/firmachain/nft/index.js +5 -1
- package/dist/sdk/firmachain/slashing/SlashingQueryClient.js +1 -1
- package/dist/sdk/firmachain/slashing/index.js +5 -1
- package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +2 -2
- package/dist/sdk/firmachain/staking/StakingQueryClient.js +10 -9
- package/dist/sdk/firmachain/staking/index.js +5 -1
- package/dist/sdk/firmachain/token/TokenQueryClient.js +1 -1
- package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +11 -11
- package/dist/sdk/firmachain/token/TokenTxTypes.js +1 -1
- package/dist/sdk/firmachain/token/index.js +5 -1
- package/dist/test/00.wallet.test.js +4 -4
- package/dist/test/01.contract_tx.test.js +5 -5
- package/dist/test/02.contract_query.test.js +15 -15
- package/dist/test/03.contract_scenario.test.js +28 -28
- package/dist/test/04.bank_tx.test.js +4 -4
- package/dist/test/05.bank_query.test.js +9 -9
- package/dist/test/06.feegrant_tx.test.js +59 -35
- package/dist/test/07.feegrant_query.test.js +18 -15
- package/dist/test/08.gas_estimate.test.js +110 -70
- package/dist/test/09.ipfs.test.js +4 -4
- package/dist/test/10.nft_tx.test.js +7 -7
- package/dist/test/11.nft_query.test.js +9 -9
- package/dist/test/12.staking_tx.test.js +27 -15
- package/dist/test/13.staking_query.test.js +20 -20
- package/dist/test/14.distribution_tx.test.js +8 -8
- package/dist/test/15.distribution_query.test.js +15 -15
- package/dist/test/16.gov_tx.test.js +17 -17
- package/dist/test/17.gov_query.test.js +19 -19
- package/dist/test/18.util.test.js +105 -63
- package/dist/test/19.chain.test.js +38 -38
- package/dist/test/20.slashing_query.test.js +25 -25
- package/dist/test/21.token_tx.test.js +6 -6
- package/dist/test/22.token_query.test.js +4 -4
- package/dist/test/23.authz_tx.test.js +77 -47
- package/dist/test/24.authz_query.test.js +66 -67
- package/dist/test/25.cosmwasm_tx.test.js +7 -7
- package/dist/test/26.cosmwasm_query.test.js +127 -59
- package/dist/test/{27.arbitary_sign.test.js → 27.arbitrary_sign.test.js} +41 -40
- package/dist/test/28.ibc_tx.test.js +8 -8
- package/dist/test/29.mint_query.test.js +2 -2
- package/dist/test/30.cw20_tx.test.js +20 -20
- package/dist/test/31.cw20_query.test.js +24 -24
- package/dist/test/32.cw721_tx.test.js +19 -19
- package/dist/test/33.cw721_query.test.js +32 -32
- package/dist/test/34.cw_bridge_tx.test.js +19 -19
- package/dist/test/35.cw_bridge_tx_low.test.js +13 -13
- package/dist/test/36.cw_bridge_query.test.js +20 -20
- package/dist/test/37.cw_marketplace_tx.test.js +32 -32
- package/dist/test/38.cw_marketplace_query.test.js +2 -2
- package/dist/test/config_test.d.ts +2 -2
- package/dist/test/config_test.js +22 -5
- package/package.json +9 -10
- package/dist/sdk/firmachain/amino/addresses.d.ts +0 -5
- package/dist/sdk/firmachain/amino/addresses.js +0 -46
- package/dist/sdk/firmachain/amino/aminomsgs.d.ts +0 -291
- package/dist/sdk/firmachain/amino/aminomsgs.js +0 -81
- package/dist/sdk/firmachain/amino/aminotypes.d.ts +0 -22
- package/dist/sdk/firmachain/amino/aminotypes.js +0 -538
- package/dist/sdk/firmachain/amino/coins.d.ts +0 -42
- package/dist/sdk/firmachain/amino/coins.js +0 -90
- package/dist/sdk/firmachain/amino/encoding.d.ts +0 -33
- package/dist/sdk/firmachain/amino/encoding.js +0 -252
- package/dist/sdk/firmachain/amino/multisig.d.ts +0 -10
- package/dist/sdk/firmachain/amino/multisig.js +0 -42
- package/dist/sdk/firmachain/amino/pubkeys.d.ts +0 -47
- package/dist/sdk/firmachain/amino/pubkeys.js +0 -29
- package/dist/sdk/firmachain/amino/signature.d.ts +0 -16
- package/dist/sdk/firmachain/amino/signature.js +0 -36
- package/dist/sdk/firmachain/amino/signdoc.d.ts +0 -44
- package/dist/sdk/firmachain/amino/signdoc.js +0 -68
- package/dist/sdk/firmachain/amino/signer.d.ts +0 -33
- package/dist/sdk/firmachain/amino/signer.js +0 -2
- package/dist/sdk/firmachain/amino/stdtx.d.ts +0 -15
- package/dist/sdk/firmachain/amino/stdtx.js +0 -17
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +0 -22
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +0 -170
- package/dist/sdk/firmachain/common/aminotypes.d.ts +0 -19
- package/dist/sdk/firmachain/common/aminotypes.js +0 -74
- package/dist/sdk/firmachain/common/modules/auth/queries.d.ts +0 -15
- package/dist/sdk/firmachain/common/modules/auth/queries.js +0 -64
- package/dist/sdk/firmachain/common/modules/authz/aminomessages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/authz/aminomessages.js +0 -15
- package/dist/sdk/firmachain/common/modules/authz/messages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/authz/messages.js +0 -9
- package/dist/sdk/firmachain/common/modules/authz/queries.d.ts +0 -10
- package/dist/sdk/firmachain/common/modules/authz/queries.js +0 -88
- package/dist/sdk/firmachain/common/modules/bank/aminomessages.d.ts +0 -35
- package/dist/sdk/firmachain/common/modules/bank/aminomessages.js +0 -85
- package/dist/sdk/firmachain/common/modules/bank/messages.d.ts +0 -8
- package/dist/sdk/firmachain/common/modules/bank/messages.js +0 -12
- package/dist/sdk/firmachain/common/modules/bank/queries.d.ts +0 -15
- package/dist/sdk/firmachain/common/modules/bank/queries.js +0 -128
- package/dist/sdk/firmachain/common/modules/crisis/aminomessages.d.ts +0 -14
- package/dist/sdk/firmachain/common/modules/crisis/aminomessages.js +0 -11
- package/dist/sdk/firmachain/common/modules/distribution/aminomessages.d.ts +0 -44
- package/dist/sdk/firmachain/common/modules/distribution/aminomessages.js +0 -113
- package/dist/sdk/firmachain/common/modules/distribution/messages.d.ts +0 -8
- package/dist/sdk/firmachain/common/modules/distribution/messages.js +0 -15
- package/dist/sdk/firmachain/common/modules/distribution/queries.d.ts +0 -16
- package/dist/sdk/firmachain/common/modules/distribution/queries.js +0 -171
- package/dist/sdk/firmachain/common/modules/evidence/aminomessages.d.ts +0 -18
- package/dist/sdk/firmachain/common/modules/evidence/aminomessages.js +0 -11
- package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.js +0 -14
- package/dist/sdk/firmachain/common/modules/feegrant/messages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/feegrant/messages.js +0 -8
- package/dist/sdk/firmachain/common/modules/feegrant/queries.d.ts +0 -9
- package/dist/sdk/firmachain/common/modules/feegrant/queries.js +0 -81
- package/dist/sdk/firmachain/common/modules/gov/aminomessages.d.ts +0 -79
- package/dist/sdk/firmachain/common/modules/gov/aminomessages.js +0 -152
- package/dist/sdk/firmachain/common/modules/gov/messages.d.ts +0 -29
- package/dist/sdk/firmachain/common/modules/gov/messages.js +0 -39
- package/dist/sdk/firmachain/common/modules/gov/queries.d.ts +0 -19
- package/dist/sdk/firmachain/common/modules/gov/queries.js +0 -160
- package/dist/sdk/firmachain/common/modules/group/aminomessages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/group/aminomessages.js +0 -8
- package/dist/sdk/firmachain/common/modules/group/messages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/group/messages.js +0 -28
- package/dist/sdk/firmachain/common/modules/ibc/aminomessages.d.ts +0 -38
- package/dist/sdk/firmachain/common/modules/ibc/aminomessages.js +0 -55
- package/dist/sdk/firmachain/common/modules/ibc/messages.d.ts +0 -8
- package/dist/sdk/firmachain/common/modules/ibc/messages.js +0 -32
- package/dist/sdk/firmachain/common/modules/ibc/queries.d.ts +0 -58
- package/dist/sdk/firmachain/common/modules/ibc/queries.js +0 -576
- package/dist/sdk/firmachain/common/modules/index.d.ts +0 -32
- package/dist/sdk/firmachain/common/modules/index.js +0 -101
- package/dist/sdk/firmachain/common/modules/mint/queries.d.ts +0 -21
- package/dist/sdk/firmachain/common/modules/mint/queries.js +0 -95
- package/dist/sdk/firmachain/common/modules/slashing/aminomessages.d.ts +0 -12
- package/dist/sdk/firmachain/common/modules/slashing/aminomessages.js +0 -11
- package/dist/sdk/firmachain/common/modules/slashing/queries.d.ts +0 -10
- package/dist/sdk/firmachain/common/modules/slashing/queries.js +0 -88
- package/dist/sdk/firmachain/common/modules/staking/aminomessages.d.ts +0 -112
- package/dist/sdk/firmachain/common/modules/staking/aminomessages.js +0 -234
- package/dist/sdk/firmachain/common/modules/staking/messages.d.ts +0 -33
- package/dist/sdk/firmachain/common/modules/staking/messages.js +0 -37
- package/dist/sdk/firmachain/common/modules/staking/queries.d.ts +0 -23
- package/dist/sdk/firmachain/common/modules/staking/queries.js +0 -242
- package/dist/sdk/firmachain/common/modules/tx/queries.d.ts +0 -11
- package/dist/sdk/firmachain/common/modules/tx/queries.js +0 -103
- package/dist/sdk/firmachain/common/modules/vesting/aminomessages.d.ts +0 -16
- package/dist/sdk/firmachain/common/modules/vesting/aminomessages.js +0 -56
- package/dist/sdk/firmachain/common/modules/vesting/messages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/vesting/messages.js +0 -7
- package/dist/sdk/firmachain/common/queryclient/index.d.ts +0 -2
- package/dist/sdk/firmachain/common/queryclient/index.js +0 -10
- package/dist/sdk/firmachain/common/queryclient/queryclient.d.ts +0 -75
- package/dist/sdk/firmachain/common/queryclient/queryclient.js +0 -157
- package/dist/sdk/firmachain/common/queryclient/utils.d.ts +0 -33
- package/dist/sdk/firmachain/common/queryclient/utils.js +0 -101
- package/dist/sdk/firmachain/common/search.d.ts +0 -10
- package/dist/sdk/firmachain/common/search.js +0 -7
- package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +0 -110
- package/dist/sdk/firmachain/google/protobuf/timestamp.js +0 -108
- /package/dist/sdk/firmachain/{amino → common}/paths.d.ts +0 -0
- /package/dist/sdk/firmachain/{amino → common}/paths.js +0 -0
- /package/dist/sdk/firmachain/{amino → common}/wallet.d.ts +0 -0
- /package/dist/test/{27.arbitary_sign.test.d.ts → 27.arbitrary_sign.test.d.ts} +0 -0
|
@@ -14,17 +14,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
17
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
18
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
19
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -40,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
40
29
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
30
|
function step(op) {
|
|
42
31
|
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (_) try {
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
33
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
34
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
35
|
switch (op[0]) {
|
|
@@ -77,85 +66,51 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
77
66
|
}
|
|
78
67
|
return ar;
|
|
79
68
|
};
|
|
80
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
81
|
-
for (var i = 0,
|
|
82
|
-
|
|
83
|
-
|
|
69
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
70
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
71
|
+
if (ar || !(i in from)) {
|
|
72
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
73
|
+
ar[i] = from[i];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
84
77
|
};
|
|
85
78
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
86
79
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
87
80
|
};
|
|
88
81
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
|
-
exports.SigningStargateClient = exports.
|
|
90
|
-
var amino_1 = require("@cosmjs/amino");
|
|
91
|
-
var crypto_1 = require("@cosmjs/crypto");
|
|
82
|
+
exports.SigningStargateClient = exports.defaultRegistryTypes = void 0;
|
|
92
83
|
var encoding_1 = require("@cosmjs/encoding");
|
|
93
|
-
var math_1 = require("@cosmjs/math");
|
|
94
84
|
var proto_signing_1 = require("@cosmjs/proto-signing");
|
|
95
85
|
var tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
|
|
96
|
-
var utils_1 = require("@cosmjs/utils");
|
|
97
86
|
var coin_1 = require("cosmjs-types/cosmos/base/v1beta1/coin");
|
|
98
|
-
var tx_1 = require("cosmjs-types/cosmos/
|
|
99
|
-
var
|
|
100
|
-
var
|
|
101
|
-
var
|
|
102
|
-
var
|
|
103
|
-
var
|
|
104
|
-
var
|
|
105
|
-
var
|
|
106
|
-
var modules_1 = require("./modules");
|
|
107
|
-
var modules_2 = require("./modules");
|
|
108
|
-
var stargateclient_1 = require("./stargateclient");
|
|
109
|
-
var FirmaUtil_1 = require("../../FirmaUtil");
|
|
87
|
+
var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
|
|
88
|
+
var keys_1 = require("cosmjs-types/cosmos/crypto/secp256k1/keys");
|
|
89
|
+
var axios_1 = __importDefault(require("axios"));
|
|
90
|
+
var accounts_1 = require("./accounts");
|
|
91
|
+
var stargateClient_1 = require("./stargateClient");
|
|
92
|
+
var any_1 = require("cosmjs-types/google/protobuf/any");
|
|
93
|
+
var modules_1 = require("@cosmjs/stargate/build/modules");
|
|
94
|
+
var signing_1 = require("./signing");
|
|
110
95
|
exports.defaultRegistryTypes = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
111
96
|
["/cosmos.base.v1beta1.Coin", coin_1.Coin]
|
|
112
|
-
], __read(modules_1.authzTypes)), __read(modules_1.bankTypes)), __read(modules_1.distributionTypes)), __read(modules_1.feegrantTypes)), __read(modules_1.govTypes)), __read(modules_1.groupTypes)), __read(modules_1.stakingTypes)), __read(modules_1.ibcTypes)), __read(modules_1.vestingTypes));
|
|
113
|
-
function createDefaultAminoConverters() {
|
|
114
|
-
return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, modules_2.createAuthzAminoConverters()), modules_2.createBankAminoConverters()), modules_2.createDistributionAminoConverters()), modules_2.createGovAminoConverters()), modules_2.createStakingAminoConverters()), modules_2.createIbcAminoConverters()), modules_2.createFeegrantAminoConverters()), modules_2.createVestingAminoConverters());
|
|
115
|
-
}
|
|
116
|
-
exports.createDefaultAminoConverters = createDefaultAminoConverters;
|
|
117
|
-
function isMsgSignData(msg) {
|
|
118
|
-
var castedMsg = msg;
|
|
119
|
-
if (castedMsg.type !== "sign/MsgSignData")
|
|
120
|
-
return false;
|
|
121
|
-
if (!utils_1.isNonNullObject(castedMsg.value))
|
|
122
|
-
return false;
|
|
123
|
-
if (typeof castedMsg.value.signer !== "string")
|
|
124
|
-
return false;
|
|
125
|
-
if (typeof castedMsg.value.data !== "string")
|
|
126
|
-
return false;
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
exports.isMsgSignData = isMsgSignData;
|
|
97
|
+
], __read(modules_1.authzTypes), false), __read(modules_1.bankTypes), false), __read(modules_1.distributionTypes), false), __read(modules_1.feegrantTypes), false), __read(modules_1.govTypes), false), __read(modules_1.groupTypes), false), __read(modules_1.stakingTypes), false), __read(modules_1.ibcTypes), false), __read(modules_1.vestingTypes), false);
|
|
130
98
|
var SigningStargateClient = /** @class */ (function (_super) {
|
|
131
99
|
__extends(SigningStargateClient, _super);
|
|
132
100
|
function SigningStargateClient(cometClient, signer, options) {
|
|
133
101
|
var _this = _super.call(this, cometClient, options) || this;
|
|
134
|
-
|
|
135
|
-
// E.g. https://github.com/cosmos/cosmos-sdk/issues/16020
|
|
136
|
-
_this.defaultGasMultiplier = 1.4;
|
|
137
|
-
var _a = options.registry, registry = _a === void 0 ? new proto_signing_1.Registry(exports.defaultRegistryTypes) : _a, _b = options.aminoTypes, aminoTypes = _b === void 0 ? new aminotypes_1.AminoTypes(createDefaultAminoConverters()) : _b;
|
|
102
|
+
var _a = options.registry, registry = _a === void 0 ? new proto_signing_1.Registry(exports.defaultRegistryTypes) : _a;
|
|
138
103
|
_this.registry = registry;
|
|
139
|
-
_this.aminoTypes = aminoTypes;
|
|
140
104
|
_this.signer = signer;
|
|
141
|
-
_this.broadcastTimeoutMs = options.broadcastTimeoutMs;
|
|
142
|
-
_this.broadcastPollIntervalMs = options.broadcastPollIntervalMs;
|
|
143
|
-
_this.gasPrice = options.gasPrice;
|
|
144
105
|
return _this;
|
|
145
106
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Creates an instance by connecting to the given CometBFT RPC endpoint.
|
|
148
|
-
*
|
|
149
|
-
* This uses auto-detection to decide between a CometBFT 0.38, Tendermint 0.37 and 0.34 client.
|
|
150
|
-
* To set the Comet client explicitly, use `createWithSigner`.
|
|
151
|
-
*/
|
|
152
107
|
SigningStargateClient.connectWithSigner = function (endpoint, signer, options) {
|
|
153
108
|
if (options === void 0) { options = {}; }
|
|
154
109
|
return __awaiter(this, void 0, void 0, function () {
|
|
155
110
|
var cometClient;
|
|
156
111
|
return __generator(this, function (_a) {
|
|
157
112
|
switch (_a.label) {
|
|
158
|
-
case 0: return [4 /*yield*/, tendermint_rpc_1.connectComet(endpoint)];
|
|
113
|
+
case 0: return [4 /*yield*/, (0, tendermint_rpc_1.connectComet)(endpoint)];
|
|
159
114
|
case 1:
|
|
160
115
|
cometClient = _a.sent();
|
|
161
116
|
return [2 /*return*/, SigningStargateClient.createWithSigner(cometClient, signer, options)];
|
|
@@ -163,10 +118,6 @@ var SigningStargateClient = /** @class */ (function (_super) {
|
|
|
163
118
|
});
|
|
164
119
|
});
|
|
165
120
|
};
|
|
166
|
-
/**
|
|
167
|
-
* Creates an instance from a manually created Comet client.
|
|
168
|
-
* Use this to use `Comet38Client` or `Tendermint37Client` instead of `Tendermint34Client`.
|
|
169
|
-
*/
|
|
170
121
|
SigningStargateClient.createWithSigner = function (cometClient, signer, options) {
|
|
171
122
|
if (options === void 0) { options = {}; }
|
|
172
123
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -175,254 +126,57 @@ var SigningStargateClient = /** @class */ (function (_super) {
|
|
|
175
126
|
});
|
|
176
127
|
});
|
|
177
128
|
};
|
|
178
|
-
|
|
179
|
-
* Creates a client in offline mode.
|
|
180
|
-
*
|
|
181
|
-
* This should only be used in niche cases where you know exactly what you're doing,
|
|
182
|
-
* e.g. when building an offline signing application.
|
|
183
|
-
*
|
|
184
|
-
* When you try to use online functionality with such a signer, an
|
|
185
|
-
* exception will be raised.
|
|
186
|
-
*/
|
|
187
|
-
SigningStargateClient.offline = function (signer, options) {
|
|
188
|
-
if (options === void 0) { options = {}; }
|
|
189
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
-
return __generator(this, function (_a) {
|
|
191
|
-
return [2 /*return*/, new SigningStargateClient(undefined, signer, options)];
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
SigningStargateClient.prototype.simulate = function (signerAddress, messages, memo) {
|
|
196
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
-
var anyMsgs, accountFromSigner, pubkey, sequence, gasInfo;
|
|
198
|
-
var _this = this;
|
|
199
|
-
return __generator(this, function (_a) {
|
|
200
|
-
switch (_a.label) {
|
|
201
|
-
case 0:
|
|
202
|
-
anyMsgs = messages.map(function (m) { return _this.registry.encodeAsAny(m); });
|
|
203
|
-
return [4 /*yield*/, this.signer.getAccounts()];
|
|
204
|
-
case 1:
|
|
205
|
-
accountFromSigner = (_a.sent()).find(function (account) { return account.address === signerAddress; });
|
|
206
|
-
if (!accountFromSigner) {
|
|
207
|
-
throw new Error("Failed to retrieve account from signer");
|
|
208
|
-
}
|
|
209
|
-
pubkey = amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey);
|
|
210
|
-
return [4 /*yield*/, this.getSequence(signerAddress)];
|
|
211
|
-
case 2:
|
|
212
|
-
sequence = (_a.sent()).sequence;
|
|
213
|
-
return [4 /*yield*/, this.forceGetQueryClient().tx.simulate(anyMsgs, memo, pubkey, sequence)];
|
|
214
|
-
case 3:
|
|
215
|
-
gasInfo = (_a.sent()).gasInfo;
|
|
216
|
-
utils_1.assertDefined(gasInfo);
|
|
217
|
-
return [2 /*return*/, math_1.Uint53.fromString(gasInfo.gasUsed.toString()).toNumber()];
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
};
|
|
222
|
-
SigningStargateClient.prototype.sendTokens = function (senderAddress, recipientAddress, amount, fee, memo) {
|
|
223
|
-
if (memo === void 0) { memo = ""; }
|
|
224
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
-
var sendMsg;
|
|
226
|
-
return __generator(this, function (_a) {
|
|
227
|
-
sendMsg = {
|
|
228
|
-
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
|
|
229
|
-
value: {
|
|
230
|
-
fromAddress: senderAddress,
|
|
231
|
-
toAddress: recipientAddress,
|
|
232
|
-
amount: __spreadArray([], __read(amount)),
|
|
233
|
-
},
|
|
234
|
-
};
|
|
235
|
-
return [2 /*return*/, this.signAndBroadcast(senderAddress, [sendMsg], fee, memo)];
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
};
|
|
239
|
-
SigningStargateClient.prototype.delegateTokens = function (delegatorAddress, validatorAddress, amount, fee, memo) {
|
|
240
|
-
if (memo === void 0) { memo = ""; }
|
|
241
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
-
var delegateMsg;
|
|
243
|
-
return __generator(this, function (_a) {
|
|
244
|
-
delegateMsg = {
|
|
245
|
-
typeUrl: "/cosmos.staking.v1beta1.MsgDelegate",
|
|
246
|
-
value: tx_2.MsgDelegate.fromPartial({
|
|
247
|
-
delegatorAddress: delegatorAddress,
|
|
248
|
-
validatorAddress: validatorAddress,
|
|
249
|
-
amount: amount,
|
|
250
|
-
}),
|
|
251
|
-
};
|
|
252
|
-
return [2 /*return*/, this.signAndBroadcast(delegatorAddress, [delegateMsg], fee, memo)];
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
};
|
|
256
|
-
SigningStargateClient.prototype.undelegateTokens = function (delegatorAddress, validatorAddress, amount, fee, memo) {
|
|
257
|
-
if (memo === void 0) { memo = ""; }
|
|
258
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
259
|
-
var undelegateMsg;
|
|
260
|
-
return __generator(this, function (_a) {
|
|
261
|
-
undelegateMsg = {
|
|
262
|
-
typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate",
|
|
263
|
-
value: tx_2.MsgUndelegate.fromPartial({
|
|
264
|
-
delegatorAddress: delegatorAddress,
|
|
265
|
-
validatorAddress: validatorAddress,
|
|
266
|
-
amount: amount,
|
|
267
|
-
}),
|
|
268
|
-
};
|
|
269
|
-
return [2 /*return*/, this.signAndBroadcast(delegatorAddress, [undelegateMsg], fee, memo)];
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
};
|
|
273
|
-
SigningStargateClient.prototype.withdrawRewards = function (delegatorAddress, validatorAddress, fee, memo) {
|
|
274
|
-
if (memo === void 0) { memo = ""; }
|
|
275
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
276
|
-
var withdrawMsg;
|
|
277
|
-
return __generator(this, function (_a) {
|
|
278
|
-
withdrawMsg = {
|
|
279
|
-
typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
|
|
280
|
-
value: tx_1.MsgWithdrawDelegatorReward.fromPartial({
|
|
281
|
-
delegatorAddress: delegatorAddress,
|
|
282
|
-
validatorAddress: validatorAddress,
|
|
283
|
-
}),
|
|
284
|
-
};
|
|
285
|
-
return [2 /*return*/, this.signAndBroadcast(delegatorAddress, [withdrawMsg], fee, memo)];
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* @deprecated This API does not support setting the memo field of `MsgTransfer` (only the transaction memo).
|
|
291
|
-
* We'll remove this method at some point because trying to wrap the various message types is a losing strategy.
|
|
292
|
-
* Please migrate to `signAndBroadcast` with an `MsgTransferEncodeObject` created in the caller code instead.
|
|
293
|
-
* @see https://github.com/cosmos/cosmjs/issues/1493
|
|
294
|
-
*/
|
|
295
|
-
SigningStargateClient.prototype.sendIbcTokens = function (senderAddress, recipientAddress, transferAmount, sourcePort, sourceChannel, timeoutHeight,
|
|
296
|
-
/** timeout in seconds */
|
|
297
|
-
timeoutTimestamp, fee, memo) {
|
|
298
|
-
if (memo === void 0) { memo = ""; }
|
|
299
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
300
|
-
var timeoutTimestampNanoseconds, transferMsg;
|
|
301
|
-
return __generator(this, function (_a) {
|
|
302
|
-
timeoutTimestampNanoseconds = timeoutTimestamp
|
|
303
|
-
? BigInt(timeoutTimestamp) * BigInt(1000000000)
|
|
304
|
-
: undefined;
|
|
305
|
-
transferMsg = {
|
|
306
|
-
typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
|
|
307
|
-
value: tx_4.MsgTransfer.fromPartial({
|
|
308
|
-
sourcePort: sourcePort,
|
|
309
|
-
sourceChannel: sourceChannel,
|
|
310
|
-
sender: senderAddress,
|
|
311
|
-
receiver: recipientAddress,
|
|
312
|
-
token: transferAmount,
|
|
313
|
-
timeoutHeight: timeoutHeight,
|
|
314
|
-
timeoutTimestamp: timeoutTimestampNanoseconds,
|
|
315
|
-
}),
|
|
316
|
-
};
|
|
317
|
-
return [2 /*return*/, this.signAndBroadcast(senderAddress, [transferMsg], fee, memo)];
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
SigningStargateClient.prototype.signAndBroadcast = function (signerAddress, messages, fee, memo, timeoutHeight) {
|
|
322
|
-
if (memo === void 0) { memo = ""; }
|
|
323
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
324
|
-
var usedFee, gasEstimation, multiplier, txRaw, txBytes;
|
|
325
|
-
return __generator(this, function (_a) {
|
|
326
|
-
switch (_a.label) {
|
|
327
|
-
case 0:
|
|
328
|
-
if (!(fee == "auto" || typeof fee === "number")) return [3 /*break*/, 2];
|
|
329
|
-
utils_1.assertDefined(this.gasPrice, "Gas price must be set in the client options when auto gas is used.");
|
|
330
|
-
return [4 /*yield*/, this.simulate(signerAddress, messages, memo)];
|
|
331
|
-
case 1:
|
|
332
|
-
gasEstimation = _a.sent();
|
|
333
|
-
multiplier = typeof fee === "number" ? fee : this.defaultGasMultiplier;
|
|
334
|
-
usedFee = fee_1.calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice);
|
|
335
|
-
return [3 /*break*/, 3];
|
|
336
|
-
case 2:
|
|
337
|
-
usedFee = fee;
|
|
338
|
-
_a.label = 3;
|
|
339
|
-
case 3: return [4 /*yield*/, this.sign(signerAddress, messages, usedFee, memo, undefined, timeoutHeight)];
|
|
340
|
-
case 4:
|
|
341
|
-
txRaw = _a.sent();
|
|
342
|
-
txBytes = tx_3.TxRaw.encode(txRaw).finish();
|
|
343
|
-
return [2 /*return*/, this.broadcastTx(txBytes, this.broadcastTimeoutMs, this.broadcastPollIntervalMs)];
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
};
|
|
348
|
-
/**
|
|
349
|
-
* This method is useful if you want to send a transaction in broadcast,
|
|
350
|
-
* without waiting for it to be placed inside a block, because for example
|
|
351
|
-
* I would like to receive the hash to later track the transaction with another tool.
|
|
352
|
-
* @returns Returns the hash of the transaction
|
|
353
|
-
*/
|
|
354
|
-
SigningStargateClient.prototype.signAndBroadcastSync = function (signerAddress, messages, fee, memo, timeoutHeight) {
|
|
129
|
+
SigningStargateClient.prototype.signAndBroadcast = function (signerAddress, messages, fee, memo) {
|
|
355
130
|
if (memo === void 0) { memo = ""; }
|
|
356
131
|
return __awaiter(this, void 0, void 0, function () {
|
|
357
|
-
var
|
|
132
|
+
var txRaw, txBytes;
|
|
358
133
|
return __generator(this, function (_a) {
|
|
359
134
|
switch (_a.label) {
|
|
360
|
-
case 0:
|
|
361
|
-
if (!(fee == "auto" || typeof fee === "number")) return [3 /*break*/, 2];
|
|
362
|
-
utils_1.assertDefined(this.gasPrice, "Gas price must be set in the client options when auto gas is used.");
|
|
363
|
-
return [4 /*yield*/, this.simulate(signerAddress, messages, memo)];
|
|
135
|
+
case 0: return [4 /*yield*/, this.sign(signerAddress, messages, fee, memo)];
|
|
364
136
|
case 1:
|
|
365
|
-
gasEstimation = _a.sent();
|
|
366
|
-
multiplier = typeof fee === "number" ? fee : this.defaultGasMultiplier;
|
|
367
|
-
usedFee = fee_1.calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice);
|
|
368
|
-
return [3 /*break*/, 3];
|
|
369
|
-
case 2:
|
|
370
|
-
usedFee = fee;
|
|
371
|
-
_a.label = 3;
|
|
372
|
-
case 3: return [4 /*yield*/, this.sign(signerAddress, messages, usedFee, memo, undefined, timeoutHeight)];
|
|
373
|
-
case 4:
|
|
374
137
|
txRaw = _a.sent();
|
|
375
|
-
txBytes =
|
|
376
|
-
return [2 /*return*/, this.
|
|
138
|
+
txBytes = tx_1.TxRaw.encode(txRaw).finish();
|
|
139
|
+
return [2 /*return*/, this.broadcastTx(txBytes)];
|
|
377
140
|
}
|
|
378
141
|
});
|
|
379
142
|
});
|
|
380
143
|
};
|
|
381
144
|
SigningStargateClient.makeSignDocForSend = function (signerAddress, pubkeyStr, messages, fee, memo, serverUrl, chainId, registry) {
|
|
382
145
|
return __awaiter(this, void 0, void 0, function () {
|
|
383
|
-
var
|
|
146
|
+
var _a, accountNumber, sequence, account, pubkeyBytes, pubkey, pubkeyAny, anyMsgs, txBody, bodyBytes, authInfoBytes;
|
|
384
147
|
return __generator(this, function (_b) {
|
|
385
148
|
switch (_b.label) {
|
|
386
|
-
case 0:
|
|
149
|
+
case 0:
|
|
150
|
+
SigningStargateClient._endpoint = serverUrl;
|
|
151
|
+
return [4 /*yield*/, SigningStargateClient.getSequence(signerAddress)];
|
|
387
152
|
case 1:
|
|
388
|
-
client = _b.sent();
|
|
389
|
-
return [4 /*yield*/, client.getSequence(signerAddress)];
|
|
390
|
-
case 2:
|
|
391
153
|
_a = _b.sent(), accountNumber = _a.accountNumber, sequence = _a.sequence;
|
|
392
|
-
return [4 /*yield*/,
|
|
393
|
-
case
|
|
154
|
+
return [4 /*yield*/, SigningStargateClient.getAccount(signerAddress)];
|
|
155
|
+
case 2:
|
|
394
156
|
account = _b.sent();
|
|
395
157
|
if (account == null)
|
|
396
158
|
throw new Error("Failed to retrieve account from signer");
|
|
397
|
-
|
|
398
|
-
pubkey =
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
},
|
|
159
|
+
pubkeyBytes = (0, encoding_1.fromBase64)(pubkeyStr);
|
|
160
|
+
pubkey = keys_1.PubKey.fromPartial({
|
|
161
|
+
key: pubkeyBytes,
|
|
162
|
+
});
|
|
163
|
+
pubkeyAny = {
|
|
164
|
+
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
|
165
|
+
value: keys_1.PubKey.encode(pubkey).finish(),
|
|
405
166
|
};
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
167
|
+
anyMsgs = messages.map(function (msg) { return registry.encodeAsAny(msg); });
|
|
168
|
+
txBody = tx_1.TxBody.fromPartial({
|
|
169
|
+
messages: anyMsgs,
|
|
170
|
+
memo: memo,
|
|
171
|
+
});
|
|
172
|
+
bodyBytes = tx_1.TxBody.encode(txBody).finish();
|
|
173
|
+
authInfoBytes = (0, signing_1.makeAuthInfoBytesProtobuf)([{ pubkey: pubkeyAny, sequence: sequence }], fee.amount, fee.gasLimit, fee.granter, fee.payer);
|
|
174
|
+
return [2 /*return*/, (0, signing_1.makeSignDocProtobuf)(bodyBytes, authInfoBytes, chainId, accountNumber)];
|
|
411
175
|
}
|
|
412
176
|
});
|
|
413
177
|
});
|
|
414
178
|
};
|
|
415
|
-
|
|
416
|
-
* Gets account number and sequence from the API, creates a sign doc,
|
|
417
|
-
* creates a single signature and assembles the signed transaction.
|
|
418
|
-
*
|
|
419
|
-
* The sign mode (SIGN_MODE_DIRECT or SIGN_MODE_LEGACY_AMINO_JSON) is determined by this client's signer.
|
|
420
|
-
*
|
|
421
|
-
* You can pass signer data (account number, sequence and chain ID) explicitly instead of querying them
|
|
422
|
-
* from the chain. This is needed when signing for a multisig account, but it also allows for offline signing
|
|
423
|
-
* (See the SigningStargateClient.offline constructor).
|
|
424
|
-
*/
|
|
425
|
-
SigningStargateClient.prototype.sign = function (signerAddress, messages, fee, memo, explicitSignerData, timeoutHeight) {
|
|
179
|
+
SigningStargateClient.prototype.sign = function (signerAddress, messages, fee, memo, explicitSignerData) {
|
|
426
180
|
return __awaiter(this, void 0, void 0, function () {
|
|
427
181
|
var signerData, _a, accountNumber, sequence, chainId;
|
|
428
182
|
return __generator(this, function (_b) {
|
|
@@ -443,232 +197,126 @@ var SigningStargateClient = /** @class */ (function (_super) {
|
|
|
443
197
|
chainId: chainId,
|
|
444
198
|
};
|
|
445
199
|
_b.label = 4;
|
|
446
|
-
case 4: return [2 /*return*/,
|
|
447
|
-
? this.signDirect(signerAddress, messages, fee, memo, signerData, timeoutHeight)
|
|
448
|
-
: this.signAmino(signerAddress, messages, fee, memo, signerData, timeoutHeight)];
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
});
|
|
452
|
-
};
|
|
453
|
-
SigningStargateClient.prototype.getChainId = function () {
|
|
454
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
455
|
-
var response, chainId;
|
|
456
|
-
return __generator(this, function (_a) {
|
|
457
|
-
switch (_a.label) {
|
|
458
|
-
case 0:
|
|
459
|
-
if (!!this.chainId) return [3 /*break*/, 2];
|
|
460
|
-
return [4 /*yield*/, this.forceGetCometClient().status()];
|
|
461
|
-
case 1:
|
|
462
|
-
response = _a.sent();
|
|
463
|
-
chainId = response.nodeInfo.network;
|
|
464
|
-
if (!chainId)
|
|
465
|
-
throw new Error("Chain ID must not be empty");
|
|
466
|
-
this.chainId = chainId;
|
|
467
|
-
_a.label = 2;
|
|
468
|
-
case 2: return [2 /*return*/, this.chainId];
|
|
200
|
+
case 4: return [2 /*return*/, this.signDirect(signerAddress, messages, fee, memo, signerData)];
|
|
469
201
|
}
|
|
470
202
|
});
|
|
471
203
|
});
|
|
472
204
|
};
|
|
473
|
-
SigningStargateClient.prototype.
|
|
205
|
+
SigningStargateClient.prototype.signDirect = function (signerAddress, messages, fee, memo, _a) {
|
|
474
206
|
var accountNumber = _a.accountNumber, sequence = _a.sequence, chainId = _a.chainId;
|
|
475
207
|
return __awaiter(this, void 0, void 0, function () {
|
|
476
|
-
var accountFromSigner, pubkey,
|
|
208
|
+
var accountFromSigner, pubkey, pubkeyAny, anyMsgs, txBody, bodyBytes, authInfoBytes, signDoc, _b, signature, signed;
|
|
477
209
|
var _this = this;
|
|
478
210
|
return __generator(this, function (_c) {
|
|
479
211
|
switch (_c.label) {
|
|
480
|
-
case 0:
|
|
481
|
-
utils_1.assert(!proto_signing_1.isOfflineDirectSigner(this.signer));
|
|
482
|
-
return [4 /*yield*/, this.signer.getAccounts()];
|
|
212
|
+
case 0: return [4 /*yield*/, this.signer.getAccounts()];
|
|
483
213
|
case 1:
|
|
484
214
|
accountFromSigner = (_c.sent()).find(function (account) { return account.address === signerAddress; });
|
|
485
215
|
if (!accountFromSigner) {
|
|
486
216
|
throw new Error("Failed to retrieve account from signer");
|
|
487
217
|
}
|
|
488
|
-
pubkey =
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
218
|
+
pubkey = keys_1.PubKey.fromPartial({
|
|
219
|
+
key: accountFromSigner.pubkey,
|
|
220
|
+
});
|
|
221
|
+
pubkeyAny = {
|
|
222
|
+
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
|
223
|
+
value: keys_1.PubKey.encode(pubkey).finish(),
|
|
224
|
+
};
|
|
225
|
+
anyMsgs = messages.map(function (msg) { return _this.registry.encodeAsAny(msg); });
|
|
226
|
+
txBody = tx_1.TxBody.fromPartial({
|
|
227
|
+
messages: anyMsgs,
|
|
228
|
+
memo: memo,
|
|
229
|
+
});
|
|
230
|
+
bodyBytes = tx_1.TxBody.encode(txBody).finish();
|
|
231
|
+
authInfoBytes = (0, signing_1.makeAuthInfoBytesProtobuf)([{ pubkey: pubkeyAny, sequence: sequence }], fee.amount, fee.gasLimit, fee.granter, fee.payer);
|
|
232
|
+
signDoc = (0, signing_1.makeSignDocProtobuf)(bodyBytes, authInfoBytes, chainId, accountNumber);
|
|
233
|
+
return [4 /*yield*/, this.signer.signDirect(signerAddress, signDoc)];
|
|
493
234
|
case 2:
|
|
494
235
|
_b = _c.sent(), signature = _b.signature, signed = _b.signed;
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
};
|
|
500
|
-
signedTxBodyEncodeObject = {
|
|
501
|
-
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
502
|
-
value: signedTxBody,
|
|
503
|
-
};
|
|
504
|
-
signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
|
|
505
|
-
signedGasLimit = math_1.Int53.fromString(signed.fee.gas).toNumber();
|
|
506
|
-
signedSequence = math_1.Int53.fromString(signed.sequence).toNumber();
|
|
507
|
-
signedAuthInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey: pubkey, sequence: signedSequence }], signed.fee.amount, signedGasLimit, signed.fee.granter, signed.fee.payer, signMode);
|
|
508
|
-
return [2 /*return*/, tx_3.TxRaw.fromPartial({
|
|
509
|
-
bodyBytes: signedTxBodyBytes,
|
|
510
|
-
authInfoBytes: signedAuthInfoBytes,
|
|
511
|
-
signatures: [encoding_1.fromBase64(signature.signature)],
|
|
236
|
+
return [2 /*return*/, tx_1.TxRaw.fromPartial({
|
|
237
|
+
bodyBytes: signed.bodyBytes,
|
|
238
|
+
authInfoBytes: signed.authInfoBytes,
|
|
239
|
+
signatures: [(0, encoding_1.fromBase64)(signature.signature)],
|
|
512
240
|
})];
|
|
513
241
|
}
|
|
514
242
|
});
|
|
515
243
|
});
|
|
516
244
|
};
|
|
517
|
-
SigningStargateClient.prototype.
|
|
518
|
-
var accountNumber = _a.accountNumber, sequence = _a.sequence, chainId = _a.chainId;
|
|
245
|
+
SigningStargateClient.prototype.signDirectForSignDoc = function (signerAddress, signDoc) {
|
|
519
246
|
return __awaiter(this, void 0, void 0, function () {
|
|
520
|
-
var accountFromSigner,
|
|
521
|
-
return __generator(this, function (
|
|
522
|
-
switch (
|
|
523
|
-
case 0:
|
|
524
|
-
utils_1.assert(proto_signing_1.isOfflineDirectSigner(this.signer));
|
|
525
|
-
return [4 /*yield*/, this.signer.getAccounts()];
|
|
247
|
+
var accountFromSigner, _a, signature, signed, txRaw;
|
|
248
|
+
return __generator(this, function (_b) {
|
|
249
|
+
switch (_b.label) {
|
|
250
|
+
case 0: return [4 /*yield*/, this.signer.getAccounts()];
|
|
526
251
|
case 1:
|
|
527
|
-
accountFromSigner = (
|
|
252
|
+
accountFromSigner = (_b.sent()).find(function (account) { return account.address === signerAddress; });
|
|
528
253
|
if (!accountFromSigner) {
|
|
529
254
|
throw new Error("Failed to retrieve account from signer");
|
|
530
255
|
}
|
|
531
|
-
pubkey = proto_signing_1.encodePubkey(amino_1.encodeSecp256k1Pubkey(accountFromSigner.pubkey));
|
|
532
|
-
txBodyEncodeObject = {
|
|
533
|
-
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
534
|
-
value: {
|
|
535
|
-
messages: messages,
|
|
536
|
-
memo: memo,
|
|
537
|
-
timeoutHeight: timeoutHeight,
|
|
538
|
-
},
|
|
539
|
-
};
|
|
540
|
-
txBodyBytes = this.registry.encode(txBodyEncodeObject);
|
|
541
|
-
gasLimit = math_1.Int53.fromString(fee.gas).toNumber();
|
|
542
|
-
authInfoBytes = proto_signing_1.makeAuthInfoBytes([{ pubkey: pubkey, sequence: sequence }], fee.amount, gasLimit, fee.granter, fee.payer);
|
|
543
|
-
signDoc = proto_signing_1.makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
|
544
256
|
return [4 /*yield*/, this.signer.signDirect(signerAddress, signDoc)];
|
|
545
257
|
case 2:
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
258
|
+
_a = _b.sent(), signature = _a.signature, signed = _a.signed;
|
|
259
|
+
txRaw = tx_1.TxRaw.fromPartial({
|
|
260
|
+
bodyBytes: signed.bodyBytes,
|
|
261
|
+
authInfoBytes: signed.authInfoBytes,
|
|
262
|
+
signatures: [(0, encoding_1.fromBase64)(signature.signature)],
|
|
263
|
+
});
|
|
264
|
+
return [2 /*return*/, { txRaw: txRaw, signature: signature.signature }];
|
|
552
265
|
}
|
|
553
266
|
});
|
|
554
267
|
});
|
|
555
268
|
};
|
|
556
|
-
SigningStargateClient.
|
|
269
|
+
SigningStargateClient.getSequence = function (address) {
|
|
557
270
|
return __awaiter(this, void 0, void 0, function () {
|
|
558
|
-
var
|
|
271
|
+
var account;
|
|
559
272
|
return __generator(this, function (_a) {
|
|
560
273
|
switch (_a.label) {
|
|
561
|
-
case 0:
|
|
562
|
-
newSignature = amino_1.encodeSecp256k1Signature(FirmaUtil_1.FirmaUtil.base64ToArrayBuffer(data.pubkey), FirmaUtil_1.FirmaUtil.base64ToArrayBuffer(data.signature));
|
|
563
|
-
signed = {
|
|
564
|
-
fee: {
|
|
565
|
-
gas: "0",
|
|
566
|
-
amount: [],
|
|
567
|
-
},
|
|
568
|
-
msg: [{
|
|
569
|
-
type: data.type,
|
|
570
|
-
value: { signer: data.signer, data: data.data }
|
|
571
|
-
}],
|
|
572
|
-
signatures: [newSignature],
|
|
573
|
-
memo: ""
|
|
574
|
-
};
|
|
575
|
-
// Restrictions from ADR-036
|
|
576
|
-
if (signed.memo !== "")
|
|
577
|
-
throw new Error("Memo must be empty.");
|
|
578
|
-
if (signed.fee.gas !== "0")
|
|
579
|
-
throw new Error("Fee gas must 0.");
|
|
580
|
-
if (signed.fee.amount.length !== 0)
|
|
581
|
-
throw new Error("Fee amount must be an empty array.");
|
|
582
|
-
accountNumber = 0;
|
|
583
|
-
sequence = 0;
|
|
584
|
-
chainId = "";
|
|
585
|
-
signedMessages = signed.msg;
|
|
586
|
-
if (!signedMessages.every(isMsgSignData)) {
|
|
587
|
-
throw new Error("Found message that is not the expected type.");
|
|
588
|
-
}
|
|
589
|
-
if (signedMessages.length === 0) {
|
|
590
|
-
throw new Error("No message found. Without messages we cannot determine the signer address.");
|
|
591
|
-
}
|
|
592
|
-
sourceMsg = Buffer.from(signedMessages[0].value.data, 'base64').toString();
|
|
593
|
-
if (sourceMsg !== checkMsg) {
|
|
594
|
-
throw new Error("Different Msg error. source:" + sourceMsg + ", target:" + checkMsg);
|
|
595
|
-
}
|
|
596
|
-
signatures = signed.signatures;
|
|
597
|
-
if (signatures.length !== 1)
|
|
598
|
-
throw new Error("Must have exactly one signature to be supported.");
|
|
599
|
-
signature = signatures[0];
|
|
600
|
-
if (!amino_1.isSecp256k1Pubkey(signature.pub_key)) {
|
|
601
|
-
throw new Error("Only secp256k1 signatures are supported.");
|
|
602
|
-
}
|
|
603
|
-
signBytes = amino_1.serializeSignDoc(amino_1.makeSignDoc(signed.msg, signed.fee, chainId, signed.memo, accountNumber, sequence));
|
|
604
|
-
prehashed = crypto_1.sha256(signBytes);
|
|
605
|
-
secpSignature = crypto_1.Secp256k1Signature.fromFixedLength(encoding_1.fromBase64(signature.signature));
|
|
606
|
-
rawSecp256k1Pubkey = encoding_1.fromBase64(signature.pub_key.value);
|
|
607
|
-
rawSignerAddress = amino_1.rawSecp256k1PubkeyToRawAddress(rawSecp256k1Pubkey);
|
|
608
|
-
if (signedMessages.some(function (msg) { return !utils_1.arrayContentEquals(encoding_1.fromBech32(msg.value.signer).data, rawSignerAddress); })) {
|
|
609
|
-
throw new Error("Found mismatch between signer in message and public key");
|
|
610
|
-
}
|
|
611
|
-
return [4 /*yield*/, crypto_1.Secp256k1.verifySignature(secpSignature, prehashed, rawSecp256k1Pubkey)];
|
|
274
|
+
case 0: return [4 /*yield*/, this.getAccount(address)];
|
|
612
275
|
case 1:
|
|
613
|
-
|
|
614
|
-
|
|
276
|
+
account = _a.sent();
|
|
277
|
+
if (!account) {
|
|
278
|
+
throw new Error("Account does not exist on chain. Send some tokens there before trying to query sequence.");
|
|
279
|
+
}
|
|
280
|
+
return [2 /*return*/, {
|
|
281
|
+
accountNumber: account.accountNumber,
|
|
282
|
+
sequence: account.sequence,
|
|
283
|
+
}];
|
|
615
284
|
}
|
|
616
285
|
});
|
|
617
286
|
});
|
|
618
287
|
};
|
|
619
|
-
SigningStargateClient.
|
|
288
|
+
SigningStargateClient.getAccount = function (address) {
|
|
620
289
|
return __awaiter(this, void 0, void 0, function () {
|
|
621
|
-
var
|
|
622
|
-
return __generator(this, function (
|
|
623
|
-
switch (
|
|
290
|
+
var accAddress, hexAccAddress, axiosInstance, path, result, finalData, account, error_1;
|
|
291
|
+
return __generator(this, function (_a) {
|
|
292
|
+
switch (_a.label) {
|
|
624
293
|
case 0:
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
};
|
|
633
|
-
memo = "";
|
|
634
|
-
datas = Array.isArray(data) ? data : [data];
|
|
635
|
-
msgs = datas.map(function (d) { return ({
|
|
636
|
-
type: "sign/MsgSignData",
|
|
637
|
-
value: {
|
|
638
|
-
signer: signerAddress,
|
|
639
|
-
data: encoding_1.toBase64(d),
|
|
294
|
+
_a.trys.push([0, 2, , 3]);
|
|
295
|
+
accAddress = (0, encoding_1.fromBech32)(address).data;
|
|
296
|
+
hexAccAddress = "0x01".concat(Buffer.from(accAddress).toString("hex"));
|
|
297
|
+
axiosInstance = axios_1.default.create({
|
|
298
|
+
baseURL: SigningStargateClient._endpoint,
|
|
299
|
+
headers: {
|
|
300
|
+
Accept: "application/json",
|
|
640
301
|
},
|
|
641
|
-
|
|
642
|
-
|
|
302
|
+
timeout: 15000
|
|
303
|
+
});
|
|
304
|
+
path = "/abci_query?path=\"/store/acc/key\"";
|
|
305
|
+
return [4 /*yield*/, axiosInstance.get(path, { params: { data: hexAccAddress } })];
|
|
643
306
|
case 1:
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
if (!("signAmino" in this.signer)) {
|
|
649
|
-
throw new Error("The signer does not support signAmino. Please use an OfflineAminoSigner instance.");
|
|
650
|
-
}
|
|
651
|
-
signDoc = amino_1.makeSignDoc(msgs, fee, chainId, memo, accountNumber, sequence);
|
|
652
|
-
return [4 /*yield*/, this.signer.signAmino(signerAddress, signDoc)];
|
|
307
|
+
result = _a.sent();
|
|
308
|
+
finalData = result.data.result.response.value;
|
|
309
|
+
account = any_1.Any.decode(Buffer.from(finalData, "base64"));
|
|
310
|
+
return [2 /*return*/, (0, accounts_1.accountFromAny)(account)];
|
|
653
311
|
case 2:
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
}
|
|
658
|
-
signatureResult = amino_1.makeStdTx(signDoc, signature);
|
|
659
|
-
decodeData = amino_1.decodeSignature(signatureResult.signatures[0]);
|
|
660
|
-
jsonData = {
|
|
661
|
-
type: "sign/MsgSignData",
|
|
662
|
-
signer: signatureResult.msg[0].value.signer,
|
|
663
|
-
data: signatureResult.msg[0].value.data,
|
|
664
|
-
pubkey: FirmaUtil_1.FirmaUtil.arrayBufferToBase64(decodeData.pubkey),
|
|
665
|
-
signature: FirmaUtil_1.FirmaUtil.arrayBufferToBase64(decodeData.signature)
|
|
666
|
-
};
|
|
667
|
-
return [2 /*return*/, jsonData];
|
|
312
|
+
error_1 = _a.sent();
|
|
313
|
+
return [2 /*return*/, null];
|
|
314
|
+
case 3: return [2 /*return*/];
|
|
668
315
|
}
|
|
669
316
|
});
|
|
670
317
|
});
|
|
671
318
|
};
|
|
319
|
+
SigningStargateClient._endpoint = "";
|
|
672
320
|
return SigningStargateClient;
|
|
673
|
-
}(
|
|
321
|
+
}(stargateClient_1.StargateClient));
|
|
674
322
|
exports.SigningStargateClient = SigningStargateClient;
|