@injectivelabs/sdk-ts 1.0.337 → 1.0.339
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/client/chain/grpc/ChainGrpcAuctionApi.js +42 -57
- package/dist/client/chain/grpc/ChainGrpcAuctionApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcAuthApi.js +38 -53
- package/dist/client/chain/grpc/ChainGrpcAuthApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcBankApi.js +63 -80
- package/dist/client/chain/grpc/ChainGrpcBankApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcDistributionApi.js +68 -87
- package/dist/client/chain/grpc/ChainGrpcDistributionApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcExchangeApi.js +142 -169
- package/dist/client/chain/grpc/ChainGrpcExchangeApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcGovApi.js +110 -131
- package/dist/client/chain/grpc/ChainGrpcGovApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcIbcApi.js +29 -42
- package/dist/client/chain/grpc/ChainGrpcIbcApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcInsuranceFundApi.js +75 -94
- package/dist/client/chain/grpc/ChainGrpcInsuranceFundApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcMintApi.js +46 -61
- package/dist/client/chain/grpc/ChainGrpcMintApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcOracleApi.js +14 -25
- package/dist/client/chain/grpc/ChainGrpcOracleApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcPeggyApi.js +14 -25
- package/dist/client/chain/grpc/ChainGrpcPeggyApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcStakingApi.js +336 -379
- package/dist/client/chain/grpc/ChainGrpcStakingApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcWasmApi.js +149 -174
- package/dist/client/chain/grpc/ChainGrpcWasmApi.js.map +1 -1
- package/dist/client/chain/grpc/ChainGrpcWasmXApi.js +28 -41
- package/dist/client/chain/grpc/ChainGrpcWasmXApi.js.map +1 -1
- package/dist/client/chain/rest/ChainRestAuthApi.js +30 -43
- package/dist/client/chain/rest/ChainRestAuthApi.js.map +1 -1
- package/dist/client/chain/rest/ChainRestBankApi.js +35 -48
- package/dist/client/chain/rest/ChainRestBankApi.js.map +1 -1
- package/dist/client/chain/rest/ChainRestTendermintApi.js +29 -42
- package/dist/client/chain/rest/ChainRestTendermintApi.js.map +1 -1
- package/dist/client/chain/types/index.js +1 -1
- package/dist/client/chain/types/index.js.map +1 -1
- package/dist/client/gql/client.js +25 -38
- package/dist/client/gql/client.js.map +1 -1
- package/dist/client/indexer/grpc/IndexerGrpcAccountApi.js +157 -182
- package/dist/client/indexer/grpc/IndexerGrpcAccountApi.js.map +1 -1
- package/dist/client/indexer/grpc/IndexerGrpcAuctionApi.js +32 -45
- package/dist/client/indexer/grpc/IndexerGrpcAuctionApi.js.map +1 -1
- package/dist/client/indexer/grpc/IndexerGrpcDerivativesApi.js +435 -472
- package/dist/client/indexer/grpc/IndexerGrpcDerivativesApi.js.map +1 -1
- package/dist/client/indexer/grpc/IndexerGrpcExplorerApi.js +236 -265
- package/dist/client/indexer/grpc/IndexerGrpcExplorerApi.js.map +1 -1
- package/dist/client/indexer/grpc/IndexerGrpcInsuranceFundApi.js +35 -48
- package/dist/client/indexer/grpc/IndexerGrpcInsuranceFundApi.js.map +1 -1
- package/dist/client/indexer/grpc/IndexerGrpcMetaApi.js +42 -57
- package/dist/client/indexer/grpc/IndexerGrpcMetaApi.js.map +1 -1
- package/dist/client/indexer/grpc/IndexerGrpcNinjaApi.js +182 -207
- package/dist/client/indexer/grpc/IndexerGrpcNinjaApi.js.map +1 -1
- package/dist/client/indexer/grpc/IndexerGrpcOracleApi.js +58 -73
- package/dist/client/indexer/grpc/IndexerGrpcOracleApi.js.map +1 -1
- package/dist/client/indexer/grpc/IndexerGrpcSpotApi.js +289 -316
- package/dist/client/indexer/grpc/IndexerGrpcSpotApi.js.map +1 -1
- package/dist/client/indexer/grpc/IndexerGrpcTransactionApi.js +193 -214
- package/dist/client/indexer/grpc/IndexerGrpcTransactionApi.js.map +1 -1
- package/dist/client/indexer/rest/IndexerRestDerivativesChronosApi.js +33 -46
- package/dist/client/indexer/rest/IndexerRestDerivativesChronosApi.js.map +1 -1
- package/dist/client/indexer/rest/IndexerRestExplorerApi.js +283 -322
- package/dist/client/indexer/rest/IndexerRestExplorerApi.js.map +1 -1
- package/dist/client/indexer/rest/IndexerRestLeaderboardChronosApi.js +16 -27
- package/dist/client/indexer/rest/IndexerRestLeaderboardChronosApi.js.map +1 -1
- package/dist/client/indexer/rest/IndexerRestMarketChronosApi.js +26 -37
- package/dist/client/indexer/rest/IndexerRestMarketChronosApi.js.map +1 -1
- package/dist/client/indexer/rest/IndexerRestSpotChronosApi.js +33 -46
- package/dist/client/indexer/rest/IndexerRestSpotChronosApi.js.map +1 -1
- package/dist/client/indexer/transformers/IndexerGrpcDerivativeTransformer.js +13 -1
- package/dist/client/indexer/transformers/IndexerGrpcDerivativeTransformer.js.map +1 -1
- package/dist/client/indexer/transformers/IndexerGrpcExplorerTransformer.js +1 -1
- package/dist/client/indexer/transformers/IndexerGrpcExplorerTransformer.js.map +1 -1
- package/dist/client/indexer/transformers/IndexerGrpcSpotTransformer.js +12 -1
- package/dist/client/indexer/transformers/IndexerGrpcSpotTransformer.js.map +1 -1
- package/dist/client/indexer/transformers/IndexerRestExplorerTransformer.js +6 -2
- package/dist/client/indexer/transformers/IndexerRestExplorerTransformer.js.map +1 -1
- package/dist/client/indexer/types/index.js +1 -1
- package/dist/client/indexer/types/index.js.map +1 -1
- package/dist/client/wasm/supernova/transformer.js +20 -2
- package/dist/client/wasm/supernova/transformer.js.map +1 -1
- package/dist/core/accounts/PrivateKey.js +46 -67
- package/dist/core/accounts/PrivateKey.js.map +1 -1
- package/dist/core/accounts/signers/OfflineAminoSigner.js +28 -43
- package/dist/core/accounts/signers/OfflineAminoSigner.js.map +1 -1
- package/dist/core/accounts/signers/OfflineDirectSigner.js +28 -43
- package/dist/core/accounts/signers/OfflineDirectSigner.js.map +1 -1
- package/dist/core/modules/MsgBase.js +1 -12
- package/dist/core/modules/MsgBase.js.map +1 -1
- package/dist/core/modules/auction/msgs/MsgBid.js +13 -15
- package/dist/core/modules/auction/msgs/MsgBid.js.map +1 -1
- package/dist/core/modules/authz/msgs/MsgExec.js +13 -15
- package/dist/core/modules/authz/msgs/MsgExec.js.map +1 -1
- package/dist/core/modules/authz/msgs/MsgGrant.js +22 -17
- package/dist/core/modules/authz/msgs/MsgGrant.js.map +1 -1
- package/dist/core/modules/authz/msgs/MsgRevoke.js +13 -15
- package/dist/core/modules/authz/msgs/MsgRevoke.js.map +1 -1
- package/dist/core/modules/bank/msgs/MsgSend.js +18 -17
- package/dist/core/modules/bank/msgs/MsgSend.js.map +1 -1
- package/dist/core/modules/distribution/msgs/MsgWithdrawDelegatorReward.js +13 -15
- package/dist/core/modules/distribution/msgs/MsgWithdrawDelegatorReward.js.map +1 -1
- package/dist/core/modules/distribution/msgs/MsgWithdrawValidatorCommission.js +13 -15
- package/dist/core/modules/distribution/msgs/MsgWithdrawValidatorCommission.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgBatchCancelBinaryOptionsOrders.js +16 -18
- package/dist/core/modules/exchange/msgs/MsgBatchCancelBinaryOptionsOrders.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgBatchCancelDerivativeOrders.js +16 -18
- package/dist/core/modules/exchange/msgs/MsgBatchCancelDerivativeOrders.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgBatchCancelSpotOrders.js +16 -18
- package/dist/core/modules/exchange/msgs/MsgBatchCancelSpotOrders.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgBatchUpdateOrders.js +33 -18
- package/dist/core/modules/exchange/msgs/MsgBatchUpdateOrders.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgCancelBinaryOptionsOrder.js +13 -15
- package/dist/core/modules/exchange/msgs/MsgCancelBinaryOptionsOrder.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgCancelDerivativeOrder.js +13 -15
- package/dist/core/modules/exchange/msgs/MsgCancelDerivativeOrder.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgCancelSpotOrder.js +13 -15
- package/dist/core/modules/exchange/msgs/MsgCancelSpotOrder.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgCreateBinaryOptionsLimitOrder.js +20 -16
- package/dist/core/modules/exchange/msgs/MsgCreateBinaryOptionsLimitOrder.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgCreateBinaryOptionsMarketOrder.js +20 -16
- package/dist/core/modules/exchange/msgs/MsgCreateBinaryOptionsMarketOrder.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgCreateDerivativeLimitOrder.js +20 -16
- package/dist/core/modules/exchange/msgs/MsgCreateDerivativeLimitOrder.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgCreateDerivativeMarketOrder.js +20 -16
- package/dist/core/modules/exchange/msgs/MsgCreateDerivativeMarketOrder.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgCreateSpotLimitOrder.js +19 -16
- package/dist/core/modules/exchange/msgs/MsgCreateSpotLimitOrder.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgCreateSpotMarketOrder.js +19 -16
- package/dist/core/modules/exchange/msgs/MsgCreateSpotMarketOrder.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgDeposit.js +13 -15
- package/dist/core/modules/exchange/msgs/MsgDeposit.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgExternalTransfer.js +13 -15
- package/dist/core/modules/exchange/msgs/MsgExternalTransfer.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgIncreasePositionMargin.js +17 -16
- package/dist/core/modules/exchange/msgs/MsgIncreasePositionMargin.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgInstantBinaryOptionsMarketLaunch.js +23 -16
- package/dist/core/modules/exchange/msgs/MsgInstantBinaryOptionsMarketLaunch.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgInstantSpotMarketLaunch.js +21 -16
- package/dist/core/modules/exchange/msgs/MsgInstantSpotMarketLaunch.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgMultiExecute.js +12 -3
- package/dist/core/modules/exchange/msgs/MsgMultiExecute.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgReclaimLockedFunds.js +13 -15
- package/dist/core/modules/exchange/msgs/MsgReclaimLockedFunds.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgTransferAndExecute.js +20 -5
- package/dist/core/modules/exchange/msgs/MsgTransferAndExecute.js.map +1 -1
- package/dist/core/modules/exchange/msgs/MsgWithdraw.js +13 -15
- package/dist/core/modules/exchange/msgs/MsgWithdraw.js.map +1 -1
- package/dist/core/modules/exchange/utils/classes/OrderHashManager.js +28 -43
- package/dist/core/modules/exchange/utils/classes/OrderHashManager.js.map +1 -1
- package/dist/core/modules/gov/msgs/MsgDeposit.js +18 -17
- package/dist/core/modules/gov/msgs/MsgDeposit.js.map +1 -1
- package/dist/core/modules/gov/msgs/MsgSubmitProposalExpiryFuturesMarketLaunch.js +32 -7
- package/dist/core/modules/gov/msgs/MsgSubmitProposalExpiryFuturesMarketLaunch.js.map +1 -1
- package/dist/core/modules/gov/msgs/MsgSubmitProposalPerpetualMarketLaunch.js +32 -7
- package/dist/core/modules/gov/msgs/MsgSubmitProposalPerpetualMarketLaunch.js.map +1 -1
- package/dist/core/modules/gov/msgs/MsgSubmitProposalSpotMarketLaunch.js +32 -7
- package/dist/core/modules/gov/msgs/MsgSubmitProposalSpotMarketLaunch.js.map +1 -1
- package/dist/core/modules/gov/msgs/MsgSubmitProposalSpotMarketParamUpdate.js +32 -7
- package/dist/core/modules/gov/msgs/MsgSubmitProposalSpotMarketParamUpdate.js.map +1 -1
- package/dist/core/modules/gov/msgs/MsgSubmitTextProposal.js +32 -7
- package/dist/core/modules/gov/msgs/MsgSubmitTextProposal.js.map +1 -1
- package/dist/core/modules/gov/msgs/MsgVote.js +13 -15
- package/dist/core/modules/gov/msgs/MsgVote.js.map +1 -1
- package/dist/core/modules/ibc/msgs/MsgTransfer.js +13 -15
- package/dist/core/modules/ibc/msgs/MsgTransfer.js.map +1 -1
- package/dist/core/modules/insurance/msgs/MsgCreateInsuranceFund.js +13 -15
- package/dist/core/modules/insurance/msgs/MsgCreateInsuranceFund.js.map +1 -1
- package/dist/core/modules/insurance/msgs/MsgRequestRedemption.js +13 -15
- package/dist/core/modules/insurance/msgs/MsgRequestRedemption.js.map +1 -1
- package/dist/core/modules/insurance/msgs/MsgUnderwrite.js +13 -15
- package/dist/core/modules/insurance/msgs/MsgUnderwrite.js.map +1 -1
- package/dist/core/modules/peggy/msgs/MsgSendToEth.js +13 -15
- package/dist/core/modules/peggy/msgs/MsgSendToEth.js.map +1 -1
- package/dist/core/modules/staking/msgs/MsgBeginRedelegate.js +13 -15
- package/dist/core/modules/staking/msgs/MsgBeginRedelegate.js.map +1 -1
- package/dist/core/modules/staking/msgs/MsgDelegate.js +13 -15
- package/dist/core/modules/staking/msgs/MsgDelegate.js.map +1 -1
- package/dist/core/modules/staking/msgs/MsgEditValidator.js +13 -15
- package/dist/core/modules/staking/msgs/MsgEditValidator.js.map +1 -1
- package/dist/core/modules/staking/msgs/MsgUndelegate.js +13 -15
- package/dist/core/modules/staking/msgs/MsgUndelegate.js.map +1 -1
- package/dist/core/modules/tx/api/TxGrpcApi.js +120 -130
- package/dist/core/modules/tx/api/TxGrpcApi.js.map +1 -1
- package/dist/core/modules/tx/api/TxRestApi.js +163 -181
- package/dist/core/modules/tx/api/TxRestApi.js.map +1 -1
- package/dist/core/modules/tx/broadcaster/MsgBroadcasterWithPk.js +84 -84
- package/dist/core/modules/tx/broadcaster/MsgBroadcasterWithPk.js.map +1 -1
- package/dist/core/modules/tx/eip712/eip712.js +14 -2
- package/dist/core/modules/tx/eip712/eip712.js.map +1 -1
- package/dist/core/modules/tx/eip712/maps.js +24 -6
- package/dist/core/modules/tx/eip712/maps.js.map +1 -1
- package/dist/core/modules/tx/tx.js +34 -24
- package/dist/core/modules/tx/tx.js.map +1 -1
- package/dist/core/modules/wasm/exec-args/ExecArgInitiateTransfer.js +9 -2
- package/dist/core/modules/wasm/exec-args/ExecArgInitiateTransfer.js.map +1 -1
- package/dist/core/modules/wasm/exec-args/ExecArgUpdateSpotVaultConfig.js +19 -1
- package/dist/core/modules/wasm/exec-args/ExecArgUpdateSpotVaultConfig.js.map +1 -1
- package/dist/core/modules/wasm/msgs/MsgExecuteContract.js +18 -16
- package/dist/core/modules/wasm/msgs/MsgExecuteContract.js.map +1 -1
- package/dist/core/modules/wasm/msgs/MsgInstantiateContract.js +16 -16
- package/dist/core/modules/wasm/msgs/MsgInstantiateContract.js.map +1 -1
- package/dist/core/modules/wasm/msgs/MsgMigrateContract.js +17 -16
- package/dist/core/modules/wasm/msgs/MsgMigrateContract.js.map +1 -1
- package/dist/core/modules/wasm/msgs/MsgPrivilegedExecuteContract.js +16 -16
- package/dist/core/modules/wasm/msgs/MsgPrivilegedExecuteContract.js.map +1 -1
- package/dist/core/modules/wasm/msgs/MsgStoreCode.js +16 -16
- package/dist/core/modules/wasm/msgs/MsgStoreCode.js.map +1 -1
- package/dist/core/stargate/StargateClient.js +17 -28
- package/dist/core/stargate/StargateClient.js.map +1 -1
- package/dist/utils/classes/Denom/Denom.js +104 -130
- package/dist/utils/classes/Denom/Denom.js.map +1 -1
- package/dist/utils/classes/Denom/DenomClient.js +10 -2
- package/dist/utils/classes/Denom/DenomClient.js.map +1 -1
- package/dist/utils/pagination.js +5 -1
- package/dist/utils/pagination.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -32,208 +23,199 @@ class TxRestApi {
|
|
|
32
23
|
timeout: 15000,
|
|
33
24
|
});
|
|
34
25
|
}
|
|
35
|
-
fetchTx(txHash, params = {}) {
|
|
36
|
-
|
|
26
|
+
async fetchTx(txHash, params = {}) {
|
|
27
|
+
try {
|
|
28
|
+
const response = await this.getRaw(`/cosmos/tx/v1beta1/txs/${txHash}`, params);
|
|
29
|
+
const { tx_response: txResponse } = response;
|
|
30
|
+
if (!txResponse) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
if (parseInt(txResponse.code.toString(), 10) !== 0) {
|
|
34
|
+
throw new exceptions_1.TransactionException(new Error(txResponse.raw_log), {
|
|
35
|
+
contextCode: txResponse.code,
|
|
36
|
+
contextModule: 'TxRestApi',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...txResponse,
|
|
41
|
+
rawLog: txResponse.raw_log,
|
|
42
|
+
gasWanted: parseInt(txResponse.gas_wanted, 10),
|
|
43
|
+
gasUsed: parseInt(txResponse.gas_used, 10),
|
|
44
|
+
height: parseInt(txResponse.height, 10),
|
|
45
|
+
txHash: txResponse.txhash,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
if (e instanceof exceptions_1.TransactionException) {
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
52
|
+
if (!(0, api_1.isTxNotFoundError)(e)) {
|
|
53
|
+
throw new exceptions_1.TransactionException(new Error('There was an issue while fetching transaction details'), {
|
|
54
|
+
contextModule: 'tx',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
throw new exceptions_1.HttpRequestException(new Error((0, api_1.errorToErrorMessage)(e)), {
|
|
58
|
+
contextModule: 'tx',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async fetchTxPoll(txHash, timeout = utils_1.DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS || 60000) {
|
|
63
|
+
const POLL_INTERVAL = utils_1.DEFAULT_BLOCK_TIME_IN_SECONDS * 1000;
|
|
64
|
+
for (let i = 0; i <= timeout / POLL_INTERVAL; i += 1) {
|
|
37
65
|
try {
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
if (parseInt(txResponse.code.toString(), 10) !== 0) {
|
|
44
|
-
throw new exceptions_1.TransactionException(new Error(txResponse.raw_log), {
|
|
45
|
-
contextCode: txResponse.code,
|
|
46
|
-
contextModule: 'TxRestApi',
|
|
47
|
-
});
|
|
66
|
+
const txInfo = await this.fetchTx(txHash);
|
|
67
|
+
const txResponse = txInfo;
|
|
68
|
+
if (txResponse) {
|
|
69
|
+
return txResponse;
|
|
48
70
|
}
|
|
49
|
-
return Object.assign(Object.assign({}, txResponse), { rawLog: txResponse.raw_log, gasWanted: parseInt(txResponse.gas_wanted, 10), gasUsed: parseInt(txResponse.gas_used, 10), height: parseInt(txResponse.height, 10), txHash: txResponse.txhash });
|
|
50
71
|
}
|
|
51
72
|
catch (e) {
|
|
52
73
|
if (e instanceof exceptions_1.TransactionException) {
|
|
53
74
|
throw e;
|
|
54
75
|
}
|
|
55
76
|
if (!(0, api_1.isTxNotFoundError)(e)) {
|
|
56
|
-
throw
|
|
57
|
-
contextModule: 'tx',
|
|
58
|
-
});
|
|
77
|
+
throw e;
|
|
59
78
|
}
|
|
60
|
-
throw new exceptions_1.HttpRequestException(new Error((0, api_1.errorToErrorMessage)(e)), {
|
|
61
|
-
contextModule: 'tx',
|
|
62
|
-
});
|
|
63
79
|
}
|
|
80
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));
|
|
81
|
+
}
|
|
82
|
+
throw new exceptions_1.TransactionException(new Error(`Transaction was not included in a block before timeout of ${timeout}ms`), {
|
|
83
|
+
contextModule: 'TxRestApi',
|
|
64
84
|
});
|
|
65
85
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (txResponse) {
|
|
74
|
-
return txResponse;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
if (e instanceof exceptions_1.TransactionException) {
|
|
79
|
-
throw e;
|
|
80
|
-
}
|
|
81
|
-
if (!(0, api_1.isTxNotFoundError)(e)) {
|
|
82
|
-
throw e;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
yield new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));
|
|
86
|
-
}
|
|
87
|
-
throw new exceptions_1.TransactionException(new Error(`Transaction was not included in a block before timeout of ${timeout}ms`), {
|
|
88
|
-
contextModule: 'TxRestApi',
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
simulate(txRaw) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
const txRawClone = txRaw.clone();
|
|
95
|
-
if (txRawClone.getSignaturesList().length === 0) {
|
|
96
|
-
txRawClone.setSignaturesList([new Uint8Array(0)]);
|
|
97
|
-
}
|
|
98
|
-
const response = yield this.postRaw('/cosmos/tx/v1beta1/simulate', {
|
|
99
|
-
tx_bytes: TxClient_1.TxClient.encode(txRawClone),
|
|
100
|
-
});
|
|
101
|
-
return {
|
|
102
|
-
result: {
|
|
103
|
-
data: response.result.data,
|
|
104
|
-
log: response.result.log,
|
|
105
|
-
eventsList: response.result.events,
|
|
106
|
-
},
|
|
107
|
-
gasInfo: {
|
|
108
|
-
gasWanted: parseInt(response.gas_info.gas_wanted, 10),
|
|
109
|
-
gasUsed: parseInt(response.gas_info.gas_used, 10),
|
|
110
|
-
},
|
|
111
|
-
};
|
|
86
|
+
async simulate(txRaw) {
|
|
87
|
+
const txRawClone = txRaw.clone();
|
|
88
|
+
if (txRawClone.getSignaturesList().length === 0) {
|
|
89
|
+
txRawClone.setSignaturesList([new Uint8Array(0)]);
|
|
90
|
+
}
|
|
91
|
+
const response = await this.postRaw('/cosmos/tx/v1beta1/simulate', {
|
|
92
|
+
tx_bytes: TxClient_1.TxClient.encode(txRawClone),
|
|
112
93
|
});
|
|
94
|
+
return {
|
|
95
|
+
result: {
|
|
96
|
+
data: response.result.data,
|
|
97
|
+
log: response.result.log,
|
|
98
|
+
eventsList: response.result.events,
|
|
99
|
+
},
|
|
100
|
+
gasInfo: {
|
|
101
|
+
gasWanted: parseInt(response.gas_info.gas_wanted, 10),
|
|
102
|
+
gasUsed: parseInt(response.gas_info.gas_used, 10),
|
|
103
|
+
},
|
|
104
|
+
};
|
|
113
105
|
}
|
|
114
|
-
broadcast(tx, options) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
return this.fetchTxPoll(txResponse.txhash, timeout);
|
|
106
|
+
async broadcast(tx, options) {
|
|
107
|
+
const { timeout } = options || {
|
|
108
|
+
timeout: utils_1.DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS || 60000,
|
|
109
|
+
};
|
|
110
|
+
try {
|
|
111
|
+
const { tx_response: txResponse } = await this.broadcastTx(tx, tx_rest_client_1.BroadcastMode.Sync);
|
|
112
|
+
if (txResponse.code !== 0) {
|
|
113
|
+
return {
|
|
114
|
+
height: parseInt(txResponse.height || '0', 10),
|
|
115
|
+
txHash: txResponse.txhash,
|
|
116
|
+
rawLog: txResponse.rawLog,
|
|
117
|
+
code: txResponse.code,
|
|
118
|
+
codespace: txResponse.codespace,
|
|
119
|
+
gasUsed: 0,
|
|
120
|
+
gasWanted: 0,
|
|
121
|
+
timestamp: '',
|
|
122
|
+
logs: [],
|
|
123
|
+
data: '',
|
|
124
|
+
info: '',
|
|
125
|
+
tx: undefined,
|
|
126
|
+
};
|
|
138
127
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
128
|
+
return this.fetchTxPoll(txResponse.txhash, timeout);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
if (e instanceof exceptions_1.HttpRequestException) {
|
|
132
|
+
if (e.code === http_status_codes_1.StatusCodes.OK) {
|
|
143
133
|
}
|
|
144
|
-
throw e;
|
|
145
134
|
}
|
|
146
|
-
|
|
135
|
+
throw e;
|
|
136
|
+
}
|
|
147
137
|
}
|
|
148
138
|
/**
|
|
149
139
|
* Broadcast the transaction using the "block" mode, waiting for its inclusion in the blockchain.
|
|
150
140
|
* @param tx transaction to broadcast
|
|
151
141
|
*/
|
|
152
|
-
broadcastBlock(tx) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
};
|
|
169
|
-
});
|
|
142
|
+
async broadcastBlock(tx) {
|
|
143
|
+
const response = await this.broadcastTx(tx, tx_rest_client_1.BroadcastMode.Block);
|
|
144
|
+
const { tx_response: txResponse } = response;
|
|
145
|
+
return {
|
|
146
|
+
txHash: txResponse.txhash,
|
|
147
|
+
rawLog: txResponse.rawLog,
|
|
148
|
+
gasWanted: parseInt(txResponse.gasWanted || '0', 10),
|
|
149
|
+
gasUsed: parseInt(txResponse.gasUsed || '0', 10),
|
|
150
|
+
height: parseInt(txResponse.height || '0', 10),
|
|
151
|
+
logs: txResponse.logs || [],
|
|
152
|
+
code: txResponse.code,
|
|
153
|
+
codespace: txResponse.codespace,
|
|
154
|
+
data: txResponse.data,
|
|
155
|
+
info: txResponse.info,
|
|
156
|
+
timestamp: txResponse.timestamp || '0',
|
|
157
|
+
};
|
|
170
158
|
}
|
|
171
|
-
broadcastTx(txRaw, mode = tx_rest_client_1.BroadcastMode.Sync) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
mode,
|
|
176
|
-
});
|
|
177
|
-
return response;
|
|
159
|
+
async broadcastTx(txRaw, mode = tx_rest_client_1.BroadcastMode.Sync) {
|
|
160
|
+
const response = await this.postRaw('cosmos/tx/v1beta1/txs', {
|
|
161
|
+
tx_bytes: TxClient_1.TxClient.encode(txRaw),
|
|
162
|
+
mode,
|
|
178
163
|
});
|
|
164
|
+
return response;
|
|
179
165
|
}
|
|
180
|
-
postRaw(endpoint, params = {}) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
?
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
method: exceptions_1.HttpRequestMethod.Post,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
throw new exceptions_1.HttpRequestException(new Error(error.message), {
|
|
203
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
204
|
-
contextModule: exceptions_1.HttpRequestMethod.Post,
|
|
166
|
+
async postRaw(endpoint, params = {}) {
|
|
167
|
+
try {
|
|
168
|
+
return this.httpClient
|
|
169
|
+
.post(endpoint, params)
|
|
170
|
+
.then((d) => d.data);
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
const error = e;
|
|
174
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
175
|
+
const message = error.response
|
|
176
|
+
? typeof error.response.data === 'string'
|
|
177
|
+
? error.response.data
|
|
178
|
+
: error.response.statusText
|
|
179
|
+
: `The request to ${endpoint} has failed.`;
|
|
180
|
+
throw new exceptions_1.HttpRequestException(new Error(message), {
|
|
181
|
+
code: error.response
|
|
182
|
+
? error.response.status
|
|
183
|
+
: http_status_codes_1.StatusCodes.BAD_REQUEST,
|
|
184
|
+
method: exceptions_1.HttpRequestMethod.Post,
|
|
205
185
|
});
|
|
206
186
|
}
|
|
207
|
-
|
|
187
|
+
throw new exceptions_1.HttpRequestException(new Error(error.message), {
|
|
188
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
189
|
+
contextModule: exceptions_1.HttpRequestMethod.Post,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
208
192
|
}
|
|
209
|
-
getRaw(endpoint, params = {}) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
?
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
method: exceptions_1.HttpRequestMethod.Get,
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
throw new exceptions_1.HttpRequestException(new Error(error.message), {
|
|
232
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
233
|
-
contextModule: exceptions_1.HttpRequestMethod.Get,
|
|
193
|
+
async getRaw(endpoint, params = {}) {
|
|
194
|
+
try {
|
|
195
|
+
return this.httpClient
|
|
196
|
+
.get(endpoint, params)
|
|
197
|
+
.then((d) => d.data);
|
|
198
|
+
}
|
|
199
|
+
catch (e) {
|
|
200
|
+
const error = e;
|
|
201
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
202
|
+
const message = error.response
|
|
203
|
+
? typeof error.response.data === 'string'
|
|
204
|
+
? error.response.data
|
|
205
|
+
: error.response.statusText
|
|
206
|
+
: `The request to ${endpoint} has failed.`;
|
|
207
|
+
throw new exceptions_1.HttpRequestException(new Error(message), {
|
|
208
|
+
code: error.response
|
|
209
|
+
? error.response.status
|
|
210
|
+
: http_status_codes_1.StatusCodes.BAD_REQUEST,
|
|
211
|
+
method: exceptions_1.HttpRequestMethod.Get,
|
|
234
212
|
});
|
|
235
213
|
}
|
|
236
|
-
|
|
214
|
+
throw new exceptions_1.HttpRequestException(new Error(error.message), {
|
|
215
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
216
|
+
contextModule: exceptions_1.HttpRequestMethod.Get,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
237
219
|
}
|
|
238
220
|
}
|
|
239
221
|
exports.TxRestApi = TxRestApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxRestApi.js","sourceRoot":"","sources":["../../../../../src/core/modules/tx/api/TxRestApi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TxRestApi.js","sourceRoot":"","sources":["../../../../../src/core/modules/tx/api/TxRestApi.ts"],"names":[],"mappings":";;;;;;AACA,gDAI6B;AAC7B,4DAKgC;AAChC,wDAAoD;AAEpD,0DAKkC;AAClC,kDAAyC;AACzC,yDAA+C;AAC/C,sCAAqE;AAGrE;;GAEG;AACH,MAAa,SAAS;IAGpB,YAAY,QAAgB;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,kBAAU,CAAC,QAAQ,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function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.MsgBroadcasterWithPk = void 0;
|
|
13
4
|
const accounts_1 = require("../../../accounts");
|
|
@@ -32,7 +23,7 @@ class MsgBroadcasterWithPk {
|
|
|
32
23
|
const networkInfo = (0, networks_1.getNetworkInfo)(options.network);
|
|
33
24
|
const endpoints = (0, networks_1.getNetworkEndpoints)(options.network);
|
|
34
25
|
this.chainId = networkInfo.chainId;
|
|
35
|
-
this.endpoints =
|
|
26
|
+
this.endpoints = { ...endpoints, ...(endpoints || {}) };
|
|
36
27
|
this.privateKey =
|
|
37
28
|
options.privateKey instanceof accounts_1.PrivateKey
|
|
38
29
|
? options.privateKey
|
|
@@ -44,48 +35,54 @@ class MsgBroadcasterWithPk {
|
|
|
44
35
|
* @param tx
|
|
45
36
|
* @returns {string} transaction hash
|
|
46
37
|
*/
|
|
47
|
-
broadcast(transaction) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const txResponse = yield txApi.broadcast(txRaw);
|
|
84
|
-
if (txResponse.code !== 0) {
|
|
85
|
-
throw new exceptions_1.GeneralException(new Error(`Transaction failed to be broadcasted - ${txResponse.rawLog}`));
|
|
86
|
-
}
|
|
87
|
-
return txResponse;
|
|
38
|
+
async broadcast(transaction) {
|
|
39
|
+
const { chainId, privateKey, endpoints } = this;
|
|
40
|
+
const msgs = Array.isArray(transaction.msgs)
|
|
41
|
+
? transaction.msgs
|
|
42
|
+
: [transaction.msgs];
|
|
43
|
+
const tx = {
|
|
44
|
+
...transaction,
|
|
45
|
+
msgs: msgs,
|
|
46
|
+
ethereumAddress: (0, helpers_1.getEthereumSignerAddress)(transaction.injectiveAddress),
|
|
47
|
+
injectiveAddress: (0, helpers_1.getInjectiveSignerAddress)(transaction.injectiveAddress),
|
|
48
|
+
};
|
|
49
|
+
/** Account Details * */
|
|
50
|
+
const publicKey = privateKey.toPublicKey();
|
|
51
|
+
const chainRestAuthApi = new rest_1.ChainRestAuthApi(endpoints.rest);
|
|
52
|
+
const accountDetailsResponse = await chainRestAuthApi.fetchAccount(tx.injectiveAddress);
|
|
53
|
+
const baseAccount = accounts_1.BaseAccount.fromRestApi(accountDetailsResponse);
|
|
54
|
+
const accountDetails = baseAccount.toAccountDetails();
|
|
55
|
+
/** Block Details */
|
|
56
|
+
const chainRestTendermintApi = new rest_1.ChainRestTendermintApi(endpoints.rest);
|
|
57
|
+
const latestBlock = await chainRestTendermintApi.fetchLatestBlock();
|
|
58
|
+
const latestHeight = latestBlock.header.height;
|
|
59
|
+
const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(utils_1.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
|
|
60
|
+
const gas = (transaction.gasLimit || (0, msgs_1.getGasPriceBasedOnMessage)(msgs)).toString();
|
|
61
|
+
/** Prepare the Transaction * */
|
|
62
|
+
const { signBytes, txRaw } = (0, __1.createTransaction)({
|
|
63
|
+
memo: '',
|
|
64
|
+
fee: {
|
|
65
|
+
...utils_1.DEFAULT_STD_FEE,
|
|
66
|
+
gas: gas || utils_1.DEFAULT_STD_FEE.gas,
|
|
67
|
+
},
|
|
68
|
+
message: msgs.map((m) => m.toDirectSign()),
|
|
69
|
+
timeoutHeight: timeoutHeight.toNumber(),
|
|
70
|
+
pubKey: publicKey.toBase64(),
|
|
71
|
+
sequence: accountDetails.sequence,
|
|
72
|
+
accountNumber: accountDetails.accountNumber,
|
|
73
|
+
chainId: chainId,
|
|
88
74
|
});
|
|
75
|
+
/** Sign transaction */
|
|
76
|
+
const signature = await privateKey.sign(Buffer.from(signBytes));
|
|
77
|
+
/** Append Signatures */
|
|
78
|
+
txRaw.setSignaturesList([signature]);
|
|
79
|
+
/** Broadcast transaction */
|
|
80
|
+
const txApi = new TxGrpcApi_1.TxGrpcApi(endpoints.grpc);
|
|
81
|
+
const txResponse = await txApi.broadcast(txRaw);
|
|
82
|
+
if (txResponse.code !== 0) {
|
|
83
|
+
throw new exceptions_1.GeneralException(new Error(`Transaction failed to be broadcasted - ${txResponse.rawLog}`));
|
|
84
|
+
}
|
|
85
|
+
return txResponse;
|
|
89
86
|
}
|
|
90
87
|
/**
|
|
91
88
|
* Broadcasting the transaction using the client
|
|
@@ -93,40 +90,43 @@ class MsgBroadcasterWithPk {
|
|
|
93
90
|
* @param tx
|
|
94
91
|
* @returns {string} transaction hash
|
|
95
92
|
*/
|
|
96
|
-
simulate(transaction) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const simulationResponse = yield new TxGrpcApi_1.TxGrpcApi(endpoints.grpc).simulate(txRaw);
|
|
128
|
-
return simulationResponse;
|
|
93
|
+
async simulate(transaction) {
|
|
94
|
+
const { privateKey, endpoints, chainId } = this;
|
|
95
|
+
const tx = {
|
|
96
|
+
...transaction,
|
|
97
|
+
msgs: Array.isArray(transaction.msgs)
|
|
98
|
+
? transaction.msgs
|
|
99
|
+
: [transaction.msgs],
|
|
100
|
+
ethereumAddress: (0, helpers_1.getEthereumSignerAddress)(transaction.injectiveAddress),
|
|
101
|
+
injectiveAddress: (0, helpers_1.getInjectiveSignerAddress)(transaction.injectiveAddress),
|
|
102
|
+
};
|
|
103
|
+
/** Account Details * */
|
|
104
|
+
const publicKey = privateKey.toPublicKey();
|
|
105
|
+
const chainRestAuthApi = new rest_1.ChainRestAuthApi(endpoints.rest);
|
|
106
|
+
const accountDetailsResponse = await chainRestAuthApi.fetchAccount(tx.injectiveAddress);
|
|
107
|
+
const baseAccount = accounts_1.BaseAccount.fromRestApi(accountDetailsResponse);
|
|
108
|
+
const accountDetails = baseAccount.toAccountDetails();
|
|
109
|
+
/** Block Details */
|
|
110
|
+
const chainRestTendermintApi = new rest_1.ChainRestTendermintApi(endpoints.rest);
|
|
111
|
+
const latestBlock = await chainRestTendermintApi.fetchLatestBlock();
|
|
112
|
+
const latestHeight = latestBlock.header.height;
|
|
113
|
+
const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(utils_1.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
|
|
114
|
+
/** Prepare the Transaction * */
|
|
115
|
+
const { txRaw } = (0, __1.createTransaction)({
|
|
116
|
+
memo: '',
|
|
117
|
+
fee: utils_1.DEFAULT_STD_FEE,
|
|
118
|
+
message: tx.msgs.map((m) => m.toDirectSign()),
|
|
119
|
+
timeoutHeight: timeoutHeight.toNumber(),
|
|
120
|
+
pubKey: publicKey.toBase64(),
|
|
121
|
+
sequence: accountDetails.sequence,
|
|
122
|
+
accountNumber: accountDetails.accountNumber,
|
|
123
|
+
chainId: chainId,
|
|
129
124
|
});
|
|
125
|
+
/** Append Blank Signatures */
|
|
126
|
+
txRaw.setSignaturesList([new Uint8Array(0)]);
|
|
127
|
+
/** Simulate transaction */
|
|
128
|
+
const simulationResponse = await new TxGrpcApi_1.TxGrpcApi(endpoints.grpc).simulate(txRaw);
|
|
129
|
+
return simulationResponse;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
exports.MsgBroadcasterWithPk = MsgBroadcasterWithPk;
|