@xchainjs/xchain-doge 0.2.0 → 0.2.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.js CHANGED
@@ -9,7 +9,7 @@ var stream = require('stream');
9
9
  var string_decoder$1 = require('string_decoder');
10
10
  var crypto$1$1 = require('crypto');
11
11
  var readableStream = require('readable-stream');
12
- var axios = require('axios');
12
+ var axios$1 = require('axios');
13
13
 
14
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
15
 
@@ -19,7 +19,7 @@ var stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
19
19
  var string_decoder$1__default = /*#__PURE__*/_interopDefaultLegacy(string_decoder$1);
20
20
  var crypto$1__default = /*#__PURE__*/_interopDefaultLegacy(crypto$1$1);
21
21
  var readableStream__default = /*#__PURE__*/_interopDefaultLegacy(readableStream);
22
- var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
22
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios$1);
23
23
 
24
24
  /*! *****************************************************************************
25
25
  Copyright (c) Microsoft Corporation.
@@ -61872,7 +61872,7 @@ var sha256$2 = createCommonjsModule(function (module, exports) {
61872
61872
  * @param {string} phrase
61873
61873
  * @returns {boolean} `true` or `false`
61874
61874
  */
61875
- var validatePhrase = function (phrase) {
61875
+ const validatePhrase = (phrase) => {
61876
61876
  return src_6(phrase);
61877
61877
  };
61878
61878
  /**
@@ -61883,7 +61883,7 @@ var validatePhrase = function (phrase) {
61883
61883
  *
61884
61884
  * @throws {"Invalid BIP39 phrase"} Thrown if phrase is an invalid one.
61885
61885
  */
61886
- var getSeed = function (phrase) {
61886
+ const getSeed = (phrase) => {
61887
61887
  if (!validatePhrase(phrase)) {
61888
61888
  throw new Error('Invalid BIP39 phrase');
61889
61889
  }
@@ -64810,14 +64810,14 @@ var bignumber$1 = createCommonjsModule$1(function (module) {
64810
64810
  * @param {string | number | BigNumber.Instance} value
64811
64811
  * @returns {BigNumber} The BigNumber interface from the given value.
64812
64812
  */
64813
- var bn$1 = function (value) { return new bignumber$1(value); };
64813
+ const bn$1 = (value) => new bignumber$1(value);
64814
64814
  /**
64815
64815
  * Helper to check whether a BigNumber is valid or not
64816
64816
  *
64817
64817
  * @param {BigNumber} value
64818
64818
  * @returns {boolean} `true` or `false`.
64819
64819
  * */
64820
- var isValidBN = function (value) { return !value.isNaN(); };
64820
+ const isValidBN = (value) => !value.isNaN();
64821
64821
  /**
64822
64822
  * The enumuration for symbol position.
64823
64823
  * `before` or `after`
@@ -64835,14 +64835,12 @@ var SymbolPosition;
64835
64835
  * @param {number} decimalPlaces The decimal place. (optional)
64836
64836
  * @returns {BigNumber} The BigNumber interface from the given value and decimal.
64837
64837
  * */
64838
- var fixedBN = function (value, decimalPlaces) {
64839
- if (decimalPlaces === void 0) { decimalPlaces = 2; }
64840
- var n = bn$1(value || 0);
64841
- var fixedBN = isValidBN(n) ? n.toFixed(decimalPlaces) : bn$1(0).toFixed(decimalPlaces);
64838
+ const fixedBN = (value, decimalPlaces = 2) => {
64839
+ const n = bn$1(value || 0);
64840
+ const fixedBN = isValidBN(n) ? n.toFixed(decimalPlaces) : bn$1(0).toFixed(decimalPlaces);
64842
64841
  return bn$1(fixedBN);
64843
64842
  };
64844
64843
 
64845
- var _a;
64846
64844
  var Chain;
64847
64845
  (function (Chain) {
64848
64846
  Chain["Binance"] = "BNB";
@@ -64856,38 +64854,38 @@ var Chain;
64856
64854
  Chain["Terra"] = "TERRA";
64857
64855
  Chain["Doge"] = "DOGE";
64858
64856
  })(Chain || (Chain = {}));
64859
- var BNBChain = Chain.Binance;
64860
- var BTCChain = Chain.Bitcoin;
64861
- var ETHChain = Chain.Ethereum;
64862
- var THORChain = Chain.THORChain;
64863
- var CosmosChain = Chain.Cosmos;
64864
- var PolkadotChain = Chain.Polkadot;
64865
- var BCHChain = Chain.BitcoinCash;
64866
- var LTCChain = Chain.Litecoin;
64867
- var LUNAChain = Chain.Terra;
64868
- var DOGEChain = Chain.Doge;
64857
+ const BNBChain = Chain.Binance;
64858
+ const BTCChain = Chain.Bitcoin;
64859
+ const ETHChain = Chain.Ethereum;
64860
+ const THORChain = Chain.THORChain;
64861
+ const CosmosChain = Chain.Cosmos;
64862
+ const PolkadotChain = Chain.Polkadot;
64863
+ const BCHChain = Chain.BitcoinCash;
64864
+ const LTCChain = Chain.Litecoin;
64865
+ const TerraChain = Chain.Terra;
64866
+ const DOGEChain = Chain.Doge;
64869
64867
  /**
64870
64868
  * Convert chain to string.
64871
64869
  *
64872
64870
  * @param {Chain} chainId.
64873
64871
  * @returns {string} The string based on the given chain type.
64874
64872
  */
64875
- var chainToString = Object.assign(function (chainId) {
64873
+ const chainToString = Object.assign((chainId) => {
64876
64874
  if (!(chainId in chainToString))
64877
64875
  return 'unknown chain';
64878
64876
  return chainToString[chainId];
64879
- }, (_a = {},
64880
- _a[Chain.THORChain] = 'Thorchain',
64881
- _a[Chain.Bitcoin] = 'Bitcoin',
64882
- _a[Chain.BitcoinCash] = 'Bitcoin Cash',
64883
- _a[Chain.Litecoin] = 'Litecoin',
64884
- _a[Chain.Ethereum] = 'Ethereum',
64885
- _a[Chain.Binance] = 'Binance Chain',
64886
- _a[Chain.Cosmos] = 'Cosmos',
64887
- _a[Chain.Polkadot] = 'Polkadot',
64888
- _a[Chain.Terra] = 'Terra',
64889
- _a[Chain.Doge] = 'Dogecoin',
64890
- _a));
64877
+ }, {
64878
+ [Chain.THORChain]: 'Thorchain',
64879
+ [Chain.Bitcoin]: 'Bitcoin',
64880
+ [Chain.BitcoinCash]: 'Bitcoin Cash',
64881
+ [Chain.Litecoin]: 'Litecoin',
64882
+ [Chain.Ethereum]: 'Ethereum',
64883
+ [Chain.Binance]: 'Binance Chain',
64884
+ [Chain.Cosmos]: 'Cosmos',
64885
+ [Chain.Polkadot]: 'Polkadot',
64886
+ [Chain.Terra]: 'Terra',
64887
+ [Chain.Doge]: 'Dogecoin',
64888
+ });
64891
64889
 
64892
64890
  var Denomination;
64893
64891
  (function (Denomination) {
@@ -64907,9 +64905,7 @@ var Denomination;
64907
64905
  * @param {unknown} v
64908
64906
  * @returns {boolean} `true` or `false`.
64909
64907
  * */
64910
- var isBigNumberValue = function (v) {
64911
- return typeof v === 'string' || typeof v === 'number' || v instanceof bignumber$1;
64912
- };
64908
+ const isBigNumberValue = (v) => typeof v === 'string' || typeof v === 'number' || v instanceof bignumber$1;
64913
64909
  /**
64914
64910
  * Default number of asset decimals
64915
64911
  * For history reason and by starting the project on Binance chain assets, it's 8 decimal.
@@ -64920,7 +64916,7 @@ var isBigNumberValue = function (v) {
64920
64916
  * 0.00000001 RUNE == 1 ð (tor)
64921
64917
  * ```
64922
64918
  * */
64923
- var ASSET_DECIMAL = 8;
64919
+ const ASSET_DECIMAL = 8;
64924
64920
  /**
64925
64921
  * Factory to create values of assets (e.g. RUNE)
64926
64922
  *
@@ -64929,34 +64925,21 @@ var ASSET_DECIMAL = 8;
64929
64925
  * @returns {AssetAmount} The asset amount from the given value and decimal.
64930
64926
  *
64931
64927
  **/
64932
- var assetAmount = function (value, decimal) {
64933
- if (decimal === void 0) { decimal = ASSET_DECIMAL; }
64934
- var amount = fixedBN(value, decimal);
64928
+ const assetAmount = (value, decimal = ASSET_DECIMAL) => {
64929
+ const amount = fixedBN(value, decimal);
64935
64930
  return {
64936
64931
  type: Denomination.Asset,
64937
- amount: function () { return amount; },
64938
- plus: function (v, d) {
64939
- if (d === void 0) { d = decimal; }
64940
- return assetAmount(amount.plus(isBigNumberValue(v) ? v : v.amount()), d);
64941
- },
64942
- minus: function (v, d) {
64943
- if (d === void 0) { d = decimal; }
64944
- return assetAmount(amount.minus(isBigNumberValue(v) ? v : v.amount()), d);
64945
- },
64946
- times: function (v, d) {
64947
- if (d === void 0) { d = decimal; }
64948
- return assetAmount(amount.times(isBigNumberValue(v) ? v : v.amount()), d);
64949
- },
64950
- div: function (v, d) {
64951
- if (d === void 0) { d = decimal; }
64952
- return assetAmount(amount.div(isBigNumberValue(v) ? v : v.amount()), d);
64953
- },
64954
- lt: function (v) { return amount.lt(isBigNumberValue(v) ? v : v.amount()); },
64955
- lte: function (v) { return amount.lte(isBigNumberValue(v) ? v : v.amount()); },
64956
- gt: function (v) { return amount.gt(isBigNumberValue(v) ? v : v.amount()); },
64957
- gte: function (v) { return amount.gte(isBigNumberValue(v) ? v : v.amount()); },
64958
- eq: function (v) { return amount.eq(isBigNumberValue(v) ? v : v.amount()); },
64959
- decimal: decimal,
64932
+ amount: () => amount,
64933
+ plus: (v, d = decimal) => assetAmount(amount.plus(isBigNumberValue(v) ? v : v.amount()), d),
64934
+ minus: (v, d = decimal) => assetAmount(amount.minus(isBigNumberValue(v) ? v : v.amount()), d),
64935
+ times: (v, d = decimal) => assetAmount(amount.times(isBigNumberValue(v) ? v : v.amount()), d),
64936
+ div: (v, d = decimal) => assetAmount(amount.div(isBigNumberValue(v) ? v : v.amount()), d),
64937
+ lt: (v) => amount.lt(isBigNumberValue(v) ? v : v.amount()),
64938
+ lte: (v) => amount.lte(isBigNumberValue(v) ? v : v.amount()),
64939
+ gt: (v) => amount.gt(isBigNumberValue(v) ? v : v.amount()),
64940
+ gte: (v) => amount.gte(isBigNumberValue(v) ? v : v.amount()),
64941
+ eq: (v) => amount.eq(isBigNumberValue(v) ? v : v.amount()),
64942
+ decimal,
64960
64943
  };
64961
64944
  };
64962
64945
  /**
@@ -64966,34 +64949,21 @@ var assetAmount = function (value, decimal) {
64966
64949
  * @param {number} decimal The decimal places of its associated AssetAmount. (optional)
64967
64950
  * @returns {BaseAmount} The base amount from the given value and decimal.
64968
64951
  **/
64969
- var baseAmount = function (value, decimal) {
64970
- if (decimal === void 0) { decimal = ASSET_DECIMAL; }
64971
- var amount = fixedBN(value, 0);
64952
+ const baseAmount = (value, decimal = ASSET_DECIMAL) => {
64953
+ const amount = fixedBN(value, 0);
64972
64954
  return {
64973
64955
  type: Denomination.Base,
64974
- amount: function () { return amount; },
64975
- plus: function (v, d) {
64976
- if (d === void 0) { d = decimal; }
64977
- return baseAmount(amount.plus(isBigNumberValue(v) ? v : v.amount()), d);
64978
- },
64979
- minus: function (v, d) {
64980
- if (d === void 0) { d = decimal; }
64981
- return baseAmount(amount.minus(isBigNumberValue(v) ? v : v.amount()), d);
64982
- },
64983
- times: function (v, d) {
64984
- if (d === void 0) { d = decimal; }
64985
- return baseAmount(amount.times(isBigNumberValue(v) ? v : v.amount()), d);
64986
- },
64987
- div: function (v, d) {
64988
- if (d === void 0) { d = decimal; }
64989
- return baseAmount(amount.div(isBigNumberValue(v) ? v : v.amount()).decimalPlaces(0, bignumber$1.ROUND_DOWN), d);
64990
- },
64991
- lt: function (v) { return amount.lt(isBigNumberValue(v) ? v : v.amount()); },
64992
- lte: function (v) { return amount.lte(isBigNumberValue(v) ? v : v.amount()); },
64993
- gt: function (v) { return amount.gt(isBigNumberValue(v) ? v : v.amount()); },
64994
- gte: function (v) { return amount.gte(isBigNumberValue(v) ? v : v.amount()); },
64995
- eq: function (v) { return amount.eq(isBigNumberValue(v) ? v : v.amount()); },
64996
- decimal: decimal,
64956
+ amount: () => amount,
64957
+ plus: (v, d = decimal) => baseAmount(amount.plus(isBigNumberValue(v) ? v : v.amount()), d),
64958
+ minus: (v, d = decimal) => baseAmount(amount.minus(isBigNumberValue(v) ? v : v.amount()), d),
64959
+ times: (v, d = decimal) => baseAmount(amount.times(isBigNumberValue(v) ? v : v.amount()), d),
64960
+ div: (v, d = decimal) => baseAmount(amount.div(isBigNumberValue(v) ? v : v.amount()).decimalPlaces(0, bignumber$1.ROUND_DOWN), d),
64961
+ lt: (v) => amount.lt(isBigNumberValue(v) ? v : v.amount()),
64962
+ lte: (v) => amount.lte(isBigNumberValue(v) ? v : v.amount()),
64963
+ gt: (v) => amount.gt(isBigNumberValue(v) ? v : v.amount()),
64964
+ gte: (v) => amount.gte(isBigNumberValue(v) ? v : v.amount()),
64965
+ eq: (v) => amount.eq(isBigNumberValue(v) ? v : v.amount()),
64966
+ decimal,
64997
64967
  };
64998
64968
  };
64999
64969
  /**
@@ -65002,8 +64972,8 @@ var baseAmount = function (value, decimal) {
65002
64972
  * @param {AssetAmount} asset
65003
64973
  * @returns {BaseAmount} The base amount from the given AssetAmount.
65004
64974
  * */
65005
- var assetToBase = function (asset) {
65006
- var value = asset
64975
+ const assetToBase = (asset) => {
64976
+ const value = asset
65007
64977
  .amount()
65008
64978
  .multipliedBy(Math.pow(10, asset.decimal))
65009
64979
  .integerValue();
@@ -65015,78 +64985,72 @@ var assetToBase = function (asset) {
65015
64985
  * Based on definition in Thorchain `common`
65016
64986
  * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
65017
64987
  */
65018
- var AssetBNB = { chain: Chain.Binance, symbol: 'BNB', ticker: 'BNB', synth: false };
64988
+ const AssetBNB = { chain: Chain.Binance, symbol: 'BNB', ticker: 'BNB', synth: false };
65019
64989
  /**
65020
64990
  * Base "chain" asset on bitcoin main net.
65021
64991
  *
65022
64992
  * Based on definition in Thorchain `common`
65023
64993
  * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
65024
64994
  */
65025
- var AssetBTC = { chain: Chain.Bitcoin, symbol: 'BTC', ticker: 'BTC', synth: false };
64995
+ const AssetBTC = { chain: Chain.Bitcoin, symbol: 'BTC', ticker: 'BTC', synth: false };
65026
64996
  /**
65027
64997
  * Base "chain" asset on bitcoin cash main net.
65028
64998
  *
65029
64999
  * Based on definition in Thorchain `common`
65030
65000
  * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
65031
65001
  */
65032
- var AssetBCH = { chain: Chain.BitcoinCash, symbol: 'BCH', ticker: 'BCH', synth: false };
65002
+ const AssetBCH = { chain: Chain.BitcoinCash, symbol: 'BCH', ticker: 'BCH', synth: false };
65033
65003
  /**
65034
65004
  * Base "chain" asset on litecoin main net.
65035
65005
  *
65036
65006
  * Based on definition in Thorchain `common`
65037
65007
  * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
65038
65008
  */
65039
- var AssetLTC = { chain: Chain.Litecoin, symbol: 'LTC', ticker: 'LTC', synth: false };
65009
+ const AssetLTC = { chain: Chain.Litecoin, symbol: 'LTC', ticker: 'LTC', synth: false };
65040
65010
  /**
65041
65011
  * Dogecoin asset
65042
65012
  * Based on definition in Thorchain
65043
65013
  * @see https://gitlab.com/thorchain/thornode/-/blob/781-add-doge-chain/common/asset.go#L24
65044
65014
  */
65045
- var AssetDOGE = { chain: Chain.Doge, symbol: 'DOGE', ticker: 'DOGE', synth: false };
65046
- /**
65047
- * Luna asset
65048
- * Based on definition in Thorchain
65049
- * @see TBD
65050
- */
65051
- var AssetLUNA = { chain: Chain.Terra, symbol: 'LUNA', ticker: 'LUNA', synth: false };
65052
- var RUNE_TICKER = 'RUNE';
65015
+ const AssetDOGE = { chain: Chain.Doge, symbol: 'DOGE', ticker: 'DOGE', synth: false };
65016
+ const RUNE_TICKER = 'RUNE';
65053
65017
  /**
65054
65018
  * Base "chain" asset on ethereum main net.
65055
65019
  *
65056
65020
  * Based on definition in Thorchain `common`
65057
65021
  * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
65058
65022
  */
65059
- var AssetETH = { chain: Chain.Ethereum, symbol: 'ETH', ticker: 'ETH', synth: false };
65023
+ const AssetETH = { chain: Chain.Ethereum, symbol: 'ETH', ticker: 'ETH', synth: false };
65060
65024
  /**
65061
65025
  * Base "chain" asset for RUNE-67C on Binance test net.
65062
65026
  *
65063
65027
  * Based on definition in Thorchain `common`
65064
65028
  * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
65065
65029
  */
65066
- var AssetRune67C = { chain: Chain.Binance, symbol: 'RUNE-67C', ticker: RUNE_TICKER, synth: false };
65030
+ const AssetRune67C = { chain: Chain.Binance, symbol: 'RUNE-67C', ticker: RUNE_TICKER, synth: false };
65067
65031
  /**
65068
65032
  * Base "chain" asset for RUNE-B1A on Binance main net.
65069
65033
  *
65070
65034
  * Based on definition in Thorchain `common`
65071
65035
  * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
65072
65036
  */
65073
- var AssetRuneB1A = { chain: Chain.Binance, symbol: 'RUNE-B1A', ticker: RUNE_TICKER, synth: false };
65037
+ const AssetRuneB1A = { chain: Chain.Binance, symbol: 'RUNE-B1A', ticker: RUNE_TICKER, synth: false };
65074
65038
  /**
65075
65039
  * Base "chain" asset on thorchain main net.
65076
65040
  *
65077
65041
  * Based on definition in Thorchain `common`
65078
65042
  * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
65079
65043
  */
65080
- var AssetRuneNative = { chain: Chain.THORChain, symbol: RUNE_TICKER, ticker: RUNE_TICKER, synth: false };
65044
+ const AssetRuneNative = { chain: Chain.THORChain, symbol: RUNE_TICKER, ticker: RUNE_TICKER, synth: false };
65081
65045
  /**
65082
65046
  * Base "chain" asset for RUNE on ethereum main net.
65083
65047
  *
65084
65048
  * Based on definition in Thorchain `common`
65085
65049
  * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
65086
65050
  */
65087
- var AssetRuneERC20 = {
65051
+ const AssetRuneERC20 = {
65088
65052
  chain: Chain.Ethereum,
65089
- symbol: RUNE_TICKER + "-0x3155ba85d5f96b2d030a4966af206230e46849cb",
65053
+ symbol: `${RUNE_TICKER}-0x3155ba85d5f96b2d030a4966af206230e46849cb`,
65090
65054
  ticker: RUNE_TICKER,
65091
65055
  synth: false,
65092
65056
  };
@@ -65096,12 +65060,33 @@ var AssetRuneERC20 = {
65096
65060
  * Based on definition in Thorchain `common`
65097
65061
  * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
65098
65062
  */
65099
- var AssetRuneERC20Testnet = {
65063
+ const AssetRuneERC20Testnet = {
65100
65064
  chain: Chain.Ethereum,
65101
- symbol: RUNE_TICKER + "-0xd601c6A3a36721320573885A8d8420746dA3d7A0",
65065
+ symbol: `${RUNE_TICKER}-0xd601c6A3a36721320573885A8d8420746dA3d7A0`,
65102
65066
  ticker: RUNE_TICKER,
65103
65067
  synth: false,
65104
65068
  };
65069
+ const SYNTH_DELIMITER = '/';
65070
+ const NON_SYNTH_DELIMITER = '.';
65071
+ /**
65072
+ * Returns an `Asset` as a string using following naming convention:
65073
+ *
65074
+ * `AAA.BBB-CCC`
65075
+ * where
65076
+ * chain: `AAA`
65077
+ * ticker (optional): `BBB`
65078
+ * symbol: `BBB-CCC` or `CCC` (if no ticker available)
65079
+ * symbol (synth): `BBB/CCC` or `CCC` (if no ticker available)
65080
+ *
65081
+ * @see https://docs.thorchain.org/developers/transaction-memos#asset-notation
65082
+ *
65083
+ * @param {Asset} asset The given asset.
65084
+ * @returns {string} The string from the given asset.
65085
+ */
65086
+ const assetToString = ({ chain, symbol, synth }) => {
65087
+ const delimiter = synth ? SYNTH_DELIMITER : NON_SYNTH_DELIMITER;
65088
+ return `${chain}${delimiter}${symbol}`;
65089
+ };
65105
65090
  /**
65106
65091
  * Currency symbols currently supported
65107
65092
  */
@@ -65112,7 +65097,77 @@ var AssetCurrencySymbol;
65112
65097
  AssetCurrencySymbol["SATOSHI"] = "\u26A1";
65113
65098
  AssetCurrencySymbol["ETH"] = "\u039E";
65114
65099
  AssetCurrencySymbol["USD"] = "$";
65115
- })(AssetCurrencySymbol || (AssetCurrencySymbol = {}));
65100
+ })(AssetCurrencySymbol || (AssetCurrencySymbol = {}));
65101
+
65102
+ /*! *****************************************************************************
65103
+ Copyright (c) Microsoft Corporation.
65104
+
65105
+ Permission to use, copy, modify, and/or distribute this software for any
65106
+ purpose with or without fee is hereby granted.
65107
+
65108
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
65109
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
65110
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
65111
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
65112
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
65113
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65114
+ PERFORMANCE OF THIS SOFTWARE.
65115
+ ***************************************************************************** */
65116
+
65117
+ function __awaiter$1(thisArg, _arguments, P, generator) {
65118
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
65119
+ return new (P || (P = Promise))(function (resolve, reject) {
65120
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
65121
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
65122
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
65123
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
65124
+ });
65125
+ }
65126
+
65127
+ const axios = require('axios');
65128
+ const midgardBaseUrls = {
65129
+ [xchainClient.Network.Testnet]: ['https://testnet.midgard.thorchain.info'],
65130
+ [xchainClient.Network.Mainnet]: ['https://midgard.ninerealms.com', 'https://midgard.thorswap.net'],
65131
+ };
65132
+ const getMimirDetails = (network = xchainClient.Network.Mainnet) => __awaiter$1(void 0, void 0, void 0, function* () {
65133
+ const path = '/v2/thorchain/mimir';
65134
+ for (const baseUrl of midgardBaseUrls[network]) {
65135
+ try {
65136
+ const { data } = yield axios.get(`${baseUrl}${path}`);
65137
+ return data;
65138
+ }
65139
+ catch (e) {
65140
+ console.error(e);
65141
+ }
65142
+ }
65143
+ throw new Error('Midgard not responding');
65144
+ });
65145
+ const getAllInboundDetails = (network = xchainClient.Network.Mainnet) => __awaiter$1(void 0, void 0, void 0, function* () {
65146
+ const path = '/v2/thorchain/inbound_addresses';
65147
+ for (const baseUrl of midgardBaseUrls[network]) {
65148
+ try {
65149
+ const { data } = yield axios.get(`${baseUrl}${path}`);
65150
+ return data;
65151
+ }
65152
+ catch (e) {
65153
+ console.error(e);
65154
+ }
65155
+ }
65156
+ throw new Error('Midgard not responding');
65157
+ });
65158
+ const getInboundDetails = (chain, network = xchainClient.Network.Mainnet) => __awaiter$1(void 0, void 0, void 0, function* () {
65159
+ const [mimirDetails, allInboundDetails] = yield Promise.all([getMimirDetails(network), getAllInboundDetails(network)]);
65160
+ const inboundDetail = allInboundDetails === null || allInboundDetails === void 0 ? void 0 : allInboundDetails.find((item) => item.chain === chain);
65161
+ const details = {
65162
+ vault: (inboundDetail === null || inboundDetail === void 0 ? void 0 : inboundDetail.address) || '',
65163
+ haltedChain: (inboundDetail === null || inboundDetail === void 0 ? void 0 : inboundDetail.halted) || !!mimirDetails[`HALT${chain}CHAIN`] || !!mimirDetails['HALTCHAINGLOBAL'],
65164
+ haltedTrading: !!mimirDetails['HALTTRADING'] || !!mimirDetails[`HALT${chain}TRADING`],
65165
+ haltedLP: !!mimirDetails['PAUSELP'] || !!mimirDetails[`PAUSELP${chain}`],
65166
+ };
65167
+ if (inboundDetail === null || inboundDetail === void 0 ? void 0 : inboundDetail.router)
65168
+ details.router = inboundDetail.router;
65169
+ return details;
65170
+ });
65116
65171
 
65117
65172
  var inherits_browser$1 = createCommonjsModule$1(function (module) {
65118
65173
  if (typeof Object.create === 'function') {
@@ -87114,6 +87169,34 @@ class Client extends xchainClient.UTXOClient {
87114
87169
  });
87115
87170
  });
87116
87171
  }
87172
+ /**
87173
+ * Transaction to THORChain inbound address.
87174
+ *
87175
+ * @param {DepositParams} params The transaction options.
87176
+ * @returns {TxHash} The transaction hash.
87177
+ *
87178
+ * @throws {"halted chain"} Thrown if chain is halted.
87179
+ * @throws {"halted trading"} Thrown if trading is halted.
87180
+ */
87181
+ deposit({ walletIndex = 0, asset = AssetDOGE, amount, memo }) {
87182
+ return __awaiter(this, void 0, void 0, function* () {
87183
+ const inboundDetails = yield getInboundDetails(asset.chain, this.network);
87184
+ if (inboundDetails.haltedChain) {
87185
+ throw new Error(`Halted chain for ${assetToString(asset)}`);
87186
+ }
87187
+ if (inboundDetails.haltedTrading) {
87188
+ throw new Error(`Halted trading for ${assetToString(asset)}`);
87189
+ }
87190
+ const txHash = yield this.transfer({
87191
+ walletIndex,
87192
+ asset,
87193
+ amount,
87194
+ recipient: inboundDetails.vault,
87195
+ memo,
87196
+ });
87197
+ return txHash;
87198
+ });
87199
+ }
87117
87200
  }
87118
87201
 
87119
87202
  /**