@lifi/sdk 4.0.1 → 4.2.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 +20 -0
- package/dist/cjs/actions/getChains.d.ts +7 -8
- package/dist/cjs/actions/getConnections.d.ts +6 -7
- package/dist/cjs/actions/getContractCallsQuote.d.ts +7 -8
- package/dist/cjs/actions/getGasRecommendation.d.ts +7 -8
- package/dist/cjs/actions/getNameServiceAddress.d.ts +6 -7
- package/dist/cjs/actions/getQuote.d.ts +7 -8
- package/dist/cjs/actions/getQuote.js +2 -1
- package/dist/cjs/actions/getQuote.js.map +1 -1
- package/dist/cjs/actions/getRelayedTransactionStatus.d.ts +7 -8
- package/dist/cjs/actions/getRelayerQuote.d.ts +7 -8
- package/dist/cjs/actions/getRoutes.d.ts +10 -10
- package/dist/cjs/actions/getRoutes.js.map +1 -1
- package/dist/cjs/actions/getStatus.d.ts +7 -8
- package/dist/cjs/actions/getStepTransaction.d.ts +10 -10
- package/dist/cjs/actions/getStepTransaction.js +2 -0
- package/dist/cjs/actions/getStepTransaction.js.map +1 -1
- package/dist/cjs/actions/getToken.d.ts +8 -9
- package/dist/cjs/actions/getTokenBalance.d.ts +8 -9
- package/dist/cjs/actions/getTokenBalances.d.ts +8 -9
- package/dist/cjs/actions/getTokenBalancesByChain.d.ts +8 -9
- package/dist/cjs/actions/getTokenBalancesByChain.js +4 -2
- package/dist/cjs/actions/getTokenBalancesByChain.js.map +1 -1
- package/dist/cjs/actions/getTokens.d.ts +6 -7
- package/dist/cjs/actions/getTools.d.ts +6 -7
- package/dist/cjs/actions/getTransactionHistory.d.ts +13 -19
- package/dist/cjs/actions/getWalletBalances.d.ts +7 -8
- package/dist/cjs/actions/index.d.ts +115 -113
- package/dist/cjs/actions/index.js.map +1 -1
- package/dist/cjs/actions/patchContractCalls.d.ts +0 -1
- package/dist/cjs/actions/relayTransaction.d.ts +7 -8
- package/dist/cjs/client/createClient.d.ts +0 -1
- package/dist/cjs/client/getClientStorage.d.ts +0 -1
- package/dist/cjs/core/BaseStepExecutionTask.d.ts +0 -1
- package/dist/cjs/core/BaseStepExecutor.d.ts +0 -1
- package/dist/cjs/core/StatusManager.d.ts +40 -51
- package/dist/cjs/core/TaskPipeline.d.ts +0 -1
- package/dist/cjs/core/actionMessages.d.ts +0 -1
- package/dist/cjs/core/execution.d.ts +29 -30
- package/dist/cjs/core/executionState.d.ts +0 -1
- package/dist/cjs/core/prepareRestart.d.ts +0 -1
- package/dist/cjs/core/tasks/CheckBalanceTask.d.ts +6 -7
- package/dist/cjs/core/tasks/PrepareTransactionTask.d.ts +0 -1
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.d.ts +0 -1
- package/dist/cjs/core/tasks/helpers/checkBalance.d.ts +17 -18
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.d.ts +0 -1
- package/dist/cjs/core/tasks/helpers/stepComparison.d.ts +11 -12
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.d.ts +0 -1
- package/dist/cjs/core/utils.d.ts +7 -8
- package/dist/cjs/errors/SDKError.d.ts +0 -1
- package/dist/cjs/errors/baseError.d.ts +0 -1
- package/dist/cjs/errors/errors.d.ts +4 -5
- package/dist/cjs/errors/httpError.d.ts +0 -1
- package/dist/cjs/errors/httpError.js +1 -1
- package/dist/cjs/errors/httpError.js.map +1 -1
- package/dist/cjs/errors/utils/baseErrorRootCause.d.ts +0 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/types/actions.d.ts +23 -3
- package/dist/cjs/types/core.d.ts +3 -4
- package/dist/cjs/types/execution.d.ts +0 -1
- package/dist/cjs/utils/checkPackageUpdates.js +1 -1
- package/dist/cjs/utils/convertQuoteToRoute.d.ts +9 -10
- package/dist/cjs/utils/formatUnits.d.ts +2 -2
- package/dist/cjs/utils/getTransactionMessage.d.ts +0 -1
- package/dist/cjs/utils/isHex.d.ts +1 -3
- package/dist/cjs/utils/isRoutesRequest.d.ts +0 -1
- package/dist/cjs/utils/isStep.d.ts +0 -1
- package/dist/cjs/utils/isStep.js +2 -1
- package/dist/cjs/utils/isStep.js.map +1 -1
- package/dist/cjs/utils/isToken.d.ts +0 -1
- package/dist/cjs/utils/parseUnits.d.ts +2 -2
- package/dist/cjs/utils/request.d.ts +0 -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/utils/waitForResult.d.ts +8 -8
- package/dist/cjs/utils/withDedupe.d.ts +5 -8
- package/dist/cjs/utils/withTimeout.d.ts +10 -16
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/actions/getChains.d.ts +7 -8
- package/dist/esm/actions/getChains.d.ts.map +1 -1
- package/dist/esm/actions/getConnections.d.ts +6 -7
- package/dist/esm/actions/getConnections.d.ts.map +1 -1
- package/dist/esm/actions/getContractCallsQuote.d.ts +7 -8
- package/dist/esm/actions/getContractCallsQuote.d.ts.map +1 -1
- package/dist/esm/actions/getGasRecommendation.d.ts +7 -8
- package/dist/esm/actions/getGasRecommendation.d.ts.map +1 -1
- package/dist/esm/actions/getNameServiceAddress.d.ts +6 -7
- package/dist/esm/actions/getNameServiceAddress.d.ts.map +1 -1
- package/dist/esm/actions/getQuote.d.ts +7 -8
- 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/getRelayedTransactionStatus.d.ts +7 -8
- package/dist/esm/actions/getRelayedTransactionStatus.d.ts.map +1 -1
- package/dist/esm/actions/getRelayerQuote.d.ts +7 -8
- package/dist/esm/actions/getRelayerQuote.d.ts.map +1 -1
- package/dist/esm/actions/getRoutes.d.ts +10 -10
- package/dist/esm/actions/getRoutes.d.ts.map +1 -1
- package/dist/esm/actions/getRoutes.js.map +1 -1
- package/dist/esm/actions/getStatus.d.ts +7 -8
- package/dist/esm/actions/getStatus.d.ts.map +1 -1
- package/dist/esm/actions/getStepTransaction.d.ts +10 -10
- package/dist/esm/actions/getStepTransaction.d.ts.map +1 -1
- package/dist/esm/actions/getStepTransaction.js +2 -0
- package/dist/esm/actions/getStepTransaction.js.map +1 -1
- package/dist/esm/actions/getToken.d.ts +8 -9
- package/dist/esm/actions/getToken.d.ts.map +1 -1
- package/dist/esm/actions/getTokenBalance.d.ts +8 -9
- package/dist/esm/actions/getTokenBalance.d.ts.map +1 -1
- package/dist/esm/actions/getTokenBalances.d.ts +8 -9
- package/dist/esm/actions/getTokenBalances.d.ts.map +1 -1
- package/dist/esm/actions/getTokenBalancesByChain.d.ts +8 -9
- package/dist/esm/actions/getTokenBalancesByChain.d.ts.map +1 -1
- package/dist/esm/actions/getTokenBalancesByChain.js +4 -2
- package/dist/esm/actions/getTokenBalancesByChain.js.map +1 -1
- package/dist/esm/actions/getTokens.d.ts +6 -7
- package/dist/esm/actions/getTokens.d.ts.map +1 -1
- package/dist/esm/actions/getTools.d.ts +6 -7
- package/dist/esm/actions/getTools.d.ts.map +1 -1
- package/dist/esm/actions/getTransactionHistory.d.ts +13 -19
- package/dist/esm/actions/getTransactionHistory.d.ts.map +1 -1
- package/dist/esm/actions/getWalletBalances.d.ts +7 -8
- package/dist/esm/actions/getWalletBalances.d.ts.map +1 -1
- package/dist/esm/actions/index.d.ts +115 -113
- package/dist/esm/actions/index.d.ts.map +1 -1
- package/dist/esm/actions/index.js.map +1 -1
- package/dist/esm/actions/patchContractCalls.d.ts +0 -1
- package/dist/esm/actions/patchContractCalls.d.ts.map +1 -1
- package/dist/esm/actions/relayTransaction.d.ts +7 -8
- package/dist/esm/actions/relayTransaction.d.ts.map +1 -1
- package/dist/esm/client/createClient.d.ts +0 -1
- package/dist/esm/client/createClient.d.ts.map +1 -1
- package/dist/esm/client/getClientStorage.d.ts +0 -1
- package/dist/esm/client/getClientStorage.d.ts.map +1 -1
- package/dist/esm/core/BaseStepExecutionTask.d.ts +0 -1
- package/dist/esm/core/BaseStepExecutionTask.d.ts.map +1 -1
- package/dist/esm/core/BaseStepExecutor.d.ts +0 -1
- package/dist/esm/core/BaseStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/StatusManager.d.ts +40 -51
- package/dist/esm/core/StatusManager.d.ts.map +1 -1
- package/dist/esm/core/TaskPipeline.d.ts +0 -1
- package/dist/esm/core/TaskPipeline.d.ts.map +1 -1
- package/dist/esm/core/actionMessages.d.ts +0 -1
- package/dist/esm/core/actionMessages.d.ts.map +1 -1
- package/dist/esm/core/execution.d.ts +29 -30
- package/dist/esm/core/execution.d.ts.map +1 -1
- package/dist/esm/core/executionState.d.ts +0 -1
- package/dist/esm/core/executionState.d.ts.map +1 -1
- package/dist/esm/core/prepareRestart.d.ts +0 -1
- package/dist/esm/core/prepareRestart.d.ts.map +1 -1
- package/dist/esm/core/storage.d.ts.map +1 -1
- package/dist/esm/core/tasks/CheckBalanceTask.d.ts +6 -7
- package/dist/esm/core/tasks/CheckBalanceTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/PrepareTransactionTask.d.ts +0 -1
- package/dist/esm/core/tasks/PrepareTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts +0 -1
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/checkBalance.d.ts +17 -18
- package/dist/esm/core/tasks/helpers/checkBalance.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts +0 -1
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/stepComparison.d.ts +11 -12
- package/dist/esm/core/tasks/helpers/stepComparison.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts +0 -1
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts.map +1 -1
- package/dist/esm/core/utils.d.ts +7 -8
- package/dist/esm/core/utils.d.ts.map +1 -1
- package/dist/esm/errors/SDKError.d.ts +0 -1
- package/dist/esm/errors/SDKError.d.ts.map +1 -1
- package/dist/esm/errors/baseError.d.ts +0 -1
- package/dist/esm/errors/baseError.d.ts.map +1 -1
- package/dist/esm/errors/constants.d.ts.map +1 -1
- package/dist/esm/errors/errors.d.ts +4 -5
- package/dist/esm/errors/errors.d.ts.map +1 -1
- package/dist/esm/errors/httpError.d.ts +0 -1
- package/dist/esm/errors/httpError.d.ts.map +1 -1
- package/dist/esm/errors/httpError.js +1 -1
- package/dist/esm/errors/httpError.js.map +1 -1
- package/dist/esm/errors/utils/baseErrorRootCause.d.ts +0 -1
- package/dist/esm/errors/utils/baseErrorRootCause.d.ts.map +1 -1
- package/dist/esm/errors/utils/rootCause.d.ts.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/types/actions.d.ts +23 -3
- package/dist/esm/types/actions.d.ts.map +1 -1
- package/dist/esm/types/core.d.ts +3 -4
- package/dist/esm/types/core.d.ts.map +1 -1
- package/dist/esm/types/execution.d.ts +0 -1
- package/dist/esm/types/execution.d.ts.map +1 -1
- package/dist/esm/types/request.d.ts.map +1 -1
- package/dist/esm/utils/checkPackageUpdates.d.ts.map +1 -1
- package/dist/esm/utils/checkPackageUpdates.js +1 -1
- package/dist/esm/utils/convertQuoteToRoute.d.ts +9 -10
- package/dist/esm/utils/convertQuoteToRoute.d.ts.map +1 -1
- package/dist/esm/utils/decode.d.ts.map +1 -1
- package/dist/esm/utils/fetchTxErrorDetails.d.ts.map +1 -1
- package/dist/esm/utils/formatUnits.d.ts +2 -2
- package/dist/esm/utils/formatUnits.d.ts.map +1 -1
- package/dist/esm/utils/getTransactionMessage.d.ts +0 -1
- package/dist/esm/utils/getTransactionMessage.d.ts.map +1 -1
- package/dist/esm/utils/isHex.d.ts +1 -3
- package/dist/esm/utils/isHex.d.ts.map +1 -1
- package/dist/esm/utils/isRoutesRequest.d.ts +0 -1
- package/dist/esm/utils/isRoutesRequest.d.ts.map +1 -1
- package/dist/esm/utils/isStep.d.ts +0 -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/isToken.d.ts +0 -1
- package/dist/esm/utils/isToken.d.ts.map +1 -1
- package/dist/esm/utils/parseUnits.d.ts +2 -2
- package/dist/esm/utils/parseUnits.d.ts.map +1 -1
- package/dist/esm/utils/request.d.ts +0 -1
- package/dist/esm/utils/request.d.ts.map +1 -1
- package/dist/esm/utils/sleep.d.ts.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/utils/waitForResult.d.ts +8 -8
- package/dist/esm/utils/waitForResult.d.ts.map +1 -1
- package/dist/esm/utils/withDedupe.d.ts +5 -8
- package/dist/esm/utils/withDedupe.d.ts.map +1 -1
- package/dist/esm/utils/withTimeout.d.ts +10 -16
- package/dist/esm/utils/withTimeout.d.ts.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.d.ts.map +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 +7 -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
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ExecuteStepRetryParams } from "../types/core.js";
|
|
2
2
|
import { LiFiErrorCode } from "./constants.js";
|
|
3
3
|
import { BaseError } from "./baseError.js";
|
|
4
|
-
|
|
5
4
|
//#region src/errors/errors.d.ts
|
|
6
5
|
declare class RPCError extends BaseError {
|
|
7
6
|
constructor(code: LiFiErrorCode, message: string, cause?: Error);
|
|
@@ -25,10 +24,10 @@ declare class ValidationError extends BaseError {
|
|
|
25
24
|
constructor(message: string);
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
28
|
-
* Thrown by a step executor when executeStep should be retried with the given params
|
|
29
|
-
* (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).
|
|
30
|
-
* The execution layer catches this and retries executeStep(client, step, retryParams).
|
|
31
|
-
*/
|
|
27
|
+
* Thrown by a step executor when executeStep should be retried with the given params
|
|
28
|
+
* (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).
|
|
29
|
+
* The execution layer catches this and retries executeStep(client, step, retryParams).
|
|
30
|
+
*/
|
|
32
31
|
declare class ExecuteStepRetryError extends BaseError {
|
|
33
32
|
readonly retryParams: ExecuteStepRetryParams;
|
|
34
33
|
constructor(message: string, retryParams: ExecuteStepRetryParams, cause?: Error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":[],"sources":["../../../src/errors/errors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../../../src/errors/errors.ts"],"mappings":";;;;cAIa,iBAAiB;EAC5B,YAAY,MAAM,eAAe,iBAAiB,QAAQ;;cAK/C,sBAAsB;EACjC,YAAY,MAAM,eAAe,iBAAiB,QAAQ;;cAK/C,yBAAyB;EACpC,YAAY,MAAM,eAAe,iBAAiB,QAAQ;;cAK/C,qBAAqB;EAChC,YAAY,iBAAiB,QAAQ;;cAK1B,qBAAqB;EAChC,YAAY,iBAAiB,QAAQ;;cAK1B,oBAAoB;EAC/B,YAAY;;cAKD,wBAAwB;EACnC,YAAY;;;;;;;cAUD,8BAA8B;WAChC,aAAa;EAEtB,YACE,iBACA,aAAa,wBACb,QAAQ"}
|
|
@@ -2,7 +2,6 @@ import { ExtendedRequestInit } from "../types/request.js";
|
|
|
2
2
|
import { ErrorName } from "./constants.js";
|
|
3
3
|
import { BaseError } from "./baseError.js";
|
|
4
4
|
import { UnavailableRoutes } from "@lifi/types";
|
|
5
|
-
|
|
6
5
|
//#region src/errors/httpError.d.ts
|
|
7
6
|
interface ServerErrorResponseBody {
|
|
8
7
|
code: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpError.d.ts","names":[],"sources":["../../../src/errors/httpError.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"httpError.d.ts","names":[],"sources":["../../../src/errors/httpError.ts"],"mappings":";;;;;UAKU;EACR;EACA;EACA,SAAS;;cAqCE,kBAAkB;EAC7B,UAAiB;EACjB;EACA,KAAY,cAAc;EAC1B,cAAqB;EACrB,OAAc;EACd,eAAsB;EAEtB,YACE,UAAU,UACV,KAAK,cAAc,KACnB,SAAS;EAoBX,0BAAgC"}
|
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseErrorRootCause.d.ts","names":[],"sources":["../../../../src/errors/utils/baseErrorRootCause.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"baseErrorRootCause.d.ts","names":[],"sources":["../../../../src/errors/utils/baseErrorRootCause.ts"],"mappings":";;cAGa,wBAAyB,GAAG,UAAQ;cAQpC,+BAAgC,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootCause.d.ts","names":[],"sources":["../../../../src/errors/utils/rootCause.ts"],"mappings":";cAAa,
|
|
1
|
+
{"version":3,"file":"rootCause.d.ts","names":[],"sources":["../../../../src/errors/utils/rootCause.ts"],"mappings":";cAAa,eAAgB,GAAG,sBAAoB"}
|
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";
|
|
2
|
-
|
|
1
|
+
import { Action, GetStatusRequest, LiFiStep, QuoteRequest as QuoteRequest$1, RoutesRequest as RoutesRequest$1, SignedLiFiStep } from "@lifi/types";
|
|
3
2
|
//#region src/types/actions.d.ts
|
|
4
3
|
type GetStatusRequestExtended = GetStatusRequest & {
|
|
5
4
|
fromAddress?: string;
|
|
6
5
|
};
|
|
6
|
+
/**
|
|
7
|
+
* Optional limit-order fields. Supplying them opts a request into limit-order
|
|
8
|
+
* handling; resolution happens on the backend.
|
|
9
|
+
*/
|
|
10
|
+
type OrderFields = {
|
|
11
|
+
toAmount?: string;
|
|
12
|
+
validUntil?: number;
|
|
13
|
+
partiallyFillable?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type RoutesRequest = Omit<RoutesRequest$1, "options"> & OrderFields & {
|
|
16
|
+
options?: RoutesRequest$1["options"] & {
|
|
17
|
+
/** (default: false) Whether to request private routes */
|
|
18
|
+
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,2BAA2B;EACrC;;;;;;KAOG;EACH;EACA;EACA;;KAGU,gBAAgB,KAAK,8BAC/B;EACE,UAAU;;IAER;;;;;;KAOM,mBAAmB,WAAW;EACxC,QAAQ,SAAS;;KAGP,yBAAyB;KAEzB,uBAAuB,KAAK;EACtC;;KAGU,eAAe,yBAAyB"}
|
package/dist/esm/types/core.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SDKStorage } from "../core/storage.js";
|
|
2
2
|
import { ExtendedRequestInit } from "./request.js";
|
|
3
3
|
import { ChainId, ChainType, CoinKey, ContractCall, ExtendedChain, FeeCost, GasCost, LiFiStep, Route, RouteOptions, Step, Substatus, Token, TokenAmount } from "@lifi/types";
|
|
4
|
-
|
|
5
4
|
//#region src/types/core.d.ts
|
|
6
5
|
type RequestInterceptor = (request: ExtendedRequestInit) => ExtendedRequestInit | Promise<ExtendedRequestInit>;
|
|
7
6
|
interface SDKBaseConfig {
|
|
@@ -53,9 +52,9 @@ interface InteractionSettings {
|
|
|
53
52
|
allowExecution?: boolean;
|
|
54
53
|
}
|
|
55
54
|
/**
|
|
56
|
-
* Params passed when retrying executeStep after an ExecuteStepRetryError.
|
|
57
|
-
* Providers can use this to pass strategy-specific retry options (e.g. atomicityNotReady for Ethereum 7702).
|
|
58
|
-
*/
|
|
55
|
+
* Params passed when retrying executeStep after an ExecuteStepRetryError.
|
|
56
|
+
* Providers can use this to pass strategy-specific retry options (e.g. atomicityNotReady for Ethereum 7702).
|
|
57
|
+
*/
|
|
59
58
|
type ExecuteStepRetryParams = Record<string, unknown>;
|
|
60
59
|
interface StepExecutor {
|
|
61
60
|
allowUserInteraction: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","names":[],"sources":["../../../src/types/core.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.d.ts","names":[],"sources":["../../../src/types/core.ts"],"mappings":";;;;KAmBY,sBACV,SAAS,wBACN,sBAAsB,QAAQ;UAElB;EACf;EACA;EACA;EACA;EACA,eAAe;EACf,mBAAmB;EACnB,SAAS;EACT;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB,UAAU;;UAGK,kBAAkB,QAAQ,KAAK;EAC9C;EACA,YAAY;;KAGF,UAAU,QAAQ,OAAO;UAEpB;WACN,MAAM;EACf,UAAU;EACV,eACE,cACA,QAAQ,WACR,UAAU,SACV,QAAQ,UACP;EACH,gBAAgB,SAAS,sBAAsB,QAAQ;EACvD,WACE,QAAQ,WACR,uBACA,QAAQ,UACP,QAAQ;;UAGI;EACf,QAAQ;EACR,WAAW;EACX,YAAY,MAAM,YAAY;EAC9B,aAAa,WAAW;EACxB,UAAU,QAAQ;EAClB,aAAa,QAAQ;EACrB,aAAa,SAAS,UAAU,QAAQ;EACxC,cAAc,QAAQ;EACtB,oBAAoB,SAAS,UAAU;;UAGxB;EACf;EACA,mBAAmB;;UAGJ;EACf;EACA;EACA;;;;;;KAOU,yBAAyB;UAEpB;EACf;EACA;EACA,eAAe,WAAW;EAC1B,YACE,QAAQ,WACR,MAAM,kBACN,cAAc,yBACb,QAAQ;;UAGI;EACf,OAAO;EACP,WAAW;EACX,mBAAmB;;KAGT,+BAA+B,QACzC,eAAe;UAGA,sBAAsB,KAAK;EAC1C,OAAO;;UAGQ,yBAAyB;EACxC,YAAY;;KAGF,eAAe;EACzB,YAAY;;KAGF;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,2BAA2B,QAAQ,eAAe,QAAQ;KAE1D,mBAAmB,cAAc;UAE5B,qCAAqC;EACpD;;KAGU,gCACV,kBAAkB,iCACf,QAAQ;UAEI;EACf,SAAS;EACT;EACA;EACA;EACA;;KAGU,4BACV,QAAQ,mCACL;UAEY;EACf,SAAS;EACT;EACA;;KAGU,gCACV,QAAQ,6BACL;UAEY;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf,eAAe;EACf;EACA,eAAe;;KAGL,wBACV,QAAQ,uBACL,QAAQ;UAEI;EACf,+BAA+B;EAC/B,kBAAkB;EAClB,+BAA+B;EAC/B,mBAAmB;EACnB;EACA;;KAGU;KAEA;KAUA;KAUA;EACV,MAAM;EACN,QAAQ;EACR;EACA,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EAEA;IAAU;IAAuB;IAAiB;;;UAGnC;EACf;EACA;EACA,QAAQ;EACR,SAAS,MAAM;EACf;EACA;EACA,UAAU;EACV,WAAW;EACX,WAAW;EACX;EACA;EAEA;IAAU;IAAuB;IAAiB;;;KAGxC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ExecuteStepRetryParams, ExecutionOptions, LiFiStepExtended, SDKClient } from "./core.js";
|
|
2
2
|
import { StatusManager } from "../core/StatusManager.js";
|
|
3
3
|
import { ExtendedChain } from "@lifi/types";
|
|
4
|
-
|
|
5
4
|
//#region src/types/execution.d.ts
|
|
6
5
|
interface StepExecutorBaseContext {
|
|
7
6
|
statusManager: StatusManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","names":[],"sources":["../../../src/types/execution.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"execution.d.ts","names":[],"sources":["../../../src/types/execution.ts"],"mappings":";;;;UASiB;EACf,eAAe;EACf,mBAAmB;EACnB,WAAW;EACX,SAAS;EACT;EACA,QAAQ;EACR,MAAM;EACN;EACA,cAAc;;UAGC,4BAA4B;EAC3C;;UAGe,WAAW,WAAW;EACrC,QAAQ;;EAER,UAAU;;KAGA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","names":[],"sources":["../../../src/types/request.ts"],"mappings":";UAAiB,
|
|
1
|
+
{"version":3,"file":"request.d.ts","names":[],"sources":["../../../src/types/request.ts"],"mappings":";UAAiB,4BAA4B;EAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkPackageUpdates.d.ts","names":[],"sources":["../../../src/utils/checkPackageUpdates.ts"],"mappings":";cAEa,
|
|
1
|
+
{"version":3,"file":"checkPackageUpdates.d.ts","names":[],"sources":["../../../src/utils/checkPackageUpdates.ts"],"mappings":";cAEa,sBACX,sBACA,4BACC"}
|
|
@@ -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.2.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,21 +1,20 @@
|
|
|
1
1
|
import { LiFiStep, Route } from "@lifi/types";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/convertQuoteToRoute.d.ts
|
|
4
3
|
interface ConvertQuoteToRouteOptions {
|
|
5
4
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
* When true, if the quote has zero output values (toAmount, toAmountMin, toAmountUSD),
|
|
6
|
+
* use the values from the previous included step that has non-zero output.
|
|
7
|
+
*/
|
|
9
8
|
adjustZeroOutputFromPreviousStep?: boolean;
|
|
10
9
|
}
|
|
11
10
|
declare function formatTokenPrice(amount?: string | bigint, price?: string, decimals?: number): number;
|
|
12
11
|
/**
|
|
13
|
-
* Converts a quote to Route
|
|
14
|
-
* @param quote - Step returned from the quote endpoint.
|
|
15
|
-
* @param options - Optional configuration for handling edge cases.
|
|
16
|
-
* @returns - The route to be executed.
|
|
17
|
-
* @throws {BaseError} Throws a ValidationError if the step has missing values.
|
|
18
|
-
*/
|
|
12
|
+
* Converts a quote to Route
|
|
13
|
+
* @param quote - Step returned from the quote endpoint.
|
|
14
|
+
* @param options - Optional configuration for handling edge cases.
|
|
15
|
+
* @returns - The route to be executed.
|
|
16
|
+
* @throws {BaseError} Throws a ValidationError if the step has missing values.
|
|
17
|
+
*/
|
|
19
18
|
declare const convertQuoteToRoute: (quote: LiFiStep, options?: ConvertQuoteToRouteOptions) => Route;
|
|
20
19
|
//#endregion
|
|
21
20
|
export { convertQuoteToRoute, formatTokenPrice };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertQuoteToRoute.d.ts","names":[],"sources":["../../../src/utils/convertQuoteToRoute.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"convertQuoteToRoute.d.ts","names":[],"sources":["../../../src/utils/convertQuoteToRoute.ts"],"mappings":";;UAKU;;;;;EAKR;;iBAoDc,iBACd,0BACA,gBACA;;;;;;;;cAwBW,sBACX,OAAO,UACP,UAAU,+BACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.d.ts","names":[],"sources":["../../../src/utils/decode.ts"],"mappings":";cAAa,
|
|
1
|
+
{"version":3,"file":"decode.d.ts","names":[],"sources":["../../../src/utils/decode.ts"],"mappings":";cAAa,eAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchTxErrorDetails.d.ts","names":[],"sources":["../../../src/utils/fetchTxErrorDetails.ts"],"mappings":";cAAa,
|
|
1
|
+
{"version":3,"file":"fetchTxErrorDetails.d.ts","names":[],"sources":["../../../src/utils/fetchTxErrorDetails.ts"],"mappings":";cAAa,sBACX,gBACA,oBACC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/utils/formatUnits.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Divides a number by a given exponent of base 10 (10exponent), and formats it into a string representation of the number.
|
|
4
|
-
*/
|
|
3
|
+
* Divides a number by a given exponent of base 10 (10exponent), and formats it into a string representation of the number.
|
|
4
|
+
*/
|
|
5
5
|
declare function formatUnits(value: bigint, decimals: number): string;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { formatUnits };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatUnits.d.ts","names":[],"sources":["../../../src/utils/formatUnits.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatUnits.d.ts","names":[],"sources":["../../../src/utils/formatUnits.ts"],"mappings":";;;;iBAGgB,YAAY,eAAe"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SDKClient } from "../types/core.js";
|
|
2
2
|
import { LiFiStep } from "@lifi/types";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/getTransactionMessage.d.ts
|
|
5
4
|
declare const getTransactionFailedMessage: (client: SDKClient, step: LiFiStep, txLink?: string) => Promise<string>;
|
|
6
5
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactionMessage.d.ts","names":[],"sources":["../../../src/utils/getTransactionMessage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getTransactionMessage.d.ts","names":[],"sources":["../../../src/utils/getTransactionMessage.ts"],"mappings":";;;cAGa,8BACX,QAAQ,WACR,MAAM,UACN,oBACC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isHex.d.ts","names":[],"sources":["../../../src/utils/isHex.ts"],"mappings":";KAAY
|
|
1
|
+
{"version":3,"file":"isHex.d.ts","names":[],"sources":["../../../src/utils/isHex.ts"],"mappings":";KAAY;iBAEI,MACd,kBACE;EAAmB;IACpB,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isRoutesRequest.d.ts","names":[],"sources":["../../../src/utils/isRoutesRequest.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isRoutesRequest.d.ts","names":[],"sources":["../../../src/utils/isRoutesRequest.ts"],"mappings":";;cAOa,kBACX,eAAe,kBACd,iBAAiB"}
|
|
@@ -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,SAAU,MAAM,aAAW,QAAQ"}
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isToken.d.ts","names":[],"sources":["../../../src/utils/isToken.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isToken.d.ts","names":[],"sources":["../../../src/utils/isToken.ts"],"mappings":";;cAEa,UAAW,OAAO,gBAAc,SAAS"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/utils/parseUnits.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Multiplies a string representation of a number by a given exponent of base 10 (10exponent).
|
|
4
|
-
*/
|
|
3
|
+
* Multiplies a string representation of a number by a given exponent of base 10 (10exponent).
|
|
4
|
+
*/
|
|
5
5
|
declare function parseUnits(value: string, decimals: number): bigint;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { parseUnits };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseUnits.d.ts","names":[],"sources":["../../../src/utils/parseUnits.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parseUnits.d.ts","names":[],"sources":["../../../src/utils/parseUnits.ts"],"mappings":";;;;iBAGgB,WAAW,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","names":[],"sources":["../../../src/utils/request.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.d.ts","names":[],"sources":["../../../src/utils/request.ts"],"mappings":";;;cAQa;EACX;;cAUW,UAAiB,IAAI,UAChC,QAAQ,eACR,KAAK,cAAc,KACnB,UAAS,wBAGR,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.d.ts","names":[],"sources":["../../../src/utils/sleep.ts"],"mappings":";iBAAgB,
|
|
1
|
+
{"version":3,"file":"sleep.d.ts","names":[],"sources":["../../../src/utils/sleep.ts"],"mappings":";iBAAgB,MAAM,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toQueryString.d.ts","names":[],"sources":["../../../src/utils/toQueryString.ts"],"mappings":";cA+Ba,gBAAiB,QAAQ"}
|
|
@@ -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"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//#region src/utils/waitForResult.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Repeatedly calls a given asynchronous function until it resolves with a value
|
|
4
|
-
* @param fn The function that should be repeated
|
|
5
|
-
* @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000
|
|
6
|
-
* @param maxRetries Maximum number of retries before throwing an error, defaults to 3
|
|
7
|
-
* @param shouldRetry Optional predicate to determine if an error should trigger a retry
|
|
8
|
-
* @returns The result of the fn function
|
|
9
|
-
* @throws Error if maximum retries is reached, if function keeps returning undefined, or if shouldRetry returns false
|
|
10
|
-
*/
|
|
3
|
+
* Repeatedly calls a given asynchronous function until it resolves with a value
|
|
4
|
+
* @param fn The function that should be repeated
|
|
5
|
+
* @param interval The timeout in milliseconds between retries, or a function that receives the current poll count and returns the interval. Defaults to 5000
|
|
6
|
+
* @param maxRetries Maximum number of retries before throwing an error, defaults to 3
|
|
7
|
+
* @param shouldRetry Optional predicate to determine if an error should trigger a retry
|
|
8
|
+
* @returns The result of the fn function
|
|
9
|
+
* @throws Error if maximum retries is reached, if function keeps returning undefined, or if shouldRetry returns false
|
|
10
|
+
*/
|
|
11
11
|
declare const waitForResult: <T>(fn: () => Promise<T | undefined>, interval?: number | ((poll: number) => number), maxRetries?: number, shouldRetry?: (count: number, error: unknown) => boolean) => Promise<T>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { waitForResult };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForResult.d.ts","names":[],"sources":["../../../src/utils/waitForResult.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"waitForResult.d.ts","names":[],"sources":["../../../src/utils/waitForResult.ts"],"mappings":";;;;;;;;;;cAWa,gBAAuB,GAClC,UAAU,QAAQ,gBAClB,sBAAqB,0BACrB,qBACA,eAAc,eAAe,+BAC5B,QAAQ"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/utils/withDedupe.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Map with a LRU (Least recently used) policy.
|
|
4
|
-
*
|
|
5
|
-
* https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
|
|
6
|
-
*/
|
|
3
|
+
* Map with a LRU (Least recently used) policy.
|
|
4
|
+
*
|
|
5
|
+
* https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
|
|
6
|
+
*/
|
|
7
7
|
declare class LruMap<value = unknown> extends Map<string, value> {
|
|
8
8
|
maxSize: number;
|
|
9
9
|
constructor(size: number);
|
|
@@ -14,10 +14,7 @@ type WithDedupeOptions = {
|
|
|
14
14
|
id?: string | undefined;
|
|
15
15
|
};
|
|
16
16
|
/** Deduplicates in-flight promises. */
|
|
17
|
-
declare function withDedupe<T>(fn: () => Promise<T>, {
|
|
18
|
-
enabled,
|
|
19
|
-
id
|
|
20
|
-
}: WithDedupeOptions): Promise<T>;
|
|
17
|
+
declare function withDedupe<T>(fn: () => Promise<T>, { enabled, id }: WithDedupeOptions): Promise<T>;
|
|
21
18
|
//#endregion
|
|
22
19
|
export { LruMap, withDedupe };
|
|
23
20
|
//# sourceMappingURL=withDedupe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withDedupe.d.ts","names":[],"sources":["../../../src/utils/withDedupe.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"withDedupe.d.ts","names":[],"sources":["../../../src/utils/withDedupe.ts"],"mappings":";;;;;;cAKa,OAAO,yBAAyB,YAAY;EACvD;EAEA,YAAY;WAKH,IAAI,aAAa,OAAO;;KAY9B;EACH;EACA;;;iBAIc,WAAW,GACzB,UAAU,QAAQ,MAChB,SAAgB,MAAM,oBACvB,QAAQ"}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
//#region src/utils/withTimeout.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Wraps a function in a timeout.
|
|
4
|
-
* Based on viem's withTimeout implementation.
|
|
5
|
-
* @param fn - The function to wrap.
|
|
6
|
-
* @param timeout - The timeout in milliseconds.
|
|
7
|
-
* @param errorInstance - The error instance to throw when the timeout is reached.
|
|
8
|
-
* @param signal - Whether or not the timeout should use an abort signal.
|
|
9
|
-
* @returns The result of the function.
|
|
10
|
-
*/
|
|
11
|
-
declare function withTimeout<T>(fn: ({
|
|
12
|
-
signal
|
|
13
|
-
}: {
|
|
3
|
+
* Wraps a function in a timeout.
|
|
4
|
+
* Based on viem's withTimeout implementation.
|
|
5
|
+
* @param fn - The function to wrap.
|
|
6
|
+
* @param timeout - The timeout in milliseconds.
|
|
7
|
+
* @param errorInstance - The error instance to throw when the timeout is reached.
|
|
8
|
+
* @param signal - Whether or not the timeout should use an abort signal.
|
|
9
|
+
* @returns The result of the function.
|
|
10
|
+
*/
|
|
11
|
+
declare function withTimeout<T>(fn: ({ signal }: {
|
|
14
12
|
signal: AbortController["signal"] | null;
|
|
15
|
-
}) => Promise<T>, {
|
|
16
|
-
errorInstance,
|
|
17
|
-
timeout,
|
|
18
|
-
signal
|
|
19
|
-
}: {
|
|
13
|
+
}) => Promise<T>, { errorInstance, timeout, signal }: {
|
|
20
14
|
errorInstance?: Error | undefined;
|
|
21
15
|
timeout: number;
|
|
22
16
|
signal?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTimeout.d.ts","names":[],"sources":["../../../src/utils/withTimeout.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"withTimeout.d.ts","names":[],"sources":["../../../src/utils/withTimeout.ts"],"mappings":";;;;;;;;;;iBASgB,YAAY,GAC1B,OAAO;EAAY,QAAQ;MAAuC,QAAQ,MAExE,eACA,SACA;EAGA,gBAAgB;EAEhB;EAEA;IAED,QAAQ"}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","names":[],"sources":["../../src/version.ts"],"mappings":";cAAa
|
|
1
|
+
{"version":3,"file":"version.d.ts","names":[],"sources":["../../src/version.ts"],"mappings":";cAAa;cACA"}
|