@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/utils.d.ts CHANGED
@@ -1,197 +1,197 @@
1
- import cosmosclient from '@cosmos-client/core';
2
- import { Balance, Fees, Network, TxHash } from '@xchainjs/xchain-client';
3
- import { CosmosSDKClient, TxLog } from '@xchainjs/xchain-cosmos';
4
- import { Address, Asset, BaseAmount } from '@xchainjs/xchain-util';
5
- import Long from 'long';
6
- import { ChainId, ExplorerUrls, TxData } from './types';
7
- import { MsgNativeTx } from './types/messages';
8
- /**
9
- * Checks whether an asset is `AssetRuneNative`
10
- *
11
- * @param {Asset} asset
12
- * @returns {boolean} `true` or `false`
13
- */
14
- export declare const isAssetRuneNative: (asset: Asset) => boolean;
15
- /**
1
+ import cosmosclient from '@cosmos-client/core';
2
+ import { Balance, Fees, Network, TxHash } from '@xchainjs/xchain-client';
3
+ import { CosmosSDKClient, TxLog } from '@xchainjs/xchain-cosmos';
4
+ import { Address, Asset, BaseAmount } from '@xchainjs/xchain-util';
5
+ import Long from 'long';
6
+ import { ChainId, ExplorerUrls, TxData } from './types';
7
+ import { MsgNativeTx } from './types/messages';
8
+ /**
9
+ * Checks whether an asset is `AssetRuneNative`
10
+ *
11
+ * @param {Asset} asset
12
+ * @returns {boolean} `true` or `false`
13
+ */
14
+ export declare const isAssetRuneNative: (asset: Asset) => boolean;
15
+ /**
16
16
 
17
- * Get denomination from Asset
18
- *
19
- * @param {Asset} asset
20
- * @returns {string} The denomination of the given asset.
21
- */
22
- export declare const getDenom: (asset: Asset) => string;
23
- /**
24
- * Get Asset from denomination
25
- *
26
- * @param {string} denom
27
- * @returns {Asset|null} The asset of the given denomination.
28
- */
29
- export declare const assetFromDenom: (denom: string) => Asset | null;
30
- /**
31
- * Response guard for transaction broadcast
32
- *
33
- * @param {any} response The response from the node.
34
- * @returns {boolean} `true` or `false`.
35
- */
36
- export declare const isBroadcastSuccess: (response: unknown) => boolean;
37
- /**
38
- * Get address prefix based on the network.
39
- *
40
- * @param {Network} network
41
- * @returns {string} The address prefix based on the network.
42
- *
43
- **/
44
- export declare const getPrefix: (network: Network) => "thor" | "sthor" | "tthor";
45
- /**
46
- * Register type for encoding `MsgDeposit` messages
47
- */
48
- export declare const registerDepositCodecs: () => void;
49
- /**
50
- * Register type for encoding `MsgSend` messages
51
- */
52
- export declare const registerSendCodecs: () => void;
53
- /**
54
- * Parse transaction data from event logs
55
- *
56
- * @param {TxLog[]} logs List of tx logs
57
- * @param {Address} address - Address to get transaction data for
58
- * @returns {TxData} Parsed transaction data
59
- */
60
- export declare const getDepositTxDataFromLogs: (logs: TxLog[], address: Address, senderAsset?: Asset | undefined, receiverAsset?: Asset | undefined) => TxData;
61
- /**
62
- * Get the default fee.
63
- *
64
- * @returns {Fees} The default fee.
65
- */
66
- export declare const getDefaultFees: () => Fees;
67
- /**
68
- * Get transaction type.
69
- *
70
- * @param {string} txData the transaction input data
71
- * @param {string} encoding `base64` or `hex`
72
- * @returns {string} the transaction type.
73
- */
74
- export declare const getTxType: (txData: string, encoding: 'base64' | 'hex') => string;
75
- /**
76
- * Helper to get THORChain's chain id
77
- * @param {string} nodeUrl THORNode url
78
- */
79
- export declare const getChainId: (nodeUrl: string) => Promise<ChainId>;
80
- /**
81
- * Builds final unsigned TX
82
- *
83
- * @param cosmosSdk - CosmosSDK
84
- * @param txBody - txBody with encoded Msgs
85
- * @param signerPubkey - signerPubkey string
86
- * @param sequence - account sequence
87
- * @param gasLimit - transaction gas limit
88
- * @returns
89
- */
90
- export declare const buildUnsignedTx: ({ cosmosSdk, txBody, signerPubkey, sequence, gasLimit, }: {
91
- cosmosSdk: cosmosclient.CosmosSDK;
92
- txBody: cosmosclient.proto.cosmos.tx.v1beta1.TxBody;
93
- signerPubkey: cosmosclient.proto.google.protobuf.Any;
94
- sequence: Long;
95
- gasLimit?: Long.Long | undefined;
96
- }) => cosmosclient.TxBuilder;
97
- /**
98
- * Estimates usage of gas
99
- *
100
- * Note: Be careful by using this helper function,
101
- * it's still experimental and result might be incorrect.
102
- * Change `multiplier` to get a valid estimation of gas.
103
- */
104
- export declare const getEstimatedGas: ({ cosmosSDKClient, txBody, privKey, accountNumber, accountSequence, multiplier, }: {
105
- cosmosSDKClient: CosmosSDKClient;
106
- txBody: cosmosclient.proto.cosmos.tx.v1beta1.TxBody;
107
- privKey: cosmosclient.proto.cosmos.crypto.secp256k1.PrivKey;
108
- accountNumber: Long;
109
- accountSequence: Long;
110
- multiplier?: number | undefined;
111
- }) => Promise<Long | undefined>;
112
- /**
113
- * Structure a MsgDeposit
114
- *
115
- * @param {MsgNativeTx} msgNativeTx Msg of type `MsgNativeTx`.
116
- * @param {string} nodeUrl Node url
117
- * @param {chainId} ChainId Chain id of the network
118
- *
119
- * @returns {Tx} The transaction details of the given transaction id.
120
- *
121
- * @throws {"Invalid client url"} Thrown if the client url is an invalid one.
122
- */
123
- export declare const buildDepositTx: ({ msgNativeTx, nodeUrl, chainId, }: {
124
- msgNativeTx: MsgNativeTx;
125
- nodeUrl: string;
126
- chainId: ChainId;
127
- }) => Promise<cosmosclient.proto.cosmos.tx.v1beta1.TxBody>;
128
- /**
129
- * Structure a MsgSend
130
- *
131
- * @param fromAddress - required, from address string
132
- * @param toAddress - required, to address string
133
- * @param assetAmount - required, asset amount string (e.g. "10000")
134
- * @param assetDenom - required, asset denom string (e.g. "rune")
135
- * @param memo - optional, memo string
136
- *
137
- * @returns
138
- */
139
- export declare const buildTransferTx: ({ fromAddress, toAddress, assetAmount, assetDenom, memo, nodeUrl, chainId, }: {
140
- fromAddress: Address;
141
- toAddress: Address;
142
- assetAmount: BaseAmount;
143
- assetDenom: string;
144
- memo?: string | undefined;
145
- nodeUrl: string;
146
- chainId: ChainId;
147
- }) => Promise<cosmosclient.proto.cosmos.tx.v1beta1.TxBody>;
148
- /**
149
- * Get the balance of a given address.
150
- *
151
- * @param {Address} address By default, it will return the balance of the current wallet. (optional)
152
- * @param {Asset} asset If not set, it will return all assets available. (optional)
153
- * @param {cosmosClient} CosmosSDKClient
154
- *
155
- * @returns {Balance[]} The balance of the address.
156
- */
157
- export declare const getBalance: ({ address, assets, cosmosClient, }: {
158
- address: Address;
159
- assets?: Asset[] | undefined;
160
- cosmosClient: CosmosSDKClient;
161
- }) => Promise<Balance[]>;
162
- /**
163
- * Get the explorer url.
164
- *
165
- * @param {Network} network
166
- * @param {ExplorerUrls} Explorer urls
167
- * @returns {string} The explorer url for thorchain based on the given network.
168
- */
169
- export declare const getExplorerUrl: ({ root }: ExplorerUrls, network: Network) => string;
170
- /**
171
- * Get explorer address url.
172
- *
173
- * @param {ExplorerUrls} Explorer urls
174
- * @param {Network} network
175
- * @param {Address} address
176
- * @returns {string} The explorer url for the given address.
177
- */
178
- export declare const getExplorerAddressUrl: ({ urls, network, address, }: {
179
- urls: ExplorerUrls;
180
- network: Network;
181
- address: Address;
182
- }) => string;
183
- /**
184
- * Get transaction url.
185
- *
186
- * @param {ExplorerUrls} Explorer urls
187
- * @param {Network} network
188
- * @param {TxHash} txID
189
- * @returns {string} The explorer url for the given transaction id.
190
- */
191
- export declare const getExplorerTxUrl: ({ urls, network, txID, }: {
192
- urls: ExplorerUrls;
193
- network: Network;
194
- txID: TxHash;
195
- }) => string;
196
- export declare const getAccount: (address: string, client: CosmosSDKClient) => Promise<cosmosclient.proto.cosmos.auth.v1beta1.IBaseAccount>;
197
- export declare const getSequence: (address: string, client: CosmosSDKClient) => Promise<number | null>;
17
+ * Get denomination from Asset
18
+ *
19
+ * @param {Asset} asset
20
+ * @returns {string} The denomination of the given asset.
21
+ */
22
+ export declare const getDenom: (asset: Asset) => string;
23
+ /**
24
+ * Get Asset from denomination
25
+ *
26
+ * @param {string} denom
27
+ * @returns {Asset|null} The asset of the given denomination.
28
+ */
29
+ export declare const assetFromDenom: (denom: string) => Asset | null;
30
+ /**
31
+ * Response guard for transaction broadcast
32
+ *
33
+ * @param {any} response The response from the node.
34
+ * @returns {boolean} `true` or `false`.
35
+ */
36
+ export declare const isBroadcastSuccess: (response: unknown) => boolean;
37
+ /**
38
+ * Get address prefix based on the network.
39
+ *
40
+ * @param {Network} network
41
+ * @returns {string} The address prefix based on the network.
42
+ *
43
+ **/
44
+ export declare const getPrefix: (network: Network) => "thor" | "sthor" | "tthor";
45
+ /**
46
+ * Register type for encoding `MsgDeposit` messages
47
+ */
48
+ export declare const registerDepositCodecs: () => void;
49
+ /**
50
+ * Register type for encoding `MsgSend` messages
51
+ */
52
+ export declare const registerSendCodecs: () => void;
53
+ /**
54
+ * Parse transaction data from event logs
55
+ *
56
+ * @param {TxLog[]} logs List of tx logs
57
+ * @param {Address} address - Address to get transaction data for
58
+ * @returns {TxData} Parsed transaction data
59
+ */
60
+ export declare const getDepositTxDataFromLogs: (logs: TxLog[], address: Address, senderAsset?: Asset, receiverAsset?: Asset) => TxData;
61
+ /**
62
+ * Get the default fee.
63
+ *
64
+ * @returns {Fees} The default fee.
65
+ */
66
+ export declare const getDefaultFees: () => Fees;
67
+ /**
68
+ * Get transaction type.
69
+ *
70
+ * @param {string} txData the transaction input data
71
+ * @param {string} encoding `base64` or `hex`
72
+ * @returns {string} the transaction type.
73
+ */
74
+ export declare const getTxType: (txData: string, encoding: 'base64' | 'hex') => string;
75
+ /**
76
+ * Helper to get THORChain's chain id
77
+ * @param {string} nodeUrl THORNode url
78
+ */
79
+ export declare const getChainId: (nodeUrl: string) => Promise<ChainId>;
80
+ /**
81
+ * Builds final unsigned TX
82
+ *
83
+ * @param cosmosSdk - CosmosSDK
84
+ * @param txBody - txBody with encoded Msgs
85
+ * @param signerPubkey - signerPubkey string
86
+ * @param sequence - account sequence
87
+ * @param gasLimit - transaction gas limit
88
+ * @returns
89
+ */
90
+ export declare const buildUnsignedTx: ({ cosmosSdk, txBody, signerPubkey, sequence, gasLimit, }: {
91
+ cosmosSdk: cosmosclient.CosmosSDK;
92
+ txBody: cosmosclient.proto.cosmos.tx.v1beta1.TxBody;
93
+ signerPubkey: cosmosclient.proto.google.protobuf.Any;
94
+ sequence: Long;
95
+ gasLimit?: Long.Long | undefined;
96
+ }) => cosmosclient.TxBuilder;
97
+ /**
98
+ * Estimates usage of gas
99
+ *
100
+ * Note: Be careful by using this helper function,
101
+ * it's still experimental and result might be incorrect.
102
+ * Change `multiplier` to get a valid estimation of gas.
103
+ */
104
+ export declare const getEstimatedGas: ({ cosmosSDKClient, txBody, privKey, accountNumber, accountSequence, multiplier, }: {
105
+ cosmosSDKClient: CosmosSDKClient;
106
+ txBody: cosmosclient.proto.cosmos.tx.v1beta1.TxBody;
107
+ privKey: cosmosclient.proto.cosmos.crypto.secp256k1.PrivKey;
108
+ accountNumber: Long;
109
+ accountSequence: Long;
110
+ multiplier?: number | undefined;
111
+ }) => Promise<Long | undefined>;
112
+ /**
113
+ * Structure a MsgDeposit
114
+ *
115
+ * @param {MsgNativeTx} msgNativeTx Msg of type `MsgNativeTx`.
116
+ * @param {string} nodeUrl Node url
117
+ * @param {chainId} ChainId Chain id of the network
118
+ *
119
+ * @returns {Tx} The transaction details of the given transaction id.
120
+ *
121
+ * @throws {"Invalid client url"} Thrown if the client url is an invalid one.
122
+ */
123
+ export declare const buildDepositTx: ({ msgNativeTx, nodeUrl, chainId, }: {
124
+ msgNativeTx: MsgNativeTx;
125
+ nodeUrl: string;
126
+ chainId: ChainId;
127
+ }) => Promise<cosmosclient.proto.cosmos.tx.v1beta1.TxBody>;
128
+ /**
129
+ * Structure a MsgSend
130
+ *
131
+ * @param fromAddress - required, from address string
132
+ * @param toAddress - required, to address string
133
+ * @param assetAmount - required, asset amount string (e.g. "10000")
134
+ * @param assetDenom - required, asset denom string (e.g. "rune")
135
+ * @param memo - optional, memo string
136
+ *
137
+ * @returns
138
+ */
139
+ export declare const buildTransferTx: ({ fromAddress, toAddress, assetAmount, assetDenom, memo, nodeUrl, chainId, }: {
140
+ fromAddress: Address;
141
+ toAddress: Address;
142
+ assetAmount: BaseAmount;
143
+ assetDenom: string;
144
+ memo?: string | undefined;
145
+ nodeUrl: string;
146
+ chainId: ChainId;
147
+ }) => Promise<cosmosclient.proto.cosmos.tx.v1beta1.TxBody>;
148
+ /**
149
+ * Get the balance of a given address.
150
+ *
151
+ * @param {Address} address By default, it will return the balance of the current wallet. (optional)
152
+ * @param {Asset} asset If not set, it will return all assets available. (optional)
153
+ * @param {cosmosClient} CosmosSDKClient
154
+ *
155
+ * @returns {Balance[]} The balance of the address.
156
+ */
157
+ export declare const getBalance: ({ address, assets, cosmosClient, }: {
158
+ address: Address;
159
+ assets?: Asset[] | undefined;
160
+ cosmosClient: CosmosSDKClient;
161
+ }) => Promise<Balance[]>;
162
+ /**
163
+ * Get the explorer url.
164
+ *
165
+ * @param {Network} network
166
+ * @param {ExplorerUrls} Explorer urls
167
+ * @returns {string} The explorer url for thorchain based on the given network.
168
+ */
169
+ export declare const getExplorerUrl: ({ root }: ExplorerUrls, network: Network) => string;
170
+ /**
171
+ * Get explorer address url.
172
+ *
173
+ * @param {ExplorerUrls} Explorer urls
174
+ * @param {Network} network
175
+ * @param {Address} address
176
+ * @returns {string} The explorer url for the given address.
177
+ */
178
+ export declare const getExplorerAddressUrl: ({ urls, network, address, }: {
179
+ urls: ExplorerUrls;
180
+ network: Network;
181
+ address: Address;
182
+ }) => string;
183
+ /**
184
+ * Get transaction url.
185
+ *
186
+ * @param {ExplorerUrls} Explorer urls
187
+ * @param {Network} network
188
+ * @param {TxHash} txID
189
+ * @returns {string} The explorer url for the given transaction id.
190
+ */
191
+ export declare const getExplorerTxUrl: ({ urls, network, txID, }: {
192
+ urls: ExplorerUrls;
193
+ network: Network;
194
+ txID: TxHash;
195
+ }) => string;
196
+ export declare const getAccount: (address: string, client: CosmosSDKClient) => Promise<cosmosclient.proto.cosmos.auth.v1beta1.IBaseAccount>;
197
+ export declare const getSequence: (address: string, client: CosmosSDKClient) => Promise<number | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.27.11",
3
+ "version": "0.28.0",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -35,12 +35,12 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@cosmos-client/core": "0.46.1",
38
- "@types/big.js": "^6.0.0",
39
- "@xchainjs/xchain-client": "^0.13.7",
40
- "@xchainjs/xchain-cosmos": "^0.20.9",
41
- "@xchainjs/xchain-crypto": "^0.2.6",
42
- "@xchainjs/xchain-util": "^0.12.0",
43
- "axios": "^0.25.0",
38
+ "@types/big.js": "^6.1.6",
39
+ "@xchainjs/xchain-client": "^0.14.0",
40
+ "@xchainjs/xchain-cosmos": "^0.21.0",
41
+ "@xchainjs/xchain-crypto": "^0.3.0",
42
+ "@xchainjs/xchain-util": "^0.13.0",
43
+ "axios": "^1.3.6",
44
44
  "bech32-buffer": "^0.2.0",
45
45
  "nock": "^13.0.5"
46
46
  },
@@ -49,11 +49,11 @@
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@cosmos-client/core": "0.46.1",
52
- "@xchainjs/xchain-client": "^0.13.7",
53
- "@xchainjs/xchain-cosmos": "^0.20.9",
54
- "@xchainjs/xchain-crypto": "^0.2.6",
55
- "@xchainjs/xchain-util": "^0.12.0",
56
- "axios": "^0.25.0",
52
+ "@xchainjs/xchain-client": "^0.14.0",
53
+ "@xchainjs/xchain-cosmos": "^0.21.0",
54
+ "@xchainjs/xchain-crypto": "^0.3.0",
55
+ "@xchainjs/xchain-util": "^0.13.0",
56
+ "axios": "^1.3.6",
57
57
  "bech32-buffer": "^0.2.0"
58
58
  }
59
59
  }