@swapkit/helpers
Advanced tools
Comparing version 1.0.0-rc.22 to 1.0.0-rc.23
@@ -13,6 +13,6 @@ var gt = Object.defineProperty; | ||
var m = (s, t, e) => (yt(s, t, "access private method"), e); | ||
import { FeeOption as L, BaseDecimal as d, Chain as o, ChainToRPC as wt, MemoType as g } from "@swapkit/types"; | ||
const At = "0x313ce567", nt = async ({ chain: s, to: t }) => { | ||
import { FeeOption as L, BaseDecimal as d, Chain as o, EVMChainList as wt, ChainToRPC as At, MemoType as g } from "@swapkit/types"; | ||
const vt = "0x313ce567", nt = async ({ chain: s, to: t }) => { | ||
try { | ||
const { result: e } = await Qt.post(wt[s], { | ||
const { result: e } = await Zt.post(At[s], { | ||
headers: { | ||
@@ -27,3 +27,3 @@ accept: "*/*", | ||
method: "eth_call", | ||
params: [{ to: t.toLowerCase(), data: At }, "latest"] | ||
params: [{ to: t.toLowerCase(), data: vt }, "latest"] | ||
}) | ||
@@ -40,6 +40,6 @@ }); | ||
return t != null && t.startsWith("0x") ? nt({ chain: o.Ethereum, to: t }) : d.ETH; | ||
}, vt = async (s) => { | ||
}, $t = async (s) => { | ||
const [, t] = s.split("-"); | ||
return t != null && t.startsWith("0x") ? nt({ chain: o.Avalanche, to: t.toLowerCase() }) : d.AVAX; | ||
}, $t = async (s) => s === o.BinanceSmartChain ? d.BSC : d.BSC, Rt = async ({ chain: s, symbol: t }) => { | ||
}, Rt = async (s) => s === o.BinanceSmartChain ? d.BSC : d.BSC, St = async ({ chain: s, symbol: t }) => { | ||
switch (s) { | ||
@@ -49,13 +49,13 @@ case o.Ethereum: | ||
case o.Avalanche: | ||
return vt(t); | ||
return $t(t); | ||
case o.BinanceSmartChain: | ||
return $t(t); | ||
return Rt(t); | ||
default: | ||
return d[s]; | ||
} | ||
}, re = { | ||
}, ne = { | ||
[L.Average]: 1.2, | ||
[L.Fast]: 1.5, | ||
[L.Fastest]: 2 | ||
}, St = ({ chain: s, symbol: t }) => { | ||
}, Ct = ({ chain: s, symbol: t }) => { | ||
switch (s) { | ||
@@ -86,3 +86,3 @@ case o.Bitcoin: | ||
} | ||
}, Ct = (s) => { | ||
}, It = (s) => { | ||
switch (s) { | ||
@@ -116,3 +116,3 @@ case "ETH.THOR": | ||
} | ||
}, It = ({ chain: s, symbol: t }) => { | ||
}, Et = ({ chain: s, symbol: t }) => { | ||
if (t.includes("/")) | ||
@@ -147,12 +147,12 @@ return "Synth"; | ||
} | ||
}, se = (s) => { | ||
}, ie = (s) => { | ||
var c; | ||
const [t, ...e] = s.split("."), r = s.includes("/"), n = e.join("."), i = (c = n == null ? void 0 : n.split("-")) == null ? void 0 : c[0]; | ||
return { chain: t, symbol: n, ticker: i, synth: r }; | ||
}, Et = new RegExp( | ||
}, Ot = new RegExp( | ||
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/, | ||
"gmi" | ||
), ne = (s) => s.filter( | ||
(t) => !Et.test(t.toString()) && !t.toString().includes("undefined") | ||
), Ot = ({ | ||
), Bt = (s) => wt.includes(s.chain) ? !s.isGasAsset && s.address && !Number.isNaN(s.decimal) : !0, oe = (s) => s.filter( | ||
(t) => !t.toString().includes("undefined") && !Ot.test(t.toString()) && Bt(t) | ||
), Mt = ({ | ||
liquidityUnits: s, | ||
@@ -164,3 +164,3 @@ poolUnits: t, | ||
return c.mul(a.sub(u).add(l)).div(h); | ||
}, Bt = ({ | ||
}, Vt = ({ | ||
liquidityUnits: s, | ||
@@ -172,3 +172,3 @@ poolUnits: t, | ||
return h.div(_); | ||
}, ie = ({ | ||
}, ae = ({ | ||
percent: s, | ||
@@ -178,3 +178,3 @@ runeDepth: t, | ||
poolUnits: r | ||
}) => Ot({ runeDepth: t, liquidityUnits: e, poolUnits: r }).mul(s), oe = ({ | ||
}) => Mt({ runeDepth: t, liquidityUnits: e, poolUnits: r }).mul(s), ce = ({ | ||
percent: s, | ||
@@ -184,3 +184,3 @@ assetDepth: t, | ||
poolUnits: r | ||
}) => Bt({ assetDepth: t, liquidityUnits: e, poolUnits: r }).mul(s), p = (s) => b.fromBigInt(BigInt(s), d.THOR), Mt = ({ | ||
}) => Vt({ assetDepth: t, liquidityUnits: e, poolUnits: r }).mul(s), p = (s) => b.fromBigInt(BigInt(s), d.THOR), kt = ({ | ||
liquidityUnits: s, | ||
@@ -193,3 +193,3 @@ poolUnits: t, | ||
runeAmount: p(e).mul(s).div(t) | ||
}), ae = ({ | ||
}), ue = ({ | ||
liquidityUnits: s, | ||
@@ -201,6 +201,6 @@ poolUnits: t, | ||
}) => Object.fromEntries( | ||
Object.entries(Mt({ liquidityUnits: s, poolUnits: t, runeDepth: e, assetDepth: r })).map( | ||
Object.entries(kt({ liquidityUnits: s, poolUnits: t, runeDepth: e, assetDepth: r })).map( | ||
([i, c]) => [i, c.mul(n)] | ||
) | ||
), ce = ({ | ||
), le = ({ | ||
runeDepth: s, | ||
@@ -213,3 +213,3 @@ poolUnits: t, | ||
}) => { | ||
const c = new b({ value: s, decimal: 8 }), a = new b({ value: e, decimal: 8 }), u = new b({ value: t, decimal: 8 }), l = new b({ value: n, decimal: 8 }), h = new b({ value: i, decimal: 8 }), _ = l.mul(a), v = h.mul(c), j = l.mul(h), mt = c.mul(a), pt = u.mul(_.add(v.add(j.mul(2)))), ft = _.add(v.add(mt.mul(2))), Q = pt.div(ft), H = p(r).add(Q); | ||
const c = new b({ value: s, decimal: 8 }), a = new b({ value: e, decimal: 8 }), u = new b({ value: t, decimal: 8 }), l = new b({ value: n, decimal: 8 }), h = new b({ value: i, decimal: 8 }), _ = l.mul(a), T = h.mul(c), j = l.mul(h), mt = c.mul(a), pt = u.mul(_.add(T.add(j.mul(2)))), ft = _.add(T.add(mt.mul(2))), Q = pt.div(ft), H = p(r).add(Q); | ||
if (Q.getBaseValue("number") === 0) | ||
@@ -219,3 +219,3 @@ return H.div(u).getBaseValue("number"); | ||
return H.div(_t).getBaseValue("number"); | ||
}, ue = ({ | ||
}, he = ({ | ||
runeAmount: s, | ||
@@ -230,7 +230,7 @@ assetAmount: t, | ||
return Math.abs(u.div(l).getBaseValue("number")); | ||
}, Vt = ({ | ||
}, qt = ({ | ||
symbol: s, | ||
ticker: t, | ||
chain: e | ||
}) => e === "ETH" && t !== "ETH" ? `${t}-${s.slice(-3)}` : s, le = (s, t) => { | ||
}) => e === "ETH" && t !== "ETH" ? `${t}-${s.slice(-3)}` : s, de = (s, t) => { | ||
switch (s) { | ||
@@ -255,3 +255,3 @@ case g.LEAVE: | ||
case g.WITHDRAW: { | ||
const { chain: e, ticker: r, symbol: n, basisPoints: i, targetAssetString: c, singleSide: a } = t, u = !a && c ? `:${c}` : "", l = Vt({ chain: e, symbol: n, ticker: r }); | ||
const { chain: e, ticker: r, symbol: n, basisPoints: i, targetAssetString: c, singleSide: a } = t, u = !a && c ? `:${c}` : "", l = qt({ chain: e, symbol: n, ticker: r }); | ||
return `${s}:${e}${a ? "/" : "."}${l}:${i}${u}`; | ||
@@ -267,7 +267,7 @@ } | ||
} | ||
}, he = (s) => { | ||
}, me = (s) => { | ||
if (s < 0) | ||
throw new Error("Invalid number of year"); | ||
return 10 + s; | ||
}, de = (s) => { | ||
}, pe = (s) => { | ||
if (s.length > 30) | ||
@@ -277,3 +277,3 @@ return !1; | ||
return !!s.match(t); | ||
}, me = ([s, t, e, r, n]) => `${s}'/${t}'/${e}'/${r}${typeof n != "number" ? "" : `/${n}`}`; | ||
}, fe = ([s, t, e, r, n]) => `${s}'/${t}'/${e}'/${r}${typeof n != "number" ? "" : `/${n}`}`; | ||
class X extends Error { | ||
@@ -331,3 +331,3 @@ constructor(t, e, r) { | ||
return t; | ||
}, kt = (() => { | ||
}, xt = (() => { | ||
let s = !1, t = !1; | ||
@@ -343,3 +343,3 @@ const e = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function"; | ||
}).headers.has("Content-Type")), s && !t; | ||
})(), qt = typeof globalThis.AbortController == "function", xt = typeof globalThis.ReadableStream == "function", Pt = typeof globalThis.FormData == "function", at = ["get", "post", "put", "patch", "head", "delete"], Nt = { | ||
})(), Pt = typeof globalThis.AbortController == "function", Nt = typeof globalThis.ReadableStream == "function", jt = typeof globalThis.FormData == "function", at = ["get", "post", "put", "patch", "head", "delete"], Ht = { | ||
json: "application/json", | ||
@@ -350,3 +350,3 @@ text: "text/*", | ||
blob: "*/*" | ||
}, D = 2147483647, ct = Symbol("stop"), jt = { | ||
}, D = 2147483647, ct = Symbol("stop"), Lt = { | ||
json: !0, | ||
@@ -362,3 +362,3 @@ parseJson: !0, | ||
fetch: !0 | ||
}, Ht = { | ||
}, Dt = { | ||
method: !0, | ||
@@ -379,6 +379,6 @@ headers: !0, | ||
duplex: !0 | ||
}, Lt = (s) => at.includes(s) ? s.toUpperCase() : s, Dt = ["get", "put", "head", "delete", "options", "trace"], Ut = [408, 413, 429, 500, 502, 503, 504], ut = [413, 429, 503], Z = { | ||
}, Ut = (s) => at.includes(s) ? s.toUpperCase() : s, Ft = ["get", "put", "head", "delete", "options", "trace"], Wt = [408, 413, 429, 500, 502, 503, 504], ut = [413, 429, 503], Z = { | ||
limit: 2, | ||
methods: Dt, | ||
statusCodes: Ut, | ||
methods: Ft, | ||
statusCodes: Wt, | ||
afterStatusCodes: ut, | ||
@@ -388,3 +388,3 @@ maxRetryAfter: Number.POSITIVE_INFINITY, | ||
delay: (s) => 0.3 * 2 ** (s - 1) * 1e3 | ||
}, Ft = (s = {}) => { | ||
}, Gt = (s = {}) => { | ||
if (typeof s == "number") | ||
@@ -405,3 +405,3 @@ return { | ||
}; | ||
async function Wt(s, t, e, r) { | ||
async function Yt(s, t, e, r) { | ||
return new Promise((n, i) => { | ||
@@ -416,3 +416,3 @@ const c = setTimeout(() => { | ||
} | ||
async function Gt(s, { signal: t }) { | ||
async function zt(s, { signal: t }) { | ||
return new Promise((e, r) => { | ||
@@ -428,6 +428,6 @@ t && (t.throwIfAborted(), t.addEventListener("abort", n, { once: !0 })); | ||
} | ||
const Yt = (s, t) => { | ||
const Jt = (s, t) => { | ||
const e = {}; | ||
for (const r in t) | ||
!(r in Ht) && !(r in jt) && !(r in s) && (e[r] = t[r]); | ||
!(r in Dt) && !(r in Lt) && !(r in s) && (e[r] = t[r]); | ||
return e; | ||
@@ -455,3 +455,3 @@ }; | ||
throw new TypeError("The `onDownloadProgress` option must be a function"); | ||
if (!xt) | ||
if (!Nt) | ||
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing."); | ||
@@ -462,3 +462,3 @@ return r._stream(a.clone(), r._options.onDownloadProgress); | ||
}, c = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(n) : n(); | ||
for (const [a, u] of Object.entries(Nt)) | ||
for (const [a, u] of Object.entries(Ht)) | ||
c[a] = async () => { | ||
@@ -515,6 +515,6 @@ r.request.headers.set("accept", r.request.headers.get("accept") || u); | ||
}, e.hooks), | ||
method: Lt(e.method ?? this._input.method), | ||
method: Ut(e.method ?? this._input.method), | ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
prefixUrl: String(e.prefixUrl || ""), | ||
retry: Ft(e.retry), | ||
retry: Gt(e.retry), | ||
throwHttpErrors: e.throwHttpErrors !== !1, | ||
@@ -530,3 +530,3 @@ timeout: e.timeout ?? 1e4, | ||
} | ||
if (qt) { | ||
if (Pt) { | ||
if (this.abortController = new globalThis.AbortController(), this._options.signal) { | ||
@@ -540,5 +540,5 @@ const r = this._options.signal; | ||
} | ||
if (kt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) { | ||
if (xt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) { | ||
const n = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, n); | ||
(Pt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(i, { ...this.request }), this._options); | ||
(jt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(i, { ...this.request }), this._options); | ||
} | ||
@@ -574,3 +574,3 @@ this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body })); | ||
if (r !== 0 && this._retryCount > 0) { | ||
await Gt(r, { signal: this._options.signal }); | ||
await zt(r, { signal: this._options.signal }); | ||
for (const n of this._options.hooks.beforeRetry) | ||
@@ -599,4 +599,4 @@ if (await n({ | ||
} | ||
const t = Yt(this.request, this._options); | ||
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Wt(this.request.clone(), t, this.abortController, this._options); | ||
const t = Jt(this.request, this._options); | ||
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Yt(this.request.clone(), t, this.abortController, this._options); | ||
} | ||
@@ -643,6 +643,6 @@ /* istanbul ignore next */ | ||
return t.create = (e) => F(M(e)), t.extend = (e) => F(M(s, e)), t.stop = ct, t; | ||
}, zt = F(), Jt = zt, Kt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, tt = Jt.create({ headers: Kt }), Qt = { | ||
}, Kt = F(), Qt = Kt, Xt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, tt = Qt.create({ headers: Xt }), Zt = { | ||
get: (s, t) => tt.get(s, t).json(), | ||
post: (s, t) => tt.post(s, t).json() | ||
}, et = Object.values(o), Xt = (s = "") => { | ||
}, et = Object.values(o), te = (s = "") => { | ||
const t = s.toUpperCase(), [e] = t.split("."); | ||
@@ -674,3 +674,3 @@ if (et.includes(e)) | ||
} | ||
var A, S, P, lt, N, ht, O, W, T, C, B, G; | ||
var A, S, P, lt, N, ht, O, W, v, C, B, G; | ||
const K = class K { | ||
@@ -682,3 +682,3 @@ constructor(t) { | ||
y(this, O); | ||
y(this, T); | ||
y(this, v); | ||
y(this, B); | ||
@@ -690,3 +690,3 @@ f(this, "decimalMultiplier", 10n ** 8n); | ||
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = $( | ||
Math.max(m(this, B, G).call(this, m(this, T, C).call(this, e)), this.decimal || 0) | ||
Math.max(m(this, B, G).call(this, m(this, v, C).call(this, e)), this.decimal || 0) | ||
), m(this, P, lt).call(this, e); | ||
@@ -768,3 +768,3 @@ } | ||
return t.bigIntValue; | ||
const r = U(t), n = m(this, T, C).call(this, r); | ||
const r = U(t), n = m(this, v, C).call(this, r); | ||
return n === "0" || n === "undefined" ? 0n : m(this, O, W).call(this, n, e); | ||
@@ -856,7 +856,7 @@ } | ||
}, P = new WeakSet(), lt = function(t) { | ||
const e = m(this, T, C).call(this, t) || "0"; | ||
const e = m(this, v, C).call(this, t) || "0"; | ||
this.bigIntValue = m(this, O, W).call(this, e); | ||
}, N = new WeakSet(), ht = function(...t) { | ||
const e = t.map( | ||
(r) => typeof r == "object" ? r.decimal || R(r.decimalMultiplier) : m(this, B, G).call(this, m(this, T, C).call(this, r)) | ||
(r) => typeof r == "object" ? r.decimal || R(r.decimalMultiplier) : m(this, B, G).call(this, m(this, v, C).call(this, r)) | ||
).filter(Boolean); | ||
@@ -867,3 +867,3 @@ return Math.max(...e, I); | ||
return BigInt(`${i}${c.padEnd(n, "0")}`); | ||
}, T = new WeakSet(), C = function(t) { | ||
}, v = new WeakSet(), C = function(t) { | ||
const r = `${typeof t == "number" ? Number(t).toLocaleString("fullwide", { | ||
@@ -890,4 +890,4 @@ useGrouping: !1, | ||
}, st = async (s, t = 0) => { | ||
Xt(s); | ||
const e = await Rt(z(s)), r = k(t, e); | ||
te(s); | ||
const e = await St(z(s)), r = k(t, e); | ||
return new w({ decimal: e, value: r, identifier: s }); | ||
@@ -908,3 +908,3 @@ }; | ||
const r = "identifier" in e ? e.identifier : `${e.chain}.${e.symbol}`, n = z(r); | ||
this.type = It(n), this.chain = n.chain, this.ticker = n.ticker, this.symbol = n.symbol, this.address = n.address, this.isSynthetic = n.isSynthetic, this.isGasAsset = n.isGasAsset; | ||
this.type = Et(n), this.chain = n.chain, this.ticker = n.ticker, this.symbol = n.symbol, this.address = n.address, this.isSynthetic = n.isSynthetic, this.isGasAsset = n.isGasAsset; | ||
} | ||
@@ -941,3 +941,3 @@ get assetValue() { | ||
static fromChainOrSignature(e, r = 0) { | ||
const { decimal: n, identifier: i } = Ct(e), c = k(r, n); | ||
const { decimal: n, identifier: i } = It(e), c = k(r, n); | ||
return new w({ value: c, decimal: n, identifier: i }); | ||
@@ -957,4 +957,4 @@ } | ||
Y = [i, ...Object.values(c)].reduce( | ||
(u, { tokens: l }) => (l.forEach(({ identifier: h, chain: _, ...v }) => { | ||
const j = "decimals" in v ? v.decimals : d[_]; | ||
(u, { tokens: l }) => (l.forEach(({ identifier: h, chain: _, ...T }) => { | ||
const j = "decimals" in T ? T.decimals : d[_]; | ||
u.set(h, { identifier: h, decimal: j }); | ||
@@ -975,3 +975,3 @@ }), u), | ||
} | ||
const pe = (s) => { | ||
const _e = (s) => { | ||
const t = w.fromChainOrSignature(s); | ||
@@ -999,3 +999,3 @@ switch (s) { | ||
chain: i, | ||
isGasAsset: St({ chain: i, symbol: c }), | ||
isGasAsset: Ct({ chain: i, symbol: c }), | ||
isSynthetic: t, | ||
@@ -1005,3 +1005,3 @@ symbol: (t ? `${e}/` : "") + (u ? `${a}-${(u == null ? void 0 : u.toLowerCase()) ?? ""}` : c), | ||
}; | ||
}, Zt = { | ||
}, ee = { | ||
/** | ||
@@ -1065,3 +1065,3 @@ * Core | ||
constructor(t, e) { | ||
console.error(e), super(t, { cause: { code: Zt[t], message: t } }), Object.setPrototypeOf(this, dt.prototype); | ||
console.error(e), super(t, { cause: { code: ee[t], message: t } }), Object.setPrototypeOf(this, dt.prototype); | ||
} | ||
@@ -1083,26 +1083,26 @@ } | ||
E as BigIntArithmetics, | ||
Qt as RequestClient, | ||
Zt as RequestClient, | ||
dt as SwapKitError, | ||
b as SwapKitNumber, | ||
se as assetFromString, | ||
me as derivationPathToString, | ||
ne as filterAssets, | ||
ie as assetFromString, | ||
fe as derivationPathToString, | ||
oe as filterAssets, | ||
x as formatBigIntToSafeValue, | ||
re as gasFeeMultiplier, | ||
It as getAssetType, | ||
Bt as getAsymmetricAssetShare, | ||
oe as getAsymmetricAssetWithdrawAmount, | ||
Ot as getAsymmetricRuneShare, | ||
ie as getAsymmetricRuneWithdrawAmount, | ||
Ct as getCommonAssetInfo, | ||
Rt as getDecimal, | ||
ce as getEstimatedPoolShare, | ||
ue as getLiquiditySlippage, | ||
le as getMemoFor, | ||
pe as getMinAmountByChain, | ||
Mt as getSymmetricPoolShare, | ||
ae as getSymmetricWithdraw, | ||
he as getTHORNameCost, | ||
St as isGasAsset, | ||
de as validateTHORName | ||
ne as gasFeeMultiplier, | ||
Et as getAssetType, | ||
Vt as getAsymmetricAssetShare, | ||
ce as getAsymmetricAssetWithdrawAmount, | ||
Mt as getAsymmetricRuneShare, | ||
ae as getAsymmetricRuneWithdrawAmount, | ||
It as getCommonAssetInfo, | ||
St as getDecimal, | ||
le as getEstimatedPoolShare, | ||
he as getLiquiditySlippage, | ||
de as getMemoFor, | ||
_e as getMinAmountByChain, | ||
kt as getSymmetricPoolShare, | ||
ue as getSymmetricWithdraw, | ||
me as getTHORNameCost, | ||
Ct as isGasAsset, | ||
pe as validateTHORName | ||
}; |
@@ -45,3 +45,3 @@ { | ||
"types": "./dist/index.d.ts", | ||
"version": "1.0.0-rc.22", | ||
"version": "1.0.0-rc.23", | ||
"scripts": { | ||
@@ -48,0 +48,0 @@ "build": "vite build", |
import type { EVMChain } from '@swapkit/types'; | ||
import { BaseDecimal, Chain, ChainToRPC, FeeOption } from '@swapkit/types'; | ||
import { BaseDecimal, Chain, ChainToRPC, EVMChainList, FeeOption } from '@swapkit/types'; | ||
@@ -189,6 +189,15 @@ import { type AssetValue, RequestClient } from '../index.ts'; | ||
); | ||
const evmAssetHasAddress = (asset: AssetValue) => { | ||
if (!EVMChainList.includes(asset.chain as EVMChain)) return true; | ||
return !asset.isGasAsset && asset.address && !Number.isNaN(asset.decimal); | ||
}; | ||
export const filterAssets = (assets: AssetValue[]) => | ||
assets.filter( | ||
(asset) => | ||
!potentialScamRegex.test(asset.toString()) && !asset.toString().includes('undefined'), | ||
!asset.toString().includes('undefined') && | ||
!potentialScamRegex.test(asset.toString()) && | ||
evmAssetHasAddress(asset), | ||
); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196338
3588