@lifi/sdk 4.0.1 → 4.1.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 +14 -0
- package/dist/cjs/actions/getQuote.js +2 -1
- package/dist/cjs/actions/getQuote.js.map +1 -1
- package/dist/cjs/actions/getRoutes.d.ts +3 -2
- package/dist/cjs/actions/getRoutes.js.map +1 -1
- package/dist/cjs/actions/getStepTransaction.d.ts +3 -2
- package/dist/cjs/actions/getStepTransaction.js.map +1 -1
- package/dist/cjs/actions/index.d.ts +9 -6
- package/dist/cjs/actions/index.js.map +1 -1
- package/dist/cjs/errors/httpError.js +1 -1
- package/dist/cjs/errors/httpError.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/types/actions.d.ts +22 -2
- package/dist/cjs/utils/checkPackageUpdates.js +1 -1
- package/dist/cjs/utils/isStep.js +2 -1
- package/dist/cjs/utils/isStep.js.map +1 -1
- package/dist/cjs/utils/toQueryString.d.ts +5 -0
- package/dist/cjs/utils/toQueryString.js +17 -0
- package/dist/cjs/utils/toQueryString.js.map +1 -0
- 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/getQuote.d.ts.map +1 -1
- package/dist/esm/actions/getQuote.js +2 -1
- package/dist/esm/actions/getQuote.js.map +1 -1
- package/dist/esm/actions/getRoutes.d.ts +3 -2
- package/dist/esm/actions/getRoutes.d.ts.map +1 -1
- package/dist/esm/actions/getRoutes.js.map +1 -1
- package/dist/esm/actions/getStepTransaction.d.ts +3 -2
- package/dist/esm/actions/getStepTransaction.d.ts.map +1 -1
- package/dist/esm/actions/getStepTransaction.js.map +1 -1
- package/dist/esm/actions/index.d.ts +9 -6
- package/dist/esm/actions/index.d.ts.map +1 -1
- package/dist/esm/actions/index.js.map +1 -1
- package/dist/esm/errors/httpError.js +1 -1
- package/dist/esm/errors/httpError.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/types/actions.d.ts +22 -2
- package/dist/esm/types/actions.d.ts.map +1 -1
- package/dist/esm/utils/checkPackageUpdates.js +1 -1
- package/dist/esm/utils/isStep.d.ts.map +1 -1
- package/dist/esm/utils/isStep.js +2 -1
- package/dist/esm/utils/isStep.js.map +1 -1
- package/dist/esm/utils/toQueryString.d.ts +5 -0
- package/dist/esm/utils/toQueryString.d.ts.map +1 -0
- package/dist/esm/utils/toQueryString.js +16 -0
- package/dist/esm/utils/toQueryString.js.map +1 -0
- 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/getQuote.ts +3 -2
- package/src/actions/getRoutes.ts +2 -1
- package/src/actions/getStepTransaction.ts +3 -2
- package/src/actions/index.ts +8 -5
- package/src/index.ts +7 -0
- package/src/types/actions.ts +29 -0
- package/src/utils/isStep.ts +4 -1
- package/src/utils/toQueryString.ts +35 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @lifi/sdk
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#411](https://github.com/lifinance/sdk/pull/411) [`82b6c17`](https://github.com/lifinance/sdk/commit/82b6c17ceadfe3968e27e2c7bb3b8a1a0ded1840) Thanks [@effie-ms](https://github.com/effie-ms)! - Add an optional `private` flag to `getRoutes` route options, allowing callers to request private routes.
|
|
8
|
+
|
|
9
|
+
- [#410](https://github.com/lifinance/sdk/pull/410) [`6e1b100`](https://github.com/lifinance/sdk/commit/6e1b1009700561571d0dca864f539129951c162b) Thanks [@effie-ms](https://github.com/effie-ms)! - Add optional limit-order fields (`toAmount`, `validUntil`, `partiallyFillable`) to `getRoutes` and to a step's `action` in `getStepTransaction`. The fields are passed through and resolved on the backend; classic calls are unchanged. Steps without an `estimate` no longer fail validation. New exported type: `LiFiStepRequest`.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#414](https://github.com/lifinance/sdk/pull/414) [`e8c8b69`](https://github.com/lifinance/sdk/commit/e8c8b6999ba8ffc127d47ba4a648d0a2792a4870) Thanks [@chybisov](https://github.com/chybisov)! - Export `getStatus`/`getQuote` param types from the entrypoint: `GetStatusRequestExtended`, `QuoteRequest`, `QuoteRequestFromAmount`, `QuoteRequestToAmount`.
|
|
14
|
+
|
|
15
|
+
- [#415](https://github.com/lifinance/sdk/pull/415) [`2ced1e4`](https://github.com/lifinance/sdk/commit/2ced1e4881923ac14e110b3009150a5bd4f9d318) Thanks [@chybisov](https://github.com/chybisov)! - Fix `getQuote` dropping `distributionFees` (and other nested array/object params). `getQuote` built its GET query string with `URLSearchParams`, which stringifies an array of objects to `[object Object]`, so multi-recipient fee splits never reached the backend (which parses query params with `qs.parse(..., { comma: true })`). A new `toQueryString` util encodes nested params in qs indices notation (`distributionFees[0][receiver]=...`), so `distributionFees` now serializes correctly on `/quote` and `/quote/toAmount`. Scalar and scalar-array params are unchanged.
|
|
16
|
+
|
|
3
17
|
## 4.0.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_errors_errors = require("../errors/errors.js");
|
|
3
3
|
const require_errors_SDKError = require("../errors/SDKError.js");
|
|
4
4
|
const require_utils_request = require("../utils/request.js");
|
|
5
|
+
const require_utils_toQueryString = require("../utils/toQueryString.js");
|
|
5
6
|
//#region src/actions/getQuote.ts
|
|
6
7
|
async function getQuote(client, params, options) {
|
|
7
8
|
for (const requiredParameter of [
|
|
@@ -27,7 +28,7 @@ async function getQuote(client, params, options) {
|
|
|
27
28
|
params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny;
|
|
28
29
|
params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer;
|
|
29
30
|
for (const key of Object.keys(params)) if (params[key] === void 0 || params[key] === null) delete params[key];
|
|
30
|
-
return await require_utils_request.request(client.config, `${client.config.apiUrl}/${isFromAmountRequest ? "quote" : "quote/toAmount"}?${
|
|
31
|
+
return await require_utils_request.request(client.config, `${client.config.apiUrl}/${isFromAmountRequest ? "quote" : "quote/toAmount"}?${require_utils_toQueryString.toQueryString(params)}`, { signal: options?.signal });
|
|
31
32
|
}
|
|
32
33
|
//#endregion
|
|
33
34
|
exports.getQuote = getQuote;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQuote.js","names":["SDKError","ValidationError","request"],"sources":["../../../src/actions/getQuote.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type {\n QuoteRequest,\n QuoteRequestFromAmount,\n QuoteRequestToAmount,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Quote for a token transfer\n */\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestToAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> {\n const requiredParameters: Array<keyof QuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n ]\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n const isFromAmountRequest =\n 'fromAmount' in params && params.fromAmount !== undefined\n const isToAmountRequest =\n 'toAmount' in params && params.toAmount !== undefined\n\n if (!isFromAmountRequest && !isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Required parameter \"fromAmount\" or \"toAmount\" is missing.'\n )\n )\n }\n\n if (isFromAmountRequest && isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Cannot provide both \"fromAmount\" and \"toAmount\" parameters.'\n )\n )\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/${isFromAmountRequest ? 'quote' : 'quote/toAmount'}?${
|
|
1
|
+
{"version":3,"file":"getQuote.js","names":["SDKError","ValidationError","request","toQueryString"],"sources":["../../../src/actions/getQuote.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type {\n QuoteRequest,\n QuoteRequestFromAmount,\n QuoteRequestToAmount,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\nimport { toQueryString } from '../utils/toQueryString.js'\n\n/**\n * Get a quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Quote for a token transfer\n */\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestToAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> {\n const requiredParameters: Array<keyof QuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n ]\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n const isFromAmountRequest =\n 'fromAmount' in params && params.fromAmount !== undefined\n const isToAmountRequest =\n 'toAmount' in params && params.toAmount !== undefined\n\n if (!isFromAmountRequest && !isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Required parameter \"fromAmount\" or \"toAmount\" is missing.'\n )\n )\n }\n\n if (isFromAmountRequest && isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Cannot provide both \"fromAmount\" and \"toAmount\" parameters.'\n )\n )\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/${isFromAmountRequest ? 'quote' : 'quote/toAmount'}?${toQueryString(\n params as Record<string, unknown>\n )}`,\n {\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;;;AA8BA,eAAsB,SACpB,QACA,QACA,SACmB;CASnB,KAAK,MAAM,qBAAqB;EAP9B;EACA;EACA;EACA;EACA;CAG+C,GAC/C,IAAI,CAAC,OAAO,oBACV,MAAM,IAAIA,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,uBAAuB,kBAAkB,cAC3C,CACF;CAIJ,MAAM,sBACJ,gBAAgB,UAAU,OAAO,eAAe,KAAA;CAClD,MAAM,oBACJ,cAAc,UAAU,OAAO,aAAa,KAAA;CAE9C,IAAI,CAAC,uBAAuB,CAAC,mBAC3B,MAAM,IAAID,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,+DACF,CACF;CAGF,IAAI,uBAAuB,mBACzB,MAAM,IAAID,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,iEACF,CACF;CAIF,OAAO,eAAe,OAAO,OAAO;CACpC,OAAO,UAAU,OAAO,OAAO,cAAc;CAC7C,OAAO,aAAa,OAAO,OAAO,cAAc;CAChD,OAAO,aAAa,OAAO,OAAO,cAAc;CAChD,OAAO,QAAQ,OAAO,OAAO,cAAc;CAC3C,OAAO,iBAAiB,OAAO,OAAO,cAAc,SAAS;CAC7D,OAAO,gBAAgB,OAAO,OAAO,cAAc,SAAS;CAC5D,OAAO,kBAAkB,OAAO,OAAO,cAAc,SAAS;CAC9D,OAAO,mBAAmB,OAAO,OAAO,cAAc,WAAW;CACjE,OAAO,kBAAkB,OAAO,OAAO,cAAc,WAAW;CAChE,OAAO,oBAAoB,OAAO,OAAO,cAAc,WAAW;CAElE,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAClC,IACE,OAAO,SAA+B,KAAA,KACtC,OAAO,SAA+B,MAEtC,OAAO,OAAO;CAIlB,OAAO,MAAMC,sBAAAA,QACX,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,GAAG,sBAAsB,UAAU,iBAAiB,GAAGC,4BAAAA,cAC7E,MACF,KACA,EACE,QAAQ,SAAS,OACnB,CACF;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SDKClient } from "../types/core.js";
|
|
2
|
-
import {
|
|
2
|
+
import { RoutesRequest as RoutesRequest$1 } from "../types/actions.js";
|
|
3
|
+
import { RequestOptions, RoutesResponse } from "@lifi/types";
|
|
3
4
|
|
|
4
5
|
//#region src/actions/getRoutes.d.ts
|
|
5
6
|
/**
|
|
@@ -10,7 +11,7 @@ import { RequestOptions, RoutesRequest, RoutesResponse } from "@lifi/types";
|
|
|
10
11
|
* @returns The resulting routes that can be used to realize the described transfer of tokens.
|
|
11
12
|
* @throws {LiFiError} Throws a LiFiError if request fails.
|
|
12
13
|
*/
|
|
13
|
-
declare const getRoutes: (client: SDKClient, params: RoutesRequest, options?: RequestOptions) => Promise<RoutesResponse>;
|
|
14
|
+
declare const getRoutes: (client: SDKClient, params: RoutesRequest$1, options?: RequestOptions) => Promise<RoutesResponse>;
|
|
14
15
|
//#endregion
|
|
15
16
|
export { getRoutes };
|
|
16
17
|
//# sourceMappingURL=getRoutes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRoutes.js","names":["isRoutesRequest","SDKError","ValidationError","request"],"sources":["../../../src/actions/getRoutes.ts"],"sourcesContent":["import type { RequestOptions,
|
|
1
|
+
{"version":3,"file":"getRoutes.js","names":["isRoutesRequest","SDKError","ValidationError","request"],"sources":["../../../src/actions/getRoutes.ts"],"sourcesContent":["import type { RequestOptions, RoutesResponse } from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { RoutesRequest } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { isRoutesRequest } from '../utils/isRoutesRequest.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a set of routes for a request that describes a transfer of tokens.\n * @param client - The SDK client.\n * @param params - A description of the transfer.\n * @param options - Request options\n * @returns The resulting routes that can be used to realize the described transfer of tokens.\n * @throws {LiFiError} Throws a LiFiError if request fails.\n */\nexport const getRoutes = async (\n client: SDKClient,\n params: RoutesRequest,\n options?: RequestOptions\n): Promise<RoutesResponse> => {\n if (!isRoutesRequest(params)) {\n throw new SDKError(new ValidationError('Invalid routes request.'))\n }\n // apply defaults\n params.options = {\n integrator: client.config.integrator,\n ...client.config.routeOptions,\n ...params.options,\n }\n\n return await request<RoutesResponse>(\n client.config,\n `${client.config.apiUrl}/advanced/routes`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAa,YAAY,OACvB,QACA,QACA,YAC4B;CAC5B,IAAI,CAACA,8BAAAA,gBAAgB,MAAM,GACzB,MAAM,IAAIC,wBAAAA,SAAS,IAAIC,sBAAAA,gBAAgB,yBAAyB,CAAC;CAGnE,OAAO,UAAU;EACf,YAAY,OAAO,OAAO;EAC1B,GAAG,OAAO,OAAO;EACjB,GAAG,OAAO;CACZ;CAEA,OAAO,MAAMC,sBAAAA,QACX,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,mBACxB;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,mBAClB;EACA,MAAM,KAAK,UAAU,MAAM;EAC3B,QAAQ,SAAS;CACnB,CACF;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SDKClient } from "../types/core.js";
|
|
2
|
-
import {
|
|
2
|
+
import { LiFiStepRequest } from "../types/actions.js";
|
|
3
|
+
import { LiFiStep, RequestOptions } from "@lifi/types";
|
|
3
4
|
|
|
4
5
|
//#region src/actions/getStepTransaction.d.ts
|
|
5
6
|
/**
|
|
@@ -10,7 +11,7 @@ import { LiFiStep, RequestOptions, SignedLiFiStep } from "@lifi/types";
|
|
|
10
11
|
* @returns The step populated with the transaction data.
|
|
11
12
|
* @throws {LiFiError} Throws a LiFiError if request fails.
|
|
12
13
|
*/
|
|
13
|
-
declare const getStepTransaction: (client: SDKClient, step:
|
|
14
|
+
declare const getStepTransaction: (client: SDKClient, step: LiFiStepRequest, options?: RequestOptions) => Promise<LiFiStep>;
|
|
14
15
|
//#endregion
|
|
15
16
|
export { getStepTransaction };
|
|
16
17
|
//# sourceMappingURL=getStepTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStepTransaction.js","names":["isStep","ChainId","request"],"sources":["../../../src/actions/getStepTransaction.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions
|
|
1
|
+
{"version":3,"file":"getStepTransaction.js","names":["isStep","ChainId","request"],"sources":["../../../src/actions/getStepTransaction.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { ChainId } from '@lifi/types'\nimport type { LiFiStepRequest } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { isStep } from '../utils/isStep.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get the transaction data for a single step of a route\n * @param client - The SDK client\n * @param step - The step object.\n * @param options - Request options\n * @returns The step populated with the transaction data.\n * @throws {LiFiError} Throws a LiFiError if request fails.\n */\nexport const getStepTransaction = async (\n client: SDKClient,\n step: LiFiStepRequest,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n if (!isStep(step)) {\n // While the validation fails for some users we should not enforce it\n console.warn('SDK Validation: Invalid Step', step)\n }\n\n const { config } = client\n\n let requestUrl = `${config.apiUrl}/advanced/stepTransaction`\n const jitoBundle = config.routeOptions?.jitoBundle\n const svmSponsor = config.routeOptions?.svmSponsor\n\n if (step.action.fromChainId === ChainId.SOL) {\n const queryParams = new URLSearchParams()\n if (jitoBundle) {\n queryParams.set('jitoBundle', jitoBundle.toString())\n }\n if (svmSponsor) {\n queryParams.set('svmSponsor', svmSponsor)\n }\n if (queryParams.size > 0) {\n requestUrl = `${requestUrl}?${queryParams}`\n }\n }\n\n return await request<LiFiStep>(config, requestUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(step),\n signal: options?.signal,\n })\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,QACA,MACA,YACsB;CACtB,IAAI,CAACA,qBAAAA,OAAO,IAAI,GAEd,QAAQ,KAAK,gCAAgC,IAAI;CAGnD,MAAM,EAAE,WAAW;CAEnB,IAAI,aAAa,GAAG,OAAO,OAAO;CAClC,MAAM,aAAa,OAAO,cAAc;CACxC,MAAM,aAAa,OAAO,cAAc;CAExC,IAAI,KAAK,OAAO,gBAAgBC,YAAAA,QAAQ,KAAK;EAC3C,MAAM,cAAc,IAAI,gBAAgB;EACxC,IAAI,YACF,YAAY,IAAI,cAAc,WAAW,SAAS,CAAC;EAErD,IAAI,YACF,YAAY,IAAI,cAAc,UAAU;EAE1C,IAAI,YAAY,OAAO,GACrB,aAAa,GAAG,WAAW,GAAG;CAElC;CAEA,OAAO,MAAMC,sBAAAA,QAAkB,QAAQ,YAAY;EACjD,QAAQ;EACR,SAAS,EACP,gBAAgB,mBAClB;EACA,MAAM,KAAK,UAAU,IAAI;EACzB,QAAQ,SAAS;CACnB,CAAC;AACH"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SDKClient } from "../types/core.js";
|
|
2
|
-
import { GetStatusRequestExtended, QuoteRequestFromAmount } from "../types/actions.js";
|
|
2
|
+
import { GetStatusRequestExtended, LiFiStepRequest, QuoteRequestFromAmount, RoutesRequest as RoutesRequest$1 } from "../types/actions.js";
|
|
3
3
|
import { getQuote } from "./getQuote.js";
|
|
4
4
|
import { PatchContractCallsResponse } from "./patchContractCalls.js";
|
|
5
|
-
import { ChainId, ChainKey, ChainType, ChainsRequest, ConnectionsRequest, ConnectionsResponse, ContractCallsQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, LiFiStep, PatchCallDataRequest, RelayRequest, RelayResponseData, RelayStatusRequest, RelayStatusResponseData, RequestOptions,
|
|
5
|
+
import { ChainId, ChainKey, ChainType, ChainsRequest, ConnectionsRequest, ConnectionsResponse, ContractCallsQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, LiFiStep, PatchCallDataRequest, RelayRequest, RelayResponseData, RelayStatusRequest, RelayStatusResponseData, RequestOptions, RoutesResponse, StatusResponse, Token, TokenAmount, TokenExtended, TokensExtendedResponse, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse, TransactionAnalyticsRequest, TransactionAnalyticsResponse, WalletTokenExtended } from "@lifi/types";
|
|
6
6
|
|
|
7
7
|
//#region src/actions/index.d.ts
|
|
8
8
|
type Actions = {
|
|
@@ -63,12 +63,14 @@ type Actions = {
|
|
|
63
63
|
*/
|
|
64
64
|
getRelayerQuote: (params: QuoteRequestFromAmount, options?: RequestOptions) => Promise<LiFiStep>;
|
|
65
65
|
/**
|
|
66
|
-
* Get a set of routes for a request that describes a transfer of tokens
|
|
66
|
+
* Get a set of routes for a request that describes a transfer of tokens.
|
|
67
|
+
* Optional limit-order fields (`toAmount`, `validUntil`, `partiallyFillable`)
|
|
68
|
+
* may be supplied and are resolved on the backend.
|
|
67
69
|
* @param params - A description of the transfer
|
|
68
70
|
* @param options - Request options
|
|
69
71
|
* @returns The resulting routes that can be used to realize the described transfer
|
|
70
72
|
*/
|
|
71
|
-
getRoutes: (params: RoutesRequest, options?: RequestOptions) => Promise<RoutesResponse>;
|
|
73
|
+
getRoutes: (params: RoutesRequest$1, options?: RequestOptions) => Promise<RoutesResponse>;
|
|
72
74
|
/**
|
|
73
75
|
* Get the status of a transaction
|
|
74
76
|
* @param params - The configuration of the requested status
|
|
@@ -77,12 +79,13 @@ type Actions = {
|
|
|
77
79
|
*/
|
|
78
80
|
getStatus: (params: GetStatusRequestExtended, options?: RequestOptions) => Promise<StatusResponse>;
|
|
79
81
|
/**
|
|
80
|
-
* Get a step transaction
|
|
82
|
+
* Get a step transaction. The step's `action` may carry the optional
|
|
83
|
+
* limit-order fields, which are resolved on the backend.
|
|
81
84
|
* @param params - The configuration of the requested step transaction
|
|
82
85
|
* @param options - Request options
|
|
83
86
|
* @returns Step transaction
|
|
84
87
|
*/
|
|
85
|
-
getStepTransaction: (params:
|
|
88
|
+
getStepTransaction: (params: LiFiStepRequest, options?: RequestOptions) => Promise<LiFiStep>;
|
|
86
89
|
/**
|
|
87
90
|
* Get a specific token
|
|
88
91
|
* @param chain - Id or key of the chain that contains the token
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getChains","getConnections","getContractCallsQuote","getGasRecommendation","getNameServiceAddress","getTokens","getTools","getQuote","getRelayedTransactionStatus","getRelayerQuote","getRoutes","getStatus","getStepTransaction","getToken","getTokenBalance","getTokenBalances","getTokenBalancesByChain","getTransactionHistory","getWalletBalances","relayTransaction","patchContractCalls"],"sources":["../../../src/actions/index.ts"],"sourcesContent":["import type {\n ChainId,\n ChainKey,\n ChainsRequest,\n ChainType,\n ConnectionsRequest,\n ConnectionsResponse,\n ContractCallsQuoteRequest,\n ExtendedChain,\n GasRecommendationRequest,\n GasRecommendationResponse,\n LiFiStep,\n PatchCallDataRequest,\n RelayRequest,\n RelayResponseData,\n RelayStatusRequest,\n RelayStatusResponseData,\n RequestOptions,\n RoutesRequest,\n RoutesResponse,\n SignedLiFiStep,\n StatusResponse,\n Token,\n TokenAmount,\n TokenExtended,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n ToolsRequest,\n ToolsResponse,\n TransactionAnalyticsRequest,\n TransactionAnalyticsResponse,\n WalletTokenExtended,\n} from '@lifi/types'\nimport type {\n GetStatusRequestExtended,\n QuoteRequestFromAmount,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { getChains } from './getChains.js'\nimport { getConnections } from './getConnections.js'\nimport { getContractCallsQuote } from './getContractCallsQuote.js'\nimport { getGasRecommendation } from './getGasRecommendation.js'\nimport { getNameServiceAddress } from './getNameServiceAddress.js'\nimport { getQuote } from './getQuote.js'\nimport { getRelayedTransactionStatus } from './getRelayedTransactionStatus.js'\nimport { getRelayerQuote } from './getRelayerQuote.js'\nimport { getRoutes } from './getRoutes.js'\nimport { getStatus } from './getStatus.js'\nimport { getStepTransaction } from './getStepTransaction.js'\nimport { getToken } from './getToken.js'\nimport { getTokenBalance } from './getTokenBalance.js'\nimport { getTokenBalances } from './getTokenBalances.js'\nimport { getTokenBalancesByChain } from './getTokenBalancesByChain.js'\nimport { getTokens } from './getTokens.js'\nimport { getTools } from './getTools.js'\nimport { getTransactionHistory } from './getTransactionHistory.js'\nimport { getWalletBalances } from './getWalletBalances.js'\nimport {\n type PatchContractCallsResponse,\n patchContractCalls,\n} from './patchContractCalls.js'\nimport { relayTransaction } from './relayTransaction.js'\n\nexport type Actions = {\n /**\n * Get all available chains\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n */\n getChains: (\n params?: ChainsRequest,\n options?: RequestOptions\n ) => Promise<ExtendedChain[]>\n\n /**\n * Get connections between chains\n * @param params - The configuration of the requested connections\n * @param options - Request options\n * @returns A list of connections\n */\n getConnections: (\n params: ConnectionsRequest,\n options?: RequestOptions\n ) => Promise<ConnectionsResponse>\n\n /**\n * Get a quote for contract calls\n * @param params - The configuration of the requested contract calls quote\n * @param options - Request options\n * @returns Quote for contract calls\n */\n getContractCallsQuote: (\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get gas recommendation for a chain\n * @param params - The configuration of the requested gas recommendation\n * @param options - Request options\n * @returns Gas recommendation\n */\n getGasRecommendation: (\n params: GasRecommendationRequest,\n options?: RequestOptions\n ) => Promise<GasRecommendationResponse>\n\n /**\n * Get the address of a name service\n * @param name - The name to resolve\n * @param chainType - The chain type to resolve the name on\n * @returns The address of the name service\n */\n getNameServiceAddress: (\n name: string,\n chainType?: ChainType\n ) => Promise<string | undefined>\n\n /**\n * Get a quote for a token transfer\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @returns Quote for a token transfer\n */\n getQuote: (\n params: Parameters<typeof getQuote>[1],\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get the status of a relayed transaction\n * @param params - The configuration of the requested relay status\n * @param options - Request options\n * @returns Status of the relayed transaction\n */\n getRelayedTransactionStatus: (\n params: RelayStatusRequest,\n options?: RequestOptions\n ) => Promise<RelayStatusResponseData>\n\n /**\n * Get a quote from a relayer\n * @param params - The configuration of the requested relayer quote\n * @param options - Request options\n * @returns Quote from a relayer\n */\n getRelayerQuote: (\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a set of routes for a request that describes a transfer of tokens\n * @param params - A description of the transfer\n * @param options - Request options\n * @returns The resulting routes that can be used to realize the described transfer\n */\n getRoutes: (\n params: RoutesRequest,\n options?: RequestOptions\n ) => Promise<RoutesResponse>\n\n /**\n * Get the status of a transaction\n * @param params - The configuration of the requested status\n * @param options - Request options\n * @returns Status of the transaction\n */\n getStatus: (\n params: GetStatusRequestExtended,\n options?: RequestOptions\n ) => Promise<StatusResponse>\n\n /**\n * Get a step transaction\n * @param params - The configuration of the requested step transaction\n * @param options - Request options\n * @returns Step transaction\n */\n getStepTransaction: (\n params: LiFiStep | SignedLiFiStep,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a specific token\n * @param chain - Id or key of the chain that contains the token\n * @param token - Address or symbol of the token on the requested chain\n * @param options - Request options\n * @returns Token information\n */\n getToken: (\n chain: ChainKey | ChainId,\n token: string,\n options?: RequestOptions\n ) => Promise<TokenExtended>\n\n /**\n * Get token balance for a specific token\n * @param walletAddress - A wallet address\n * @param token - A Token object\n * @returns Token balance\n */\n getTokenBalance: (\n walletAddress: string,\n token: Token\n ) => Promise<TokenAmount | null>\n\n /**\n * Get token balances for multiple tokens\n * @param walletAddress - A wallet address\n * @param tokens - A list of Token objects\n * @returns Token balances\n */\n getTokenBalances: (\n walletAddress: string,\n tokens: Token[]\n ) => Promise<TokenAmount[]>\n\n /**\n * Get token balances by chain\n * @param walletAddress - A wallet address\n * @param tokensByChain - A list of token objects organized by chain ids\n * @returns Token balances by chain\n */\n getTokenBalancesByChain: (\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n ) => Promise<{\n [chainId: number]: TokenAmount[]\n }>\n\n /**\n * Get all available tokens\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns A list of all available tokens\n */\n getTokens: {\n (\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n ): Promise<TokensResponse>\n (\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n ): Promise<TokensExtendedResponse>\n }\n\n /**\n * Get all available tools (bridges and exchanges)\n * @param params - The configuration of the requested tools\n * @param options - Request options\n * @returns A list of all available tools\n */\n getTools: (\n params?: ToolsRequest,\n options?: RequestOptions\n ) => Promise<ToolsResponse>\n\n /**\n * Get transaction history\n * @param params - The configuration of the requested transaction history\n * @param options - Request options\n * @returns Transaction history\n */\n getTransactionHistory: (\n params: TransactionAnalyticsRequest,\n options?: RequestOptions\n ) => Promise<TransactionAnalyticsResponse>\n\n /**\n * Get wallet balances\n * @param params - The configuration of the requested wallet balances\n * @param options - Request options\n * @returns Wallet balances\n */\n getWalletBalances: (\n walletAddress: string,\n options?: RequestOptions\n ) => Promise<Record<number, WalletTokenExtended[]>>\n\n /**\n * Relay a transaction through the relayer service\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @returns Task ID and transaction link for the relayed transaction\n */\n relayTransaction: (\n params: RelayRequest,\n options?: RequestOptions\n ) => Promise<RelayResponseData>\n\n /**\n * Patch contract calls\n * @param params - The configuration for the patch contract calls request\n * @param options - Request options\n * @returns Patched contract calls\n */\n patchContractCalls: (\n params: PatchCallDataRequest,\n options?: RequestOptions\n ) => Promise<PatchContractCallsResponse[]>\n}\n\nexport function actions(client: SDKClient): Actions {\n return {\n getChains: (params, options) => getChains(client, params, options),\n getConnections: (params, options) =>\n getConnections(client, params, options),\n getContractCallsQuote: (params, options) =>\n getContractCallsQuote(client, params, options),\n getGasRecommendation: (params, options) =>\n getGasRecommendation(client, params, options),\n getNameServiceAddress: (name, chainType) =>\n getNameServiceAddress(client, name, chainType),\n getTokens: (params, options) => getTokens(client, params as any, options),\n getTools: (params, options) => getTools(client, params, options),\n getQuote: (params, options) => getQuote(client, params, options),\n getRelayedTransactionStatus: (params, options) =>\n getRelayedTransactionStatus(client, params, options),\n getRelayerQuote: (params, options) =>\n getRelayerQuote(client, params, options),\n getRoutes: (params, options) => getRoutes(client, params, options),\n getStatus: (params, options) => getStatus(client, params, options),\n getStepTransaction: (params, options) =>\n getStepTransaction(client, params, options),\n getToken: (chain, token, options) =>\n getToken(client, chain, token, options),\n getTokenBalance: (walletAddress, token) =>\n getTokenBalance(client, walletAddress, token),\n getTokenBalances: (walletAddress, tokens) =>\n getTokenBalances(client, walletAddress, tokens),\n getTokenBalancesByChain: (walletAddress, tokensByChain) =>\n getTokenBalancesByChain(client, walletAddress, tokensByChain),\n getTransactionHistory: (params, options) =>\n getTransactionHistory(client, params, options),\n getWalletBalances: (walletAddress, options) =>\n getWalletBalances(client, walletAddress, options),\n relayTransaction: (params, options) =>\n relayTransaction(client, params, options),\n patchContractCalls: (params, options) =>\n patchContractCalls(client, params, options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmTA,SAAgB,QAAQ,QAA4B;CAClD,OAAO;EACL,YAAY,QAAQ,YAAYA,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,iBAAiB,QAAQ,YACvBC,+BAAAA,eAAe,QAAQ,QAAQ,OAAO;EACxC,wBAAwB,QAAQ,YAC9BC,sCAAAA,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,uBAAuB,QAAQ,YAC7BC,qCAAAA,qBAAqB,QAAQ,QAAQ,OAAO;EAC9C,wBAAwB,MAAM,cAC5BC,sCAAAA,sBAAsB,QAAQ,MAAM,SAAS;EAC/C,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAe,OAAO;EACxE,WAAW,QAAQ,YAAYC,yBAAAA,SAAS,QAAQ,QAAQ,OAAO;EAC/D,WAAW,QAAQ,YAAYC,yBAAAA,SAAS,QAAQ,QAAQ,OAAO;EAC/D,8BAA8B,QAAQ,YACpCC,4CAAAA,4BAA4B,QAAQ,QAAQ,OAAO;EACrD,kBAAkB,QAAQ,YACxBC,gCAAAA,gBAAgB,QAAQ,QAAQ,OAAO;EACzC,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,qBAAqB,QAAQ,YAC3BC,mCAAAA,mBAAmB,QAAQ,QAAQ,OAAO;EAC5C,WAAW,OAAO,OAAO,YACvBC,yBAAAA,SAAS,QAAQ,OAAO,OAAO,OAAO;EACxC,kBAAkB,eAAe,UAC/BC,gCAAAA,gBAAgB,QAAQ,eAAe,KAAK;EAC9C,mBAAmB,eAAe,WAChCC,iCAAAA,iBAAiB,QAAQ,eAAe,MAAM;EAChD,0BAA0B,eAAe,kBACvCC,wCAAAA,wBAAwB,QAAQ,eAAe,aAAa;EAC9D,wBAAwB,QAAQ,YAC9BC,sCAAAA,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,oBAAoB,eAAe,YACjCC,kCAAAA,kBAAkB,QAAQ,eAAe,OAAO;EAClD,mBAAmB,QAAQ,YACzBC,iCAAAA,iBAAiB,QAAQ,QAAQ,OAAO;EAC1C,qBAAqB,QAAQ,YAC3BC,mCAAAA,mBAAmB,QAAQ,QAAQ,OAAO;CAC9C;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["getChains","getConnections","getContractCallsQuote","getGasRecommendation","getNameServiceAddress","getTokens","getTools","getQuote","getRelayedTransactionStatus","getRelayerQuote","getRoutes","getStatus","getStepTransaction","getToken","getTokenBalance","getTokenBalances","getTokenBalancesByChain","getTransactionHistory","getWalletBalances","relayTransaction","patchContractCalls"],"sources":["../../../src/actions/index.ts"],"sourcesContent":["import type {\n ChainId,\n ChainKey,\n ChainsRequest,\n ChainType,\n ConnectionsRequest,\n ConnectionsResponse,\n ContractCallsQuoteRequest,\n ExtendedChain,\n GasRecommendationRequest,\n GasRecommendationResponse,\n LiFiStep,\n PatchCallDataRequest,\n RelayRequest,\n RelayResponseData,\n RelayStatusRequest,\n RelayStatusResponseData,\n RequestOptions,\n RoutesResponse,\n StatusResponse,\n Token,\n TokenAmount,\n TokenExtended,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n ToolsRequest,\n ToolsResponse,\n TransactionAnalyticsRequest,\n TransactionAnalyticsResponse,\n WalletTokenExtended,\n} from '@lifi/types'\nimport type {\n GetStatusRequestExtended,\n LiFiStepRequest,\n QuoteRequestFromAmount,\n RoutesRequest,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { getChains } from './getChains.js'\nimport { getConnections } from './getConnections.js'\nimport { getContractCallsQuote } from './getContractCallsQuote.js'\nimport { getGasRecommendation } from './getGasRecommendation.js'\nimport { getNameServiceAddress } from './getNameServiceAddress.js'\nimport { getQuote } from './getQuote.js'\nimport { getRelayedTransactionStatus } from './getRelayedTransactionStatus.js'\nimport { getRelayerQuote } from './getRelayerQuote.js'\nimport { getRoutes } from './getRoutes.js'\nimport { getStatus } from './getStatus.js'\nimport { getStepTransaction } from './getStepTransaction.js'\nimport { getToken } from './getToken.js'\nimport { getTokenBalance } from './getTokenBalance.js'\nimport { getTokenBalances } from './getTokenBalances.js'\nimport { getTokenBalancesByChain } from './getTokenBalancesByChain.js'\nimport { getTokens } from './getTokens.js'\nimport { getTools } from './getTools.js'\nimport { getTransactionHistory } from './getTransactionHistory.js'\nimport { getWalletBalances } from './getWalletBalances.js'\nimport {\n type PatchContractCallsResponse,\n patchContractCalls,\n} from './patchContractCalls.js'\nimport { relayTransaction } from './relayTransaction.js'\n\nexport type Actions = {\n /**\n * Get all available chains\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n */\n getChains: (\n params?: ChainsRequest,\n options?: RequestOptions\n ) => Promise<ExtendedChain[]>\n\n /**\n * Get connections between chains\n * @param params - The configuration of the requested connections\n * @param options - Request options\n * @returns A list of connections\n */\n getConnections: (\n params: ConnectionsRequest,\n options?: RequestOptions\n ) => Promise<ConnectionsResponse>\n\n /**\n * Get a quote for contract calls\n * @param params - The configuration of the requested contract calls quote\n * @param options - Request options\n * @returns Quote for contract calls\n */\n getContractCallsQuote: (\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get gas recommendation for a chain\n * @param params - The configuration of the requested gas recommendation\n * @param options - Request options\n * @returns Gas recommendation\n */\n getGasRecommendation: (\n params: GasRecommendationRequest,\n options?: RequestOptions\n ) => Promise<GasRecommendationResponse>\n\n /**\n * Get the address of a name service\n * @param name - The name to resolve\n * @param chainType - The chain type to resolve the name on\n * @returns The address of the name service\n */\n getNameServiceAddress: (\n name: string,\n chainType?: ChainType\n ) => Promise<string | undefined>\n\n /**\n * Get a quote for a token transfer\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @returns Quote for a token transfer\n */\n getQuote: (\n params: Parameters<typeof getQuote>[1],\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get the status of a relayed transaction\n * @param params - The configuration of the requested relay status\n * @param options - Request options\n * @returns Status of the relayed transaction\n */\n getRelayedTransactionStatus: (\n params: RelayStatusRequest,\n options?: RequestOptions\n ) => Promise<RelayStatusResponseData>\n\n /**\n * Get a quote from a relayer\n * @param params - The configuration of the requested relayer quote\n * @param options - Request options\n * @returns Quote from a relayer\n */\n getRelayerQuote: (\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a set of routes for a request that describes a transfer of tokens.\n * Optional limit-order fields (`toAmount`, `validUntil`, `partiallyFillable`)\n * may be supplied and are resolved on the backend.\n * @param params - A description of the transfer\n * @param options - Request options\n * @returns The resulting routes that can be used to realize the described transfer\n */\n getRoutes: (\n params: RoutesRequest,\n options?: RequestOptions\n ) => Promise<RoutesResponse>\n\n /**\n * Get the status of a transaction\n * @param params - The configuration of the requested status\n * @param options - Request options\n * @returns Status of the transaction\n */\n getStatus: (\n params: GetStatusRequestExtended,\n options?: RequestOptions\n ) => Promise<StatusResponse>\n\n /**\n * Get a step transaction. The step's `action` may carry the optional\n * limit-order fields, which are resolved on the backend.\n * @param params - The configuration of the requested step transaction\n * @param options - Request options\n * @returns Step transaction\n */\n getStepTransaction: (\n params: LiFiStepRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a specific token\n * @param chain - Id or key of the chain that contains the token\n * @param token - Address or symbol of the token on the requested chain\n * @param options - Request options\n * @returns Token information\n */\n getToken: (\n chain: ChainKey | ChainId,\n token: string,\n options?: RequestOptions\n ) => Promise<TokenExtended>\n\n /**\n * Get token balance for a specific token\n * @param walletAddress - A wallet address\n * @param token - A Token object\n * @returns Token balance\n */\n getTokenBalance: (\n walletAddress: string,\n token: Token\n ) => Promise<TokenAmount | null>\n\n /**\n * Get token balances for multiple tokens\n * @param walletAddress - A wallet address\n * @param tokens - A list of Token objects\n * @returns Token balances\n */\n getTokenBalances: (\n walletAddress: string,\n tokens: Token[]\n ) => Promise<TokenAmount[]>\n\n /**\n * Get token balances by chain\n * @param walletAddress - A wallet address\n * @param tokensByChain - A list of token objects organized by chain ids\n * @returns Token balances by chain\n */\n getTokenBalancesByChain: (\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n ) => Promise<{\n [chainId: number]: TokenAmount[]\n }>\n\n /**\n * Get all available tokens\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns A list of all available tokens\n */\n getTokens: {\n (\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n ): Promise<TokensResponse>\n (\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n ): Promise<TokensExtendedResponse>\n }\n\n /**\n * Get all available tools (bridges and exchanges)\n * @param params - The configuration of the requested tools\n * @param options - Request options\n * @returns A list of all available tools\n */\n getTools: (\n params?: ToolsRequest,\n options?: RequestOptions\n ) => Promise<ToolsResponse>\n\n /**\n * Get transaction history\n * @param params - The configuration of the requested transaction history\n * @param options - Request options\n * @returns Transaction history\n */\n getTransactionHistory: (\n params: TransactionAnalyticsRequest,\n options?: RequestOptions\n ) => Promise<TransactionAnalyticsResponse>\n\n /**\n * Get wallet balances\n * @param params - The configuration of the requested wallet balances\n * @param options - Request options\n * @returns Wallet balances\n */\n getWalletBalances: (\n walletAddress: string,\n options?: RequestOptions\n ) => Promise<Record<number, WalletTokenExtended[]>>\n\n /**\n * Relay a transaction through the relayer service\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @returns Task ID and transaction link for the relayed transaction\n */\n relayTransaction: (\n params: RelayRequest,\n options?: RequestOptions\n ) => Promise<RelayResponseData>\n\n /**\n * Patch contract calls\n * @param params - The configuration for the patch contract calls request\n * @param options - Request options\n * @returns Patched contract calls\n */\n patchContractCalls: (\n params: PatchCallDataRequest,\n options?: RequestOptions\n ) => Promise<PatchContractCallsResponse[]>\n}\n\nexport function actions(client: SDKClient): Actions {\n return {\n getChains: (params, options) => getChains(client, params, options),\n getConnections: (params, options) =>\n getConnections(client, params, options),\n getContractCallsQuote: (params, options) =>\n getContractCallsQuote(client, params, options),\n getGasRecommendation: (params, options) =>\n getGasRecommendation(client, params, options),\n getNameServiceAddress: (name, chainType) =>\n getNameServiceAddress(client, name, chainType),\n getTokens: (params, options) => getTokens(client, params as any, options),\n getTools: (params, options) => getTools(client, params, options),\n getQuote: (params, options) => getQuote(client, params, options),\n getRelayedTransactionStatus: (params, options) =>\n getRelayedTransactionStatus(client, params, options),\n getRelayerQuote: (params, options) =>\n getRelayerQuote(client, params, options),\n getRoutes: (params, options) => getRoutes(client, params, options),\n getStatus: (params, options) => getStatus(client, params, options),\n getStepTransaction: (params, options) =>\n getStepTransaction(client, params, options),\n getToken: (chain, token, options) =>\n getToken(client, chain, token, options),\n getTokenBalance: (walletAddress, token) =>\n getTokenBalance(client, walletAddress, token),\n getTokenBalances: (walletAddress, tokens) =>\n getTokenBalances(client, walletAddress, tokens),\n getTokenBalancesByChain: (walletAddress, tokensByChain) =>\n getTokenBalancesByChain(client, walletAddress, tokensByChain),\n getTransactionHistory: (params, options) =>\n getTransactionHistory(client, params, options),\n getWalletBalances: (walletAddress, options) =>\n getWalletBalances(client, walletAddress, options),\n relayTransaction: (params, options) =>\n relayTransaction(client, params, options),\n patchContractCalls: (params, options) =>\n patchContractCalls(client, params, options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsTA,SAAgB,QAAQ,QAA4B;CAClD,OAAO;EACL,YAAY,QAAQ,YAAYA,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,iBAAiB,QAAQ,YACvBC,+BAAAA,eAAe,QAAQ,QAAQ,OAAO;EACxC,wBAAwB,QAAQ,YAC9BC,sCAAAA,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,uBAAuB,QAAQ,YAC7BC,qCAAAA,qBAAqB,QAAQ,QAAQ,OAAO;EAC9C,wBAAwB,MAAM,cAC5BC,sCAAAA,sBAAsB,QAAQ,MAAM,SAAS;EAC/C,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAe,OAAO;EACxE,WAAW,QAAQ,YAAYC,yBAAAA,SAAS,QAAQ,QAAQ,OAAO;EAC/D,WAAW,QAAQ,YAAYC,yBAAAA,SAAS,QAAQ,QAAQ,OAAO;EAC/D,8BAA8B,QAAQ,YACpCC,4CAAAA,4BAA4B,QAAQ,QAAQ,OAAO;EACrD,kBAAkB,QAAQ,YACxBC,gCAAAA,gBAAgB,QAAQ,QAAQ,OAAO;EACzC,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,qBAAqB,QAAQ,YAC3BC,mCAAAA,mBAAmB,QAAQ,QAAQ,OAAO;EAC5C,WAAW,OAAO,OAAO,YACvBC,yBAAAA,SAAS,QAAQ,OAAO,OAAO,OAAO;EACxC,kBAAkB,eAAe,UAC/BC,gCAAAA,gBAAgB,QAAQ,eAAe,KAAK;EAC9C,mBAAmB,eAAe,WAChCC,iCAAAA,iBAAiB,QAAQ,eAAe,MAAM;EAChD,0BAA0B,eAAe,kBACvCC,wCAAAA,wBAAwB,QAAQ,eAAe,aAAa;EAC9D,wBAAwB,QAAQ,YAC9BC,sCAAAA,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,oBAAoB,eAAe,YACjCC,kCAAAA,kBAAkB,QAAQ,eAAe,OAAO;EAClD,mBAAmB,QAAQ,YACzBC,iCAAAA,iBAAiB,QAAQ,QAAQ,OAAO;EAC1C,qBAAqB,QAAQ,YAC3BC,mCAAAA,mBAAmB,QAAQ,QAAQ,OAAO;CAC9C;AACF"}
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_errors_baseError = require("./baseError.js");
|
|
3
3
|
require("./constants.js");
|
|
4
4
|
//#region src/errors/httpError.ts
|
|
5
|
-
const statusCodeToErrorClassificationMap = new Map([
|
|
5
|
+
const statusCodeToErrorClassificationMap = /* @__PURE__ */ new Map([
|
|
6
6
|
[400, {
|
|
7
7
|
type: "ValidationError",
|
|
8
8
|
code: 1001
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpError.js","names":["BaseError"],"sources":["../../../src/errors/httpError.ts"],"sourcesContent":["import type { UnavailableRoutes } from '@lifi/types'\nimport type { ExtendedRequestInit } from '../types/request.js'\nimport { BaseError } from './baseError.js'\nimport { ErrorMessage, ErrorName, LiFiErrorCode } from './constants.js'\n\ninterface ServerErrorResponseBody {\n code: number\n message: string\n errors?: UnavailableRoutes\n}\n\nconst statusCodeToErrorClassificationMap = new Map([\n [\n 400,\n { type: ErrorName.ValidationError, code: LiFiErrorCode.ValidationError },\n ],\n [404, { type: ErrorName.NotFoundError, code: LiFiErrorCode.NotFound }],\n [\n 409,\n {\n type: ErrorName.SlippageError,\n code: LiFiErrorCode.SlippageError,\n message: ErrorMessage.SlippageError,\n },\n ],\n [424, { type: ErrorName.ServerError, code: LiFiErrorCode.ThirdPartyError }],\n [429, { type: ErrorName.ServerError, code: LiFiErrorCode.RateLimitExceeded }],\n [500, { type: ErrorName.ServerError, code: LiFiErrorCode.InternalError }],\n])\n\nconst getErrorClassificationFromStatusCode = (code: number) =>\n statusCodeToErrorClassificationMap.get(code) ?? {\n type: ErrorName.ServerError,\n code: LiFiErrorCode.InternalError,\n }\n\nconst createInitialMessage = (response: Response) => {\n const statusCode =\n response.status || response.status === 0 ? response.status : ''\n const title = response.statusText || ''\n const status = `${statusCode} ${title}`.trim()\n const reason = status ? `status code ${status}` : 'an unknown error'\n return `Request failed with ${reason}`\n}\n\nexport class HTTPError extends BaseError {\n public response: Response\n public status: number\n public url: RequestInfo | URL\n public fetchOptions: ExtendedRequestInit\n public type?: ErrorName\n public responseBody?: ServerErrorResponseBody\n\n constructor(\n response: Response,\n url: RequestInfo | URL,\n options: ExtendedRequestInit\n ) {\n const errorClassification = getErrorClassificationFromStatusCode(\n response.status\n )\n const additionalMessage = errorClassification?.message\n ? `\\n${errorClassification.message}`\n : ''\n const message = createInitialMessage(response) + additionalMessage\n\n super(ErrorName.HTTPError, errorClassification.code, message)\n\n this.type = errorClassification.type\n this.response = response\n this.status = response.status\n this.message = message\n this.url = url\n this.fetchOptions = options\n }\n\n async buildAdditionalDetails(): Promise<void> {\n if (this.type) {\n this.message = `[${this.type}] ${this.message}`\n }\n\n try {\n this.responseBody = await this.response.json()\n\n if (this.responseBody?.message) {\n this.message += this.message.endsWith('.')\n ? ` ${this.responseBody.message.toString()}`\n : `. ${this.responseBody.message.toString()}`\n }\n } catch {}\n }\n}\n"],"mappings":";;;;AAWA,MAAM,
|
|
1
|
+
{"version":3,"file":"httpError.js","names":["BaseError"],"sources":["../../../src/errors/httpError.ts"],"sourcesContent":["import type { UnavailableRoutes } from '@lifi/types'\nimport type { ExtendedRequestInit } from '../types/request.js'\nimport { BaseError } from './baseError.js'\nimport { ErrorMessage, ErrorName, LiFiErrorCode } from './constants.js'\n\ninterface ServerErrorResponseBody {\n code: number\n message: string\n errors?: UnavailableRoutes\n}\n\nconst statusCodeToErrorClassificationMap = new Map([\n [\n 400,\n { type: ErrorName.ValidationError, code: LiFiErrorCode.ValidationError },\n ],\n [404, { type: ErrorName.NotFoundError, code: LiFiErrorCode.NotFound }],\n [\n 409,\n {\n type: ErrorName.SlippageError,\n code: LiFiErrorCode.SlippageError,\n message: ErrorMessage.SlippageError,\n },\n ],\n [424, { type: ErrorName.ServerError, code: LiFiErrorCode.ThirdPartyError }],\n [429, { type: ErrorName.ServerError, code: LiFiErrorCode.RateLimitExceeded }],\n [500, { type: ErrorName.ServerError, code: LiFiErrorCode.InternalError }],\n])\n\nconst getErrorClassificationFromStatusCode = (code: number) =>\n statusCodeToErrorClassificationMap.get(code) ?? {\n type: ErrorName.ServerError,\n code: LiFiErrorCode.InternalError,\n }\n\nconst createInitialMessage = (response: Response) => {\n const statusCode =\n response.status || response.status === 0 ? response.status : ''\n const title = response.statusText || ''\n const status = `${statusCode} ${title}`.trim()\n const reason = status ? `status code ${status}` : 'an unknown error'\n return `Request failed with ${reason}`\n}\n\nexport class HTTPError extends BaseError {\n public response: Response\n public status: number\n public url: RequestInfo | URL\n public fetchOptions: ExtendedRequestInit\n public type?: ErrorName\n public responseBody?: ServerErrorResponseBody\n\n constructor(\n response: Response,\n url: RequestInfo | URL,\n options: ExtendedRequestInit\n ) {\n const errorClassification = getErrorClassificationFromStatusCode(\n response.status\n )\n const additionalMessage = errorClassification?.message\n ? `\\n${errorClassification.message}`\n : ''\n const message = createInitialMessage(response) + additionalMessage\n\n super(ErrorName.HTTPError, errorClassification.code, message)\n\n this.type = errorClassification.type\n this.response = response\n this.status = response.status\n this.message = message\n this.url = url\n this.fetchOptions = options\n }\n\n async buildAdditionalDetails(): Promise<void> {\n if (this.type) {\n this.message = `[${this.type}] ${this.message}`\n }\n\n try {\n this.responseBody = await this.response.json()\n\n if (this.responseBody?.message) {\n this.message += this.message.endsWith('.')\n ? ` ${this.responseBody.message.toString()}`\n : `. ${this.responseBody.message.toString()}`\n }\n } catch {}\n }\n}\n"],"mappings":";;;;AAWA,MAAM,qDAAqC,IAAI,IAAI;CACjD,CACE,KACA;EAAE,MAAA;EAAiC,MAAA;CAAoC,CACzE;CACA,CAAC,KAAK;EAAE,MAAA;EAA+B,MAAA;CAA6B,CAAC;CACrE,CACE,KACA;EACE,MAAA;EACA,MAAA;EACA,SAAA;CACF,CACF;CACA,CAAC,KAAK;EAAE,MAAA;EAA6B,MAAA;CAAoC,CAAC;CAC1E,CAAC,KAAK;EAAE,MAAA;EAA6B,MAAA;CAAsC,CAAC;CAC5E,CAAC,KAAK;EAAE,MAAA;EAA6B,MAAA;CAAkC,CAAC;AAC1E,CAAC;AAED,MAAM,wCAAwC,SAC5C,mCAAmC,IAAI,IAAI,KAAK;CAC9C,MAAA;CACA,MAAA;AACF;AAEF,MAAM,wBAAwB,aAAuB;CAInD,MAAM,SAAS,GAFb,SAAS,UAAU,SAAS,WAAW,IAAI,SAAS,SAAS,GAElC,GADf,SAAS,cAAc,KACG,KAAK;CAE7C,OAAO,uBADQ,SAAS,eAAe,WAAW;AAEpD;AAEA,IAAa,YAAb,cAA+BA,yBAAAA,UAAU;CACvC;CACA;CACA;CACA;CACA;CACA;CAEA,YACE,UACA,KACA,SACA;EACA,MAAM,sBAAsB,qCAC1B,SAAS,MACX;EACA,MAAM,oBAAoB,qBAAqB,UAC3C,KAAK,oBAAoB,YACzB;EACJ,MAAM,UAAU,qBAAqB,QAAQ,IAAI;EAEjD,MAAA,aAA2B,oBAAoB,MAAM,OAAO;EAE5D,KAAK,OAAO,oBAAoB;EAChC,KAAK,WAAW;EAChB,KAAK,SAAS,SAAS;EACvB,KAAK,UAAU;EACf,KAAK,MAAM;EACX,KAAK,eAAe;CACtB;CAEA,MAAM,yBAAwC;EAC5C,IAAI,KAAK,MACP,KAAK,UAAU,IAAI,KAAK,KAAK,IAAI,KAAK;EAGxC,IAAI;GACF,KAAK,eAAe,MAAM,KAAK,SAAS,KAAK;GAE7C,IAAI,KAAK,cAAc,SACrB,KAAK,WAAW,KAAK,QAAQ,SAAS,GAAG,IACrC,IAAI,KAAK,aAAa,QAAQ,SAAS,MACvC,KAAK,KAAK,aAAa,QAAQ,SAAS;EAEhD,QAAQ,CAAC;CACX;AACF"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { getConnections } from "./actions/getConnections.js";
|
|
|
5
5
|
import { getContractCallsQuote } from "./actions/getContractCallsQuote.js";
|
|
6
6
|
import { getGasRecommendation } from "./actions/getGasRecommendation.js";
|
|
7
7
|
import { getNameServiceAddress } from "./actions/getNameServiceAddress.js";
|
|
8
|
+
import { GetStatusRequestExtended, LiFiStepRequest, QuoteRequest, QuoteRequestFromAmount, QuoteRequestToAmount } from "./types/actions.js";
|
|
8
9
|
import { getQuote } from "./actions/getQuote.js";
|
|
9
10
|
import { getRelayedTransactionStatus } from "./actions/getRelayedTransactionStatus.js";
|
|
10
11
|
import { getRelayerQuote } from "./actions/getRelayerQuote.js";
|
|
@@ -52,4 +53,4 @@ import { waitForResult } from "./utils/waitForResult.js";
|
|
|
52
53
|
import { LruMap, withDedupe } from "./utils/withDedupe.js";
|
|
53
54
|
import { withTimeout } from "./utils/withTimeout.js";
|
|
54
55
|
export * from "@lifi/types";
|
|
55
|
-
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, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, 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, getWalletBalances, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, 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 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, getWalletBalances, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, waitForResult, withDedupe, withTimeout };
|
|
@@ -1,14 +1,34 @@
|
|
|
1
|
-
import { GetStatusRequest, QuoteRequest as QuoteRequest$1 } from "@lifi/types";
|
|
1
|
+
import { Action, GetStatusRequest, LiFiStep, QuoteRequest as QuoteRequest$1, RoutesRequest as RoutesRequest$1, SignedLiFiStep } from "@lifi/types";
|
|
2
2
|
|
|
3
3
|
//#region src/types/actions.d.ts
|
|
4
4
|
type GetStatusRequestExtended = GetStatusRequest & {
|
|
5
5
|
fromAddress?: string;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Optional limit-order fields. Supplying them opts a request into limit-order
|
|
9
|
+
* handling; resolution happens on the backend.
|
|
10
|
+
*/
|
|
11
|
+
type OrderFields = {
|
|
12
|
+
toAmount?: string;
|
|
13
|
+
validUntil?: number;
|
|
14
|
+
partiallyFillable?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type RoutesRequest = Omit<RoutesRequest$1, "options"> & OrderFields & {
|
|
17
|
+
options?: RoutesRequest$1["options"] & {
|
|
18
|
+
/** (default: false) Whether to request private routes */private?: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A step request that may carry the optional limit-order `action` fields.
|
|
23
|
+
*/
|
|
24
|
+
type LiFiStepRequest = (LiFiStep | SignedLiFiStep) & {
|
|
25
|
+
action: Action & OrderFields;
|
|
26
|
+
};
|
|
7
27
|
type QuoteRequestFromAmount = QuoteRequest$1;
|
|
8
28
|
type QuoteRequestToAmount = Omit<QuoteRequest$1, "fromAmount"> & {
|
|
9
29
|
toAmount: string;
|
|
10
30
|
};
|
|
11
31
|
type QuoteRequest = QuoteRequestFromAmount | QuoteRequestToAmount;
|
|
12
32
|
//#endregion
|
|
13
|
-
export { GetStatusRequestExtended, QuoteRequest, QuoteRequestFromAmount, QuoteRequestToAmount };
|
|
33
|
+
export { GetStatusRequestExtended, LiFiStepRequest, QuoteRequest, QuoteRequestFromAmount, QuoteRequestToAmount, RoutesRequest };
|
|
14
34
|
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -5,7 +5,7 @@ const checkPackageUpdates = async (packageName, packageVersion) => {
|
|
|
5
5
|
try {
|
|
6
6
|
const pkgName = packageName ?? "@lifi/sdk";
|
|
7
7
|
const latestVersion = (await (await fetch(`https://registry.npmjs.org/${pkgName}/latest`)).json()).version;
|
|
8
|
-
const currentVersion = packageVersion ?? "4.0
|
|
8
|
+
const currentVersion = packageVersion ?? "4.1.0";
|
|
9
9
|
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}.`);
|
|
10
10
|
} catch (_error) {}
|
|
11
11
|
};
|
package/dist/cjs/utils/isStep.js
CHANGED
|
@@ -6,6 +6,7 @@ const isAction = (action) => {
|
|
|
6
6
|
return typeof fromChainId === "number" && typeof fromAmount === "string" && fromAmount !== "" && require_utils_isToken.isToken(fromToken) && typeof toChainId === "number" && require_utils_isToken.isToken(toToken);
|
|
7
7
|
};
|
|
8
8
|
const isEstimate = (estimate) => {
|
|
9
|
+
if (!estimate) return false;
|
|
9
10
|
const { fromAmount, toAmount, toAmountMin, approvalAddress } = estimate;
|
|
10
11
|
return typeof fromAmount === "string" && fromAmount !== "" && typeof toAmount === "string" && toAmount !== "" && typeof toAmountMin === "string" && toAmountMin !== "" && (typeof approvalAddress === "string" || approvalAddress === null);
|
|
11
12
|
};
|
|
@@ -15,7 +16,7 @@ const isStep = (step) => {
|
|
|
15
16
|
"swap",
|
|
16
17
|
"cross",
|
|
17
18
|
"lifi"
|
|
18
|
-
].includes(type) && typeof tool === "string" && isAction(action) && isEstimate(estimate);
|
|
19
|
+
].includes(type) && typeof tool === "string" && isAction(action) && (!estimate || isEstimate(estimate));
|
|
19
20
|
};
|
|
20
21
|
//#endregion
|
|
21
22
|
exports.isStep = isStep;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isStep.js","names":["isToken"],"sources":["../../../src/utils/isStep.ts"],"sourcesContent":["import type { Action, Estimate, LiFiStep } from '@lifi/types'\nimport { isToken } from './isToken.js'\n\nconst isAction = (action: Action): action is Action => {\n const { fromChainId, fromAmount, fromToken, toChainId, toToken } = action\n\n return (\n typeof fromChainId === 'number' &&\n typeof fromAmount === 'string' &&\n fromAmount !== '' &&\n isToken(fromToken) &&\n typeof toChainId === 'number' &&\n isToken(toToken)\n )\n}\n\nconst isEstimate = (estimate: Estimate): estimate is Estimate => {\n const { fromAmount, toAmount, toAmountMin, approvalAddress } = estimate\n\n return (\n typeof fromAmount === 'string' &&\n fromAmount !== '' &&\n typeof toAmount === 'string' &&\n toAmount !== '' &&\n typeof toAmountMin === 'string' &&\n toAmountMin !== '' &&\n (typeof approvalAddress === 'string' || approvalAddress === null)\n )\n}\n\nexport const isStep = (step: LiFiStep): step is LiFiStep => {\n const { id, type, tool, action, estimate } = step\n\n return (\n typeof id === 'string' &&\n ['swap', 'cross', 'lifi'].includes(type) &&\n typeof tool === 'string' &&\n isAction(action) &&\n isEstimate(estimate)\n )\n}\n"],"mappings":";;;AAGA,MAAM,YAAY,WAAqC;CACrD,MAAM,EAAE,aAAa,YAAY,WAAW,WAAW,YAAY;CAEnE,OACE,OAAO,gBAAgB,YACvB,OAAO,eAAe,YACtB,eAAe,MACfA,sBAAAA,QAAQ,SAAS,KACjB,OAAO,cAAc,YACrBA,sBAAAA,QAAQ,OAAO;AAEnB;AAEA,MAAM,cAAc,aAA6C;CAC/D,MAAM,EAAE,YAAY,UAAU,aAAa,oBAAoB;CAE/D,OACE,OAAO,eAAe,YACtB,eAAe,MACf,OAAO,aAAa,YACpB,aAAa,MACb,OAAO,gBAAgB,YACvB,gBAAgB,OACf,OAAO,oBAAoB,YAAY,oBAAoB;AAEhE;AAEA,MAAa,UAAU,SAAqC;CAC1D,MAAM,EAAE,IAAI,MAAM,MAAM,QAAQ,aAAa;CAE7C,OACE,OAAO,OAAO,YACd;EAAC;EAAQ;EAAS;CAAM,CAAC,CAAC,SAAS,IAAI,KACvC,OAAO,SAAS,YAChB,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"isStep.js","names":["isToken"],"sources":["../../../src/utils/isStep.ts"],"sourcesContent":["import type { Action, Estimate, LiFiStep } from '@lifi/types'\nimport { isToken } from './isToken.js'\n\nconst isAction = (action: Action): action is Action => {\n const { fromChainId, fromAmount, fromToken, toChainId, toToken } = action\n\n return (\n typeof fromChainId === 'number' &&\n typeof fromAmount === 'string' &&\n fromAmount !== '' &&\n isToken(fromToken) &&\n typeof toChainId === 'number' &&\n isToken(toToken)\n )\n}\n\nconst isEstimate = (estimate: Estimate): estimate is Estimate => {\n if (!estimate) {\n return false\n }\n const { fromAmount, toAmount, toAmountMin, approvalAddress } = estimate\n\n return (\n typeof fromAmount === 'string' &&\n fromAmount !== '' &&\n typeof toAmount === 'string' &&\n toAmount !== '' &&\n typeof toAmountMin === 'string' &&\n toAmountMin !== '' &&\n (typeof approvalAddress === 'string' || approvalAddress === null)\n )\n}\n\nexport const isStep = (step: LiFiStep): step is LiFiStep => {\n const { id, type, tool, action, estimate } = step\n\n return (\n typeof id === 'string' &&\n ['swap', 'cross', 'lifi'].includes(type) &&\n typeof tool === 'string' &&\n isAction(action) &&\n (!estimate || isEstimate(estimate))\n )\n}\n"],"mappings":";;;AAGA,MAAM,YAAY,WAAqC;CACrD,MAAM,EAAE,aAAa,YAAY,WAAW,WAAW,YAAY;CAEnE,OACE,OAAO,gBAAgB,YACvB,OAAO,eAAe,YACtB,eAAe,MACfA,sBAAAA,QAAQ,SAAS,KACjB,OAAO,cAAc,YACrBA,sBAAAA,QAAQ,OAAO;AAEnB;AAEA,MAAM,cAAc,aAA6C;CAC/D,IAAI,CAAC,UACH,OAAO;CAET,MAAM,EAAE,YAAY,UAAU,aAAa,oBAAoB;CAE/D,OACE,OAAO,eAAe,YACtB,eAAe,MACf,OAAO,aAAa,YACpB,aAAa,MACb,OAAO,gBAAgB,YACvB,gBAAgB,OACf,OAAO,oBAAoB,YAAY,oBAAoB;AAEhE;AAEA,MAAa,UAAU,SAAqC;CAC1D,MAAM,EAAE,IAAI,MAAM,MAAM,QAAQ,aAAa;CAE7C,OACE,OAAO,OAAO,YACd;EAAC;EAAQ;EAAS;CAAM,CAAC,CAAC,SAAS,IAAI,KACvC,OAAO,SAAS,YAChB,SAAS,MAAM,MACd,CAAC,YAAY,WAAW,QAAQ;AAErC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/utils/toQueryString.ts
|
|
3
|
+
const isPrimitive = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint";
|
|
4
|
+
const serialize = (key, value) => {
|
|
5
|
+
if (value === void 0 || value === null) return [];
|
|
6
|
+
if (isPrimitive(value)) return [`${key}=${encodeURIComponent(String(value))}`];
|
|
7
|
+
if (Array.isArray(value)) {
|
|
8
|
+
if (value.every(isPrimitive)) return [`${key}=${encodeURIComponent(value.join(","))}`];
|
|
9
|
+
return value.flatMap((item, index) => serialize(`${key}[${index}]`, item));
|
|
10
|
+
}
|
|
11
|
+
return Object.entries(value).flatMap(([subKey, subValue]) => serialize(`${key}[${subKey}]`, subValue));
|
|
12
|
+
};
|
|
13
|
+
const toQueryString = (params) => Object.entries(params).flatMap(([key, value]) => serialize(key, value)).join("&");
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.toQueryString = toQueryString;
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=toQueryString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toQueryString.js","names":[],"sources":["../../../src/utils/toQueryString.ts"],"sourcesContent":["type QueryPrimitive = string | number | boolean | bigint\n\nconst isPrimitive = (value: unknown): value is QueryPrimitive =>\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n typeof value === 'bigint'\n\n// Arrays of objects use qs indices notation (`key[0][subKey]=value`) to match\n// the backend's `qs.parse(str, { comma: true })`; only values are encoded.\nconst serialize = (key: string, value: unknown): string[] => {\n if (value === undefined || value === null) {\n return []\n }\n if (isPrimitive(value)) {\n return [`${key}=${encodeURIComponent(String(value))}`]\n }\n if (Array.isArray(value)) {\n // Scalar arrays stay comma-joined (backend splits on `comma: true`).\n if (value.every(isPrimitive)) {\n return [`${key}=${encodeURIComponent(value.join(','))}`]\n }\n return value.flatMap((item, index) => serialize(`${key}[${index}]`, item))\n }\n return Object.entries(value as Record<string, unknown>).flatMap(\n ([subKey, subValue]) => serialize(`${key}[${subKey}]`, subValue)\n )\n}\n\n// Encode params into a query string (no leading `?`). Drop-in for\n// `URLSearchParams` that handles nested array/object params; skips null/undefined.\nexport const toQueryString = (params: Record<string, unknown>): string =>\n Object.entries(params)\n .flatMap(([key, value]) => serialize(key, value))\n .join('&')\n"],"mappings":";;AAEA,MAAM,eAAe,UACnB,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,aACjB,OAAO,UAAU;AAInB,MAAM,aAAa,KAAa,UAA6B;CAC3D,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,OAAO,CAAC;CAEV,IAAI,YAAY,KAAK,GACnB,OAAO,CAAC,GAAG,IAAI,GAAG,mBAAmB,OAAO,KAAK,CAAC,GAAG;CAEvD,IAAI,MAAM,QAAQ,KAAK,GAAG;EAExB,IAAI,MAAM,MAAM,WAAW,GACzB,OAAO,CAAC,GAAG,IAAI,GAAG,mBAAmB,MAAM,KAAK,GAAG,CAAC,GAAG;EAEzD,OAAO,MAAM,SAAS,MAAM,UAAU,UAAU,GAAG,IAAI,GAAG,MAAM,IAAI,IAAI,CAAC;CAC3E;CACA,OAAO,OAAO,QAAQ,KAAgC,CAAC,CAAC,SACrD,CAAC,QAAQ,cAAc,UAAU,GAAG,IAAI,GAAG,OAAO,IAAI,QAAQ,CACjE;AACF;AAIA,MAAa,iBAAiB,WAC5B,OAAO,QAAQ,MAAM,CAAC,CACnB,SAAS,CAAC,KAAK,WAAW,UAAU,KAAK,KAAK,CAAC,CAAC,CAChD,KAAK,GAAG"}
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
package/dist/cjs/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.0
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.1.0'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQuote.d.ts","names":[],"sources":["../../../src/actions/getQuote.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"getQuote.d.ts","names":[],"sources":["../../../src/actions/getQuote.ts"],"mappings":";;;;;;;AAoBA;;;;;;iBAAsB,QAAA,CACpB,MAAA,EAAQ,SAAA,EACR,MAAA,EAAQ,sBAAA,EACR,OAAA,GAAU,cAAA,GACT,OAAA,CAAQ,QAAA;AAAA,iBACW,QAAA,CACpB,MAAA,EAAQ,SAAA,EACR,MAAA,EAAQ,oBAAA,EACR,OAAA,GAAU,cAAA,GACT,OAAA,CAAQ,QAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ValidationError } from "../errors/errors.js";
|
|
2
2
|
import { SDKError } from "../errors/SDKError.js";
|
|
3
3
|
import { request } from "../utils/request.js";
|
|
4
|
+
import { toQueryString } from "../utils/toQueryString.js";
|
|
4
5
|
//#region src/actions/getQuote.ts
|
|
5
6
|
async function getQuote(client, params, options) {
|
|
6
7
|
for (const requiredParameter of [
|
|
@@ -26,7 +27,7 @@ async function getQuote(client, params, options) {
|
|
|
26
27
|
params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny;
|
|
27
28
|
params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer;
|
|
28
29
|
for (const key of Object.keys(params)) if (params[key] === void 0 || params[key] === null) delete params[key];
|
|
29
|
-
return await request(client.config, `${client.config.apiUrl}/${isFromAmountRequest ? "quote" : "quote/toAmount"}?${
|
|
30
|
+
return await request(client.config, `${client.config.apiUrl}/${isFromAmountRequest ? "quote" : "quote/toAmount"}?${toQueryString(params)}`, { signal: options?.signal });
|
|
30
31
|
}
|
|
31
32
|
//#endregion
|
|
32
33
|
export { getQuote };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQuote.js","names":[],"sources":["../../../src/actions/getQuote.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type {\n QuoteRequest,\n QuoteRequestFromAmount,\n QuoteRequestToAmount,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Quote for a token transfer\n */\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestToAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> {\n const requiredParameters: Array<keyof QuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n ]\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n const isFromAmountRequest =\n 'fromAmount' in params && params.fromAmount !== undefined\n const isToAmountRequest =\n 'toAmount' in params && params.toAmount !== undefined\n\n if (!isFromAmountRequest && !isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Required parameter \"fromAmount\" or \"toAmount\" is missing.'\n )\n )\n }\n\n if (isFromAmountRequest && isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Cannot provide both \"fromAmount\" and \"toAmount\" parameters.'\n )\n )\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/${isFromAmountRequest ? 'quote' : 'quote/toAmount'}?${
|
|
1
|
+
{"version":3,"file":"getQuote.js","names":[],"sources":["../../../src/actions/getQuote.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type {\n QuoteRequest,\n QuoteRequestFromAmount,\n QuoteRequestToAmount,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\nimport { toQueryString } from '../utils/toQueryString.js'\n\n/**\n * Get a quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Quote for a token transfer\n */\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequestToAmount,\n options?: RequestOptions\n): Promise<LiFiStep>\nexport async function getQuote(\n client: SDKClient,\n params: QuoteRequest,\n options?: RequestOptions\n): Promise<LiFiStep> {\n const requiredParameters: Array<keyof QuoteRequest> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'toChain',\n 'toToken',\n ]\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n const isFromAmountRequest =\n 'fromAmount' in params && params.fromAmount !== undefined\n const isToAmountRequest =\n 'toAmount' in params && params.toAmount !== undefined\n\n if (!isFromAmountRequest && !isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Required parameter \"fromAmount\" or \"toAmount\" is missing.'\n )\n )\n }\n\n if (isFromAmountRequest && isToAmountRequest) {\n throw new SDKError(\n new ValidationError(\n 'Cannot provide both \"fromAmount\" and \"toAmount\" parameters.'\n )\n )\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n return await request<LiFiStep>(\n client.config,\n `${client.config.apiUrl}/${isFromAmountRequest ? 'quote' : 'quote/toAmount'}?${toQueryString(\n params as Record<string, unknown>\n )}`,\n {\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;;AA8BA,eAAsB,SACpB,QACA,QACA,SACmB;CASnB,KAAK,MAAM,qBAAqB;EAP9B;EACA;EACA;EACA;EACA;CAG+C,GAC/C,IAAI,CAAC,OAAO,oBACV,MAAM,IAAI,SACR,IAAI,gBACF,uBAAuB,kBAAkB,cAC3C,CACF;CAIJ,MAAM,sBACJ,gBAAgB,UAAU,OAAO,eAAe,KAAA;CAClD,MAAM,oBACJ,cAAc,UAAU,OAAO,aAAa,KAAA;CAE9C,IAAI,CAAC,uBAAuB,CAAC,mBAC3B,MAAM,IAAI,SACR,IAAI,gBACF,+DACF,CACF;CAGF,IAAI,uBAAuB,mBACzB,MAAM,IAAI,SACR,IAAI,gBACF,iEACF,CACF;CAIF,OAAO,eAAe,OAAO,OAAO;CACpC,OAAO,UAAU,OAAO,OAAO,cAAc;CAC7C,OAAO,aAAa,OAAO,OAAO,cAAc;CAChD,OAAO,aAAa,OAAO,OAAO,cAAc;CAChD,OAAO,QAAQ,OAAO,OAAO,cAAc;CAC3C,OAAO,iBAAiB,OAAO,OAAO,cAAc,SAAS;CAC7D,OAAO,gBAAgB,OAAO,OAAO,cAAc,SAAS;CAC5D,OAAO,kBAAkB,OAAO,OAAO,cAAc,SAAS;CAC9D,OAAO,mBAAmB,OAAO,OAAO,cAAc,WAAW;CACjE,OAAO,kBAAkB,OAAO,OAAO,cAAc,WAAW;CAChE,OAAO,oBAAoB,OAAO,OAAO,cAAc,WAAW;CAElE,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAClC,IACE,OAAO,SAA+B,KAAA,KACtC,OAAO,SAA+B,MAEtC,OAAO,OAAO;CAIlB,OAAO,MAAM,QACX,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,GAAG,sBAAsB,UAAU,iBAAiB,GAAG,cAC7E,MACF,KACA,EACE,QAAQ,SAAS,OACnB,CACF;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SDKClient } from "../types/core.js";
|
|
2
|
-
import {
|
|
2
|
+
import { RoutesRequest as RoutesRequest$1 } from "../types/actions.js";
|
|
3
|
+
import { RequestOptions, RoutesResponse } from "@lifi/types";
|
|
3
4
|
|
|
4
5
|
//#region src/actions/getRoutes.d.ts
|
|
5
6
|
/**
|
|
@@ -10,7 +11,7 @@ import { RequestOptions, RoutesRequest, RoutesResponse } from "@lifi/types";
|
|
|
10
11
|
* @returns The resulting routes that can be used to realize the described transfer of tokens.
|
|
11
12
|
* @throws {LiFiError} Throws a LiFiError if request fails.
|
|
12
13
|
*/
|
|
13
|
-
declare const getRoutes: (client: SDKClient, params: RoutesRequest, options?: RequestOptions) => Promise<RoutesResponse>;
|
|
14
|
+
declare const getRoutes: (client: SDKClient, params: RoutesRequest$1, options?: RequestOptions) => Promise<RoutesResponse>;
|
|
14
15
|
//#endregion
|
|
15
16
|
export { getRoutes };
|
|
16
17
|
//# sourceMappingURL=getRoutes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRoutes.d.ts","names":[],"sources":["../../../src/actions/getRoutes.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"getRoutes.d.ts","names":[],"sources":["../../../src/actions/getRoutes.ts"],"mappings":";;;;;;;AAgBA;;;;;;cAAa,SAAA,GACX,MAAA,EAAQ,SAAA,EACR,MAAA,EAAQ,eAAA,EACR,OAAA,GAAU,cAAA,KACT,OAAA,CAAQ,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRoutes.js","names":[],"sources":["../../../src/actions/getRoutes.ts"],"sourcesContent":["import type { RequestOptions,
|
|
1
|
+
{"version":3,"file":"getRoutes.js","names":[],"sources":["../../../src/actions/getRoutes.ts"],"sourcesContent":["import type { RequestOptions, RoutesResponse } from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { RoutesRequest } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { isRoutesRequest } from '../utils/isRoutesRequest.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a set of routes for a request that describes a transfer of tokens.\n * @param client - The SDK client.\n * @param params - A description of the transfer.\n * @param options - Request options\n * @returns The resulting routes that can be used to realize the described transfer of tokens.\n * @throws {LiFiError} Throws a LiFiError if request fails.\n */\nexport const getRoutes = async (\n client: SDKClient,\n params: RoutesRequest,\n options?: RequestOptions\n): Promise<RoutesResponse> => {\n if (!isRoutesRequest(params)) {\n throw new SDKError(new ValidationError('Invalid routes request.'))\n }\n // apply defaults\n params.options = {\n integrator: client.config.integrator,\n ...client.config.routeOptions,\n ...params.options,\n }\n\n return await request<RoutesResponse>(\n client.config,\n `${client.config.apiUrl}/advanced/routes`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n signal: options?.signal,\n }\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,YAAY,OACvB,QACA,QACA,YAC4B;CAC5B,IAAI,CAAC,gBAAgB,MAAM,GACzB,MAAM,IAAI,SAAS,IAAI,gBAAgB,yBAAyB,CAAC;CAGnE,OAAO,UAAU;EACf,YAAY,OAAO,OAAO;EAC1B,GAAG,OAAO,OAAO;EACjB,GAAG,OAAO;CACZ;CAEA,OAAO,MAAM,QACX,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,mBACxB;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,mBAClB;EACA,MAAM,KAAK,UAAU,MAAM;EAC3B,QAAQ,SAAS;CACnB,CACF;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SDKClient } from "../types/core.js";
|
|
2
|
-
import {
|
|
2
|
+
import { LiFiStepRequest } from "../types/actions.js";
|
|
3
|
+
import { LiFiStep, RequestOptions } from "@lifi/types";
|
|
3
4
|
|
|
4
5
|
//#region src/actions/getStepTransaction.d.ts
|
|
5
6
|
/**
|
|
@@ -10,7 +11,7 @@ import { LiFiStep, RequestOptions, SignedLiFiStep } from "@lifi/types";
|
|
|
10
11
|
* @returns The step populated with the transaction data.
|
|
11
12
|
* @throws {LiFiError} Throws a LiFiError if request fails.
|
|
12
13
|
*/
|
|
13
|
-
declare const getStepTransaction: (client: SDKClient, step:
|
|
14
|
+
declare const getStepTransaction: (client: SDKClient, step: LiFiStepRequest, options?: RequestOptions) => Promise<LiFiStep>;
|
|
14
15
|
//#endregion
|
|
15
16
|
export { getStepTransaction };
|
|
16
17
|
//# sourceMappingURL=getStepTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStepTransaction.d.ts","names":[],"sources":["../../../src/actions/getStepTransaction.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"getStepTransaction.d.ts","names":[],"sources":["../../../src/actions/getStepTransaction.ts"],"mappings":";;;;;;;AAeA;;;;;;cAAa,kBAAA,GACX,MAAA,EAAQ,SAAA,EACR,IAAA,EAAM,eAAA,EACN,OAAA,GAAU,cAAA,KACT,OAAA,CAAQ,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStepTransaction.js","names":[],"sources":["../../../src/actions/getStepTransaction.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions
|
|
1
|
+
{"version":3,"file":"getStepTransaction.js","names":[],"sources":["../../../src/actions/getStepTransaction.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { ChainId } from '@lifi/types'\nimport type { LiFiStepRequest } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { isStep } from '../utils/isStep.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get the transaction data for a single step of a route\n * @param client - The SDK client\n * @param step - The step object.\n * @param options - Request options\n * @returns The step populated with the transaction data.\n * @throws {LiFiError} Throws a LiFiError if request fails.\n */\nexport const getStepTransaction = async (\n client: SDKClient,\n step: LiFiStepRequest,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n if (!isStep(step)) {\n // While the validation fails for some users we should not enforce it\n console.warn('SDK Validation: Invalid Step', step)\n }\n\n const { config } = client\n\n let requestUrl = `${config.apiUrl}/advanced/stepTransaction`\n const jitoBundle = config.routeOptions?.jitoBundle\n const svmSponsor = config.routeOptions?.svmSponsor\n\n if (step.action.fromChainId === ChainId.SOL) {\n const queryParams = new URLSearchParams()\n if (jitoBundle) {\n queryParams.set('jitoBundle', jitoBundle.toString())\n }\n if (svmSponsor) {\n queryParams.set('svmSponsor', svmSponsor)\n }\n if (queryParams.size > 0) {\n requestUrl = `${requestUrl}?${queryParams}`\n }\n }\n\n return await request<LiFiStep>(config, requestUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(step),\n signal: options?.signal,\n })\n}\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,QACA,MACA,YACsB;CACtB,IAAI,CAAC,OAAO,IAAI,GAEd,QAAQ,KAAK,gCAAgC,IAAI;CAGnD,MAAM,EAAE,WAAW;CAEnB,IAAI,aAAa,GAAG,OAAO,OAAO;CAClC,MAAM,aAAa,OAAO,cAAc;CACxC,MAAM,aAAa,OAAO,cAAc;CAExC,IAAI,KAAK,OAAO,gBAAgB,QAAQ,KAAK;EAC3C,MAAM,cAAc,IAAI,gBAAgB;EACxC,IAAI,YACF,YAAY,IAAI,cAAc,WAAW,SAAS,CAAC;EAErD,IAAI,YACF,YAAY,IAAI,cAAc,UAAU;EAE1C,IAAI,YAAY,OAAO,GACrB,aAAa,GAAG,WAAW,GAAG;CAElC;CAEA,OAAO,MAAM,QAAkB,QAAQ,YAAY;EACjD,QAAQ;EACR,SAAS,EACP,gBAAgB,mBAClB;EACA,MAAM,KAAK,UAAU,IAAI;EACzB,QAAQ,SAAS;CACnB,CAAC;AACH"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SDKClient } from "../types/core.js";
|
|
2
|
-
import { GetStatusRequestExtended, QuoteRequestFromAmount } from "../types/actions.js";
|
|
2
|
+
import { GetStatusRequestExtended, LiFiStepRequest, QuoteRequestFromAmount, RoutesRequest as RoutesRequest$1 } from "../types/actions.js";
|
|
3
3
|
import { getQuote } from "./getQuote.js";
|
|
4
4
|
import { PatchContractCallsResponse } from "./patchContractCalls.js";
|
|
5
|
-
import { ChainId, ChainKey, ChainType, ChainsRequest, ConnectionsRequest, ConnectionsResponse, ContractCallsQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, LiFiStep, PatchCallDataRequest, RelayRequest, RelayResponseData, RelayStatusRequest, RelayStatusResponseData, RequestOptions,
|
|
5
|
+
import { ChainId, ChainKey, ChainType, ChainsRequest, ConnectionsRequest, ConnectionsResponse, ContractCallsQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, LiFiStep, PatchCallDataRequest, RelayRequest, RelayResponseData, RelayStatusRequest, RelayStatusResponseData, RequestOptions, RoutesResponse, StatusResponse, Token, TokenAmount, TokenExtended, TokensExtendedResponse, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse, TransactionAnalyticsRequest, TransactionAnalyticsResponse, WalletTokenExtended } from "@lifi/types";
|
|
6
6
|
|
|
7
7
|
//#region src/actions/index.d.ts
|
|
8
8
|
type Actions = {
|
|
@@ -63,12 +63,14 @@ type Actions = {
|
|
|
63
63
|
*/
|
|
64
64
|
getRelayerQuote: (params: QuoteRequestFromAmount, options?: RequestOptions) => Promise<LiFiStep>;
|
|
65
65
|
/**
|
|
66
|
-
* Get a set of routes for a request that describes a transfer of tokens
|
|
66
|
+
* Get a set of routes for a request that describes a transfer of tokens.
|
|
67
|
+
* Optional limit-order fields (`toAmount`, `validUntil`, `partiallyFillable`)
|
|
68
|
+
* may be supplied and are resolved on the backend.
|
|
67
69
|
* @param params - A description of the transfer
|
|
68
70
|
* @param options - Request options
|
|
69
71
|
* @returns The resulting routes that can be used to realize the described transfer
|
|
70
72
|
*/
|
|
71
|
-
getRoutes: (params: RoutesRequest, options?: RequestOptions) => Promise<RoutesResponse>;
|
|
73
|
+
getRoutes: (params: RoutesRequest$1, options?: RequestOptions) => Promise<RoutesResponse>;
|
|
72
74
|
/**
|
|
73
75
|
* Get the status of a transaction
|
|
74
76
|
* @param params - The configuration of the requested status
|
|
@@ -77,12 +79,13 @@ type Actions = {
|
|
|
77
79
|
*/
|
|
78
80
|
getStatus: (params: GetStatusRequestExtended, options?: RequestOptions) => Promise<StatusResponse>;
|
|
79
81
|
/**
|
|
80
|
-
* Get a step transaction
|
|
82
|
+
* Get a step transaction. The step's `action` may carry the optional
|
|
83
|
+
* limit-order fields, which are resolved on the backend.
|
|
81
84
|
* @param params - The configuration of the requested step transaction
|
|
82
85
|
* @param options - Request options
|
|
83
86
|
* @returns Step transaction
|
|
84
87
|
*/
|
|
85
|
-
getStepTransaction: (params:
|
|
88
|
+
getStepTransaction: (params: LiFiStepRequest, options?: RequestOptions) => Promise<LiFiStep>;
|
|
86
89
|
/**
|
|
87
90
|
* Get a specific token
|
|
88
91
|
* @param chain - Id or key of the chain that contains the token
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/actions/index.ts"],"mappings":";;;;;;;KAgEY,OAAA;;AAAZ;;;;;EAOE,SAAA,GACE,MAAA,GAAS,aAAA,EACT,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,aAAA;;;;;;;EAQb,cAAA,GACE,MAAA,EAAQ,kBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,mBAAA;;;;;;;EAQb,qBAAA,GACE,MAAA,EAAQ,yBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,QAAA;;;;;;;EAQb,oBAAA,GACE,MAAA,EAAQ,wBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,yBAAA;;;;;;;EAQb,qBAAA,GACE,IAAA,UACA,SAAA,GAAY,SAAA,KACT,OAAA;;;;;;;EAQL,QAAA,GACE,MAAA,EAAQ,UAAA,QAAkB,QAAA,MAC1B,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,QAAA;;;;;;;EAQb,2BAAA,GACE,MAAA,EAAQ,kBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,uBAAA;;;;;;;EAQb,eAAA,GACE,MAAA,EAAQ,sBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,QAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/actions/index.ts"],"mappings":";;;;;;;KAgEY,OAAA;;AAAZ;;;;;EAOE,SAAA,GACE,MAAA,GAAS,aAAA,EACT,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,aAAA;;;;;;;EAQb,cAAA,GACE,MAAA,EAAQ,kBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,mBAAA;;;;;;;EAQb,qBAAA,GACE,MAAA,EAAQ,yBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,QAAA;;;;;;;EAQb,oBAAA,GACE,MAAA,EAAQ,wBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,yBAAA;;;;;;;EAQb,qBAAA,GACE,IAAA,UACA,SAAA,GAAY,SAAA,KACT,OAAA;;;;;;;EAQL,QAAA,GACE,MAAA,EAAQ,UAAA,QAAkB,QAAA,MAC1B,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,QAAA;;;;;;;EAQb,2BAAA,GACE,MAAA,EAAQ,kBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,uBAAA;;;;;;;EAQb,eAAA,GACE,MAAA,EAAQ,sBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,QAAA;;;;;;;;;EAUb,SAAA,GACE,MAAA,EAAQ,eAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,cAAA;;;;;;;EAQb,SAAA,GACE,MAAA,EAAQ,wBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,cAAA;;;;;;;;EASb,kBAAA,GACE,MAAA,EAAQ,eAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,QAAA;;;;;;;;EASb,QAAA,GACE,KAAA,EAAO,QAAA,GAAW,OAAA,EAClB,KAAA,UACA,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,aAAA;;;;;;;EAQb,eAAA,GACE,aAAA,UACA,KAAA,EAAO,KAAA,KACJ,OAAA,CAAQ,WAAA;;;;;;;EAQb,gBAAA,GACE,aAAA,UACA,MAAA,EAAQ,KAAA,OACL,OAAA,CAAQ,WAAA;;;;;;;EAQb,uBAAA,GACE,aAAA,UACA,aAAA;IAAA,mBAAoC,KAAA;EAAA,MACjC,OAAA;IAAA,mBACgB,WAAA;EAAA;;;;;;;EASrB,SAAA;IAAA,CAEI,MAAA,GAAS,aAAA;MAAkB,QAAA;IAAA,GAC3B,OAAA,GAAU,cAAA,GACT,OAAA,CAAQ,cAAA;IAAA,CAET,MAAA,EAAQ,aAAA;MAAkB,QAAA;IAAA,GAC1B,OAAA,GAAU,cAAA,GACT,OAAA,CAAQ,sBAAA;EAAA;;;;;;;EASb,QAAA,GACE,MAAA,GAAS,YAAA,EACT,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,aAAA;;;;;;;EAQb,qBAAA,GACE,MAAA,EAAQ,2BAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,4BAAA;;;;;;;EAQb,iBAAA,GACE,aAAA,UACA,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,MAAA,SAAe,mBAAA;;;;;;;EAQ5B,gBAAA,GACE,MAAA,EAAQ,YAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,iBAAA;;;;;;;EAQb,kBAAA,GACE,MAAA,EAAQ,oBAAA,EACR,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,0BAAA;AAAA;AAAA,iBAGC,OAAA,CAAQ,MAAA,EAAQ,SAAA,GAAY,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/actions/index.ts"],"sourcesContent":["import type {\n ChainId,\n ChainKey,\n ChainsRequest,\n ChainType,\n ConnectionsRequest,\n ConnectionsResponse,\n ContractCallsQuoteRequest,\n ExtendedChain,\n GasRecommendationRequest,\n GasRecommendationResponse,\n LiFiStep,\n PatchCallDataRequest,\n RelayRequest,\n RelayResponseData,\n RelayStatusRequest,\n RelayStatusResponseData,\n RequestOptions,\n RoutesRequest,\n RoutesResponse,\n SignedLiFiStep,\n StatusResponse,\n Token,\n TokenAmount,\n TokenExtended,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n ToolsRequest,\n ToolsResponse,\n TransactionAnalyticsRequest,\n TransactionAnalyticsResponse,\n WalletTokenExtended,\n} from '@lifi/types'\nimport type {\n GetStatusRequestExtended,\n QuoteRequestFromAmount,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { getChains } from './getChains.js'\nimport { getConnections } from './getConnections.js'\nimport { getContractCallsQuote } from './getContractCallsQuote.js'\nimport { getGasRecommendation } from './getGasRecommendation.js'\nimport { getNameServiceAddress } from './getNameServiceAddress.js'\nimport { getQuote } from './getQuote.js'\nimport { getRelayedTransactionStatus } from './getRelayedTransactionStatus.js'\nimport { getRelayerQuote } from './getRelayerQuote.js'\nimport { getRoutes } from './getRoutes.js'\nimport { getStatus } from './getStatus.js'\nimport { getStepTransaction } from './getStepTransaction.js'\nimport { getToken } from './getToken.js'\nimport { getTokenBalance } from './getTokenBalance.js'\nimport { getTokenBalances } from './getTokenBalances.js'\nimport { getTokenBalancesByChain } from './getTokenBalancesByChain.js'\nimport { getTokens } from './getTokens.js'\nimport { getTools } from './getTools.js'\nimport { getTransactionHistory } from './getTransactionHistory.js'\nimport { getWalletBalances } from './getWalletBalances.js'\nimport {\n type PatchContractCallsResponse,\n patchContractCalls,\n} from './patchContractCalls.js'\nimport { relayTransaction } from './relayTransaction.js'\n\nexport type Actions = {\n /**\n * Get all available chains\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n */\n getChains: (\n params?: ChainsRequest,\n options?: RequestOptions\n ) => Promise<ExtendedChain[]>\n\n /**\n * Get connections between chains\n * @param params - The configuration of the requested connections\n * @param options - Request options\n * @returns A list of connections\n */\n getConnections: (\n params: ConnectionsRequest,\n options?: RequestOptions\n ) => Promise<ConnectionsResponse>\n\n /**\n * Get a quote for contract calls\n * @param params - The configuration of the requested contract calls quote\n * @param options - Request options\n * @returns Quote for contract calls\n */\n getContractCallsQuote: (\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get gas recommendation for a chain\n * @param params - The configuration of the requested gas recommendation\n * @param options - Request options\n * @returns Gas recommendation\n */\n getGasRecommendation: (\n params: GasRecommendationRequest,\n options?: RequestOptions\n ) => Promise<GasRecommendationResponse>\n\n /**\n * Get the address of a name service\n * @param name - The name to resolve\n * @param chainType - The chain type to resolve the name on\n * @returns The address of the name service\n */\n getNameServiceAddress: (\n name: string,\n chainType?: ChainType\n ) => Promise<string | undefined>\n\n /**\n * Get a quote for a token transfer\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @returns Quote for a token transfer\n */\n getQuote: (\n params: Parameters<typeof getQuote>[1],\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get the status of a relayed transaction\n * @param params - The configuration of the requested relay status\n * @param options - Request options\n * @returns Status of the relayed transaction\n */\n getRelayedTransactionStatus: (\n params: RelayStatusRequest,\n options?: RequestOptions\n ) => Promise<RelayStatusResponseData>\n\n /**\n * Get a quote from a relayer\n * @param params - The configuration of the requested relayer quote\n * @param options - Request options\n * @returns Quote from a relayer\n */\n getRelayerQuote: (\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a set of routes for a request that describes a transfer of tokens\n * @param params - A description of the transfer\n * @param options - Request options\n * @returns The resulting routes that can be used to realize the described transfer\n */\n getRoutes: (\n params: RoutesRequest,\n options?: RequestOptions\n ) => Promise<RoutesResponse>\n\n /**\n * Get the status of a transaction\n * @param params - The configuration of the requested status\n * @param options - Request options\n * @returns Status of the transaction\n */\n getStatus: (\n params: GetStatusRequestExtended,\n options?: RequestOptions\n ) => Promise<StatusResponse>\n\n /**\n * Get a step transaction\n * @param params - The configuration of the requested step transaction\n * @param options - Request options\n * @returns Step transaction\n */\n getStepTransaction: (\n params: LiFiStep | SignedLiFiStep,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a specific token\n * @param chain - Id or key of the chain that contains the token\n * @param token - Address or symbol of the token on the requested chain\n * @param options - Request options\n * @returns Token information\n */\n getToken: (\n chain: ChainKey | ChainId,\n token: string,\n options?: RequestOptions\n ) => Promise<TokenExtended>\n\n /**\n * Get token balance for a specific token\n * @param walletAddress - A wallet address\n * @param token - A Token object\n * @returns Token balance\n */\n getTokenBalance: (\n walletAddress: string,\n token: Token\n ) => Promise<TokenAmount | null>\n\n /**\n * Get token balances for multiple tokens\n * @param walletAddress - A wallet address\n * @param tokens - A list of Token objects\n * @returns Token balances\n */\n getTokenBalances: (\n walletAddress: string,\n tokens: Token[]\n ) => Promise<TokenAmount[]>\n\n /**\n * Get token balances by chain\n * @param walletAddress - A wallet address\n * @param tokensByChain - A list of token objects organized by chain ids\n * @returns Token balances by chain\n */\n getTokenBalancesByChain: (\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n ) => Promise<{\n [chainId: number]: TokenAmount[]\n }>\n\n /**\n * Get all available tokens\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns A list of all available tokens\n */\n getTokens: {\n (\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n ): Promise<TokensResponse>\n (\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n ): Promise<TokensExtendedResponse>\n }\n\n /**\n * Get all available tools (bridges and exchanges)\n * @param params - The configuration of the requested tools\n * @param options - Request options\n * @returns A list of all available tools\n */\n getTools: (\n params?: ToolsRequest,\n options?: RequestOptions\n ) => Promise<ToolsResponse>\n\n /**\n * Get transaction history\n * @param params - The configuration of the requested transaction history\n * @param options - Request options\n * @returns Transaction history\n */\n getTransactionHistory: (\n params: TransactionAnalyticsRequest,\n options?: RequestOptions\n ) => Promise<TransactionAnalyticsResponse>\n\n /**\n * Get wallet balances\n * @param params - The configuration of the requested wallet balances\n * @param options - Request options\n * @returns Wallet balances\n */\n getWalletBalances: (\n walletAddress: string,\n options?: RequestOptions\n ) => Promise<Record<number, WalletTokenExtended[]>>\n\n /**\n * Relay a transaction through the relayer service\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @returns Task ID and transaction link for the relayed transaction\n */\n relayTransaction: (\n params: RelayRequest,\n options?: RequestOptions\n ) => Promise<RelayResponseData>\n\n /**\n * Patch contract calls\n * @param params - The configuration for the patch contract calls request\n * @param options - Request options\n * @returns Patched contract calls\n */\n patchContractCalls: (\n params: PatchCallDataRequest,\n options?: RequestOptions\n ) => Promise<PatchContractCallsResponse[]>\n}\n\nexport function actions(client: SDKClient): Actions {\n return {\n getChains: (params, options) => getChains(client, params, options),\n getConnections: (params, options) =>\n getConnections(client, params, options),\n getContractCallsQuote: (params, options) =>\n getContractCallsQuote(client, params, options),\n getGasRecommendation: (params, options) =>\n getGasRecommendation(client, params, options),\n getNameServiceAddress: (name, chainType) =>\n getNameServiceAddress(client, name, chainType),\n getTokens: (params, options) => getTokens(client, params as any, options),\n getTools: (params, options) => getTools(client, params, options),\n getQuote: (params, options) => getQuote(client, params, options),\n getRelayedTransactionStatus: (params, options) =>\n getRelayedTransactionStatus(client, params, options),\n getRelayerQuote: (params, options) =>\n getRelayerQuote(client, params, options),\n getRoutes: (params, options) => getRoutes(client, params, options),\n getStatus: (params, options) => getStatus(client, params, options),\n getStepTransaction: (params, options) =>\n getStepTransaction(client, params, options),\n getToken: (chain, token, options) =>\n getToken(client, chain, token, options),\n getTokenBalance: (walletAddress, token) =>\n getTokenBalance(client, walletAddress, token),\n getTokenBalances: (walletAddress, tokens) =>\n getTokenBalances(client, walletAddress, tokens),\n getTokenBalancesByChain: (walletAddress, tokensByChain) =>\n getTokenBalancesByChain(client, walletAddress, tokensByChain),\n getTransactionHistory: (params, options) =>\n getTransactionHistory(client, params, options),\n getWalletBalances: (walletAddress, options) =>\n getWalletBalances(client, walletAddress, options),\n relayTransaction: (params, options) =>\n relayTransaction(client, params, options),\n patchContractCalls: (params, options) =>\n patchContractCalls(client, params, options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmTA,SAAgB,QAAQ,QAA4B;CAClD,OAAO;EACL,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,iBAAiB,QAAQ,YACvB,eAAe,QAAQ,QAAQ,OAAO;EACxC,wBAAwB,QAAQ,YAC9B,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,uBAAuB,QAAQ,YAC7B,qBAAqB,QAAQ,QAAQ,OAAO;EAC9C,wBAAwB,MAAM,cAC5B,sBAAsB,QAAQ,MAAM,SAAS;EAC/C,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAe,OAAO;EACxE,WAAW,QAAQ,YAAY,SAAS,QAAQ,QAAQ,OAAO;EAC/D,WAAW,QAAQ,YAAY,SAAS,QAAQ,QAAQ,OAAO;EAC/D,8BAA8B,QAAQ,YACpC,4BAA4B,QAAQ,QAAQ,OAAO;EACrD,kBAAkB,QAAQ,YACxB,gBAAgB,QAAQ,QAAQ,OAAO;EACzC,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,qBAAqB,QAAQ,YAC3B,mBAAmB,QAAQ,QAAQ,OAAO;EAC5C,WAAW,OAAO,OAAO,YACvB,SAAS,QAAQ,OAAO,OAAO,OAAO;EACxC,kBAAkB,eAAe,UAC/B,gBAAgB,QAAQ,eAAe,KAAK;EAC9C,mBAAmB,eAAe,WAChC,iBAAiB,QAAQ,eAAe,MAAM;EAChD,0BAA0B,eAAe,kBACvC,wBAAwB,QAAQ,eAAe,aAAa;EAC9D,wBAAwB,QAAQ,YAC9B,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,oBAAoB,eAAe,YACjC,kBAAkB,QAAQ,eAAe,OAAO;EAClD,mBAAmB,QAAQ,YACzB,iBAAiB,QAAQ,QAAQ,OAAO;EAC1C,qBAAqB,QAAQ,YAC3B,mBAAmB,QAAQ,QAAQ,OAAO;CAC9C;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/actions/index.ts"],"sourcesContent":["import type {\n ChainId,\n ChainKey,\n ChainsRequest,\n ChainType,\n ConnectionsRequest,\n ConnectionsResponse,\n ContractCallsQuoteRequest,\n ExtendedChain,\n GasRecommendationRequest,\n GasRecommendationResponse,\n LiFiStep,\n PatchCallDataRequest,\n RelayRequest,\n RelayResponseData,\n RelayStatusRequest,\n RelayStatusResponseData,\n RequestOptions,\n RoutesResponse,\n StatusResponse,\n Token,\n TokenAmount,\n TokenExtended,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n ToolsRequest,\n ToolsResponse,\n TransactionAnalyticsRequest,\n TransactionAnalyticsResponse,\n WalletTokenExtended,\n} from '@lifi/types'\nimport type {\n GetStatusRequestExtended,\n LiFiStepRequest,\n QuoteRequestFromAmount,\n RoutesRequest,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { getChains } from './getChains.js'\nimport { getConnections } from './getConnections.js'\nimport { getContractCallsQuote } from './getContractCallsQuote.js'\nimport { getGasRecommendation } from './getGasRecommendation.js'\nimport { getNameServiceAddress } from './getNameServiceAddress.js'\nimport { getQuote } from './getQuote.js'\nimport { getRelayedTransactionStatus } from './getRelayedTransactionStatus.js'\nimport { getRelayerQuote } from './getRelayerQuote.js'\nimport { getRoutes } from './getRoutes.js'\nimport { getStatus } from './getStatus.js'\nimport { getStepTransaction } from './getStepTransaction.js'\nimport { getToken } from './getToken.js'\nimport { getTokenBalance } from './getTokenBalance.js'\nimport { getTokenBalances } from './getTokenBalances.js'\nimport { getTokenBalancesByChain } from './getTokenBalancesByChain.js'\nimport { getTokens } from './getTokens.js'\nimport { getTools } from './getTools.js'\nimport { getTransactionHistory } from './getTransactionHistory.js'\nimport { getWalletBalances } from './getWalletBalances.js'\nimport {\n type PatchContractCallsResponse,\n patchContractCalls,\n} from './patchContractCalls.js'\nimport { relayTransaction } from './relayTransaction.js'\n\nexport type Actions = {\n /**\n * Get all available chains\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n */\n getChains: (\n params?: ChainsRequest,\n options?: RequestOptions\n ) => Promise<ExtendedChain[]>\n\n /**\n * Get connections between chains\n * @param params - The configuration of the requested connections\n * @param options - Request options\n * @returns A list of connections\n */\n getConnections: (\n params: ConnectionsRequest,\n options?: RequestOptions\n ) => Promise<ConnectionsResponse>\n\n /**\n * Get a quote for contract calls\n * @param params - The configuration of the requested contract calls quote\n * @param options - Request options\n * @returns Quote for contract calls\n */\n getContractCallsQuote: (\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get gas recommendation for a chain\n * @param params - The configuration of the requested gas recommendation\n * @param options - Request options\n * @returns Gas recommendation\n */\n getGasRecommendation: (\n params: GasRecommendationRequest,\n options?: RequestOptions\n ) => Promise<GasRecommendationResponse>\n\n /**\n * Get the address of a name service\n * @param name - The name to resolve\n * @param chainType - The chain type to resolve the name on\n * @returns The address of the name service\n */\n getNameServiceAddress: (\n name: string,\n chainType?: ChainType\n ) => Promise<string | undefined>\n\n /**\n * Get a quote for a token transfer\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @returns Quote for a token transfer\n */\n getQuote: (\n params: Parameters<typeof getQuote>[1],\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get the status of a relayed transaction\n * @param params - The configuration of the requested relay status\n * @param options - Request options\n * @returns Status of the relayed transaction\n */\n getRelayedTransactionStatus: (\n params: RelayStatusRequest,\n options?: RequestOptions\n ) => Promise<RelayStatusResponseData>\n\n /**\n * Get a quote from a relayer\n * @param params - The configuration of the requested relayer quote\n * @param options - Request options\n * @returns Quote from a relayer\n */\n getRelayerQuote: (\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a set of routes for a request that describes a transfer of tokens.\n * Optional limit-order fields (`toAmount`, `validUntil`, `partiallyFillable`)\n * may be supplied and are resolved on the backend.\n * @param params - A description of the transfer\n * @param options - Request options\n * @returns The resulting routes that can be used to realize the described transfer\n */\n getRoutes: (\n params: RoutesRequest,\n options?: RequestOptions\n ) => Promise<RoutesResponse>\n\n /**\n * Get the status of a transaction\n * @param params - The configuration of the requested status\n * @param options - Request options\n * @returns Status of the transaction\n */\n getStatus: (\n params: GetStatusRequestExtended,\n options?: RequestOptions\n ) => Promise<StatusResponse>\n\n /**\n * Get a step transaction. The step's `action` may carry the optional\n * limit-order fields, which are resolved on the backend.\n * @param params - The configuration of the requested step transaction\n * @param options - Request options\n * @returns Step transaction\n */\n getStepTransaction: (\n params: LiFiStepRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a specific token\n * @param chain - Id or key of the chain that contains the token\n * @param token - Address or symbol of the token on the requested chain\n * @param options - Request options\n * @returns Token information\n */\n getToken: (\n chain: ChainKey | ChainId,\n token: string,\n options?: RequestOptions\n ) => Promise<TokenExtended>\n\n /**\n * Get token balance for a specific token\n * @param walletAddress - A wallet address\n * @param token - A Token object\n * @returns Token balance\n */\n getTokenBalance: (\n walletAddress: string,\n token: Token\n ) => Promise<TokenAmount | null>\n\n /**\n * Get token balances for multiple tokens\n * @param walletAddress - A wallet address\n * @param tokens - A list of Token objects\n * @returns Token balances\n */\n getTokenBalances: (\n walletAddress: string,\n tokens: Token[]\n ) => Promise<TokenAmount[]>\n\n /**\n * Get token balances by chain\n * @param walletAddress - A wallet address\n * @param tokensByChain - A list of token objects organized by chain ids\n * @returns Token balances by chain\n */\n getTokenBalancesByChain: (\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n ) => Promise<{\n [chainId: number]: TokenAmount[]\n }>\n\n /**\n * Get all available tokens\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns A list of all available tokens\n */\n getTokens: {\n (\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n ): Promise<TokensResponse>\n (\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n ): Promise<TokensExtendedResponse>\n }\n\n /**\n * Get all available tools (bridges and exchanges)\n * @param params - The configuration of the requested tools\n * @param options - Request options\n * @returns A list of all available tools\n */\n getTools: (\n params?: ToolsRequest,\n options?: RequestOptions\n ) => Promise<ToolsResponse>\n\n /**\n * Get transaction history\n * @param params - The configuration of the requested transaction history\n * @param options - Request options\n * @returns Transaction history\n */\n getTransactionHistory: (\n params: TransactionAnalyticsRequest,\n options?: RequestOptions\n ) => Promise<TransactionAnalyticsResponse>\n\n /**\n * Get wallet balances\n * @param params - The configuration of the requested wallet balances\n * @param options - Request options\n * @returns Wallet balances\n */\n getWalletBalances: (\n walletAddress: string,\n options?: RequestOptions\n ) => Promise<Record<number, WalletTokenExtended[]>>\n\n /**\n * Relay a transaction through the relayer service\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @returns Task ID and transaction link for the relayed transaction\n */\n relayTransaction: (\n params: RelayRequest,\n options?: RequestOptions\n ) => Promise<RelayResponseData>\n\n /**\n * Patch contract calls\n * @param params - The configuration for the patch contract calls request\n * @param options - Request options\n * @returns Patched contract calls\n */\n patchContractCalls: (\n params: PatchCallDataRequest,\n options?: RequestOptions\n ) => Promise<PatchContractCallsResponse[]>\n}\n\nexport function actions(client: SDKClient): Actions {\n return {\n getChains: (params, options) => getChains(client, params, options),\n getConnections: (params, options) =>\n getConnections(client, params, options),\n getContractCallsQuote: (params, options) =>\n getContractCallsQuote(client, params, options),\n getGasRecommendation: (params, options) =>\n getGasRecommendation(client, params, options),\n getNameServiceAddress: (name, chainType) =>\n getNameServiceAddress(client, name, chainType),\n getTokens: (params, options) => getTokens(client, params as any, options),\n getTools: (params, options) => getTools(client, params, options),\n getQuote: (params, options) => getQuote(client, params, options),\n getRelayedTransactionStatus: (params, options) =>\n getRelayedTransactionStatus(client, params, options),\n getRelayerQuote: (params, options) =>\n getRelayerQuote(client, params, options),\n getRoutes: (params, options) => getRoutes(client, params, options),\n getStatus: (params, options) => getStatus(client, params, options),\n getStepTransaction: (params, options) =>\n getStepTransaction(client, params, options),\n getToken: (chain, token, options) =>\n getToken(client, chain, token, options),\n getTokenBalance: (walletAddress, token) =>\n getTokenBalance(client, walletAddress, token),\n getTokenBalances: (walletAddress, tokens) =>\n getTokenBalances(client, walletAddress, tokens),\n getTokenBalancesByChain: (walletAddress, tokensByChain) =>\n getTokenBalancesByChain(client, walletAddress, tokensByChain),\n getTransactionHistory: (params, options) =>\n getTransactionHistory(client, params, options),\n getWalletBalances: (walletAddress, options) =>\n getWalletBalances(client, walletAddress, options),\n relayTransaction: (params, options) =>\n relayTransaction(client, params, options),\n patchContractCalls: (params, options) =>\n patchContractCalls(client, params, options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsTA,SAAgB,QAAQ,QAA4B;CAClD,OAAO;EACL,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,iBAAiB,QAAQ,YACvB,eAAe,QAAQ,QAAQ,OAAO;EACxC,wBAAwB,QAAQ,YAC9B,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,uBAAuB,QAAQ,YAC7B,qBAAqB,QAAQ,QAAQ,OAAO;EAC9C,wBAAwB,MAAM,cAC5B,sBAAsB,QAAQ,MAAM,SAAS;EAC/C,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAe,OAAO;EACxE,WAAW,QAAQ,YAAY,SAAS,QAAQ,QAAQ,OAAO;EAC/D,WAAW,QAAQ,YAAY,SAAS,QAAQ,QAAQ,OAAO;EAC/D,8BAA8B,QAAQ,YACpC,4BAA4B,QAAQ,QAAQ,OAAO;EACrD,kBAAkB,QAAQ,YACxB,gBAAgB,QAAQ,QAAQ,OAAO;EACzC,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,qBAAqB,QAAQ,YAC3B,mBAAmB,QAAQ,QAAQ,OAAO;EAC5C,WAAW,OAAO,OAAO,YACvB,SAAS,QAAQ,OAAO,OAAO,OAAO;EACxC,kBAAkB,eAAe,UAC/B,gBAAgB,QAAQ,eAAe,KAAK;EAC9C,mBAAmB,eAAe,WAChC,iBAAiB,QAAQ,eAAe,MAAM;EAChD,0BAA0B,eAAe,kBACvC,wBAAwB,QAAQ,eAAe,aAAa;EAC9D,wBAAwB,QAAQ,YAC9B,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,oBAAoB,eAAe,YACjC,kBAAkB,QAAQ,eAAe,OAAO;EAClD,mBAAmB,QAAQ,YACzB,iBAAiB,QAAQ,QAAQ,OAAO;EAC1C,qBAAqB,QAAQ,YAC3B,mBAAmB,QAAQ,QAAQ,OAAO;CAC9C;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseError } from "./baseError.js";
|
|
2
2
|
import "./constants.js";
|
|
3
3
|
//#region src/errors/httpError.ts
|
|
4
|
-
const statusCodeToErrorClassificationMap = new Map([
|
|
4
|
+
const statusCodeToErrorClassificationMap = /* @__PURE__ */ new Map([
|
|
5
5
|
[400, {
|
|
6
6
|
type: "ValidationError",
|
|
7
7
|
code: 1001
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpError.js","names":[],"sources":["../../../src/errors/httpError.ts"],"sourcesContent":["import type { UnavailableRoutes } from '@lifi/types'\nimport type { ExtendedRequestInit } from '../types/request.js'\nimport { BaseError } from './baseError.js'\nimport { ErrorMessage, ErrorName, LiFiErrorCode } from './constants.js'\n\ninterface ServerErrorResponseBody {\n code: number\n message: string\n errors?: UnavailableRoutes\n}\n\nconst statusCodeToErrorClassificationMap = new Map([\n [\n 400,\n { type: ErrorName.ValidationError, code: LiFiErrorCode.ValidationError },\n ],\n [404, { type: ErrorName.NotFoundError, code: LiFiErrorCode.NotFound }],\n [\n 409,\n {\n type: ErrorName.SlippageError,\n code: LiFiErrorCode.SlippageError,\n message: ErrorMessage.SlippageError,\n },\n ],\n [424, { type: ErrorName.ServerError, code: LiFiErrorCode.ThirdPartyError }],\n [429, { type: ErrorName.ServerError, code: LiFiErrorCode.RateLimitExceeded }],\n [500, { type: ErrorName.ServerError, code: LiFiErrorCode.InternalError }],\n])\n\nconst getErrorClassificationFromStatusCode = (code: number) =>\n statusCodeToErrorClassificationMap.get(code) ?? {\n type: ErrorName.ServerError,\n code: LiFiErrorCode.InternalError,\n }\n\nconst createInitialMessage = (response: Response) => {\n const statusCode =\n response.status || response.status === 0 ? response.status : ''\n const title = response.statusText || ''\n const status = `${statusCode} ${title}`.trim()\n const reason = status ? `status code ${status}` : 'an unknown error'\n return `Request failed with ${reason}`\n}\n\nexport class HTTPError extends BaseError {\n public response: Response\n public status: number\n public url: RequestInfo | URL\n public fetchOptions: ExtendedRequestInit\n public type?: ErrorName\n public responseBody?: ServerErrorResponseBody\n\n constructor(\n response: Response,\n url: RequestInfo | URL,\n options: ExtendedRequestInit\n ) {\n const errorClassification = getErrorClassificationFromStatusCode(\n response.status\n )\n const additionalMessage = errorClassification?.message\n ? `\\n${errorClassification.message}`\n : ''\n const message = createInitialMessage(response) + additionalMessage\n\n super(ErrorName.HTTPError, errorClassification.code, message)\n\n this.type = errorClassification.type\n this.response = response\n this.status = response.status\n this.message = message\n this.url = url\n this.fetchOptions = options\n }\n\n async buildAdditionalDetails(): Promise<void> {\n if (this.type) {\n this.message = `[${this.type}] ${this.message}`\n }\n\n try {\n this.responseBody = await this.response.json()\n\n if (this.responseBody?.message) {\n this.message += this.message.endsWith('.')\n ? ` ${this.responseBody.message.toString()}`\n : `. ${this.responseBody.message.toString()}`\n }\n } catch {}\n }\n}\n"],"mappings":";;;AAWA,MAAM,
|
|
1
|
+
{"version":3,"file":"httpError.js","names":[],"sources":["../../../src/errors/httpError.ts"],"sourcesContent":["import type { UnavailableRoutes } from '@lifi/types'\nimport type { ExtendedRequestInit } from '../types/request.js'\nimport { BaseError } from './baseError.js'\nimport { ErrorMessage, ErrorName, LiFiErrorCode } from './constants.js'\n\ninterface ServerErrorResponseBody {\n code: number\n message: string\n errors?: UnavailableRoutes\n}\n\nconst statusCodeToErrorClassificationMap = new Map([\n [\n 400,\n { type: ErrorName.ValidationError, code: LiFiErrorCode.ValidationError },\n ],\n [404, { type: ErrorName.NotFoundError, code: LiFiErrorCode.NotFound }],\n [\n 409,\n {\n type: ErrorName.SlippageError,\n code: LiFiErrorCode.SlippageError,\n message: ErrorMessage.SlippageError,\n },\n ],\n [424, { type: ErrorName.ServerError, code: LiFiErrorCode.ThirdPartyError }],\n [429, { type: ErrorName.ServerError, code: LiFiErrorCode.RateLimitExceeded }],\n [500, { type: ErrorName.ServerError, code: LiFiErrorCode.InternalError }],\n])\n\nconst getErrorClassificationFromStatusCode = (code: number) =>\n statusCodeToErrorClassificationMap.get(code) ?? {\n type: ErrorName.ServerError,\n code: LiFiErrorCode.InternalError,\n }\n\nconst createInitialMessage = (response: Response) => {\n const statusCode =\n response.status || response.status === 0 ? response.status : ''\n const title = response.statusText || ''\n const status = `${statusCode} ${title}`.trim()\n const reason = status ? `status code ${status}` : 'an unknown error'\n return `Request failed with ${reason}`\n}\n\nexport class HTTPError extends BaseError {\n public response: Response\n public status: number\n public url: RequestInfo | URL\n public fetchOptions: ExtendedRequestInit\n public type?: ErrorName\n public responseBody?: ServerErrorResponseBody\n\n constructor(\n response: Response,\n url: RequestInfo | URL,\n options: ExtendedRequestInit\n ) {\n const errorClassification = getErrorClassificationFromStatusCode(\n response.status\n )\n const additionalMessage = errorClassification?.message\n ? `\\n${errorClassification.message}`\n : ''\n const message = createInitialMessage(response) + additionalMessage\n\n super(ErrorName.HTTPError, errorClassification.code, message)\n\n this.type = errorClassification.type\n this.response = response\n this.status = response.status\n this.message = message\n this.url = url\n this.fetchOptions = options\n }\n\n async buildAdditionalDetails(): Promise<void> {\n if (this.type) {\n this.message = `[${this.type}] ${this.message}`\n }\n\n try {\n this.responseBody = await this.response.json()\n\n if (this.responseBody?.message) {\n this.message += this.message.endsWith('.')\n ? ` ${this.responseBody.message.toString()}`\n : `. ${this.responseBody.message.toString()}`\n }\n } catch {}\n }\n}\n"],"mappings":";;;AAWA,MAAM,qDAAqC,IAAI,IAAI;CACjD,CACE,KACA;EAAE,MAAA;EAAiC,MAAA;CAAoC,CACzE;CACA,CAAC,KAAK;EAAE,MAAA;EAA+B,MAAA;CAA6B,CAAC;CACrE,CACE,KACA;EACE,MAAA;EACA,MAAA;EACA,SAAA;CACF,CACF;CACA,CAAC,KAAK;EAAE,MAAA;EAA6B,MAAA;CAAoC,CAAC;CAC1E,CAAC,KAAK;EAAE,MAAA;EAA6B,MAAA;CAAsC,CAAC;CAC5E,CAAC,KAAK;EAAE,MAAA;EAA6B,MAAA;CAAkC,CAAC;AAC1E,CAAC;AAED,MAAM,wCAAwC,SAC5C,mCAAmC,IAAI,IAAI,KAAK;CAC9C,MAAA;CACA,MAAA;AACF;AAEF,MAAM,wBAAwB,aAAuB;CAInD,MAAM,SAAS,GAFb,SAAS,UAAU,SAAS,WAAW,IAAI,SAAS,SAAS,GAElC,GADf,SAAS,cAAc,KACG,KAAK;CAE7C,OAAO,uBADQ,SAAS,eAAe,WAAW;AAEpD;AAEA,IAAa,YAAb,cAA+B,UAAU;CACvC;CACA;CACA;CACA;CACA;CACA;CAEA,YACE,UACA,KACA,SACA;EACA,MAAM,sBAAsB,qCAC1B,SAAS,MACX;EACA,MAAM,oBAAoB,qBAAqB,UAC3C,KAAK,oBAAoB,YACzB;EACJ,MAAM,UAAU,qBAAqB,QAAQ,IAAI;EAEjD,MAAA,aAA2B,oBAAoB,MAAM,OAAO;EAE5D,KAAK,OAAO,oBAAoB;EAChC,KAAK,WAAW;EAChB,KAAK,SAAS,SAAS;EACvB,KAAK,UAAU;EACf,KAAK,MAAM;EACX,KAAK,eAAe;CACtB;CAEA,MAAM,yBAAwC;EAC5C,IAAI,KAAK,MACP,KAAK,UAAU,IAAI,KAAK,KAAK,IAAI,KAAK;EAGxC,IAAI;GACF,KAAK,eAAe,MAAM,KAAK,SAAS,KAAK;GAE7C,IAAI,KAAK,cAAc,SACrB,KAAK,WAAW,KAAK,QAAQ,SAAS,GAAG,IACrC,IAAI,KAAK,aAAa,QAAQ,SAAS,MACvC,KAAK,KAAK,aAAa,QAAQ,SAAS;EAEhD,QAAQ,CAAC;CACX;AACF"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { getConnections } from "./actions/getConnections.js";
|
|
|
5
5
|
import { getContractCallsQuote } from "./actions/getContractCallsQuote.js";
|
|
6
6
|
import { getGasRecommendation } from "./actions/getGasRecommendation.js";
|
|
7
7
|
import { getNameServiceAddress } from "./actions/getNameServiceAddress.js";
|
|
8
|
+
import { GetStatusRequestExtended, LiFiStepRequest, QuoteRequest, QuoteRequestFromAmount, QuoteRequestToAmount } from "./types/actions.js";
|
|
8
9
|
import { getQuote } from "./actions/getQuote.js";
|
|
9
10
|
import { getRelayedTransactionStatus } from "./actions/getRelayedTransactionStatus.js";
|
|
10
11
|
import { getRelayerQuote } from "./actions/getRelayerQuote.js";
|
|
@@ -52,4 +53,4 @@ import { waitForResult } from "./utils/waitForResult.js";
|
|
|
52
53
|
import { LruMap, withDedupe } from "./utils/withDedupe.js";
|
|
53
54
|
import { withTimeout } from "./utils/withTimeout.js";
|
|
54
55
|
export * from "@lifi/types";
|
|
55
|
-
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, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, 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, getWalletBalances, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, 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 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, getWalletBalances, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, waitForResult, withDedupe, withTimeout };
|
|
@@ -1,14 +1,34 @@
|
|
|
1
|
-
import { GetStatusRequest, QuoteRequest as QuoteRequest$1 } from "@lifi/types";
|
|
1
|
+
import { Action, GetStatusRequest, LiFiStep, QuoteRequest as QuoteRequest$1, RoutesRequest as RoutesRequest$1, SignedLiFiStep } from "@lifi/types";
|
|
2
2
|
|
|
3
3
|
//#region src/types/actions.d.ts
|
|
4
4
|
type GetStatusRequestExtended = GetStatusRequest & {
|
|
5
5
|
fromAddress?: string;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Optional limit-order fields. Supplying them opts a request into limit-order
|
|
9
|
+
* handling; resolution happens on the backend.
|
|
10
|
+
*/
|
|
11
|
+
type OrderFields = {
|
|
12
|
+
toAmount?: string;
|
|
13
|
+
validUntil?: number;
|
|
14
|
+
partiallyFillable?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type RoutesRequest = Omit<RoutesRequest$1, "options"> & OrderFields & {
|
|
17
|
+
options?: RoutesRequest$1["options"] & {
|
|
18
|
+
/** (default: false) Whether to request private routes */private?: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A step request that may carry the optional limit-order `action` fields.
|
|
23
|
+
*/
|
|
24
|
+
type LiFiStepRequest = (LiFiStep | SignedLiFiStep) & {
|
|
25
|
+
action: Action & OrderFields;
|
|
26
|
+
};
|
|
7
27
|
type QuoteRequestFromAmount = QuoteRequest$1;
|
|
8
28
|
type QuoteRequestToAmount = Omit<QuoteRequest$1, "fromAmount"> & {
|
|
9
29
|
toAmount: string;
|
|
10
30
|
};
|
|
11
31
|
type QuoteRequest = QuoteRequestFromAmount | QuoteRequestToAmount;
|
|
12
32
|
//#endregion
|
|
13
|
-
export { GetStatusRequestExtended, QuoteRequest, QuoteRequestFromAmount, QuoteRequestToAmount };
|
|
33
|
+
export { GetStatusRequestExtended, LiFiStepRequest, QuoteRequest, QuoteRequestFromAmount, QuoteRequestToAmount, RoutesRequest };
|
|
14
34
|
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","names":[],"sources":["../../../src/types/actions.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"actions.d.ts","names":[],"sources":["../../../src/types/actions.ts"],"mappings":";;;KASY,wBAAA,GAA2B,gBAAA;EACrC,WAAA;AAAA;;;;AAAA;KAOG,WAAA;EACH,QAAA;EACA,UAAA;EACA,iBAAA;AAAA;AAAA,KAGU,aAAA,GAAgB,IAAA,CAAK,eAAA,eAC/B,WAAA;EACE,OAAA,GAAU,eAAA;IALZ,yDAOI,OAAA;EAAA;AAAA;;;;KAOM,eAAA,IAAmB,QAAA,GAAW,cAAA;EACxC,MAAA,EAAQ,MAAA,GAAS,WAAA;AAAA;AAAA,KAGP,sBAAA,GAAyB,cAAA;AAAA,KAEzB,oBAAA,GAAuB,IAAA,CAAK,cAAA;EACtC,QAAA;AAAA;AAAA,KAGU,YAAA,GAAe,sBAAA,GAAyB,oBAAA"}
|
|
@@ -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.0
|
|
7
|
+
const currentVersion = packageVersion ?? "4.1.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isStep.d.ts","names":[],"sources":["../../../src/utils/isStep.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"isStep.d.ts","names":[],"sources":["../../../src/utils/isStep.ts"],"mappings":";;;cAiCa,MAAA,GAAU,IAAA,EAAM,QAAA,KAAW,IAAA,IAAQ,QAAA"}
|
package/dist/esm/utils/isStep.js
CHANGED
|
@@ -5,6 +5,7 @@ const isAction = (action) => {
|
|
|
5
5
|
return typeof fromChainId === "number" && typeof fromAmount === "string" && fromAmount !== "" && isToken(fromToken) && typeof toChainId === "number" && isToken(toToken);
|
|
6
6
|
};
|
|
7
7
|
const isEstimate = (estimate) => {
|
|
8
|
+
if (!estimate) return false;
|
|
8
9
|
const { fromAmount, toAmount, toAmountMin, approvalAddress } = estimate;
|
|
9
10
|
return typeof fromAmount === "string" && fromAmount !== "" && typeof toAmount === "string" && toAmount !== "" && typeof toAmountMin === "string" && toAmountMin !== "" && (typeof approvalAddress === "string" || approvalAddress === null);
|
|
10
11
|
};
|
|
@@ -14,7 +15,7 @@ const isStep = (step) => {
|
|
|
14
15
|
"swap",
|
|
15
16
|
"cross",
|
|
16
17
|
"lifi"
|
|
17
|
-
].includes(type) && typeof tool === "string" && isAction(action) && isEstimate(estimate);
|
|
18
|
+
].includes(type) && typeof tool === "string" && isAction(action) && (!estimate || isEstimate(estimate));
|
|
18
19
|
};
|
|
19
20
|
//#endregion
|
|
20
21
|
export { isStep };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isStep.js","names":[],"sources":["../../../src/utils/isStep.ts"],"sourcesContent":["import type { Action, Estimate, LiFiStep } from '@lifi/types'\nimport { isToken } from './isToken.js'\n\nconst isAction = (action: Action): action is Action => {\n const { fromChainId, fromAmount, fromToken, toChainId, toToken } = action\n\n return (\n typeof fromChainId === 'number' &&\n typeof fromAmount === 'string' &&\n fromAmount !== '' &&\n isToken(fromToken) &&\n typeof toChainId === 'number' &&\n isToken(toToken)\n )\n}\n\nconst isEstimate = (estimate: Estimate): estimate is Estimate => {\n const { fromAmount, toAmount, toAmountMin, approvalAddress } = estimate\n\n return (\n typeof fromAmount === 'string' &&\n fromAmount !== '' &&\n typeof toAmount === 'string' &&\n toAmount !== '' &&\n typeof toAmountMin === 'string' &&\n toAmountMin !== '' &&\n (typeof approvalAddress === 'string' || approvalAddress === null)\n )\n}\n\nexport const isStep = (step: LiFiStep): step is LiFiStep => {\n const { id, type, tool, action, estimate } = step\n\n return (\n typeof id === 'string' &&\n ['swap', 'cross', 'lifi'].includes(type) &&\n typeof tool === 'string' &&\n isAction(action) &&\n isEstimate(estimate)\n )\n}\n"],"mappings":";;AAGA,MAAM,YAAY,WAAqC;CACrD,MAAM,EAAE,aAAa,YAAY,WAAW,WAAW,YAAY;CAEnE,OACE,OAAO,gBAAgB,YACvB,OAAO,eAAe,YACtB,eAAe,MACf,QAAQ,SAAS,KACjB,OAAO,cAAc,YACrB,QAAQ,OAAO;AAEnB;AAEA,MAAM,cAAc,aAA6C;CAC/D,MAAM,EAAE,YAAY,UAAU,aAAa,oBAAoB;CAE/D,OACE,OAAO,eAAe,YACtB,eAAe,MACf,OAAO,aAAa,YACpB,aAAa,MACb,OAAO,gBAAgB,YACvB,gBAAgB,OACf,OAAO,oBAAoB,YAAY,oBAAoB;AAEhE;AAEA,MAAa,UAAU,SAAqC;CAC1D,MAAM,EAAE,IAAI,MAAM,MAAM,QAAQ,aAAa;CAE7C,OACE,OAAO,OAAO,YACd;EAAC;EAAQ;EAAS;CAAM,CAAC,CAAC,SAAS,IAAI,KACvC,OAAO,SAAS,YAChB,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"isStep.js","names":[],"sources":["../../../src/utils/isStep.ts"],"sourcesContent":["import type { Action, Estimate, LiFiStep } from '@lifi/types'\nimport { isToken } from './isToken.js'\n\nconst isAction = (action: Action): action is Action => {\n const { fromChainId, fromAmount, fromToken, toChainId, toToken } = action\n\n return (\n typeof fromChainId === 'number' &&\n typeof fromAmount === 'string' &&\n fromAmount !== '' &&\n isToken(fromToken) &&\n typeof toChainId === 'number' &&\n isToken(toToken)\n )\n}\n\nconst isEstimate = (estimate: Estimate): estimate is Estimate => {\n if (!estimate) {\n return false\n }\n const { fromAmount, toAmount, toAmountMin, approvalAddress } = estimate\n\n return (\n typeof fromAmount === 'string' &&\n fromAmount !== '' &&\n typeof toAmount === 'string' &&\n toAmount !== '' &&\n typeof toAmountMin === 'string' &&\n toAmountMin !== '' &&\n (typeof approvalAddress === 'string' || approvalAddress === null)\n )\n}\n\nexport const isStep = (step: LiFiStep): step is LiFiStep => {\n const { id, type, tool, action, estimate } = step\n\n return (\n typeof id === 'string' &&\n ['swap', 'cross', 'lifi'].includes(type) &&\n typeof tool === 'string' &&\n isAction(action) &&\n (!estimate || isEstimate(estimate))\n )\n}\n"],"mappings":";;AAGA,MAAM,YAAY,WAAqC;CACrD,MAAM,EAAE,aAAa,YAAY,WAAW,WAAW,YAAY;CAEnE,OACE,OAAO,gBAAgB,YACvB,OAAO,eAAe,YACtB,eAAe,MACf,QAAQ,SAAS,KACjB,OAAO,cAAc,YACrB,QAAQ,OAAO;AAEnB;AAEA,MAAM,cAAc,aAA6C;CAC/D,IAAI,CAAC,UACH,OAAO;CAET,MAAM,EAAE,YAAY,UAAU,aAAa,oBAAoB;CAE/D,OACE,OAAO,eAAe,YACtB,eAAe,MACf,OAAO,aAAa,YACpB,aAAa,MACb,OAAO,gBAAgB,YACvB,gBAAgB,OACf,OAAO,oBAAoB,YAAY,oBAAoB;AAEhE;AAEA,MAAa,UAAU,SAAqC;CAC1D,MAAM,EAAE,IAAI,MAAM,MAAM,QAAQ,aAAa;CAE7C,OACE,OAAO,OAAO,YACd;EAAC;EAAQ;EAAS;CAAM,CAAC,CAAC,SAAS,IAAI,KACvC,OAAO,SAAS,YAChB,SAAS,MAAM,MACd,CAAC,YAAY,WAAW,QAAQ;AAErC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toQueryString.d.ts","names":[],"sources":["../../../src/utils/toQueryString.ts"],"mappings":";cA+Ba,aAAA,GAAiB,MAAQ,EAAA,MAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/utils/toQueryString.ts
|
|
2
|
+
const isPrimitive = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint";
|
|
3
|
+
const serialize = (key, value) => {
|
|
4
|
+
if (value === void 0 || value === null) return [];
|
|
5
|
+
if (isPrimitive(value)) return [`${key}=${encodeURIComponent(String(value))}`];
|
|
6
|
+
if (Array.isArray(value)) {
|
|
7
|
+
if (value.every(isPrimitive)) return [`${key}=${encodeURIComponent(value.join(","))}`];
|
|
8
|
+
return value.flatMap((item, index) => serialize(`${key}[${index}]`, item));
|
|
9
|
+
}
|
|
10
|
+
return Object.entries(value).flatMap(([subKey, subValue]) => serialize(`${key}[${subKey}]`, subValue));
|
|
11
|
+
};
|
|
12
|
+
const toQueryString = (params) => Object.entries(params).flatMap(([key, value]) => serialize(key, value)).join("&");
|
|
13
|
+
//#endregion
|
|
14
|
+
export { toQueryString };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=toQueryString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toQueryString.js","names":[],"sources":["../../../src/utils/toQueryString.ts"],"sourcesContent":["type QueryPrimitive = string | number | boolean | bigint\n\nconst isPrimitive = (value: unknown): value is QueryPrimitive =>\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n typeof value === 'bigint'\n\n// Arrays of objects use qs indices notation (`key[0][subKey]=value`) to match\n// the backend's `qs.parse(str, { comma: true })`; only values are encoded.\nconst serialize = (key: string, value: unknown): string[] => {\n if (value === undefined || value === null) {\n return []\n }\n if (isPrimitive(value)) {\n return [`${key}=${encodeURIComponent(String(value))}`]\n }\n if (Array.isArray(value)) {\n // Scalar arrays stay comma-joined (backend splits on `comma: true`).\n if (value.every(isPrimitive)) {\n return [`${key}=${encodeURIComponent(value.join(','))}`]\n }\n return value.flatMap((item, index) => serialize(`${key}[${index}]`, item))\n }\n return Object.entries(value as Record<string, unknown>).flatMap(\n ([subKey, subValue]) => serialize(`${key}[${subKey}]`, subValue)\n )\n}\n\n// Encode params into a query string (no leading `?`). Drop-in for\n// `URLSearchParams` that handles nested array/object params; skips null/undefined.\nexport const toQueryString = (params: Record<string, unknown>): string =>\n Object.entries(params)\n .flatMap(([key, value]) => serialize(key, value))\n .join('&')\n"],"mappings":";AAEA,MAAM,eAAe,UACnB,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,aACjB,OAAO,UAAU;AAInB,MAAM,aAAa,KAAa,UAA6B;CAC3D,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,OAAO,CAAC;CAEV,IAAI,YAAY,KAAK,GACnB,OAAO,CAAC,GAAG,IAAI,GAAG,mBAAmB,OAAO,KAAK,CAAC,GAAG;CAEvD,IAAI,MAAM,QAAQ,KAAK,GAAG;EAExB,IAAI,MAAM,MAAM,WAAW,GACzB,OAAO,CAAC,GAAG,IAAI,GAAG,mBAAmB,MAAM,KAAK,GAAG,CAAC,GAAG;EAEzD,OAAO,MAAM,SAAS,MAAM,UAAU,UAAU,GAAG,IAAI,GAAG,MAAM,IAAI,IAAI,CAAC;CAC3E;CACA,OAAO,OAAO,QAAQ,KAAgC,CAAC,CAAC,SACrD,CAAC,QAAQ,cAAc,UAAU,GAAG,IAAI,GAAG,OAAO,IAAI,QAAQ,CACjE;AACF;AAIA,MAAa,iBAAiB,WAC5B,OAAO,QAAQ,MAAM,CAAC,CACnB,SAAS,CAAC,KAAK,WAAW,UAAU,KAAK,KAAK,CAAC,CAAC,CAChD,KAAK,GAAG"}
|
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.0
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.1.0'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
package/package.json
CHANGED
package/src/actions/getQuote.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
} from '../types/actions.js'
|
|
9
9
|
import type { SDKClient } from '../types/core.js'
|
|
10
10
|
import { request } from '../utils/request.js'
|
|
11
|
+
import { toQueryString } from '../utils/toQueryString.js'
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Get a quote for a token transfer
|
|
@@ -95,8 +96,8 @@ export async function getQuote(
|
|
|
95
96
|
|
|
96
97
|
return await request<LiFiStep>(
|
|
97
98
|
client.config,
|
|
98
|
-
`${client.config.apiUrl}/${isFromAmountRequest ? 'quote' : 'quote/toAmount'}?${
|
|
99
|
-
params as
|
|
99
|
+
`${client.config.apiUrl}/${isFromAmountRequest ? 'quote' : 'quote/toAmount'}?${toQueryString(
|
|
100
|
+
params as Record<string, unknown>
|
|
100
101
|
)}`,
|
|
101
102
|
{
|
|
102
103
|
signal: options?.signal,
|
package/src/actions/getRoutes.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { RequestOptions,
|
|
1
|
+
import type { RequestOptions, RoutesResponse } from '@lifi/types'
|
|
2
2
|
import { ValidationError } from '../errors/errors.js'
|
|
3
3
|
import { SDKError } from '../errors/SDKError.js'
|
|
4
|
+
import type { RoutesRequest } from '../types/actions.js'
|
|
4
5
|
import type { SDKClient } from '../types/core.js'
|
|
5
6
|
import { isRoutesRequest } from '../utils/isRoutesRequest.js'
|
|
6
7
|
import { request } from '../utils/request.js'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { LiFiStep, RequestOptions
|
|
1
|
+
import type { LiFiStep, RequestOptions } from '@lifi/types'
|
|
2
2
|
import { ChainId } from '@lifi/types'
|
|
3
|
+
import type { LiFiStepRequest } from '../types/actions.js'
|
|
3
4
|
import type { SDKClient } from '../types/core.js'
|
|
4
5
|
import { isStep } from '../utils/isStep.js'
|
|
5
6
|
import { request } from '../utils/request.js'
|
|
@@ -14,7 +15,7 @@ import { request } from '../utils/request.js'
|
|
|
14
15
|
*/
|
|
15
16
|
export const getStepTransaction = async (
|
|
16
17
|
client: SDKClient,
|
|
17
|
-
step:
|
|
18
|
+
step: LiFiStepRequest,
|
|
18
19
|
options?: RequestOptions
|
|
19
20
|
): Promise<LiFiStep> => {
|
|
20
21
|
if (!isStep(step)) {
|
package/src/actions/index.ts
CHANGED
|
@@ -16,9 +16,7 @@ import type {
|
|
|
16
16
|
RelayStatusRequest,
|
|
17
17
|
RelayStatusResponseData,
|
|
18
18
|
RequestOptions,
|
|
19
|
-
RoutesRequest,
|
|
20
19
|
RoutesResponse,
|
|
21
|
-
SignedLiFiStep,
|
|
22
20
|
StatusResponse,
|
|
23
21
|
Token,
|
|
24
22
|
TokenAmount,
|
|
@@ -34,7 +32,9 @@ import type {
|
|
|
34
32
|
} from '@lifi/types'
|
|
35
33
|
import type {
|
|
36
34
|
GetStatusRequestExtended,
|
|
35
|
+
LiFiStepRequest,
|
|
37
36
|
QuoteRequestFromAmount,
|
|
37
|
+
RoutesRequest,
|
|
38
38
|
} from '../types/actions.js'
|
|
39
39
|
import type { SDKClient } from '../types/core.js'
|
|
40
40
|
import { getChains } from './getChains.js'
|
|
@@ -152,7 +152,9 @@ export type Actions = {
|
|
|
152
152
|
) => Promise<LiFiStep>
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
|
-
* Get a set of routes for a request that describes a transfer of tokens
|
|
155
|
+
* Get a set of routes for a request that describes a transfer of tokens.
|
|
156
|
+
* Optional limit-order fields (`toAmount`, `validUntil`, `partiallyFillable`)
|
|
157
|
+
* may be supplied and are resolved on the backend.
|
|
156
158
|
* @param params - A description of the transfer
|
|
157
159
|
* @param options - Request options
|
|
158
160
|
* @returns The resulting routes that can be used to realize the described transfer
|
|
@@ -174,13 +176,14 @@ export type Actions = {
|
|
|
174
176
|
) => Promise<StatusResponse>
|
|
175
177
|
|
|
176
178
|
/**
|
|
177
|
-
* Get a step transaction
|
|
179
|
+
* Get a step transaction. The step's `action` may carry the optional
|
|
180
|
+
* limit-order fields, which are resolved on the backend.
|
|
178
181
|
* @param params - The configuration of the requested step transaction
|
|
179
182
|
* @param options - Request options
|
|
180
183
|
* @returns Step transaction
|
|
181
184
|
*/
|
|
182
185
|
getStepTransaction: (
|
|
183
|
-
params:
|
|
186
|
+
params: LiFiStepRequest,
|
|
184
187
|
options?: RequestOptions
|
|
185
188
|
) => Promise<LiFiStep>
|
|
186
189
|
|
package/src/index.ts
CHANGED
|
@@ -67,6 +67,13 @@ export {
|
|
|
67
67
|
} from './errors/errors.js'
|
|
68
68
|
export { HTTPError } from './errors/httpError.js'
|
|
69
69
|
export { SDKError } from './errors/SDKError.js'
|
|
70
|
+
export type {
|
|
71
|
+
GetStatusRequestExtended,
|
|
72
|
+
LiFiStepRequest,
|
|
73
|
+
QuoteRequest,
|
|
74
|
+
QuoteRequestFromAmount,
|
|
75
|
+
QuoteRequestToAmount,
|
|
76
|
+
} from './types/actions.js'
|
|
70
77
|
export type {
|
|
71
78
|
AcceptExchangeRateUpdateHook,
|
|
72
79
|
AcceptSlippageUpdateHook,
|
package/src/types/actions.ts
CHANGED
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
Action,
|
|
2
3
|
GetStatusRequest,
|
|
4
|
+
LiFiStep,
|
|
3
5
|
QuoteRequest as QuoteRequestBase,
|
|
6
|
+
RoutesRequest as RoutesRequestBase,
|
|
7
|
+
SignedLiFiStep,
|
|
4
8
|
} from '@lifi/types'
|
|
5
9
|
|
|
6
10
|
export type GetStatusRequestExtended = GetStatusRequest & {
|
|
7
11
|
fromAddress?: string
|
|
8
12
|
}
|
|
9
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Optional limit-order fields. Supplying them opts a request into limit-order
|
|
16
|
+
* handling; resolution happens on the backend.
|
|
17
|
+
*/
|
|
18
|
+
type OrderFields = {
|
|
19
|
+
toAmount?: string
|
|
20
|
+
validUntil?: number
|
|
21
|
+
partiallyFillable?: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type RoutesRequest = Omit<RoutesRequestBase, 'options'> &
|
|
25
|
+
OrderFields & {
|
|
26
|
+
options?: RoutesRequestBase['options'] & {
|
|
27
|
+
/** (default: false) Whether to request private routes */
|
|
28
|
+
private?: boolean
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A step request that may carry the optional limit-order `action` fields.
|
|
34
|
+
*/
|
|
35
|
+
export type LiFiStepRequest = (LiFiStep | SignedLiFiStep) & {
|
|
36
|
+
action: Action & OrderFields
|
|
37
|
+
}
|
|
38
|
+
|
|
10
39
|
export type QuoteRequestFromAmount = QuoteRequestBase
|
|
11
40
|
|
|
12
41
|
export type QuoteRequestToAmount = Omit<QuoteRequestBase, 'fromAmount'> & {
|
package/src/utils/isStep.ts
CHANGED
|
@@ -15,6 +15,9 @@ const isAction = (action: Action): action is Action => {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const isEstimate = (estimate: Estimate): estimate is Estimate => {
|
|
18
|
+
if (!estimate) {
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
18
21
|
const { fromAmount, toAmount, toAmountMin, approvalAddress } = estimate
|
|
19
22
|
|
|
20
23
|
return (
|
|
@@ -36,6 +39,6 @@ export const isStep = (step: LiFiStep): step is LiFiStep => {
|
|
|
36
39
|
['swap', 'cross', 'lifi'].includes(type) &&
|
|
37
40
|
typeof tool === 'string' &&
|
|
38
41
|
isAction(action) &&
|
|
39
|
-
isEstimate(estimate)
|
|
42
|
+
(!estimate || isEstimate(estimate))
|
|
40
43
|
)
|
|
41
44
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type QueryPrimitive = string | number | boolean | bigint
|
|
2
|
+
|
|
3
|
+
const isPrimitive = (value: unknown): value is QueryPrimitive =>
|
|
4
|
+
typeof value === 'string' ||
|
|
5
|
+
typeof value === 'number' ||
|
|
6
|
+
typeof value === 'boolean' ||
|
|
7
|
+
typeof value === 'bigint'
|
|
8
|
+
|
|
9
|
+
// Arrays of objects use qs indices notation (`key[0][subKey]=value`) to match
|
|
10
|
+
// the backend's `qs.parse(str, { comma: true })`; only values are encoded.
|
|
11
|
+
const serialize = (key: string, value: unknown): string[] => {
|
|
12
|
+
if (value === undefined || value === null) {
|
|
13
|
+
return []
|
|
14
|
+
}
|
|
15
|
+
if (isPrimitive(value)) {
|
|
16
|
+
return [`${key}=${encodeURIComponent(String(value))}`]
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
// Scalar arrays stay comma-joined (backend splits on `comma: true`).
|
|
20
|
+
if (value.every(isPrimitive)) {
|
|
21
|
+
return [`${key}=${encodeURIComponent(value.join(','))}`]
|
|
22
|
+
}
|
|
23
|
+
return value.flatMap((item, index) => serialize(`${key}[${index}]`, item))
|
|
24
|
+
}
|
|
25
|
+
return Object.entries(value as Record<string, unknown>).flatMap(
|
|
26
|
+
([subKey, subValue]) => serialize(`${key}[${subKey}]`, subValue)
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Encode params into a query string (no leading `?`). Drop-in for
|
|
31
|
+
// `URLSearchParams` that handles nested array/object params; skips null/undefined.
|
|
32
|
+
export const toQueryString = (params: Record<string, unknown>): string =>
|
|
33
|
+
Object.entries(params)
|
|
34
|
+
.flatMap(([key, value]) => serialize(key, value))
|
|
35
|
+
.join('&')
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk'
|
|
2
|
-
export const version = '4.0
|
|
2
|
+
export const version = '4.1.0'
|