@swapkit/helpers 1.0.0-rc.65 → 1.0.0-rc.67

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/dist/index.es.js CHANGED
@@ -11,12 +11,12 @@ var O = (e, t, n) => {
11
11
  };
12
12
  var T = (e, t, n) => (Ve(e, t, "access private method"), n);
13
13
  import { FeeOption as Y, BaseDecimal as d, Chain as a, EVMChainList as Be, ChainToRPC as Ue, MemoType as E, ChainToChainId as Le } from "@swapkit/types";
14
- var l = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_MAX_500 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(l || {});
15
- l.INVALID_INPUT_PARAMETERS + "", l.UNKNOWN_PROVIDERS + "", l.CANNOT_FIND_INBOUND_ADDRESS + "", l.NO_INBOUND_ADDRESSES + "", l.CHAIN_HALTED_OR_UNSUPPORTED + "", l.MISSING_INPUT_PARAMETER + "", l.INVALID_TYPE_GENERIC + "", l.INVALID_NUMBER_STRING + "", l.INVALID_NUMBER + "", l.INVALID_BOOLEAN + "", l.INVALID_OBJECT + "", l.INVALID_ARRAY + "", l.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", l.SELL_BUY_ASSETS_ARE_THE_SAME + "", l.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", l.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", l.AFF_ADDRESS_TOO_LONG + "", l.AFF_BPS_INTEGER_MAX_500 + "", l.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", l.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", l.PREFERRED_PROVIDER_NOT_SUPPORTED + "", l.SOURCE_ADDRESS_SMART_CONTRACT + "", l.DESTINATION_ADDRESS_SMART_CONTRACT + "", l.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", l.INVALID_PROVIDER + "", l.MISSING_CROSS_CHAIN_PROVIDER + "", l.MISSING_AVAX_PROVIDER + "", l.MISSING_BSC_PROVIDER + "", l.MISSING_ETH_PROVIDER + "", l.MISSING_ARB_PROVIDER + "", l.INVALID_PROVIDER_FOR_SWAP_OUT + "", l.INVALID_CHAIN + "", l.INVALID_ASSET + "", l.UNSUPPORTED_CHAIN + "", l.UNSUPPORTED_ASSET + "", l.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", l.THORNODE_QUOTE_GENERIC_ERROR + "", l.INVALID_SOURCE_ADDRESS + "", l.INVALID_DESTINATION_ADDRESS + "", l.NOT_ENOUGH_SYNTH_BALANCE + "", l.SYNTH_MINTING_CAP_REACHED + "", l.INVALID_QUOTE_MODE + "", l.NO_QUOTES + "", l.SERVICE_UNAVAILABLE_GENERIC + "", l.MISSING_GAS_DATA_GENERIC + "", l.MISSING_TOKEN_INFO_GENERIC + "", l.CANT_FIND_TOKEN_LIST + "", l.NO_PRICE + "", l.PRICE_IS_STALE + "", l.ADDRESS_NOT_WHITELISTED + "", l.ADDRESS_ALREADY_CLAIMED + "";
16
- var j = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(j || {}), te = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(te || {}), de = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(de || {}), R = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(R || {});
17
- const q = Object.values(j), ve = Object.keys(j), ne = q.reduce(
14
+ var l = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_MAX_500 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.SWAP_AMOUNT_TOO_LOW = "2012", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(l || {});
15
+ l.INVALID_INPUT_PARAMETERS + "", l.UNKNOWN_PROVIDERS + "", l.CANNOT_FIND_INBOUND_ADDRESS + "", l.NO_INBOUND_ADDRESSES + "", l.CHAIN_HALTED_OR_UNSUPPORTED + "", l.MISSING_INPUT_PARAMETER + "", l.INVALID_TYPE_GENERIC + "", l.INVALID_NUMBER_STRING + "", l.INVALID_NUMBER + "", l.INVALID_BOOLEAN + "", l.INVALID_OBJECT + "", l.INVALID_ARRAY + "", l.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", l.SELL_BUY_ASSETS_ARE_THE_SAME + "", l.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", l.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", l.AFF_ADDRESS_TOO_LONG + "", l.AFF_BPS_INTEGER_MAX_500 + "", l.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", l.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", l.PREFERRED_PROVIDER_NOT_SUPPORTED + "", l.SOURCE_ADDRESS_SMART_CONTRACT + "", l.SWAP_AMOUNT_TOO_LOW + "", l.DESTINATION_ADDRESS_SMART_CONTRACT + "", l.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", l.INVALID_PROVIDER + "", l.MISSING_CROSS_CHAIN_PROVIDER + "", l.MISSING_AVAX_PROVIDER + "", l.MISSING_BSC_PROVIDER + "", l.MISSING_ETH_PROVIDER + "", l.MISSING_ARB_PROVIDER + "", l.INVALID_PROVIDER_FOR_SWAP_OUT + "", l.INVALID_CHAIN + "", l.INVALID_ASSET + "", l.UNSUPPORTED_CHAIN + "", l.UNSUPPORTED_ASSET + "", l.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", l.THORNODE_QUOTE_GENERIC_ERROR + "", l.INVALID_SOURCE_ADDRESS + "", l.INVALID_DESTINATION_ADDRESS + "", l.NOT_ENOUGH_SYNTH_BALANCE + "", l.SYNTH_MINTING_CAP_REACHED + "", l.INVALID_QUOTE_MODE + "", l.NO_QUOTES + "", l.SERVICE_UNAVAILABLE_GENERIC + "", l.MISSING_GAS_DATA_GENERIC + "", l.MISSING_TOKEN_INFO_GENERIC + "", l.CANT_FIND_TOKEN_LIST + "", l.NO_PRICE + "", l.PRICE_IS_STALE + "", l.ADDRESS_NOT_WHITELISTED + "", l.ADDRESS_ALREADY_CLAIMED + "";
16
+ var k = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(k || {}), te = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(te || {}), de = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(de || {}), R = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(R || {});
17
+ const q = Object.values(k), ve = Object.keys(k), ne = q.reduce(
18
18
  (e, t) => {
19
- const n = ve.find((r) => j[r] === t);
19
+ const n = ve.find((r) => k[r] === t);
20
20
  return n && (e[t] = n), e;
21
21
  },
22
22
  {}
@@ -132,9 +132,9 @@ const M = (e) => e !== null && typeof e == "object", v = (...e) => {
132
132
  window: !0,
133
133
  dispatcher: !0,
134
134
  duplex: !0
135
- }, ke = (e) => pe.includes(e) ? e.toUpperCase() : e, je = ["get", "put", "head", "delete", "options", "trace"], qe = [408, 413, 429, 500, 502, 503, 504], me = [413, 429, 503], ce = {
135
+ }, je = (e) => pe.includes(e) ? e.toUpperCase() : e, ke = ["get", "put", "head", "delete", "options", "trace"], qe = [408, 413, 429, 500, 502, 503, 504], me = [413, 429, 503], ce = {
136
136
  limit: 2,
137
- methods: je,
137
+ methods: ke,
138
138
  statusCodes: qe,
139
139
  afterStatusCodes: me,
140
140
  maxRetryAfter: Number.POSITIVE_INFINITY,
@@ -261,7 +261,7 @@ class F {
261
261
  beforeError: [],
262
262
  afterResponse: []
263
263
  }, n.hooks),
264
- method: ke(n.method ?? this._input.method),
264
+ method: je(n.method ?? this._input.method),
265
265
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
266
266
  prefixUrl: String(n.prefixUrl || ""),
267
267
  retry: Xe(n.retry),
@@ -738,19 +738,19 @@ function G({
738
738
  ""
739
739
  );
740
740
  }
741
- var C, y, f, D, k, Ne, U, z, L, Z;
741
+ var C, y, f, D, j, Ne, U, z, L, Z;
742
742
  const se = class se {
743
743
  constructor(t) {
744
744
  O(this, C);
745
745
  O(this, f);
746
- O(this, k);
746
+ O(this, j);
747
747
  O(this, U);
748
748
  O(this, L);
749
749
  p(this, "decimalMultiplier", 10n ** 8n);
750
750
  p(this, "bigIntValue", 0n);
751
751
  p(this, "decimal");
752
752
  const n = ee(t), r = typeof t == "object";
753
- this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : N(Math.max(_e($(n)), this.decimal || 0)), T(this, k, Ne).call(this, n);
753
+ this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : N(Math.max(_e($(n)), this.decimal || 0)), T(this, j, Ne).call(this, n);
754
754
  }
755
755
  static fromBigInt(t, n) {
756
756
  return new se({
@@ -933,7 +933,7 @@ C = new WeakSet(), y = function(t, ...n) {
933
933
  case "eqValue":
934
934
  return i === s;
935
935
  }
936
- }, k = new WeakSet(), Ne = function(t) {
936
+ }, j = new WeakSet(), Ne = function(t) {
937
937
  const n = $(t) || "0";
938
938
  this.bigIntValue = T(this, L, Z).call(this, n);
939
939
  }, U = new WeakSet(), z = function(...t) {
@@ -1107,13 +1107,13 @@ function x(e) {
1107
1107
  const t = e.slice(0, 14).includes("/"), [n, r] = e.split(".")[0].toUpperCase() === a.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1108
1108
  if (t && (!n || !r))
1109
1109
  throw new Error("Invalid asset identifier");
1110
- const s = e.includes(".") && !t ? e : `${a.THORChain}.${r}`, [i, o] = s.split("."), [u, c] = (t ? r : o).split("-");
1110
+ const s = e.includes(".") && !t ? e : `${a.THORChain}.${r}`, [i, ...o] = s.split("."), [u, c] = (t ? r : o.join(".")).split("-"), _ = t ? r : o.join(".");
1111
1111
  return {
1112
1112
  address: c == null ? void 0 : c.toLowerCase(),
1113
1113
  chain: i,
1114
- isGasAsset: fe({ chain: i, symbol: o }),
1114
+ isGasAsset: fe({ chain: i, symbol: _ }),
1115
1115
  isSynthetic: t,
1116
- symbol: (t ? `${n}/` : "") + (c ? `${u}-${(c == null ? void 0 : c.toLowerCase()) ?? ""}` : o),
1116
+ symbol: (t ? `${n}/` : "") + (c ? `${u}-${(c == null ? void 0 : c.toLowerCase()) ?? ""}` : _),
1117
1117
  ticker: u
1118
1118
  };
1119
1119
  }