@xchainjs/xchain-thorchain 0.27.11 → 0.28.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/lib/client.d.ts CHANGED
@@ -1,223 +1,223 @@
1
- import cosmosclient from '@cosmos-client/core';
2
- import { Balance, BaseXChainClient, Fees, Network, Tx, TxHash, TxHistoryParams, TxParams, TxsPage, XChainClient, XChainClientParams } from '@xchainjs/xchain-client';
3
- import { CosmosSDKClient, RPCTxResult } from '@xchainjs/xchain-cosmos';
4
- import { Address, Asset } from '@xchainjs/xchain-util';
5
- import BigNumber from 'bignumber.js';
6
- import { ChainId, ClientUrl, DepositParam, ExplorerUrls, NodeUrl, ThorchainClientParams, TxOfflineParams } from './types';
7
- /**
8
- * Interface for custom Thorchain client
9
- */
10
- export interface ThorchainClient {
11
- setClientUrl(clientUrl: ClientUrl): void;
12
- getClientUrl(): NodeUrl;
13
- setExplorerUrls(explorerUrls: ExplorerUrls): void;
14
- getCosmosClient(): CosmosSDKClient;
15
- deposit(params: DepositParam): Promise<TxHash>;
16
- transferOffline(params: TxOfflineParams): Promise<string>;
17
- }
18
- /**
19
- * Custom Thorchain Client
20
- */
21
- declare class Client extends BaseXChainClient implements ThorchainClient, XChainClient {
22
- private clientUrl;
23
- private explorerUrls;
24
- private chainIds;
25
- private cosmosClient;
26
- /**
27
- * Constructor
28
- *
29
- * Client has to be initialised with network type and phrase.
30
- * It will throw an error if an invalid phrase has been passed.
31
- *
32
- * @param {XChainClientParams} params
33
- *
34
- * @throws {"Invalid phrase"} Thrown if the given phase is invalid.
35
- */
36
- constructor({ network, phrase, clientUrl, explorerUrls, rootDerivationPaths, chainIds, }: XChainClientParams & ThorchainClientParams);
37
- /**
38
- * Set/update the current network.
39
- *
40
- * @param {Network} network
41
- * @returns {void}
42
- *
43
- * @throws {"Network must be provided"}
44
- * Thrown if network has not been set before.
45
- */
46
- setNetwork(network: Network): void;
47
- /**
48
- * Set/update the client URL.
49
- *
50
- * @param {ClientUrl} clientUrl The client url to be set.
51
- * @returns {void}
52
- */
53
- setClientUrl(clientUrl: ClientUrl): void;
54
- /**
55
- * Get the client url.
56
- *
57
- * @returns {NodeUrl} The client url for thorchain based on the current network.
58
- */
59
- getClientUrl(): NodeUrl;
60
- /**
61
- * Set/update the explorer URLs.
62
- *
63
- * @param {ExplorerUrls} urls The explorer urls to be set.
64
- * @returns {void}
65
- */
66
- setExplorerUrls(urls: ExplorerUrls): void;
67
- /**
68
- * Get the explorer url.
69
- *
70
- * @returns {string} The explorer url for thorchain based on the current network.
71
- */
72
- getExplorerUrl(): string;
73
- /**
74
- * Sets chain id
75
- *
76
- * @param {ChainId} chainId Chain id to update
77
- * @param {Network} network (optional) Network for given chainId. If `network`not set, current network of the client is used
78
- *
79
- * @returns {void}
80
- */
81
- setChainId(chainId: ChainId, network?: Network): void;
82
- /**
83
- * Gets chain id
84
- *
85
- * @param {Network} network (optional) Network to get chain id from. If `network`not set, current network of the client is used
86
- *
87
- * @returns {ChainId} Chain id based on the current network.
88
- */
89
- getChainId(network?: Network): ChainId;
90
- /**
91
- * Get cosmos client
92
- * @returns {CosmosSDKClient} current cosmos client
93
- */
94
- getCosmosClient(): CosmosSDKClient;
95
- /**
96
- * Get the explorer url for the given address.
97
- *
98
- * @param {Address} address
99
- * @returns {string} The explorer url for the given address.
100
- */
101
- getExplorerAddressUrl(address: Address): string;
102
- /**
103
- * Get the explorer url for the given transaction id.
104
- *
105
- * @param {string} txID
106
- * @returns {string} The explorer url for the given transaction id.
107
- */
108
- getExplorerTxUrl(txID: string): string;
109
- /**
110
- * Get private key
111
- *
112
- * @param {number} index the HD wallet index (optional)
113
- * @returns {PrivKey} The private key generated from the given phrase
114
- *
115
- * @throws {"Phrase not set"}
116
- * Throws an error if phrase has not been set before
117
- * */
118
- getPrivateKey(index?: number): cosmosclient.proto.cosmos.crypto.secp256k1.PrivKey;
119
- /**
120
- * Get public key
121
- *
122
- * @param {number} index the HD wallet index (optional)
123
- *
124
- * @returns {PubKey} The public key generated from the given phrase
125
- *
126
- * @throws {"Phrase not set"}
127
- * Throws an error if phrase has not been set before
128
- **/
129
- getPubKey(index?: number): cosmosclient.PubKey;
130
- /**
131
- * Get the current address.
132
- *
133
- * @returns {Address} The current address.
134
- *
135
- * @throws {Error} Thrown if phrase has not been set before. A phrase is needed to create a wallet and to derive an address from it.
136
- */
137
- getAddress(index?: number): string;
138
- /**
139
- * Validate the given address.
140
- *
141
- * @param {Address} address
142
- * @returns {boolean} `true` or `false`
143
- */
144
- validateAddress(address: Address): boolean;
145
- /**
146
- * Get the balance of a given address.
147
- *
148
- * @param {Address} address By default, it will return the balance of the current wallet. (optional)
149
- * @param {Asset} asset If not set, it will return all assets available. (optional)
150
- * @returns {Balance[]} The balance of the address.
151
- */
152
- getBalance(address: Address, assets?: Asset[]): Promise<Balance[]>;
153
- /**
154
- * Get transaction history of a given address with pagination options.
155
- * By default it will return the transaction history of the current wallet.
156
- *
157
- * @param {TxHistoryParams} params The options to get transaction history. (optional)
158
- * @returns {TxsPage} The transaction history.
159
- */
160
- getTransactions: (params?: (TxHistoryParams & {
161
- filterFn?: ((tx: RPCTxResult) => boolean) | undefined;
162
- }) | undefined) => Promise<TxsPage>;
163
- /**
164
- * Get the transaction details of a given transaction id.
165
- *
166
- * @param {string} txId The transaction id.
167
- * @returns {Tx} The transaction details of the given transaction id.
168
- */
169
- getTransactionData(txId: string, address: Address): Promise<Tx>;
170
- /** This function is used when in bound or outbound tx is not of thorchain
171
- *
172
- * @param txId - transaction hash
173
- * @returns - Tx object
174
- */
175
- private getTransactionDataThornode;
176
- /**
177
- * Get the transaction details of a given transaction id. (from /thorchain/txs/hash)
178
- *
179
- * Node: /thorchain/txs/hash response doesn't have timestamp field.
180
- *
181
- * @param {string} txId The transaction id.
182
- * @returns {Tx} The transaction details of the given transaction id.
183
- */
184
- getDepositTransaction(txId: string): Promise<Omit<Tx, 'date'>>;
185
- /**
186
- * Transaction with MsgNativeTx.
187
- *
188
- * @param {DepositParam} params The transaction options.
189
- * @returns {TxHash} The transaction hash.
190
- *
191
- * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
192
- * @throws {"Invalid transaction hash"} Thrown by missing tx hash
193
- */
194
- deposit({ walletIndex, asset, amount, memo, gasLimit, sequence, }: DepositParam): Promise<TxHash>;
195
- /**
196
- * Transfer balances with MsgSend
197
- *
198
- * @param {TxParams} params The transfer options.
199
- * @returns {TxHash} The transaction hash.
200
- *
201
- * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
202
- * @throws {"Invalid transaction hash"} Thrown by missing tx hash
203
- */
204
- transfer({ walletIndex, asset, amount, recipient, memo, gasLimit, sequence, }: TxParams & {
205
- gasLimit?: BigNumber;
206
- sequence?: number;
207
- }): Promise<TxHash>;
208
- broadcastTx(txHex: string): Promise<TxHash>;
209
- /**
210
- * Transfer without broadcast balances with MsgSend
211
- *
212
- * @param {TxOfflineParams} params The transfer offline options.
213
- * @returns {string} The signed transaction bytes.
214
- */
215
- transferOffline({ walletIndex, asset, amount, recipient, memo, fromRuneBalance: from_rune_balance, fromAssetBalance: from_asset_balance, fromAccountNumber, fromSequence, gasLimit, }: TxOfflineParams): Promise<string>;
216
- /**
217
- * Gets fees from Node
218
- *
219
- * @returns {Fees}
220
- */
221
- getFees(): Promise<Fees>;
222
- }
223
- export { Client };
1
+ import cosmosclient from '@cosmos-client/core';
2
+ import { Balance, BaseXChainClient, Fees, Network, Tx, TxHash, TxHistoryParams, TxParams, TxsPage, XChainClient, XChainClientParams } from '@xchainjs/xchain-client';
3
+ import { CosmosSDKClient, RPCTxResult } from '@xchainjs/xchain-cosmos';
4
+ import { Address, Asset } from '@xchainjs/xchain-util';
5
+ import BigNumber from 'bignumber.js';
6
+ import { ChainId, ClientUrl, DepositParam, ExplorerUrls, NodeUrl, ThorchainClientParams, TxOfflineParams } from './types';
7
+ /**
8
+ * Interface for custom Thorchain client
9
+ */
10
+ export interface ThorchainClient {
11
+ setClientUrl(clientUrl: ClientUrl): void;
12
+ getClientUrl(): NodeUrl;
13
+ setExplorerUrls(explorerUrls: ExplorerUrls): void;
14
+ getCosmosClient(): CosmosSDKClient;
15
+ deposit(params: DepositParam): Promise<TxHash>;
16
+ transferOffline(params: TxOfflineParams): Promise<string>;
17
+ }
18
+ /**
19
+ * Custom Thorchain Client
20
+ */
21
+ declare class Client extends BaseXChainClient implements ThorchainClient, XChainClient {
22
+ private clientUrl;
23
+ private explorerUrls;
24
+ private chainIds;
25
+ private cosmosClient;
26
+ /**
27
+ * Constructor
28
+ *
29
+ * Client has to be initialised with network type and phrase.
30
+ * It will throw an error if an invalid phrase has been passed.
31
+ *
32
+ * @param {XChainClientParams} params
33
+ *
34
+ * @throws {"Invalid phrase"} Thrown if the given phase is invalid.
35
+ */
36
+ constructor({ network, phrase, clientUrl, explorerUrls, rootDerivationPaths, chainIds, }: XChainClientParams & ThorchainClientParams);
37
+ /**
38
+ * Set/update the current network.
39
+ *
40
+ * @param {Network} network
41
+ * @returns {void}
42
+ *
43
+ * @throws {"Network must be provided"}
44
+ * Thrown if network has not been set before.
45
+ */
46
+ setNetwork(network: Network): void;
47
+ /**
48
+ * Set/update the client URL.
49
+ *
50
+ * @param {ClientUrl} clientUrl The client url to be set.
51
+ * @returns {void}
52
+ */
53
+ setClientUrl(clientUrl: ClientUrl): void;
54
+ /**
55
+ * Get the client url.
56
+ *
57
+ * @returns {NodeUrl} The client url for thorchain based on the current network.
58
+ */
59
+ getClientUrl(): NodeUrl;
60
+ /**
61
+ * Set/update the explorer URLs.
62
+ *
63
+ * @param {ExplorerUrls} urls The explorer urls to be set.
64
+ * @returns {void}
65
+ */
66
+ setExplorerUrls(urls: ExplorerUrls): void;
67
+ /**
68
+ * Get the explorer url.
69
+ *
70
+ * @returns {string} The explorer url for thorchain based on the current network.
71
+ */
72
+ getExplorerUrl(): string;
73
+ /**
74
+ * Sets chain id
75
+ *
76
+ * @param {ChainId} chainId Chain id to update
77
+ * @param {Network} network (optional) Network for given chainId. If `network`not set, current network of the client is used
78
+ *
79
+ * @returns {void}
80
+ */
81
+ setChainId(chainId: ChainId, network?: Network): void;
82
+ /**
83
+ * Gets chain id
84
+ *
85
+ * @param {Network} network (optional) Network to get chain id from. If `network`not set, current network of the client is used
86
+ *
87
+ * @returns {ChainId} Chain id based on the current network.
88
+ */
89
+ getChainId(network?: Network): ChainId;
90
+ /**
91
+ * Get cosmos client
92
+ * @returns {CosmosSDKClient} current cosmos client
93
+ */
94
+ getCosmosClient(): CosmosSDKClient;
95
+ /**
96
+ * Get the explorer url for the given address.
97
+ *
98
+ * @param {Address} address
99
+ * @returns {string} The explorer url for the given address.
100
+ */
101
+ getExplorerAddressUrl(address: Address): string;
102
+ /**
103
+ * Get the explorer url for the given transaction id.
104
+ *
105
+ * @param {string} txID
106
+ * @returns {string} The explorer url for the given transaction id.
107
+ */
108
+ getExplorerTxUrl(txID: string): string;
109
+ /**
110
+ * Get private key
111
+ *
112
+ * @param {number} index the HD wallet index (optional)
113
+ * @returns {PrivKey} The private key generated from the given phrase
114
+ *
115
+ * @throws {"Phrase not set"}
116
+ * Throws an error if phrase has not been set before
117
+ * */
118
+ getPrivateKey(index?: number): cosmosclient.proto.cosmos.crypto.secp256k1.PrivKey;
119
+ /**
120
+ * Get public key
121
+ *
122
+ * @param {number} index the HD wallet index (optional)
123
+ *
124
+ * @returns {PubKey} The public key generated from the given phrase
125
+ *
126
+ * @throws {"Phrase not set"}
127
+ * Throws an error if phrase has not been set before
128
+ **/
129
+ getPubKey(index?: number): cosmosclient.PubKey;
130
+ /**
131
+ * Get the current address.
132
+ *
133
+ * @returns {Address} The current address.
134
+ *
135
+ * @throws {Error} Thrown if phrase has not been set before. A phrase is needed to create a wallet and to derive an address from it.
136
+ */
137
+ getAddress(index?: number): string;
138
+ /**
139
+ * Validate the given address.
140
+ *
141
+ * @param {Address} address
142
+ * @returns {boolean} `true` or `false`
143
+ */
144
+ validateAddress(address: Address): boolean;
145
+ /**
146
+ * Get the balance of a given address.
147
+ *
148
+ * @param {Address} address By default, it will return the balance of the current wallet. (optional)
149
+ * @param {Asset} asset If not set, it will return all assets available. (optional)
150
+ * @returns {Balance[]} The balance of the address.
151
+ */
152
+ getBalance(address: Address, assets?: Asset[]): Promise<Balance[]>;
153
+ /**
154
+ * Get transaction history of a given address with pagination options.
155
+ * By default it will return the transaction history of the current wallet.
156
+ *
157
+ * @param {TxHistoryParams} params The options to get transaction history. (optional)
158
+ * @returns {TxsPage} The transaction history.
159
+ */
160
+ getTransactions: (params?: (TxHistoryParams & {
161
+ filterFn?: ((tx: RPCTxResult) => boolean) | undefined;
162
+ }) | undefined) => Promise<TxsPage>;
163
+ /**
164
+ * Get the transaction details of a given transaction id.
165
+ *
166
+ * @param {string} txId The transaction id.
167
+ * @returns {Tx} The transaction details of the given transaction id.
168
+ */
169
+ getTransactionData(txId: string, address: Address): Promise<Tx>;
170
+ /** This function is used when in bound or outbound tx is not of thorchain
171
+ *
172
+ * @param txId - transaction hash
173
+ * @returns - Tx object
174
+ */
175
+ private getTransactionDataThornode;
176
+ /**
177
+ * Get the transaction details of a given transaction id. (from /thorchain/txs/hash)
178
+ *
179
+ * Node: /thorchain/txs/hash response doesn't have timestamp field.
180
+ *
181
+ * @param {string} txId The transaction id.
182
+ * @returns {Tx} The transaction details of the given transaction id.
183
+ */
184
+ getDepositTransaction(txId: string): Promise<Omit<Tx, 'date'>>;
185
+ /**
186
+ * Transaction with MsgNativeTx.
187
+ *
188
+ * @param {DepositParam} params The transaction options.
189
+ * @returns {TxHash} The transaction hash.
190
+ *
191
+ * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
192
+ * @throws {"Invalid transaction hash"} Thrown by missing tx hash
193
+ */
194
+ deposit({ walletIndex, asset, amount, memo, gasLimit, sequence, }: DepositParam): Promise<TxHash>;
195
+ /**
196
+ * Transfer balances with MsgSend
197
+ *
198
+ * @param {TxParams} params The transfer options.
199
+ * @returns {TxHash} The transaction hash.
200
+ *
201
+ * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
202
+ * @throws {"Invalid transaction hash"} Thrown by missing tx hash
203
+ */
204
+ transfer({ walletIndex, asset, amount, recipient, memo, gasLimit, sequence, }: TxParams & {
205
+ gasLimit?: BigNumber;
206
+ sequence?: number;
207
+ }): Promise<TxHash>;
208
+ broadcastTx(txHex: string): Promise<TxHash>;
209
+ /**
210
+ * Transfer without broadcast balances with MsgSend
211
+ *
212
+ * @param {TxOfflineParams} params The transfer offline options.
213
+ * @returns {string} The signed transaction bytes.
214
+ */
215
+ transferOffline({ walletIndex, asset, amount, recipient, memo, fromRuneBalance: from_rune_balance, fromAssetBalance: from_asset_balance, fromAccountNumber, fromSequence, gasLimit, }: TxOfflineParams): Promise<string>;
216
+ /**
217
+ * Gets fees from Node
218
+ *
219
+ * @returns {Fees}
220
+ */
221
+ getFees(): Promise<Fees>;
222
+ }
223
+ export { Client };
package/lib/const.d.ts CHANGED
@@ -1,51 +1,51 @@
1
- import { Asset } from '@xchainjs/xchain-util/lib';
2
- import { ExplorerUrls } from './types';
3
- export declare const DECIMAL = 8;
4
- export declare const DEFAULT_GAS_ADJUSTMENT = 2;
5
- export declare const DEFAULT_GAS_LIMIT_VALUE = "4000000";
6
- export declare const DEPOSIT_GAS_LIMIT_VALUE = "600000000";
7
- export declare const MAX_TX_COUNT_PER_PAGE = 100;
8
- export declare const MAX_TX_COUNT_PER_FUNCTION_CALL = 500;
9
- export declare const MAX_PAGES_PER_FUNCTION_CALL = 15;
10
- export declare const RUNE_SYMBOL = "\u16B1";
11
- export declare const defaultExplorerUrls: ExplorerUrls;
12
- /**
13
- * Chain identifier for Thorchain
14
- *
15
- */
16
- export declare const THORChain: "THOR";
17
- /**
18
- * Base "chain" asset for RUNE-67C on Binance test net.
19
- *
20
- * Based on definition in Thorchain `common`
21
- * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
22
- */
23
- export declare const AssetRune67C: Asset;
24
- /**
25
- * Base "chain" asset for RUNE-B1A on Binance main net.
26
- *
27
- * Based on definition in Thorchain `common`
28
- * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
29
- */
30
- export declare const AssetRuneB1A: Asset;
31
- /**
32
- * Base "chain" asset on thorchain main net.
33
- *
34
- * Based on definition in Thorchain `common`
35
- * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
36
- */
37
- export declare const AssetRuneNative: Asset;
38
- /**
39
- * Base "chain" asset for RUNE on ethereum main net.
40
- *
41
- * Based on definition in Thorchain `common`
42
- * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
43
- */
44
- export declare const AssetRuneERC20: Asset;
45
- /**
46
- * Base "chain" asset for RUNE on ethereum main net.
47
- *
48
- * Based on definition in Thorchain `common`
49
- * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
50
- */
51
- export declare const AssetRuneERC20Testnet: Asset;
1
+ import { Asset } from '@xchainjs/xchain-util/lib';
2
+ import { ExplorerUrls } from './types';
3
+ export declare const DECIMAL = 8;
4
+ export declare const DEFAULT_GAS_ADJUSTMENT = 2;
5
+ export declare const DEFAULT_GAS_LIMIT_VALUE = "4000000";
6
+ export declare const DEPOSIT_GAS_LIMIT_VALUE = "600000000";
7
+ export declare const MAX_TX_COUNT_PER_PAGE = 100;
8
+ export declare const MAX_TX_COUNT_PER_FUNCTION_CALL = 500;
9
+ export declare const MAX_PAGES_PER_FUNCTION_CALL = 15;
10
+ export declare const RUNE_SYMBOL = "\u16B1";
11
+ export declare const defaultExplorerUrls: ExplorerUrls;
12
+ /**
13
+ * Chain identifier for Thorchain
14
+ *
15
+ */
16
+ export declare const THORChain: "THOR";
17
+ /**
18
+ * Base "chain" asset for RUNE-67C on Binance test net.
19
+ *
20
+ * Based on definition in Thorchain `common`
21
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
22
+ */
23
+ export declare const AssetRune67C: Asset;
24
+ /**
25
+ * Base "chain" asset for RUNE-B1A on Binance main net.
26
+ *
27
+ * Based on definition in Thorchain `common`
28
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
29
+ */
30
+ export declare const AssetRuneB1A: Asset;
31
+ /**
32
+ * Base "chain" asset on thorchain main net.
33
+ *
34
+ * Based on definition in Thorchain `common`
35
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
36
+ */
37
+ export declare const AssetRuneNative: Asset;
38
+ /**
39
+ * Base "chain" asset for RUNE on ethereum main net.
40
+ *
41
+ * Based on definition in Thorchain `common`
42
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
43
+ */
44
+ export declare const AssetRuneERC20: Asset;
45
+ /**
46
+ * Base "chain" asset for RUNE on ethereum main net.
47
+ *
48
+ * Based on definition in Thorchain `common`
49
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
50
+ */
51
+ export declare const AssetRuneERC20Testnet: Asset;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './client';
2
- export * from './types';
3
- export * from './utils';
4
- export * from './const';
1
+ export * from './client';
2
+ export * from './types';
3
+ export * from './utils';
4
+ export * from './const';