New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@coinmasters/helpers

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coinmasters/helpers - npm Package Compare versions

Comparing version 8.0.15 to 8.0.16

204

dist/index.es.js

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

};
var R = (r, t, e) => {
var S = (r, t, e) => {
if (t.has(r))

@@ -14,3 +14,3 @@ 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 i, EVMChainList as At, ChainToRPC as vt, MemoType as b } from "@coinmasters/types";
import { FeeOption as L, BaseDecimal as d, Chain as i, EVMChainList as At, ChainToRPC as vt, MemoType as b } from "@coinmasters/types";
const Tt = "0x313ce567", at = async ({ chain: r, to: t }) => {

@@ -55,5 +55,5 @@ try {

}, ie = {
[D.Average]: 1.2,
[D.Fast]: 1.5,
[D.Fastest]: 2
[L.Average]: 1.2,
[L.Fast]: 1.5,
[L.Fastest]: 2
}, ot = ({ chain: r, symbol: t }) => {

@@ -77,3 +77,3 @@ switch (r) {

return t === "ETH";
case i.Maya:
case i.Mayachain:
return t === "CACAO";

@@ -107,4 +107,2 @@ case i.Kujira:

return { identifier: "MAYA.MAYA", decimal: 4 };
case i.Base:
return { identifier: "BASE.ETH", decimal: 18 };
case i.Ripple:

@@ -123,2 +121,3 @@ case i.Kujira:

case i.Bitcoin:
case i.Base:
case i.Ethereum:

@@ -167,6 +166,6 @@ return { identifier: `${r}.${r}`, decimal: d[r] };

return { chain: t, symbol: n, ticker: a, synth: s };
}, Et = new RegExp(
}, Bt = new RegExp(
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
"gmi"
), Bt = (r) => {
), Et = (r) => {
const [t, e] = r.split(".");

@@ -179,3 +178,3 @@ if (!At.includes(t))

const e = `${t.chain}.${t.symbol}`;
return !Et.test(e) && Bt(e) && t.value !== "0";
return !Bt.test(e) && Et(e) && t.value !== "0";
}), Mt = ({

@@ -231,7 +230,7 @@ liquidityUnits: r,

}) => {
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: a, 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);
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: a, decimal: 8 }), _ = h.mul(c), g = l.mul(o), $ = h.mul(l), R = o.mul(c), ft = u.mul(_.add(g.add($.mul(2)))), _t = _.add(g.add(R.mul(2))), Q = ft.div(_t), D = p(s).add(Q);
if (Q.getBaseValue("number") === 0)
return H.div(u).getBaseValue("number");
const gt = u.add(H);
return H.div(gt).getBaseValue("number");
return D.div(u).getBaseValue("number");
const gt = u.add(D);
return D.div(gt).getBaseValue("number");
}, de = ({

@@ -323,7 +322,7 @@ runeAmount: r,

}
const q = (r) => r !== null && typeof r == "object", x = (...r) => {
const V = (r) => r !== null && typeof r == "object", k = (...r) => {
for (const t of r)
if ((!q(t) || Array.isArray(t)) && t !== void 0)
if ((!V(t) || Array.isArray(t)) && t !== void 0)
throw new TypeError("The `options` argument must be an object");
return J({}, ...r);
return K({}, ...r);
}, ut = (r = {}, t = {}) => {

@@ -334,3 +333,3 @@ const e = new globalThis.Headers(r), s = t instanceof globalThis.Headers, n = new globalThis.Headers(t);

return e;
}, J = (...r) => {
}, K = (...r) => {
let t = {}, e = {};

@@ -340,6 +339,6 @@ for (const s of r)

Array.isArray(t) || (t = []), t = [...t, ...s];
else if (q(s)) {
else if (V(s)) {
for (let [n, a] of Object.entries(s))
q(a) && n in t && (a = J(t[n], a)), t = { ...t, [n]: a };
q(s.headers) && (e = ut(e, s.headers), t.headers = e);
V(a) && n in t && (a = K(t[n], a)), t = { ...t, [n]: a };
V(s.headers) && (e = ut(e, s.headers), t.headers = e);
}

@@ -364,3 +363,3 @@ return t;

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

@@ -443,7 +442,7 @@ parseJson: !0,

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

@@ -516,3 +515,3 @@ let c = await s._fetch();

headers: ut(this._input.headers, e.headers),
hooks: J({
hooks: K({
beforeRequest: [],

@@ -577,3 +576,3 @@ beforeRetry: [],

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

@@ -642,8 +641,8 @@ await zt(s, { signal: this._options.signal });

/*! MIT License © Sindre Sorhus */
const U = (r) => {
const t = (e, s) => P.create(e, x(r, s));
const F = (r) => {
const t = (e, s) => N.create(e, k(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 = {
t[e] = (s, n) => N.create(s, k(r, n, { method: e }));
return t.create = (e) => F(k(e)), t.extend = (e) => F(k(r, e)), t.stop = ht, t;
}, Kt = F(), 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(),

@@ -661,7 +660,7 @@ post: (r, t) => et.post(r, t).json()

);
}, O = 8, A = (r) => 10n ** BigInt(r), C = (r) => Math.log10(parseFloat(r.toString()));
function N({
}, B = 8, A = (r) => 10n ** BigInt(r), I = (r) => Math.log10(parseFloat(r.toString()));
function j({
value: r,
bigIntDecimal: t = O,
decimal: e = O
bigIntDecimal: t = B,
decimal: e = B
}) {

@@ -679,20 +678,20 @@ const s = r < 0n;

}
var T, I, w, S, j, mt, B, F, M, G;
const K = class K {
var T, O, w, C, H, mt, M, G, x, W;
const Z = class Z {
constructor(t) {
R(this, T);
R(this, w);
R(this, j);
R(this, B);
R(this, M);
S(this, T);
S(this, w);
S(this, H);
S(this, M);
S(this, x);
f(this, "decimalMultiplier", 10n ** 8n);
f(this, "bigIntValue", 0n);
f(this, "decimal");
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);
const e = Y(t), s = typeof t == "object";
this.decimal = s ? t.decimal : void 0, this.decimalMultiplier = s && "decimalMultiplier" in t ? t.decimalMultiplier : A(Math.max(rt(q(e)), this.decimal || 0)), m(this, H, mt).call(this, e);
}
static fromBigInt(t, e) {
return new K({
return new Z({
decimal: e,
value: N({ value: t, bigIntDecimal: e, decimal: e })
value: j({ value: t, bigIntDecimal: e, decimal: e })
});

@@ -714,27 +713,27 @@ }

add(...t) {
return m(this, T, I).call(this, "add", ...t);
return m(this, T, O).call(this, "add", ...t);
}
sub(...t) {
return m(this, T, I).call(this, "sub", ...t);
return m(this, T, O).call(this, "sub", ...t);
}
mul(...t) {
return m(this, T, I).call(this, "mul", ...t);
return m(this, T, O).call(this, "mul", ...t);
}
div(...t) {
return m(this, T, I).call(this, "div", ...t);
return m(this, T, O).call(this, "div", ...t);
}
gt(t) {
return m(this, w, S).call(this, "gt", t);
return m(this, w, C).call(this, "gt", t);
}
gte(t) {
return m(this, w, S).call(this, "gte", t);
return m(this, w, C).call(this, "gte", t);
}
lt(t) {
return m(this, w, S).call(this, "lt", t);
return m(this, w, C).call(this, "lt", t);
}
lte(t) {
return m(this, w, S).call(this, "lte", t);
return m(this, w, C).call(this, "lte", t);
}
eqValue(t) {
return m(this, w, S).call(this, "eqValue", t);
return m(this, w, C).call(this, "eqValue", t);
}

@@ -745,3 +744,3 @@ // @ts-expect-error False positive

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

@@ -772,4 +771,4 @@ switch (t) {

return t.bigIntValue;
const s = W(t), n = k(s);
return n === "0" || n === "undefined" ? 0n : m(this, M, G).call(this, n, e);
const s = Y(t), n = q(s);
return n === "0" || n === "undefined" ? 0n : m(this, x, W).call(this, n, e);
}

@@ -820,5 +819,5 @@ toSignificant(t = 6) {

formatBigIntToSafeValue(t, e) {
const s = e || this.decimal || O, n = Math.max(
const s = e || this.decimal || B, n = Math.max(
s,
C(this.decimalMultiplier)
I(this.decimalMultiplier)
), a = t < 0n, o = t.toString().substring(a ? 1 : 0), c = n - (o.length - 1), u = c > 0 ? "0".repeat(c) + o : o, h = u.length - n;

@@ -832,4 +831,4 @@ let l = u.slice(-n);

};
T = new WeakSet(), I = function(t, ...e) {
const s = m(this, B, F).call(this, this, ...e), n = Math.max(s, C(this.decimalMultiplier)), a = A(n), o = e.reduce(
T = new WeakSet(), O = function(t, ...e) {
const s = m(this, M, G).call(this, this, ...e), n = Math.max(s, I(this.decimalMultiplier)), a = A(n), o = e.reduce(
(u, h) => {

@@ -855,3 +854,3 @@ const l = this.getBigIntValue(h, n);

this.bigIntValue * a / this.decimalMultiplier
), c = N({
), c = j({
bigIntDecimal: n,

@@ -867,4 +866,4 @@ decimal: n,

});
}, w = new WeakSet(), S = function(t, ...e) {
const s = m(this, B, F).call(this, this, ...e), n = this.getBigIntValue(e[0], s), a = this.getBigIntValue(this, s);
}, w = new WeakSet(), C = function(t, ...e) {
const s = m(this, M, G).call(this, this, ...e), n = this.getBigIntValue(e[0], s), a = this.getBigIntValue(this, s);
switch (t) {

@@ -882,13 +881,13 @@ case "gt":

}
}, j = new WeakSet(), mt = function(t) {
const e = k(t) || "0";
this.bigIntValue = m(this, M, G).call(this, e);
}, B = 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);
}, M = new WeakSet(), G = function(t, e) {
const s = e ? A(e) : this.decimalMultiplier, n = C(s), [a = "", o = ""] = t.split(".");
}, H = new WeakSet(), mt = function(t) {
const e = q(t) || "0";
this.bigIntValue = m(this, x, W).call(this, e);
}, M = new WeakSet(), G = function(...t) {
const e = t.map((s) => typeof s == "object" ? s.decimal || I(s.decimalMultiplier) : rt(q(s))).filter(Boolean);
return Math.max(...e, B);
}, x = new WeakSet(), W = function(t, e) {
const s = e ? A(e) : this.decimalMultiplier, n = I(s), [a = "", o = ""] = t.split(".");
return BigInt(`${a}${o.padEnd(n, "0")}`);
};
let E = K;
let E = Z;
const ee = Intl.NumberFormat("fullwide", {

@@ -898,4 +897,4 @@ useGrouping: !1,

});
function k(r) {
const e = `${typeof r == "number" ? ee.format(r) : W(r)}`.replaceAll(",", ".").split(".");
function q(r) {
const e = `${typeof r == "number" ? ee.format(r) : Y(r)}`.replaceAll(",", ".").split(".");
return e.length > 1 ? `${e.slice(0, -1).join("")}.${e.at(-1)}` : e[0];

@@ -906,16 +905,16 @@ }

const t = ((e = r.split(".")[1]) == null ? void 0 : e.length) || 0;
return Math.max(t, O);
return Math.max(t, B);
}
function W(r) {
function Y(r) {
return typeof r == "object" ? "getValue" in r ? r.getValue("string") : r.value : r;
}
const V = (r, t) => typeof r == "bigint" ? N({ value: r, bigIntDecimal: t, decimal: t }) : r;
let Y;
const P = (r, t) => typeof r == "bigint" ? j({ value: r, bigIntDecimal: t, decimal: t }) : r;
let z;
const nt = (r) => {
if (!Y)
if (!z)
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
return Y.get(r.toUpperCase()) || { decimal: d.THOR, identifier: "" };
return z.get(r.toUpperCase()) || { decimal: d.THOR, identifier: "" };
}, it = async (r, t = 0) => {
te(r);
const e = await Ct(z(r)), s = V(t, e);
const e = await Ct(J(r)), s = P(t, e);
return new v({ decimal: e, value: s, identifier: r });

@@ -937,3 +936,3 @@ };

f(this, "type");
const n = z(s);
const n = J(s);
this.type = Ot(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.tax = e.tax;

@@ -961,8 +960,20 @@ }

static fromStringSync(e, s = 0) {
const { isSynthetic: n, symbol: a, chain: o, isGasAsset: c, ticker: u, address: h } = z(e), {
const { isSynthetic: n, symbol: a, chain: o, isGasAsset: c, ticker: u, address: h } = J(e), {
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;
} = nt(e), $ = P(s, _);
let R;
return g ? R = new v({
tax: l,
decimal: _,
identifier: g,
value: $
}) : n ? R = new v({
tax: l,
decimal: 8,
// Synthetic assets use a fixed decimal value
identifier: e,
value: $
}) : R = void 0, R;
}

@@ -973,3 +984,3 @@ static async fromIdentifier(e, s = 0) {

static fromIdentifierSync(e, s = 0) {
const { decimal: n, identifier: a } = nt(e), o = V(s, n);
const { decimal: n, identifier: a } = nt(e), o = P(s, n);
return new v({ decimal: n, identifier: a, value: o });

@@ -981,3 +992,3 @@ }

throw Error("unknown coin! " + e);
const o = V(s, n);
const o = P(s, n);
return new v({ value: o, decimal: n, identifier: a });

@@ -996,3 +1007,3 @@ }

} = await import("@coinmasters/tokens");
Y = [a, ...Object.values(o)].reduce(
z = [a, ...Object.values(o)].reduce(
(u, { tokens: h }) => (h.forEach(({ identifier: l, chain: _, ...g }) => {

@@ -1026,2 +1037,3 @@ const $ = "decimals" in g ? g.decimals : d[_];

return t.set(1.00000001);
case i.Base:
case i.Avalanche:

@@ -1036,3 +1048,3 @@ case i.Ethereum:

}
}, z = (r) => {
}, J = (r) => {
const t = r.slice(0, 14).includes("/"), [e, s] = r.split(".").pop().split("/"), n = r.includes(".") && !t ? r : `${i.THORChain}.${s}`, [a, o] = n.split("."), [c, u] = (t ? s : o).split("-");

@@ -1118,3 +1130,3 @@ return {

decimal: e,
value: N({ value: t, bigIntDecimal: e, decimal: e })
value: j({ value: t, bigIntDecimal: e, decimal: e })
});

@@ -1132,3 +1144,3 @@ }

oe as filterAssets,
N as formatBigIntToSafeValue,
j as formatBigIntToSafeValue,
ie as gasFeeMultiplier,

@@ -1135,0 +1147,0 @@ Ot as getAssetType,

@@ -11,5 +11,5 @@ {

"vitest": "0.34.6",
"@internal/config": "2.4.15",
"@coinmasters/tokens": "3.4.15",
"@coinmasters/types": "4.4.15"
"@internal/config": "2.4.16",
"@coinmasters/tokens": "3.4.16",
"@coinmasters/types": "4.4.16"
},

@@ -20,4 +20,4 @@ "eslintConfig": {

"peerDependencies": {
"@coinmasters/tokens": "3.4.15",
"@coinmasters/types": "4.4.15"
"@coinmasters/tokens": "3.4.16",
"@coinmasters/types": "4.4.16"
},

@@ -47,3 +47,3 @@ "exports": {

"types": "./dist/index.d.ts",
"version": "8.0.15",
"version": "8.0.16",
"scripts": {

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

@@ -93,3 +93,3 @@ import type { EVMChain } from '@coinmasters/types';

return 'ETH' === symbol;
case Chain.Maya:
case Chain.Mayachain:
return symbol === 'CACAO';

@@ -128,4 +128,2 @@ case Chain.Kujira:

return { identifier: 'MAYA.MAYA', decimal: 4 };
case Chain.Base:
return { identifier: 'BASE.ETH', decimal: 18 };
case Chain.Ripple:

@@ -144,2 +142,3 @@ case Chain.Kujira:

case Chain.Bitcoin:
case Chain.Base:
case Chain.Ethereum:

@@ -146,0 +145,0 @@ return { identifier: `${assetString}.${assetString}`, decimal: BaseDecimal[assetString] };

@@ -61,2 +61,4 @@ import type {

}
//console.log('getStaticToken: staticTokensMap: ', staticTokensMap);
//console.log('getStaticToken: identifier: ', identifier.toUpperCase());
const tokenInfo = staticTokensMap.get(identifier.toUpperCase() as TokenNames);

@@ -133,3 +135,3 @@

const { isSynthetic, symbol, chain, isGasAsset, ticker, address } = getAssetInfo(assetString);
//console.log('isSynthetic: ', { isSynthetic, symbol, chain, isGasAsset, ticker, address });
//console.log('getAssetInfo: ', { isSynthetic, symbol, chain, isGasAsset, ticker, address });
const {

@@ -140,10 +142,27 @@ tax,

} = getStaticToken(assetString as unknown as TokenNames);
//console.log('getStaticToken: ', { tax, decimal, tokenIdentifier });
const parsedValue = safeValue(value, decimal);
//console.log('parsedValue: ', parsedValue);
let asset: AssetValue | undefined;
const asset = tokenIdentifier
? new AssetValue({ tax, decimal, identifier: tokenIdentifier, value: parsedValue })
: isSynthetic
? new AssetValue({ tax, decimal: 8, identifier: assetString, value: parsedValue })
: undefined;
if (tokenIdentifier) {
//console.log('tokenIdentifier is truthy'); // Indicates tokenIdentifier has a value considered true in a boolean context
asset = new AssetValue({
tax,
decimal,
identifier: tokenIdentifier,
value: parsedValue,
});
} else if (isSynthetic) {
//console.log('isSynthetic is true'); // Indicates the asset is synthetic
asset = new AssetValue({
tax,
decimal: 8, // Synthetic assets use a fixed decimal value
identifier: assetString,
value: parsedValue,
});
} else {
//console.log('No valid condition met'); // Neither condition is true, asset is left undefined
asset = undefined;
}

@@ -230,2 +249,3 @@ return asset;

case Chain.Base:
case Chain.Avalanche:

@@ -232,0 +252,0 @@ case Chain.Ethereum:

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