@xchainjs/xchain-thorchain 0.26.1 → 0.27.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.
package/lib/index.esm.js CHANGED
@@ -9605,6 +9605,26 @@ const DEFAULT_GAS_LIMIT_VALUE = '4000000';
9605
9605
  const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
9606
9606
  const MAX_TX_COUNT = 100;
9607
9607
  const DENOM_RUNE_NATIVE = 'rune';
9608
+ const DEFAULT_EXPLORER_URL = 'https://viewblock.io/thorchain';
9609
+ const txUrl = `${DEFAULT_EXPLORER_URL}/tx`;
9610
+ const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
9611
+ const defaultExplorerUrls = {
9612
+ root: {
9613
+ [Network.Testnet]: `${DEFAULT_EXPLORER_URL}?network=testnet`,
9614
+ [Network.Stagenet]: `${DEFAULT_EXPLORER_URL}?network=stagenet`,
9615
+ [Network.Mainnet]: DEFAULT_EXPLORER_URL,
9616
+ },
9617
+ tx: {
9618
+ [Network.Testnet]: txUrl,
9619
+ [Network.Stagenet]: txUrl,
9620
+ [Network.Mainnet]: txUrl,
9621
+ },
9622
+ address: {
9623
+ [Network.Testnet]: addressUrl,
9624
+ [Network.Stagenet]: addressUrl,
9625
+ [Network.Mainnet]: addressUrl,
9626
+ },
9627
+ };
9608
9628
  /**
9609
9629
  * Get denomination from Asset
9610
9630
  *
@@ -9733,21 +9753,6 @@ const getChainId = (nodeUrl) => __awaiter(void 0, void 0, void 0, function* () {
9733
9753
  const { data } = yield axios.get(`${nodeUrl}/cosmos/base/tendermint/v1beta1/node_info`);
9734
9754
  return ((_a = data === null || data === void 0 ? void 0 : data.default_node_info) === null || _a === void 0 ? void 0 : _a.network) || Promise.reject('Could not parse chain id');
9735
9755
  });
9736
- /**
9737
- * Helper to get all THORChain's chain id
9738
- * @param {ClientUrl} client urls (use `getDefaultClientUrl()` if you don't need to use custom urls)
9739
- */
9740
- const getChainIds = (client) => __awaiter(void 0, void 0, void 0, function* () {
9741
- return Promise.all([
9742
- getChainId(client[Network.Testnet].node),
9743
- getChainId(client[Network.Stagenet].node),
9744
- getChainId(client[Network.Mainnet].node),
9745
- ]).then(([testnetId, stagenetId, mainnetId]) => ({
9746
- testnet: testnetId,
9747
- stagenet: stagenetId,
9748
- mainnet: mainnetId,
9749
- }));
9750
- });
9751
9756
  /**
9752
9757
  * Builds final unsigned TX
9753
9758
  *
@@ -9884,57 +9889,6 @@ const getBalance = ({ address, assets, cosmosClient, }) => __awaiter(void 0, voi
9884
9889
  }))
9885
9890
  .filter((balance) => !assets || assets.filter((asset) => assetToString(balance.asset) === assetToString(asset)).length);
9886
9891
  });
9887
- /**
9888
- * Get the client url.
9889
- *
9890
- * @returns {ClientUrl} The client url (both mainnet and testnet) for thorchain.
9891
- */
9892
- const getDefaultClientUrl = () => {
9893
- return {
9894
- [Network.Testnet]: {
9895
- node: 'https://testnet.thornode.thorchain.info',
9896
- rpc: 'https://testnet-rpc.ninerealms.com',
9897
- },
9898
- [Network.Stagenet]: {
9899
- node: 'https://stagenet-thornode.ninerealms.com',
9900
- rpc: 'https://stagenet-rpc.ninerealms.com',
9901
- },
9902
- [Network.Mainnet]: {
9903
- node: 'https://thornode.ninerealms.com',
9904
- rpc: 'https://rpc.ninerealms.com',
9905
- },
9906
- };
9907
- };
9908
- const DEFAULT_EXPLORER_URL = 'https://viewblock.io/thorchain';
9909
- /**
9910
- * Get default explorer urls.
9911
- *
9912
- * @returns {ExplorerUrls} Default explorer urls (both mainnet and testnet) for thorchain.
9913
- */
9914
- const getDefaultExplorerUrls = () => {
9915
- const root = {
9916
- [Network.Testnet]: `${DEFAULT_EXPLORER_URL}?network=testnet`,
9917
- [Network.Stagenet]: `${DEFAULT_EXPLORER_URL}?network=stagenet`,
9918
- [Network.Mainnet]: DEFAULT_EXPLORER_URL,
9919
- };
9920
- const txUrl = `${DEFAULT_EXPLORER_URL}/tx`;
9921
- const tx = {
9922
- [Network.Testnet]: txUrl,
9923
- [Network.Stagenet]: txUrl,
9924
- [Network.Mainnet]: txUrl,
9925
- };
9926
- const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
9927
- const address = {
9928
- [Network.Testnet]: addressUrl,
9929
- [Network.Stagenet]: addressUrl,
9930
- [Network.Mainnet]: addressUrl,
9931
- };
9932
- return {
9933
- root,
9934
- tx,
9935
- address,
9936
- };
9937
- };
9938
9892
  /**
9939
9893
  * Get the explorer url.
9940
9894
  *
@@ -9996,11 +9950,28 @@ class Client extends BaseXChainClient {
9996
9950
  *
9997
9951
  * @throws {"Invalid phrase"} Thrown if the given phase is invalid.
9998
9952
  */
9999
- constructor({ network = Network.Testnet, phrase, clientUrl, explorerUrls, rootDerivationPaths = {
9953
+ constructor({ network = Network.Mainnet, phrase, clientUrl = {
9954
+ [Network.Testnet]: {
9955
+ node: 'deprecated',
9956
+ rpc: 'deprecated',
9957
+ },
9958
+ [Network.Stagenet]: {
9959
+ node: 'https://stagenet-thornode.ninerealms.com',
9960
+ rpc: 'https://stagenet-rpc.ninerealms.com',
9961
+ },
9962
+ [Network.Mainnet]: {
9963
+ node: 'https://thornode.ninerealms.com',
9964
+ rpc: 'https://rpc.ninerealms.com',
9965
+ },
9966
+ }, explorerUrls = defaultExplorerUrls, rootDerivationPaths = {
10000
9967
  [Network.Mainnet]: "44'/931'/0'/0/",
10001
9968
  [Network.Stagenet]: "44'/931'/0'/0/",
10002
9969
  [Network.Testnet]: "44'/931'/0'/0/",
10003
- }, chainIds, }) {
9970
+ }, chainIds = {
9971
+ [Network.Mainnet]: 'thorchain-mainnet-v1',
9972
+ [Network.Stagenet]: 'chain-id-stagenet',
9973
+ [Network.Testnet]: 'deprecated',
9974
+ }, }) {
10004
9975
  super(Chain.Cosmos, { network, rootDerivationPaths, phrase });
10005
9976
  /**
10006
9977
  * Get transaction history of a given address with pagination options.
@@ -10053,8 +10024,8 @@ class Client extends BaseXChainClient {
10053
10024
  txs,
10054
10025
  };
10055
10026
  });
10056
- this.clientUrl = clientUrl || getDefaultClientUrl();
10057
- this.explorerUrls = explorerUrls || getDefaultExplorerUrls();
10027
+ this.clientUrl = clientUrl;
10028
+ this.explorerUrls = explorerUrls;
10058
10029
  this.chainIds = chainIds;
10059
10030
  registerSendCodecs();
10060
10031
  registerDepositCodecs();
@@ -10487,4 +10458,4 @@ const msgNativeTxFromJson = (value) => {
10487
10458
  return new MsgNativeTx(value.coins, value.memo, cosmosclient.AccAddress.fromString(value.signer));
10488
10459
  };
10489
10460
 
10490
- 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, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
10461
+ export { Client, DECIMAL, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, defaultExplorerUrls, getBalance, getChainId, getDefaultFees, getDenom, getDepositTxDataFromLogs, getEstimatedGas, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getTxType, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
package/lib/index.js CHANGED
@@ -9613,6 +9613,26 @@ const DEFAULT_GAS_LIMIT_VALUE = '4000000';
9613
9613
  const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
9614
9614
  const MAX_TX_COUNT = 100;
9615
9615
  const DENOM_RUNE_NATIVE = 'rune';
9616
+ const DEFAULT_EXPLORER_URL = 'https://viewblock.io/thorchain';
9617
+ const txUrl = `${DEFAULT_EXPLORER_URL}/tx`;
9618
+ const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
9619
+ const defaultExplorerUrls = {
9620
+ root: {
9621
+ [xchainClient.Network.Testnet]: `${DEFAULT_EXPLORER_URL}?network=testnet`,
9622
+ [xchainClient.Network.Stagenet]: `${DEFAULT_EXPLORER_URL}?network=stagenet`,
9623
+ [xchainClient.Network.Mainnet]: DEFAULT_EXPLORER_URL,
9624
+ },
9625
+ tx: {
9626
+ [xchainClient.Network.Testnet]: txUrl,
9627
+ [xchainClient.Network.Stagenet]: txUrl,
9628
+ [xchainClient.Network.Mainnet]: txUrl,
9629
+ },
9630
+ address: {
9631
+ [xchainClient.Network.Testnet]: addressUrl,
9632
+ [xchainClient.Network.Stagenet]: addressUrl,
9633
+ [xchainClient.Network.Mainnet]: addressUrl,
9634
+ },
9635
+ };
9616
9636
  /**
9617
9637
  * Get denomination from Asset
9618
9638
  *
@@ -9741,21 +9761,6 @@ const getChainId = (nodeUrl) => __awaiter(void 0, void 0, void 0, function* () {
9741
9761
  const { data } = yield axios__default['default'].get(`${nodeUrl}/cosmos/base/tendermint/v1beta1/node_info`);
9742
9762
  return ((_a = data === null || data === void 0 ? void 0 : data.default_node_info) === null || _a === void 0 ? void 0 : _a.network) || Promise.reject('Could not parse chain id');
9743
9763
  });
9744
- /**
9745
- * Helper to get all THORChain's chain id
9746
- * @param {ClientUrl} client urls (use `getDefaultClientUrl()` if you don't need to use custom urls)
9747
- */
9748
- const getChainIds = (client) => __awaiter(void 0, void 0, void 0, function* () {
9749
- return Promise.all([
9750
- getChainId(client[xchainClient.Network.Testnet].node),
9751
- getChainId(client[xchainClient.Network.Stagenet].node),
9752
- getChainId(client[xchainClient.Network.Mainnet].node),
9753
- ]).then(([testnetId, stagenetId, mainnetId]) => ({
9754
- testnet: testnetId,
9755
- stagenet: stagenetId,
9756
- mainnet: mainnetId,
9757
- }));
9758
- });
9759
9764
  /**
9760
9765
  * Builds final unsigned TX
9761
9766
  *
@@ -9892,57 +9897,6 @@ const getBalance = ({ address, assets, cosmosClient, }) => __awaiter(void 0, voi
9892
9897
  }))
9893
9898
  .filter((balance) => !assets || assets.filter((asset) => xchainUtil.assetToString(balance.asset) === xchainUtil.assetToString(asset)).length);
9894
9899
  });
9895
- /**
9896
- * Get the client url.
9897
- *
9898
- * @returns {ClientUrl} The client url (both mainnet and testnet) for thorchain.
9899
- */
9900
- const getDefaultClientUrl = () => {
9901
- return {
9902
- [xchainClient.Network.Testnet]: {
9903
- node: 'https://testnet.thornode.thorchain.info',
9904
- rpc: 'https://testnet-rpc.ninerealms.com',
9905
- },
9906
- [xchainClient.Network.Stagenet]: {
9907
- node: 'https://stagenet-thornode.ninerealms.com',
9908
- rpc: 'https://stagenet-rpc.ninerealms.com',
9909
- },
9910
- [xchainClient.Network.Mainnet]: {
9911
- node: 'https://thornode.ninerealms.com',
9912
- rpc: 'https://rpc.ninerealms.com',
9913
- },
9914
- };
9915
- };
9916
- const DEFAULT_EXPLORER_URL = 'https://viewblock.io/thorchain';
9917
- /**
9918
- * Get default explorer urls.
9919
- *
9920
- * @returns {ExplorerUrls} Default explorer urls (both mainnet and testnet) for thorchain.
9921
- */
9922
- const getDefaultExplorerUrls = () => {
9923
- const root = {
9924
- [xchainClient.Network.Testnet]: `${DEFAULT_EXPLORER_URL}?network=testnet`,
9925
- [xchainClient.Network.Stagenet]: `${DEFAULT_EXPLORER_URL}?network=stagenet`,
9926
- [xchainClient.Network.Mainnet]: DEFAULT_EXPLORER_URL,
9927
- };
9928
- const txUrl = `${DEFAULT_EXPLORER_URL}/tx`;
9929
- const tx = {
9930
- [xchainClient.Network.Testnet]: txUrl,
9931
- [xchainClient.Network.Stagenet]: txUrl,
9932
- [xchainClient.Network.Mainnet]: txUrl,
9933
- };
9934
- const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
9935
- const address = {
9936
- [xchainClient.Network.Testnet]: addressUrl,
9937
- [xchainClient.Network.Stagenet]: addressUrl,
9938
- [xchainClient.Network.Mainnet]: addressUrl,
9939
- };
9940
- return {
9941
- root,
9942
- tx,
9943
- address,
9944
- };
9945
- };
9946
9900
  /**
9947
9901
  * Get the explorer url.
9948
9902
  *
@@ -10004,11 +9958,28 @@ class Client extends xchainClient.BaseXChainClient {
10004
9958
  *
10005
9959
  * @throws {"Invalid phrase"} Thrown if the given phase is invalid.
10006
9960
  */
10007
- constructor({ network = xchainClient.Network.Testnet, phrase, clientUrl, explorerUrls, rootDerivationPaths = {
9961
+ constructor({ network = xchainClient.Network.Mainnet, phrase, clientUrl = {
9962
+ [xchainClient.Network.Testnet]: {
9963
+ node: 'deprecated',
9964
+ rpc: 'deprecated',
9965
+ },
9966
+ [xchainClient.Network.Stagenet]: {
9967
+ node: 'https://stagenet-thornode.ninerealms.com',
9968
+ rpc: 'https://stagenet-rpc.ninerealms.com',
9969
+ },
9970
+ [xchainClient.Network.Mainnet]: {
9971
+ node: 'https://thornode.ninerealms.com',
9972
+ rpc: 'https://rpc.ninerealms.com',
9973
+ },
9974
+ }, explorerUrls = defaultExplorerUrls, rootDerivationPaths = {
10008
9975
  [xchainClient.Network.Mainnet]: "44'/931'/0'/0/",
10009
9976
  [xchainClient.Network.Stagenet]: "44'/931'/0'/0/",
10010
9977
  [xchainClient.Network.Testnet]: "44'/931'/0'/0/",
10011
- }, chainIds, }) {
9978
+ }, chainIds = {
9979
+ [xchainClient.Network.Mainnet]: 'thorchain-mainnet-v1',
9980
+ [xchainClient.Network.Stagenet]: 'chain-id-stagenet',
9981
+ [xchainClient.Network.Testnet]: 'deprecated',
9982
+ }, }) {
10012
9983
  super(xchainUtil.Chain.Cosmos, { network, rootDerivationPaths, phrase });
10013
9984
  /**
10014
9985
  * Get transaction history of a given address with pagination options.
@@ -10061,8 +10032,8 @@ class Client extends xchainClient.BaseXChainClient {
10061
10032
  txs,
10062
10033
  };
10063
10034
  });
10064
- this.clientUrl = clientUrl || getDefaultClientUrl();
10065
- this.explorerUrls = explorerUrls || getDefaultExplorerUrls();
10035
+ this.clientUrl = clientUrl;
10036
+ this.explorerUrls = explorerUrls;
10066
10037
  this.chainIds = chainIds;
10067
10038
  registerSendCodecs();
10068
10039
  registerDepositCodecs();
@@ -10506,11 +10477,9 @@ exports.assetFromDenom = assetFromDenom;
10506
10477
  exports.buildDepositTx = buildDepositTx;
10507
10478
  exports.buildTransferTx = buildTransferTx;
10508
10479
  exports.buildUnsignedTx = buildUnsignedTx;
10480
+ exports.defaultExplorerUrls = defaultExplorerUrls;
10509
10481
  exports.getBalance = getBalance;
10510
10482
  exports.getChainId = getChainId;
10511
- exports.getChainIds = getChainIds;
10512
- exports.getDefaultClientUrl = getDefaultClientUrl;
10513
- exports.getDefaultExplorerUrls = getDefaultExplorerUrls;
10514
10483
  exports.getDefaultFees = getDefaultFees;
10515
10484
  exports.getDenom = getDenom;
10516
10485
  exports.getDepositTxDataFromLogs = getDepositTxDataFromLogs;
@@ -18,7 +18,7 @@ export declare type ChainIds = Record<Network, ChainId>;
18
18
  export declare type ThorchainClientParams = {
19
19
  clientUrl?: ClientUrl;
20
20
  explorerUrls?: ExplorerUrls;
21
- chainIds: ChainIds;
21
+ chainIds?: ChainIds;
22
22
  };
23
23
  export declare type DepositParam = {
24
24
  walletIndex?: number;
package/lib/util.d.ts CHANGED
@@ -3,13 +3,14 @@ import { Balance, Fees, Network, TxHash } from '@xchainjs/xchain-client';
3
3
  import { CosmosSDKClient, TxLog } from '@xchainjs/xchain-cosmos';
4
4
  import { Address, Asset, BaseAmount } from '@xchainjs/xchain-util';
5
5
  import Long from 'long';
6
- import { ChainId, ChainIds, ClientUrl, ExplorerUrls, TxData } from './types';
6
+ import { ChainId, ExplorerUrls, TxData } from './types';
7
7
  import { MsgNativeTx } from './types/messages';
8
8
  export declare const DECIMAL = 8;
9
9
  export declare const DEFAULT_GAS_ADJUSTMENT = 2;
10
10
  export declare const DEFAULT_GAS_LIMIT_VALUE = "4000000";
11
11
  export declare const DEPOSIT_GAS_LIMIT_VALUE = "600000000";
12
12
  export declare const MAX_TX_COUNT = 100;
13
+ export declare const defaultExplorerUrls: ExplorerUrls;
13
14
  /**
14
15
  * Get denomination from Asset
15
16
  *
@@ -74,11 +75,6 @@ export declare const getTxType: (txData: string, encoding: 'base64' | 'hex') =>
74
75
  * @param {string} nodeUrl THORNode url
75
76
  */
76
77
  export declare const getChainId: (nodeUrl: string) => Promise<ChainId>;
77
- /**
78
- * Helper to get all THORChain's chain id
79
- * @param {ClientUrl} client urls (use `getDefaultClientUrl()` if you don't need to use custom urls)
80
- */
81
- export declare const getChainIds: (client: ClientUrl) => Promise<ChainIds>;
82
78
  /**
83
79
  * Builds final unsigned TX
84
80
  *
@@ -161,18 +157,6 @@ export declare const getBalance: ({ address, assets, cosmosClient, }: {
161
157
  assets?: Asset[] | undefined;
162
158
  cosmosClient: CosmosSDKClient;
163
159
  }) => Promise<Balance[]>;
164
- /**
165
- * Get the client url.
166
- *
167
- * @returns {ClientUrl} The client url (both mainnet and testnet) for thorchain.
168
- */
169
- export declare const getDefaultClientUrl: () => ClientUrl;
170
- /**
171
- * Get default explorer urls.
172
- *
173
- * @returns {ExplorerUrls} Default explorer urls (both mainnet and testnet) for thorchain.
174
- */
175
- export declare const getDefaultExplorerUrls: () => ExplorerUrls;
176
160
  /**
177
161
  * Get the explorer url.
178
162
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.26.1",
3
+ "version": "0.27.1",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -36,10 +36,10 @@
36
36
  "devDependencies": {
37
37
  "@cosmos-client/core": "0.45.13",
38
38
  "@types/big.js": "^6.0.0",
39
- "@xchainjs/xchain-client": "^0.13.1",
39
+ "@xchainjs/xchain-client": "^0.13.2",
40
40
  "@xchainjs/xchain-cosmos": "^0.20.0",
41
41
  "@xchainjs/xchain-crypto": "^0.2.6",
42
- "@xchainjs/xchain-util": "^0.10.0",
42
+ "@xchainjs/xchain-util": "^0.11.0",
43
43
  "axios": "^0.25.0",
44
44
  "bech32-buffer": "^0.2.0",
45
45
  "nock": "^13.0.5"
@@ -49,10 +49,10 @@
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@cosmos-client/core": "0.45.13",
52
- "@xchainjs/xchain-client": "^0.13.1",
52
+ "@xchainjs/xchain-client": "^0.13.2",
53
53
  "@xchainjs/xchain-cosmos": "^0.19.0",
54
54
  "@xchainjs/xchain-crypto": "^0.2.6",
55
- "@xchainjs/xchain-util": "^0.10.0",
55
+ "@xchainjs/xchain-util": "^0.11.0",
56
56
  "axios": "^0.25.0",
57
57
  "bech32-buffer": "^0.2.0"
58
58
  }