Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swapkit/helpers

Package Overview
Dependencies
Maintainers
1
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swapkit/helpers - npm Package Compare versions

Comparing version 1.0.0-rc.56 to 1.0.0-rc.57

83

dist/index.es.js

@@ -13,3 +13,3 @@ var bt = Object.defineProperty;

var m = (s, t, e) => (wt(s, t, "access private method"), e);
import { FeeOption as L, BaseDecimal as d, Chain as o, EVMChainList as At, ChainToRPC as $t, MemoType as _ } from "@swapkit/types";
import { FeeOption as U, BaseDecimal as d, Chain as o, EVMChainList as At, ChainToRPC as $t, MemoType as _ } from "@swapkit/types";
const vt = "0x313ce567", nt = async ({ chain: s, to: t }) => {

@@ -39,6 +39,6 @@ try {

return t != null && t.startsWith("0x") ? nt({ chain: o.Ethereum, to: t }) : d.ETH;
}, Rt = async (s) => {
}, Ct = async (s) => {
const [, t] = s.split("-");
return t != null && t.startsWith("0x") ? nt({ chain: o.Avalanche, to: t.toLowerCase() }) : d.AVAX;
}, Ct = async (s) => s === o.BinanceSmartChain ? d.BSC : d.BSC, St = async ({ chain: s, symbol: t }) => {
}, Rt = async (s) => s === o.BinanceSmartChain ? d.BSC : d.BSC, St = async ({ chain: s, symbol: t }) => {
switch (s) {

@@ -48,5 +48,5 @@ case o.Ethereum:

case o.Avalanche:
return Ct(t);
case o.BinanceSmartChain:
return Rt(t);
case o.BinanceSmartChain:
return Ct(t);
default:

@@ -56,5 +56,5 @@ return d[s];

}, ne = {
[L.Average]: 1.2,
[L.Fast]: 1.5,
[L.Fastest]: 2
[U.Average]: 1.2,
[U.Fast]: 1.5,
[U.Fastest]: 2
}, it = ({ chain: s, symbol: t }) => {

@@ -366,3 +366,3 @@ switch (s) {

}).headers.has("Content-Type")), s && !t;
})(), Vt = typeof globalThis.AbortController == "function", kt = typeof globalThis.ReadableStream == "function", Nt = typeof globalThis.FormData == "function", ct = ["get", "post", "put", "patch", "head", "delete"], jt = {
})(), Vt = typeof globalThis.AbortController == "function", kt = typeof globalThis.ReadableStream == "function", jt = typeof globalThis.FormData == "function", ct = ["get", "post", "put", "patch", "head", "delete"], Nt = {
json: "application/json",

@@ -373,3 +373,3 @@ text: "text/*",

blob: "*/*"
}, U = 2147483647, ut = Symbol("stop"), Ht = {
}, L = 2147483647, ut = Symbol("stop"), Ht = {
json: !0,

@@ -401,5 +401,5 @@ parseJson: !0,

duplex: !0
}, Lt = (s) => ct.includes(s) ? s.toUpperCase() : s, Ut = ["get", "put", "head", "delete", "options", "trace"], Ft = [408, 413, 429, 500, 502, 503, 504], lt = [413, 429, 503], Z = {
}, Ut = (s) => ct.includes(s) ? s.toUpperCase() : s, Lt = ["get", "put", "head", "delete", "options", "trace"], Ft = [408, 413, 429, 500, 502, 503, 504], lt = [413, 429, 503], Z = {
limit: 2,
methods: Ut,
methods: Lt,
statusCodes: Ft,

@@ -456,4 +456,4 @@ afterStatusCodes: lt,

const r = new V(t, e), n = async () => {
if (typeof r._options.timeout == "number" && r._options.timeout > U)
throw new RangeError(`The \`timeout\` option cannot be greater than ${U}`);
if (typeof r._options.timeout == "number" && r._options.timeout > L)
throw new RangeError(`The \`timeout\` option cannot be greater than ${L}`);
await Promise.resolve();

@@ -480,3 +480,3 @@ let a = await r._fetch();

}, c = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(n) : n();
for (const [a, u] of Object.entries(jt))
for (const [a, u] of Object.entries(Nt))
c[a] = async () => {

@@ -533,3 +533,3 @@ 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

@@ -559,3 +559,3 @@ prefixUrl: String(e.prefixUrl || ""),

const n = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, n);
(Nt && 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);
}

@@ -589,3 +589,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 }));

} catch (e) {
const r = Math.min(this._calculateRetryDelay(e), U);
const r = Math.min(this._calculateRetryDelay(e), L);
if (r !== 0 && this._retryCount > 0) {

@@ -674,3 +674,3 @@ await Yt(r, { signal: this._options.signal });

}
const O = 8, y = (s) => 10n ** BigInt(s), R = (s) => Math.log10(parseFloat(s.toString()));
const O = 8, y = (s) => 10n ** BigInt(s), C = (s) => Math.log10(parseFloat(s.toString()));
function k({

@@ -694,3 +694,3 @@ value: s,

}
var w, C, b, T, j, ht, E, G, B, Y;
var w, R, b, T, N, ht, E, G, B, Y;
const K = class K {

@@ -700,3 +700,3 @@ constructor(t) {

v(this, b);
v(this, j);
v(this, N);
v(this, E);

@@ -708,3 +708,3 @@ v(this, B);

const e = z(t), r = typeof t == "object";
this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : y(Math.max(rt(x(e)), this.decimal || 0)), m(this, j, ht).call(this, e);
this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : y(Math.max(rt(x(e)), this.decimal || 0)), m(this, N, ht).call(this, e);
}

@@ -731,12 +731,12 @@ static fromBigInt(t, e) {

add(...t) {
return m(this, w, C).call(this, "add", ...t);
return m(this, w, R).call(this, "add", ...t);
}
sub(...t) {
return m(this, w, C).call(this, "sub", ...t);
return m(this, w, R).call(this, "sub", ...t);
}
mul(...t) {
return m(this, w, C).call(this, "mul", ...t);
return m(this, w, R).call(this, "mul", ...t);
}
div(...t) {
return m(this, w, C).call(this, "div", ...t);
return m(this, w, R).call(this, "div", ...t);
}

@@ -762,3 +762,3 @@ gt(t) {

this.bigIntValue,
this.decimal || R(this.decimalMultiplier)
this.decimal || C(this.decimalMultiplier)
);

@@ -838,3 +838,3 @@ switch (t) {

r,
R(this.decimalMultiplier)
C(this.decimalMultiplier)
), i = t < 0n, c = t.toString().substring(i ? 1 : 0), a = n - (c.length - 1), u = a > 0 ? "0".repeat(a) + c : c, l = u.length - n;

@@ -848,4 +848,4 @@ let h = u.slice(-n);

};
w = new WeakSet(), C = function(t, ...e) {
const r = m(this, E, G).call(this, this, ...e), n = Math.max(r, R(this.decimalMultiplier)), i = y(n), c = e.reduce(
w = new WeakSet(), R = function(t, ...e) {
const r = m(this, E, G).call(this, this, ...e), n = Math.max(r, C(this.decimalMultiplier)), i = y(n), c = e.reduce(
(u, l) => {

@@ -896,13 +896,13 @@ const h = this.getBigIntValue(l, n);

}
}, j = new WeakSet(), ht = function(t) {
}, N = new WeakSet(), ht = function(t) {
const e = x(t) || "0";
this.bigIntValue = m(this, B, Y).call(this, e);
}, E = new WeakSet(), G = function(...t) {
const e = t.map((r) => typeof r == "object" ? r.decimal || R(r.decimalMultiplier) : rt(x(r))).filter(Boolean);
const e = t.map((r) => typeof r == "object" ? r.decimal || C(r.decimalMultiplier) : rt(x(r))).filter(Boolean);
return Math.max(...e, O);
}, B = new WeakSet(), Y = function(t, e) {
const r = e ? y(e) : this.decimalMultiplier, n = R(r), [i = "", c = ""] = t.split(".");
const r = e ? y(e) : this.decimalMultiplier, n = C(r), [i = "", c = ""] = t.split(".");
return BigInt(`${i}${c.padEnd(n, "0")}`);
};
let N = K;
let j = K;
const te = Intl.NumberFormat("fullwide", {

@@ -925,3 +925,3 @@ useGrouping: !1,

const S = /* @__PURE__ */ new Map();
class A extends N {
class A extends j {
constructor({

@@ -1051,3 +1051,5 @@ value: e,

function st(s, t = 0) {
const [e, r] = s.split("/");
const [e, r] = s.split(".")[0].toUpperCase() === o.THORChain ? s.split(".").slice(1).join().split("/") : s.split("/");
if (!e || !r)
throw new Error("Invalid asset identifier");
return new A({

@@ -1063,3 +1065,6 @@ decimal: 8,

function P(s) {
const t = s.slice(0, 14).includes("/"), [e, r] = s.split(".").pop().split("/"), n = s.includes(".") && !t ? s : `${o.THORChain}.${r}`, [i, c] = n.split("."), [a, u] = (t ? r : c).split("-");
const t = s.slice(0, 14).includes("/"), [e, r] = s.split(".")[0].toUpperCase() === o.THORChain ? s.split(".").slice(1).join().split("/") : s.split("/");
if (t && (!e || !r))
throw new Error("Invalid asset identifier");
const n = s.includes(".") && !t ? s : `${o.THORChain}.${r}`, [i, c] = n.split("."), [a, u] = (t ? r : c).split("-");
return {

@@ -1137,3 +1142,3 @@ address: u == null ? void 0 : u.toLowerCase(),

}
class g extends N {
class g extends j {
eq(t) {

@@ -1151,3 +1156,3 @@ return this.eqValue(t);

A as AssetValue,
N as BigIntArithmetics,
j as BigIntArithmetics,
Xt as RequestClient,

@@ -1154,0 +1159,0 @@ dt as SwapKitError,

@@ -45,3 +45,3 @@ {

"types": "./dist/index.d.ts",
"version": "1.0.0-rc.56",
"version": "1.0.0-rc.57",
"scripts": {

@@ -48,0 +48,0 @@ "build": "vite build",

@@ -207,8 +207,13 @@ import { BaseDecimal, Chain } from '@swapkit/types';

function createSyntheticAssetValue(identifier: string, value: NumberPrimitives = 0) {
const [symbol, ticker] = identifier.split('/');
const [synthChain, symbol] =
identifier.split('.')[0].toUpperCase() === Chain.THORChain
? identifier.split('.').slice(1)!.join().split('/')
: identifier.split('/');
if (!synthChain || !symbol) throw new Error('Invalid asset identifier');
return new AssetValue({
decimal: 8,
value: safeValue(value, 8),
identifier: `${Chain.THORChain}.${symbol}/${ticker}`,
identifier: `${Chain.THORChain}.${synthChain}/${symbol}`,
});

@@ -225,3 +230,9 @@ }

const isSynthetic = identifier.slice(0, 14).includes('/');
const [synthChain, synthSymbol] = identifier.split('.').pop()!.split('/');
const [synthChain, synthSymbol] =
identifier.split('.')[0].toUpperCase() === Chain.THORChain
? identifier.split('.').slice(1)!.join().split('/')
: identifier.split('/');
if (isSynthetic && (!synthChain || !synthSymbol)) throw new Error('Invalid asset identifier');
const adjustedIdentifier =

@@ -228,0 +239,0 @@ identifier.includes('.') && !isSynthetic ? identifier : `${Chain.THORChain}.${synthSymbol}`;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc