@xchainjs/xchain-bitcoin 0.18.4 → 0.19.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/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$1 = require('axios');
12
+ var axios = 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$1);
22
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
23
23
 
24
24
  /*! *****************************************************************************
25
25
  Copyright (c) Microsoft Corporation.
@@ -64905,7 +64905,7 @@ const chainToString = Object.assign((chainId) => {
64905
64905
  [Chain.Polkadot]: 'Polkadot',
64906
64906
  [Chain.Terra]: 'Terra',
64907
64907
  [Chain.Doge]: 'Dogecoin',
64908
- });
64908
+ });
64909
64909
 
64910
64910
  var Denomination;
64911
64911
  (function (Denomination) {
@@ -65086,27 +65086,6 @@ const AssetRuneERC20Testnet = {
65086
65086
  ticker: RUNE_TICKER,
65087
65087
  synth: false,
65088
65088
  };
65089
- const SYNTH_DELIMITER = '/';
65090
- const NON_SYNTH_DELIMITER = '.';
65091
- /**
65092
- * Returns an `Asset` as a string using following naming convention:
65093
- *
65094
- * `AAA.BBB-CCC`
65095
- * where
65096
- * chain: `AAA`
65097
- * ticker (optional): `BBB`
65098
- * symbol: `BBB-CCC` or `CCC` (if no ticker available)
65099
- * symbol (synth): `BBB/CCC` or `CCC` (if no ticker available)
65100
- *
65101
- * @see https://docs.thorchain.org/developers/transaction-memos#asset-notation
65102
- *
65103
- * @param {Asset} asset The given asset.
65104
- * @returns {string} The string from the given asset.
65105
- */
65106
- const assetToString = ({ chain, symbol, synth }) => {
65107
- const delimiter = synth ? SYNTH_DELIMITER : NON_SYNTH_DELIMITER;
65108
- return `${chain}${delimiter}${symbol}`;
65109
- };
65110
65089
  /**
65111
65090
  * Currency symbols currently supported
65112
65091
  */
@@ -65117,77 +65096,7 @@ var AssetCurrencySymbol;
65117
65096
  AssetCurrencySymbol["SATOSHI"] = "\u26A1";
65118
65097
  AssetCurrencySymbol["ETH"] = "\u039E";
65119
65098
  AssetCurrencySymbol["USD"] = "$";
65120
- })(AssetCurrencySymbol || (AssetCurrencySymbol = {}));
65121
-
65122
- /*! *****************************************************************************
65123
- Copyright (c) Microsoft Corporation.
65124
-
65125
- Permission to use, copy, modify, and/or distribute this software for any
65126
- purpose with or without fee is hereby granted.
65127
-
65128
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
65129
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
65130
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
65131
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
65132
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
65133
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65134
- PERFORMANCE OF THIS SOFTWARE.
65135
- ***************************************************************************** */
65136
-
65137
- function __awaiter$1(thisArg, _arguments, P, generator) {
65138
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
65139
- return new (P || (P = Promise))(function (resolve, reject) {
65140
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
65141
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
65142
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
65143
- step((generator = generator.apply(thisArg, _arguments || [])).next());
65144
- });
65145
- }
65146
-
65147
- const axios = require('axios');
65148
- const midgardBaseUrls = {
65149
- [xchainClient.Network.Testnet]: ['https://testnet.midgard.thorchain.info'],
65150
- [xchainClient.Network.Mainnet]: ['https://midgard.ninerealms.com', 'https://midgard.thorswap.net'],
65151
- };
65152
- const getMimirDetails = (network = xchainClient.Network.Mainnet) => __awaiter$1(void 0, void 0, void 0, function* () {
65153
- const path = '/v2/thorchain/mimir';
65154
- for (const baseUrl of midgardBaseUrls[network]) {
65155
- try {
65156
- const { data } = yield axios.get(`${baseUrl}${path}`);
65157
- return data;
65158
- }
65159
- catch (e) {
65160
- console.error(e);
65161
- }
65162
- }
65163
- throw new Error('Midgard not responding');
65164
- });
65165
- const getAllInboundDetails = (network = xchainClient.Network.Mainnet) => __awaiter$1(void 0, void 0, void 0, function* () {
65166
- const path = '/v2/thorchain/inbound_addresses';
65167
- for (const baseUrl of midgardBaseUrls[network]) {
65168
- try {
65169
- const { data } = yield axios.get(`${baseUrl}${path}`);
65170
- return data;
65171
- }
65172
- catch (e) {
65173
- console.error(e);
65174
- }
65175
- }
65176
- throw new Error('Midgard not responding');
65177
- });
65178
- const getInboundDetails = (chain, network = xchainClient.Network.Mainnet) => __awaiter$1(void 0, void 0, void 0, function* () {
65179
- const [mimirDetails, allInboundDetails] = yield Promise.all([getMimirDetails(network), getAllInboundDetails(network)]);
65180
- const inboundDetail = allInboundDetails === null || allInboundDetails === void 0 ? void 0 : allInboundDetails.find((item) => item.chain === chain);
65181
- const details = {
65182
- vault: (inboundDetail === null || inboundDetail === void 0 ? void 0 : inboundDetail.address) || '',
65183
- haltedChain: (inboundDetail === null || inboundDetail === void 0 ? void 0 : inboundDetail.halted) || !!mimirDetails[`HALT${chain}CHAIN`] || !!mimirDetails['HALTCHAINGLOBAL'],
65184
- haltedTrading: !!mimirDetails['HALTTRADING'] || !!mimirDetails[`HALT${chain}TRADING`],
65185
- haltedLP: !!mimirDetails['PAUSELP'] || !!mimirDetails[`PAUSELP${chain}`],
65186
- };
65187
- if (inboundDetail === null || inboundDetail === void 0 ? void 0 : inboundDetail.router)
65188
- details.router = inboundDetail.router;
65189
- return details;
65190
- });
65099
+ })(AssetCurrencySymbol || (AssetCurrencySymbol = {}));
65191
65100
 
65192
65101
  var inherits_browser$1 = createCommonjsModule$1(function (module) {
65193
65102
  if (typeof Object.create === 'function') {
@@ -86097,35 +86006,6 @@ class Client extends xchainClient.UTXOClient {
86097
86006
  return yield broadcastTx$1({ txHex, haskoinUrl });
86098
86007
  });
86099
86008
  }
86100
- /**
86101
- * Transaction to THORChain inbound address.
86102
- *
86103
- * @param {DepositParams} params The transaction options.
86104
- * @returns {TxHash} The transaction hash.
86105
- *
86106
- * @throws {"halted chain"} Thrown if chain is halted.
86107
- * @throws {"halted trading"} Thrown if trading is halted.
86108
- * @throws {"memo too long"} Thrown if memo longer than 80 chars.
86109
- */
86110
- deposit({ walletIndex = 0, asset = AssetBTC, amount, memo }) {
86111
- return __awaiter(this, void 0, void 0, function* () {
86112
- const inboundDetails = yield getInboundDetails(asset.chain, this.network);
86113
- if (inboundDetails.haltedChain) {
86114
- throw new Error(`Halted chain for ${assetToString(asset)}`);
86115
- }
86116
- if (inboundDetails.haltedTrading) {
86117
- throw new Error(`Halted trading for ${assetToString(asset)}`);
86118
- }
86119
- const txHash = yield this.transfer({
86120
- walletIndex,
86121
- asset,
86122
- amount,
86123
- recipient: inboundDetails.vault,
86124
- memo,
86125
- });
86126
- return txHash;
86127
- });
86128
- }
86129
86009
  }
86130
86010
 
86131
86011
  exports.BTC_DECIMAL = BTC_DECIMAL;