@xchainjs/xchain-thorchain 0.24.1 → 0.25.2-alpha.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
1
  import { Network, Tx, TxParams } from '@xchainjs/xchain-client';
2
2
  import { Asset, BaseAmount } from '@xchainjs/xchain-util';
3
+ import BigNumber from 'bignumber.js';
4
+ import Long from 'long';
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: Long;
42
+ fromSequence: 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
@@ -2,11 +2,13 @@ import { cosmosclient, proto } from '@cosmos-client/core';
2
2
  import { Address, Balance, Fees, Network, TxHash } from '@xchainjs/xchain-client';
3
3
  import { CosmosSDKClient, TxLog } from '@xchainjs/xchain-cosmos';
4
4
  import { Asset, BaseAmount } from '@xchainjs/xchain-util';
5
+ import Long from 'long';
5
6
  import { ChainId, ChainIds, ClientUrl, ExplorerUrls, TxData } from './types';
6
7
  import { MsgNativeTx } from './types/messages';
7
8
  export declare const DECIMAL = 8;
8
- export declare const DEFAULT_GAS_VALUE = "4000000";
9
- export declare const DEPOSIT_GAS_VALUE = "500000000";
9
+ export declare const DEFAULT_GAS_ADJUSTMENT = 2;
10
+ export declare const DEFAULT_GAS_LIMIT_VALUE = "4000000";
11
+ export declare const DEPOSIT_GAS_LIMIT_VALUE = "600000000";
10
12
  export declare const MAX_TX_COUNT = 100;
11
13
  /**
12
14
  * Checks whether an asset is `AssetRuneNative`
@@ -98,9 +100,24 @@ export declare const buildUnsignedTx: ({ cosmosSdk, txBody, signerPubkey, sequen
98
100
  cosmosSdk: cosmosclient.CosmosSDK;
99
101
  txBody: proto.cosmos.tx.v1beta1.TxBody;
100
102
  signerPubkey: proto.google.protobuf.Any;
101
- sequence: cosmosclient.Long;
102
- gasLimit: string;
103
+ sequence: Long;
104
+ gasLimit?: Long.Long | undefined;
103
105
  }) => cosmosclient.TxBuilder;
106
+ /**
107
+ * Estimates usage of gas
108
+ *
109
+ * Note: Be careful by using this helper function,
110
+ * it's still experimental and result might be incorrect.
111
+ * Change `multiplier` to get a valid estimation of gas.
112
+ */
113
+ export declare const getEstimatedGas: ({ cosmosSDKClient, txBody, privKey, accountNumber, accountSequence, multiplier, }: {
114
+ cosmosSDKClient: CosmosSDKClient;
115
+ txBody: proto.cosmos.tx.v1beta1.TxBody;
116
+ privKey: proto.cosmos.crypto.secp256k1.PrivKey;
117
+ accountNumber: Long;
118
+ accountSequence: Long;
119
+ multiplier?: number | undefined;
120
+ }) => Promise<Long | undefined>;
104
121
  /**
105
122
  * Structure a MsgDeposit
106
123
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.24.1",
3
+ "version": "0.25.2-alpha.1",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -34,10 +34,10 @@
34
34
  "generate:ThorchainMsgs": "./genMsgs.sh"
35
35
  },
36
36
  "devDependencies": {
37
- "@cosmos-client/core": "^0.45.1",
37
+ "@cosmos-client/core": "^0.45.10",
38
38
  "@types/big.js": "^6.0.0",
39
39
  "@xchainjs/xchain-client": "^0.11.1",
40
- "@xchainjs/xchain-cosmos": "^0.17.0",
40
+ "@xchainjs/xchain-cosmos": "^0.18.0-alpha.2",
41
41
  "@xchainjs/xchain-crypto": "^0.2.4",
42
42
  "@xchainjs/xchain-util": "^0.5.1",
43
43
  "axios": "^0.25.0",
@@ -48,9 +48,9 @@
48
48
  "access": "public"
49
49
  },
50
50
  "peerDependencies": {
51
- "@cosmos-client/core": "^0.45.1",
51
+ "@cosmos-client/core": "^0.45.10",
52
52
  "@xchainjs/xchain-client": "^0.11.1",
53
- "@xchainjs/xchain-cosmos": "^0.17.0",
53
+ "@xchainjs/xchain-cosmos": "^0.18.0-alpha.2",
54
54
  "@xchainjs/xchain-crypto": "^0.2.4",
55
55
  "@xchainjs/xchain-util": "^0.5.1",
56
56
  "axios": "^0.25.0",