@swapkit/core 1.0.0-rc.72 → 1.0.0-rc.74

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
@@ -839,7 +839,7 @@ const ie = Object.values(i), ot = Object.keys(i), fe = ie.reduce(
839
839
  var ut = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(ut || {}), h = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(h || {}), F = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(F || {}), lt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.OKX_MOBILE = "OKX_MOBILE", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(lt || {}), yt = Object.defineProperty, ct = (e, t, n) => t in e ? yt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, S = (e, t, n) => (ct(e, typeof t != "symbol" ? t + "" : t, n), n), mt = (e, t, n) => {
840
840
  if (!t.has(e))
841
841
  throw TypeError("Cannot " + n);
842
- }, H = (e, t, n) => {
842
+ }, $ = (e, t, n) => {
843
843
  if (t.has(e))
844
844
  throw TypeError("Cannot add the same private member more than once");
845
845
  t instanceof WeakSet ? t.add(e) : t.set(e, n);
@@ -1081,7 +1081,7 @@ const M = (e, t) => {
1081
1081
  }
1082
1082
  case h.UNBOND: {
1083
1083
  const { address: n, unbondAmount: a } = t;
1084
- return `${e}:${n}:${a * 10 ** 8}`;
1084
+ return `${e}:${n}:${a}`;
1085
1085
  }
1086
1086
  case h.THORNAME_REGISTER: {
1087
1087
  const { name: n, chain: a, address: s, owner: r } = t;
@@ -1249,7 +1249,7 @@ const z = (e) => e !== null && typeof e == "object", Q = (...e) => {
1249
1249
  afterStatusCodes: Ve
1250
1250
  };
1251
1251
  };
1252
- async function $t(e, t, n, a) {
1252
+ async function Ht(e, t, n, a) {
1253
1253
  return new Promise((s, r) => {
1254
1254
  const o = setTimeout(() => {
1255
1255
  n && n.abort(), r(new De(e));
@@ -1259,7 +1259,7 @@ async function $t(e, t, n, a) {
1259
1259
  });
1260
1260
  });
1261
1261
  }
1262
- async function Ht(e, { signal: t }) {
1262
+ async function $t(e, { signal: t }) {
1263
1263
  return new Promise((n, a) => {
1264
1264
  t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
1265
1265
  function s() {
@@ -1410,7 +1410,7 @@ class te {
1410
1410
  } catch (n) {
1411
1411
  const a = Math.min(this._calculateRetryDelay(n), de);
1412
1412
  if (a !== 0 && this._retryCount > 0) {
1413
- await Ht(a, { signal: this._options.signal });
1413
+ await $t(a, { signal: this._options.signal });
1414
1414
  for (const s of this._options.hooks.beforeRetry)
1415
1415
  if (await s({
1416
1416
  request: this.request,
@@ -1435,7 +1435,7 @@ class te {
1435
1435
  return a;
1436
1436
  }
1437
1437
  const t = kt(this.request, this._options);
1438
- return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : $t(this.request.clone(), t, this.abortController, this._options);
1438
+ return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Ht(this.request.clone(), t, this.abortController, this._options);
1439
1439
  }
1440
1440
  /* istanbul ignore next */
1441
1441
  _stream(t, n) {
@@ -1511,15 +1511,15 @@ function re({
1511
1511
  ""
1512
1512
  );
1513
1513
  }
1514
- var U, k, B, $, me, Ue, Z, ue, ne, Te;
1515
- const jt = class $e {
1514
+ var U, k, B, H, me, Ue, Z, ue, ne, Te;
1515
+ const jt = class He {
1516
1516
  constructor(t) {
1517
- H(this, U), H(this, B), H(this, me), H(this, Z), H(this, ne), S(this, "decimalMultiplier", 10n ** 8n), S(this, "bigIntValue", 0n), S(this, "decimal");
1517
+ $(this, U), $(this, B), $(this, me), $(this, Z), $(this, ne), S(this, "decimalMultiplier", 10n ** 8n), S(this, "bigIntValue", 0n), S(this, "decimal");
1518
1518
  const n = he(t), a = typeof t == "object";
1519
1519
  this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : L(Math.max(ke(ae(n)), this.decimal || 0)), R(this, me, Ue).call(this, n);
1520
1520
  }
1521
1521
  static fromBigInt(t, n) {
1522
- return new $e({
1522
+ return new He({
1523
1523
  decimal: n,
1524
1524
  value: re({ value: t, bigIntDecimal: n, decimal: n })
1525
1525
  });
@@ -1550,19 +1550,19 @@ const jt = class $e {
1550
1550
  return R(this, U, k).call(this, "div", ...t);
1551
1551
  }
1552
1552
  gt(t) {
1553
- return R(this, B, $).call(this, "gt", t);
1553
+ return R(this, B, H).call(this, "gt", t);
1554
1554
  }
1555
1555
  gte(t) {
1556
- return R(this, B, $).call(this, "gte", t);
1556
+ return R(this, B, H).call(this, "gte", t);
1557
1557
  }
1558
1558
  lt(t) {
1559
- return R(this, B, $).call(this, "lt", t);
1559
+ return R(this, B, H).call(this, "lt", t);
1560
1560
  }
1561
1561
  lte(t) {
1562
- return R(this, B, $).call(this, "lte", t);
1562
+ return R(this, B, H).call(this, "lte", t);
1563
1563
  }
1564
1564
  eqValue(t) {
1565
- return R(this, B, $).call(this, "eqValue", t);
1565
+ return R(this, B, H).call(this, "eqValue", t);
1566
1566
  }
1567
1567
  // @ts-expect-error False positive
1568
1568
  getValue(t) {
@@ -1685,7 +1685,7 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
1685
1685
  value: o,
1686
1686
  identifier: this.toString()
1687
1687
  });
1688
- }, B = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
1688
+ }, B = /* @__PURE__ */ new WeakSet(), H = function(e, ...t) {
1689
1689
  const n = R(this, Z, ue).call(this, this, ...t), a = this.getBigIntValue(t[0], n), s = this.getBigIntValue(this, n);
1690
1690
  switch (e) {
1691
1691
  case "gt":
@@ -1709,7 +1709,7 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
1709
1709
  const n = t ? L(t) : this.decimalMultiplier, a = G(n), [s = "", r = ""] = e.split(".");
1710
1710
  return BigInt(`${s}${r.padEnd(a, "0")}`);
1711
1711
  };
1712
- let He = jt;
1712
+ let $e = jt;
1713
1713
  const Kt = Intl.NumberFormat("fullwide", {
1714
1714
  useGrouping: !1,
1715
1715
  maximumFractionDigits: 20
@@ -1727,7 +1727,7 @@ function he(e) {
1727
1727
  return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
1728
1728
  }
1729
1729
  const q = /* @__PURE__ */ new Map();
1730
- class N extends He {
1730
+ class N extends $e {
1731
1731
  constructor({
1732
1732
  value: t,
1733
1733
  decimal: n,
@@ -1844,7 +1844,9 @@ async function ye(e, t = 0) {
1844
1844
  return n || q.set(e.toUpperCase(), { identifier: e, decimal: a }), new N({ decimal: a, value: W(t, a), identifier: e });
1845
1845
  }
1846
1846
  function Oe(e, t = 0) {
1847
- const [n, a] = e.split("/");
1847
+ const [n, a] = e.split(".")[0].toUpperCase() === i.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1848
+ if (!n || !a)
1849
+ throw new Error("Invalid asset identifier");
1848
1850
  return new N({
1849
1851
  decimal: 8,
1850
1852
  value: W(t, 8),
@@ -1855,7 +1857,10 @@ function W(e, t) {
1855
1857
  return typeof e == "bigint" ? re({ value: e, bigIntDecimal: t, decimal: t }) : e;
1856
1858
  }
1857
1859
  function ee(e) {
1858
- const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".").pop().split("/"), s = e.includes(".") && !t ? e : `${i.THORChain}.${a}`, [r, o] = s.split("."), [p, d] = (t ? a : o).split("-");
1860
+ const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".")[0].toUpperCase() === i.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1861
+ if (t && (!n || !a))
1862
+ throw new Error("Invalid asset identifier");
1863
+ const s = e.includes(".") && !t ? e : `${i.THORChain}.${a}`, [r, o] = s.split("."), [p, d] = (t ? a : o).split("-");
1859
1864
  return {
1860
1865
  address: d == null ? void 0 : d.toLowerCase(),
1861
1866
  chain: r,
@@ -1928,7 +1933,7 @@ class c extends Error {
1928
1933
  console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: Xt[t], message: t } }), Object.setPrototypeOf(this, c.prototype);
1929
1934
  }
1930
1935
  }
1931
- class x extends He {
1936
+ class x extends $e {
1932
1937
  eq(t) {
1933
1938
  return this.eqValue(t);
1934
1939
  }
@@ -4224,7 +4229,7 @@ export {
4224
4229
  j as ApiUrl,
4225
4230
  N as AssetValue,
4226
4231
  b as BaseDecimal,
4227
- He as BigIntArithmetics,
4232
+ $e as BigIntArithmetics,
4228
4233
  i as Chain,
4229
4234
  _e as ChainId,
4230
4235
  On as ChainIdToChain,