@xchainjs/xchain-thorchain 0.24.1 → 0.25.0
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/CHANGELOG.md +12 -0
- package/lib/client.d.ts +2 -1
- package/lib/index.esm.js +56 -12
- package/lib/index.js +58 -12
- package/lib/types/client-types.d.ts +14 -4
- package/lib/util.d.ts +13 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v0.25.0 (2022-05-10)
|
|
2
|
+
|
|
3
|
+
## Fix
|
|
4
|
+
|
|
5
|
+
- Before sending a transaction, gas limits are estimated
|
|
6
|
+
- Helper `getEstimatedGas`
|
|
7
|
+
|
|
8
|
+
## Breaking changes
|
|
9
|
+
|
|
10
|
+
- Client's `transferOffline` requires `fromAccountNumber` and `fromSequence`
|
|
11
|
+
- Rename parameters in `transferOffline` to keep names in camel case (not snake case)
|
|
12
|
+
|
|
1
13
|
# v0.24.1 (2022-04-23)
|
|
2
14
|
|
|
3
15
|
## Fix
|
package/lib/client.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface ThorchainClient {
|
|
|
12
12
|
setExplorerUrls(explorerUrls: ExplorerUrls): void;
|
|
13
13
|
getCosmosClient(): CosmosSDKClient;
|
|
14
14
|
deposit(params: DepositParam): Promise<TxHash>;
|
|
15
|
+
transferOffline(params: TxOfflineParams): Promise<string>;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Custom Thorchain Client
|
|
@@ -197,7 +198,7 @@ declare class Client extends BaseXChainClient implements ThorchainClient, XChain
|
|
|
197
198
|
* @param {TxOfflineParams} params The transfer offline options.
|
|
198
199
|
* @returns {string} The signed transaction bytes.
|
|
199
200
|
*/
|
|
200
|
-
transferOffline({ walletIndex, asset, amount, recipient, memo, from_rune_balance, from_asset_balance,
|
|
201
|
+
transferOffline({ walletIndex, asset, amount, recipient, memo, fromRuneBalance: from_rune_balance, fromAssetBalance: from_asset_balance, fromAccountNumber, fromSequence, }: TxOfflineParams): Promise<string>;
|
|
201
202
|
/**
|
|
202
203
|
* Gets fees from Node
|
|
203
204
|
*
|
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cosmosclient, proto } from '@cosmos-client/core';
|
|
1
|
+
import { cosmosclient, proto, rest } from '@cosmos-client/core';
|
|
2
2
|
import { Network, TxType, singleFee, FeeType, BaseXChainClient } from '@xchainjs/xchain-client';
|
|
3
3
|
import { CosmosSDKClient } from '@xchainjs/xchain-cosmos';
|
|
4
4
|
import { assetToString, AssetRuneNative, isSynthAsset, assetFromString, baseAmount, assetToBase, assetAmount, Chain } from '@xchainjs/xchain-util';
|
|
@@ -5376,8 +5376,9 @@ $root.cosmos = (function() {
|
|
|
5376
5376
|
var MsgCompiled = $root;
|
|
5377
5377
|
|
|
5378
5378
|
const DECIMAL = 8;
|
|
5379
|
-
const
|
|
5380
|
-
const
|
|
5379
|
+
const DEFAULT_GAS_ADJUSTMENT = 2;
|
|
5380
|
+
const DEFAULT_GAS_LIMIT_VALUE = '4000000';
|
|
5381
|
+
const DEPOSIT_GAS_LIMIT_VALUE = '500000000';
|
|
5381
5382
|
const MAX_TX_COUNT = 100;
|
|
5382
5383
|
/**
|
|
5383
5384
|
* Checks whether an asset is `AssetRuneNative`
|
|
@@ -5555,11 +5556,29 @@ const buildUnsignedTx = ({ cosmosSdk, txBody, signerPubkey, sequence, gasLimit,
|
|
|
5555
5556
|
],
|
|
5556
5557
|
fee: {
|
|
5557
5558
|
amount: null,
|
|
5558
|
-
gas_limit:
|
|
5559
|
+
gas_limit: gasLimit || null,
|
|
5559
5560
|
},
|
|
5560
5561
|
});
|
|
5561
5562
|
return new cosmosclient.TxBuilder(cosmosSdk, txBody, authInfo);
|
|
5562
5563
|
};
|
|
5564
|
+
const getEstimatedGas = ({ cosmosSDKClient, txBody, privKey, accountNumber, accountSequence, multiplier, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5565
|
+
var _b, _c, _d;
|
|
5566
|
+
const pubKey = privKey.pubKey();
|
|
5567
|
+
const txBuilder = buildUnsignedTx({
|
|
5568
|
+
cosmosSdk: cosmosSDKClient.sdk,
|
|
5569
|
+
txBody: txBody,
|
|
5570
|
+
signerPubkey: cosmosclient.codec.packAny(pubKey),
|
|
5571
|
+
sequence: accountSequence,
|
|
5572
|
+
});
|
|
5573
|
+
const signDocBytes = txBuilder.signDocBytes(accountNumber);
|
|
5574
|
+
txBuilder.addSignature(privKey.sign(signDocBytes));
|
|
5575
|
+
const resp = yield rest.tx.simulate(cosmosSDKClient.sdk, { tx_bytes: txBuilder.txBytes() });
|
|
5576
|
+
const estimatedGas = (_d = (_c = (_b = resp.data) === null || _b === void 0 ? void 0 : _b.gas_info) === null || _c === void 0 ? void 0 : _c.gas_used) !== null && _d !== void 0 ? _d : null;
|
|
5577
|
+
if (!estimatedGas) {
|
|
5578
|
+
throw new Error('Could not get data of estimated gas');
|
|
5579
|
+
}
|
|
5580
|
+
return cosmosclient.Long.fromString(estimatedGas).multiply(multiplier || DEFAULT_GAS_ADJUSTMENT);
|
|
5581
|
+
});
|
|
5563
5582
|
/**
|
|
5564
5583
|
* Structure a MsgDeposit
|
|
5565
5584
|
*
|
|
@@ -6081,11 +6100,20 @@ class Client extends BaseXChainClient {
|
|
|
6081
6100
|
chainId: this.getChainId(),
|
|
6082
6101
|
});
|
|
6083
6102
|
const account = yield this.getCosmosClient().getAccount(fromAddressAcc);
|
|
6103
|
+
const accountSequence = account.sequence || cosmosclient.Long.ZERO;
|
|
6104
|
+
const accountNumber = account.account_number || cosmosclient.Long.ZERO;
|
|
6105
|
+
const gasLimit = yield getEstimatedGas({
|
|
6106
|
+
cosmosSDKClient: this.getCosmosClient(),
|
|
6107
|
+
txBody: depositTxBody,
|
|
6108
|
+
privKey,
|
|
6109
|
+
accountNumber,
|
|
6110
|
+
accountSequence,
|
|
6111
|
+
});
|
|
6084
6112
|
const txBuilder = buildUnsignedTx({
|
|
6085
6113
|
cosmosSdk: this.getCosmosClient().sdk,
|
|
6086
6114
|
txBody: depositTxBody,
|
|
6087
6115
|
signerPubkey: cosmosclient.codec.packAny(signerPubkey),
|
|
6088
|
-
gasLimit
|
|
6116
|
+
gasLimit,
|
|
6089
6117
|
sequence: account.sequence || cosmosclient.Long.ZERO,
|
|
6090
6118
|
});
|
|
6091
6119
|
return (yield this.getCosmosClient().signAndBroadcast(txBuilder, privKey, account)) || '';
|
|
@@ -6131,12 +6159,21 @@ class Client extends BaseXChainClient {
|
|
|
6131
6159
|
nodeUrl: this.getClientUrl().node,
|
|
6132
6160
|
});
|
|
6133
6161
|
const account = yield this.getCosmosClient().getAccount(accAddress);
|
|
6162
|
+
const accountSequence = account.sequence || cosmosclient.Long.ZERO;
|
|
6163
|
+
const accountNumber = account.account_number || cosmosclient.Long.ZERO;
|
|
6164
|
+
const gasLimit = yield getEstimatedGas({
|
|
6165
|
+
cosmosSDKClient: this.getCosmosClient(),
|
|
6166
|
+
txBody,
|
|
6167
|
+
privKey,
|
|
6168
|
+
accountNumber,
|
|
6169
|
+
accountSequence,
|
|
6170
|
+
});
|
|
6134
6171
|
const txBuilder = buildUnsignedTx({
|
|
6135
6172
|
cosmosSdk: this.getCosmosClient().sdk,
|
|
6136
6173
|
txBody: txBody,
|
|
6137
|
-
gasLimit
|
|
6174
|
+
gasLimit,
|
|
6138
6175
|
signerPubkey: cosmosclient.codec.packAny(signerPubkey),
|
|
6139
|
-
sequence:
|
|
6176
|
+
sequence: accountSequence,
|
|
6140
6177
|
});
|
|
6141
6178
|
return (yield this.cosmosClient.signAndBroadcast(txBuilder, privKey, account)) || '';
|
|
6142
6179
|
});
|
|
@@ -6147,7 +6184,7 @@ class Client extends BaseXChainClient {
|
|
|
6147
6184
|
* @param {TxOfflineParams} params The transfer offline options.
|
|
6148
6185
|
* @returns {string} The signed transaction bytes.
|
|
6149
6186
|
*/
|
|
6150
|
-
transferOffline({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, from_rune_balance, from_asset_balance = baseAmount(0, DECIMAL),
|
|
6187
|
+
transferOffline({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, fromRuneBalance: from_rune_balance, fromAssetBalance: from_asset_balance = baseAmount(0, DECIMAL), fromAccountNumber = cosmosclient.Long.ZERO, fromSequence = cosmosclient.Long.ZERO, }) {
|
|
6151
6188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6152
6189
|
const fee = (yield this.getFees()).average;
|
|
6153
6190
|
if (isAssetRuneNative(asset)) {
|
|
@@ -6172,14 +6209,21 @@ class Client extends BaseXChainClient {
|
|
|
6172
6209
|
nodeUrl: this.getClientUrl().node,
|
|
6173
6210
|
});
|
|
6174
6211
|
const privKey = this.getPrivateKey(walletIndex);
|
|
6212
|
+
const gasLimit = yield getEstimatedGas({
|
|
6213
|
+
cosmosSDKClient: this.getCosmosClient(),
|
|
6214
|
+
txBody,
|
|
6215
|
+
privKey,
|
|
6216
|
+
accountNumber: fromAccountNumber,
|
|
6217
|
+
accountSequence: fromSequence,
|
|
6218
|
+
});
|
|
6175
6219
|
const txBuilder = buildUnsignedTx({
|
|
6176
6220
|
cosmosSdk: this.getCosmosClient().sdk,
|
|
6177
6221
|
txBody: txBody,
|
|
6178
|
-
gasLimit:
|
|
6222
|
+
gasLimit: gasLimit,
|
|
6179
6223
|
signerPubkey: cosmosclient.codec.packAny(privKey.pubKey()),
|
|
6180
|
-
sequence:
|
|
6224
|
+
sequence: fromSequence,
|
|
6181
6225
|
});
|
|
6182
|
-
const signDocBytes = txBuilder.signDocBytes(
|
|
6226
|
+
const signDocBytes = txBuilder.signDocBytes(fromAccountNumber);
|
|
6183
6227
|
txBuilder.addSignature(privKey.sign(signDocBytes));
|
|
6184
6228
|
return txBuilder.txBytes();
|
|
6185
6229
|
});
|
|
@@ -6222,4 +6266,4 @@ const msgNativeTxFromJson = (value) => {
|
|
|
6222
6266
|
return new MsgNativeTx(value.coins, value.memo, cosmosclient.AccAddress.fromString(value.signer));
|
|
6223
6267
|
};
|
|
6224
6268
|
|
|
6225
|
-
export { Client, DECIMAL,
|
|
6269
|
+
export { Client, DECIMAL, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, getBalance, getChainId, getChainIds, getDefaultClientUrl, getDefaultExplorerUrls, getDefaultFees, getDenom, getDepositTxDataFromLogs, getEstimatedGas, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getTxType, isAssetRuneNative, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
|
package/lib/index.js
CHANGED
|
@@ -5384,8 +5384,9 @@ $root.cosmos = (function() {
|
|
|
5384
5384
|
var MsgCompiled = $root;
|
|
5385
5385
|
|
|
5386
5386
|
const DECIMAL = 8;
|
|
5387
|
-
const
|
|
5388
|
-
const
|
|
5387
|
+
const DEFAULT_GAS_ADJUSTMENT = 2;
|
|
5388
|
+
const DEFAULT_GAS_LIMIT_VALUE = '4000000';
|
|
5389
|
+
const DEPOSIT_GAS_LIMIT_VALUE = '500000000';
|
|
5389
5390
|
const MAX_TX_COUNT = 100;
|
|
5390
5391
|
/**
|
|
5391
5392
|
* Checks whether an asset is `AssetRuneNative`
|
|
@@ -5563,11 +5564,29 @@ const buildUnsignedTx = ({ cosmosSdk, txBody, signerPubkey, sequence, gasLimit,
|
|
|
5563
5564
|
],
|
|
5564
5565
|
fee: {
|
|
5565
5566
|
amount: null,
|
|
5566
|
-
gas_limit:
|
|
5567
|
+
gas_limit: gasLimit || null,
|
|
5567
5568
|
},
|
|
5568
5569
|
});
|
|
5569
5570
|
return new core.cosmosclient.TxBuilder(cosmosSdk, txBody, authInfo);
|
|
5570
5571
|
};
|
|
5572
|
+
const getEstimatedGas = ({ cosmosSDKClient, txBody, privKey, accountNumber, accountSequence, multiplier, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5573
|
+
var _b, _c, _d;
|
|
5574
|
+
const pubKey = privKey.pubKey();
|
|
5575
|
+
const txBuilder = buildUnsignedTx({
|
|
5576
|
+
cosmosSdk: cosmosSDKClient.sdk,
|
|
5577
|
+
txBody: txBody,
|
|
5578
|
+
signerPubkey: core.cosmosclient.codec.packAny(pubKey),
|
|
5579
|
+
sequence: accountSequence,
|
|
5580
|
+
});
|
|
5581
|
+
const signDocBytes = txBuilder.signDocBytes(accountNumber);
|
|
5582
|
+
txBuilder.addSignature(privKey.sign(signDocBytes));
|
|
5583
|
+
const resp = yield core.rest.tx.simulate(cosmosSDKClient.sdk, { tx_bytes: txBuilder.txBytes() });
|
|
5584
|
+
const estimatedGas = (_d = (_c = (_b = resp.data) === null || _b === void 0 ? void 0 : _b.gas_info) === null || _c === void 0 ? void 0 : _c.gas_used) !== null && _d !== void 0 ? _d : null;
|
|
5585
|
+
if (!estimatedGas) {
|
|
5586
|
+
throw new Error('Could not get data of estimated gas');
|
|
5587
|
+
}
|
|
5588
|
+
return core.cosmosclient.Long.fromString(estimatedGas).multiply(multiplier || DEFAULT_GAS_ADJUSTMENT);
|
|
5589
|
+
});
|
|
5571
5590
|
/**
|
|
5572
5591
|
* Structure a MsgDeposit
|
|
5573
5592
|
*
|
|
@@ -6089,11 +6108,20 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
6089
6108
|
chainId: this.getChainId(),
|
|
6090
6109
|
});
|
|
6091
6110
|
const account = yield this.getCosmosClient().getAccount(fromAddressAcc);
|
|
6111
|
+
const accountSequence = account.sequence || core.cosmosclient.Long.ZERO;
|
|
6112
|
+
const accountNumber = account.account_number || core.cosmosclient.Long.ZERO;
|
|
6113
|
+
const gasLimit = yield getEstimatedGas({
|
|
6114
|
+
cosmosSDKClient: this.getCosmosClient(),
|
|
6115
|
+
txBody: depositTxBody,
|
|
6116
|
+
privKey,
|
|
6117
|
+
accountNumber,
|
|
6118
|
+
accountSequence,
|
|
6119
|
+
});
|
|
6092
6120
|
const txBuilder = buildUnsignedTx({
|
|
6093
6121
|
cosmosSdk: this.getCosmosClient().sdk,
|
|
6094
6122
|
txBody: depositTxBody,
|
|
6095
6123
|
signerPubkey: core.cosmosclient.codec.packAny(signerPubkey),
|
|
6096
|
-
gasLimit
|
|
6124
|
+
gasLimit,
|
|
6097
6125
|
sequence: account.sequence || core.cosmosclient.Long.ZERO,
|
|
6098
6126
|
});
|
|
6099
6127
|
return (yield this.getCosmosClient().signAndBroadcast(txBuilder, privKey, account)) || '';
|
|
@@ -6139,12 +6167,21 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
6139
6167
|
nodeUrl: this.getClientUrl().node,
|
|
6140
6168
|
});
|
|
6141
6169
|
const account = yield this.getCosmosClient().getAccount(accAddress);
|
|
6170
|
+
const accountSequence = account.sequence || core.cosmosclient.Long.ZERO;
|
|
6171
|
+
const accountNumber = account.account_number || core.cosmosclient.Long.ZERO;
|
|
6172
|
+
const gasLimit = yield getEstimatedGas({
|
|
6173
|
+
cosmosSDKClient: this.getCosmosClient(),
|
|
6174
|
+
txBody,
|
|
6175
|
+
privKey,
|
|
6176
|
+
accountNumber,
|
|
6177
|
+
accountSequence,
|
|
6178
|
+
});
|
|
6142
6179
|
const txBuilder = buildUnsignedTx({
|
|
6143
6180
|
cosmosSdk: this.getCosmosClient().sdk,
|
|
6144
6181
|
txBody: txBody,
|
|
6145
|
-
gasLimit
|
|
6182
|
+
gasLimit,
|
|
6146
6183
|
signerPubkey: core.cosmosclient.codec.packAny(signerPubkey),
|
|
6147
|
-
sequence:
|
|
6184
|
+
sequence: accountSequence,
|
|
6148
6185
|
});
|
|
6149
6186
|
return (yield this.cosmosClient.signAndBroadcast(txBuilder, privKey, account)) || '';
|
|
6150
6187
|
});
|
|
@@ -6155,7 +6192,7 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
6155
6192
|
* @param {TxOfflineParams} params The transfer offline options.
|
|
6156
6193
|
* @returns {string} The signed transaction bytes.
|
|
6157
6194
|
*/
|
|
6158
|
-
transferOffline({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo, from_rune_balance, from_asset_balance = xchainUtil.baseAmount(0, DECIMAL),
|
|
6195
|
+
transferOffline({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo, fromRuneBalance: from_rune_balance, fromAssetBalance: from_asset_balance = xchainUtil.baseAmount(0, DECIMAL), fromAccountNumber = core.cosmosclient.Long.ZERO, fromSequence = core.cosmosclient.Long.ZERO, }) {
|
|
6159
6196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6160
6197
|
const fee = (yield this.getFees()).average;
|
|
6161
6198
|
if (isAssetRuneNative(asset)) {
|
|
@@ -6180,14 +6217,21 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
6180
6217
|
nodeUrl: this.getClientUrl().node,
|
|
6181
6218
|
});
|
|
6182
6219
|
const privKey = this.getPrivateKey(walletIndex);
|
|
6220
|
+
const gasLimit = yield getEstimatedGas({
|
|
6221
|
+
cosmosSDKClient: this.getCosmosClient(),
|
|
6222
|
+
txBody,
|
|
6223
|
+
privKey,
|
|
6224
|
+
accountNumber: fromAccountNumber,
|
|
6225
|
+
accountSequence: fromSequence,
|
|
6226
|
+
});
|
|
6183
6227
|
const txBuilder = buildUnsignedTx({
|
|
6184
6228
|
cosmosSdk: this.getCosmosClient().sdk,
|
|
6185
6229
|
txBody: txBody,
|
|
6186
|
-
gasLimit:
|
|
6230
|
+
gasLimit: gasLimit,
|
|
6187
6231
|
signerPubkey: core.cosmosclient.codec.packAny(privKey.pubKey()),
|
|
6188
|
-
sequence:
|
|
6232
|
+
sequence: fromSequence,
|
|
6189
6233
|
});
|
|
6190
|
-
const signDocBytes = txBuilder.signDocBytes(
|
|
6234
|
+
const signDocBytes = txBuilder.signDocBytes(fromAccountNumber);
|
|
6191
6235
|
txBuilder.addSignature(privKey.sign(signDocBytes));
|
|
6192
6236
|
return txBuilder.txBytes();
|
|
6193
6237
|
});
|
|
@@ -6232,8 +6276,9 @@ const msgNativeTxFromJson = (value) => {
|
|
|
6232
6276
|
|
|
6233
6277
|
exports.Client = Client;
|
|
6234
6278
|
exports.DECIMAL = DECIMAL;
|
|
6235
|
-
exports.
|
|
6236
|
-
exports.
|
|
6279
|
+
exports.DEFAULT_GAS_ADJUSTMENT = DEFAULT_GAS_ADJUSTMENT;
|
|
6280
|
+
exports.DEFAULT_GAS_LIMIT_VALUE = DEFAULT_GAS_LIMIT_VALUE;
|
|
6281
|
+
exports.DEPOSIT_GAS_LIMIT_VALUE = DEPOSIT_GAS_LIMIT_VALUE;
|
|
6237
6282
|
exports.MAX_TX_COUNT = MAX_TX_COUNT;
|
|
6238
6283
|
exports.MsgNativeTx = MsgNativeTx;
|
|
6239
6284
|
exports.assetFromDenom = assetFromDenom;
|
|
@@ -6248,6 +6293,7 @@ exports.getDefaultExplorerUrls = getDefaultExplorerUrls;
|
|
|
6248
6293
|
exports.getDefaultFees = getDefaultFees;
|
|
6249
6294
|
exports.getDenom = getDenom;
|
|
6250
6295
|
exports.getDepositTxDataFromLogs = getDepositTxDataFromLogs;
|
|
6296
|
+
exports.getEstimatedGas = getEstimatedGas;
|
|
6251
6297
|
exports.getExplorerAddressUrl = getExplorerAddressUrl;
|
|
6252
6298
|
exports.getExplorerTxUrl = getExplorerTxUrl;
|
|
6253
6299
|
exports.getExplorerUrl = getExplorerUrl;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cosmosclient } from '@cosmos-client/core';
|
|
1
2
|
import { Network, Tx, TxParams } from '@xchainjs/xchain-client';
|
|
2
3
|
import { Asset, BaseAmount } from '@xchainjs/xchain-util';
|
|
3
4
|
export declare type NodeUrl = {
|
|
@@ -29,14 +30,14 @@ export declare type TxOfflineParams = TxParams & {
|
|
|
29
30
|
/**
|
|
30
31
|
* Balance of Rune to send from
|
|
31
32
|
*/
|
|
32
|
-
|
|
33
|
+
fromRuneBalance: BaseAmount;
|
|
33
34
|
/**
|
|
34
35
|
* Balance of asset to send from
|
|
35
36
|
* Optional: It can be ignored if asset to send from is RUNE
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
fromAssetBalance?: BaseAmount;
|
|
39
|
+
fromAccountNumber: cosmosclient.Long.Long;
|
|
40
|
+
fromSequence: cosmosclient.Long.Long;
|
|
40
41
|
};
|
|
41
42
|
/**
|
|
42
43
|
* Response from `thorchain/constants` endpoint
|
|
@@ -55,3 +56,12 @@ export declare type NodeInfoResponse = {
|
|
|
55
56
|
network: string;
|
|
56
57
|
};
|
|
57
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Response of `/cosmos/tx/v1beta1/simulateo`
|
|
61
|
+
* Note: We are interested in `network` (aka chain id) only
|
|
62
|
+
*/
|
|
63
|
+
export declare type SimulateResponse = {
|
|
64
|
+
gas_info: {
|
|
65
|
+
gas_used: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
package/lib/util.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ import { Asset, BaseAmount } from '@xchainjs/xchain-util';
|
|
|
5
5
|
import { ChainId, ChainIds, ClientUrl, ExplorerUrls, TxData } from './types';
|
|
6
6
|
import { MsgNativeTx } from './types/messages';
|
|
7
7
|
export declare const DECIMAL = 8;
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
8
|
+
export declare const DEFAULT_GAS_ADJUSTMENT = 2;
|
|
9
|
+
export declare const DEFAULT_GAS_LIMIT_VALUE = "4000000";
|
|
10
|
+
export declare const DEPOSIT_GAS_LIMIT_VALUE = "500000000";
|
|
10
11
|
export declare const MAX_TX_COUNT = 100;
|
|
11
12
|
/**
|
|
12
13
|
* Checks whether an asset is `AssetRuneNative`
|
|
@@ -98,9 +99,17 @@ export declare const buildUnsignedTx: ({ cosmosSdk, txBody, signerPubkey, sequen
|
|
|
98
99
|
cosmosSdk: cosmosclient.CosmosSDK;
|
|
99
100
|
txBody: proto.cosmos.tx.v1beta1.TxBody;
|
|
100
101
|
signerPubkey: proto.google.protobuf.Any;
|
|
101
|
-
sequence: cosmosclient.Long;
|
|
102
|
-
gasLimit
|
|
102
|
+
sequence: cosmosclient.Long.Long;
|
|
103
|
+
gasLimit?: cosmosclient.Long.Long | undefined;
|
|
103
104
|
}) => cosmosclient.TxBuilder;
|
|
105
|
+
export declare const getEstimatedGas: ({ cosmosSDKClient, txBody, privKey, accountNumber, accountSequence, multiplier, }: {
|
|
106
|
+
cosmosSDKClient: CosmosSDKClient;
|
|
107
|
+
txBody: proto.cosmos.tx.v1beta1.TxBody;
|
|
108
|
+
privKey: proto.cosmos.crypto.secp256k1.PrivKey;
|
|
109
|
+
accountNumber: cosmosclient.Long.Long;
|
|
110
|
+
accountSequence: cosmosclient.Long.Long;
|
|
111
|
+
multiplier?: number | undefined;
|
|
112
|
+
}) => Promise<cosmosclient.Long.Long | undefined>;
|
|
104
113
|
/**
|
|
105
114
|
* Structure a MsgDeposit
|
|
106
115
|
*
|