@swapkit/api
Advanced tools
Comparing version 1.0.0-rc.38 to 1.0.0-rc.39
@@ -25,5 +25,5 @@ import type { Chain } from '@swapkit/types'; | ||
}[]; | ||
metadata?: 'true' | 'false'; | ||
lookup?: 'true' | 'false'; | ||
sparkline?: 'true' | 'false'; | ||
metadata?: "true" | "false"; | ||
lookup?: "true" | "false"; | ||
sparkline?: "true" | "false"; | ||
}; | ||
@@ -30,0 +30,0 @@ |
@@ -1,7 +0,5 @@ | ||
var o = /* @__PURE__ */ ((t) => (t.INVALID_INPUT_PARAMETERS = "1000", t.UNKNOWN_PROVIDERS = "1001", t.CANNOT_FIND_INBOUND_ADDRESS = "1002", t.NO_INBOUND_ADDRESSES = "1003", t.CHAIN_HALTED_OR_UNSUPPORTED = "1004", t.MISSING_INPUT_PARAMETER = "1005", t.INVALID_TYPE_GENERIC = "1100", t.INVALID_NUMBER_STRING = "1101", t.INVALID_NUMBER = "1102", t.INVALID_BOOLEAN = "1103", t.INVALID_OBJECT = "1104", t.INVALID_ARRAY = "1105", t.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", t.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", t.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", t.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", t.AFF_ADDRESS_TOO_LONG = "2004", t.AFF_BPS_INTEGER_MAX_500 = "2005", t.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", t.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", t.PREFERRED_PROVIDER_NOT_SUPPORTED = "2008", t.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", t.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", t.SOURCE_ADDRESS_SMART_CONTRACT = "2011", t.SWAP_AMOUNT_TOO_LOW = "2012", t.INVALID_PROVIDER = "2100", t.MISSING_CROSS_CHAIN_PROVIDER = "2101", t.MISSING_AVAX_PROVIDER = "2102", t.MISSING_BSC_PROVIDER = "2103", t.MISSING_ETH_PROVIDER = "2104", t.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", t.MISSING_ARB_PROVIDER = "2106", t.INVALID_CHAIN = "2200", t.INVALID_ASSET = "2201", t.INVALID_ASSET_IDENTIFIER = "2202", t.UNSUPPORTED_CHAIN = "2204", t.UNSUPPORTED_ASSET = "2203", t.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", t.INVALID_SOURCE_ADDRESS = "2300", t.INVALID_DESTINATION_ADDRESS = "2301", t.THORNODE_QUOTE_GENERIC_ERROR = "3000", t.NOT_ENOUGH_SYNTH_BALANCE = "3001", t.SYNTH_MINTING_CAP_REACHED = "3002", t.INVALID_QUOTE_MODE = "4000", t.NO_QUOTES = "4001", t.SERVICE_UNAVAILABLE_GENERIC = "5000", t.MISSING_GAS_DATA_GENERIC = "5100", t.MISSING_TOKEN_INFO_GENERIC = "5200", t.CANT_FIND_TOKEN_LIST = "5201", t.NO_PRICE = "5202", t.PRICE_IS_STALE = "5203", t.ADDRESS_NOT_WHITELISTED = "6000", t.ADDRESS_ALREADY_CLAIMED = "6001", t.TEMPORARY_ERROR = "9999", t))(o || {}); | ||
o.INVALID_INPUT_PARAMETERS + "", o.UNKNOWN_PROVIDERS + "", o.CANNOT_FIND_INBOUND_ADDRESS + "", o.NO_INBOUND_ADDRESSES + "", o.CHAIN_HALTED_OR_UNSUPPORTED + "", o.MISSING_INPUT_PARAMETER + "", o.INVALID_TYPE_GENERIC + "", o.INVALID_NUMBER_STRING + "", o.INVALID_NUMBER + "", o.INVALID_BOOLEAN + "", o.INVALID_OBJECT + "", o.INVALID_ARRAY + "", o.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", o.SELL_BUY_ASSETS_ARE_THE_SAME + "", o.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", o.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", o.AFF_ADDRESS_TOO_LONG + "", o.AFF_BPS_INTEGER_MAX_500 + "", o.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", o.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", o.PREFERRED_PROVIDER_NOT_SUPPORTED + "", o.SOURCE_ADDRESS_SMART_CONTRACT + "", o.SWAP_AMOUNT_TOO_LOW + "", o.DESTINATION_ADDRESS_SMART_CONTRACT + "", o.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", o.INVALID_PROVIDER + "", o.MISSING_CROSS_CHAIN_PROVIDER + "", o.MISSING_AVAX_PROVIDER + "", o.MISSING_BSC_PROVIDER + "", o.MISSING_ETH_PROVIDER + "", o.MISSING_ARB_PROVIDER + "", o.INVALID_PROVIDER_FOR_SWAP_OUT + "", o.INVALID_CHAIN + "", o.INVALID_ASSET + "", o.UNSUPPORTED_CHAIN + "", o.UNSUPPORTED_ASSET + "", o.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", o.THORNODE_QUOTE_GENERIC_ERROR + "", o.INVALID_SOURCE_ADDRESS + "", o.INVALID_DESTINATION_ADDRESS + "", o.NOT_ENOUGH_SYNTH_BALANCE + "", o.SYNTH_MINTING_CAP_REACHED + "", o.INVALID_QUOTE_MODE + "", o.NO_QUOTES + "", o.SERVICE_UNAVAILABLE_GENERIC + "", o.MISSING_GAS_DATA_GENERIC + "", o.MISSING_TOKEN_INFO_GENERIC + "", o.CANT_FIND_TOKEN_LIST + "", o.NO_PRICE + "", o.PRICE_IS_STALE + "", o.ADDRESS_NOT_WHITELISTED + "", o.ADDRESS_ALREADY_CLAIMED + ""; | ||
var I = /* @__PURE__ */ ((t) => (t.Arbitrum = "ARB", t.Avalanche = "AVAX", t.Binance = "BNB", t.BinanceSmartChain = "BSC", t.Bitcoin = "BTC", t.BitcoinCash = "BCH", t.Cosmos = "GAIA", t.Dash = "DASH", t.Dogecoin = "DOGE", t.Ethereum = "ETH", t.Kujira = "KUJI", t.Litecoin = "LTC", t.Maya = "MAYA", t.Optimism = "OP", t.Polkadot = "DOT", t.Chainflip = "FLIP", t.Polygon = "MATIC", t.THORChain = "THOR", t))(I || {}), f = /* @__PURE__ */ ((t) => (t.Arbitrum = "42161", t.ArbitrumHex = "0xa4b1", t.Avalanche = "43114", t.AvalancheHex = "0xa86a", t.Binance = "Binance-Chain-Tigris", t.BinanceSmartChain = "56", t.BinanceSmartChainHex = "0x38", t.Bitcoin = "bitcoin", t.BitcoinCash = "bitcoincash", t.Chainflip = "chainflip", t.Cosmos = "cosmoshub-4", t.Dash = "dash", t.Dogecoin = "dogecoin", t.Kujira = "kaiyo-1", t.Ethereum = "1", t.EthereumHex = "0x1", t.Litecoin = "litecoin", t.Maya = "mayachain-mainnet-v1", t.MayaStagenet = "mayachain-stagenet-v1", t.Optimism = "10", t.OptimismHex = "0xa", t.Polkadot = "polkadot", t.Polygon = "137", t.PolygonHex = "0x89", t.THORChain = "thorchain-mainnet-v1", t.THORChainStagenet = "thorchain-stagenet-v2", t))(f || {}), g = /* @__PURE__ */ ((t) => (t.Arbitrum = "https://arb1.arbitrum.io/rpc", t.Avalanche = "https://node-router.thorswap.net/avalanche-c", t.Binance = "", t.BinanceSmartChain = "https://bsc-dataseed.binance.org", t.Bitcoin = "https://node-router.thorswap.net/bitcoin", t.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", t.Chainflip = "wss://mainnet-archive.chainflip.io", t.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", t.Dash = "https://node-router.thorswap.net/dash", t.Dogecoin = "https://node-router.thorswap.net/dogecoin", t.Ethereum = "https://node-router.thorswap.net/ethereum", t.Kujira = "https://rpc-kujira.synergynodes.com/", t.Litecoin = "https://node-router.thorswap.net/litecoin", t.Maya = "https://tendermint.mayachain.info", t.MayaStagenet = "https://stagenet.tendermint.mayachain.info", t.Optimism = "https://mainnet.optimism.io", t.Polkadot = "wss://rpc.polkadot.io", t.Polygon = "https://polygon-rpc.com", t.THORChain = "https://rpc.thorswap.net", t.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", t))(g || {}), E = /* @__PURE__ */ ((t) => (t.Cosmos = "https://node-router.thorswap.net/cosmos/rest", t.Kujira = "https://lcd-kujira.synergynodes.com/", t.MayanodeMainnet = "https://mayanode.mayachain.info", t.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", t.ThornodeMainnet = "https://thornode.thorswap.net", t.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", t.ThorswapApi = "https://api.thorswap.net", t.ThorswapStatic = "https://static.thorswap.net", t))(E || {}); | ||
const N = Object.values(I), M = Object.keys(I), O = N.reduce( | ||
var C = /* @__PURE__ */ ((t) => (t.Arbitrum = "ARB", t.Avalanche = "AVAX", t.Binance = "BNB", t.BinanceSmartChain = "BSC", t.Bitcoin = "BTC", t.BitcoinCash = "BCH", t.Cosmos = "GAIA", t.Dash = "DASH", t.Dogecoin = "DOGE", t.Ethereum = "ETH", t.Kujira = "KUJI", t.Litecoin = "LTC", t.Maya = "MAYA", t.Optimism = "OP", t.Polkadot = "DOT", t.Chainflip = "FLIP", t.Polygon = "MATIC", t.THORChain = "THOR", t))(C || {}), b = /* @__PURE__ */ ((t) => (t.Arbitrum = "42161", t.ArbitrumHex = "0xa4b1", t.Avalanche = "43114", t.AvalancheHex = "0xa86a", t.Binance = "Binance-Chain-Tigris", t.BinanceSmartChain = "56", t.BinanceSmartChainHex = "0x38", t.Bitcoin = "bitcoin", t.BitcoinCash = "bitcoincash", t.Chainflip = "chainflip", t.Cosmos = "cosmoshub-4", t.Dash = "dash", t.Dogecoin = "dogecoin", t.Kujira = "kaiyo-1", t.Ethereum = "1", t.EthereumHex = "0x1", t.Litecoin = "litecoin", t.Maya = "mayachain-mainnet-v1", t.MayaStagenet = "mayachain-stagenet-v1", t.Optimism = "10", t.OptimismHex = "0xa", t.Polkadot = "polkadot", t.Polygon = "137", t.PolygonHex = "0x89", t.THORChain = "thorchain-mainnet-v1", t.THORChainStagenet = "thorchain-stagenet-v2", t))(b || {}), O = /* @__PURE__ */ ((t) => (t.Arbitrum = "https://arb1.arbitrum.io/rpc", t.Avalanche = "https://node-router.thorswap.net/avalanche-c", t.Binance = "", t.BinanceSmartChain = "https://bsc-dataseed.binance.org", t.Bitcoin = "https://node-router.thorswap.net/bitcoin", t.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", t.Chainflip = "wss://mainnet-archive.chainflip.io", t.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", t.Dash = "https://node-router.thorswap.net/dash", t.Dogecoin = "https://node-router.thorswap.net/dogecoin", t.Ethereum = "https://node-router.thorswap.net/ethereum", t.Kujira = "https://rpc-kujira.synergynodes.com/", t.Litecoin = "https://node-router.thorswap.net/litecoin", t.Maya = "https://tendermint.mayachain.info", t.MayaStagenet = "https://stagenet.tendermint.mayachain.info", t.Optimism = "https://mainnet.optimism.io", t.Polkadot = "wss://rpc.polkadot.io", t.Polygon = "https://polygon-rpc.com", t.THORChain = "https://rpc.thorswap.net", t.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", t))(O || {}), d = /* @__PURE__ */ ((t) => (t.Cosmos = "https://node-router.thorswap.net/cosmos/rest", t.Kujira = "https://lcd-kujira.synergynodes.com/", t.MayanodeMainnet = "https://mayanode.mayachain.info", t.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", t.ThornodeMainnet = "https://thornode.thorswap.net", t.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", t.ThorswapApi = "https://api.thorswap.net", t.ThorswapStatic = "https://static.thorswap.net", t))(d || {}); | ||
const m = Object.values(C), v = Object.keys(C), E = m.reduce( | ||
(t, e) => { | ||
const s = M.find((r) => I[r] === e); | ||
const s = v.find((r) => C[r] === e); | ||
return s && (t[e] = s), t; | ||
@@ -11,21 +9,21 @@ }, | ||
); | ||
N.reduce( | ||
(t, e) => (t[e] = f[O[e]], t), | ||
m.reduce( | ||
(t, e) => (t[e] = b[E[e]], t), | ||
{} | ||
); | ||
N.reduce( | ||
(t, e) => (t[e] = g[O[e]], t), | ||
m.reduce( | ||
(t, e) => (t[e] = O[E[e]], t), | ||
{} | ||
); | ||
N.reduce( | ||
m.reduce( | ||
(t, e) => { | ||
const s = `${O[e]}Hex`; | ||
return t[e] = f[s], t; | ||
const s = `${E[e]}Hex`; | ||
return t[e] = b[s], t; | ||
}, | ||
{} | ||
); | ||
class m extends Error { | ||
class g extends Error { | ||
constructor(e, s, r) { | ||
const i = e.status || e.status === 0 ? e.status : "", n = e.statusText || "", a = `${i} ${n}`.trim(), _ = a ? `status code ${a}` : "an unknown error"; | ||
super(`Request failed with ${_}`), Object.defineProperty(this, "response", { | ||
const o = e.status || e.status === 0 ? e.status : "", n = e.statusText || "", a = `${o} ${n}`.trim(), i = a ? `status code ${a}` : "an unknown error"; | ||
super(`Request failed with ${i}`), Object.defineProperty(this, "response", { | ||
enumerable: !0, | ||
@@ -48,3 +46,3 @@ configurable: !0, | ||
} | ||
class U extends Error { | ||
class N extends Error { | ||
constructor(e) { | ||
@@ -59,13 +57,13 @@ super("Request timed out"), Object.defineProperty(this, "request", { | ||
} | ||
const c = (t) => t !== null && typeof t == "object", T = (...t) => { | ||
const A = (t) => t !== null && typeof t == "object", _ = (...t) => { | ||
for (const e of t) | ||
if ((!c(e) || Array.isArray(e)) && e !== void 0) | ||
if ((!A(e) || Array.isArray(e)) && e !== void 0) | ||
throw new TypeError("The `options` argument must be an object"); | ||
return D({}, ...t); | ||
}, y = (t = {}, e = {}) => { | ||
const s = new globalThis.Headers(t), r = e instanceof globalThis.Headers, i = new globalThis.Headers(e); | ||
for (const [n, a] of i.entries()) | ||
return P({}, ...t); | ||
}, D = (t = {}, e = {}) => { | ||
const s = new globalThis.Headers(t), r = e instanceof globalThis.Headers, o = new globalThis.Headers(e); | ||
for (const [n, a] of o.entries()) | ||
r && a === "undefined" || a === void 0 ? s.delete(n) : s.set(n, a); | ||
return s; | ||
}, D = (...t) => { | ||
}, P = (...t) => { | ||
let e = {}, s = {}; | ||
@@ -75,9 +73,9 @@ for (const r of t) | ||
Array.isArray(e) || (e = []), e = [...e, ...r]; | ||
else if (c(r)) { | ||
for (let [i, n] of Object.entries(r)) | ||
c(n) && i in e && (n = D(e[i], n)), e = { ...e, [i]: n }; | ||
c(r.headers) && (s = y(s, r.headers), e.headers = s); | ||
else if (A(r)) { | ||
for (let [o, n] of Object.entries(r)) | ||
A(n) && o in e && (n = P(e[o], n)), e = { ...e, [o]: n }; | ||
A(r.headers) && (s = D(s, r.headers), e.headers = s); | ||
} | ||
return e; | ||
}, v = (() => { | ||
}, q = (() => { | ||
let t = !1, e = !1; | ||
@@ -93,3 +91,3 @@ const s = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function"; | ||
}).headers.has("Content-Type")), t && !e; | ||
})(), G = typeof globalThis.AbortController == "function", W = typeof globalThis.ReadableStream == "function", k = typeof globalThis.FormData == "function", w = ["get", "post", "put", "patch", "head", "delete"], F = { | ||
})(), L = typeof globalThis.AbortController == "function", U = typeof globalThis.ReadableStream == "function", x = typeof globalThis.FormData == "function", k = ["get", "post", "put", "patch", "head", "delete"], V = { | ||
json: "application/json", | ||
@@ -100,3 +98,3 @@ text: "text/*", | ||
blob: "*/*" | ||
}, p = 2147483647, L = Symbol("stop"), q = { | ||
}, S = 2147483647, H = Symbol("stop"), j = { | ||
json: !0, | ||
@@ -112,3 +110,3 @@ parseJson: !0, | ||
fetch: !0 | ||
}, x = { | ||
}, F = { | ||
method: !0, | ||
@@ -129,7 +127,7 @@ headers: !0, | ||
duplex: !0 | ||
}, j = (t) => w.includes(t) ? t.toUpperCase() : t, X = ["get", "put", "head", "delete", "options", "trace"], Y = [408, 413, 429, 500, 502, 503, 504], V = [413, 429, 503], P = { | ||
}, G = (t) => k.includes(t) ? t.toUpperCase() : t, M = ["get", "put", "head", "delete", "options", "trace"], X = [408, 413, 429, 500, 502, 503, 504], W = [413, 429, 503], w = { | ||
limit: 2, | ||
methods: X, | ||
statusCodes: Y, | ||
afterStatusCodes: V, | ||
methods: M, | ||
statusCodes: X, | ||
afterStatusCodes: W, | ||
maxRetryAfter: Number.POSITIVE_INFINITY, | ||
@@ -141,3 +139,3 @@ backoffLimit: Number.POSITIVE_INFINITY, | ||
return { | ||
...P, | ||
...w, | ||
limit: t | ||
@@ -150,13 +148,13 @@ }; | ||
return { | ||
...P, | ||
...w, | ||
...t, | ||
afterStatusCodes: V | ||
afterStatusCodes: W | ||
}; | ||
}; | ||
async function K(t, e, s, r) { | ||
return new Promise((i, n) => { | ||
return new Promise((o, n) => { | ||
const a = setTimeout(() => { | ||
s && s.abort(), n(new U(t)); | ||
s && s.abort(), n(new N(t)); | ||
}, r.timeout); | ||
r.fetch(t, e).then(i).catch(n).then(() => { | ||
r.fetch(t, e).then(o).catch(n).then(() => { | ||
clearTimeout(a); | ||
@@ -168,33 +166,33 @@ }); | ||
return new Promise((s, r) => { | ||
e && (e.throwIfAborted(), e.addEventListener("abort", i, { once: !0 })); | ||
function i() { | ||
e && (e.throwIfAborted(), e.addEventListener("abort", o, { once: !0 })); | ||
function o() { | ||
clearTimeout(n), r(e.reason); | ||
} | ||
const n = setTimeout(() => { | ||
e == null || e.removeEventListener("abort", i), s(); | ||
e == null || e.removeEventListener("abort", o), s(); | ||
}, t); | ||
}); | ||
} | ||
const Q = (t, e) => { | ||
const z = (t, e) => { | ||
const s = {}; | ||
for (const r in e) | ||
!(r in x) && !(r in q) && !(r in t) && (s[r] = e[r]); | ||
!(r in F) && !(r in j) && !(r in t) && (s[r] = e[r]); | ||
return s; | ||
}; | ||
class l { | ||
class T { | ||
static create(e, s) { | ||
const r = new l(e, s), i = async () => { | ||
if (typeof r._options.timeout == "number" && r._options.timeout > p) | ||
throw new RangeError(`The \`timeout\` option cannot be greater than ${p}`); | ||
const r = new T(e, s), o = async () => { | ||
if (typeof r._options.timeout == "number" && r._options.timeout > S) | ||
throw new RangeError(`The \`timeout\` option cannot be greater than ${S}`); | ||
await Promise.resolve(); | ||
let _ = await r._fetch(); | ||
for (const u of r._options.hooks.afterResponse) { | ||
const A = await u(r.request, r._options, r._decorateResponse(_.clone())); | ||
A instanceof globalThis.Response && (_ = A); | ||
let i = await r._fetch(); | ||
for (const h of r._options.hooks.afterResponse) { | ||
const u = await h(r.request, r._options, r._decorateResponse(i.clone())); | ||
u instanceof globalThis.Response && (i = u); | ||
} | ||
if (r._decorateResponse(_), !_.ok && r._options.throwHttpErrors) { | ||
let u = new m(_, r.request, r._options); | ||
for (const A of r._options.hooks.beforeError) | ||
u = await A(u); | ||
throw u; | ||
if (r._decorateResponse(i), !i.ok && r._options.throwHttpErrors) { | ||
let h = new g(i, r.request, r._options); | ||
for (const u of r._options.hooks.beforeError) | ||
h = await u(h); | ||
throw h; | ||
} | ||
@@ -204,19 +202,19 @@ if (r._options.onDownloadProgress) { | ||
throw new TypeError("The `onDownloadProgress` option must be a function"); | ||
if (!W) | ||
if (!U) | ||
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing."); | ||
return r._stream(_.clone(), r._options.onDownloadProgress); | ||
return r._stream(i.clone(), r._options.onDownloadProgress); | ||
} | ||
return _; | ||
}, a = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(i) : i(); | ||
for (const [_, u] of Object.entries(F)) | ||
a[_] = async () => { | ||
r.request.headers.set("accept", r.request.headers.get("accept") || u); | ||
const R = (await a).clone(); | ||
if (_ === "json") { | ||
if (R.status === 204 || (await R.clone().arrayBuffer()).byteLength === 0) | ||
return i; | ||
}, a = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(o) : o(); | ||
for (const [i, h] of Object.entries(V)) | ||
a[i] = async () => { | ||
r.request.headers.set("accept", r.request.headers.get("accept") || h); | ||
const p = (await a).clone(); | ||
if (i === "json") { | ||
if (p.status === 204 || (await p.clone().arrayBuffer()).byteLength === 0) | ||
return ""; | ||
if (s.parseJson) | ||
return s.parseJson(await R.text()); | ||
return s.parseJson(await p.text()); | ||
} | ||
return R[_](); | ||
return p[i](); | ||
}; | ||
@@ -256,4 +254,4 @@ return a; | ||
...s, | ||
headers: y(this._input.headers, s.headers), | ||
hooks: D({ | ||
headers: D(this._input.headers, s.headers), | ||
hooks: P({ | ||
beforeRequest: [], | ||
@@ -264,3 +262,3 @@ beforeRetry: [], | ||
}, s.hooks), | ||
method: j(s.method ?? this._input.method), | ||
method: G(s.method ?? this._input.method), | ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
@@ -279,3 +277,3 @@ prefixUrl: String(s.prefixUrl || ""), | ||
} | ||
if (G) { | ||
if (L) { | ||
if (this.abortController = new globalThis.AbortController(), this._options.signal) { | ||
@@ -289,5 +287,5 @@ const r = this._options.signal; | ||
} | ||
if (v && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) { | ||
const i = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), n = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, i); | ||
(k && 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(n, { ...this.request }), this._options); | ||
if (q && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) { | ||
const o = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), n = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, o); | ||
(x && 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(n, { ...this.request }), this._options); | ||
} | ||
@@ -297,4 +295,4 @@ 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 })); | ||
_calculateRetryDelay(e) { | ||
if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(e instanceof U)) { | ||
if (e instanceof m) { | ||
if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(e instanceof N)) { | ||
if (e instanceof g) { | ||
if (!this._options.retry.statusCodes.includes(e.response.status)) | ||
@@ -304,4 +302,4 @@ return 0; | ||
if (r && this._options.retry.afterStatusCodes.includes(e.response.status)) { | ||
let i = Number(r); | ||
return Number.isNaN(i) ? i = Date.parse(r) - Date.now() : i *= 1e3, this._options.retry.maxRetryAfter !== void 0 && i > this._options.retry.maxRetryAfter ? 0 : i; | ||
let o = Number(r); | ||
return Number.isNaN(o) ? o = Date.parse(r) - Date.now() : o *= 1e3, this._options.retry.maxRetryAfter !== void 0 && o > this._options.retry.maxRetryAfter ? 0 : o; | ||
} | ||
@@ -323,7 +321,7 @@ if (e.response.status === 413) | ||
} catch (s) { | ||
const r = Math.min(this._calculateRetryDelay(s), p); | ||
const r = Math.min(this._calculateRetryDelay(s), S); | ||
if (r !== 0 && this._retryCount > 0) { | ||
await J(r, { signal: this._options.signal }); | ||
for (const i of this._options.hooks.beforeRetry) | ||
if (await i({ | ||
for (const o of this._options.hooks.beforeRetry) | ||
if (await o({ | ||
request: this.request, | ||
@@ -333,3 +331,3 @@ options: this._options, | ||
retryCount: this._retryCount | ||
}) === L) | ||
}) === H) | ||
return; | ||
@@ -351,3 +349,3 @@ return this._retry(e); | ||
} | ||
const e = Q(this.request, this._options); | ||
const e = z(this.request, this._options); | ||
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), e) : K(this.request.clone(), e, this.abortController, this._options); | ||
@@ -358,4 +356,4 @@ } | ||
const r = Number(e.headers.get("content-length")) || 0; | ||
let i = 0; | ||
return e.status === 204 ? (s && s({ percent: 1, totalBytes: r, transferredBytes: i }, new Uint8Array()), new globalThis.Response(null, { | ||
let o = 0; | ||
return e.status === 204 ? (s && s({ percent: 1, totalBytes: r, transferredBytes: o }, new Uint8Array()), new globalThis.Response(null, { | ||
status: e.status, | ||
@@ -368,5 +366,5 @@ statusText: e.statusText, | ||
s && s({ percent: 0, transferredBytes: 0, totalBytes: r }, new Uint8Array()); | ||
async function _() { | ||
const { done: u, value: A } = await a.read(); | ||
if (u) { | ||
async function i() { | ||
const { done: h, value: u } = await a.read(); | ||
if (h) { | ||
n.close(); | ||
@@ -376,9 +374,9 @@ return; | ||
if (s) { | ||
i += A.byteLength; | ||
const R = r === 0 ? 0 : i / r; | ||
s({ percent: R, transferredBytes: i, totalBytes: r }, A); | ||
o += u.byteLength; | ||
const p = r === 0 ? 0 : o / r; | ||
s({ percent: p, transferredBytes: o, totalBytes: r }, u); | ||
} | ||
n.enqueue(A), await _(); | ||
n.enqueue(u), await i(); | ||
} | ||
await _(); | ||
await i(); | ||
} | ||
@@ -393,53 +391,57 @@ }), { | ||
/*! MIT License © Sindre Sorhus */ | ||
const C = (t) => { | ||
const e = (s, r) => l.create(s, T(t, r)); | ||
for (const s of w) | ||
e[s] = (r, i) => l.create(r, T(t, i, { method: s })); | ||
return e.create = (s) => C(T(s)), e.extend = (s) => C(T(t, s)), e.stop = L, e; | ||
}, B = C(); | ||
let d; | ||
const h = { | ||
CachedPrices: `${E.ThorswapApi}/tokenlist/cached-price`, | ||
GasRates: `${E.ThorswapApi}/resource-worker/gasPrice/getAll`, | ||
Quote: `${E.ThorswapApi}/aggregator/tokens/quote`, | ||
Txn: `${E.ThorswapApi}/apiusage/v2/txn`, | ||
TokenlistProviders: `${E.ThorswapApi}/tokenlist/providers`, | ||
TokenList: `${E.ThorswapStatic}/token-list`, | ||
Thorname: `${E.ThorswapApi}/thorname` | ||
}, H = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, b = () => d || (d = B.create({ headers: H }), d), ot = ({ apiKey: t, ...e }) => { | ||
d = B.create({ | ||
const R = (t) => { | ||
const e = (s, r) => T.create(s, _(t, r)); | ||
for (const s of k) | ||
e[s] = (r, o) => T.create(r, _(t, o, { method: s })); | ||
return e.create = (s) => R(_(s)), e.extend = (s) => R(_(t, s)), e.stop = H, e; | ||
}, I = R(); | ||
let f; | ||
const c = { | ||
CachedPrices: `${d.ThorswapApi}/tokenlist/cached-price`, | ||
GasRates: `${d.ThorswapApi}/resource-worker/gasPrice/getAll`, | ||
Quote: `${d.ThorswapApi}/aggregator/tokens/quote`, | ||
Txn: `${d.ThorswapApi}/apiusage/v2/txn`, | ||
TokenlistProviders: `${d.ThorswapApi}/tokenlist/providers`, | ||
TokenList: `${d.ThorswapStatic}/token-list`, | ||
Thorname: `${d.ThorswapApi}/thorname` | ||
}, B = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, y = () => f || (f = I.create({ headers: B }), f), st = ({ apiKey: t, ...e }) => { | ||
f = I.create({ | ||
...e, | ||
headers: { ...H, ...e.headers, "x-api-key": t } | ||
headers: { ...B, ...e.headers, "x-api-key": t } | ||
}); | ||
}, S = { | ||
get: (t, e) => b().get(t, e).json(), | ||
post: (t, e) => b().post(t, e).json() | ||
}, z = ({ tokens: t, ...e }) => { | ||
const s = new URLSearchParams(); | ||
return t.filter((r, i, n) => n.findIndex((a) => a === r) === i).forEach((r) => s.append("tokens", JSON.stringify(r))), e.metadata && s.append("metadata", "true"), e.lookup && s.append("lookup", "true"), e.sparkline && s.append("sparkline", "true"), S.post(h.CachedPrices, { | ||
}, l = { | ||
get: (t, e) => y().get(t, e).json(), | ||
post: (t, e) => y().post(t, e).json() | ||
}, Q = ({ tokens: t, ...e }) => { | ||
const s = new URLSearchParams(), r = t.filter( | ||
(o, n, a) => a.findIndex((i) => i === o) === n | ||
); | ||
for (const o of r) | ||
s.append("tokens", JSON.stringify(o)); | ||
return e.metadata && s.append("metadata", "true"), e.lookup && s.append("lookup", "true"), e.sparkline && s.append("sparkline", "true"), l.post(c.CachedPrices, { | ||
body: s.toString(), | ||
headers: { "Content-Type": "application/x-www-form-urlencoded" } | ||
}); | ||
}, it = { | ||
getCachedPrices: z, | ||
getQuote: (t) => S.get(h.Quote, { searchParams: t }), | ||
getGasRates: () => S.get(h.GasRates), | ||
getTxnDetails: (t) => S.get(h.Txn, { searchParams: t }), | ||
getTokenlistProviders: () => S.get(h.TokenlistProviders), | ||
getTokenList: (t) => S.get(`${h.TokenList}/${t}.json`), | ||
getThornameAddresses: (t) => S.get(`${h.Thorname}/${t}`), | ||
getThornameRegisteredChains: (t) => S.get(`${h.Thorname}/chains/${t}`), | ||
getThornameRlookup: (t, e) => S.get(`${h.Thorname}/rlookup`, { searchParams: { address: t, chain: e } }) | ||
}, ot = { | ||
getCachedPrices: Q, | ||
getQuote: (t) => l.get(c.Quote, { searchParams: t }), | ||
getGasRates: () => l.get(c.GasRates), | ||
getTxnDetails: (t) => l.get(c.Txn, { searchParams: t }), | ||
getTokenlistProviders: () => l.get(c.TokenlistProviders), | ||
getTokenList: (t) => l.get(`${c.TokenList}/${t}.json`), | ||
getThornameAddresses: (t) => l.get(`${c.Thorname}/${t}`), | ||
getThornameRegisteredChains: (t) => l.get(`${c.Thorname}/chains/${t}`), | ||
getThornameRlookup: (t, e) => l.get(`${c.Thorname}/rlookup`, { searchParams: { address: t, chain: e } }) | ||
}; | ||
var Z = /* @__PURE__ */ ((t) => (t.SWAP_TC_TO_TC = "SWAP:TC-TC", t.SWAP_ETH_TO_TC = "SWAP:ERC20-TC", t.SWAP_TC_TO_ETH = "SWAP:TC-ERC20", t.SWAP_ETH_TO_ETH = "SWAP:ERC20-ERC20", t.SWAP_AVAX_TO_TC = "SWAP:AVAX-TC", t.SWAP_TC_TO_AVAX = "SWAP:TC-AVAX", t.SWAP_AVAX_TO_AVAX = "SWAP:AVAX-AVAX", t.SWAP_ETH_TO_AVAX = "SWAP:ETH-AVAX", t.SWAP_AVAX_TO_ETH = "SWAP:AVAX-ETH", t.SWAP_TC_TO_GAIA = "SWAP:TC-GAIA", t.SWAP_GAIA_TO_TC = "SWAP:GAIA-TC", t.SWAP_TC_TO_BNB = "SWAP:TC-BNB", t.SWAP_BNB_TO_TC = "SWAP:BNB-TC", t.SWAP_TC_TO_BTC = "SWAP:TC-BTC", t.SWAP_BTC_TO_TC = "SWAP:BTC-TC", t.SWAP_TC_TO_BCH = "SWAP:TC-BCH", t.SWAP_BCH_TO_TC = "SWAP:BCH-TC", t.SWAP_TC_TO_LTC = "SWAP:TC-LTC", t.SWAP_LTC_TO_TC = "SWAP:LTC-TC", t.SWAP_TC_TO_DOGE = "SWAP:TC-DOGE", t.SWAP_DOGE_TO_TC = "SWAP:DOGE-TC", t.TC_STATUS = "TC:STATUS", t.TC_TRANSFER = "TC:TRANSFER", t.TC_DEPOSIT = "TC:DEPOSIT", t.TC_SEND = "TC:SEND", t.TC_SWITCH = "TC:SWITCH", t.TC_LP_ADD = "TC:ADDLIQUIDITY", t.TC_LP_WITHDRAW = "TC:WITHDRAW", t.TC_TNS_CREATE = "TC:TNS-CREATE", t.TC_TNS_EXTEND = "TC:TNS-EXTEND", t.TC_TNS_UPDATE = "TC:TNS-UPDATE", t.TC_SAVINGS_ADD = "TC:ADDSAVINGS", t.TC_SAVINGS_WITHDRAW = "TC:WITHDRAWSAVINGS", t.TC_LENDING_OPEN = "TC:LENDINGOPEN", t.TC_LENDING_CLOSE = "TC:LENDINGCLOSE", t.ETH_APPROVAL = "ETH:APPROVAL", t.ETH_STATUS = "ETH:STATUS", t.ETH_TRANSFER_TO_TC = "ETH:TRANSFER:IN", t.ETH_TRANSFER_FROM_TC = "ETH:TRANSFER:OUT", t.AVAX_APPROVAL = "AVAX:APPROVAL", t.AVAX_STATUS = "AVAX:STATUS", t.AVAX_TRANSFER_TO_TC = "AVAX:TRANSFER:IN", t.AVAX_TRANSFER_FROM_TC = "AVAX:TRANSFER:OUT", t.BSC_APPROVAL = "BSC:APPROVAL", t.BSC_STATUS = "BSC:STATUS", t.BSC_TRANSFER_TO_TC = "BSC:TRANSFER:IN", t.BSC_TRANSFER_FROM_TC = "BSC:TRANSFER:OUT", t.APPROVAL = "APPROVAL", t.STATUS = "STATUS", t.TRANSFER_TO_TC = "TRANSFER:IN", t.TRANSFER_FROM_TC = "TRANSFER:OUT", t.UNSUPPORTED = "UNSUPPORTED", t.TC_LENDING = "TC:LENDING", t))(Z || {}), tt = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.SUCCESS = "success", t.CANCELLED = "cancelled", t.REFUNDED = "refunded", t.REPLACED = "replaced", t.ERROR = "error", t.UNKNOWN = "unknown", t.NOT_STARTED = "not_started", t.NOT_FOUND = "not_found", t.RETRIES_EXCEEDED = "retries_exceeded", t.STREAMING = "streaming", t))(tt || {}), et = /* @__PURE__ */ ((t) => (t[t.NOT_STARTED = 0] = "NOT_STARTED", t[t.SUCCESS = 1] = "SUCCESS", t[t.REFUNDED = 2] = "REFUNDED", t))(et || {}); | ||
var Y = /* @__PURE__ */ ((t) => (t.SWAP_TC_TO_TC = "SWAP:TC-TC", t.SWAP_ETH_TO_TC = "SWAP:ERC20-TC", t.SWAP_TC_TO_ETH = "SWAP:TC-ERC20", t.SWAP_ETH_TO_ETH = "SWAP:ERC20-ERC20", t.SWAP_AVAX_TO_TC = "SWAP:AVAX-TC", t.SWAP_TC_TO_AVAX = "SWAP:TC-AVAX", t.SWAP_AVAX_TO_AVAX = "SWAP:AVAX-AVAX", t.SWAP_ETH_TO_AVAX = "SWAP:ETH-AVAX", t.SWAP_AVAX_TO_ETH = "SWAP:AVAX-ETH", t.SWAP_TC_TO_GAIA = "SWAP:TC-GAIA", t.SWAP_GAIA_TO_TC = "SWAP:GAIA-TC", t.SWAP_TC_TO_BNB = "SWAP:TC-BNB", t.SWAP_BNB_TO_TC = "SWAP:BNB-TC", t.SWAP_TC_TO_BTC = "SWAP:TC-BTC", t.SWAP_BTC_TO_TC = "SWAP:BTC-TC", t.SWAP_TC_TO_BCH = "SWAP:TC-BCH", t.SWAP_BCH_TO_TC = "SWAP:BCH-TC", t.SWAP_TC_TO_LTC = "SWAP:TC-LTC", t.SWAP_LTC_TO_TC = "SWAP:LTC-TC", t.SWAP_TC_TO_DOGE = "SWAP:TC-DOGE", t.SWAP_DOGE_TO_TC = "SWAP:DOGE-TC", t.TC_STATUS = "TC:STATUS", t.TC_TRANSFER = "TC:TRANSFER", t.TC_DEPOSIT = "TC:DEPOSIT", t.TC_SEND = "TC:SEND", t.TC_SWITCH = "TC:SWITCH", t.TC_LP_ADD = "TC:ADDLIQUIDITY", t.TC_LP_WITHDRAW = "TC:WITHDRAW", t.TC_TNS_CREATE = "TC:TNS-CREATE", t.TC_TNS_EXTEND = "TC:TNS-EXTEND", t.TC_TNS_UPDATE = "TC:TNS-UPDATE", t.TC_SAVINGS_ADD = "TC:ADDSAVINGS", t.TC_SAVINGS_WITHDRAW = "TC:WITHDRAWSAVINGS", t.TC_LENDING_OPEN = "TC:LENDINGOPEN", t.TC_LENDING_CLOSE = "TC:LENDINGCLOSE", t.ETH_APPROVAL = "ETH:APPROVAL", t.ETH_STATUS = "ETH:STATUS", t.ETH_TRANSFER_TO_TC = "ETH:TRANSFER:IN", t.ETH_TRANSFER_FROM_TC = "ETH:TRANSFER:OUT", t.AVAX_APPROVAL = "AVAX:APPROVAL", t.AVAX_STATUS = "AVAX:STATUS", t.AVAX_TRANSFER_TO_TC = "AVAX:TRANSFER:IN", t.AVAX_TRANSFER_FROM_TC = "AVAX:TRANSFER:OUT", t.BSC_APPROVAL = "BSC:APPROVAL", t.BSC_STATUS = "BSC:STATUS", t.BSC_TRANSFER_TO_TC = "BSC:TRANSFER:IN", t.BSC_TRANSFER_FROM_TC = "BSC:TRANSFER:OUT", t.APPROVAL = "APPROVAL", t.STATUS = "STATUS", t.TRANSFER_TO_TC = "TRANSFER:IN", t.TRANSFER_FROM_TC = "TRANSFER:OUT", t.UNSUPPORTED = "UNSUPPORTED", t.TC_LENDING = "TC:LENDING", t))(Y || {}), Z = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.SUCCESS = "success", t.CANCELLED = "cancelled", t.REFUNDED = "refunded", t.REPLACED = "replaced", t.ERROR = "error", t.UNKNOWN = "unknown", t.NOT_STARTED = "not_started", t.NOT_FOUND = "not_found", t.RETRIES_EXCEEDED = "retries_exceeded", t.STREAMING = "streaming", t))(Z || {}), tt = /* @__PURE__ */ ((t) => (t[t.NOT_STARTED = 0] = "NOT_STARTED", t[t.SUCCESS = 1] = "SUCCESS", t[t.REFUNDED = 2] = "REFUNDED", t))(tt || {}); | ||
export { | ||
h as ApiEndpoints, | ||
S as RequestClient, | ||
et as StreamingSwapProgressStatus, | ||
it as SwapKitApi, | ||
Z as TransactionType, | ||
tt as TxStatus, | ||
H as defaultRequestHeaders, | ||
ot as setRequestClientConfig | ||
c as ApiEndpoints, | ||
l as RequestClient, | ||
tt as StreamingSwapProgressStatus, | ||
ot as SwapKitApi, | ||
Y as TransactionType, | ||
Z as TxStatus, | ||
B as defaultRequestHeaders, | ||
st as setRequestClientConfig | ||
}; | ||
//# sourceMappingURL=index.es.js.map |
{ | ||
"author": "swapkit-oss-team", | ||
"author": "swapkit-oss", | ||
"dependencies": { | ||
"ky": "1.2.0", | ||
"@swapkit/types": "1.0.0-rc.37" | ||
"@swapkit/types": "1.0.0-rc.38" | ||
}, | ||
"description": "SwapKit Lib swapkit-api", | ||
"devDependencies": { | ||
"@vitest/coverage-istanbul": "1.2.1", | ||
"vite": "5.0.12", | ||
"vitest": "1.2.1", | ||
"@internal/config": "0.0.2-rc.0" | ||
"@vitest/coverage-istanbul": "1.3.1", | ||
"vite": "5.1.3", | ||
"vitest": "1.3.1" | ||
}, | ||
"eslintConfig": { | ||
"extends": "../../../internal/eslint-config" | ||
}, | ||
"exports": { | ||
@@ -40,7 +36,7 @@ ".": { | ||
"types": "./dist/index.d.ts", | ||
"version": "1.0.0-rc.38", | ||
"version": "1.0.0-rc.39", | ||
"scripts": { | ||
"build": "vite build", | ||
"clean": "rm -rf dist vite.config.ts.* .turbo node_modules", | ||
"lint": "eslint ./ --ext .ts,.tsx --fix; tsc --noEmit", | ||
"clean": "rm -rf dist vite.config.ts.* node_modules", | ||
"lint": "biome check --apply ./src", | ||
"test": "echo 'vitest --run'", | ||
@@ -47,0 +43,0 @@ "test:coverage": "echo 'vitest run --coverage'" |
@@ -1,2 +0,2 @@ | ||
import { ApiEndpoints, RequestClient } from './requestClient.ts'; | ||
import { ApiEndpoints, RequestClient } from "./requestClient.ts"; | ||
import type { | ||
@@ -11,17 +11,21 @@ CachedPricesParams, | ||
TxnResponse, | ||
} from './types/index.ts'; | ||
} from "./types/index.ts"; | ||
const getCachedPrices = ({ tokens, ...options }: CachedPricesParams) => { | ||
const body = new URLSearchParams(); | ||
tokens | ||
.filter((token, index, sourceArr) => sourceArr.findIndex((t) => t === token) === index) | ||
.forEach((token) => body.append('tokens', JSON.stringify(token))); | ||
const filteredTokens = tokens.filter( | ||
(token, index, sourceArr) => sourceArr.findIndex((t) => t === token) === index, | ||
); | ||
if (options.metadata) body.append('metadata', 'true'); | ||
if (options.lookup) body.append('lookup', 'true'); | ||
if (options.sparkline) body.append('sparkline', 'true'); | ||
for (const token of filteredTokens) { | ||
body.append("tokens", JSON.stringify(token)); | ||
} | ||
if (options.metadata) body.append("metadata", "true"); | ||
if (options.lookup) body.append("lookup", "true"); | ||
if (options.sparkline) body.append("sparkline", "true"); | ||
return RequestClient.post<CachedPricesResponse[]>(ApiEndpoints.CachedPrices, { | ||
body: body.toString(), | ||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, | ||
headers: { "Content-Type": "application/x-www-form-urlencoded" }, | ||
}); | ||
@@ -28,0 +32,0 @@ }; |
@@ -1,3 +0,3 @@ | ||
export * from './api.ts'; | ||
export * from './requestClient.ts'; | ||
export * from './types/index.ts'; | ||
export * from "./api.ts"; | ||
export * from "./requestClient.ts"; | ||
export * from "./types/index.ts"; |
@@ -1,4 +0,4 @@ | ||
import { ApiUrl } from '@swapkit/types'; | ||
import type { Options } from 'ky'; | ||
import ky from 'ky'; | ||
import { ApiUrl } from "@swapkit/types"; | ||
import type { Options } from "ky"; | ||
import ky from "ky"; | ||
@@ -21,5 +21,5 @@ let kyClient: typeof ky; | ||
export const defaultRequestHeaders = | ||
typeof window !== 'undefined' | ||
typeof window !== "undefined" | ||
? {} | ||
: { referrer: 'https://sk.thorswap.net', referer: 'https://sk.thorswap.net' }; | ||
: { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }; | ||
@@ -37,3 +37,3 @@ const getKyClient = () => { | ||
...config, | ||
headers: { ...defaultRequestHeaders, ...config.headers, 'x-api-key': apiKey }, | ||
headers: { ...defaultRequestHeaders, ...config.headers, "x-api-key": apiKey }, | ||
}); | ||
@@ -40,0 +40,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
export * from './gasRates.ts'; | ||
export * from './quote.ts'; | ||
export * from "./gasRates.ts"; | ||
export * from "./quote.ts"; |
@@ -1,88 +0,88 @@ | ||
import type { Chain, LedgerErrorCode, QuoteMode } from '@swapkit/types'; | ||
import type { Chain, LedgerErrorCode, QuoteMode } from "@swapkit/types"; | ||
export enum TransactionType { | ||
// Old quote mode | ||
SWAP_TC_TO_TC = 'SWAP:TC-TC', | ||
SWAP_ETH_TO_TC = 'SWAP:ERC20-TC', | ||
SWAP_TC_TO_ETH = 'SWAP:TC-ERC20', | ||
SWAP_ETH_TO_ETH = 'SWAP:ERC20-ERC20', | ||
SWAP_TC_TO_TC = "SWAP:TC-TC", | ||
SWAP_ETH_TO_TC = "SWAP:ERC20-TC", | ||
SWAP_TC_TO_ETH = "SWAP:TC-ERC20", | ||
SWAP_ETH_TO_ETH = "SWAP:ERC20-ERC20", | ||
// Old quote mode: AVAX | ||
SWAP_AVAX_TO_TC = 'SWAP:AVAX-TC', | ||
SWAP_TC_TO_AVAX = 'SWAP:TC-AVAX', | ||
SWAP_AVAX_TO_AVAX = 'SWAP:AVAX-AVAX', | ||
SWAP_ETH_TO_AVAX = 'SWAP:ETH-AVAX', | ||
SWAP_AVAX_TO_ETH = 'SWAP:AVAX-ETH', | ||
SWAP_AVAX_TO_TC = "SWAP:AVAX-TC", | ||
SWAP_TC_TO_AVAX = "SWAP:TC-AVAX", | ||
SWAP_AVAX_TO_AVAX = "SWAP:AVAX-AVAX", | ||
SWAP_ETH_TO_AVAX = "SWAP:ETH-AVAX", | ||
SWAP_AVAX_TO_ETH = "SWAP:AVAX-ETH", | ||
// ATOM | ||
SWAP_TC_TO_GAIA = 'SWAP:TC-GAIA', | ||
SWAP_GAIA_TO_TC = 'SWAP:GAIA-TC', | ||
SWAP_TC_TO_GAIA = "SWAP:TC-GAIA", | ||
SWAP_GAIA_TO_TC = "SWAP:GAIA-TC", | ||
// BNB | ||
SWAP_TC_TO_BNB = 'SWAP:TC-BNB', | ||
SWAP_BNB_TO_TC = 'SWAP:BNB-TC', | ||
SWAP_TC_TO_BNB = "SWAP:TC-BNB", | ||
SWAP_BNB_TO_TC = "SWAP:BNB-TC", | ||
// BTC | ||
SWAP_TC_TO_BTC = 'SWAP:TC-BTC', | ||
SWAP_BTC_TO_TC = 'SWAP:BTC-TC', | ||
SWAP_TC_TO_BTC = "SWAP:TC-BTC", | ||
SWAP_BTC_TO_TC = "SWAP:BTC-TC", | ||
// BCH | ||
SWAP_TC_TO_BCH = 'SWAP:TC-BCH', | ||
SWAP_BCH_TO_TC = 'SWAP:BCH-TC', | ||
SWAP_TC_TO_BCH = "SWAP:TC-BCH", | ||
SWAP_BCH_TO_TC = "SWAP:BCH-TC", | ||
// LTC | ||
SWAP_TC_TO_LTC = 'SWAP:TC-LTC', | ||
SWAP_LTC_TO_TC = 'SWAP:LTC-TC', | ||
SWAP_TC_TO_LTC = "SWAP:TC-LTC", | ||
SWAP_LTC_TO_TC = "SWAP:LTC-TC", | ||
// DOGE | ||
SWAP_TC_TO_DOGE = 'SWAP:TC-DOGE', | ||
SWAP_DOGE_TO_TC = 'SWAP:DOGE-TC', | ||
SWAP_TC_TO_DOGE = "SWAP:TC-DOGE", | ||
SWAP_DOGE_TO_TC = "SWAP:DOGE-TC", | ||
// TC txns | ||
TC_STATUS = 'TC:STATUS', // only track status | ||
TC_TRANSFER = 'TC:TRANSFER', // only track status | ||
TC_DEPOSIT = 'TC:DEPOSIT', | ||
TC_SEND = 'TC:SEND', | ||
TC_SWITCH = 'TC:SWITCH', | ||
TC_LP_ADD = 'TC:ADDLIQUIDITY', | ||
TC_LP_WITHDRAW = 'TC:WITHDRAW', // Supports 'WITHDRAWLIQUIDITY' as well | ||
TC_TNS_CREATE = 'TC:TNS-CREATE', | ||
TC_TNS_EXTEND = 'TC:TNS-EXTEND', | ||
TC_TNS_UPDATE = 'TC:TNS-UPDATE', | ||
TC_STATUS = "TC:STATUS", // only track status | ||
TC_TRANSFER = "TC:TRANSFER", // only track status | ||
TC_DEPOSIT = "TC:DEPOSIT", | ||
TC_SEND = "TC:SEND", | ||
TC_SWITCH = "TC:SWITCH", | ||
TC_LP_ADD = "TC:ADDLIQUIDITY", | ||
TC_LP_WITHDRAW = "TC:WITHDRAW", // Supports 'WITHDRAWLIQUIDITY' as well | ||
TC_TNS_CREATE = "TC:TNS-CREATE", | ||
TC_TNS_EXTEND = "TC:TNS-EXTEND", | ||
TC_TNS_UPDATE = "TC:TNS-UPDATE", | ||
// SAVINGS | ||
TC_SAVINGS_ADD = 'TC:ADDSAVINGS', | ||
TC_SAVINGS_WITHDRAW = 'TC:WITHDRAWSAVINGS', | ||
TC_SAVINGS_ADD = "TC:ADDSAVINGS", | ||
TC_SAVINGS_WITHDRAW = "TC:WITHDRAWSAVINGS", | ||
// LENDING | ||
TC_LENDING_OPEN = 'TC:LENDINGOPEN', | ||
TC_LENDING_CLOSE = 'TC:LENDINGCLOSE', | ||
TC_LENDING_OPEN = "TC:LENDINGOPEN", | ||
TC_LENDING_CLOSE = "TC:LENDINGCLOSE", | ||
// ERC-20 txns | ||
ETH_APPROVAL = 'ETH:APPROVAL', | ||
ETH_STATUS = 'ETH:STATUS', // only track status | ||
ETH_TRANSFER_TO_TC = 'ETH:TRANSFER:IN', | ||
ETH_TRANSFER_FROM_TC = 'ETH:TRANSFER:OUT', | ||
ETH_APPROVAL = "ETH:APPROVAL", | ||
ETH_STATUS = "ETH:STATUS", // only track status | ||
ETH_TRANSFER_TO_TC = "ETH:TRANSFER:IN", | ||
ETH_TRANSFER_FROM_TC = "ETH:TRANSFER:OUT", | ||
// AVAX | ||
AVAX_APPROVAL = 'AVAX:APPROVAL', | ||
AVAX_STATUS = 'AVAX:STATUS', // only track status | ||
AVAX_TRANSFER_TO_TC = 'AVAX:TRANSFER:IN', | ||
AVAX_TRANSFER_FROM_TC = 'AVAX:TRANSFER:OUT', | ||
AVAX_APPROVAL = "AVAX:APPROVAL", | ||
AVAX_STATUS = "AVAX:STATUS", // only track status | ||
AVAX_TRANSFER_TO_TC = "AVAX:TRANSFER:IN", | ||
AVAX_TRANSFER_FROM_TC = "AVAX:TRANSFER:OUT", | ||
// BSC | ||
BSC_APPROVAL = 'BSC:APPROVAL', | ||
BSC_STATUS = 'BSC:STATUS', // only track status | ||
BSC_TRANSFER_TO_TC = 'BSC:TRANSFER:IN', | ||
BSC_TRANSFER_FROM_TC = 'BSC:TRANSFER:OUT', | ||
BSC_APPROVAL = "BSC:APPROVAL", | ||
BSC_STATUS = "BSC:STATUS", // only track status | ||
BSC_TRANSFER_TO_TC = "BSC:TRANSFER:IN", | ||
BSC_TRANSFER_FROM_TC = "BSC:TRANSFER:OUT", | ||
// Generic types | ||
APPROVAL = 'APPROVAL', | ||
STATUS = 'STATUS', | ||
TRANSFER_TO_TC = 'TRANSFER:IN', | ||
TRANSFER_FROM_TC = 'TRANSFER:OUT', | ||
APPROVAL = "APPROVAL", | ||
STATUS = "STATUS", | ||
TRANSFER_TO_TC = "TRANSFER:IN", | ||
TRANSFER_FROM_TC = "TRANSFER:OUT", | ||
// Unsupported | ||
UNSUPPORTED = 'UNSUPPORTED', | ||
UNSUPPORTED = "UNSUPPORTED", | ||
// Lending | ||
TC_LENDING = 'TC:LENDING', | ||
TC_LENDING = "TC:LENDING", | ||
} | ||
export enum TxStatus { | ||
PENDING = 'pending', | ||
SUCCESS = 'success', | ||
CANCELLED = 'cancelled', | ||
REFUNDED = 'refunded', | ||
REPLACED = 'replaced', | ||
ERROR = 'error', | ||
UNKNOWN = 'unknown', | ||
NOT_STARTED = 'not_started', | ||
NOT_FOUND = 'not_found', | ||
RETRIES_EXCEEDED = 'retries_exceeded', | ||
STREAMING = 'streaming', | ||
PENDING = "pending", | ||
SUCCESS = "success", | ||
CANCELLED = "cancelled", | ||
REFUNDED = "refunded", | ||
REPLACED = "replaced", | ||
ERROR = "error", | ||
UNKNOWN = "unknown", | ||
NOT_STARTED = "not_started", | ||
NOT_FOUND = "not_found", | ||
RETRIES_EXCEEDED = "retries_exceeded", | ||
STREAMING = "streaming", | ||
} | ||
@@ -222,5 +222,5 @@ | ||
tokens: { identifier: string }[]; | ||
metadata?: 'true' | 'false'; | ||
lookup?: 'true' | 'false'; | ||
sparkline?: 'true' | 'false'; | ||
metadata?: "true" | "false"; | ||
lookup?: "true" | "false"; | ||
sparkline?: "true" | "false"; | ||
}; | ||
@@ -227,0 +227,0 @@ |
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
3
249437
13
1320
+ Added@swapkit/types@1.0.0-rc.38(transitive)
- Removed@swapkit/types@1.0.0-rc.37(transitive)
Updated@swapkit/types@1.0.0-rc.38