@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
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { CometClient, HttpEndpoint } from "@cosmjs/tendermint-rpc";
|
|
2
|
-
import {
|
|
3
|
-
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
|
|
2
|
+
import { AuthExtension, BankExtension, QueryClient, StakingExtension, TxExtension } from "@cosmjs/stargate";
|
|
4
3
|
import { Account, AccountParser } from "./accounts";
|
|
5
4
|
import { Event } from "./events";
|
|
6
|
-
import { AuthExtension, BankExtension, StakingExtension, TxExtension } from "./modules";
|
|
7
|
-
import { QueryClient } from "./queryclient";
|
|
8
|
-
import { SearchTxQuery } from "./search";
|
|
9
5
|
export declare class TimeoutError extends Error {
|
|
10
6
|
readonly txId: string;
|
|
11
7
|
constructor(message: string, txId: string);
|
|
@@ -37,17 +33,6 @@ export interface IndexedTx {
|
|
|
37
33
|
/** Transaction execution error code. 0 on success. */
|
|
38
34
|
readonly code: number;
|
|
39
35
|
readonly events: readonly Event[];
|
|
40
|
-
/**
|
|
41
|
-
* A string-based log document.
|
|
42
|
-
*
|
|
43
|
-
* This currently seems to merge attributes of multiple events into one event per type
|
|
44
|
-
* (https://github.com/tendermint/tendermint/issues/9595). You might want to use the `events`
|
|
45
|
-
* field instead.
|
|
46
|
-
*
|
|
47
|
-
* @deprecated This field is not filled anymore in Cosmos SDK 0.50+ (https://github.com/cosmos/cosmos-sdk/pull/15845).
|
|
48
|
-
* Please consider using `events` instead.
|
|
49
|
-
*/
|
|
50
|
-
readonly rawLog: string;
|
|
51
36
|
/**
|
|
52
37
|
* Raw transaction bytes stored in Tendermint.
|
|
53
38
|
*
|
|
@@ -64,9 +49,8 @@ export interface IndexedTx {
|
|
|
64
49
|
*/
|
|
65
50
|
readonly tx: Uint8Array;
|
|
66
51
|
/**
|
|
67
|
-
* The message responses
|
|
68
|
-
*
|
|
69
|
-
* This field is an empty list for chains running Cosmos SDK < 0.46.
|
|
52
|
+
* The message responses extracted from events.
|
|
53
|
+
* This field contains structured message response data parsed from transaction events.
|
|
70
54
|
*/
|
|
71
55
|
readonly msgResponses: Array<{
|
|
72
56
|
readonly typeUrl: string;
|
|
@@ -92,22 +76,8 @@ export interface DeliverTxResponse {
|
|
|
92
76
|
readonly transactionHash: string;
|
|
93
77
|
readonly events: readonly Event[];
|
|
94
78
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* This currently seems to merge attributes of multiple events into one event per type
|
|
98
|
-
* (https://github.com/tendermint/tendermint/issues/9595). You might want to use the `events`
|
|
99
|
-
* field instead.
|
|
100
|
-
*
|
|
101
|
-
* @deprecated This field is not filled anymore in Cosmos SDK 0.50+ (https://github.com/cosmos/cosmos-sdk/pull/15845).
|
|
102
|
-
* Please consider using `events` instead.
|
|
103
|
-
*/
|
|
104
|
-
readonly rawLog?: string;
|
|
105
|
-
/** @deprecated Use `msgResponses` instead. */
|
|
106
|
-
readonly data?: readonly MsgData[];
|
|
107
|
-
/**
|
|
108
|
-
* The message responses of the [TxMsgData](https://github.com/cosmos/cosmos-sdk/blob/v0.46.3/proto/cosmos/base/abci/v1beta1/abci.proto#L128-L140)
|
|
109
|
-
* as `Any`s.
|
|
110
|
-
* This field is an empty list for chains running Cosmos SDK < 0.46.
|
|
79
|
+
* The message responses extracted from events.
|
|
80
|
+
* This field contains structured message response data parsed from transaction events.
|
|
111
81
|
*/
|
|
112
82
|
readonly msgResponses: Array<{
|
|
113
83
|
readonly typeUrl: string;
|
|
@@ -116,8 +86,11 @@ export interface DeliverTxResponse {
|
|
|
116
86
|
readonly gasUsed: bigint;
|
|
117
87
|
readonly gasWanted: bigint;
|
|
118
88
|
}
|
|
89
|
+
export type BroadcastTxResponse = DeliverTxResponse;
|
|
119
90
|
export declare function isDeliverTxFailure(result: DeliverTxResponse): boolean;
|
|
120
91
|
export declare function isDeliverTxSuccess(result: DeliverTxResponse): boolean;
|
|
92
|
+
export declare function isBroadcastTxFailure(result: BroadcastTxResponse): boolean;
|
|
93
|
+
export declare function isBroadcastTxSuccess(result: BroadcastTxResponse): boolean;
|
|
121
94
|
/**
|
|
122
95
|
* Ensures the given result is a success. Throws a detailed error message otherwise.
|
|
123
96
|
*/
|
|
@@ -147,6 +120,7 @@ export interface StargateClientOptions {
|
|
|
147
120
|
export declare class StargateClient {
|
|
148
121
|
private readonly cometClient;
|
|
149
122
|
private readonly queryClient;
|
|
123
|
+
private chainId;
|
|
150
124
|
private readonly accountParser;
|
|
151
125
|
/**
|
|
152
126
|
* Creates an instance by connecting to the given CometBFT RPC endpoint.
|
|
@@ -160,27 +134,16 @@ export declare class StargateClient {
|
|
|
160
134
|
* Use this to use `Comet38Client` or `Tendermint37Client` instead of `Tendermint34Client`.
|
|
161
135
|
*/
|
|
162
136
|
static create(cometClient: CometClient, options?: StargateClientOptions): Promise<StargateClient>;
|
|
163
|
-
protected constructor(cometClient: CometClient | undefined, options
|
|
137
|
+
protected constructor(cometClient: CometClient | undefined, options?: StargateClientOptions);
|
|
164
138
|
protected getCometClient(): CometClient | undefined;
|
|
165
139
|
protected forceGetCometClient(): CometClient;
|
|
166
140
|
protected getQueryClient(): (QueryClient & AuthExtension & BankExtension & StakingExtension & TxExtension) | undefined;
|
|
167
141
|
protected forceGetQueryClient(): QueryClient & AuthExtension & BankExtension & StakingExtension & TxExtension;
|
|
142
|
+
getChainId(): Promise<string>;
|
|
168
143
|
getHeight(): Promise<number>;
|
|
169
144
|
getAccount(searchAddress: string): Promise<Account | null>;
|
|
170
145
|
getSequence(address: string): Promise<SequenceResponse>;
|
|
171
|
-
getBlock(height?: number): Promise<Block>;
|
|
172
|
-
getBalance(address: string, searchDenom: string): Promise<Coin>;
|
|
173
|
-
/**
|
|
174
|
-
* Queries all balances for all denoms that belong to this address.
|
|
175
|
-
*
|
|
176
|
-
* Uses the grpc queries (which iterates over the store internally), and we cannot get
|
|
177
|
-
* proofs from such a method.
|
|
178
|
-
*/
|
|
179
|
-
getAllBalances(address: string): Promise<readonly Coin[]>;
|
|
180
|
-
getBalanceStaked(address: string): Promise<Coin | null>;
|
|
181
|
-
getDelegation(delegatorAddress: string, validatorAddress: string): Promise<Coin | null>;
|
|
182
146
|
getTx(id: string): Promise<IndexedTx | null>;
|
|
183
|
-
searchTx(query: SearchTxQuery): Promise<IndexedTx[]>;
|
|
184
147
|
disconnect(): void;
|
|
185
148
|
/**
|
|
186
149
|
* Broadcasts a signed transaction to the network and monitors its inclusion in a block.
|
|
@@ -194,17 +157,5 @@ export declare class StargateClient {
|
|
|
194
157
|
* usually needs to check for execution success or failure.
|
|
195
158
|
*/
|
|
196
159
|
broadcastTx(tx: Uint8Array, timeoutMs?: number, pollIntervalMs?: number): Promise<DeliverTxResponse>;
|
|
197
|
-
/**
|
|
198
|
-
* Broadcasts a signed transaction to the network without monitoring it.
|
|
199
|
-
*
|
|
200
|
-
* If broadcasting is rejected by the node for some reason (e.g. because of a CheckTx failure),
|
|
201
|
-
* an error is thrown.
|
|
202
|
-
*
|
|
203
|
-
* If the transaction is broadcasted, a `string` containing the hash of the transaction is returned. The caller then
|
|
204
|
-
* usually needs to check if the transaction was included in a block and was successful.
|
|
205
|
-
*
|
|
206
|
-
* @returns Returns the hash of the transaction
|
|
207
|
-
*/
|
|
208
|
-
broadcastTxSync(tx: Uint8Array): Promise<string>;
|
|
209
160
|
private txsQuery;
|
|
210
161
|
}
|
|
@@ -29,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
29
29
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
30
|
function step(op) {
|
|
31
31
|
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
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;
|
|
34
34
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
35
|
switch (op[0]) {
|
|
@@ -50,41 +50,26 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
catch (error) { e = { error: error }; }
|
|
61
|
-
finally {
|
|
62
|
-
try {
|
|
63
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
53
|
+
var __values = (this && this.__values) || function(o) {
|
|
54
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
55
|
+
if (m) return m.call(o);
|
|
56
|
+
if (o && typeof o.length === "number") return {
|
|
57
|
+
next: function () {
|
|
58
|
+
if (o && i >= o.length) o = void 0;
|
|
59
|
+
return { value: o && o[i++], done: !o };
|
|
64
60
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return ar;
|
|
68
|
-
};
|
|
69
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
70
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
71
|
-
to[j] = from[i];
|
|
72
|
-
return to;
|
|
61
|
+
};
|
|
62
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
73
63
|
};
|
|
74
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
|
-
exports.StargateClient = exports.BroadcastTxError = exports.assertIsDeliverTxFailure = exports.assertIsDeliverTxSuccess = exports.isDeliverTxSuccess = exports.isDeliverTxFailure = exports.TimeoutError = void 0;
|
|
65
|
+
exports.StargateClient = exports.BroadcastTxError = exports.assertIsDeliverTxFailure = exports.assertIsDeliverTxSuccess = exports.isBroadcastTxSuccess = exports.isBroadcastTxFailure = exports.isDeliverTxSuccess = exports.isDeliverTxFailure = exports.TimeoutError = void 0;
|
|
76
66
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
77
|
-
var amino_1 = require("@cosmjs/amino");
|
|
78
67
|
var encoding_1 = require("@cosmjs/encoding");
|
|
79
|
-
var math_1 = require("@cosmjs/math");
|
|
80
68
|
var tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
|
|
81
69
|
var utils_1 = require("@cosmjs/utils");
|
|
82
|
-
var
|
|
70
|
+
var stargate_1 = require("@cosmjs/stargate");
|
|
83
71
|
var accounts_1 = require("./accounts");
|
|
84
72
|
var events_1 = require("./events");
|
|
85
|
-
var modules_1 = require("./modules");
|
|
86
|
-
var queryclient_1 = require("./queryclient");
|
|
87
|
-
var search_1 = require("./search");
|
|
88
73
|
var TimeoutError = /** @class */ (function (_super) {
|
|
89
74
|
__extends(TimeoutError, _super);
|
|
90
75
|
function TimeoutError(message, txId) {
|
|
@@ -103,12 +88,20 @@ function isDeliverTxSuccess(result) {
|
|
|
103
88
|
return !isDeliverTxFailure(result);
|
|
104
89
|
}
|
|
105
90
|
exports.isDeliverTxSuccess = isDeliverTxSuccess;
|
|
91
|
+
function isBroadcastTxFailure(result) {
|
|
92
|
+
return !!result.code;
|
|
93
|
+
}
|
|
94
|
+
exports.isBroadcastTxFailure = isBroadcastTxFailure;
|
|
95
|
+
function isBroadcastTxSuccess(result) {
|
|
96
|
+
return !isBroadcastTxFailure(result);
|
|
97
|
+
}
|
|
98
|
+
exports.isBroadcastTxSuccess = isBroadcastTxSuccess;
|
|
106
99
|
/**
|
|
107
100
|
* Ensures the given result is a success. Throws a detailed error message otherwise.
|
|
108
101
|
*/
|
|
109
102
|
function assertIsDeliverTxSuccess(result) {
|
|
110
103
|
if (isDeliverTxFailure(result)) {
|
|
111
|
-
throw new Error("Error when broadcasting tx "
|
|
104
|
+
throw new Error("Error when broadcasting tx ".concat(result.transactionHash, " at height ").concat(result.height, ". Code: ").concat(result.code, "; Check events for details."));
|
|
112
105
|
}
|
|
113
106
|
}
|
|
114
107
|
exports.assertIsDeliverTxSuccess = assertIsDeliverTxSuccess;
|
|
@@ -117,7 +110,7 @@ exports.assertIsDeliverTxSuccess = assertIsDeliverTxSuccess;
|
|
|
117
110
|
*/
|
|
118
111
|
function assertIsDeliverTxFailure(result) {
|
|
119
112
|
if (isDeliverTxSuccess(result)) {
|
|
120
|
-
throw new Error("Transaction "
|
|
113
|
+
throw new Error("Transaction ".concat(result.transactionHash, " did not fail at height ").concat(result.height, ". Code: ").concat(result.code, "; Check events for details."));
|
|
121
114
|
}
|
|
122
115
|
}
|
|
123
116
|
exports.assertIsDeliverTxFailure = assertIsDeliverTxFailure;
|
|
@@ -129,7 +122,7 @@ exports.assertIsDeliverTxFailure = assertIsDeliverTxFailure;
|
|
|
129
122
|
var BroadcastTxError = /** @class */ (function (_super) {
|
|
130
123
|
__extends(BroadcastTxError, _super);
|
|
131
124
|
function BroadcastTxError(code, codespace, log) {
|
|
132
|
-
var _this = _super.call(this, "Broadcasting transaction failed with code "
|
|
125
|
+
var _this = _super.call(this, "Broadcasting transaction failed with code ".concat(code, " (codespace: ").concat(codespace, "). Log: ").concat(log)) || this;
|
|
133
126
|
_this.code = code;
|
|
134
127
|
_this.codespace = codespace;
|
|
135
128
|
_this.log = log;
|
|
@@ -138,11 +131,56 @@ var BroadcastTxError = /** @class */ (function (_super) {
|
|
|
138
131
|
return BroadcastTxError;
|
|
139
132
|
}(Error));
|
|
140
133
|
exports.BroadcastTxError = BroadcastTxError;
|
|
134
|
+
/**
|
|
135
|
+
* Extracts message responses from transaction events.
|
|
136
|
+
* In Cosmos SDK v0.50+, message responses are embedded in events rather than separate data fields.
|
|
137
|
+
*/
|
|
138
|
+
function extractMsgResponsesFromEvents(events) {
|
|
139
|
+
var e_1, _a, e_2, _b;
|
|
140
|
+
var msgResponses = [];
|
|
141
|
+
try {
|
|
142
|
+
for (var events_2 = __values(events), events_2_1 = events_2.next(); !events_2_1.done; events_2_1 = events_2.next()) {
|
|
143
|
+
var event_1 = events_2_1.value;
|
|
144
|
+
if (event_1.type === "message") {
|
|
145
|
+
try {
|
|
146
|
+
// Look for message response data in message events
|
|
147
|
+
for (var _c = (e_2 = void 0, __values(event_1.attributes)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
148
|
+
var attr = _d.value;
|
|
149
|
+
if (attr.key === "module" || attr.key === "action") {
|
|
150
|
+
// Extract type information for message responses
|
|
151
|
+
var typeUrl = "/cosmos.".concat(attr.value);
|
|
152
|
+
msgResponses.push({
|
|
153
|
+
typeUrl: typeUrl,
|
|
154
|
+
value: new Uint8Array(), // In v0.50, detailed response data is in other events
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
160
|
+
finally {
|
|
161
|
+
try {
|
|
162
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
163
|
+
}
|
|
164
|
+
finally { if (e_2) throw e_2.error; }
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
170
|
+
finally {
|
|
171
|
+
try {
|
|
172
|
+
if (events_2_1 && !events_2_1.done && (_a = events_2.return)) _a.call(events_2);
|
|
173
|
+
}
|
|
174
|
+
finally { if (e_1) throw e_1.error; }
|
|
175
|
+
}
|
|
176
|
+
return msgResponses;
|
|
177
|
+
}
|
|
141
178
|
var StargateClient = /** @class */ (function () {
|
|
142
179
|
function StargateClient(cometClient, options) {
|
|
180
|
+
if (options === void 0) { options = {}; }
|
|
143
181
|
if (cometClient) {
|
|
144
182
|
this.cometClient = cometClient;
|
|
145
|
-
this.queryClient =
|
|
183
|
+
this.queryClient = stargate_1.QueryClient.withExtensions(cometClient, stargate_1.setupAuthExtension, stargate_1.setupBankExtension, stargate_1.setupStakingExtension, stargate_1.setupTxExtension);
|
|
146
184
|
}
|
|
147
185
|
var _a = options.accountParser, accountParser = _a === void 0 ? accounts_1.accountFromAny : _a;
|
|
148
186
|
this.accountParser = accountParser;
|
|
@@ -159,7 +197,7 @@ var StargateClient = /** @class */ (function () {
|
|
|
159
197
|
var cometClient;
|
|
160
198
|
return __generator(this, function (_a) {
|
|
161
199
|
switch (_a.label) {
|
|
162
|
-
case 0: return [4 /*yield*/, tendermint_rpc_1.connectComet(endpoint)];
|
|
200
|
+
case 0: return [4 /*yield*/, (0, tendermint_rpc_1.connectComet)(endpoint)];
|
|
163
201
|
case 1:
|
|
164
202
|
cometClient = _a.sent();
|
|
165
203
|
return [2 /*return*/, StargateClient.create(cometClient, options)];
|
|
@@ -197,6 +235,26 @@ var StargateClient = /** @class */ (function () {
|
|
|
197
235
|
}
|
|
198
236
|
return this.queryClient;
|
|
199
237
|
};
|
|
238
|
+
StargateClient.prototype.getChainId = function () {
|
|
239
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
240
|
+
var response, chainId;
|
|
241
|
+
return __generator(this, function (_a) {
|
|
242
|
+
switch (_a.label) {
|
|
243
|
+
case 0:
|
|
244
|
+
if (!!this.chainId) return [3 /*break*/, 2];
|
|
245
|
+
return [4 /*yield*/, this.forceGetCometClient().status()];
|
|
246
|
+
case 1:
|
|
247
|
+
response = _a.sent();
|
|
248
|
+
chainId = response.nodeInfo.network;
|
|
249
|
+
if (!chainId)
|
|
250
|
+
throw new Error("Chain ID must not be empty");
|
|
251
|
+
this.chainId = chainId;
|
|
252
|
+
_a.label = 2;
|
|
253
|
+
case 2: return [2 /*return*/, this.chainId];
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
};
|
|
200
258
|
StargateClient.prototype.getHeight = function () {
|
|
201
259
|
return __awaiter(this, void 0, void 0, function () {
|
|
202
260
|
var status;
|
|
@@ -241,7 +299,7 @@ var StargateClient = /** @class */ (function () {
|
|
|
241
299
|
case 1:
|
|
242
300
|
account = _a.sent();
|
|
243
301
|
if (!account) {
|
|
244
|
-
throw new Error("Account '"
|
|
302
|
+
throw new Error("Account '".concat(address, "' does not exist on chain. Send some tokens there before trying to query sequence."));
|
|
245
303
|
}
|
|
246
304
|
return [2 /*return*/, {
|
|
247
305
|
accountNumber: account.accountNumber,
|
|
@@ -251,114 +309,13 @@ var StargateClient = /** @class */ (function () {
|
|
|
251
309
|
});
|
|
252
310
|
});
|
|
253
311
|
};
|
|
254
|
-
StargateClient.prototype.getBlock = function (height) {
|
|
255
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
-
var response;
|
|
257
|
-
return __generator(this, function (_a) {
|
|
258
|
-
switch (_a.label) {
|
|
259
|
-
case 0: return [4 /*yield*/, this.forceGetCometClient().block(height)];
|
|
260
|
-
case 1:
|
|
261
|
-
response = _a.sent();
|
|
262
|
-
return [2 /*return*/, {
|
|
263
|
-
id: encoding_1.toHex(response.blockId.hash).toUpperCase(),
|
|
264
|
-
header: {
|
|
265
|
-
version: {
|
|
266
|
-
block: new math_1.Uint53(response.block.header.version.block).toString(),
|
|
267
|
-
app: new math_1.Uint53(response.block.header.version.app).toString(),
|
|
268
|
-
},
|
|
269
|
-
height: response.block.header.height,
|
|
270
|
-
chainId: response.block.header.chainId,
|
|
271
|
-
time: tendermint_rpc_1.toRfc3339WithNanoseconds(response.block.header.time),
|
|
272
|
-
},
|
|
273
|
-
txs: response.block.txs,
|
|
274
|
-
}];
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
StargateClient.prototype.getBalance = function (address, searchDenom) {
|
|
280
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
281
|
-
return __generator(this, function (_a) {
|
|
282
|
-
return [2 /*return*/, this.forceGetQueryClient().bank.balance(address, searchDenom)];
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
/**
|
|
287
|
-
* Queries all balances for all denoms that belong to this address.
|
|
288
|
-
*
|
|
289
|
-
* Uses the grpc queries (which iterates over the store internally), and we cannot get
|
|
290
|
-
* proofs from such a method.
|
|
291
|
-
*/
|
|
292
|
-
StargateClient.prototype.getAllBalances = function (address) {
|
|
293
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
294
|
-
return __generator(this, function (_a) {
|
|
295
|
-
return [2 /*return*/, this.forceGetQueryClient().bank.allBalances(address)];
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
};
|
|
299
|
-
StargateClient.prototype.getBalanceStaked = function (address) {
|
|
300
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
301
|
-
var allDelegations, startAtKey, _a, delegationResponses, pagination, loadedDelegations, sumValues;
|
|
302
|
-
return __generator(this, function (_b) {
|
|
303
|
-
switch (_b.label) {
|
|
304
|
-
case 0:
|
|
305
|
-
allDelegations = [];
|
|
306
|
-
startAtKey = undefined;
|
|
307
|
-
_b.label = 1;
|
|
308
|
-
case 1: return [4 /*yield*/, this.forceGetQueryClient().staking.delegatorDelegations(address, startAtKey)];
|
|
309
|
-
case 2:
|
|
310
|
-
_a = _b.sent(), delegationResponses = _a.delegationResponses, pagination = _a.pagination;
|
|
311
|
-
loadedDelegations = delegationResponses || [];
|
|
312
|
-
allDelegations.push.apply(allDelegations, __spreadArray([], __read(loadedDelegations)));
|
|
313
|
-
startAtKey = pagination === null || pagination === void 0 ? void 0 : pagination.nextKey;
|
|
314
|
-
_b.label = 3;
|
|
315
|
-
case 3:
|
|
316
|
-
if (startAtKey !== undefined && startAtKey.length !== 0) return [3 /*break*/, 1];
|
|
317
|
-
_b.label = 4;
|
|
318
|
-
case 4:
|
|
319
|
-
sumValues = allDelegations.reduce(function (previousValue, currentValue) {
|
|
320
|
-
// Safe because field is set to non-nullable (https://github.com/cosmos/cosmos-sdk/blob/v0.45.3/proto/cosmos/staking/v1beta1/staking.proto#L295)
|
|
321
|
-
utils_1.assert(currentValue.balance);
|
|
322
|
-
return previousValue !== null ? amino_1.addCoins(previousValue, currentValue.balance) : currentValue.balance;
|
|
323
|
-
}, null);
|
|
324
|
-
return [2 /*return*/, sumValues];
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
};
|
|
329
|
-
StargateClient.prototype.getDelegation = function (delegatorAddress, validatorAddress) {
|
|
330
|
-
var _a;
|
|
331
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
332
|
-
var delegatedAmount, e_1;
|
|
333
|
-
return __generator(this, function (_b) {
|
|
334
|
-
switch (_b.label) {
|
|
335
|
-
case 0:
|
|
336
|
-
_b.trys.push([0, 2, , 3]);
|
|
337
|
-
return [4 /*yield*/, this.forceGetQueryClient().staking.delegation(delegatorAddress, validatorAddress)];
|
|
338
|
-
case 1:
|
|
339
|
-
delegatedAmount = (_a = (_b.sent()).delegationResponse) === null || _a === void 0 ? void 0 : _a.balance;
|
|
340
|
-
return [3 /*break*/, 3];
|
|
341
|
-
case 2:
|
|
342
|
-
e_1 = _b.sent();
|
|
343
|
-
if (e_1.toString().includes("key not found")) {
|
|
344
|
-
// ignore, `delegatedAmount` remains undefined
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
throw e_1;
|
|
348
|
-
}
|
|
349
|
-
return [3 /*break*/, 3];
|
|
350
|
-
case 3: return [2 /*return*/, delegatedAmount || null];
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
};
|
|
355
312
|
StargateClient.prototype.getTx = function (id) {
|
|
356
313
|
var _a;
|
|
357
314
|
return __awaiter(this, void 0, void 0, function () {
|
|
358
315
|
var results;
|
|
359
316
|
return __generator(this, function (_b) {
|
|
360
317
|
switch (_b.label) {
|
|
361
|
-
case 0: return [4 /*yield*/, this.txsQuery("tx.hash='"
|
|
318
|
+
case 0: return [4 /*yield*/, this.txsQuery("tx.hash='".concat(id, "'"))];
|
|
362
319
|
case 1:
|
|
363
320
|
results = _b.sent();
|
|
364
321
|
return [2 /*return*/, (_a = results[0]) !== null && _a !== void 0 ? _a : null];
|
|
@@ -366,31 +323,6 @@ var StargateClient = /** @class */ (function () {
|
|
|
366
323
|
});
|
|
367
324
|
});
|
|
368
325
|
};
|
|
369
|
-
StargateClient.prototype.searchTx = function (query) {
|
|
370
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
371
|
-
var rawQuery;
|
|
372
|
-
return __generator(this, function (_a) {
|
|
373
|
-
if (typeof query === "string") {
|
|
374
|
-
rawQuery = query;
|
|
375
|
-
}
|
|
376
|
-
else if (search_1.isSearchTxQueryArray(query)) {
|
|
377
|
-
rawQuery = query
|
|
378
|
-
.map(function (t) {
|
|
379
|
-
// numeric values must not have quotes https://github.com/cosmos/cosmjs/issues/1462
|
|
380
|
-
if (typeof t.value === "string")
|
|
381
|
-
return t.key + "='" + t.value + "'";
|
|
382
|
-
else
|
|
383
|
-
return t.key + "=" + t.value;
|
|
384
|
-
})
|
|
385
|
-
.join(" AND ");
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
throw new Error("Got unsupported query type. See CosmJS 0.31 CHANGELOG for API breaking changes here.");
|
|
389
|
-
}
|
|
390
|
-
return [2 /*return*/, this.txsQuery(rawQuery)];
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
};
|
|
394
326
|
StargateClient.prototype.disconnect = function () {
|
|
395
327
|
if (this.cometClient)
|
|
396
328
|
this.cometClient.disconnect();
|
|
@@ -407,13 +339,14 @@ var StargateClient = /** @class */ (function () {
|
|
|
407
339
|
* usually needs to check for execution success or failure.
|
|
408
340
|
*/
|
|
409
341
|
StargateClient.prototype.broadcastTx = function (tx, timeoutMs, pollIntervalMs) {
|
|
342
|
+
var _a;
|
|
410
343
|
if (timeoutMs === void 0) { timeoutMs = 60000; }
|
|
411
344
|
if (pollIntervalMs === void 0) { pollIntervalMs = 3000; }
|
|
412
345
|
return __awaiter(this, void 0, void 0, function () {
|
|
413
|
-
var timedOut, txPollTimeout, pollForTx, transactionId;
|
|
346
|
+
var timedOut, txPollTimeout, pollForTx, broadcasted, transactionId;
|
|
414
347
|
var _this = this;
|
|
415
|
-
return __generator(this, function (
|
|
416
|
-
switch (
|
|
348
|
+
return __generator(this, function (_b) {
|
|
349
|
+
switch (_b.label) {
|
|
417
350
|
case 0:
|
|
418
351
|
timedOut = false;
|
|
419
352
|
txPollTimeout = setTimeout(function () {
|
|
@@ -425,9 +358,9 @@ var StargateClient = /** @class */ (function () {
|
|
|
425
358
|
switch (_a.label) {
|
|
426
359
|
case 0:
|
|
427
360
|
if (timedOut) {
|
|
428
|
-
throw new TimeoutError("Transaction with ID "
|
|
361
|
+
throw new TimeoutError("Transaction with ID ".concat(txId, " was submitted but was not yet found on the chain. You might want to check later. There was a wait of ").concat(timeoutMs / 1000, " seconds."), txId);
|
|
429
362
|
}
|
|
430
|
-
return [4 /*yield*/, utils_1.sleep(pollIntervalMs)];
|
|
363
|
+
return [4 /*yield*/, (0, utils_1.sleep)(pollIntervalMs)];
|
|
431
364
|
case 1:
|
|
432
365
|
_a.sent();
|
|
433
366
|
return [4 /*yield*/, this.getTx(txId)];
|
|
@@ -439,7 +372,6 @@ var StargateClient = /** @class */ (function () {
|
|
|
439
372
|
height: result.height,
|
|
440
373
|
txIndex: result.txIndex,
|
|
441
374
|
events: result.events,
|
|
442
|
-
rawLog: result.rawLog,
|
|
443
375
|
transactionHash: txId,
|
|
444
376
|
msgResponses: result.msgResponses,
|
|
445
377
|
gasUsed: result.gasUsed,
|
|
@@ -449,9 +381,13 @@ var StargateClient = /** @class */ (function () {
|
|
|
449
381
|
}
|
|
450
382
|
});
|
|
451
383
|
}); };
|
|
452
|
-
return [4 /*yield*/, this.broadcastTxSync(tx)];
|
|
384
|
+
return [4 /*yield*/, this.forceGetCometClient().broadcastTxSync({ tx: tx })];
|
|
453
385
|
case 1:
|
|
454
|
-
|
|
386
|
+
broadcasted = _b.sent();
|
|
387
|
+
if (broadcasted.code) {
|
|
388
|
+
return [2 /*return*/, Promise.reject(new BroadcastTxError(broadcasted.code, (_a = broadcasted.codespace) !== null && _a !== void 0 ? _a : "", broadcasted.log))];
|
|
389
|
+
}
|
|
390
|
+
transactionId = (0, encoding_1.toHex)(broadcasted.hash).toUpperCase();
|
|
455
391
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
456
392
|
return pollForTx(transactionId).then(function (value) {
|
|
457
393
|
clearTimeout(txPollTimeout);
|
|
@@ -465,35 +401,6 @@ var StargateClient = /** @class */ (function () {
|
|
|
465
401
|
});
|
|
466
402
|
});
|
|
467
403
|
};
|
|
468
|
-
/**
|
|
469
|
-
* Broadcasts a signed transaction to the network without monitoring it.
|
|
470
|
-
*
|
|
471
|
-
* If broadcasting is rejected by the node for some reason (e.g. because of a CheckTx failure),
|
|
472
|
-
* an error is thrown.
|
|
473
|
-
*
|
|
474
|
-
* If the transaction is broadcasted, a `string` containing the hash of the transaction is returned. The caller then
|
|
475
|
-
* usually needs to check if the transaction was included in a block and was successful.
|
|
476
|
-
*
|
|
477
|
-
* @returns Returns the hash of the transaction
|
|
478
|
-
*/
|
|
479
|
-
StargateClient.prototype.broadcastTxSync = function (tx) {
|
|
480
|
-
var _a;
|
|
481
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
482
|
-
var broadcasted, transactionId;
|
|
483
|
-
return __generator(this, function (_b) {
|
|
484
|
-
switch (_b.label) {
|
|
485
|
-
case 0: return [4 /*yield*/, this.forceGetCometClient().broadcastTxSync({ tx: tx })];
|
|
486
|
-
case 1:
|
|
487
|
-
broadcasted = _b.sent();
|
|
488
|
-
if (broadcasted.code) {
|
|
489
|
-
return [2 /*return*/, Promise.reject(new BroadcastTxError(broadcasted.code, (_a = broadcasted.codespace) !== null && _a !== void 0 ? _a : "", broadcasted.log))];
|
|
490
|
-
}
|
|
491
|
-
transactionId = encoding_1.toHex(broadcasted.hash).toUpperCase();
|
|
492
|
-
return [2 /*return*/, transactionId];
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
});
|
|
496
|
-
};
|
|
497
404
|
StargateClient.prototype.txsQuery = function (query) {
|
|
498
405
|
return __awaiter(this, void 0, void 0, function () {
|
|
499
406
|
var results;
|
|
@@ -503,17 +410,16 @@ var StargateClient = /** @class */ (function () {
|
|
|
503
410
|
case 1:
|
|
504
411
|
results = _a.sent();
|
|
505
412
|
return [2 /*return*/, results.txs.map(function (tx) {
|
|
506
|
-
var
|
|
507
|
-
var
|
|
413
|
+
var events = tx.result.events.map(events_1.fromTendermintEvent);
|
|
414
|
+
var msgResponses = extractMsgResponsesFromEvents(events);
|
|
508
415
|
return {
|
|
509
416
|
height: tx.height,
|
|
510
417
|
txIndex: tx.index,
|
|
511
|
-
hash: encoding_1.toHex(tx.hash).toUpperCase(),
|
|
418
|
+
hash: (0, encoding_1.toHex)(tx.hash).toUpperCase(),
|
|
512
419
|
code: tx.result.code,
|
|
513
|
-
events:
|
|
514
|
-
rawLog: tx.result.log || "",
|
|
420
|
+
events: events,
|
|
515
421
|
tx: tx.tx,
|
|
516
|
-
msgResponses:
|
|
422
|
+
msgResponses: msgResponses,
|
|
517
423
|
gasUsed: tx.result.gasUsed,
|
|
518
424
|
gasWanted: tx.result.gasWanted,
|
|
519
425
|
};
|