@xchainjs/xchain-thorchain 0.24.0 → 0.25.1

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.
@@ -1,5 +1,7 @@
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';
4
+ import BigNumber from 'bignumber.js';
3
5
  export declare type NodeUrl = {
4
6
  node: string;
5
7
  rpc: string;
@@ -23,20 +25,22 @@ export declare type DepositParam = {
23
25
  asset?: Asset;
24
26
  amount: BaseAmount;
25
27
  memo: string;
28
+ gasLimit?: BigNumber;
26
29
  };
27
30
  export declare type TxData = Pick<Tx, 'from' | 'to' | 'type'>;
28
31
  export declare type TxOfflineParams = TxParams & {
29
32
  /**
30
33
  * Balance of Rune to send from
31
34
  */
32
- from_rune_balance: BaseAmount;
35
+ fromRuneBalance: BaseAmount;
33
36
  /**
34
37
  * Balance of asset to send from
35
38
  * Optional: It can be ignored if asset to send from is RUNE
36
39
  */
37
- from_asset_balance?: BaseAmount;
38
- from_account_number: string;
39
- from_sequence: string;
40
+ fromAssetBalance?: BaseAmount;
41
+ fromAccountNumber: cosmosclient.Long.Long;
42
+ fromSequence: cosmosclient.Long.Long;
43
+ gasLimit?: BigNumber;
40
44
  };
41
45
  /**
42
46
  * Response from `thorchain/constants` endpoint
@@ -55,3 +59,12 @@ export declare type NodeInfoResponse = {
55
59
  network: string;
56
60
  };
57
61
  };
62
+ /**
63
+ * Response of `/cosmos/tx/v1beta1/simulateo`
64
+ * Note: We are interested in `network` (aka chain id) only
65
+ */
66
+ export declare type SimulateResponse = {
67
+ gas_info: {
68
+ gas_used: string;
69
+ };
70
+ };
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 DEFAULT_GAS_VALUE = "3000000";
9
- export declare const DEPOSIT_GAS_VALUE = "500000000";
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 = "600000000";
10
11
  export declare const MAX_TX_COUNT = 100;
11
12
  /**
12
13
  * Checks whether an asset is `AssetRuneNative`
@@ -98,9 +99,24 @@ 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: string;
102
+ sequence: cosmosclient.Long.Long;
103
+ gasLimit?: cosmosclient.Long.Long | undefined;
103
104
  }) => cosmosclient.TxBuilder;
105
+ /**
106
+ * Estimates usage of gas
107
+ *
108
+ * Note: Be careful by using this helper function,
109
+ * it's still experimental and result might be incorrect.
110
+ * Change `multiplier` to get a valid estimation of gas.
111
+ */
112
+ export declare const getEstimatedGas: ({ cosmosSDKClient, txBody, privKey, accountNumber, accountSequence, multiplier, }: {
113
+ cosmosSDKClient: CosmosSDKClient;
114
+ txBody: proto.cosmos.tx.v1beta1.TxBody;
115
+ privKey: proto.cosmos.crypto.secp256k1.PrivKey;
116
+ accountNumber: cosmosclient.Long.Long;
117
+ accountSequence: cosmosclient.Long.Long;
118
+ multiplier?: number | undefined;
119
+ }) => Promise<cosmosclient.Long.Long | undefined>;
104
120
  /**
105
121
  * Structure a MsgDeposit
106
122
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.24.0",
3
+ "version": "0.25.1",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",