@xchainjs/xchain-thorchain 0.27.6 → 0.27.7

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/const.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { Asset, Chain } 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 = 100;
8
+ export declare const RUNE_SYMBOL = "\u16B1";
9
+ export declare const defaultExplorerUrls: ExplorerUrls;
10
+ /**
11
+ * Chain identifier for Thorchain
12
+ *
13
+ */
14
+ export declare const THORChain: Chain;
15
+ /**
16
+ * Base "chain" asset for RUNE-67C on Binance test net.
17
+ *
18
+ * Based on definition in Thorchain `common`
19
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
20
+ */
21
+ export declare const AssetRune67C: Asset;
22
+ /**
23
+ * Base "chain" asset for RUNE-B1A on Binance main net.
24
+ *
25
+ * Based on definition in Thorchain `common`
26
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
27
+ */
28
+ export declare const AssetRuneB1A: Asset;
29
+ /**
30
+ * Base "chain" asset on thorchain main net.
31
+ *
32
+ * Based on definition in Thorchain `common`
33
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
34
+ */
35
+ export declare const AssetRuneNative: Asset;
36
+ /**
37
+ * Base "chain" asset for RUNE on ethereum main net.
38
+ *
39
+ * Based on definition in Thorchain `common`
40
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
41
+ */
42
+ export declare const AssetRuneERC20: Asset;
43
+ /**
44
+ * Base "chain" asset for RUNE on ethereum main net.
45
+ *
46
+ * Based on definition in Thorchain `common`
47
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
48
+ */
49
+ export declare const AssetRuneERC20Testnet: Asset;
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './client';
2
2
  export * from './types';
3
- export * from './util';
3
+ export * from './utils';
4
+ export * from './const';
package/lib/index.esm.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import cosmosclient from '@cosmos-client/core';
2
- import { Network, TxType, singleFee, FeeType, BaseXChainClient } from '@xchainjs/xchain-client';
3
- import { CosmosSDKClient } from '@xchainjs/xchain-cosmos';
4
- import { isAssetRuneNative, isSynthAsset, assetToString, AssetRuneNative, assetFromString, baseAmount, assetToBase, assetAmount, Chain } from '@xchainjs/xchain-util';
2
+ import { Network as Network$1, TxType, singleFee, FeeType, BaseXChainClient } from '@xchainjs/xchain-client';
3
+ import { GAIAChain, CosmosSDKClient } from '@xchainjs/xchain-cosmos';
4
+ import { assetToString, isSynthAsset, assetFromString, baseAmount, assetToBase, assetAmount } from '@xchainjs/xchain-util';
5
5
  import axios from 'axios';
6
+ import { Network } from '@xchainjs/xchain-client/lib';
6
7
  import { decode } from 'bech32-buffer';
7
8
 
8
9
  /*! *****************************************************************************
@@ -4260,6 +4261,84 @@ Long.fromBytesBE = function fromBytesBE(bytes, unsigned) {
4260
4261
  );
4261
4262
  };
4262
4263
 
4264
+ const DEFAULT_EXPLORER_URL = 'https://viewblock.io/thorchain';
4265
+ const txUrl = `${DEFAULT_EXPLORER_URL}/tx`;
4266
+ const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
4267
+ const RUNE_TICKER = 'RUNE';
4268
+ const DECIMAL = 8;
4269
+ const DEFAULT_GAS_ADJUSTMENT = 2;
4270
+ const DEFAULT_GAS_LIMIT_VALUE = '4000000';
4271
+ const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
4272
+ const MAX_TX_COUNT = 100;
4273
+ const RUNE_SYMBOL = 'ᚱ';
4274
+ const defaultExplorerUrls = {
4275
+ root: {
4276
+ [Network.Testnet]: `${DEFAULT_EXPLORER_URL}?network=testnet`,
4277
+ [Network.Stagenet]: `${DEFAULT_EXPLORER_URL}?network=stagenet`,
4278
+ [Network.Mainnet]: DEFAULT_EXPLORER_URL,
4279
+ },
4280
+ tx: {
4281
+ [Network.Testnet]: txUrl,
4282
+ [Network.Stagenet]: txUrl,
4283
+ [Network.Mainnet]: txUrl,
4284
+ },
4285
+ address: {
4286
+ [Network.Testnet]: addressUrl,
4287
+ [Network.Stagenet]: addressUrl,
4288
+ [Network.Mainnet]: addressUrl,
4289
+ },
4290
+ };
4291
+ /**
4292
+ * Chain identifier for Thorchain
4293
+ *
4294
+ */
4295
+ const THORChain = 'THOR';
4296
+ /**
4297
+ * Base "chain" asset for RUNE-67C on Binance test net.
4298
+ *
4299
+ * Based on definition in Thorchain `common`
4300
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
4301
+ */
4302
+ const AssetRune67C = { chain: 'BNB', symbol: 'RUNE-67C', ticker: RUNE_TICKER, synth: false };
4303
+ /**
4304
+ * Base "chain" asset for RUNE-B1A on Binance main net.
4305
+ *
4306
+ * Based on definition in Thorchain `common`
4307
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
4308
+ */
4309
+ const AssetRuneB1A = { chain: 'BNB', symbol: 'RUNE-B1A', ticker: RUNE_TICKER, synth: false };
4310
+ /**
4311
+ * Base "chain" asset on thorchain main net.
4312
+ *
4313
+ * Based on definition in Thorchain `common`
4314
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
4315
+ */
4316
+ const AssetRuneNative = { chain: THORChain, symbol: RUNE_TICKER, ticker: RUNE_TICKER, synth: false };
4317
+ /**
4318
+ * Base "chain" asset for RUNE on ethereum main net.
4319
+ *
4320
+ * Based on definition in Thorchain `common`
4321
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
4322
+ */
4323
+ const AssetRuneERC20 = {
4324
+ chain: 'ETH',
4325
+ symbol: `${RUNE_TICKER}-0x3155ba85d5f96b2d030a4966af206230e46849cb`,
4326
+ ticker: RUNE_TICKER,
4327
+ synth: false,
4328
+ };
4329
+ /**
4330
+ * Base "chain" asset for RUNE on ethereum main net.
4331
+ *
4332
+ * Based on definition in Thorchain `common`
4333
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
4334
+ */
4335
+ const AssetRuneERC20Testnet = {
4336
+ chain: 'ETH',
4337
+ symbol: `${RUNE_TICKER}-0xd601c6A3a36721320573885A8d8420746dA3d7A0`,
4338
+ ticker: RUNE_TICKER,
4339
+ synth: false,
4340
+ };
4341
+
4263
4342
  var aspromise = asPromise;
4264
4343
 
4265
4344
  /**
@@ -9599,33 +9678,16 @@ $root.cosmos = (function() {
9599
9678
 
9600
9679
  var MsgCompiled = $root;
9601
9680
 
9602
- const DECIMAL = 8;
9603
- const DEFAULT_GAS_ADJUSTMENT = 2;
9604
- const DEFAULT_GAS_LIMIT_VALUE = '4000000';
9605
- const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
9606
- const MAX_TX_COUNT = 100;
9607
9681
  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
- };
9628
9682
  /**
9683
+ * Checks whether an asset is `AssetRuneNative`
9684
+ *
9685
+ * @param {Asset} asset
9686
+ * @returns {boolean} `true` or `false`
9687
+ */
9688
+ const isAssetRuneNative = (asset) => assetToString(asset) === assetToString(AssetRuneNative);
9689
+ /**
9690
+
9629
9691
  * Get denomination from Asset
9630
9692
  *
9631
9693
  * @param {Asset} asset
@@ -9668,11 +9730,11 @@ const isBroadcastSuccess = (response) => typeof response === 'object' &&
9668
9730
  **/
9669
9731
  const getPrefix = (network) => {
9670
9732
  switch (network) {
9671
- case Network.Mainnet:
9733
+ case Network$1.Mainnet:
9672
9734
  return 'thor';
9673
- case Network.Stagenet:
9735
+ case Network$1.Stagenet:
9674
9736
  return 'sthor';
9675
- case Network.Testnet:
9737
+ case Network$1.Testnet:
9676
9738
  return 'tthor';
9677
9739
  }
9678
9740
  };
@@ -9908,11 +9970,11 @@ const getExplorerUrl = ({ root }, network) => root[network];
9908
9970
  const getExplorerAddressUrl = ({ urls, network, address, }) => {
9909
9971
  const url = `${urls.address[network]}/${address}`;
9910
9972
  switch (network) {
9911
- case Network.Mainnet:
9973
+ case Network$1.Mainnet:
9912
9974
  return url;
9913
- case Network.Stagenet:
9975
+ case Network$1.Stagenet:
9914
9976
  return `${url}?network=stagenet`;
9915
- case Network.Testnet:
9977
+ case Network$1.Testnet:
9916
9978
  return `${url}?network=testnet`;
9917
9979
  }
9918
9980
  };
@@ -9927,11 +9989,11 @@ const getExplorerAddressUrl = ({ urls, network, address, }) => {
9927
9989
  const getExplorerTxUrl = ({ urls, network, txID, }) => {
9928
9990
  const url = `${urls.tx[network]}/${txID}`;
9929
9991
  switch (network) {
9930
- case Network.Mainnet:
9992
+ case Network$1.Mainnet:
9931
9993
  return url;
9932
- case Network.Stagenet:
9994
+ case Network$1.Stagenet:
9933
9995
  return `${url}?network=stagenet`;
9934
- case Network.Testnet:
9996
+ case Network$1.Testnet:
9935
9997
  return `${url}?network=testnet`;
9936
9998
  }
9937
9999
  };
@@ -9959,29 +10021,29 @@ class Client extends BaseXChainClient {
9959
10021
  *
9960
10022
  * @throws {"Invalid phrase"} Thrown if the given phase is invalid.
9961
10023
  */
9962
- constructor({ network = Network.Mainnet, phrase, clientUrl = {
9963
- [Network.Testnet]: {
10024
+ constructor({ network = Network$1.Mainnet, phrase, clientUrl = {
10025
+ [Network$1.Testnet]: {
9964
10026
  node: 'deprecated',
9965
10027
  rpc: 'deprecated',
9966
10028
  },
9967
- [Network.Stagenet]: {
10029
+ [Network$1.Stagenet]: {
9968
10030
  node: 'https://stagenet-thornode.ninerealms.com',
9969
10031
  rpc: 'https://stagenet-rpc.ninerealms.com',
9970
10032
  },
9971
- [Network.Mainnet]: {
10033
+ [Network$1.Mainnet]: {
9972
10034
  node: 'https://thornode.ninerealms.com',
9973
10035
  rpc: 'https://rpc.ninerealms.com',
9974
10036
  },
9975
10037
  }, explorerUrls = defaultExplorerUrls, rootDerivationPaths = {
9976
- [Network.Mainnet]: "44'/931'/0'/0/",
9977
- [Network.Stagenet]: "44'/931'/0'/0/",
9978
- [Network.Testnet]: "44'/931'/0'/0/",
10038
+ [Network$1.Mainnet]: "44'/931'/0'/0/",
10039
+ [Network$1.Stagenet]: "44'/931'/0'/0/",
10040
+ [Network$1.Testnet]: "44'/931'/0'/0/",
9979
10041
  }, chainIds = {
9980
- [Network.Mainnet]: 'thorchain-mainnet-v1',
9981
- [Network.Stagenet]: 'thorchain-stagenet-v2',
9982
- [Network.Testnet]: 'deprecated',
10042
+ [Network$1.Mainnet]: 'thorchain-mainnet-v1',
10043
+ [Network$1.Stagenet]: 'thorchain-stagenet-v2',
10044
+ [Network$1.Testnet]: 'deprecated',
9983
10045
  }, }) {
9984
- super(Chain.Cosmos, { network, rootDerivationPaths, phrase });
10046
+ super(GAIAChain, { network, rootDerivationPaths, phrase });
9985
10047
  /**
9986
10048
  * Get transaction history of a given address with pagination options.
9987
10049
  * By default it will return the transaction history of the current wallet.
@@ -10467,4 +10529,4 @@ const msgNativeTxFromJson = (value) => {
10467
10529
  return new MsgNativeTx(value.coins, value.memo, cosmosclient.AccAddress.fromString(value.signer));
10468
10530
  };
10469
10531
 
10470
- export { Client, DECIMAL, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, defaultExplorerUrls, getAccount, getBalance, getChainId, getDefaultFees, getDenom, getDepositTxDataFromLogs, getEstimatedGas, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getSequence, getTxType, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
10532
+ export { AssetRune67C, AssetRuneB1A, AssetRuneERC20, AssetRuneERC20Testnet, AssetRuneNative, Client, DECIMAL, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MAX_TX_COUNT, MsgNativeTx, RUNE_SYMBOL, THORChain, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, defaultExplorerUrls, getAccount, getBalance, getChainId, getDefaultFees, getDenom, getDepositTxDataFromLogs, getEstimatedGas, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getSequence, getTxType, isAssetRuneNative, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
package/lib/index.js CHANGED
@@ -7,6 +7,7 @@ var xchainClient = require('@xchainjs/xchain-client');
7
7
  var xchainCosmos = require('@xchainjs/xchain-cosmos');
8
8
  var xchainUtil = require('@xchainjs/xchain-util');
9
9
  var axios = require('axios');
10
+ var lib = require('@xchainjs/xchain-client/lib');
10
11
  var bech32Buffer = require('bech32-buffer');
11
12
 
12
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -4269,6 +4270,84 @@ Long.fromBytesBE = function fromBytesBE(bytes, unsigned) {
4269
4270
  );
4270
4271
  };
4271
4272
 
4273
+ const DEFAULT_EXPLORER_URL = 'https://viewblock.io/thorchain';
4274
+ const txUrl = `${DEFAULT_EXPLORER_URL}/tx`;
4275
+ const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
4276
+ const RUNE_TICKER = 'RUNE';
4277
+ const DECIMAL = 8;
4278
+ const DEFAULT_GAS_ADJUSTMENT = 2;
4279
+ const DEFAULT_GAS_LIMIT_VALUE = '4000000';
4280
+ const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
4281
+ const MAX_TX_COUNT = 100;
4282
+ const RUNE_SYMBOL = 'ᚱ';
4283
+ const defaultExplorerUrls = {
4284
+ root: {
4285
+ [lib.Network.Testnet]: `${DEFAULT_EXPLORER_URL}?network=testnet`,
4286
+ [lib.Network.Stagenet]: `${DEFAULT_EXPLORER_URL}?network=stagenet`,
4287
+ [lib.Network.Mainnet]: DEFAULT_EXPLORER_URL,
4288
+ },
4289
+ tx: {
4290
+ [lib.Network.Testnet]: txUrl,
4291
+ [lib.Network.Stagenet]: txUrl,
4292
+ [lib.Network.Mainnet]: txUrl,
4293
+ },
4294
+ address: {
4295
+ [lib.Network.Testnet]: addressUrl,
4296
+ [lib.Network.Stagenet]: addressUrl,
4297
+ [lib.Network.Mainnet]: addressUrl,
4298
+ },
4299
+ };
4300
+ /**
4301
+ * Chain identifier for Thorchain
4302
+ *
4303
+ */
4304
+ const THORChain = 'THOR';
4305
+ /**
4306
+ * Base "chain" asset for RUNE-67C on Binance test net.
4307
+ *
4308
+ * Based on definition in Thorchain `common`
4309
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
4310
+ */
4311
+ const AssetRune67C = { chain: 'BNB', symbol: 'RUNE-67C', ticker: RUNE_TICKER, synth: false };
4312
+ /**
4313
+ * Base "chain" asset for RUNE-B1A on Binance main net.
4314
+ *
4315
+ * Based on definition in Thorchain `common`
4316
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
4317
+ */
4318
+ const AssetRuneB1A = { chain: 'BNB', symbol: 'RUNE-B1A', ticker: RUNE_TICKER, synth: false };
4319
+ /**
4320
+ * Base "chain" asset on thorchain main net.
4321
+ *
4322
+ * Based on definition in Thorchain `common`
4323
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
4324
+ */
4325
+ const AssetRuneNative = { chain: THORChain, symbol: RUNE_TICKER, ticker: RUNE_TICKER, synth: false };
4326
+ /**
4327
+ * Base "chain" asset for RUNE on ethereum main net.
4328
+ *
4329
+ * Based on definition in Thorchain `common`
4330
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
4331
+ */
4332
+ const AssetRuneERC20 = {
4333
+ chain: 'ETH',
4334
+ symbol: `${RUNE_TICKER}-0x3155ba85d5f96b2d030a4966af206230e46849cb`,
4335
+ ticker: RUNE_TICKER,
4336
+ synth: false,
4337
+ };
4338
+ /**
4339
+ * Base "chain" asset for RUNE on ethereum main net.
4340
+ *
4341
+ * Based on definition in Thorchain `common`
4342
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
4343
+ */
4344
+ const AssetRuneERC20Testnet = {
4345
+ chain: 'ETH',
4346
+ symbol: `${RUNE_TICKER}-0xd601c6A3a36721320573885A8d8420746dA3d7A0`,
4347
+ ticker: RUNE_TICKER,
4348
+ synth: false,
4349
+ };
4350
+
4272
4351
  var aspromise = asPromise;
4273
4352
 
4274
4353
  /**
@@ -9608,40 +9687,23 @@ $root.cosmos = (function() {
9608
9687
 
9609
9688
  var MsgCompiled = $root;
9610
9689
 
9611
- const DECIMAL = 8;
9612
- const DEFAULT_GAS_ADJUSTMENT = 2;
9613
- const DEFAULT_GAS_LIMIT_VALUE = '4000000';
9614
- const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
9615
- const MAX_TX_COUNT = 100;
9616
9690
  const DENOM_RUNE_NATIVE = 'rune';
9617
- const DEFAULT_EXPLORER_URL = 'https://viewblock.io/thorchain';
9618
- const txUrl = `${DEFAULT_EXPLORER_URL}/tx`;
9619
- const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
9620
- const defaultExplorerUrls = {
9621
- root: {
9622
- [xchainClient.Network.Testnet]: `${DEFAULT_EXPLORER_URL}?network=testnet`,
9623
- [xchainClient.Network.Stagenet]: `${DEFAULT_EXPLORER_URL}?network=stagenet`,
9624
- [xchainClient.Network.Mainnet]: DEFAULT_EXPLORER_URL,
9625
- },
9626
- tx: {
9627
- [xchainClient.Network.Testnet]: txUrl,
9628
- [xchainClient.Network.Stagenet]: txUrl,
9629
- [xchainClient.Network.Mainnet]: txUrl,
9630
- },
9631
- address: {
9632
- [xchainClient.Network.Testnet]: addressUrl,
9633
- [xchainClient.Network.Stagenet]: addressUrl,
9634
- [xchainClient.Network.Mainnet]: addressUrl,
9635
- },
9636
- };
9637
9691
  /**
9692
+ * Checks whether an asset is `AssetRuneNative`
9693
+ *
9694
+ * @param {Asset} asset
9695
+ * @returns {boolean} `true` or `false`
9696
+ */
9697
+ const isAssetRuneNative = (asset) => xchainUtil.assetToString(asset) === xchainUtil.assetToString(AssetRuneNative);
9698
+ /**
9699
+
9638
9700
  * Get denomination from Asset
9639
9701
  *
9640
9702
  * @param {Asset} asset
9641
9703
  * @returns {string} The denomination of the given asset.
9642
9704
  */
9643
9705
  const getDenom = (asset) => {
9644
- if (xchainUtil.isAssetRuneNative(asset))
9706
+ if (isAssetRuneNative(asset))
9645
9707
  return DENOM_RUNE_NATIVE;
9646
9708
  if (xchainUtil.isSynthAsset(asset))
9647
9709
  return xchainUtil.assetToString(asset).toLowerCase();
@@ -9655,7 +9717,7 @@ const getDenom = (asset) => {
9655
9717
  */
9656
9718
  const assetFromDenom = (denom) => {
9657
9719
  if (denom === DENOM_RUNE_NATIVE)
9658
- return xchainUtil.AssetRuneNative;
9720
+ return AssetRuneNative;
9659
9721
  return xchainUtil.assetFromString(denom.toUpperCase());
9660
9722
  };
9661
9723
  /**
@@ -9893,7 +9955,7 @@ const getBalance = ({ address, assets, cosmosClient, }) => __awaiter(void 0, voi
9893
9955
  const balances = yield cosmosClient.getBalance(address);
9894
9956
  return balances
9895
9957
  .map((balance) => ({
9896
- asset: (balance.denom && assetFromDenom(balance.denom)) || xchainUtil.AssetRuneNative,
9958
+ asset: (balance.denom && assetFromDenom(balance.denom)) || AssetRuneNative,
9897
9959
  amount: xchainUtil.baseAmount(balance.amount, DECIMAL),
9898
9960
  }))
9899
9961
  .filter((balance) => !assets || assets.filter((asset) => xchainUtil.assetToString(balance.asset) === xchainUtil.assetToString(asset)).length);
@@ -9990,7 +10052,7 @@ class Client extends xchainClient.BaseXChainClient {
9990
10052
  [xchainClient.Network.Stagenet]: 'thorchain-stagenet-v2',
9991
10053
  [xchainClient.Network.Testnet]: 'deprecated',
9992
10054
  }, }) {
9993
- super(xchainUtil.Chain.Cosmos, { network, rootDerivationPaths, phrase });
10055
+ super(xchainCosmos.GAIAChain, { network, rootDerivationPaths, phrase });
9994
10056
  /**
9995
10057
  * Get transaction history of a given address with pagination options.
9996
10058
  * By default it will return the transaction history of the current wallet.
@@ -10229,7 +10291,7 @@ class Client extends xchainClient.BaseXChainClient {
10229
10291
  const { from, to, type } = txData;
10230
10292
  return {
10231
10293
  hash: txId,
10232
- asset: xchainUtil.AssetRuneNative,
10294
+ asset: AssetRuneNative,
10233
10295
  from,
10234
10296
  to,
10235
10297
  date: new Date(txResult.timestamp),
@@ -10265,7 +10327,7 @@ class Client extends xchainClient.BaseXChainClient {
10265
10327
  asset = xchainUtil.assetFromString(coin.asset);
10266
10328
  });
10267
10329
  return {
10268
- asset: asset || xchainUtil.AssetRuneNative,
10330
+ asset: asset || AssetRuneNative,
10269
10331
  from,
10270
10332
  to,
10271
10333
  type: xchainClient.TxType.Transfer,
@@ -10282,14 +10344,14 @@ class Client extends xchainClient.BaseXChainClient {
10282
10344
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
10283
10345
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
10284
10346
  */
10285
- deposit({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), sequence, }) {
10347
+ deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), sequence, }) {
10286
10348
  var _a, _b, _c, _d;
10287
10349
  return __awaiter(this, void 0, void 0, function* () {
10288
10350
  const balances = yield this.getBalance(this.getAddress(walletIndex));
10289
- const runeBalance = (_b = (_a = balances.filter(({ asset }) => xchainUtil.isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : xchainUtil.baseAmount(0, DECIMAL);
10351
+ const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : xchainUtil.baseAmount(0, DECIMAL);
10290
10352
  const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => xchainUtil.assetToString(assetInList) === xchainUtil.assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : xchainUtil.baseAmount(0, DECIMAL);
10291
10353
  const { average: fee } = yield this.getFees();
10292
- if (xchainUtil.isAssetRuneNative(asset)) {
10354
+ if (isAssetRuneNative(asset)) {
10293
10355
  // amount + fee < runeBalance
10294
10356
  if (runeBalance.lt(amount.plus(fee))) {
10295
10357
  throw new Error('insufficient funds');
@@ -10345,14 +10407,14 @@ class Client extends xchainClient.BaseXChainClient {
10345
10407
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
10346
10408
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
10347
10409
  */
10348
- transfer({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
10410
+ transfer({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
10349
10411
  var _a, _b, _c, _d;
10350
10412
  return __awaiter(this, void 0, void 0, function* () {
10351
10413
  const balances = yield this.getBalance(this.getAddress(walletIndex));
10352
- const runeBalance = (_b = (_a = balances.filter(({ asset }) => xchainUtil.isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : xchainUtil.baseAmount(0, DECIMAL);
10414
+ const runeBalance = (_b = (_a = balances.filter(({ asset }) => isAssetRuneNative(asset))[0]) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : xchainUtil.baseAmount(0, DECIMAL);
10353
10415
  const assetBalance = (_d = (_c = balances.filter(({ asset: assetInList }) => xchainUtil.assetToString(assetInList) === xchainUtil.assetToString(asset))[0]) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : xchainUtil.baseAmount(0, DECIMAL);
10354
10416
  const fee = (yield this.getFees()).average;
10355
- if (xchainUtil.isAssetRuneNative(asset)) {
10417
+ if (isAssetRuneNative(asset)) {
10356
10418
  // amount + fee < runeBalance
10357
10419
  if (runeBalance.lt(amount.plus(fee))) {
10358
10420
  throw new Error('insufficient funds');
@@ -10401,10 +10463,10 @@ class Client extends xchainClient.BaseXChainClient {
10401
10463
  * @param {TxOfflineParams} params The transfer offline options.
10402
10464
  * @returns {string} The signed transaction bytes.
10403
10465
  */
10404
- transferOffline({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo, fromRuneBalance: from_rune_balance, fromAssetBalance: from_asset_balance = xchainUtil.baseAmount(0, DECIMAL), fromAccountNumber = long_1.ZERO, fromSequence = long_1.ZERO, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), }) {
10466
+ transferOffline({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, fromRuneBalance: from_rune_balance, fromAssetBalance: from_asset_balance = xchainUtil.baseAmount(0, DECIMAL), fromAccountNumber = long_1.ZERO, fromSequence = long_1.ZERO, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), }) {
10405
10467
  return __awaiter(this, void 0, void 0, function* () {
10406
10468
  const fee = (yield this.getFees()).average;
10407
- if (xchainUtil.isAssetRuneNative(asset)) {
10469
+ if (isAssetRuneNative(asset)) {
10408
10470
  // amount + fee < runeBalance
10409
10471
  if (from_rune_balance.lt(amount.plus(fee))) {
10410
10472
  throw new Error('insufficient funds');
@@ -10476,6 +10538,11 @@ const msgNativeTxFromJson = (value) => {
10476
10538
  return new MsgNativeTx(value.coins, value.memo, cosmosclient__default['default'].AccAddress.fromString(value.signer));
10477
10539
  };
10478
10540
 
10541
+ exports.AssetRune67C = AssetRune67C;
10542
+ exports.AssetRuneB1A = AssetRuneB1A;
10543
+ exports.AssetRuneERC20 = AssetRuneERC20;
10544
+ exports.AssetRuneERC20Testnet = AssetRuneERC20Testnet;
10545
+ exports.AssetRuneNative = AssetRuneNative;
10479
10546
  exports.Client = Client;
10480
10547
  exports.DECIMAL = DECIMAL;
10481
10548
  exports.DEFAULT_GAS_ADJUSTMENT = DEFAULT_GAS_ADJUSTMENT;
@@ -10483,6 +10550,8 @@ exports.DEFAULT_GAS_LIMIT_VALUE = DEFAULT_GAS_LIMIT_VALUE;
10483
10550
  exports.DEPOSIT_GAS_LIMIT_VALUE = DEPOSIT_GAS_LIMIT_VALUE;
10484
10551
  exports.MAX_TX_COUNT = MAX_TX_COUNT;
10485
10552
  exports.MsgNativeTx = MsgNativeTx;
10553
+ exports.RUNE_SYMBOL = RUNE_SYMBOL;
10554
+ exports.THORChain = THORChain;
10486
10555
  exports.assetFromDenom = assetFromDenom;
10487
10556
  exports.buildDepositTx = buildDepositTx;
10488
10557
  exports.buildTransferTx = buildTransferTx;
@@ -10501,6 +10570,7 @@ exports.getExplorerUrl = getExplorerUrl;
10501
10570
  exports.getPrefix = getPrefix;
10502
10571
  exports.getSequence = getSequence;
10503
10572
  exports.getTxType = getTxType;
10573
+ exports.isAssetRuneNative = isAssetRuneNative;
10504
10574
  exports.isBroadcastSuccess = isBroadcastSuccess;
10505
10575
  exports.msgNativeTxFromJson = msgNativeTxFromJson;
10506
10576
  exports.registerDepositCodecs = registerDepositCodecs;
@@ -5,13 +5,15 @@ import { Address, Asset, BaseAmount } from '@xchainjs/xchain-util';
5
5
  import Long from 'long';
6
6
  import { ChainId, ExplorerUrls, TxData } from './types';
7
7
  import { MsgNativeTx } from './types/messages';
8
- export declare const DECIMAL = 8;
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";
12
- export declare const MAX_TX_COUNT = 100;
13
- export declare const defaultExplorerUrls: ExplorerUrls;
14
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
+
15
17
  * Get denomination from Asset
16
18
  *
17
19
  * @param {Asset} asset
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.27.6",
3
+ "version": "0.27.7",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -36,10 +36,12 @@
36
36
  "devDependencies": {
37
37
  "@cosmos-client/core": "0.46.1",
38
38
  "@types/big.js": "^6.0.0",
39
- "@xchainjs/xchain-client": "^0.13.3",
40
- "@xchainjs/xchain-cosmos": "^0.20.5",
39
+ "@xchainjs/xchain-binance": "^5.6.6",
40
+ "@xchainjs/xchain-client": "^0.13.5",
41
+ "@xchainjs/xchain-cosmos": "^0.20.6",
41
42
  "@xchainjs/xchain-crypto": "^0.2.6",
42
- "@xchainjs/xchain-util": "^0.11.0",
43
+ "@xchainjs/xchain-ethereum": "^0.27.6",
44
+ "@xchainjs/xchain-util": "^0.12.0",
43
45
  "axios": "^0.25.0",
44
46
  "bech32-buffer": "^0.2.0",
45
47
  "nock": "^13.0.5"
@@ -49,10 +51,10 @@
49
51
  },
50
52
  "peerDependencies": {
51
53
  "@cosmos-client/core": "0.46.1",
52
- "@xchainjs/xchain-client": "^0.13.3",
53
- "@xchainjs/xchain-cosmos": "^0.20.5",
54
+ "@xchainjs/xchain-client": "^0.13.5",
55
+ "@xchainjs/xchain-cosmos": "^0.20.6",
54
56
  "@xchainjs/xchain-crypto": "^0.2.6",
55
- "@xchainjs/xchain-util": "^0.11.0",
57
+ "@xchainjs/xchain-util": "^0.12.0",
56
58
  "axios": "^0.25.0",
57
59
  "bech32-buffer": "^0.2.0"
58
60
  }