@lifi/sdk 4.8.1 → 4.9.0
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/CHANGELOG.md +32 -0
- package/dist/cjs/actions/getChains.js +7 -1
- package/dist/cjs/actions/getChains.js.map +1 -1
- package/dist/cjs/actions/getContractCallsQuote.js +1 -1
- package/dist/cjs/actions/getGasRecommendation.js +1 -1
- package/dist/cjs/actions/getQuote.js +1 -1
- package/dist/cjs/actions/getRelayedTransactionStatus.js +1 -1
- package/dist/cjs/actions/getRelayerQuote.js +1 -1
- package/dist/cjs/actions/getRoutes.js +1 -1
- package/dist/cjs/actions/getStatus.js +1 -1
- package/dist/cjs/actions/getToken.js +1 -1
- package/dist/cjs/actions/getTokens.js +7 -1
- package/dist/cjs/actions/getTokens.js.map +1 -1
- package/dist/cjs/actions/relayTransaction.js +1 -1
- package/dist/cjs/client/createClient.js +27 -6
- package/dist/cjs/client/createClient.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/types/core.d.ts +56 -1
- package/dist/cjs/utils/checkPackageUpdates.js +1 -1
- package/dist/cjs/utils/convertQuoteToRoute.js +1 -1
- package/dist/cjs/utils/request.js +2 -2
- package/dist/cjs/utils/withDedupe.d.ts +15 -2
- package/dist/cjs/utils/withDedupe.js +70 -7
- package/dist/cjs/utils/withDedupe.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/actions/getChains.d.ts.map +1 -1
- package/dist/esm/actions/getChains.js +7 -1
- package/dist/esm/actions/getChains.js.map +1 -1
- package/dist/esm/actions/getContractCallsQuote.js +1 -1
- package/dist/esm/actions/getGasRecommendation.js +1 -1
- package/dist/esm/actions/getQuote.js +1 -1
- package/dist/esm/actions/getRelayedTransactionStatus.js +1 -1
- package/dist/esm/actions/getRelayerQuote.js +1 -1
- package/dist/esm/actions/getRoutes.js +1 -1
- package/dist/esm/actions/getStatus.js +1 -1
- package/dist/esm/actions/getToken.js +1 -1
- package/dist/esm/actions/getTokens.d.ts.map +1 -1
- package/dist/esm/actions/getTokens.js +7 -1
- package/dist/esm/actions/getTokens.js.map +1 -1
- package/dist/esm/actions/relayTransaction.js +1 -1
- package/dist/esm/client/createClient.d.ts.map +1 -1
- package/dist/esm/client/createClient.js +27 -6
- package/dist/esm/client/createClient.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/types/core.d.ts +56 -1
- package/dist/esm/types/core.d.ts.map +1 -1
- package/dist/esm/utils/checkPackageUpdates.js +1 -1
- package/dist/esm/utils/convertQuoteToRoute.js +1 -1
- package/dist/esm/utils/request.js +2 -2
- package/dist/esm/utils/withDedupe.d.ts +15 -2
- package/dist/esm/utils/withDedupe.d.ts.map +1 -1
- package/dist/esm/utils/withDedupe.js +70 -7
- package/dist/esm/utils/withDedupe.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +1 -1
- package/src/actions/getChains.ts +12 -4
- package/src/actions/getTokens.ts +12 -4
- package/src/client/createClient.ts +47 -3
- package/src/index.ts +2 -0
- package/src/types/core.ts +59 -1
- package/src/utils/withDedupe.ts +127 -9
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getChains.js","names":[],"sources":["../../../src/actions/getChains.ts"],"sourcesContent":["import type {\n ChainsRequest,\n ChainsResponse,\n ExtendedChain,\n RequestOptions,\n} from '@lifi/types'\nimport type { SDKBaseConfig, SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\nimport { withDedupe } from '../utils/withDedupe.js'\n\n/**\n * Get all available chains\n * @param client - The SDK client\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n * @throws {LiFiError} Throws a LiFiError if request fails.\n */\nexport const getChains = async (\n client: SDKClient,\n params?: ChainsRequest,\n options?: RequestOptions\n): Promise<ExtendedChain[]> => {\n return await _getChains(client.config, params, options)\n}\n\nexport const _getChains = async (\n config: SDKBaseConfig,\n params?: ChainsRequest,\n options?: RequestOptions\n): Promise<ExtendedChain[]> => {\n if (params) {\n for (const key of Object.keys(params)) {\n const value = params[key as keyof ChainsRequest]\n if (value === undefined || value === null) {\n delete params[key as keyof ChainsRequest]\n }\n }\n }\n const urlSearchParams = new URLSearchParams(\n params as Record<string, string>\n ).toString()\n const response = await withDedupe(\n () =>\n request<ChainsResponse>(\n config,\n `${config.apiUrl}/chains?${urlSearchParams}`,\n {\n signal
|
|
1
|
+
{"version":3,"file":"getChains.js","names":[],"sources":["../../../src/actions/getChains.ts"],"sourcesContent":["import type {\n ChainsRequest,\n ChainsResponse,\n ExtendedChain,\n RequestOptions,\n} from '@lifi/types'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKBaseConfig, SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\nimport { withDedupe } from '../utils/withDedupe.js'\n\n/**\n * Get all available chains\n * @param client - The SDK client\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n * @throws {LiFiError} Throws a LiFiError if request fails.\n */\nexport const getChains = async (\n client: SDKClient,\n params?: ChainsRequest,\n options?: RequestOptions\n): Promise<ExtendedChain[]> => {\n return await _getChains(client.config, params, options)\n}\n\nexport const _getChains = async (\n config: SDKBaseConfig,\n params?: ChainsRequest,\n options?: RequestOptions\n): Promise<ExtendedChain[]> => {\n if (params) {\n for (const key of Object.keys(params)) {\n const value = params[key as keyof ChainsRequest]\n if (value === undefined || value === null) {\n delete params[key as keyof ChainsRequest]\n }\n }\n }\n const urlSearchParams = new URLSearchParams(\n params as Record<string, string>\n ).toString()\n const response = await withDedupe(\n (signal) =>\n request<ChainsResponse>(\n config,\n `${config.apiUrl}/chains?${urlSearchParams}`,\n {\n signal,\n }\n ),\n {\n id: `${getChains.name}.${config.apiUrl}.${urlSearchParams}`,\n signal: options?.signal,\n }\n ).catch((error) => {\n // A caller that aborts leaves before the request settles; keep its error\n // shaped like one from `request`.\n throw error instanceof SDKError ? error : new SDKError(error)\n })\n return response.chains\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,MAAa,YAAY,OACvB,QACA,QACA,YAC6B;CAC7B,OAAO,MAAM,WAAW,OAAO,QAAQ,QAAQ,OAAO;AACxD;AAEA,MAAa,aAAa,OACxB,QACA,QACA,YAC6B;CAC7B,IAAI,QACF,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAAG;EACrC,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,OAAO,OAAO;CAElB;CAEF,MAAM,kBAAkB,IAAI,gBAC1B,MACF,CAAC,CAAC,SAAS;CAmBX,QAAO,MAlBgB,YACpB,WACC,QACE,QACA,GAAG,OAAO,OAAO,UAAU,mBAC3B,EACE,OACF,CACF,GACF;EACE,IAAI,GAAG,UAAU,KAAK,GAAG,OAAO,OAAO,GAAG;EAC1C,QAAQ,SAAS;CACnB,CACF,CAAC,CAAC,OAAO,UAAU;EAGjB,MAAM,iBAAiB,WAAW,QAAQ,IAAI,SAAS,KAAK;CAC9D,CAAC,EAAA,CACe;AAClB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ValidationError } from "../errors/errors.js";
|
|
2
1
|
import { SDKError } from "../errors/SDKError.js";
|
|
2
|
+
import { ValidationError } from "../errors/errors.js";
|
|
3
3
|
import { request } from "../utils/request.js";
|
|
4
4
|
import { isContractCallsRequestWithFromAmount, isContractCallsRequestWithToAmount } from "@lifi/types";
|
|
5
5
|
//#region src/actions/getContractCallsQuote.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ValidationError } from "../errors/errors.js";
|
|
2
1
|
import { SDKError } from "../errors/SDKError.js";
|
|
2
|
+
import { ValidationError } from "../errors/errors.js";
|
|
3
3
|
import { request } from "../utils/request.js";
|
|
4
4
|
import { toQueryString } from "../utils/toQueryString.js";
|
|
5
5
|
//#region src/actions/getQuote.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { SDKError } from "../errors/SDKError.js";
|
|
1
2
|
import { BaseError } from "../errors/baseError.js";
|
|
2
3
|
import "../errors/constants.js";
|
|
3
4
|
import { ValidationError } from "../errors/errors.js";
|
|
4
|
-
import { SDKError } from "../errors/SDKError.js";
|
|
5
5
|
import { request } from "../utils/request.js";
|
|
6
6
|
import { decodeTaskId } from "../utils/decode.js";
|
|
7
7
|
import { getStatus } from "./getStatus.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { SDKError } from "../errors/SDKError.js";
|
|
1
2
|
import { BaseError } from "../errors/baseError.js";
|
|
2
3
|
import "../errors/constants.js";
|
|
3
4
|
import { ValidationError } from "../errors/errors.js";
|
|
4
|
-
import { SDKError } from "../errors/SDKError.js";
|
|
5
5
|
import { request } from "../utils/request.js";
|
|
6
6
|
//#region src/actions/getRelayerQuote.ts
|
|
7
7
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ValidationError } from "../errors/errors.js";
|
|
2
1
|
import { SDKError } from "../errors/SDKError.js";
|
|
2
|
+
import { ValidationError } from "../errors/errors.js";
|
|
3
3
|
import { request } from "../utils/request.js";
|
|
4
4
|
import { isRoutesRequest } from "../utils/isRoutesRequest.js";
|
|
5
5
|
//#region src/actions/getRoutes.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTokens.d.ts","names":[],"sources":["../../../src/actions/getTokens.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getTokens.d.ts","names":[],"sources":["../../../src/actions/getTokens.ts"],"mappings":";;;;;;;;;;wBAkBsB,UACpB,QAAQ,WACR,SAAS;EAAkB;GAC3B,UAAU,iBACT,QAAQ;wBACW,UACpB,QAAQ,WACR,QAAQ;EAAkB;GAC1B,UAAU,iBACT,QAAQ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SDKError } from "../errors/SDKError.js";
|
|
1
2
|
import { request } from "../utils/request.js";
|
|
2
3
|
import { withDedupe } from "../utils/withDedupe.js";
|
|
3
4
|
//#region src/actions/getTokens.ts
|
|
@@ -8,7 +9,12 @@ async function getTokens(client, params, options) {
|
|
|
8
9
|
}
|
|
9
10
|
const urlSearchParams = new URLSearchParams(params).toString();
|
|
10
11
|
params?.extended;
|
|
11
|
-
return await withDedupe(() => request(client.config, `${client.config.apiUrl}/tokens?${urlSearchParams}`, { signal
|
|
12
|
+
return await withDedupe((signal) => request(client.config, `${client.config.apiUrl}/tokens?${urlSearchParams}`, { signal }), {
|
|
13
|
+
id: `${getTokens.name}.${client.config.apiUrl}.${urlSearchParams}`,
|
|
14
|
+
signal: options?.signal
|
|
15
|
+
}).catch((error) => {
|
|
16
|
+
throw error instanceof SDKError ? error : new SDKError(error);
|
|
17
|
+
});
|
|
12
18
|
}
|
|
13
19
|
//#endregion
|
|
14
20
|
export { getTokens };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTokens.js","names":[],"sources":["../../../src/actions/getTokens.ts"],"sourcesContent":["import type {\n RequestOptions,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n} from '@lifi/types'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\nimport { withDedupe } from '../utils/withDedupe.js'\n\n/**\n * Get all known tokens.\n * @param client - The SDK client\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns The tokens that are available on the requested chains\n */\nexport async function getTokens(\n client: SDKClient,\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n): Promise<TokensResponse>\nexport async function getTokens(\n client: SDKClient,\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n): Promise<TokensExtendedResponse>\nexport async function getTokens(\n client: SDKClient,\n params?: TokensRequest,\n options?: RequestOptions\n): Promise<TokensResponse> {\n if (params) {\n for (const key of Object.keys(params)) {\n const value = params[key as keyof TokensRequest]\n if (value === undefined || value === null) {\n delete params[key as keyof TokensRequest]\n }\n }\n }\n const urlSearchParams = new URLSearchParams(\n params as Record<string, string>\n ).toString()\n const _isExtended = params?.extended === true\n const response = await withDedupe(\n () =>\n request<\n typeof _isExtended extends true\n ? TokensExtendedResponse\n : TokensResponse\n >(client.config, `${client.config.apiUrl}/tokens?${urlSearchParams}`, {\n signal
|
|
1
|
+
{"version":3,"file":"getTokens.js","names":[],"sources":["../../../src/actions/getTokens.ts"],"sourcesContent":["import type {\n RequestOptions,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n} from '@lifi/types'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\nimport { withDedupe } from '../utils/withDedupe.js'\n\n/**\n * Get all known tokens.\n * @param client - The SDK client\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns The tokens that are available on the requested chains\n */\nexport async function getTokens(\n client: SDKClient,\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n): Promise<TokensResponse>\nexport async function getTokens(\n client: SDKClient,\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n): Promise<TokensExtendedResponse>\nexport async function getTokens(\n client: SDKClient,\n params?: TokensRequest,\n options?: RequestOptions\n): Promise<TokensResponse> {\n if (params) {\n for (const key of Object.keys(params)) {\n const value = params[key as keyof TokensRequest]\n if (value === undefined || value === null) {\n delete params[key as keyof TokensRequest]\n }\n }\n }\n const urlSearchParams = new URLSearchParams(\n params as Record<string, string>\n ).toString()\n const _isExtended = params?.extended === true\n const response = await withDedupe(\n (signal) =>\n request<\n typeof _isExtended extends true\n ? TokensExtendedResponse\n : TokensResponse\n >(client.config, `${client.config.apiUrl}/tokens?${urlSearchParams}`, {\n signal,\n }),\n {\n id: `${getTokens.name}.${client.config.apiUrl}.${urlSearchParams}`,\n signal: options?.signal,\n }\n ).catch((error) => {\n // A caller that aborts leaves before the request settles; keep its error\n // shaped like one from `request`.\n throw error instanceof SDKError ? error : new SDKError(error)\n })\n return response\n}\n"],"mappings":";;;;AA4BA,eAAsB,UACpB,QACA,QACA,SACyB;CACzB,IAAI,QACF,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAAG;EACrC,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,OAAO,OAAO;CAElB;CAEF,MAAM,kBAAkB,IAAI,gBAC1B,MACF,CAAC,CAAC,SAAS;CACS,QAAQ;CAmB5B,OAAO,MAlBgB,YACpB,WACC,QAIE,OAAO,QAAQ,GAAG,OAAO,OAAO,OAAO,UAAU,mBAAmB,EACpE,OACF,CAAC,GACH;EACE,IAAI,GAAG,UAAU,KAAK,GAAG,OAAO,OAAO,OAAO,GAAG;EACjD,QAAQ,SAAS;CACnB,CACF,CAAC,CAAC,OAAO,UAAU;EAGjB,MAAM,iBAAiB,WAAW,QAAQ,IAAI,SAAS,KAAK;CAC9D,CAAC;AAEH"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { SDKError } from "../errors/SDKError.js";
|
|
1
2
|
import { BaseError } from "../errors/baseError.js";
|
|
2
3
|
import "../errors/constants.js";
|
|
3
4
|
import { ValidationError } from "../errors/errors.js";
|
|
4
|
-
import { SDKError } from "../errors/SDKError.js";
|
|
5
5
|
import { request } from "../utils/request.js";
|
|
6
6
|
//#region src/actions/relayTransaction.ts
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.d.ts","names":[],"sources":["../../../src/client/createClient.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"createClient.d.ts","names":[],"sources":["../../../src/client/createClient.ts"],"mappings":";;wBAYgB,aAAa,SAAS,YAAY"}
|
|
@@ -5,11 +5,26 @@ import { getClientStorage } from "./getClientStorage.js";
|
|
|
5
5
|
function createClient(options) {
|
|
6
6
|
if (!options.integrator) throw new Error("Integrator not found. Please see documentation https://docs.li.fi/integrate-li.fi-js-sdk/set-up-the-sdk");
|
|
7
7
|
if (!options.disableVersionCheck && process.env.NODE_ENV === "development") checkPackageUpdates(name, version);
|
|
8
|
-
const { providers, ...configOptions } = options;
|
|
8
|
+
const { providers, rpcUrls, ...configOptions } = options;
|
|
9
|
+
const readRpcUrls = {};
|
|
10
|
+
const writeRpcUrls = {};
|
|
11
|
+
const bundleRpcUrls = {};
|
|
12
|
+
let hasRoles = false;
|
|
13
|
+
for (const key in rpcUrls) {
|
|
14
|
+
const chainId = Number(key);
|
|
15
|
+
const entry = rpcUrls[chainId];
|
|
16
|
+
if (Array.isArray(entry)) readRpcUrls[chainId] = entry;
|
|
17
|
+
else if (entry) {
|
|
18
|
+
hasRoles = true;
|
|
19
|
+
if (entry.read) readRpcUrls[chainId] = entry.read;
|
|
20
|
+
if (entry.write?.length) writeRpcUrls[chainId] = entry.write;
|
|
21
|
+
if (entry.bundle?.length) bundleRpcUrls[chainId] = entry.bundle;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
9
24
|
const _config = {
|
|
10
25
|
...configOptions,
|
|
11
26
|
apiUrl: configOptions?.apiUrl ?? "https://li.quest/v1",
|
|
12
|
-
rpcUrls:
|
|
27
|
+
rpcUrls: hasRoles ? readRpcUrls : rpcUrls ?? {},
|
|
13
28
|
debug: configOptions?.debug ?? false,
|
|
14
29
|
preloadChains: configOptions?.preloadChains ?? true,
|
|
15
30
|
integrator: configOptions?.integrator ?? "lifi-sdk"
|
|
@@ -49,15 +64,21 @@ function createClient(options) {
|
|
|
49
64
|
const chainRpcUrls = (await this.getRpcUrls())[chainId];
|
|
50
65
|
if (!chainRpcUrls?.length) throw new Error(`RPC URL not found for chainId: ${chainId}`);
|
|
51
66
|
return chainRpcUrls;
|
|
67
|
+
},
|
|
68
|
+
async getWriteRpcUrlsByChainId(chainId) {
|
|
69
|
+
return writeRpcUrls[chainId] ?? [];
|
|
70
|
+
},
|
|
71
|
+
async getBundleRpcUrlsByChainId(chainId) {
|
|
72
|
+
return bundleRpcUrls[chainId] ?? [];
|
|
52
73
|
}
|
|
53
74
|
};
|
|
54
75
|
function extend(base) {
|
|
55
76
|
return (extendFn) => {
|
|
56
77
|
const extensions = extendFn(base);
|
|
57
|
-
const extended = {
|
|
58
|
-
...base,
|
|
59
|
-
...extensions
|
|
60
|
-
};
|
|
78
|
+
const extended = Object.defineProperties({}, {
|
|
79
|
+
...Object.getOwnPropertyDescriptors(base),
|
|
80
|
+
...Object.getOwnPropertyDescriptors(extensions)
|
|
81
|
+
});
|
|
61
82
|
return Object.assign(extended, { extend: extend(extended) });
|
|
62
83
|
};
|
|
63
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","names":[],"sources":["../../../src/client/createClient.ts"],"sourcesContent":["import type { ChainId, ChainType, ExtendedChain } from '@lifi/types'\nimport type {\n SDKBaseConfig,\n SDKClient,\n SDKConfig,\n SDKProvider,\n} from '../types/core.js'\nimport { checkPackageUpdates } from '../utils/checkPackageUpdates.js'\nimport { name, version } from '../version.js'\nimport { getClientStorage } from './getClientStorage.js'\n\nexport function createClient(options: SDKConfig): SDKClient {\n if (!options.integrator) {\n throw new Error(\n 'Integrator not found. Please see documentation https://docs.li.fi/integrate-li.fi-js-sdk/set-up-the-sdk'\n )\n }\n\n if (!options.disableVersionCheck && process.env.NODE_ENV === 'development') {\n checkPackageUpdates(name, version)\n }\n\n const { providers, ...configOptions } = options\n\n const _config: SDKBaseConfig = {\n ...configOptions,\n apiUrl: configOptions?.apiUrl ?? 'https://li.quest/v1',\n rpcUrls:
|
|
1
|
+
{"version":3,"file":"createClient.js","names":[],"sources":["../../../src/client/createClient.ts"],"sourcesContent":["import type { ChainId, ChainType, ExtendedChain } from '@lifi/types'\nimport type {\n RPCUrls,\n SDKBaseConfig,\n SDKClient,\n SDKConfig,\n SDKProvider,\n} from '../types/core.js'\nimport { checkPackageUpdates } from '../utils/checkPackageUpdates.js'\nimport { name, version } from '../version.js'\nimport { getClientStorage } from './getClientStorage.js'\n\nexport function createClient(options: SDKConfig): SDKClient {\n if (!options.integrator) {\n throw new Error(\n 'Integrator not found. Please see documentation https://docs.li.fi/integrate-li.fi-js-sdk/set-up-the-sdk'\n )\n }\n\n if (!options.disableVersionCheck && process.env.NODE_ENV === 'development') {\n checkPackageUpdates(name, version)\n }\n\n const { providers, rpcUrls, ...configOptions } = options\n\n // Role entries split once, here: the config keeps plain read lists, so\n // everything that reads `config.rpcUrls` sees `string[]` as before.\n const readRpcUrls: RPCUrls = {}\n const writeRpcUrls: RPCUrls = {}\n const bundleRpcUrls: RPCUrls = {}\n let hasRoles = false\n for (const key in rpcUrls) {\n const chainId = Number(key) as ChainId\n const entry = rpcUrls[chainId]\n if (Array.isArray(entry)) {\n readRpcUrls[chainId] = entry\n } else if (entry) {\n hasRoles = true\n if (entry.read) {\n readRpcUrls[chainId] = entry.read\n }\n if (entry.write?.length) {\n writeRpcUrls[chainId] = entry.write\n }\n if (entry.bundle?.length) {\n bundleRpcUrls[chainId] = entry.bundle\n }\n }\n }\n\n const _config: SDKBaseConfig = {\n ...configOptions,\n apiUrl: configOptions?.apiUrl ?? 'https://li.quest/v1',\n // Plain lists only: the caller's own object, exactly as before.\n rpcUrls: hasRoles ? readRpcUrls : ((rpcUrls ?? {}) as RPCUrls),\n debug: configOptions?.debug ?? false,\n preloadChains: configOptions?.preloadChains ?? true,\n integrator: configOptions?.integrator ?? 'lifi-sdk',\n }\n\n let _providers: SDKProvider[] = providers ?? []\n const _storage = getClientStorage(_config)\n\n const client: SDKClient = {\n get config() {\n return _config\n },\n get providers() {\n return _providers\n },\n getProvider(type: ChainType) {\n return this.providers.find((provider) => provider.type === type)\n },\n setProviders(newProviders: SDKProvider[]) {\n const providerMap = new Map(\n this.providers.map((provider) => [provider.type, provider])\n )\n for (const provider of newProviders) {\n providerMap.set(provider.type, provider)\n }\n _providers = Array.from(providerMap.values())\n },\n setChains(chains: ExtendedChain[]) {\n _storage.setChains(chains)\n },\n async getChains() {\n return await _storage.getChains()\n },\n async getChainById(chainId: ChainId) {\n const chains = await this.getChains()\n const chain = chains?.find((chain) => chain.id === chainId)\n if (!chain) {\n throw new Error(`ChainId ${chainId} not found`)\n }\n return chain\n },\n async getRpcUrls() {\n return await _storage.getRpcUrls()\n },\n async getRpcUrlsByChainId(chainId: ChainId) {\n const rpcUrls = await this.getRpcUrls()\n const chainRpcUrls = rpcUrls[chainId]\n if (!chainRpcUrls?.length) {\n throw new Error(`RPC URL not found for chainId: ${chainId}`)\n }\n return chainRpcUrls\n },\n async getWriteRpcUrlsByChainId(chainId: ChainId) {\n return writeRpcUrls[chainId] ?? []\n },\n async getBundleRpcUrlsByChainId(chainId: ChainId) {\n return bundleRpcUrls[chainId] ?? []\n },\n }\n\n function extend<TClient extends SDKClient>(\n base: TClient\n ): <TExtensions extends Record<string, any>>(\n extendFn: (client: TClient) => TExtensions\n ) => TClient & TExtensions {\n return (extendFn) => {\n const extensions = extendFn(base)\n // Copy descriptors rather than spreading. `config` and `providers` are\n // accessors over closure variables, and `setProviders` reassigns\n // `_providers` — so a spread would freeze the extension on the values\n // those getters happened to return at extend time, leaving it with a\n // provider list that never updates.\n const extended = Object.defineProperties(\n {},\n {\n ...Object.getOwnPropertyDescriptors(base),\n ...Object.getOwnPropertyDescriptors(extensions),\n }\n ) as TClient & typeof extensions\n\n // Preserve the extend function for further extensions\n return Object.assign(extended, {\n extend: extend(extended),\n })\n }\n }\n\n return Object.assign(client, { extend: extend(client) })\n}\n"],"mappings":";;;;AAYA,SAAgB,aAAa,SAA+B;CAC1D,IAAI,CAAC,QAAQ,YACX,MAAM,IAAI,MACR,yGACF;CAGF,IAAI,CAAC,QAAQ,uBAAuB,QAAQ,IAAI,aAAa,eAC3D,oBAAoB,MAAM,OAAO;CAGnC,MAAM,EAAE,WAAW,SAAS,GAAG,kBAAkB;CAIjD,MAAM,cAAuB,CAAC;CAC9B,MAAM,eAAwB,CAAC;CAC/B,MAAM,gBAAyB,CAAC;CAChC,IAAI,WAAW;CACf,KAAK,MAAM,OAAO,SAAS;EACzB,MAAM,UAAU,OAAO,GAAG;EAC1B,MAAM,QAAQ,QAAQ;EACtB,IAAI,MAAM,QAAQ,KAAK,GACrB,YAAY,WAAW;OAClB,IAAI,OAAO;GAChB,WAAW;GACX,IAAI,MAAM,MACR,YAAY,WAAW,MAAM;GAE/B,IAAI,MAAM,OAAO,QACf,aAAa,WAAW,MAAM;GAEhC,IAAI,MAAM,QAAQ,QAChB,cAAc,WAAW,MAAM;EAEnC;CACF;CAEA,MAAM,UAAyB;EAC7B,GAAG;EACH,QAAQ,eAAe,UAAU;EAEjC,SAAS,WAAW,cAAgB,WAAW,CAAC;EAChD,OAAO,eAAe,SAAS;EAC/B,eAAe,eAAe,iBAAiB;EAC/C,YAAY,eAAe,cAAc;CAC3C;CAEA,IAAI,aAA4B,aAAa,CAAC;CAC9C,MAAM,WAAW,iBAAiB,OAAO;CAEzC,MAAM,SAAoB;EACxB,IAAI,SAAS;GACX,OAAO;EACT;EACA,IAAI,YAAY;GACd,OAAO;EACT;EACA,YAAY,MAAiB;GAC3B,OAAO,KAAK,UAAU,MAAM,aAAa,SAAS,SAAS,IAAI;EACjE;EACA,aAAa,cAA6B;GACxC,MAAM,cAAc,IAAI,IACtB,KAAK,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,QAAQ,CAAC,CAC5D;GACA,KAAK,MAAM,YAAY,cACrB,YAAY,IAAI,SAAS,MAAM,QAAQ;GAEzC,aAAa,MAAM,KAAK,YAAY,OAAO,CAAC;EAC9C;EACA,UAAU,QAAyB;GACjC,SAAS,UAAU,MAAM;EAC3B;EACA,MAAM,YAAY;GAChB,OAAO,MAAM,SAAS,UAAU;EAClC;EACA,MAAM,aAAa,SAAkB;GAEnC,MAAM,SAAQ,MADO,KAAK,UAAU,EAAA,EACd,MAAM,UAAU,MAAM,OAAO,OAAO;GAC1D,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,WAAW,QAAQ,WAAW;GAEhD,OAAO;EACT;EACA,MAAM,aAAa;GACjB,OAAO,MAAM,SAAS,WAAW;EACnC;EACA,MAAM,oBAAoB,SAAkB;GAE1C,MAAM,gBAAe,MADC,KAAK,WAAW,EAAA,CACT;GAC7B,IAAI,CAAC,cAAc,QACjB,MAAM,IAAI,MAAM,kCAAkC,SAAS;GAE7D,OAAO;EACT;EACA,MAAM,yBAAyB,SAAkB;GAC/C,OAAO,aAAa,YAAY,CAAC;EACnC;EACA,MAAM,0BAA0B,SAAkB;GAChD,OAAO,cAAc,YAAY,CAAC;EACpC;CACF;CAEA,SAAS,OACP,MAGyB;EACzB,QAAQ,aAAa;GACnB,MAAM,aAAa,SAAS,IAAI;GAMhC,MAAM,WAAW,OAAO,iBACtB,CAAC,GACD;IACE,GAAG,OAAO,0BAA0B,IAAI;IACxC,GAAG,OAAO,0BAA0B,UAAU;GAChD,CACF;GAGA,OAAO,OAAO,OAAO,UAAU,EAC7B,QAAQ,OAAO,QAAQ,EACzB,CAAC;EACH;CACF;CAEA,OAAO,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,MAAM,EAAE,CAAC;AACzD"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InMemoryStorage, LocalStorageAdapter, SDKStorage, createDefaultStorage } from "./core/storage.js";
|
|
2
|
-
import { AcceptExchangeRateUpdateHook, AcceptSlippageUpdateHook, AcceptSlippageUpdateHookParams, ContractCallParams, ContractTool, ExchangeRateUpdateParams, ExecuteStepRetryParams, Execution, ExecutionAction, ExecutionActionStatus, ExecutionActionType, ExecutionOptions, ExecutionStatus, GetContractCallsHook, GetContractCallsResult, InteractionSettings, LiFiStepExtended, RPCUrls, RequestInterceptor, RouteExecutionData, RouteExecutionDataDictionary, RouteExecutionDictionary, RouteExtended, SDKBaseConfig, SDKClient, SDKConfig, SDKProvider, StepExecutor, StepExecutorOptions, StepExtended, TransactionMethodType, TransactionParameters, TransactionRequestParameters, TransactionRequestUpdateHook, UpdateRouteHook } from "./types/core.js";
|
|
2
|
+
import { AcceptExchangeRateUpdateHook, AcceptSlippageUpdateHook, AcceptSlippageUpdateHookParams, ContractCallParams, ContractTool, ExchangeRateUpdateParams, ExecuteStepRetryParams, Execution, ExecutionAction, ExecutionActionStatus, ExecutionActionType, ExecutionOptions, ExecutionStatus, GetContractCallsHook, GetContractCallsResult, InteractionSettings, LiFiStepExtended, RPCUrls, RPCUrlsByRole, RPCUrlsConfig, RequestInterceptor, RouteExecutionData, RouteExecutionDataDictionary, RouteExecutionDictionary, RouteExtended, SDKBaseConfig, SDKClient, SDKConfig, SDKProvider, StepExecutor, StepExecutorOptions, StepExtended, TransactionMethodType, TransactionParameters, TransactionRequestParameters, TransactionRequestUpdateHook, UpdateRouteHook } from "./types/core.js";
|
|
3
3
|
import { getChains } from "./actions/getChains.js";
|
|
4
4
|
import { getConnections } from "./actions/getConnections.js";
|
|
5
5
|
import { getContractCallsQuote } from "./actions/getContractCallsQuote.js";
|
|
@@ -53,4 +53,4 @@ import { LruMap, withDedupe } from "./utils/withDedupe.js";
|
|
|
53
53
|
import { withTimeout } from "./utils/withTimeout.js";
|
|
54
54
|
import { name, version } from "./version.js";
|
|
55
55
|
export * from "@lifi/types";
|
|
56
|
-
export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
|
|
56
|
+
export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RPCUrlsByRole, type RPCUrlsConfig, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { name, version } from "./version.js";
|
|
2
|
+
import { SDKError } from "./errors/SDKError.js";
|
|
1
3
|
import { BaseError } from "./errors/baseError.js";
|
|
2
4
|
import { ErrorMessage, ErrorName, LiFiErrorCode } from "./errors/constants.js";
|
|
3
5
|
import { BalanceError, ExecuteStepRetryError, ProviderError, RPCError, ServerError, TransactionError, UnknownError, ValidationError } from "./errors/errors.js";
|
|
4
6
|
import { HTTPError } from "./errors/httpError.js";
|
|
5
|
-
import { name, version } from "./version.js";
|
|
6
|
-
import { SDKError } from "./errors/SDKError.js";
|
|
7
7
|
import { sleep } from "./utils/sleep.js";
|
|
8
8
|
import { LruMap, withDedupe } from "./utils/withDedupe.js";
|
|
9
9
|
import { getChains } from "./actions/getChains.js";
|
package/dist/esm/types/core.d.ts
CHANGED
|
@@ -19,10 +19,51 @@ export interface SDKBaseConfig {
|
|
|
19
19
|
requestInterceptor?: RequestInterceptor;
|
|
20
20
|
storage?: SDKStorage;
|
|
21
21
|
}
|
|
22
|
-
export interface SDKConfig extends Partial<Omit<SDKBaseConfig, "integrator">> {
|
|
22
|
+
export interface SDKConfig extends Partial<Omit<SDKBaseConfig, "integrator" | "rpcUrls">> {
|
|
23
23
|
integrator: string;
|
|
24
|
+
/**
|
|
25
|
+
* Per chain, one list for reads and sends, or lists by role. The client
|
|
26
|
+
* keeps the read lists in `config.rpcUrls` and serves the write and bundle
|
|
27
|
+
* lists through `getWriteRpcUrlsByChainId` and `getBundleRpcUrlsByChainId`.
|
|
28
|
+
*/
|
|
29
|
+
rpcUrls?: RPCUrlsConfig;
|
|
24
30
|
providers?: SDKProvider[];
|
|
25
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* RPC URLs for one chain, split by what they are used for.
|
|
34
|
+
*/
|
|
35
|
+
export interface RPCUrlsByRole {
|
|
36
|
+
/**
|
|
37
|
+
* Reads: balances, simulation and confirmation. Unset, the chain's own RPC
|
|
38
|
+
* URLs serve reads, as for a chain with no `rpcUrls` entry.
|
|
39
|
+
*/
|
|
40
|
+
read?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Sends. Unset or empty, the read URLs send as well. While `write` is set,
|
|
43
|
+
* nothing is sent through the read URLs: when `bundle` is unset, the write
|
|
44
|
+
* URLs that support bundles also submit bundles, and with none of them, a
|
|
45
|
+
* route that needs a bundle fails.
|
|
46
|
+
*
|
|
47
|
+
* Only `@lifi/sdk-provider-solana` uses this today; other providers ignore
|
|
48
|
+
* it.
|
|
49
|
+
*/
|
|
50
|
+
write?: string[];
|
|
51
|
+
/**
|
|
52
|
+
* Bundle submissions (Jito `sendBundle`). Unset, empty, or with no URL that
|
|
53
|
+
* supports bundles, the write URLs that do submit them. While `bundle` or
|
|
54
|
+
* `write` is set, bundles never go to the read URLs.
|
|
55
|
+
*
|
|
56
|
+
* Only `@lifi/sdk-provider-solana` uses this today; other providers ignore
|
|
57
|
+
* it.
|
|
58
|
+
*/
|
|
59
|
+
bundle?: string[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The `rpcUrls` option of `createClient`: per chain, either one list for reads
|
|
63
|
+
* and sends, or lists by role.
|
|
64
|
+
*/
|
|
65
|
+
export type RPCUrlsConfig = Partial<Record<ChainId, string[] | RPCUrlsByRole>>;
|
|
66
|
+
/** RPC URL lists per chain. `client.config.rpcUrls` holds the read lists. */
|
|
26
67
|
export type RPCUrls = Partial<Record<ChainId, string[]>>;
|
|
27
68
|
export interface SDKProvider {
|
|
28
69
|
readonly type: ChainType;
|
|
@@ -47,6 +88,20 @@ export interface SDKClient {
|
|
|
47
88
|
getChainById(chainId: ChainId): Promise<ExtendedChain>;
|
|
48
89
|
getRpcUrls(): Promise<RPCUrls>;
|
|
49
90
|
getRpcUrlsByChainId(chainId: ChainId): Promise<string[]>;
|
|
91
|
+
/**
|
|
92
|
+
* The chain's dedicated write RPC URLs (`rpcUrls[chainId].write`). Empty
|
|
93
|
+
* when the chain has none.
|
|
94
|
+
*
|
|
95
|
+
* Optional so clients from other SDK versions, and hand-written ones, still
|
|
96
|
+
* satisfy `SDKClient`. Providers treat a missing method as no write list.
|
|
97
|
+
*/
|
|
98
|
+
getWriteRpcUrlsByChainId?(chainId: ChainId): Promise<string[]>;
|
|
99
|
+
/**
|
|
100
|
+
* The chain's dedicated bundle RPC URLs (`rpcUrls[chainId].bundle`). Empty
|
|
101
|
+
* when the chain has none. Optional for the same reason as
|
|
102
|
+
* `getWriteRpcUrlsByChainId`.
|
|
103
|
+
*/
|
|
104
|
+
getBundleRpcUrlsByChainId?(chainId: ChainId): Promise<string[]>;
|
|
50
105
|
}
|
|
51
106
|
export interface StepExecutorOptions {
|
|
52
107
|
routeId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","names":[],"sources":["../../../src/types/core.ts"],"mappings":";;;;YAmBY,sBACV,SAAS,wBACN,sBAAsB,QAAQ;iBAElB;EACf;EACA;EACA;EACA;EACA,eAAe;EACf,mBAAmB;EACnB,SAAS;EACT;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB,UAAU;;iBAGK,
|
|
1
|
+
{"version":3,"file":"core.d.ts","names":[],"sources":["../../../src/types/core.ts"],"mappings":";;;;YAmBY,sBACV,SAAS,wBACN,sBAAsB,QAAQ;iBAElB;EACf;EACA;EACA;EACA;EACA,eAAe;EACf,mBAAmB;EACnB,SAAS;EACT;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB,UAAU;;iBAGK,kBACP,QAAQ,KAAK;EACrB;;;;;;EAMA,UAAU;EACV,YAAY;;;;;iBAMG;;;;;EAKf;;;;;;;;;;EAUA;;;;;;;;;EASA;;;;;;YAOU,gBAAgB,QAAQ,OAAO,oBAAoB;;YAGnD,UAAU,QAAQ,OAAO;iBAEpB;WACN,MAAM;EACf,UAAU;;;;;;EAMV,gBAAgB;EAChB,eACE,cACA,QAAQ,WACR,UAAU,SACV,QAAQ,UACP;EACH,gBAAgB,SAAS,sBAAsB,QAAQ;EACvD,WACE,QAAQ,WACR,uBACA,QAAQ,UACP,QAAQ;;iBAGI;EACf,QAAQ;EACR,WAAW;EACX,YAAY,MAAM,YAAY;EAC9B,aAAa,WAAW;EACxB,UAAU,QAAQ;EAClB,aAAa,QAAQ;EACrB,aAAa,SAAS,UAAU,QAAQ;EACxC,cAAc,QAAQ;EACtB,oBAAoB,SAAS,UAAU;;;;;;;;EAQvC,0BAA0B,SAAS,UAAU;;;;;;EAM7C,2BAA2B,SAAS,UAAU;;iBAG/B;EACf;EACA,mBAAmB;;iBAGJ;EACf;EACA;EACA;;;;;;YAOU,yBAAyB;iBAEpB;EACf;EACA;EACA,eAAe,WAAW;EAC1B,YACE,QAAQ,WACR,MAAM,kBACN,cAAc,yBACb,QAAQ;;iBAGI;EACf,OAAO;EACP,WAAW;EACX,mBAAmB;;YAGT,+BAA+B,QACzC,eAAe;iBAGA,sBAAsB,KAAK;EAC1C,OAAO;;iBAGQ,yBAAyB;EACxC,YAAY;;YAGF,eAAe;EACzB,YAAY;;YAGF;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU,2BAA2B,QAAQ,eAAe,QAAQ;YAE1D,mBAAmB,cAAc;iBAE5B,qCAAqC;EACpD;;YAGU,gCACV,kBAAkB,iCACf,QAAQ;iBAEI;EACf,SAAS;EACT;EACA;EACA;EACA;;YAGU,4BACV,QAAQ,mCACL;iBAEY;EACf,SAAS;EACT;EACA;;YAGU,gCACV,QAAQ,6BACL;iBAEY;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf;EACA;;iBAGe;EACf,eAAe;EACf;EACA,eAAe;;YAGL,wBACV,QAAQ,uBACL,QAAQ;iBAEI;EACf,+BAA+B;EAC/B,kBAAkB;EAClB,+BAA+B;EAC/B,mBAAmB;EACnB;EACA;;YAGU;YAEA;YAUA;YAUA;EACV,MAAM;EACN,QAAQ;EACR;EACA,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EAEA;IAAU;IAAuB;IAAiB;;;iBAGnC;EACf;EACA;EACA,QAAQ;EACR,SAAS,MAAM;EACf;EACA;EACA,UAAU;EACV,WAAW;EACX,WAAW;EACX;EACA;EAEA;IAAU;IAAuB;IAAiB;;;YAGxC"}
|
|
@@ -4,7 +4,7 @@ const checkPackageUpdates = async (packageName, packageVersion) => {
|
|
|
4
4
|
try {
|
|
5
5
|
const pkgName = packageName ?? "@lifi/sdk";
|
|
6
6
|
const latestVersion = (await (await fetch(`https://registry.npmjs.org/${pkgName}/latest`)).json()).version;
|
|
7
|
-
const currentVersion = packageVersion ?? "4.
|
|
7
|
+
const currentVersion = packageVersion ?? "4.9.0";
|
|
8
8
|
if (latestVersion > currentVersion) console.warn(`${pkgName}: new package version is available. Please update as soon as possible to enjoy the newest features. Current version: ${currentVersion}. Latest version: ${latestVersion}.`);
|
|
9
9
|
} catch (_error) {}
|
|
10
10
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ValidationError } from "../errors/errors.js";
|
|
2
1
|
import { SDKError } from "../errors/SDKError.js";
|
|
2
|
+
import { ValidationError } from "../errors/errors.js";
|
|
3
3
|
import { formatUnits } from "./formatUnits.js";
|
|
4
4
|
//#region src/utils/convertQuoteToRoute.ts
|
|
5
5
|
const parseBigInt = (value) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ValidationError } from "../errors/errors.js";
|
|
2
|
-
import { HTTPError } from "../errors/httpError.js";
|
|
3
1
|
import { version } from "../version.js";
|
|
4
2
|
import { SDKError } from "../errors/SDKError.js";
|
|
3
|
+
import { ValidationError } from "../errors/errors.js";
|
|
4
|
+
import { HTTPError } from "../errors/httpError.js";
|
|
5
5
|
import { sleep } from "./sleep.js";
|
|
6
6
|
//#region src/utils/request.ts
|
|
7
7
|
const requestSettings = { retries: 1 };
|
|
@@ -12,8 +12,21 @@ export declare class LruMap<value = unknown> extends Map<string, value> {
|
|
|
12
12
|
type WithDedupeOptions = {
|
|
13
13
|
enabled?: boolean | undefined;
|
|
14
14
|
id?: string | undefined;
|
|
15
|
+
/** Lets this caller leave a shared request without aborting it for others. */
|
|
16
|
+
signal?: AbortSignal | undefined;
|
|
15
17
|
};
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Deduplicates in-flight promises.
|
|
20
|
+
*
|
|
21
|
+
* When the first caller passes a signal, `fn` receives the signal to hand on
|
|
22
|
+
* to its request. A caller that aborts leaves the shared request at once; the
|
|
23
|
+
* request itself is aborted only when every caller has aborted. The next
|
|
24
|
+
* caller then starts a new request, so `fn` should pass the signal on: a run
|
|
25
|
+
* that ignores it keeps going alongside the new one.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withDedupe<T>(fn: (signal?: AbortSignal) => Promise<T>, options: WithDedupeOptions): Promise<T>;
|
|
28
|
+
export declare function withDedupe<T>(fn: () => Promise<T>, options: WithDedupeOptions & {
|
|
29
|
+
signal?: undefined;
|
|
30
|
+
}): Promise<T>;
|
|
18
31
|
//#endregion
|
|
19
32
|
//# sourceMappingURL=withDedupe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withDedupe.d.ts","names":[],"sources":["../../../src/utils/withDedupe.ts"],"mappings":";;;;;;qBAKa,OAAO,yBAAyB,YAAY;EACvD;EAEA,YAAY;WAKH,IAAI,aAAa,OAAO;;
|
|
1
|
+
{"version":3,"file":"withDedupe.d.ts","names":[],"sources":["../../../src/utils/withDedupe.ts"],"mappings":";;;;;;qBAKa,OAAO,yBAAyB,YAAY;EACvD;EAEA,YAAY;WAKH,IAAI,aAAa,OAAO;;KA2B9B;EACH;EACA;;EAEA,SAAS;;;;;;;;;;;wBAYK,WAAW,GACzB,KAAK,SAAS,gBAAgB,QAAQ,IACtC,SAAS,oBACR,QAAQ;wBACK,WAAW,GACzB,UAAU,QAAQ,IAClB,SAAS;EAAsB;IAC9B,QAAQ"}
|
|
@@ -18,14 +18,77 @@ var LruMap = class extends Map {
|
|
|
18
18
|
};
|
|
19
19
|
/** @internal */
|
|
20
20
|
const promiseCache = /*#__PURE__*/ new LruMap(8192);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
function withDedupe(fn, { enabled = true, id, signal }) {
|
|
22
|
+
if (!enabled || !id) return fn(signal);
|
|
23
|
+
if (signal?.aborted) return Promise.reject(abortReason(signal));
|
|
24
|
+
let inFlight = promiseCache.get(id);
|
|
25
|
+
if (!inFlight) {
|
|
26
|
+
const controller = signal ? new AbortController() : void 0;
|
|
27
|
+
const promise = fn(controller?.signal).finally(() => evict(id, promise));
|
|
28
|
+
inFlight = {
|
|
29
|
+
promise,
|
|
30
|
+
controller,
|
|
31
|
+
pinned: false
|
|
32
|
+
};
|
|
33
|
+
promiseCache.set(id, inFlight);
|
|
34
|
+
}
|
|
35
|
+
return join(id, inFlight, signal);
|
|
36
|
+
}
|
|
37
|
+
function join(id, inFlight, signal) {
|
|
38
|
+
if (!signal) {
|
|
39
|
+
inFlight.pinned = true;
|
|
40
|
+
return inFlight.promise;
|
|
41
|
+
}
|
|
42
|
+
const callers = inFlight.callers ?? subscribe(inFlight);
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
const caller = {
|
|
45
|
+
resolve: (value) => {
|
|
46
|
+
signal.removeEventListener("abort", leave);
|
|
47
|
+
resolve(value);
|
|
48
|
+
},
|
|
49
|
+
reject: (error) => {
|
|
50
|
+
signal.removeEventListener("abort", leave);
|
|
51
|
+
reject(error);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const leave = () => {
|
|
55
|
+
signal.removeEventListener("abort", leave);
|
|
56
|
+
callers.delete(caller);
|
|
57
|
+
const reason = abortReason(signal);
|
|
58
|
+
reject(reason);
|
|
59
|
+
if (!inFlight.pinned && callers.size === 0) {
|
|
60
|
+
evict(id, inFlight.promise);
|
|
61
|
+
inFlight.controller?.abort(reason);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
callers.add(caller);
|
|
65
|
+
signal.addEventListener("abort", leave, { once: true });
|
|
66
|
+
if (signal.aborted) leave();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Hands the result to the callers with a signal, through one reaction per
|
|
71
|
+
* request, so a caller that leaves holds nothing here. It is added only when
|
|
72
|
+
* the first such caller joins: a request shared only by callers without a
|
|
73
|
+
* signal gets no handler of ours, and a failure they all ignore is still
|
|
74
|
+
* reported as an unhandled rejection.
|
|
75
|
+
*/
|
|
76
|
+
function subscribe(inFlight) {
|
|
77
|
+
const callers = /* @__PURE__ */ new Set();
|
|
78
|
+
inFlight.callers = callers;
|
|
79
|
+
inFlight.promise.then((value) => {
|
|
80
|
+
for (const caller of callers) caller.resolve(value);
|
|
81
|
+
}, (error) => {
|
|
82
|
+
for (const caller of callers) caller.reject(error);
|
|
83
|
+
});
|
|
84
|
+
return callers;
|
|
85
|
+
}
|
|
86
|
+
/** Drops the entry for `id` only while it still holds this request. */
|
|
87
|
+
function evict(id, promise) {
|
|
88
|
+
if (promiseCache.get(id)?.promise === promise) promiseCache.delete(id);
|
|
28
89
|
}
|
|
90
|
+
/** Older runtimes and polyfills can abort a signal without a `reason`. */
|
|
91
|
+
const abortReason = (signal) => signal.reason ?? Object.assign(/* @__PURE__ */ new Error("This operation was aborted"), { name: "AbortError" });
|
|
29
92
|
//#endregion
|
|
30
93
|
export { LruMap, withDedupe };
|
|
31
94
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withDedupe.js","names":[],"sources":["../../../src/utils/withDedupe.ts"],"sourcesContent":["/**\n * Map with a LRU (Least recently used) policy.\n *\n * https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU\n */\nexport class LruMap<value = unknown> extends Map<string, value> {\n maxSize: number\n\n constructor(size: number) {\n super()\n this.maxSize = size\n }\n\n override set(key: string, value: value): this {\n super.set(key, value)\n if (this.maxSize && this.size > this.maxSize) {\n this.delete(this.keys().next().value!)\n }\n return this\n }\n}\n\n/** @internal */\nconst promiseCache = /*#__PURE__*/ new LruMap<
|
|
1
|
+
{"version":3,"file":"withDedupe.js","names":[],"sources":["../../../src/utils/withDedupe.ts"],"sourcesContent":["/**\n * Map with a LRU (Least recently used) policy.\n *\n * https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU\n */\nexport class LruMap<value = unknown> extends Map<string, value> {\n maxSize: number\n\n constructor(size: number) {\n super()\n this.maxSize = size\n }\n\n override set(key: string, value: value): this {\n super.set(key, value)\n if (this.maxSize && this.size > this.maxSize) {\n this.delete(this.keys().next().value!)\n }\n return this\n }\n}\n\ntype Caller = {\n resolve: (value: any) => void\n reject: (error: unknown) => void\n}\n\ntype InFlight = {\n promise: Promise<any>\n /** Absent when the first caller had no signal: then nothing can abort it. */\n controller?: AbortController | undefined\n /** Callers with a signal that are still waiting, once the first one joins. */\n callers?: Set<Caller> | undefined\n /** A caller without a signal joined, so the request must run to the end. */\n pinned: boolean\n}\n\n/** @internal */\nconst promiseCache = /*#__PURE__*/ new LruMap<InFlight>(8192)\n\ntype WithDedupeOptions = {\n enabled?: boolean | undefined\n id?: string | undefined\n /** Lets this caller leave a shared request without aborting it for others. */\n signal?: AbortSignal | undefined\n}\n\n/**\n * Deduplicates in-flight promises.\n *\n * When the first caller passes a signal, `fn` receives the signal to hand on\n * to its request. A caller that aborts leaves the shared request at once; the\n * request itself is aborted only when every caller has aborted. The next\n * caller then starts a new request, so `fn` should pass the signal on: a run\n * that ignores it keeps going alongside the new one.\n */\nexport function withDedupe<T>(\n fn: (signal?: AbortSignal) => Promise<T>,\n options: WithDedupeOptions\n): Promise<T>\nexport function withDedupe<T>(\n fn: () => Promise<T>,\n options: WithDedupeOptions & { signal?: undefined }\n): Promise<T>\nexport function withDedupe<T>(\n fn: (signal?: AbortSignal) => Promise<T>,\n { enabled = true, id, signal }: WithDedupeOptions\n): Promise<T> {\n if (!enabled || !id) {\n return fn(signal)\n }\n if (signal?.aborted) {\n return Promise.reject(abortReason(signal))\n }\n let inFlight = promiseCache.get(id)\n if (!inFlight) {\n const controller = signal ? new AbortController() : undefined\n const promise = fn(controller?.signal).finally(() => evict(id, promise))\n inFlight = { promise, controller, pinned: false }\n promiseCache.set(id, inFlight)\n }\n return join<T>(id, inFlight, signal)\n}\n\nfunction join<T>(\n id: string,\n inFlight: InFlight,\n signal: AbortSignal | undefined\n): Promise<T> {\n if (!signal) {\n inFlight.pinned = true\n return inFlight.promise\n }\n const callers = inFlight.callers ?? subscribe(inFlight)\n return new Promise<T>((resolve, reject) => {\n // Stop listening before settling, so a later abort cannot reach the request.\n const caller: Caller = {\n resolve: (value) => {\n signal.removeEventListener('abort', leave)\n resolve(value)\n },\n reject: (error) => {\n signal.removeEventListener('abort', leave)\n reject(error)\n },\n }\n const leave = () => {\n // `leave` can run without the event, so the listener is not always gone.\n signal.removeEventListener('abort', leave)\n callers.delete(caller)\n const reason = abortReason(signal)\n reject(reason)\n if (!inFlight.pinned && callers.size === 0) {\n // A caller arriving now must start a new request, not join this one.\n evict(id, inFlight.promise)\n inFlight.controller?.abort(reason)\n }\n }\n callers.add(caller)\n signal.addEventListener('abort', leave, { once: true })\n // `fn` runs before this listener exists and may have aborted the signal.\n if (signal.aborted) {\n leave()\n }\n })\n}\n\n/**\n * Hands the result to the callers with a signal, through one reaction per\n * request, so a caller that leaves holds nothing here. It is added only when\n * the first such caller joins: a request shared only by callers without a\n * signal gets no handler of ours, and a failure they all ignore is still\n * reported as an unhandled rejection.\n */\nfunction subscribe(inFlight: InFlight): Set<Caller> {\n const callers = new Set<Caller>()\n inFlight.callers = callers\n inFlight.promise.then(\n (value) => {\n for (const caller of callers) {\n caller.resolve(value)\n }\n },\n (error) => {\n for (const caller of callers) {\n caller.reject(error)\n }\n }\n )\n return callers\n}\n\n/** Drops the entry for `id` only while it still holds this request. */\nfunction evict(id: string, promise: Promise<unknown>): void {\n if (promiseCache.get(id)?.promise === promise) {\n promiseCache.delete(id)\n }\n}\n\n/** Older runtimes and polyfills can abort a signal without a `reason`. */\nconst abortReason = (signal: AbortSignal): unknown =>\n signal.reason ??\n Object.assign(new Error('This operation was aborted'), { name: 'AbortError' })\n"],"mappings":";;;;;;AAKA,IAAa,SAAb,cAA6C,IAAmB;CAC9D;CAEA,YAAY,MAAc;EACxB,MAAM;EACN,KAAK,UAAU;CACjB;CAEA,IAAa,KAAa,OAAoB;EAC5C,MAAM,IAAI,KAAK,KAAK;EACpB,IAAI,KAAK,WAAW,KAAK,OAAO,KAAK,SACnC,KAAK,OAAO,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAM;EAEvC,OAAO;CACT;AACF;;AAkBA,MAAM,6BAA6B,IAAI,OAAiB,IAAI;AA0B5D,SAAgB,WACd,IACA,EAAE,UAAU,MAAM,IAAI,UACV;CACZ,IAAI,CAAC,WAAW,CAAC,IACf,OAAO,GAAG,MAAM;CAElB,IAAI,QAAQ,SACV,OAAO,QAAQ,OAAO,YAAY,MAAM,CAAC;CAE3C,IAAI,WAAW,aAAa,IAAI,EAAE;CAClC,IAAI,CAAC,UAAU;EACb,MAAM,aAAa,SAAS,IAAI,gBAAgB,IAAI,KAAA;EACpD,MAAM,UAAU,GAAG,YAAY,MAAM,CAAC,CAAC,cAAc,MAAM,IAAI,OAAO,CAAC;EACvE,WAAW;GAAE;GAAS;GAAY,QAAQ;EAAM;EAChD,aAAa,IAAI,IAAI,QAAQ;CAC/B;CACA,OAAO,KAAQ,IAAI,UAAU,MAAM;AACrC;AAEA,SAAS,KACP,IACA,UACA,QACY;CACZ,IAAI,CAAC,QAAQ;EACX,SAAS,SAAS;EAClB,OAAO,SAAS;CAClB;CACA,MAAM,UAAU,SAAS,WAAW,UAAU,QAAQ;CACtD,OAAO,IAAI,SAAY,SAAS,WAAW;EAEzC,MAAM,SAAiB;GACrB,UAAU,UAAU;IAClB,OAAO,oBAAoB,SAAS,KAAK;IACzC,QAAQ,KAAK;GACf;GACA,SAAS,UAAU;IACjB,OAAO,oBAAoB,SAAS,KAAK;IACzC,OAAO,KAAK;GACd;EACF;EACA,MAAM,cAAc;GAElB,OAAO,oBAAoB,SAAS,KAAK;GACzC,QAAQ,OAAO,MAAM;GACrB,MAAM,SAAS,YAAY,MAAM;GACjC,OAAO,MAAM;GACb,IAAI,CAAC,SAAS,UAAU,QAAQ,SAAS,GAAG;IAE1C,MAAM,IAAI,SAAS,OAAO;IAC1B,SAAS,YAAY,MAAM,MAAM;GACnC;EACF;EACA,QAAQ,IAAI,MAAM;EAClB,OAAO,iBAAiB,SAAS,OAAO,EAAE,MAAM,KAAK,CAAC;EAEtD,IAAI,OAAO,SACT,MAAM;CAEV,CAAC;AACH;;;;;;;;AASA,SAAS,UAAU,UAAiC;CAClD,MAAM,0BAAU,IAAI,IAAY;CAChC,SAAS,UAAU;CACnB,SAAS,QAAQ,MACd,UAAU;EACT,KAAK,MAAM,UAAU,SACnB,OAAO,QAAQ,KAAK;CAExB,IACC,UAAU;EACT,KAAK,MAAM,UAAU,SACnB,OAAO,OAAO,KAAK;CAEvB,CACF;CACA,OAAO;AACT;;AAGA,SAAS,MAAM,IAAY,SAAiC;CAC1D,IAAI,aAAa,IAAI,EAAE,CAAC,EAAE,YAAY,SACpC,aAAa,OAAO,EAAE;AAE1B;;AAGA,MAAM,eAAe,WACnB,OAAO,UACP,OAAO,uBAAO,IAAI,MAAM,4BAA4B,GAAG,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.9.0'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
package/package.json
CHANGED
package/src/actions/getChains.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ExtendedChain,
|
|
5
5
|
RequestOptions,
|
|
6
6
|
} from '@lifi/types'
|
|
7
|
+
import { SDKError } from '../errors/SDKError.js'
|
|
7
8
|
import type { SDKBaseConfig, SDKClient } from '../types/core.js'
|
|
8
9
|
import { request } from '../utils/request.js'
|
|
9
10
|
import { withDedupe } from '../utils/withDedupe.js'
|
|
@@ -41,15 +42,22 @@ export const _getChains = async (
|
|
|
41
42
|
params as Record<string, string>
|
|
42
43
|
).toString()
|
|
43
44
|
const response = await withDedupe(
|
|
44
|
-
() =>
|
|
45
|
+
(signal) =>
|
|
45
46
|
request<ChainsResponse>(
|
|
46
47
|
config,
|
|
47
48
|
`${config.apiUrl}/chains?${urlSearchParams}`,
|
|
48
49
|
{
|
|
49
|
-
signal
|
|
50
|
+
signal,
|
|
50
51
|
}
|
|
51
52
|
),
|
|
52
|
-
{
|
|
53
|
-
|
|
53
|
+
{
|
|
54
|
+
id: `${getChains.name}.${config.apiUrl}.${urlSearchParams}`,
|
|
55
|
+
signal: options?.signal,
|
|
56
|
+
}
|
|
57
|
+
).catch((error) => {
|
|
58
|
+
// A caller that aborts leaves before the request settles; keep its error
|
|
59
|
+
// shaped like one from `request`.
|
|
60
|
+
throw error instanceof SDKError ? error : new SDKError(error)
|
|
61
|
+
})
|
|
54
62
|
return response.chains
|
|
55
63
|
}
|
package/src/actions/getTokens.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
TokensRequest,
|
|
5
5
|
TokensResponse,
|
|
6
6
|
} from '@lifi/types'
|
|
7
|
+
import { SDKError } from '../errors/SDKError.js'
|
|
7
8
|
import type { SDKClient } from '../types/core.js'
|
|
8
9
|
import { request } from '../utils/request.js'
|
|
9
10
|
import { withDedupe } from '../utils/withDedupe.js'
|
|
@@ -43,15 +44,22 @@ export async function getTokens(
|
|
|
43
44
|
).toString()
|
|
44
45
|
const _isExtended = params?.extended === true
|
|
45
46
|
const response = await withDedupe(
|
|
46
|
-
() =>
|
|
47
|
+
(signal) =>
|
|
47
48
|
request<
|
|
48
49
|
typeof _isExtended extends true
|
|
49
50
|
? TokensExtendedResponse
|
|
50
51
|
: TokensResponse
|
|
51
52
|
>(client.config, `${client.config.apiUrl}/tokens?${urlSearchParams}`, {
|
|
52
|
-
signal
|
|
53
|
+
signal,
|
|
53
54
|
}),
|
|
54
|
-
{
|
|
55
|
-
|
|
55
|
+
{
|
|
56
|
+
id: `${getTokens.name}.${client.config.apiUrl}.${urlSearchParams}`,
|
|
57
|
+
signal: options?.signal,
|
|
58
|
+
}
|
|
59
|
+
).catch((error) => {
|
|
60
|
+
// A caller that aborts leaves before the request settles; keep its error
|
|
61
|
+
// shaped like one from `request`.
|
|
62
|
+
throw error instanceof SDKError ? error : new SDKError(error)
|
|
63
|
+
})
|
|
56
64
|
return response
|
|
57
65
|
}
|