@swapkit/core 1.0.0-rc.111 → 1.0.0-rc.112
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/LICENSE +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -12
- package/dist/index.es.js +75 -77
- package/dist/index.es.js.map +1 -1
- package/package.json +14 -14
- package/src/client/index.ts +27 -29
- package/src/client/old.ts +14 -18
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare enum ApproveMode {
|
|
|
51
51
|
export declare type ApproveReturnType<T extends ApproveMode> = T extends "checkOnly" ? Promise<boolean> : Promise<string>;
|
|
52
52
|
|
|
53
53
|
export declare type AvailableProviders<T> = T | {
|
|
54
|
-
[K in
|
|
54
|
+
[K in PluginName]?: ProviderMethods;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
export declare type ChainWallet<T extends Chain> = WalletMethods[T] & {
|
|
@@ -105,13 +105,13 @@ export declare type OldWallet = {
|
|
|
105
105
|
[key in Chain]: OldChainWallet | null;
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
+
export declare type PluginName = "thorchain" | "chainflip" | "mayachain";
|
|
109
|
+
|
|
108
110
|
export declare type ProviderMethods = {
|
|
109
111
|
swap: (swapParams: SwapParams) => Promise<string>;
|
|
110
112
|
[key: string]: any;
|
|
111
113
|
};
|
|
112
114
|
|
|
113
|
-
export declare type ProviderName = "thorchain" | "chainflip" | "mayachain";
|
|
114
|
-
|
|
115
115
|
export declare type QuoteRouteV2 = {
|
|
116
116
|
buyAsset: string;
|
|
117
117
|
sellAsset: string;
|
|
@@ -123,8 +123,8 @@ export declare type QuoteRouteV2 = {
|
|
|
123
123
|
|
|
124
124
|
export declare type SubstrateBasedWallet<T extends typeof PolkadotToolbox | typeof ChainflipToolbox> = Awaited<ReturnType<T>>;
|
|
125
125
|
|
|
126
|
-
export declare function SwapKit<ExtendedProviders extends {}, ConnectWalletMethods extends Record<string, ReturnType<SwapKitWallet["connect"]>>>({ stagenet, wallets,
|
|
127
|
-
|
|
126
|
+
export declare function SwapKit<ExtendedProviders extends {}, ConnectWalletMethods extends Record<string, ReturnType<SwapKitWallet["connect"]>>>({ stagenet, wallets, plugins, config, apis, rpcUrls, }: {
|
|
127
|
+
plugins: SwapKitPlugin[];
|
|
128
128
|
stagenet: boolean;
|
|
129
129
|
wallets: SwapKitWallet[];
|
|
130
130
|
config?: Record<string, any>;
|
|
@@ -228,7 +228,9 @@ export declare class SwapKitCore<T = ""> {
|
|
|
228
228
|
registerThorname: ({ assetValue, ...param }: ThornameRegisterParam & {
|
|
229
229
|
assetValue: AssetValue;
|
|
230
230
|
}) => Promise<string>;
|
|
231
|
-
registerMayaname: ({ assetValue, ...param }:
|
|
231
|
+
registerMayaname: ({ assetValue, ...param }: ThornameRegisterParam & {
|
|
232
|
+
assetValue: AssetValue;
|
|
233
|
+
}) => Promise<string>;
|
|
232
234
|
extend: ({ wallets, config, apis, rpcUrls }: ExtendParams<T>) => void;
|
|
233
235
|
estimateMaxSendableAmount: ({ chain, params, }: {
|
|
234
236
|
chain: Chain;
|
|
@@ -253,19 +255,19 @@ export declare class SwapKitCore<T = ""> {
|
|
|
253
255
|
disconnectChain: (chain: Chain) => void;
|
|
254
256
|
}
|
|
255
257
|
|
|
256
|
-
export declare type
|
|
258
|
+
export declare type SwapKitPlugin = ({ wallets, stagenet }: {
|
|
257
259
|
wallets: Wallets;
|
|
258
260
|
stagenet?: boolean;
|
|
259
261
|
}) => {
|
|
260
|
-
name:
|
|
262
|
+
name: PluginName;
|
|
261
263
|
methods: ProviderMethods;
|
|
262
264
|
};
|
|
263
265
|
|
|
264
|
-
declare type
|
|
265
|
-
[K in
|
|
266
|
+
declare type SwapKitPlugins = {
|
|
267
|
+
[K in PluginName]?: ProviderMethods;
|
|
266
268
|
};
|
|
267
269
|
|
|
268
|
-
export declare type SwapKitReturnType =
|
|
270
|
+
export declare type SwapKitReturnType = SwapKitPlugins & {
|
|
269
271
|
getAddress: (chain: Chain) => string;
|
|
270
272
|
getWallet: (chain: Chain) => ChainWallet<Chain> | undefined;
|
|
271
273
|
getWalletWithBalance: (chain: Chain, potentialScamFilter?: boolean) => Promise<ChainWallet<Chain>>;
|
|
@@ -288,7 +290,7 @@ export declare type SwapKitWallet = {
|
|
|
288
290
|
|
|
289
291
|
export declare type SwapParams = (SwapWithRouteParams | GenericSwapParams) & {
|
|
290
292
|
provider?: {
|
|
291
|
-
name:
|
|
293
|
+
name: PluginName;
|
|
292
294
|
config: Record<string, any>;
|
|
293
295
|
};
|
|
294
296
|
};
|
package/dist/index.es.js
CHANGED
|
@@ -616,14 +616,14 @@ const Mt = [
|
|
|
616
616
|
"BEP20-ERC20",
|
|
617
617
|
"BEP20-ARC20"
|
|
618
618
|
/* BSC_TO_AVAX */
|
|
619
|
-
],
|
|
619
|
+
], Ct = [
|
|
620
620
|
"TC-TC",
|
|
621
621
|
"TC-ERC20",
|
|
622
622
|
"TC-ARC20",
|
|
623
623
|
"TC-BEP20"
|
|
624
624
|
/* TC_SUPPORTED_TO_BSC */
|
|
625
625
|
];
|
|
626
|
-
var r = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(r || {}),
|
|
626
|
+
var r = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(r || {}), Et = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(Et || {}), Ot = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DASH = "m/44'/5'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.DOT = "////", e.ETH = "m/44'/60'/0'/0", e.FLIP = "////", e.GAIA = "m/44'/118'/0'/0", e.KUJI = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(Ot || {});
|
|
627
627
|
const Zn = {
|
|
628
628
|
ARB: [44, 60, 0, 0, 0],
|
|
629
629
|
AVAX: [44, 60, 0, 0, 0],
|
|
@@ -759,7 +759,7 @@ var w = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LE
|
|
|
759
759
|
if (t.has(e))
|
|
760
760
|
throw TypeError("Cannot add the same private member more than once");
|
|
761
761
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
762
|
-
},
|
|
762
|
+
}, E = (e, t, n) => (Ft(e, t, "access private method"), n), be = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(be || {}), Be = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Chainflip = "chainflip", e.Cosmos = "cosmoshub-4", e.Dash = "dash", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polkadot = "polkadot", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(Be || {}), Je = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Chainflip = "wss://mainnet-archive.chainflip.io", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Dash = "https://node-router.thorswap.net/dash", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polkadot = "wss://rpc.polkadot.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Je || {}), N = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(N || {});
|
|
763
763
|
const fe = Object.values(be), Lt = Object.keys(be), Pe = fe.reduce(
|
|
764
764
|
(e, t) => {
|
|
765
765
|
const n = Lt.find((a) => be[a] === t);
|
|
@@ -971,7 +971,7 @@ class oe {
|
|
|
971
971
|
}
|
|
972
972
|
// eslint-disable-next-line complexity
|
|
973
973
|
constructor(t, n = {}) {
|
|
974
|
-
|
|
974
|
+
Object.defineProperty(this, "request", {
|
|
975
975
|
enumerable: !0,
|
|
976
976
|
configurable: !0,
|
|
977
977
|
writable: !0,
|
|
@@ -996,9 +996,10 @@ class oe {
|
|
|
996
996
|
configurable: !0,
|
|
997
997
|
writable: !0,
|
|
998
998
|
value: void 0
|
|
999
|
-
}), this._input = t
|
|
1000
|
-
|
|
1001
|
-
|
|
999
|
+
}), this._input = t;
|
|
1000
|
+
const a = "credentials" in Request.prototype;
|
|
1001
|
+
if (this._options = {
|
|
1002
|
+
credentials: a ? this._input.credentials : void 0,
|
|
1002
1003
|
...n,
|
|
1003
1004
|
headers: ze(this._input.headers, n.headers),
|
|
1004
1005
|
hooks: He({
|
|
@@ -1023,16 +1024,16 @@ class oe {
|
|
|
1023
1024
|
}
|
|
1024
1025
|
if (Nt) {
|
|
1025
1026
|
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1026
|
-
const
|
|
1027
|
+
const i = this._options.signal;
|
|
1027
1028
|
this._options.signal.addEventListener("abort", () => {
|
|
1028
|
-
this.abortController.abort(
|
|
1029
|
+
this.abortController.abort(i.reason);
|
|
1029
1030
|
});
|
|
1030
1031
|
}
|
|
1031
1032
|
this._options.signal = this.abortController.signal;
|
|
1032
1033
|
}
|
|
1033
1034
|
if (Vt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1034
|
-
const
|
|
1035
|
-
(Wt && 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(
|
|
1035
|
+
const i = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, i);
|
|
1036
|
+
(Wt && 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(s, { ...this.request }), this._options);
|
|
1036
1037
|
}
|
|
1037
1038
|
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 }));
|
|
1038
1039
|
}
|
|
@@ -1125,12 +1126,12 @@ class oe {
|
|
|
1125
1126
|
}
|
|
1126
1127
|
}
|
|
1127
1128
|
/*! MIT License © Sindre Sorhus */
|
|
1128
|
-
const
|
|
1129
|
+
const Ce = (e) => {
|
|
1129
1130
|
const t = (n, a) => oe.create(n, re(e, a));
|
|
1130
1131
|
for (const n of et)
|
|
1131
1132
|
t[n] = (a, i) => oe.create(a, re(e, i, { method: n }));
|
|
1132
|
-
return t.create = (n) =>
|
|
1133
|
-
}, at =
|
|
1133
|
+
return t.create = (n) => Ce(re(n)), t.extend = (n) => Ce(re(e, n)), t.stop = tt, t;
|
|
1134
|
+
}, at = Ce();
|
|
1134
1135
|
let ue;
|
|
1135
1136
|
const L = {
|
|
1136
1137
|
CachedPrices: `${N.ThorswapApi}/tokenlist/cached-price`,
|
|
@@ -1185,7 +1186,7 @@ const an = "0x313ce567", st = async ({ chain: e, to: t }) => {
|
|
|
1185
1186
|
params: [{ to: t.toLowerCase(), data: an }, "latest"]
|
|
1186
1187
|
})
|
|
1187
1188
|
});
|
|
1188
|
-
return parseInt(BigInt(n).toString());
|
|
1189
|
+
return Number.parseInt(BigInt(n).toString());
|
|
1189
1190
|
} catch (n) {
|
|
1190
1191
|
return console.error(n), g[e];
|
|
1191
1192
|
}
|
|
@@ -1362,8 +1363,8 @@ function ma({
|
|
|
1362
1363
|
runeAmount: i,
|
|
1363
1364
|
assetAmount: s
|
|
1364
1365
|
}) {
|
|
1365
|
-
const p = new F({ value: e, decimal: 8 }), u = new F({ value: n, decimal: 8 }), y = new F({ value: t, decimal: 8 }), o = new F({ value: i, decimal: 8 }), l = new F({ value: s, decimal: 8 }), b = o.mul(u), T = l.mul(p), f = o.mul(l), _ = p.mul(u), M = y.mul(b.add(T.add(f.mul(2)))), v = b.add(T.add(_.mul(2))),
|
|
1366
|
-
if (
|
|
1366
|
+
const p = new F({ value: e, decimal: 8 }), u = new F({ value: n, decimal: 8 }), y = new F({ value: t, decimal: 8 }), o = new F({ value: i, decimal: 8 }), l = new F({ value: s, decimal: 8 }), b = o.mul(u), T = l.mul(p), f = o.mul(l), _ = p.mul(u), M = y.mul(b.add(T.add(f.mul(2)))), v = b.add(T.add(_.mul(2))), C = M.div(v), R = S(a).add(C);
|
|
1367
|
+
if (C.getBaseValue("number") === 0)
|
|
1367
1368
|
return R.div(y).getBaseValue("number");
|
|
1368
1369
|
const J = y.add(R);
|
|
1369
1370
|
return R.div(J).getBaseValue("number");
|
|
@@ -1459,7 +1460,7 @@ function fn(e = "") {
|
|
|
1459
1460
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1460
1461
|
);
|
|
1461
1462
|
}
|
|
1462
|
-
const ne = 8, W = (e) => 10n ** BigInt(e), te = (e) => Math.log10(parseFloat(e.toString()));
|
|
1463
|
+
const ne = 8, W = (e) => 10n ** BigInt(e), te = (e) => Math.log10(Number.parseFloat(e.toString()));
|
|
1463
1464
|
function he({
|
|
1464
1465
|
value: e,
|
|
1465
1466
|
bigIntDecimal: t = ne,
|
|
@@ -1473,17 +1474,17 @@ function he({
|
|
|
1473
1474
|
s > 0 && (i = "0".repeat(s) + i);
|
|
1474
1475
|
const p = i.length - n;
|
|
1475
1476
|
let u = i.slice(-n);
|
|
1476
|
-
return parseInt(u[t]) >= 5 ? u = `${u.substring(0, t - 1)}${(parseInt(u[t - 1]) + 1).toString()}` : u = u.substring(0, t), `${a ? "-" : ""}${i.slice(0, p)}.${u}`.replace(
|
|
1477
|
+
return Number.parseInt(u[t]) >= 5 ? u = `${u.substring(0, t - 1)}${(Number.parseInt(u[t - 1]) + 1).toString()}` : u = u.substring(0, t), `${a ? "-" : ""}${i.slice(0, p)}.${u}`.replace(
|
|
1477
1478
|
/\.?0*$/,
|
|
1478
1479
|
""
|
|
1479
1480
|
);
|
|
1480
1481
|
}
|
|
1481
|
-
var G, z, q, j,
|
|
1482
|
+
var G, z, q, j, Ee, pt, ye, ge, de, Oe;
|
|
1482
1483
|
const hn = class xe {
|
|
1483
1484
|
constructor(t) {
|
|
1484
|
-
Z(this, G), Z(this, q), Z(this,
|
|
1485
|
+
Z(this, G), Z(this, q), Z(this, Ee), Z(this, ye), Z(this, de), P(this, "decimalMultiplier", 10n ** 8n), P(this, "bigIntValue", 0n), P(this, "decimal");
|
|
1485
1486
|
const n = Se(t), a = typeof t == "object";
|
|
1486
|
-
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : W(Math.max(ut(le(n)), this.decimal || 0)),
|
|
1487
|
+
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : W(Math.max(ut(le(n)), this.decimal || 0)), E(this, Ee, pt).call(this, n);
|
|
1487
1488
|
}
|
|
1488
1489
|
static fromBigInt(t, n) {
|
|
1489
1490
|
return new xe({
|
|
@@ -1505,31 +1506,31 @@ const hn = class xe {
|
|
|
1505
1506
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1506
1507
|
}
|
|
1507
1508
|
add(...t) {
|
|
1508
|
-
return
|
|
1509
|
+
return E(this, G, z).call(this, "add", ...t);
|
|
1509
1510
|
}
|
|
1510
1511
|
sub(...t) {
|
|
1511
|
-
return
|
|
1512
|
+
return E(this, G, z).call(this, "sub", ...t);
|
|
1512
1513
|
}
|
|
1513
1514
|
mul(...t) {
|
|
1514
|
-
return
|
|
1515
|
+
return E(this, G, z).call(this, "mul", ...t);
|
|
1515
1516
|
}
|
|
1516
1517
|
div(...t) {
|
|
1517
|
-
return
|
|
1518
|
+
return E(this, G, z).call(this, "div", ...t);
|
|
1518
1519
|
}
|
|
1519
1520
|
gt(t) {
|
|
1520
|
-
return
|
|
1521
|
+
return E(this, q, j).call(this, "gt", t);
|
|
1521
1522
|
}
|
|
1522
1523
|
gte(t) {
|
|
1523
|
-
return
|
|
1524
|
+
return E(this, q, j).call(this, "gte", t);
|
|
1524
1525
|
}
|
|
1525
1526
|
lt(t) {
|
|
1526
|
-
return
|
|
1527
|
+
return E(this, q, j).call(this, "lt", t);
|
|
1527
1528
|
}
|
|
1528
1529
|
lte(t) {
|
|
1529
|
-
return
|
|
1530
|
+
return E(this, q, j).call(this, "lte", t);
|
|
1530
1531
|
}
|
|
1531
1532
|
eqValue(t) {
|
|
1532
|
-
return
|
|
1533
|
+
return E(this, q, j).call(this, "eqValue", t);
|
|
1533
1534
|
}
|
|
1534
1535
|
// @ts-expect-error False positive
|
|
1535
1536
|
getValue(t) {
|
|
@@ -1562,20 +1563,20 @@ const hn = class xe {
|
|
|
1562
1563
|
if (!n && typeof t == "object")
|
|
1563
1564
|
return t.bigIntValue;
|
|
1564
1565
|
const a = Se(t), i = le(a);
|
|
1565
|
-
return i === "0" || i === "undefined" ? 0n :
|
|
1566
|
+
return i === "0" || i === "undefined" ? 0n : E(this, de, Oe).call(this, i, n);
|
|
1566
1567
|
}
|
|
1567
1568
|
toSignificant(t = 6) {
|
|
1568
1569
|
const [n, a] = this.getValue("string").split("."), i = n || "", s = a || "";
|
|
1569
|
-
if ((parseInt(i) ? i.length + s.length : s.length) <= t)
|
|
1570
|
+
if ((Number.parseInt(i) ? i.length + s.length : s.length) <= t)
|
|
1570
1571
|
return this.getValue("string");
|
|
1571
1572
|
if (i.length >= t)
|
|
1572
1573
|
return i.slice(0, t).padEnd(i.length, "0");
|
|
1573
|
-
if (parseInt(i))
|
|
1574
|
+
if (Number.parseInt(i))
|
|
1574
1575
|
return `${i}.${s.slice(0, t - i.length)}`.padEnd(
|
|
1575
1576
|
t - i.length,
|
|
1576
1577
|
"0"
|
|
1577
1578
|
);
|
|
1578
|
-
const p = parseInt(s), u = `${p}`.slice(0, t);
|
|
1579
|
+
const p = Number.parseInt(s), u = `${p}`.slice(0, t);
|
|
1579
1580
|
return `0.${u.padStart(
|
|
1580
1581
|
s.length - `${p}`.length + u.length,
|
|
1581
1582
|
"0"
|
|
@@ -1583,9 +1584,9 @@ const hn = class xe {
|
|
|
1583
1584
|
}
|
|
1584
1585
|
toFixed(t = 6) {
|
|
1585
1586
|
const [n, a] = this.getValue("string").split("."), i = n || "", s = a || "";
|
|
1586
|
-
if (parseInt(i))
|
|
1587
|
+
if (Number.parseInt(i))
|
|
1587
1588
|
return `${i}.${s.slice(0, t)}`.padEnd(t, "0");
|
|
1588
|
-
const p = parseInt(s), u = `${p}`.slice(0, t);
|
|
1589
|
+
const p = Number.parseInt(s), u = `${p}`.slice(0, t);
|
|
1589
1590
|
return `0.${u.padStart(
|
|
1590
1591
|
s.length - `${p}`.length + u.length,
|
|
1591
1592
|
"0"
|
|
@@ -1604,7 +1605,7 @@ const hn = class xe {
|
|
|
1604
1605
|
decimalSeparator: i = ".",
|
|
1605
1606
|
thousandSeparator: s = ","
|
|
1606
1607
|
} = {}) {
|
|
1607
|
-
const p = this.getValue("number"), [u, y = ""] = p.toFixed(6).split("."), o = u.replace(/\B(?=(\d{3})+(?!\d))/g, s), l = u || y ? u === "0" ? `${parseFloat(`0.${y}`)}`.replace(".", i) : `${o}${parseInt(y) ? `${i}${y.slice(0, a)}` : ""}` : "0.00";
|
|
1608
|
+
const p = this.getValue("number"), [u, y = ""] = p.toFixed(6).split("."), o = u.replace(/\B(?=(\d{3})+(?!\d))/g, s), l = u || y ? u === "0" ? `${Number.parseFloat(`0.${y}`)}`.replace(".", i) : `${o}${Number.parseInt(y) ? `${i}${y.slice(0, a)}` : ""}` : "0.00";
|
|
1608
1609
|
return `${n === "start" ? t : ""}${l}${n === "end" ? t : ""}`;
|
|
1609
1610
|
}
|
|
1610
1611
|
formatBigIntToSafeValue(t, n) {
|
|
@@ -1613,14 +1614,14 @@ const hn = class xe {
|
|
|
1613
1614
|
te(this.decimalMultiplier)
|
|
1614
1615
|
), s = t < 0n, p = t.toString().substring(s ? 1 : 0), u = i - (p.length - 1), y = u > 0 ? "0".repeat(u) + p : p, o = y.length - i;
|
|
1615
1616
|
let l = y.slice(-i);
|
|
1616
|
-
return parseInt(l[a]) >= 5 ? l = `${l.substring(0, a - 1)}${(parseInt(l[a - 1]) + 1).toString()}` : l = l.substring(0, a), `${s ? "-" : ""}${y.slice(
|
|
1617
|
+
return Number.parseInt(l[a]) >= 5 ? l = `${l.substring(0, a - 1)}${(Number.parseInt(l[a - 1]) + 1).toString()}` : l = l.substring(0, a), `${s ? "-" : ""}${y.slice(
|
|
1617
1618
|
0,
|
|
1618
1619
|
o
|
|
1619
1620
|
)}.${l}`.replace(/\.?0*$/, "");
|
|
1620
1621
|
}
|
|
1621
1622
|
};
|
|
1622
1623
|
G = /* @__PURE__ */ new WeakSet(), z = function(e, ...t) {
|
|
1623
|
-
const n =
|
|
1624
|
+
const n = E(this, ye, ge).call(this, this, ...t), a = Math.max(n, te(this.decimalMultiplier)), i = W(a), s = t.reduce(
|
|
1624
1625
|
(u, y) => {
|
|
1625
1626
|
const o = this.getBigIntValue(y, a);
|
|
1626
1627
|
switch (e) {
|
|
@@ -1653,7 +1654,7 @@ G = /* @__PURE__ */ new WeakSet(), z = function(e, ...t) {
|
|
|
1653
1654
|
identifier: this.toString()
|
|
1654
1655
|
});
|
|
1655
1656
|
}, q = /* @__PURE__ */ new WeakSet(), j = function(e, ...t) {
|
|
1656
|
-
const n =
|
|
1657
|
+
const n = E(this, ye, ge).call(this, this, ...t), a = this.getBigIntValue(t[0], n), i = this.getBigIntValue(this, n);
|
|
1657
1658
|
switch (e) {
|
|
1658
1659
|
case "gt":
|
|
1659
1660
|
return i > a;
|
|
@@ -1666,9 +1667,9 @@ G = /* @__PURE__ */ new WeakSet(), z = function(e, ...t) {
|
|
|
1666
1667
|
case "eqValue":
|
|
1667
1668
|
return i === a;
|
|
1668
1669
|
}
|
|
1669
|
-
},
|
|
1670
|
+
}, Ee = /* @__PURE__ */ new WeakSet(), pt = function(e) {
|
|
1670
1671
|
const t = le(e) || "0";
|
|
1671
|
-
this.bigIntValue =
|
|
1672
|
+
this.bigIntValue = E(this, de, Oe).call(this, t);
|
|
1672
1673
|
}, ye = /* @__PURE__ */ new WeakSet(), ge = function(...e) {
|
|
1673
1674
|
const t = e.map((n) => typeof n == "object" ? n.decimal || te(n.decimalMultiplier) : ut(le(n))).filter(Boolean);
|
|
1674
1675
|
return Math.max(...t, ne);
|
|
@@ -1884,6 +1885,7 @@ const An = {
|
|
|
1884
1885
|
core_extend_error: 10003,
|
|
1885
1886
|
core_inbound_data_not_found: 10004,
|
|
1886
1887
|
core_approve_asset_address_or_from_not_found: 10005,
|
|
1888
|
+
core_plugin_not_found: 10006,
|
|
1887
1889
|
core_chain_halted: 10099,
|
|
1888
1890
|
/**
|
|
1889
1891
|
* Core - Wallet Connection
|
|
@@ -1908,7 +1910,6 @@ const An = {
|
|
|
1908
1910
|
core_swap_contract_not_supported: 10205,
|
|
1909
1911
|
core_swap_transaction_error: 10206,
|
|
1910
1912
|
core_swap_quote_mode_not_supported: 10207,
|
|
1911
|
-
core_swap_provider_not_found: 10208,
|
|
1912
1913
|
/**
|
|
1913
1914
|
* Core - Transaction
|
|
1914
1915
|
*/
|
|
@@ -2013,7 +2014,7 @@ var gn = /* @__PURE__ */ ((e) => (e.Approve = "approve", e.CheckOnly = "checkOnl
|
|
|
2013
2014
|
function Aa({
|
|
2014
2015
|
stagenet: e,
|
|
2015
2016
|
wallets: t,
|
|
2016
|
-
|
|
2017
|
+
plugins: n,
|
|
2017
2018
|
config: a = {},
|
|
2018
2019
|
apis: i,
|
|
2019
2020
|
rpcUrls: s
|
|
@@ -2032,10 +2033,7 @@ function Aa({
|
|
|
2032
2033
|
function o(c) {
|
|
2033
2034
|
const h = u[c] || Object.values(u)[0];
|
|
2034
2035
|
if (!h)
|
|
2035
|
-
throw new d(
|
|
2036
|
-
"core_swap_provider_not_found",
|
|
2037
|
-
"Could not find the requested provider"
|
|
2038
|
-
);
|
|
2036
|
+
throw new d("core_plugin_not_found", "Could not find the requested plugin");
|
|
2039
2037
|
return h;
|
|
2040
2038
|
}
|
|
2041
2039
|
function l(c) {
|
|
@@ -2080,7 +2078,7 @@ function Aa({
|
|
|
2080
2078
|
function v(c, h) {
|
|
2081
2079
|
return ot({ chain: c, address: h });
|
|
2082
2080
|
}
|
|
2083
|
-
function
|
|
2081
|
+
function C({ address: c, chain: h }) {
|
|
2084
2082
|
var I, O;
|
|
2085
2083
|
return (O = (I = T(h)) == null ? void 0 : I.validateAddress) == null ? void 0 : O.call(I, c);
|
|
2086
2084
|
}
|
|
@@ -2126,7 +2124,7 @@ function Aa({
|
|
|
2126
2124
|
getWalletWithBalance: R,
|
|
2127
2125
|
isAssetValueApproved: we,
|
|
2128
2126
|
swap: lt,
|
|
2129
|
-
validateAddress:
|
|
2127
|
+
validateAddress: C
|
|
2130
2128
|
};
|
|
2131
2129
|
}
|
|
2132
2130
|
const _n = [
|
|
@@ -2469,7 +2467,7 @@ const _n = [
|
|
|
2469
2467
|
type: "function"
|
|
2470
2468
|
},
|
|
2471
2469
|
{ stateMutability: "payable", type: "receive" }
|
|
2472
|
-
],
|
|
2470
|
+
], Cn = [
|
|
2473
2471
|
{
|
|
2474
2472
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2475
2473
|
stateMutability: "nonpayable",
|
|
@@ -2560,7 +2558,7 @@ const _n = [
|
|
|
2560
2558
|
type: "function"
|
|
2561
2559
|
},
|
|
2562
2560
|
{ stateMutability: "payable", type: "receive" }
|
|
2563
|
-
],
|
|
2561
|
+
], En = [
|
|
2564
2562
|
{
|
|
2565
2563
|
inputs: [
|
|
2566
2564
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8540,7 +8538,7 @@ const _n = [
|
|
|
8540
8538
|
], dt = {
|
|
8541
8539
|
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: _n,
|
|
8542
8540
|
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: vn,
|
|
8543
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
8541
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Cn
|
|
8544
8542
|
}, $n = {
|
|
8545
8543
|
...Pn,
|
|
8546
8544
|
...dt,
|
|
@@ -8549,7 +8547,7 @@ const _n = [
|
|
|
8549
8547
|
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Mn,
|
|
8550
8548
|
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: Dn,
|
|
8551
8549
|
// BSC
|
|
8552
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
8550
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: En,
|
|
8553
8551
|
// ETH
|
|
8554
8552
|
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: Hn,
|
|
8555
8553
|
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: Fn,
|
|
@@ -8581,7 +8579,7 @@ const _n = [
|
|
|
8581
8579
|
const v = !!dt[t.toLowerCase()];
|
|
8582
8580
|
if (v && !o)
|
|
8583
8581
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
8584
|
-
const
|
|
8582
|
+
const C = b || y, R = e && l || C;
|
|
8585
8583
|
if (!(f || _))
|
|
8586
8584
|
throw new Error("TC Vault is required on calldata");
|
|
8587
8585
|
if (!(T || o))
|
|
@@ -8670,7 +8668,7 @@ class ga {
|
|
|
8670
8668
|
};
|
|
8671
8669
|
return o.sendTransaction(M, i);
|
|
8672
8670
|
}
|
|
8673
|
-
if (
|
|
8671
|
+
if (Ct.includes(s)) {
|
|
8674
8672
|
if (!a.calldata.fromAsset)
|
|
8675
8673
|
throw new d("core_swap_asset_not_recognized");
|
|
8676
8674
|
const o = await k.fromString(a.calldata.fromAsset);
|
|
@@ -8679,11 +8677,11 @@ class ga {
|
|
|
8679
8677
|
const { address: l } = await A(this, $).call(this, o.chain), {
|
|
8680
8678
|
contract: b,
|
|
8681
8679
|
calldata: { expiration: T, amountIn: f, memo: _, memoStreamingSwap: M }
|
|
8682
|
-
} = a, v = o.add(F.fromBigInt(BigInt(f), o.decimal)),
|
|
8680
|
+
} = a, v = o.add(F.fromBigInt(BigInt(f), o.decimal)), C = t && M || _;
|
|
8683
8681
|
return this.deposit({
|
|
8684
8682
|
expiration: T,
|
|
8685
8683
|
assetValue: v,
|
|
8686
|
-
memo:
|
|
8684
|
+
memo: C,
|
|
8687
8685
|
feeOptionKey: i,
|
|
8688
8686
|
router: b,
|
|
8689
8687
|
recipient: l
|
|
@@ -8788,7 +8786,7 @@ class ga {
|
|
|
8788
8786
|
T({ chain: s, symbol: p, ticker: u }, s),
|
|
8789
8787
|
t.getBaseValue("string"),
|
|
8790
8788
|
b.memo,
|
|
8791
|
-
i.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
8789
|
+
i.expiration || Number.parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
8792
8790
|
],
|
|
8793
8791
|
txOverrides: {
|
|
8794
8792
|
from: b.from,
|
|
@@ -8800,7 +8798,7 @@ class ga {
|
|
|
8800
8798
|
return await y.transfer(b);
|
|
8801
8799
|
}
|
|
8802
8800
|
} catch (T) {
|
|
8803
|
-
const f = typeof T == "string" ? T.toLowerCase() : T == null ? void 0 : T.message.toLowerCase(), _ = f == null ? void 0 : f.includes("insufficient funds"), M = f == null ? void 0 : f.includes("gas"), v = f == null ? void 0 : f.includes("server"),
|
|
8801
|
+
const f = typeof T == "string" ? T.toLowerCase() : T == null ? void 0 : T.message.toLowerCase(), _ = f == null ? void 0 : f.includes("insufficient funds"), M = f == null ? void 0 : f.includes("gas"), v = f == null ? void 0 : f.includes("server"), C = f == null ? void 0 : f.includes("user rejected"), R = _ ? "core_transaction_deposit_insufficient_funds_error" : M ? "core_transaction_deposit_gas_error" : v ? "core_transaction_deposit_server_error" : C ? "core_transaction_user_rejected" : "core_transaction_deposit_error";
|
|
8804
8802
|
throw new d(R, T);
|
|
8805
8803
|
}
|
|
8806
8804
|
});
|
|
@@ -8862,8 +8860,8 @@ class ga {
|
|
|
8862
8860
|
address: _
|
|
8863
8861
|
})
|
|
8864
8862
|
});
|
|
8865
|
-
} catch (
|
|
8866
|
-
throw new d("core_transaction_add_liquidity_rune_error",
|
|
8863
|
+
} catch (C) {
|
|
8864
|
+
throw new d("core_transaction_add_liquidity_rune_error", C);
|
|
8867
8865
|
}
|
|
8868
8866
|
if (b && n)
|
|
8869
8867
|
try {
|
|
@@ -8875,8 +8873,8 @@ class ga {
|
|
|
8875
8873
|
address: f
|
|
8876
8874
|
})
|
|
8877
8875
|
});
|
|
8878
|
-
} catch (
|
|
8879
|
-
throw new d("core_transaction_add_liquidity_asset_error",
|
|
8876
|
+
} catch (C) {
|
|
8877
|
+
throw new d("core_transaction_add_liquidity_asset_error", C);
|
|
8880
8878
|
}
|
|
8881
8879
|
return { runeTx: M, assetTx: v };
|
|
8882
8880
|
});
|
|
@@ -9020,39 +9018,39 @@ class ga {
|
|
|
9020
9018
|
/**
|
|
9021
9019
|
* Wallet connection methods
|
|
9022
9020
|
*/
|
|
9023
|
-
// biome-ignore lint/
|
|
9021
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9024
9022
|
m(this, "connectXDEFI", async (t) => {
|
|
9025
9023
|
throw new d("core_wallet_xdefi_not_installed");
|
|
9026
9024
|
});
|
|
9027
|
-
// biome-ignore lint/
|
|
9025
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9028
9026
|
m(this, "connectEVMWallet", async (t, n) => {
|
|
9029
9027
|
throw new d("core_wallet_evmwallet_not_installed");
|
|
9030
9028
|
});
|
|
9031
|
-
// biome-ignore lint/
|
|
9029
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9032
9030
|
m(this, "connectWalletconnect", async (t, n) => {
|
|
9033
9031
|
throw new d("core_wallet_walletconnect_not_installed");
|
|
9034
9032
|
});
|
|
9035
|
-
// biome-ignore lint/
|
|
9033
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9036
9034
|
m(this, "connectKeepkey", async (t, n) => {
|
|
9037
9035
|
throw new d("core_wallet_keepkey_not_installed");
|
|
9038
9036
|
});
|
|
9039
|
-
// biome-ignore lint/
|
|
9037
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9040
9038
|
m(this, "connectKeystore", async (t, n) => {
|
|
9041
9039
|
throw new d("core_wallet_keystore_not_installed");
|
|
9042
9040
|
});
|
|
9043
|
-
// biome-ignore lint/
|
|
9041
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9044
9042
|
m(this, "connectLedger", async (t, n) => {
|
|
9045
9043
|
throw new d("core_wallet_ledger_not_installed");
|
|
9046
9044
|
});
|
|
9047
|
-
// biome-ignore lint/
|
|
9045
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9048
9046
|
m(this, "connectTrezor", async (t, n) => {
|
|
9049
9047
|
throw new d("core_wallet_trezor_not_installed");
|
|
9050
9048
|
});
|
|
9051
|
-
// biome-ignore lint/
|
|
9049
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9052
9050
|
m(this, "connectKeplr", async (t) => {
|
|
9053
9051
|
throw new d("core_wallet_keplr_not_installed");
|
|
9054
9052
|
});
|
|
9055
|
-
// biome-ignore lint/
|
|
9053
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9056
9054
|
m(this, "connectOkx", async (t) => {
|
|
9057
9055
|
throw new d("core_wallet_okx_not_installed");
|
|
9058
9056
|
});
|
|
@@ -9118,7 +9116,7 @@ class ga {
|
|
|
9118
9116
|
gas_rate: i,
|
|
9119
9117
|
router: s,
|
|
9120
9118
|
address: p
|
|
9121
|
-
} = await A(this, $).call(this, t.chain), u = (parseInt(i) || 0) * yn[a];
|
|
9119
|
+
} = await A(this, $).call(this, t.chain), u = (Number.parseInt(i) || 0) * yn[a];
|
|
9122
9120
|
return this.deposit({
|
|
9123
9121
|
assetValue: t,
|
|
9124
9122
|
recipient: p,
|
|
@@ -9170,7 +9168,7 @@ export {
|
|
|
9170
9168
|
Ye as ChainToExplorerUrl,
|
|
9171
9169
|
ia as ChainToHexChainId,
|
|
9172
9170
|
It as ChainToRPC,
|
|
9173
|
-
|
|
9171
|
+
Et as ContractAddress,
|
|
9174
9172
|
na as CosmosChainList,
|
|
9175
9173
|
kt as CosmosChains,
|
|
9176
9174
|
Ot as DerivationPath,
|
|
@@ -9184,7 +9182,7 @@ export {
|
|
|
9184
9182
|
Ke as RPCUrl,
|
|
9185
9183
|
x as RequestClient,
|
|
9186
9184
|
vt as SWAP_IN,
|
|
9187
|
-
|
|
9185
|
+
Ct as SWAP_OUT,
|
|
9188
9186
|
nn as StreamingSwapProgressStatus,
|
|
9189
9187
|
zn as SubstrateChains,
|
|
9190
9188
|
Aa as SwapKit,
|