@lifi/sdk 4.0.0-alpha.2 → 4.0.0-alpha.21
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/dist/cjs/actions/getChains.d.ts +1 -1
- package/dist/cjs/actions/getChains.js +4 -4
- package/dist/cjs/actions/getChains.js.map +1 -1
- package/dist/cjs/actions/getRelayedTransactionStatus.js +1 -1
- package/dist/cjs/actions/getRelayedTransactionStatus.js.map +1 -1
- package/dist/cjs/actions/getStepTransaction.js +9 -1
- package/dist/cjs/actions/getStepTransaction.js.map +1 -1
- package/dist/cjs/actions/index.d.ts +3 -1
- package/dist/cjs/actions/index.js +2 -0
- package/dist/cjs/actions/index.js.map +1 -1
- package/dist/cjs/actions/patchContractCalls.d.ts +10 -0
- package/dist/cjs/actions/patchContractCalls.js +16 -0
- package/dist/cjs/actions/patchContractCalls.js.map +1 -0
- package/dist/cjs/client/createClient.js +4 -0
- package/dist/cjs/client/createClient.js.map +1 -1
- package/dist/cjs/client/getClientStorage.d.ts +1 -0
- package/dist/cjs/client/getClientStorage.js +18 -6
- package/dist/cjs/client/getClientStorage.js.map +1 -1
- package/dist/cjs/core/BaseStepExecutionTask.d.ts +5 -0
- package/dist/cjs/core/BaseStepExecutionTask.js +10 -0
- package/dist/cjs/core/BaseStepExecutionTask.js.map +1 -0
- package/dist/cjs/core/BaseStepExecutor.d.ts +10 -3
- package/dist/cjs/core/BaseStepExecutor.js +53 -0
- package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
- package/dist/cjs/core/StatusManager.d.ts +13 -12
- package/dist/cjs/core/StatusManager.js +55 -61
- package/dist/cjs/core/StatusManager.js.map +1 -1
- package/dist/cjs/core/TaskPipeline.d.ts +7 -0
- package/dist/cjs/core/TaskPipeline.js +27 -0
- package/dist/cjs/core/TaskPipeline.js.map +1 -0
- package/dist/cjs/core/actionMessages.d.ts +4 -0
- package/dist/cjs/core/{processMessages.js → actionMessages.js} +25 -9
- package/dist/cjs/core/actionMessages.js.map +1 -0
- package/dist/cjs/core/execution.js +13 -1
- package/dist/cjs/core/execution.js.map +1 -1
- package/dist/cjs/core/prepareRestart.js +6 -6
- package/dist/cjs/core/prepareRestart.js.map +1 -1
- package/dist/cjs/core/storage.d.ts +17 -0
- package/dist/cjs/core/storage.js +36 -0
- package/dist/cjs/core/storage.js.map +1 -0
- package/dist/cjs/core/tasks/CheckBalanceTask.d.ts +5 -0
- package/dist/cjs/core/tasks/CheckBalanceTask.js +26 -0
- package/dist/cjs/core/tasks/CheckBalanceTask.js.map +1 -0
- package/dist/cjs/core/tasks/PrepareTransactionTask.d.ts +5 -0
- package/dist/cjs/core/tasks/PrepareTransactionTask.js +36 -0
- package/dist/cjs/core/tasks/PrepareTransactionTask.js.map +1 -0
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.d.ts +8 -0
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +73 -0
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -0
- package/dist/cjs/core/{checkBalance.d.ts → tasks/helpers/checkBalance.d.ts} +1 -1
- package/dist/cjs/core/{checkBalance.js → tasks/helpers/checkBalance.js} +6 -6
- package/dist/cjs/core/tasks/helpers/checkBalance.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.d.ts +2 -0
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js +30 -0
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js.map +1 -0
- package/dist/cjs/core/{stepComparison.d.ts → tasks/helpers/stepComparison.d.ts} +2 -2
- package/dist/cjs/core/{stepComparison.js → tasks/helpers/stepComparison.js} +3 -3
- package/dist/cjs/core/tasks/helpers/stepComparison.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.d.ts +4 -0
- package/dist/cjs/core/{waitForTransactionStatus.js → tasks/helpers/waitForTransactionStatus.js} +10 -8
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
- package/dist/cjs/core/utils.d.ts +9 -3
- package/dist/cjs/core/utils.js +0 -5
- package/dist/cjs/core/utils.js.map +1 -1
- package/dist/cjs/errors/SDKError.d.ts +3 -3
- package/dist/cjs/errors/SDKError.js +3 -3
- package/dist/cjs/errors/SDKError.js.map +1 -1
- package/dist/cjs/errors/constants.d.ts +5 -2
- package/dist/cjs/errors/constants.js +3 -0
- package/dist/cjs/errors/constants.js.map +1 -1
- package/dist/cjs/errors/errors.d.ts +5 -0
- package/dist/cjs/errors/errors.js +9 -1
- package/dist/cjs/errors/errors.js.map +1 -1
- package/dist/cjs/index.d.ts +20 -10
- package/dist/cjs/index.js +34 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/core.d.ts +51 -21
- package/dist/cjs/types/execution.d.ts +22 -0
- package/dist/cjs/types/execution.js +3 -0
- package/dist/cjs/types/execution.js.map +1 -0
- package/dist/cjs/utils/convertQuoteToRoute.d.ts +6 -1
- package/dist/cjs/utils/convertQuoteToRoute.js +73 -5
- package/dist/cjs/utils/convertQuoteToRoute.js.map +1 -1
- package/dist/cjs/utils/formatUnits.d.ts +1 -0
- package/dist/cjs/utils/formatUnits.js +18 -0
- package/dist/cjs/utils/formatUnits.js.map +1 -0
- package/dist/cjs/utils/isHex.d.ts +4 -0
- package/dist/cjs/utils/isHex.js +13 -0
- package/dist/cjs/utils/isHex.js.map +1 -0
- package/dist/cjs/utils/parseUnits.d.ts +1 -0
- package/dist/cjs/utils/parseUnits.js +44 -0
- package/dist/cjs/utils/parseUnits.js.map +1 -0
- package/dist/cjs/utils/request.js +7 -6
- package/dist/cjs/utils/request.js.map +1 -1
- package/dist/cjs/utils/waitForResult.d.ts +1 -1
- package/dist/cjs/utils/waitForResult.js +6 -2
- package/dist/cjs/utils/waitForResult.js.map +1 -1
- package/dist/cjs/utils/withDedupe.d.ts +5 -0
- package/dist/cjs/utils/withDedupe.js +2 -0
- package/dist/cjs/utils/withDedupe.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/actions/getChains.d.ts +1 -1
- package/dist/esm/actions/getChains.js +2 -2
- package/dist/esm/actions/getChains.js.map +1 -1
- package/dist/esm/actions/getRelayedTransactionStatus.js +1 -1
- package/dist/esm/actions/getRelayedTransactionStatus.js.map +1 -1
- package/dist/esm/actions/getStepTransaction.js +10 -1
- package/dist/esm/actions/getStepTransaction.js.map +1 -1
- package/dist/esm/actions/index.d.ts +9 -1
- package/dist/esm/actions/index.js +2 -0
- package/dist/esm/actions/index.js.map +1 -1
- package/dist/esm/actions/patchContractCalls.d.ts +10 -0
- package/dist/esm/actions/patchContractCalls.js +12 -0
- package/dist/esm/actions/patchContractCalls.js.map +1 -0
- package/dist/esm/client/createClient.js +4 -0
- package/dist/esm/client/createClient.js.map +1 -1
- package/dist/esm/client/getClientStorage.d.ts +1 -0
- package/dist/esm/client/getClientStorage.js +22 -7
- package/dist/esm/client/getClientStorage.js.map +1 -1
- package/dist/esm/core/BaseStepExecutionTask.d.ts +5 -0
- package/dist/esm/core/BaseStepExecutionTask.js +6 -0
- package/dist/esm/core/BaseStepExecutionTask.js.map +1 -0
- package/dist/esm/core/BaseStepExecutor.d.ts +10 -3
- package/dist/esm/core/BaseStepExecutor.js +53 -0
- package/dist/esm/core/BaseStepExecutor.js.map +1 -1
- package/dist/esm/core/StatusManager.d.ts +40 -39
- package/dist/esm/core/StatusManager.js +86 -92
- package/dist/esm/core/StatusManager.js.map +1 -1
- package/dist/esm/core/TaskPipeline.d.ts +7 -0
- package/dist/esm/core/TaskPipeline.js +23 -0
- package/dist/esm/core/TaskPipeline.js.map +1 -0
- package/dist/esm/core/actionMessages.d.ts +4 -0
- package/dist/esm/core/{processMessages.js → actionMessages.js} +24 -8
- package/dist/esm/core/actionMessages.js.map +1 -0
- package/dist/esm/core/execution.js +14 -3
- package/dist/esm/core/execution.js.map +1 -1
- package/dist/esm/core/prepareRestart.js +10 -9
- package/dist/esm/core/prepareRestart.js.map +1 -1
- package/dist/esm/core/storage.d.ts +17 -0
- package/dist/esm/core/storage.js +30 -0
- package/dist/esm/core/storage.js.map +1 -0
- package/dist/esm/core/tasks/CheckBalanceTask.d.ts +5 -0
- package/dist/esm/core/tasks/CheckBalanceTask.js +22 -0
- package/dist/esm/core/tasks/CheckBalanceTask.js.map +1 -0
- package/dist/esm/core/tasks/PrepareTransactionTask.d.ts +5 -0
- package/dist/esm/core/tasks/PrepareTransactionTask.js +32 -0
- package/dist/esm/core/tasks/PrepareTransactionTask.js.map +1 -0
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts +8 -0
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +74 -0
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -0
- package/dist/esm/core/{checkBalance.d.ts → tasks/helpers/checkBalance.d.ts} +1 -1
- package/dist/esm/core/{checkBalance.js → tasks/helpers/checkBalance.js} +4 -4
- package/dist/esm/core/tasks/helpers/checkBalance.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts +2 -0
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.js +26 -0
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.js.map +1 -0
- package/dist/esm/core/{stepComparison.d.ts → tasks/helpers/stepComparison.d.ts} +2 -2
- package/dist/esm/core/{stepComparison.js → tasks/helpers/stepComparison.js} +3 -3
- package/dist/esm/core/tasks/helpers/stepComparison.js.map +1 -0
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts +4 -0
- package/dist/esm/core/{waitForTransactionStatus.js → tasks/helpers/waitForTransactionStatus.js} +9 -7
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
- package/dist/esm/core/utils.d.ts +9 -11
- package/dist/esm/core/utils.js +0 -11
- package/dist/esm/core/utils.js.map +1 -1
- package/dist/esm/errors/SDKError.d.ts +3 -3
- package/dist/esm/errors/SDKError.js +4 -4
- package/dist/esm/errors/SDKError.js.map +1 -1
- package/dist/esm/errors/constants.d.ts +5 -2
- package/dist/esm/errors/constants.js +3 -0
- package/dist/esm/errors/constants.js.map +1 -1
- package/dist/esm/errors/errors.d.ts +10 -0
- package/dist/esm/errors/errors.js +12 -0
- package/dist/esm/errors/errors.js.map +1 -1
- package/dist/esm/index.d.ts +20 -10
- package/dist/esm/index.js +17 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core.d.ts +55 -21
- package/dist/esm/types/execution.d.ts +23 -0
- package/dist/esm/types/execution.js +2 -0
- package/dist/esm/types/execution.js.map +1 -0
- package/dist/esm/utils/convertQuoteToRoute.d.ts +11 -3
- package/dist/esm/utils/convertQuoteToRoute.js +76 -7
- package/dist/esm/utils/convertQuoteToRoute.js.map +1 -1
- package/dist/esm/utils/formatUnits.d.ts +4 -0
- package/dist/esm/utils/formatUnits.js +18 -0
- package/dist/esm/utils/formatUnits.js.map +1 -0
- package/dist/esm/utils/isHex.d.ts +4 -0
- package/dist/esm/utils/isHex.js +10 -0
- package/dist/esm/utils/isHex.js.map +1 -0
- package/dist/esm/utils/parseUnits.d.ts +4 -0
- package/dist/esm/utils/parseUnits.js +46 -0
- package/dist/esm/utils/parseUnits.js.map +1 -0
- package/dist/esm/utils/request.js +7 -6
- package/dist/esm/utils/request.js.map +1 -1
- package/dist/esm/utils/waitForResult.d.ts +2 -2
- package/dist/esm/utils/waitForResult.js +7 -3
- package/dist/esm/utils/waitForResult.js.map +1 -1
- package/dist/esm/utils/withDedupe.d.ts +10 -0
- package/dist/esm/utils/withDedupe.js +1 -1
- package/dist/esm/utils/withDedupe.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/actions/getChains.d.ts +1 -1
- package/dist/types/actions/getChains.d.ts.map +1 -1
- package/dist/types/actions/getStepTransaction.d.ts.map +1 -1
- package/dist/types/actions/index.d.ts +9 -1
- package/dist/types/actions/index.d.ts.map +1 -1
- package/dist/types/actions/patchContractCalls.d.ts +11 -0
- package/dist/types/actions/patchContractCalls.d.ts.map +1 -0
- package/dist/types/client/createClient.d.ts.map +1 -1
- package/dist/types/client/getClientStorage.d.ts +1 -0
- package/dist/types/client/getClientStorage.d.ts.map +1 -1
- package/dist/types/core/BaseStepExecutionTask.d.ts +6 -0
- package/dist/types/core/BaseStepExecutionTask.d.ts.map +1 -0
- package/dist/types/core/BaseStepExecutor.d.ts +10 -3
- package/dist/types/core/BaseStepExecutor.d.ts.map +1 -1
- package/dist/types/core/StatusManager.d.ts +40 -39
- package/dist/types/core/StatusManager.d.ts.map +1 -1
- package/dist/types/core/TaskPipeline.d.ts +8 -0
- package/dist/types/core/TaskPipeline.d.ts.map +1 -0
- package/dist/types/core/actionMessages.d.ts +5 -0
- package/dist/types/core/actionMessages.d.ts.map +1 -0
- package/dist/types/core/execution.d.ts.map +1 -1
- package/dist/types/core/prepareRestart.d.ts.map +1 -1
- package/dist/types/core/storage.d.ts +18 -0
- package/dist/types/core/storage.d.ts.map +1 -0
- package/dist/types/core/tasks/CheckBalanceTask.d.ts +6 -0
- package/dist/types/core/tasks/CheckBalanceTask.d.ts.map +1 -0
- package/dist/types/core/tasks/PrepareTransactionTask.d.ts +6 -0
- package/dist/types/core/tasks/PrepareTransactionTask.d.ts.map +1 -0
- package/dist/types/core/tasks/WaitForTransactionStatusTask.d.ts +9 -0
- package/dist/types/core/tasks/WaitForTransactionStatusTask.d.ts.map +1 -0
- package/dist/types/core/{checkBalance.d.ts → tasks/helpers/checkBalance.d.ts} +1 -1
- package/dist/types/core/tasks/helpers/checkBalance.d.ts.map +1 -0
- package/dist/types/core/tasks/helpers/getTransactionRequestData.d.ts +3 -0
- package/dist/types/core/tasks/helpers/getTransactionRequestData.d.ts.map +1 -0
- package/dist/types/core/{stepComparison.d.ts → tasks/helpers/stepComparison.d.ts} +2 -2
- package/dist/types/core/tasks/helpers/stepComparison.d.ts.map +1 -0
- package/dist/types/core/tasks/helpers/waitForTransactionStatus.d.ts +5 -0
- package/dist/types/core/tasks/helpers/waitForTransactionStatus.d.ts.map +1 -0
- package/dist/types/core/utils.d.ts +9 -11
- package/dist/types/core/utils.d.ts.map +1 -1
- package/dist/types/errors/SDKError.d.ts +3 -3
- package/dist/types/errors/SDKError.d.ts.map +1 -1
- package/dist/types/errors/constants.d.ts +5 -2
- package/dist/types/errors/constants.d.ts.map +1 -1
- package/dist/types/errors/errors.d.ts +10 -0
- package/dist/types/errors/errors.d.ts.map +1 -1
- package/dist/types/index.d.ts +20 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/core.d.ts +55 -21
- package/dist/types/types/core.d.ts.map +1 -1
- package/dist/types/types/execution.d.ts +24 -0
- package/dist/types/types/execution.d.ts.map +1 -0
- package/dist/types/utils/convertQuoteToRoute.d.ts +11 -3
- package/dist/types/utils/convertQuoteToRoute.d.ts.map +1 -1
- package/dist/types/utils/formatUnits.d.ts +5 -0
- package/dist/types/utils/formatUnits.d.ts.map +1 -0
- package/dist/types/utils/isHex.d.ts +5 -0
- package/dist/types/utils/isHex.d.ts.map +1 -0
- package/dist/types/utils/parseUnits.d.ts +5 -0
- package/dist/types/utils/parseUnits.d.ts.map +1 -0
- package/dist/types/utils/request.d.ts.map +1 -1
- package/dist/types/utils/waitForResult.d.ts +2 -2
- package/dist/types/utils/waitForResult.d.ts.map +1 -1
- package/dist/types/utils/withDedupe.d.ts +10 -0
- package/dist/types/utils/withDedupe.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/actions/getChains.ts +2 -2
- package/src/actions/getRelayedTransactionStatus.ts +1 -1
- package/src/actions/getStepTransaction.ts +20 -12
- package/src/actions/index.ts +18 -0
- package/src/actions/patchContractCalls.ts +30 -0
- package/src/client/createClient.ts +5 -1
- package/src/client/getClientStorage.ts +25 -7
- package/src/core/BaseStepExecutionTask.ts +9 -0
- package/src/core/BaseStepExecutor.ts +91 -2
- package/src/core/StatusManager.ts +108 -113
- package/src/core/TaskPipeline.ts +28 -0
- package/src/core/{processMessages.ts → actionMessages.ts} +32 -12
- package/src/core/execution.ts +17 -3
- package/src/core/prepareRestart.ts +12 -11
- package/src/core/storage.ts +42 -0
- package/src/core/tasks/CheckBalanceTask.ts +29 -0
- package/src/core/tasks/PrepareTransactionTask.ts +62 -0
- package/src/core/tasks/WaitForTransactionStatusTask.ts +114 -0
- package/src/core/{checkBalance.ts → tasks/helpers/checkBalance.ts} +5 -5
- package/src/core/tasks/helpers/getTransactionRequestData.ts +47 -0
- package/src/core/{stepComparison.ts → tasks/helpers/stepComparison.ts} +5 -5
- package/src/core/{waitForTransactionStatus.ts → tasks/helpers/waitForTransactionStatus.ts} +11 -9
- package/src/core/utils.ts +1 -13
- package/src/errors/SDKError.ts +5 -5
- package/src/errors/constants.ts +3 -0
- package/src/errors/errors.ts +24 -0
- package/src/index.ts +37 -12
- package/src/types/core.ts +69 -29
- package/src/types/execution.ts +32 -0
- package/src/utils/convertQuoteToRoute.ts +117 -8
- package/src/utils/formatUnits.ts +22 -0
- package/src/utils/isHex.ts +14 -0
- package/src/utils/parseUnits.ts +50 -0
- package/src/utils/request.ts +9 -6
- package/src/utils/waitForResult.ts +9 -4
- package/src/utils/withDedupe.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/cjs/core/checkBalance.js.map +0 -1
- package/dist/cjs/core/processMessages.d.ts +0 -4
- package/dist/cjs/core/processMessages.js.map +0 -1
- package/dist/cjs/core/stepComparison.js.map +0 -1
- package/dist/cjs/core/waitForDestinationChainTransaction.d.ts +0 -4
- package/dist/cjs/core/waitForDestinationChainTransaction.js +0 -69
- package/dist/cjs/core/waitForDestinationChainTransaction.js.map +0 -1
- package/dist/cjs/core/waitForTransactionStatus.d.ts +0 -4
- package/dist/cjs/core/waitForTransactionStatus.js.map +0 -1
- package/dist/esm/core/checkBalance.js.map +0 -1
- package/dist/esm/core/processMessages.d.ts +0 -4
- package/dist/esm/core/processMessages.js.map +0 -1
- package/dist/esm/core/stepComparison.js.map +0 -1
- package/dist/esm/core/waitForDestinationChainTransaction.d.ts +0 -4
- package/dist/esm/core/waitForDestinationChainTransaction.js +0 -71
- package/dist/esm/core/waitForDestinationChainTransaction.js.map +0 -1
- package/dist/esm/core/waitForTransactionStatus.d.ts +0 -4
- package/dist/esm/core/waitForTransactionStatus.js.map +0 -1
- package/dist/types/core/checkBalance.d.ts.map +0 -1
- package/dist/types/core/processMessages.d.ts +0 -5
- package/dist/types/core/processMessages.d.ts.map +0 -1
- package/dist/types/core/stepComparison.d.ts.map +0 -1
- package/dist/types/core/waitForDestinationChainTransaction.d.ts +0 -5
- package/dist/types/core/waitForDestinationChainTransaction.d.ts.map +0 -1
- package/dist/types/core/waitForTransactionStatus.d.ts +0 -5
- package/dist/types/core/waitForTransactionStatus.d.ts.map +0 -1
- package/src/core/waitForDestinationChainTransaction.ts +0 -106
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { version } from '../version.js';
|
|
2
2
|
// Note: SDKError is used to wrapper and present errors at the top level
|
|
3
|
-
// Where opportunity allows we also add the step and the
|
|
3
|
+
// Where opportunity allows we also add the step and the action related to the error
|
|
4
4
|
export class SDKError extends Error {
|
|
5
5
|
step;
|
|
6
|
-
|
|
6
|
+
action;
|
|
7
7
|
code;
|
|
8
8
|
name = 'SDKError';
|
|
9
9
|
cause;
|
|
10
|
-
constructor(cause, step,
|
|
10
|
+
constructor(cause, step, action) {
|
|
11
11
|
const errorMessage = `${cause.message ? `[${cause.name}] ${cause.message}` : 'Unknown error occurred'}\nLI.FI SDK version: ${version}`;
|
|
12
12
|
super(errorMessage);
|
|
13
13
|
this.name = 'SDKError';
|
|
14
14
|
this.step = step;
|
|
15
|
-
this.
|
|
15
|
+
this.action = action;
|
|
16
16
|
this.cause = cause;
|
|
17
17
|
this.stack = this.cause.stack;
|
|
18
18
|
this.code = cause.code;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SDKError.js","sourceRoot":"","sources":["../../../src/errors/SDKError.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIvC,wEAAwE;AACxE,
|
|
1
|
+
{"version":3,"file":"SDKError.js","sourceRoot":"","sources":["../../../src/errors/SDKError.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIvC,wEAAwE;AACxE,oFAAoF;AACpF,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,IAAI,CAAW;IACf,MAAM,CAAkB;IACxB,IAAI,CAAW;IACN,IAAI,GAAG,UAAU,CAAA;IACjB,KAAK,CAAW;IAEzB,YAAY,KAAgB,EAAE,IAAe,EAAE,MAAwB;QACrE,MAAM,YAAY,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,wBAAwB,wBAAwB,OAAO,EAAE,CAAA;QACtI,KAAK,CAAC,YAAY,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAA;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IACxB,CAAC;CACF"}
|
|
@@ -8,7 +8,9 @@ export declare enum ErrorName {
|
|
|
8
8
|
NotFoundError = "NotFoundError",
|
|
9
9
|
UnknownError = "UnknownError",
|
|
10
10
|
SlippageError = "SlippageError",
|
|
11
|
-
HTTPError = "HTTPError"
|
|
11
|
+
HTTPError = "HTTPError",
|
|
12
|
+
ConfigError = "ConfigError",
|
|
13
|
+
ExecuteStepRetryError = "ExecuteStepRetryError"
|
|
12
14
|
}
|
|
13
15
|
export type ErrorCode = LiFiErrorCode;
|
|
14
16
|
export declare enum LiFiErrorCode {
|
|
@@ -37,7 +39,8 @@ export declare enum LiFiErrorCode {
|
|
|
37
39
|
TransactionRejected = 1022,
|
|
38
40
|
RateLimitExceeded = 1023,
|
|
39
41
|
ThirdPartyError = 1024,
|
|
40
|
-
InsufficientGas = 1025
|
|
42
|
+
InsufficientGas = 1025,
|
|
43
|
+
ConfigError = 1026
|
|
41
44
|
}
|
|
42
45
|
export declare enum ErrorMessage {
|
|
43
46
|
UnknownError = "Unknown error occurred.",
|
|
@@ -10,6 +10,8 @@ export var ErrorName;
|
|
|
10
10
|
ErrorName["UnknownError"] = "UnknownError";
|
|
11
11
|
ErrorName["SlippageError"] = "SlippageError";
|
|
12
12
|
ErrorName["HTTPError"] = "HTTPError";
|
|
13
|
+
ErrorName["ConfigError"] = "ConfigError";
|
|
14
|
+
ErrorName["ExecuteStepRetryError"] = "ExecuteStepRetryError";
|
|
13
15
|
})(ErrorName || (ErrorName = {}));
|
|
14
16
|
export var LiFiErrorCode;
|
|
15
17
|
(function (LiFiErrorCode) {
|
|
@@ -39,6 +41,7 @@ export var LiFiErrorCode;
|
|
|
39
41
|
LiFiErrorCode[LiFiErrorCode["RateLimitExceeded"] = 1023] = "RateLimitExceeded";
|
|
40
42
|
LiFiErrorCode[LiFiErrorCode["ThirdPartyError"] = 1024] = "ThirdPartyError";
|
|
41
43
|
LiFiErrorCode[LiFiErrorCode["InsufficientGas"] = 1025] = "InsufficientGas";
|
|
44
|
+
LiFiErrorCode[LiFiErrorCode["ConfigError"] = 1026] = "ConfigError";
|
|
42
45
|
})(LiFiErrorCode || (LiFiErrorCode = {}));
|
|
43
46
|
export var ErrorMessage;
|
|
44
47
|
(function (ErrorMessage) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/errors/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/errors/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,SAaX;AAbD,WAAY,SAAS;IACnB,kCAAqB,CAAA;IACrB,4CAA+B,CAAA;IAC/B,wCAA2B,CAAA;IAC3B,kDAAqC,CAAA;IACrC,gDAAmC,CAAA;IACnC,0CAA6B,CAAA;IAC7B,4CAA+B,CAAA;IAC/B,0CAA6B,CAAA;IAC7B,4CAA+B,CAAA;IAC/B,oCAAuB,CAAA;IACvB,wCAA2B,CAAA;IAC3B,4DAA+C,CAAA;AACjD,CAAC,EAbW,SAAS,KAAT,SAAS,QAapB;AAID,MAAM,CAAN,IAAY,aA4BX;AA5BD,WAAY,aAAa;IACvB,sEAAoB,CAAA;IACpB,0EAAsB,CAAA;IACtB,wFAA6B,CAAA;IAC7B,8EAAwB,CAAA;IACxB,0DAAc,CAAA;IACd,kFAA0B,CAAA;IAC1B,4DAAe,CAAA;IACf,4EAAuB,CAAA;IACvB,sFAA4B,CAAA;IAC5B,sEAAoB,CAAA;IACpB,kFAA0B,CAAA;IAC1B,sEAAoB,CAAA;IACpB,8EAAwB,CAAA;IACxB,oEAAmB,CAAA;IACnB,8EAAwB,CAAA;IACxB,8EAAwB,CAAA;IACxB,gGAAiC,CAAA;IACjC,oGAAmC,CAAA;IACnC,gFAAyB,CAAA;IACzB,kGAAkC,CAAA;IAClC,kFAA0B,CAAA;IAC1B,kFAA0B,CAAA;IAC1B,kFAA0B,CAAA;IAC1B,8EAAwB,CAAA;IACxB,0EAAsB,CAAA;IACtB,0EAAsB,CAAA;IACtB,kEAAkB,CAAA;AACpB,CAAC,EA5BW,aAAa,KAAb,aAAa,QA4BxB;AAED,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,wDAAwC,CAAA;IACxC,qIAAqH,CAAA;IACrH,qDAAqC,CAAA;IACrC,sEAAsD,CAAA;IACtD,iEAAiD,CAAA;AACnD,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExecuteStepRetryParams } from '../types/core.js';
|
|
1
2
|
import { BaseError } from './baseError.js';
|
|
2
3
|
import { LiFiErrorCode } from './constants.js';
|
|
3
4
|
export declare class RPCError extends BaseError {
|
|
@@ -21,3 +22,12 @@ export declare class ServerError extends BaseError {
|
|
|
21
22
|
export declare class ValidationError extends BaseError {
|
|
22
23
|
constructor(message: string);
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Thrown by a step executor when executeStep should be retried with the given params
|
|
27
|
+
* (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).
|
|
28
|
+
* The execution layer catches this and retries executeStep(client, step, retryParams).
|
|
29
|
+
*/
|
|
30
|
+
export declare class ExecuteStepRetryError extends BaseError {
|
|
31
|
+
readonly retryParams: ExecuteStepRetryParams;
|
|
32
|
+
constructor(message: string, retryParams: ExecuteStepRetryParams, cause?: Error);
|
|
33
|
+
}
|
|
@@ -35,4 +35,16 @@ export class ValidationError extends BaseError {
|
|
|
35
35
|
super(ErrorName.ValidationError, LiFiErrorCode.ValidationError, message);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Thrown by a step executor when executeStep should be retried with the given params
|
|
40
|
+
* (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).
|
|
41
|
+
* The execution layer catches this and retries executeStep(client, step, retryParams).
|
|
42
|
+
*/
|
|
43
|
+
export class ExecuteStepRetryError extends BaseError {
|
|
44
|
+
retryParams;
|
|
45
|
+
constructor(message, retryParams, cause) {
|
|
46
|
+
super(ErrorName.ExecuteStepRetryError, LiFiErrorCode.InternalError, message, cause);
|
|
47
|
+
this.retryParams = retryParams;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
38
50
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/errors/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/errors/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEzD,MAAM,OAAO,QAAS,SAAQ,SAAS;IACrC,YAAY,IAAmB,EAAE,OAAe,EAAE,KAAa;QAC7D,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IACjD,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,YAAY,IAAmB,EAAE,OAAe,EAAE,KAAa;QAC7D,KAAK,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IACtD,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAC7C,YAAY,IAAmB,EAAE,OAAe,EAAE,KAAa;QAC7D,KAAK,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IACzD,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CAAC,SAAS,CAAC,YAAY,EAAE,aAAa,CAAC,aAAa,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IAC5E,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CAAC,SAAS,CAAC,YAAY,EAAE,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IAC3E,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,aAAa,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;IACpE,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,SAAS,CAAC,eAAe,EAAE,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;IAC1E,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,SAAS;IACzC,WAAW,CAAwB;IAE5C,YACE,OAAe,EACf,WAAmC,EACnC,KAAa;QAEb,KAAK,CACH,SAAS,CAAC,qBAAqB,EAC/B,aAAa,CAAC,aAAa,EAC3B,OAAO,EACP,KAAK,CACN,CAAA;QACD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;CACF"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export * from '@lifi/types';
|
|
2
|
-
export
|
|
3
|
-
export { formatUnits, isHex, parseUnits } from 'viem/utils';
|
|
4
|
-
export { getChains, getChainsFromConfig } from './actions/getChains.js';
|
|
2
|
+
export { getChains } from './actions/getChains.js';
|
|
5
3
|
export { getConnections } from './actions/getConnections.js';
|
|
6
4
|
export { getContractCallsQuote } from './actions/getContractCallsQuote.js';
|
|
7
5
|
export { getGasRecommendation } from './actions/getGasRecommendation.js';
|
|
@@ -21,25 +19,37 @@ export { getTools } from './actions/getTools.js';
|
|
|
21
19
|
export { getTransactionHistory } from './actions/getTransactionHistory.js';
|
|
22
20
|
export { getWalletBalances } from './actions/getWalletBalances.js';
|
|
23
21
|
export { actions } from './actions/index.js';
|
|
22
|
+
export { patchContractCalls } from './actions/patchContractCalls.js';
|
|
24
23
|
export { relayTransaction } from './actions/relayTransaction.js';
|
|
25
24
|
export { createClient } from './client/createClient.js';
|
|
25
|
+
export { getActionMessage, getSubstatusMessage } from './core/actionMessages.js';
|
|
26
|
+
export { BaseStepExecutionTask } from './core/BaseStepExecutionTask.js';
|
|
26
27
|
export { BaseStepExecutor } from './core/BaseStepExecutor.js';
|
|
27
|
-
export { checkBalance } from './core/checkBalance.js';
|
|
28
28
|
export { executeRoute, getActiveRoute, getActiveRoutes, resumeRoute, stopRouteExecution, updateRouteExecution, } from './core/execution.js';
|
|
29
29
|
export { StatusManager } from './core/StatusManager.js';
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
30
|
+
export type { SDKStorage } from './core/storage.js';
|
|
31
|
+
export { createDefaultStorage, InMemoryStorage, LocalStorageAdapter, } from './core/storage.js';
|
|
32
|
+
export { TaskPipeline } from './core/TaskPipeline.js';
|
|
33
|
+
export { CheckBalanceTask } from './core/tasks/CheckBalanceTask.js';
|
|
34
|
+
export { checkBalance } from './core/tasks/helpers/checkBalance.js';
|
|
35
|
+
export { getTransactionRequestData } from './core/tasks/helpers/getTransactionRequestData.js';
|
|
36
|
+
export { stepComparison } from './core/tasks/helpers/stepComparison.js';
|
|
37
|
+
export { PrepareTransactionTask } from './core/tasks/PrepareTransactionTask.js';
|
|
38
|
+
export { WaitForTransactionStatusTask } from './core/tasks/WaitForTransactionStatusTask.js';
|
|
33
39
|
export { BaseError } from './errors/baseError.js';
|
|
34
40
|
export type { ErrorCode } from './errors/constants.js';
|
|
35
41
|
export { ErrorMessage, ErrorName, LiFiErrorCode } from './errors/constants.js';
|
|
36
|
-
export { BalanceError, ProviderError, RPCError, ServerError, TransactionError, UnknownError, ValidationError, } from './errors/errors.js';
|
|
42
|
+
export { BalanceError, ExecuteStepRetryError, ProviderError, RPCError, ServerError, TransactionError, UnknownError, ValidationError, } from './errors/errors.js';
|
|
37
43
|
export { HTTPError } from './errors/httpError.js';
|
|
38
44
|
export { SDKError } from './errors/SDKError.js';
|
|
39
|
-
export type { AcceptExchangeRateUpdateHook, AcceptSlippageUpdateHook, AcceptSlippageUpdateHookParams, ExchangeRateUpdateParams, Execution, ExecutionOptions, ExecutionStatus,
|
|
45
|
+
export type { AcceptExchangeRateUpdateHook, AcceptSlippageUpdateHook, AcceptSlippageUpdateHookParams, ContractCallParams, ContractTool, ExchangeRateUpdateParams, ExecuteStepRetryParams, Execution, ExecutionAction, ExecutionActionStatus, ExecutionActionType, ExecutionOptions, ExecutionStatus, GetContractCallsHook, GetContractCallsResult, InteractionSettings, LiFiStepExtended, RequestInterceptor, RouteExecutionData, RouteExecutionDataDictionary, RouteExecutionDictionary, RouteExtended, RPCUrls, SDKBaseConfig, SDKClient, SDKConfig, SDKProvider, StepExecutor, StepExecutorOptions, StepExtended, TransactionMethodType, TransactionParameters, TransactionRequestParameters, TransactionRequestUpdateHook, UpdateRouteHook, } from './types/core.js';
|
|
46
|
+
export type { StepExecutorBaseContext, StepExecutorContext, TaskResult, TaskStatus, } from './types/execution.js';
|
|
40
47
|
export { checkPackageUpdates } from './utils/checkPackageUpdates.js';
|
|
41
48
|
export { convertQuoteToRoute } from './utils/convertQuoteToRoute.js';
|
|
42
49
|
export { fetchTxErrorDetails } from './utils/fetchTxErrorDetails.js';
|
|
50
|
+
export { formatUnits } from './utils/formatUnits.js';
|
|
51
|
+
export { isHex } from './utils/isHex.js';
|
|
52
|
+
export { parseUnits } from './utils/parseUnits.js';
|
|
43
53
|
export { sleep } from './utils/sleep.js';
|
|
44
54
|
export { waitForResult } from './utils/waitForResult.js';
|
|
45
|
-
export { withDedupe } from './utils/withDedupe.js';
|
|
55
|
+
export { LruMap, withDedupe } from './utils/withDedupe.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// biome-ignore lint/performance/noBarrelFile: module entrypoint
|
|
2
2
|
// biome-ignore lint/performance/noReExportAll: types
|
|
3
3
|
export * from '@lifi/types';
|
|
4
|
-
export {
|
|
5
|
-
export { getChains, getChainsFromConfig } from './actions/getChains.js';
|
|
4
|
+
export { getChains } from './actions/getChains.js';
|
|
6
5
|
export { getConnections } from './actions/getConnections.js';
|
|
7
6
|
export { getContractCallsQuote } from './actions/getContractCallsQuote.js';
|
|
8
7
|
export { getGasRecommendation } from './actions/getGasRecommendation.js';
|
|
@@ -22,24 +21,34 @@ export { getTools } from './actions/getTools.js';
|
|
|
22
21
|
export { getTransactionHistory } from './actions/getTransactionHistory.js';
|
|
23
22
|
export { getWalletBalances } from './actions/getWalletBalances.js';
|
|
24
23
|
export { actions } from './actions/index.js';
|
|
24
|
+
export { patchContractCalls } from './actions/patchContractCalls.js';
|
|
25
25
|
export { relayTransaction } from './actions/relayTransaction.js';
|
|
26
26
|
export { createClient } from './client/createClient.js';
|
|
27
|
+
export { getActionMessage, getSubstatusMessage } from './core/actionMessages.js';
|
|
28
|
+
export { BaseStepExecutionTask } from './core/BaseStepExecutionTask.js';
|
|
27
29
|
export { BaseStepExecutor } from './core/BaseStepExecutor.js';
|
|
28
|
-
export { checkBalance } from './core/checkBalance.js';
|
|
29
30
|
export { executeRoute, getActiveRoute, getActiveRoutes, resumeRoute, stopRouteExecution, updateRouteExecution, } from './core/execution.js';
|
|
30
31
|
export { StatusManager } from './core/StatusManager.js';
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
32
|
+
export { createDefaultStorage, InMemoryStorage, LocalStorageAdapter, } from './core/storage.js';
|
|
33
|
+
export { TaskPipeline } from './core/TaskPipeline.js';
|
|
34
|
+
export { CheckBalanceTask } from './core/tasks/CheckBalanceTask.js';
|
|
35
|
+
export { checkBalance } from './core/tasks/helpers/checkBalance.js';
|
|
36
|
+
export { getTransactionRequestData } from './core/tasks/helpers/getTransactionRequestData.js';
|
|
37
|
+
export { stepComparison } from './core/tasks/helpers/stepComparison.js';
|
|
38
|
+
export { PrepareTransactionTask } from './core/tasks/PrepareTransactionTask.js';
|
|
39
|
+
export { WaitForTransactionStatusTask } from './core/tasks/WaitForTransactionStatusTask.js';
|
|
34
40
|
export { BaseError } from './errors/baseError.js';
|
|
35
41
|
export { ErrorMessage, ErrorName, LiFiErrorCode } from './errors/constants.js';
|
|
36
|
-
export { BalanceError, ProviderError, RPCError, ServerError, TransactionError, UnknownError, ValidationError, } from './errors/errors.js';
|
|
42
|
+
export { BalanceError, ExecuteStepRetryError, ProviderError, RPCError, ServerError, TransactionError, UnknownError, ValidationError, } from './errors/errors.js';
|
|
37
43
|
export { HTTPError } from './errors/httpError.js';
|
|
38
44
|
export { SDKError } from './errors/SDKError.js';
|
|
39
45
|
export { checkPackageUpdates } from './utils/checkPackageUpdates.js';
|
|
40
46
|
export { convertQuoteToRoute } from './utils/convertQuoteToRoute.js';
|
|
41
47
|
export { fetchTxErrorDetails } from './utils/fetchTxErrorDetails.js';
|
|
48
|
+
export { formatUnits } from './utils/formatUnits.js';
|
|
49
|
+
export { isHex } from './utils/isHex.js';
|
|
50
|
+
export { parseUnits } from './utils/parseUnits.js';
|
|
42
51
|
export { sleep } from './utils/sleep.js';
|
|
43
52
|
export { waitForResult } from './utils/waitForResult.js';
|
|
44
|
-
export { withDedupe } from './utils/withDedupe.js';
|
|
53
|
+
export { LruMap, withDedupe } from './utils/withDedupe.js';
|
|
45
54
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,qDAAqD;AACrD,cAAc,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,qDAAqD;AACrD,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,o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A;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/esm/types/core.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { ChainId, ChainType, CoinKey, ExtendedChain, FeeCost, GasCost, LiFiStep, Route, RouteOptions, Step, Substatus, Token, TokenAmount } from '@lifi/types';
|
|
2
|
-
import type {
|
|
1
|
+
import type { ChainId, ChainType, CoinKey, ContractCall, ExtendedChain, FeeCost, GasCost, LiFiStep, Route, RouteOptions, Step, Substatus, Token, TokenAmount } from '@lifi/types';
|
|
2
|
+
import type { SDKStorage } from '../core/storage.js';
|
|
3
|
+
import type { ExtendedRequestInit } from './request.js';
|
|
4
|
+
export type RequestInterceptor = (request: ExtendedRequestInit) => ExtendedRequestInit | Promise<ExtendedRequestInit>;
|
|
3
5
|
export interface SDKBaseConfig {
|
|
4
6
|
apiKey?: string;
|
|
5
7
|
apiUrl: string;
|
|
@@ -11,6 +13,10 @@ export interface SDKBaseConfig {
|
|
|
11
13
|
disableVersionCheck?: boolean;
|
|
12
14
|
widgetVersion?: string;
|
|
13
15
|
debug: boolean;
|
|
16
|
+
preloadChains?: boolean;
|
|
17
|
+
chainsRefetchInterval?: number;
|
|
18
|
+
requestInterceptor?: RequestInterceptor;
|
|
19
|
+
storage?: SDKStorage;
|
|
14
20
|
}
|
|
15
21
|
export interface SDKConfig extends Partial<Omit<SDKBaseConfig, 'integrator'>> {
|
|
16
22
|
integrator: string;
|
|
@@ -28,6 +34,7 @@ export interface SDKClient {
|
|
|
28
34
|
providers: SDKProvider[];
|
|
29
35
|
getProvider(type: ChainType): SDKProvider | undefined;
|
|
30
36
|
setProviders(providers: SDKProvider[]): void;
|
|
37
|
+
setChains(chains: ExtendedChain[]): void;
|
|
31
38
|
getChains(): Promise<ExtendedChain[]>;
|
|
32
39
|
getChainById(chainId: ChainId): Promise<ExtendedChain>;
|
|
33
40
|
getRpcUrls(): Promise<RPCUrls>;
|
|
@@ -42,11 +49,16 @@ export interface InteractionSettings {
|
|
|
42
49
|
allowUpdates?: boolean;
|
|
43
50
|
allowExecution?: boolean;
|
|
44
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Params passed when retrying executeStep after an ExecuteStepRetryError.
|
|
54
|
+
* Providers can use this to pass strategy-specific retry options (e.g. atomicityNotReady for Ethereum 7702).
|
|
55
|
+
*/
|
|
56
|
+
export type ExecuteStepRetryParams = Record<string, unknown>;
|
|
45
57
|
export interface StepExecutor {
|
|
46
58
|
allowUserInteraction: boolean;
|
|
47
59
|
allowExecution: boolean;
|
|
48
60
|
setInteraction(settings?: InteractionSettings): void;
|
|
49
|
-
executeStep(client: SDKClient, step: LiFiStepExtended): Promise<LiFiStepExtended>;
|
|
61
|
+
executeStep(client: SDKClient, step: LiFiStepExtended, retryParams?: ExecuteStepRetryParams): Promise<LiFiStepExtended>;
|
|
50
62
|
}
|
|
51
63
|
export interface RouteExecutionData {
|
|
52
64
|
route: Route;
|
|
@@ -81,7 +93,6 @@ export interface TransactionRequestParameters extends TransactionParameters {
|
|
|
81
93
|
requestType: 'approve' | 'transaction';
|
|
82
94
|
}
|
|
83
95
|
export type TransactionRequestUpdateHook = (updatedTxRequest: TransactionRequestParameters) => Promise<TransactionParameters>;
|
|
84
|
-
export type SwitchChainHook = (chainId: number) => Promise<Client | undefined>;
|
|
85
96
|
export interface AcceptSlippageUpdateHookParams {
|
|
86
97
|
toToken: Token;
|
|
87
98
|
oldToAmount: string;
|
|
@@ -96,48 +107,66 @@ export interface ExchangeRateUpdateParams {
|
|
|
96
107
|
newToAmount: string;
|
|
97
108
|
}
|
|
98
109
|
export type AcceptExchangeRateUpdateHook = (params: ExchangeRateUpdateParams) => Promise<boolean | undefined>;
|
|
110
|
+
export interface ContractCallParams {
|
|
111
|
+
fromChainId: number;
|
|
112
|
+
toChainId: number;
|
|
113
|
+
fromTokenAddress: string;
|
|
114
|
+
toTokenAddress: string;
|
|
115
|
+
fromAddress: string;
|
|
116
|
+
toAddress?: string;
|
|
117
|
+
fromAmount: bigint;
|
|
118
|
+
toAmount: bigint;
|
|
119
|
+
slippage?: number;
|
|
120
|
+
}
|
|
121
|
+
export interface ContractTool {
|
|
122
|
+
name: string;
|
|
123
|
+
logoURI: string;
|
|
124
|
+
}
|
|
125
|
+
export interface GetContractCallsResult {
|
|
126
|
+
contractCalls: ContractCall[];
|
|
127
|
+
patcher?: boolean;
|
|
128
|
+
contractTool?: ContractTool;
|
|
129
|
+
}
|
|
130
|
+
export type GetContractCallsHook = (params: ContractCallParams) => Promise<GetContractCallsResult>;
|
|
99
131
|
export interface ExecutionOptions {
|
|
100
132
|
acceptExchangeRateUpdateHook?: AcceptExchangeRateUpdateHook;
|
|
101
|
-
switchChainHook?: SwitchChainHook;
|
|
102
133
|
updateRouteHook?: UpdateRouteHook;
|
|
103
134
|
updateTransactionRequestHook?: TransactionRequestUpdateHook;
|
|
135
|
+
getContractCalls?: GetContractCallsHook;
|
|
136
|
+
adjustZeroOutputFromPreviousStep?: boolean;
|
|
104
137
|
executeInBackground?: boolean;
|
|
105
|
-
disableMessageSigning?: boolean;
|
|
106
138
|
/**
|
|
107
139
|
* @deprecated
|
|
108
140
|
*/
|
|
109
141
|
infiniteApproval?: boolean;
|
|
110
142
|
}
|
|
111
143
|
export type ExecutionStatus = 'ACTION_REQUIRED' | 'PENDING' | 'FAILED' | 'DONE';
|
|
112
|
-
export type
|
|
113
|
-
export type
|
|
114
|
-
export type
|
|
115
|
-
type:
|
|
116
|
-
status:
|
|
144
|
+
export type ExecutionActionStatus = 'STARTED' | 'ACTION_REQUIRED' | 'MESSAGE_REQUIRED' | 'RESET_REQUIRED' | 'PENDING' | 'FAILED' | 'DONE' | 'CANCELLED';
|
|
145
|
+
export type ExecutionActionType = 'PERMIT' | 'CHECK_ALLOWANCE' | 'NATIVE_PERMIT' | 'RESET_ALLOWANCE' | 'SET_ALLOWANCE' | 'SWAP' | 'CROSS_CHAIN' | 'RECEIVING_CHAIN';
|
|
146
|
+
export type ExecutionAction = {
|
|
147
|
+
type: ExecutionActionType;
|
|
148
|
+
status: ExecutionActionStatus;
|
|
149
|
+
message?: string;
|
|
117
150
|
substatus?: Substatus;
|
|
151
|
+
substatusMessage?: string;
|
|
118
152
|
chainId?: number;
|
|
119
153
|
txHash?: string;
|
|
120
|
-
taskId?: string;
|
|
121
154
|
txLink?: string;
|
|
155
|
+
taskId?: string;
|
|
122
156
|
txType?: TransactionMethodType;
|
|
123
|
-
|
|
124
|
-
doneAt?: number;
|
|
125
|
-
failedAt?: number;
|
|
126
|
-
pendingAt?: number;
|
|
127
|
-
startedAt: number;
|
|
128
|
-
message?: string;
|
|
157
|
+
txHex?: string;
|
|
129
158
|
error?: {
|
|
130
159
|
code: string | number;
|
|
131
160
|
message: string;
|
|
132
161
|
htmlMessage?: string;
|
|
133
162
|
};
|
|
134
|
-
[key: string]: any;
|
|
135
163
|
};
|
|
136
164
|
export interface Execution {
|
|
137
165
|
startedAt: number;
|
|
138
|
-
|
|
166
|
+
signedAt?: number;
|
|
139
167
|
status: ExecutionStatus;
|
|
140
|
-
|
|
168
|
+
actions: Array<ExecutionAction>;
|
|
169
|
+
lastActionType?: ExecutionActionType;
|
|
141
170
|
fromAmount?: string;
|
|
142
171
|
toAmount?: string;
|
|
143
172
|
toToken?: Token;
|
|
@@ -145,5 +174,10 @@ export interface Execution {
|
|
|
145
174
|
gasCosts?: GasCost[];
|
|
146
175
|
internalTxLink?: string;
|
|
147
176
|
externalTxLink?: string;
|
|
177
|
+
error?: {
|
|
178
|
+
code: string | number;
|
|
179
|
+
message: string;
|
|
180
|
+
htmlMessage?: string;
|
|
181
|
+
};
|
|
148
182
|
}
|
|
149
183
|
export type TransactionMethodType = 'standard' | 'relayed' | 'batched';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ExtendedChain } from '@lifi/types';
|
|
2
|
+
import type { StatusManager } from '../core/StatusManager.js';
|
|
3
|
+
import type { ExecuteStepRetryParams, ExecutionOptions, LiFiStepExtended, SDKClient } from './core.js';
|
|
4
|
+
export interface StepExecutorBaseContext {
|
|
5
|
+
statusManager: StatusManager;
|
|
6
|
+
executionOptions?: ExecutionOptions;
|
|
7
|
+
fromChain: ExtendedChain;
|
|
8
|
+
toChain: ExtendedChain;
|
|
9
|
+
isBridgeExecution: boolean;
|
|
10
|
+
client: SDKClient;
|
|
11
|
+
step: LiFiStepExtended;
|
|
12
|
+
allowUserInteraction: boolean;
|
|
13
|
+
retryParams?: ExecuteStepRetryParams;
|
|
14
|
+
}
|
|
15
|
+
export interface StepExecutorContext extends StepExecutorBaseContext {
|
|
16
|
+
pollingIntervalMs?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface TaskResult<TContext = Record<string, unknown>> {
|
|
19
|
+
status: TaskStatus;
|
|
20
|
+
/** Optional: data produced for downstream tasks. Pipeline merges into the executor context. */
|
|
21
|
+
context?: TContext;
|
|
22
|
+
}
|
|
23
|
+
export type TaskStatus = 'COMPLETED' | 'PAUSED';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/types/execution.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { LiFiStep, Route } from '@lifi/types';
|
|
2
|
+
interface ConvertQuoteToRouteOptions {
|
|
3
|
+
/**
|
|
4
|
+
* When true, if the quote has zero output values (toAmount, toAmountMin, toAmountUSD),
|
|
5
|
+
* use the values from the previous included step that has non-zero output.
|
|
6
|
+
*/
|
|
7
|
+
adjustZeroOutputFromPreviousStep?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function formatTokenPrice(amount?: string | bigint, price?: string, decimals?: number): number;
|
|
2
10
|
/**
|
|
3
11
|
* Converts a quote to Route
|
|
4
12
|
* @param quote - Step returned from the quote endpoint.
|
|
5
|
-
* @param
|
|
6
|
-
* @param chainId
|
|
13
|
+
* @param options - Optional configuration for handling edge cases.
|
|
7
14
|
* @returns - The route to be executed.
|
|
8
15
|
* @throws {BaseError} Throws a ValidationError if the step has missing values.
|
|
9
16
|
*/
|
|
10
|
-
export declare const convertQuoteToRoute: (quote: LiFiStep) => Route;
|
|
17
|
+
export declare const convertQuoteToRoute: (quote: LiFiStep, options?: ConvertQuoteToRouteOptions) => Route;
|
|
18
|
+
export {};
|
|
@@ -1,18 +1,87 @@
|
|
|
1
1
|
import { ValidationError } from '../errors/errors.js';
|
|
2
2
|
import { SDKError } from '../errors/SDKError.js';
|
|
3
|
+
import { formatUnits } from './formatUnits.js';
|
|
4
|
+
const parseBigInt = (value) => {
|
|
5
|
+
if (!value) {
|
|
6
|
+
return 0n;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
return BigInt(value);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return 0n;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const parseNumber = (value) => {
|
|
16
|
+
if (!value) {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
const parsed = Number(value);
|
|
20
|
+
return Number.isNaN(parsed) ? 0 : parsed;
|
|
21
|
+
};
|
|
22
|
+
const isZeroOutput = (toAmount, toAmountMin, toAmountUSD) => {
|
|
23
|
+
return (!parseBigInt(toAmount) &&
|
|
24
|
+
!parseBigInt(toAmountMin) &&
|
|
25
|
+
!parseNumber(toAmountUSD));
|
|
26
|
+
};
|
|
27
|
+
const hasNonZeroOutput = (step) => {
|
|
28
|
+
return (!!parseBigInt(step.estimate.toAmount) ||
|
|
29
|
+
!!parseBigInt(step.estimate.toAmountMin));
|
|
30
|
+
};
|
|
31
|
+
const findPreviousNonZeroStep = (steps) => {
|
|
32
|
+
// Find the last step that has non-zero output (the step before the zero output step)
|
|
33
|
+
for (let i = steps.length - 1; i >= 0; i--) {
|
|
34
|
+
const step = steps[i];
|
|
35
|
+
if (hasNonZeroOutput(step)) {
|
|
36
|
+
return step;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
};
|
|
41
|
+
export function formatTokenPrice(amount, price, decimals) {
|
|
42
|
+
if (!amount || !price) {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
const formattedAmount = typeof amount === 'bigint' && decimals !== undefined
|
|
46
|
+
? formatUnits(amount, decimals)
|
|
47
|
+
: amount.toString();
|
|
48
|
+
if (Number.isNaN(Number(formattedAmount)) || Number.isNaN(Number(price))) {
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
return Number.parseFloat(formattedAmount) * Number.parseFloat(price);
|
|
52
|
+
}
|
|
3
53
|
/**
|
|
4
54
|
* Converts a quote to Route
|
|
5
55
|
* @param quote - Step returned from the quote endpoint.
|
|
6
|
-
* @param
|
|
7
|
-
* @param chainId
|
|
56
|
+
* @param options - Optional configuration for handling edge cases.
|
|
8
57
|
* @returns - The route to be executed.
|
|
9
58
|
* @throws {BaseError} Throws a ValidationError if the step has missing values.
|
|
10
59
|
*/
|
|
11
|
-
export const convertQuoteToRoute = (quote) => {
|
|
60
|
+
export const convertQuoteToRoute = (quote, options) => {
|
|
61
|
+
let toAmount = quote.estimate.toAmount;
|
|
62
|
+
let toAmountMin = quote.estimate.toAmountMin;
|
|
63
|
+
let toAmountUSD = quote.estimate.toAmountUSD;
|
|
64
|
+
// Handle zero output values by looking at previous included step
|
|
65
|
+
if (options?.adjustZeroOutputFromPreviousStep &&
|
|
66
|
+
quote.includedSteps?.length &&
|
|
67
|
+
isZeroOutput(toAmount, toAmountMin, toAmountUSD)) {
|
|
68
|
+
const previousStep = findPreviousNonZeroStep(quote.includedSteps);
|
|
69
|
+
if (previousStep) {
|
|
70
|
+
toAmount = previousStep.estimate.toAmount;
|
|
71
|
+
toAmountMin = previousStep.estimate.toAmountMin;
|
|
72
|
+
toAmountUSD = formatTokenPrice(parseBigInt(toAmount), previousStep.action.toToken.priceUSD, previousStep.action.toToken.decimals).toFixed(2);
|
|
73
|
+
// Update the last included step's estimate with the adjusted values
|
|
74
|
+
const lastStep = quote.includedSteps[quote.includedSteps.length - 1];
|
|
75
|
+
if (lastStep && !hasNonZeroOutput(lastStep)) {
|
|
76
|
+
lastStep.estimate.toAmount = toAmount;
|
|
77
|
+
lastStep.estimate.toAmountMin = toAmountMin;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
12
81
|
if (!quote.estimate.fromAmountUSD) {
|
|
13
82
|
throw new SDKError(new ValidationError("Missing 'fromAmountUSD' in step estimate."));
|
|
14
83
|
}
|
|
15
|
-
if (!
|
|
84
|
+
if (!toAmountUSD) {
|
|
16
85
|
throw new SDKError(new ValidationError("Missing 'toAmountUSD' in step estimate."));
|
|
17
86
|
}
|
|
18
87
|
const route = {
|
|
@@ -24,9 +93,9 @@ export const convertQuoteToRoute = (quote) => {
|
|
|
24
93
|
fromAddress: quote.action.fromAddress,
|
|
25
94
|
toChainId: quote.action.toToken.chainId,
|
|
26
95
|
toToken: quote.action.toToken,
|
|
27
|
-
toAmount
|
|
28
|
-
toAmountMin
|
|
29
|
-
toAmountUSD
|
|
96
|
+
toAmount,
|
|
97
|
+
toAmountMin,
|
|
98
|
+
toAmountUSD,
|
|
30
99
|
toAddress: quote.action.toAddress || quote.action.fromAddress,
|
|
31
100
|
gasCostUSD: quote.estimate.gasCosts?.[0]?.amountUSD || '0',
|
|
32
101
|
steps: [quote],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertQuoteToRoute.js","sourceRoot":"","sources":["../../../src/utils/convertQuoteToRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"convertQuoteToRoute.js","sourceRoot":"","sources":["../../../src/utils/convertQuoteToRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAA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C3C,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS;QACjC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU;QACnC,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,aAAa;QAC3C,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW;QACrC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO;QACvC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO;QAC7B,QAAQ;QACR,WAAW;QACX,WAAW;QACX,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW;QAC7D,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,IAAI,GAAG;QAC1D,KAAK,EAAE,CAAC,KAAK,CAAC;QACd,SAAS,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,GAAG,EAAE;KACzD,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divides a number by a given exponent of base 10 (10exponent), and formats it into a string representation of the number.
|
|
3
|
+
*/
|
|
4
|
+
export function formatUnits(value, decimals) {
|
|
5
|
+
let display = value.toString();
|
|
6
|
+
const negative = display.startsWith('-');
|
|
7
|
+
if (negative) {
|
|
8
|
+
display = display.slice(1);
|
|
9
|
+
}
|
|
10
|
+
display = display.padStart(decimals, '0');
|
|
11
|
+
let [integer, fraction] = [
|
|
12
|
+
display.slice(0, display.length - decimals),
|
|
13
|
+
display.slice(display.length - decimals),
|
|
14
|
+
];
|
|
15
|
+
fraction = fraction.replace(/(0+)$/, '');
|
|
16
|
+
return `${negative ? '-' : ''}${integer || '0'}${fraction ? `.${fraction}` : ''}`;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=formatUnits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatUnits.js","sourceRoot":"","sources":["../../../src/utils/formatUnits.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,QAAgB;IACzD,IAAI,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAA;IAE9B,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACxC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC;IAED,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IAEzC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG;QACxB,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC;QAC3C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC;KACzC,CAAA;IACD,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACxC,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,IAAI,GAAG,GAC5C,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,EAC9B,EAAE,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function isHex(value, { strict = true } = {}) {
|
|
2
|
+
if (!value) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
if (typeof value !== 'string') {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith('0x');
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=isHex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isHex.js","sourceRoot":"","sources":["../../../src/utils/isHex.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,KAAK,CACnB,KAAc,EACd,EAAE,MAAM,GAAG,IAAI,KAAuC,EAAE;IAExD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AACzE,CAAC"}
|