@coinmasters/helpers
Advanced tools
Comparing version 5.0.0 to 6.0.0
@@ -7,3 +7,3 @@ var bt = Object.defineProperty; | ||
}; | ||
var $ = (r, t, e) => { | ||
var R = (r, t, e) => { | ||
if (t.has(r)) | ||
@@ -14,4 +14,4 @@ throw TypeError("Cannot add the same private member more than once"); | ||
var m = (r, t, e) => (wt(r, t, "access private method"), e); | ||
import { FeeOption as D, BaseDecimal as d, Chain as a, EVMChainList as At, ChainToRPC as vt, MemoType as g } from "@coinmasters/types"; | ||
const Tt = "0x313ce567", it = async ({ chain: r, to: t }) => { | ||
import { FeeOption as D, BaseDecimal as d, Chain as a, EVMChainList as At, ChainToRPC as vt, MemoType as b } from "@coinmasters/types"; | ||
const Tt = "0x313ce567", at = async ({ chain: r, to: t }) => { | ||
try { | ||
@@ -39,6 +39,6 @@ const { result: e } = await Xt.post(vt[r], { | ||
const [, t] = r.split("-"); | ||
return t != null && t.startsWith("0x") ? it({ chain: a.Ethereum, to: t }) : d.ETH; | ||
return t != null && t.startsWith("0x") ? at({ chain: a.Ethereum, to: t }) : d.ETH; | ||
}, Rt = async (r) => { | ||
const [, t] = r.split("-"); | ||
return t != null && t.startsWith("0x") ? it({ chain: a.Avalanche, to: t.toLowerCase() }) : d.AVAX; | ||
return t != null && t.startsWith("0x") ? at({ chain: a.Avalanche, to: t.toLowerCase() }) : d.AVAX; | ||
}, St = async (r) => r === a.BinanceSmartChain ? d.BSC : d.BSC, Ct = async ({ chain: r, symbol: t }) => { | ||
@@ -59,3 +59,3 @@ switch (r) { | ||
[D.Fastest]: 2 | ||
}, at = ({ chain: r, symbol: t }) => { | ||
}, ot = ({ chain: r, symbol: t }) => { | ||
switch (r) { | ||
@@ -168,3 +168,3 @@ case a.Bitcoin: | ||
const [, s] = e.split("-"); | ||
return at({ chain: t, symbol: e }) || !!s; | ||
return ot({ chain: t, symbol: e }) || !!s; | ||
}, oe = (r) => r.filter((t) => { | ||
@@ -197,3 +197,3 @@ const e = `${t.chain}.${t.symbol}`; | ||
poolUnits: s | ||
}) => xt({ assetDepth: t, liquidityUnits: e, poolUnits: s }).mul(r), p = (r) => b.fromBigInt(BigInt(r), d.THOR), qt = ({ | ||
}) => xt({ assetDepth: t, liquidityUnits: e, poolUnits: s }).mul(r), p = (r) => y.fromBigInt(BigInt(r), d.THOR), kt = ({ | ||
liquidityUnits: r, | ||
@@ -213,3 +213,3 @@ poolUnits: t, | ||
}) => Object.fromEntries( | ||
Object.entries(qt({ liquidityUnits: r, poolUnits: t, runeDepth: e, assetDepth: s })).map( | ||
Object.entries(kt({ liquidityUnits: r, poolUnits: t, runeDepth: e, assetDepth: s })).map( | ||
([i, o]) => [i, o.mul(n)] | ||
@@ -225,4 +225,4 @@ ) | ||
}) => { | ||
const o = new b({ value: r, decimal: 8 }), c = new b({ value: e, decimal: 8 }), u = new b({ value: t, decimal: 8 }), h = new b({ value: n, decimal: 8 }), l = new b({ value: i, decimal: 8 }), _ = h.mul(c), T = l.mul(o), j = h.mul(l), pt = o.mul(c), ft = u.mul(_.add(T.add(j.mul(2)))), _t = _.add(T.add(pt.mul(2))), Z = ft.div(_t), H = p(s).add(Z); | ||
if (Z.getBaseValue("number") === 0) | ||
const o = new y({ value: r, decimal: 8 }), c = new y({ value: e, decimal: 8 }), u = new y({ value: t, decimal: 8 }), h = new y({ value: n, decimal: 8 }), l = new y({ value: i, decimal: 8 }), _ = h.mul(c), g = l.mul(o), $ = h.mul(l), Z = o.mul(c), ft = u.mul(_.add(g.add($.mul(2)))), _t = _.add(g.add(Z.mul(2))), Q = ft.div(_t), H = p(s).add(Q); | ||
if (Q.getBaseValue("number") === 0) | ||
return H.div(u).getBaseValue("number"); | ||
@@ -241,3 +241,3 @@ const gt = u.add(H); | ||
return Math.abs(u.div(h).getBaseValue("number")); | ||
}, kt = ({ | ||
}, qt = ({ | ||
symbol: r, | ||
@@ -248,25 +248,25 @@ ticker: t, | ||
switch (r) { | ||
case g.LEAVE: | ||
case g.BOND: { | ||
case b.LEAVE: | ||
case b.BOND: { | ||
const { address: e } = t; | ||
return `${r}:${e}`; | ||
} | ||
case g.UNBOND: { | ||
case b.UNBOND: { | ||
const { address: e, unbondAmount: s } = t; | ||
return `${r}:${e}:${s * 10 ** 8}`; | ||
} | ||
case g.THORNAME_REGISTER: { | ||
case b.THORNAME_REGISTER: { | ||
const { name: e, chain: s, address: n, owner: i } = t; | ||
return `${r}:${e}:${s}:${n}${i ? `:${i}` : ""}`; | ||
} | ||
case g.DEPOSIT: { | ||
case b.DEPOSIT: { | ||
const { chain: e, symbol: s, address: n, singleSide: i } = t; | ||
return i ? `${r}:${e}/${s}::t:0` : `${r}:${e}.${s}:${n || ""}:t:0`; | ||
} | ||
case g.WITHDRAW: { | ||
const { chain: e, ticker: s, symbol: n, basisPoints: i, targetAssetString: o, singleSide: c } = t, u = !c && o ? `:${o}` : "", h = kt({ chain: e, symbol: n, ticker: s }); | ||
case b.WITHDRAW: { | ||
const { chain: e, ticker: s, symbol: n, basisPoints: i, targetAssetString: o, singleSide: c } = t, u = !c && o ? `:${o}` : "", h = qt({ chain: e, symbol: n, ticker: s }); | ||
return `${r}:${e}${c ? "/" : "."}${h}:${i}${u}`; | ||
} | ||
case g.OPEN_LOAN: | ||
case g.CLOSE_LOAN: { | ||
case b.OPEN_LOAN: | ||
case b.CLOSE_LOAN: { | ||
const { asset: e, address: s } = t; | ||
@@ -288,3 +288,3 @@ return `${r}:${e}:${s}`; | ||
}, _e = ([r, t, e, s, n]) => `${r}'/${t}'/${e}'/${s}${typeof n != "number" ? "" : `/${n}`}`; | ||
class Q extends Error { | ||
class X extends Error { | ||
constructor(t, e, s) { | ||
@@ -310,3 +310,3 @@ const n = t.status || t.status === 0 ? t.status : "", i = t.statusText || "", o = `${n} ${i}`.trim(), c = o ? `status code ${o}` : "an unknown error"; | ||
} | ||
class ot extends Error { | ||
class ct extends Error { | ||
constructor(t) { | ||
@@ -321,3 +321,3 @@ super("Request timed out"), Object.defineProperty(this, "request", { | ||
} | ||
const q = (r) => r !== null && typeof r == "object", B = (...r) => { | ||
const q = (r) => r !== null && typeof r == "object", x = (...r) => { | ||
for (const t of r) | ||
@@ -327,3 +327,3 @@ if ((!q(t) || Array.isArray(t)) && t !== void 0) | ||
return J({}, ...r); | ||
}, ct = (r = {}, t = {}) => { | ||
}, ut = (r = {}, t = {}) => { | ||
const e = new globalThis.Headers(r), s = t instanceof globalThis.Headers, n = new globalThis.Headers(t); | ||
@@ -341,3 +341,3 @@ for (const [i, o] of n.entries()) | ||
q(i) && n in t && (i = J(t[n], i)), t = { ...t, [n]: i }; | ||
q(s.headers) && (e = ct(e, s.headers), t.headers = e); | ||
q(s.headers) && (e = ut(e, s.headers), t.headers = e); | ||
} | ||
@@ -356,3 +356,3 @@ return t; | ||
}).headers.has("Content-Type")), r && !t; | ||
})(), Pt = typeof globalThis.AbortController == "function", Nt = typeof globalThis.ReadableStream == "function", jt = typeof globalThis.FormData == "function", ut = ["get", "post", "put", "patch", "head", "delete"], Ht = { | ||
})(), Pt = typeof globalThis.AbortController == "function", Nt = typeof globalThis.ReadableStream == "function", jt = typeof globalThis.FormData == "function", lt = ["get", "post", "put", "patch", "head", "delete"], Ht = { | ||
json: "application/json", | ||
@@ -363,3 +363,3 @@ text: "text/*", | ||
blob: "*/*" | ||
}, L = 2147483647, lt = Symbol("stop"), Dt = { | ||
}, L = 2147483647, ht = Symbol("stop"), Dt = { | ||
json: !0, | ||
@@ -391,14 +391,14 @@ parseJson: !0, | ||
duplex: !0 | ||
}, Ut = (r) => ut.includes(r) ? r.toUpperCase() : r, Ft = ["get", "put", "head", "delete", "options", "trace"], Wt = [408, 413, 429, 500, 502, 503, 504], ht = [413, 429, 503], X = { | ||
}, Ut = (r) => lt.includes(r) ? r.toUpperCase() : r, Ft = ["get", "put", "head", "delete", "options", "trace"], Gt = [408, 413, 429, 500, 502, 503, 504], dt = [413, 429, 503], tt = { | ||
limit: 2, | ||
methods: Ft, | ||
statusCodes: Wt, | ||
afterStatusCodes: ht, | ||
statusCodes: Gt, | ||
afterStatusCodes: dt, | ||
maxRetryAfter: Number.POSITIVE_INFINITY, | ||
backoffLimit: Number.POSITIVE_INFINITY, | ||
delay: (r) => 0.3 * 2 ** (r - 1) * 1e3 | ||
}, Gt = (r = {}) => { | ||
}, Wt = (r = {}) => { | ||
if (typeof r == "number") | ||
return { | ||
...X, | ||
...tt, | ||
limit: r | ||
@@ -411,5 +411,5 @@ }; | ||
return { | ||
...X, | ||
...tt, | ||
...r, | ||
afterStatusCodes: ht | ||
afterStatusCodes: dt | ||
}; | ||
@@ -420,3 +420,3 @@ }; | ||
const o = setTimeout(() => { | ||
e && e.abort(), i(new ot(r)); | ||
e && e.abort(), i(new ct(r)); | ||
}, s.timeout); | ||
@@ -445,5 +445,5 @@ s.fetch(r, t).then(n).catch(i).then(() => { | ||
}; | ||
class V { | ||
class P { | ||
static create(t, e) { | ||
const s = new V(t, e), n = async () => { | ||
const s = new P(t, e), n = async () => { | ||
if (typeof s._options.timeout == "number" && s._options.timeout > L) | ||
@@ -458,3 +458,3 @@ throw new RangeError(`The \`timeout\` option cannot be greater than ${L}`); | ||
if (s._decorateResponse(c), !c.ok && s._options.throwHttpErrors) { | ||
let u = new Q(c, s.request, s._options); | ||
let u = new X(c, s.request, s._options); | ||
for (const h of s._options.hooks.beforeError) | ||
@@ -518,3 +518,3 @@ u = await h(u); | ||
...e, | ||
headers: ct(this._input.headers, e.headers), | ||
headers: ut(this._input.headers, e.headers), | ||
hooks: J({ | ||
@@ -529,3 +529,3 @@ beforeRequest: [], | ||
prefixUrl: String(e.prefixUrl || ""), | ||
retry: Gt(e.retry), | ||
retry: Wt(e.retry), | ||
throwHttpErrors: e.throwHttpErrors !== !1, | ||
@@ -557,4 +557,4 @@ timeout: e.timeout ?? 1e4, | ||
_calculateRetryDelay(t) { | ||
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof ot)) { | ||
if (t instanceof Q) { | ||
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof ct)) { | ||
if (t instanceof X) { | ||
if (!this._options.retry.statusCodes.includes(t.response.status)) | ||
@@ -591,3 +591,3 @@ return 0; | ||
retryCount: this._retryCount | ||
}) === lt) | ||
}) === ht) | ||
return; | ||
@@ -648,15 +648,15 @@ return this._retry(t); | ||
const U = (r) => { | ||
const t = (e, s) => V.create(e, B(r, s)); | ||
for (const e of ut) | ||
t[e] = (s, n) => V.create(s, B(r, n, { method: e })); | ||
return t.create = (e) => U(B(e)), t.extend = (e) => U(B(r, e)), t.stop = lt, t; | ||
}, Kt = U(), Zt = Kt, Qt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, tt = Zt.create({ headers: Qt }), Xt = { | ||
get: (r, t) => tt.get(r, t).json(), | ||
post: (r, t) => tt.post(r, t).json() | ||
}, et = Object.values(a), te = (r = "") => { | ||
const t = (e, s) => P.create(e, x(r, s)); | ||
for (const e of lt) | ||
t[e] = (s, n) => P.create(s, x(r, n, { method: e })); | ||
return t.create = (e) => U(x(e)), t.extend = (e) => U(x(r, e)), t.stop = ht, t; | ||
}, Kt = U(), Zt = Kt, Qt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, et = Zt.create({ headers: Qt }), Xt = { | ||
get: (r, t) => et.get(r, t).json(), | ||
post: (r, t) => et.post(r, t).json() | ||
}, st = Object.values(a), te = (r = "") => { | ||
const t = r.toUpperCase(), [e] = t.split("."); | ||
if (et.includes(e)) | ||
if (st.includes(e)) | ||
return !0; | ||
const [s] = t.split("/"); | ||
if (et.includes(s)) | ||
if (st.includes(s)) | ||
return !0; | ||
@@ -666,7 +666,7 @@ throw new Error( | ||
); | ||
}, I = 8, w = (r) => 10n ** BigInt(r), S = (r) => Math.log10(parseFloat(r.toString())); | ||
function P({ | ||
}, O = 8, A = (r) => 10n ** BigInt(r), C = (r) => Math.log10(parseFloat(r.toString())); | ||
function N({ | ||
value: r, | ||
bigIntDecimal: t = I, | ||
decimal: e = I | ||
bigIntDecimal: t = O, | ||
decimal: e = O | ||
}) { | ||
@@ -684,15 +684,15 @@ const s = r < 0n; | ||
} | ||
var v, C, y, R, N, dt, E, F, M, W; | ||
var T, I, w, S, j, mt, M, F, B, G; | ||
const K = class K { | ||
constructor(t) { | ||
$(this, v); | ||
$(this, y); | ||
$(this, N); | ||
$(this, E); | ||
$(this, M); | ||
R(this, T); | ||
R(this, w); | ||
R(this, j); | ||
R(this, M); | ||
R(this, B); | ||
f(this, "decimalMultiplier", 10n ** 8n); | ||
f(this, "bigIntValue", 0n); | ||
f(this, "decimal"); | ||
const e = G(t), s = typeof t == "object"; | ||
this.decimal = s ? t.decimal : void 0, this.decimalMultiplier = s && "decimalMultiplier" in t ? t.decimalMultiplier : w(Math.max(st(x(e)), this.decimal || 0)), m(this, N, dt).call(this, e); | ||
const e = W(t), s = typeof t == "object"; | ||
this.decimal = s ? t.decimal : void 0, this.decimalMultiplier = s && "decimalMultiplier" in t ? t.decimalMultiplier : A(Math.max(rt(k(e)), this.decimal || 0)), m(this, j, mt).call(this, e); | ||
} | ||
@@ -702,3 +702,3 @@ static fromBigInt(t, e) { | ||
decimal: e, | ||
value: P({ value: t, bigIntDecimal: e, decimal: e }) | ||
value: N({ value: t, bigIntDecimal: e, decimal: e }) | ||
}); | ||
@@ -712,3 +712,3 @@ } | ||
return this.fromBigInt( | ||
t.getBaseValue("bigint") * w(s) / w(e), | ||
t.getBaseValue("bigint") * A(s) / A(e), | ||
s | ||
@@ -721,27 +721,27 @@ ); | ||
add(...t) { | ||
return m(this, v, C).call(this, "add", ...t); | ||
return m(this, T, I).call(this, "add", ...t); | ||
} | ||
sub(...t) { | ||
return m(this, v, C).call(this, "sub", ...t); | ||
return m(this, T, I).call(this, "sub", ...t); | ||
} | ||
mul(...t) { | ||
return m(this, v, C).call(this, "mul", ...t); | ||
return m(this, T, I).call(this, "mul", ...t); | ||
} | ||
div(...t) { | ||
return m(this, v, C).call(this, "div", ...t); | ||
return m(this, T, I).call(this, "div", ...t); | ||
} | ||
gt(t) { | ||
return m(this, y, R).call(this, "gt", t); | ||
return m(this, w, S).call(this, "gt", t); | ||
} | ||
gte(t) { | ||
return m(this, y, R).call(this, "gte", t); | ||
return m(this, w, S).call(this, "gte", t); | ||
} | ||
lt(t) { | ||
return m(this, y, R).call(this, "lt", t); | ||
return m(this, w, S).call(this, "lt", t); | ||
} | ||
lte(t) { | ||
return m(this, y, R).call(this, "lte", t); | ||
return m(this, w, S).call(this, "lte", t); | ||
} | ||
eqValue(t) { | ||
return m(this, y, R).call(this, "eqValue", t); | ||
return m(this, w, S).call(this, "eqValue", t); | ||
} | ||
@@ -752,3 +752,3 @@ // @ts-expect-error False positive | ||
this.bigIntValue, | ||
this.decimal || S(this.decimalMultiplier) | ||
this.decimal || C(this.decimalMultiplier) | ||
); | ||
@@ -766,3 +766,3 @@ switch (t) { | ||
getBaseValue(t) { | ||
const e = this.decimalMultiplier / w(this.decimal || d.THOR), s = this.bigIntValue / e; | ||
const e = this.decimalMultiplier / A(this.decimal || d.THOR), s = this.bigIntValue / e; | ||
switch (t) { | ||
@@ -780,4 +780,4 @@ case "number": | ||
return t.bigIntValue; | ||
const s = G(t), n = x(s); | ||
return n === "0" || n === "undefined" ? 0n : m(this, M, W).call(this, n, e); | ||
const s = W(t), n = k(s); | ||
return n === "0" || n === "undefined" ? 0n : m(this, B, G).call(this, n, e); | ||
} | ||
@@ -828,5 +828,5 @@ toSignificant(t = 6) { | ||
formatBigIntToSafeValue(t, e) { | ||
const s = e || this.decimal || I, n = Math.max( | ||
const s = e || this.decimal || O, n = Math.max( | ||
s, | ||
S(this.decimalMultiplier) | ||
C(this.decimalMultiplier) | ||
), i = t < 0n, o = t.toString().substring(i ? 1 : 0), c = n - (o.length - 1), u = c > 0 ? "0".repeat(c) + o : o, h = u.length - n; | ||
@@ -840,4 +840,4 @@ let l = u.slice(-n); | ||
}; | ||
v = new WeakSet(), C = function(t, ...e) { | ||
const s = m(this, E, F).call(this, this, ...e), n = Math.max(s, S(this.decimalMultiplier)), i = w(n), o = e.reduce( | ||
T = new WeakSet(), I = function(t, ...e) { | ||
const s = m(this, M, F).call(this, this, ...e), n = Math.max(s, C(this.decimalMultiplier)), i = A(n), o = e.reduce( | ||
(u, h) => { | ||
@@ -863,3 +863,3 @@ const l = this.getBigIntValue(h, n); | ||
this.bigIntValue * i / this.decimalMultiplier | ||
), c = P({ | ||
), c = N({ | ||
bigIntDecimal: n, | ||
@@ -870,3 +870,3 @@ decimal: n, | ||
return new this.constructor({ | ||
decimalMultiplier: w(n), | ||
decimalMultiplier: A(n), | ||
decimal: this.decimal, | ||
@@ -876,4 +876,4 @@ value: c, | ||
}); | ||
}, y = new WeakSet(), R = function(t, ...e) { | ||
const s = m(this, E, F).call(this, this, ...e), n = this.getBigIntValue(e[0], s), i = this.getBigIntValue(this, s); | ||
}, w = new WeakSet(), S = function(t, ...e) { | ||
const s = m(this, M, F).call(this, this, ...e), n = this.getBigIntValue(e[0], s), i = this.getBigIntValue(this, s); | ||
switch (t) { | ||
@@ -891,13 +891,13 @@ case "gt": | ||
} | ||
}, N = new WeakSet(), dt = function(t) { | ||
const e = x(t) || "0"; | ||
this.bigIntValue = m(this, M, W).call(this, e); | ||
}, E = new WeakSet(), F = function(...t) { | ||
const e = t.map((s) => typeof s == "object" ? s.decimal || S(s.decimalMultiplier) : st(x(s))).filter(Boolean); | ||
return Math.max(...e, I); | ||
}, M = new WeakSet(), W = function(t, e) { | ||
const s = e ? w(e) : this.decimalMultiplier, n = S(s), [i = "", o = ""] = t.split("."); | ||
}, j = new WeakSet(), mt = function(t) { | ||
const e = k(t) || "0"; | ||
this.bigIntValue = m(this, B, G).call(this, e); | ||
}, M = new WeakSet(), F = function(...t) { | ||
const e = t.map((s) => typeof s == "object" ? s.decimal || C(s.decimalMultiplier) : rt(k(s))).filter(Boolean); | ||
return Math.max(...e, O); | ||
}, B = new WeakSet(), G = function(t, e) { | ||
const s = e ? A(e) : this.decimalMultiplier, n = C(s), [i = "", o = ""] = t.split("."); | ||
return BigInt(`${i}${o.padEnd(n, "0")}`); | ||
}; | ||
let O = K; | ||
let E = K; | ||
const ee = Intl.NumberFormat("fullwide", { | ||
@@ -907,30 +907,30 @@ useGrouping: !1, | ||
}); | ||
function x(r) { | ||
const e = `${typeof r == "number" ? ee.format(r) : G(r)}`.replaceAll(",", ".").split("."); | ||
function k(r) { | ||
const e = `${typeof r == "number" ? ee.format(r) : W(r)}`.replaceAll(",", ".").split("."); | ||
return e.length > 1 ? `${e.slice(0, -1).join("")}.${e.at(-1)}` : e[0]; | ||
} | ||
function st(r) { | ||
function rt(r) { | ||
var e; | ||
const t = ((e = r.split(".")[1]) == null ? void 0 : e.length) || 0; | ||
return Math.max(t, I); | ||
return Math.max(t, O); | ||
} | ||
function G(r) { | ||
function W(r) { | ||
return typeof r == "object" ? "getValue" in r ? r.getValue("string") : r.value : r; | ||
} | ||
const k = (r, t) => typeof r == "bigint" ? P({ value: r, bigIntDecimal: t, decimal: t }) : r; | ||
const V = (r, t) => typeof r == "bigint" ? N({ value: r, bigIntDecimal: t, decimal: t }) : r; | ||
let Y; | ||
const rt = (r) => { | ||
const nt = (r) => { | ||
if (!Y) | ||
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first"); | ||
return Y.get(r.toUpperCase()) || { decimal: d.THOR, identifier: "" }; | ||
}, nt = async (r, t = 0) => { | ||
}, it = async (r, t = 0) => { | ||
te(r); | ||
const e = await Ct(z(r)), s = k(t, e); | ||
return new A({ decimal: e, value: s, identifier: r }); | ||
const e = await Ct(z(r)), s = V(t, e); | ||
return new v({ decimal: e, value: s, identifier: r }); | ||
}; | ||
class A extends O { | ||
class v extends E { | ||
constructor(e) { | ||
const s = "identifier" in e ? e.identifier : `${e.chain}.${e.symbol}`; | ||
super( | ||
e.value instanceof O ? e.value : { decimal: e.decimal, value: e.value } | ||
e.value instanceof E ? e.value : { decimal: e.decimal, value: e.value } | ||
); | ||
@@ -965,18 +965,20 @@ f(this, "address"); | ||
static async fromString(e, s = 0) { | ||
return nt(e, s); | ||
return it(e, s); | ||
} | ||
static fromStringSync(e, s = 0) { | ||
const { isSynthetic: n } = z(e), { | ||
tax: i, | ||
decimal: o, | ||
identifier: c | ||
} = rt(e), u = k(s, o); | ||
return c ? new A({ tax: i, decimal: o, identifier: c, value: u }) : n ? new A({ tax: i, decimal: 8, identifier: e, value: u }) : void 0; | ||
const { isSynthetic: n, symbol: i, chain: o, isGasAsset: c, ticker: u, address: h } = z(e); | ||
console.log("isSynthetic: ", { isSynthetic: n, symbol: i, chain: o, isGasAsset: c, ticker: u, address: h }); | ||
const { | ||
tax: l, | ||
decimal: _, | ||
identifier: g | ||
} = nt(e), $ = V(s, _); | ||
return g ? new v({ tax: l, decimal: _, identifier: g, value: $ }) : n ? new v({ tax: l, decimal: 8, identifier: e, value: $ }) : void 0; | ||
} | ||
static async fromIdentifier(e, s = 0) { | ||
return nt(e, s); | ||
return it(e, s); | ||
} | ||
static fromIdentifierSync(e, s = 0) { | ||
const { decimal: n, identifier: i } = rt(e), o = k(s, n); | ||
return new A({ decimal: n, identifier: i, value: o }); | ||
const { decimal: n, identifier: i } = nt(e), o = V(s, n); | ||
return new v({ decimal: n, identifier: i, value: o }); | ||
} | ||
@@ -987,4 +989,4 @@ static fromChainOrSignature(e, s = 0) { | ||
throw Error("unknown coin! " + e); | ||
const o = k(s, n); | ||
return new A({ value: o, decimal: n, identifier: i }); | ||
const o = V(s, n); | ||
return new v({ value: o, decimal: n, identifier: i }); | ||
} | ||
@@ -1003,5 +1005,5 @@ static async loadStaticAssets() { | ||
Y = [i, ...Object.values(o)].reduce( | ||
(u, { tokens: h }) => (h.forEach(({ identifier: l, chain: _, ...T }) => { | ||
const j = "decimals" in T ? T.decimals : d[_]; | ||
u.set(l, { identifier: l, decimal: j }); | ||
(u, { tokens: h }) => (h.forEach(({ identifier: l, chain: _, ...g }) => { | ||
const $ = "decimals" in g ? g.decimals : d[_]; | ||
u.set(l, { identifier: l, decimal: $ }); | ||
}), u), | ||
@@ -1022,3 +1024,3 @@ /* @__PURE__ */ new Map() | ||
const ge = (r) => { | ||
const t = A.fromChainOrSignature(r); | ||
const t = v.fromChainOrSignature(r); | ||
switch (r) { | ||
@@ -1047,3 +1049,3 @@ case a.Bitcoin: | ||
chain: i, | ||
isGasAsset: at({ chain: i, symbol: o }), | ||
isGasAsset: ot({ chain: i, symbol: o }), | ||
isSynthetic: t, | ||
@@ -1112,8 +1114,8 @@ symbol: (t ? `${e}/` : "") + (u ? `${c}-${(u == null ? void 0 : u.toLowerCase()) ?? ""}` : o), | ||
}; | ||
class mt extends Error { | ||
class pt extends Error { | ||
constructor(t, e) { | ||
console.error(e, { stack: e == null ? void 0 : e.stack, message: e == null ? void 0 : e.message }), super(t, { cause: { code: se[t], message: t } }), Object.setPrototypeOf(this, mt.prototype); | ||
console.error(e, { stack: e == null ? void 0 : e.stack, message: e == null ? void 0 : e.message }), super(t, { cause: { code: se[t], message: t } }), Object.setPrototypeOf(this, pt.prototype); | ||
} | ||
} | ||
class b extends O { | ||
class y extends E { | ||
eq(t) { | ||
@@ -1123,5 +1125,5 @@ return this.eqValue(t); | ||
static fromBigInt(t, e) { | ||
return new b({ | ||
return new y({ | ||
decimal: e, | ||
value: P({ value: t, bigIntDecimal: e, decimal: e }) | ||
value: N({ value: t, bigIntDecimal: e, decimal: e }) | ||
}); | ||
@@ -1131,11 +1133,11 @@ } | ||
export { | ||
A as AssetValue, | ||
O as BigIntArithmetics, | ||
v as AssetValue, | ||
E as BigIntArithmetics, | ||
Xt as RequestClient, | ||
mt as SwapKitError, | ||
b as SwapKitNumber, | ||
pt as SwapKitError, | ||
y as SwapKitNumber, | ||
ae as assetFromString, | ||
_e as derivationPathToString, | ||
oe as filterAssets, | ||
P as formatBigIntToSafeValue, | ||
N as formatBigIntToSafeValue, | ||
ie as gasFeeMultiplier, | ||
@@ -1153,7 +1155,7 @@ Ot as getAssetType, | ||
ge as getMinAmountByChain, | ||
qt as getSymmetricPoolShare, | ||
kt as getSymmetricPoolShare, | ||
le as getSymmetricWithdraw, | ||
pe as getTHORNameCost, | ||
at as isGasAsset, | ||
ot as isGasAsset, | ||
fe as validateTHORName | ||
}; |
@@ -11,5 +11,5 @@ { | ||
"vitest": "0.34.6", | ||
"@internal/config": "2.1.0", | ||
"@coinmasters/tokens": "3.1.0", | ||
"@coinmasters/types": "4.1.0" | ||
"@coinmasters/tokens": "3.2.0", | ||
"@internal/config": "2.2.0", | ||
"@coinmasters/types": "4.2.0" | ||
}, | ||
@@ -20,4 +20,4 @@ "eslintConfig": { | ||
"peerDependencies": { | ||
"@coinmasters/tokens": "3.1.0", | ||
"@coinmasters/types": "4.1.0" | ||
"@coinmasters/tokens": "3.2.0", | ||
"@coinmasters/types": "4.2.0" | ||
}, | ||
@@ -47,3 +47,3 @@ "exports": { | ||
"types": "./dist/index.d.ts", | ||
"version": "5.0.0", | ||
"version": "6.0.0", | ||
"scripts": { | ||
@@ -50,0 +50,0 @@ "build": "vite build", |
@@ -131,3 +131,4 @@ import type { | ||
static fromStringSync(assetString: string, value: NumberPrimitives = 0) { | ||
const { isSynthetic } = getAssetInfo(assetString); | ||
const { isSynthetic, symbol, chain, isGasAsset, ticker, address } = getAssetInfo(assetString); | ||
console.log('isSynthetic: ', { isSynthetic, symbol, chain, isGasAsset, ticker, address }); | ||
const { | ||
@@ -134,0 +135,0 @@ tax, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
204936
3799