@lifi/sdk 4.0.1-alpha.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1233 -0
- package/README.md +88 -5
- package/dist/cjs/actions/getChains.d.ts +17 -4
- package/dist/cjs/actions/getChains.js +22 -19
- package/dist/cjs/actions/getChains.js.map +1 -1
- package/dist/cjs/actions/getConnections.d.ts +15 -3
- package/dist/cjs/actions/getConnections.js +30 -35
- package/dist/cjs/actions/getConnections.js.map +1 -1
- package/dist/cjs/actions/getContractCallsQuote.d.ts +16 -3
- package/dist/cjs/actions/getContractCallsQuote.js +41 -42
- package/dist/cjs/actions/getContractCallsQuote.js.map +1 -1
- package/dist/cjs/actions/getGasRecommendation.d.ts +16 -3
- package/dist/cjs/actions/getGasRecommendation.js +20 -19
- package/dist/cjs/actions/getGasRecommendation.js.map +1 -1
- package/dist/cjs/actions/getNameServiceAddress.d.ts +15 -3
- package/dist/cjs/actions/getNameServiceAddress.js +25 -27
- package/dist/cjs/actions/getNameServiceAddress.js.map +1 -1
- package/dist/cjs/actions/getQuote.d.ts +18 -5
- package/dist/cjs/actions/getQuote.js +33 -45
- package/dist/cjs/actions/getQuote.js.map +1 -1
- package/dist/cjs/actions/getRelayedTransactionStatus.d.ts +16 -3
- package/dist/cjs/actions/getRelayedTransactionStatus.js +26 -26
- package/dist/cjs/actions/getRelayedTransactionStatus.js.map +1 -1
- package/dist/cjs/actions/getRelayerQuote.d.ts +17 -4
- package/dist/cjs/actions/getRelayerQuote.js +40 -44
- package/dist/cjs/actions/getRelayerQuote.js.map +1 -1
- package/dist/cjs/actions/getRoutes.d.ts +17 -3
- package/dist/cjs/actions/getRoutes.js +28 -23
- package/dist/cjs/actions/getRoutes.js.map +1 -1
- package/dist/cjs/actions/getStatus.d.ts +17 -4
- package/dist/cjs/actions/getStatus.js +18 -14
- package/dist/cjs/actions/getStatus.js.map +1 -1
- package/dist/cjs/actions/getStepTransaction.d.ts +17 -3
- package/dist/cjs/actions/getStepTransaction.js +32 -24
- package/dist/cjs/actions/getStepTransaction.js.map +1 -1
- package/dist/cjs/actions/getToken.d.ts +17 -3
- package/dist/cjs/actions/getToken.js +22 -18
- package/dist/cjs/actions/getToken.js.map +1 -1
- package/dist/cjs/actions/getTokenBalance.d.ts +17 -3
- package/dist/cjs/actions/getTokenBalance.js +16 -6
- package/dist/cjs/actions/getTokenBalance.js.map +1 -1
- package/dist/cjs/actions/getTokenBalances.d.ts +17 -3
- package/dist/cjs/actions/getTokenBalances.js +12 -13
- package/dist/cjs/actions/getTokenBalances.js.map +1 -1
- package/dist/cjs/actions/getTokenBalancesByChain.d.ts +19 -5
- package/dist/cjs/actions/getTokenBalancesByChain.js +22 -37
- package/dist/cjs/actions/getTokenBalancesByChain.js.map +1 -1
- package/dist/cjs/actions/getTokens.d.ts +18 -6
- package/dist/cjs/actions/getTokens.js +14 -18
- package/dist/cjs/actions/getTokens.js.map +1 -1
- package/dist/cjs/actions/getTools.d.ts +15 -3
- package/dist/cjs/actions/getTools.js +17 -14
- package/dist/cjs/actions/getTools.js.map +1 -1
- package/dist/cjs/actions/getTransactionHistory.d.ts +26 -3
- package/dist/cjs/actions/getTransactionHistory.js +27 -21
- package/dist/cjs/actions/getTransactionHistory.js.map +1 -1
- package/dist/cjs/actions/getWalletBalances.d.ts +16 -3
- package/dist/cjs/actions/getWalletBalances.js +16 -12
- package/dist/cjs/actions/getWalletBalances.js.map +1 -1
- package/dist/cjs/actions/index.d.ts +174 -39
- package/dist/cjs/actions/index.js +49 -47
- package/dist/cjs/actions/index.js.map +1 -1
- package/dist/cjs/actions/patchContractCalls.d.ts +14 -9
- package/dist/cjs/actions/patchContractCalls.js +11 -12
- package/dist/cjs/actions/patchContractCalls.js.map +1 -1
- package/dist/cjs/actions/relayTransaction.d.ts +16 -3
- package/dist/cjs/actions/relayTransaction.js +30 -34
- package/dist/cjs/actions/relayTransaction.js.map +1 -1
- package/dist/cjs/client/createClient.d.ts +7 -2
- package/dist/cjs/client/createClient.js +67 -75
- package/dist/cjs/client/createClient.js.map +1 -1
- package/dist/cjs/client/getClientStorage.d.ts +14 -8
- package/dist/cjs/client/getClientStorage.js +44 -47
- package/dist/cjs/client/getClientStorage.js.map +1 -1
- package/dist/cjs/core/BaseStepExecutionTask.d.ts +10 -0
- package/dist/cjs/core/BaseStepExecutionTask.js +11 -0
- package/dist/cjs/core/BaseStepExecutionTask.js.map +1 -0
- package/dist/cjs/core/BaseStepExecutor.d.ts +23 -11
- package/dist/cjs/core/BaseStepExecutor.js +67 -26
- package/dist/cjs/core/BaseStepExecutor.js.map +1 -1
- package/dist/cjs/core/StatusManager.d.ts +81 -20
- package/dist/cjs/core/StatusManager.js +158 -137
- package/dist/cjs/core/StatusManager.js.map +1 -1
- package/dist/cjs/core/TaskPipeline.d.ts +12 -0
- package/dist/cjs/core/TaskPipeline.js +21 -0
- package/dist/cjs/core/TaskPipeline.js.map +1 -0
- package/dist/cjs/core/actionMessages.d.ts +9 -4
- package/dist/cjs/core/actionMessages.js +72 -58
- package/dist/cjs/core/actionMessages.js.map +1 -1
- package/dist/cjs/core/execution.d.ts +48 -8
- package/dist/cjs/core/execution.js +131 -121
- package/dist/cjs/core/execution.js.map +1 -1
- package/dist/cjs/core/executionState.d.ts +17 -13
- package/dist/cjs/core/executionState.js +27 -27
- package/dist/cjs/core/executionState.js.map +1 -1
- package/dist/cjs/core/prepareRestart.d.ts +7 -2
- package/dist/cjs/core/prepareRestart.js +17 -19
- package/dist/cjs/core/prepareRestart.js.map +1 -1
- package/dist/cjs/core/storage.d.ts +21 -0
- package/dist/cjs/core/storage.js +35 -0
- package/dist/cjs/core/storage.js.map +1 -0
- package/dist/cjs/core/tasks/CheckBalanceTask.d.ts +19 -0
- package/dist/cjs/core/tasks/CheckBalanceTask.js +35 -0
- package/dist/cjs/core/tasks/CheckBalanceTask.js.map +1 -0
- package/dist/cjs/core/tasks/PrepareTransactionTask.d.ts +10 -0
- package/dist/cjs/core/tasks/PrepareTransactionTask.js +30 -0
- package/dist/cjs/core/tasks/PrepareTransactionTask.js.map +1 -0
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.d.ts +13 -0
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js +63 -0
- package/dist/cjs/core/tasks/WaitForTransactionStatusTask.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/checkBalance.d.ts +30 -0
- package/dist/cjs/core/tasks/helpers/checkBalance.js +108 -0
- package/dist/cjs/core/tasks/helpers/checkBalance.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.d.ts +7 -0
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js +25 -0
- package/dist/cjs/core/tasks/helpers/getTransactionRequestData.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/stepComparison.d.ts +21 -0
- package/dist/cjs/core/tasks/helpers/stepComparison.js +32 -0
- package/dist/cjs/core/tasks/helpers/stepComparison.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.d.ts +9 -0
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js +48 -0
- package/dist/cjs/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
- package/dist/cjs/core/utils.d.ts +17 -86
- package/dist/cjs/core/utils.js +37 -38
- package/dist/cjs/core/utils.js.map +1 -1
- package/dist/cjs/errors/SDKError.d.ts +16 -11
- package/dist/cjs/errors/SDKError.js +22 -21
- package/dist/cjs/errors/SDKError.js.map +1 -1
- package/dist/cjs/errors/baseError.d.ts +10 -5
- package/dist/cjs/errors/baseError.js +17 -18
- package/dist/cjs/errors/baseError.js.map +1 -1
- package/dist/cjs/errors/constants.d.ts +52 -47
- package/dist/cjs/errors/constants.js +60 -55
- package/dist/cjs/errors/constants.js.map +1 -1
- package/dist/cjs/errors/errors.d.ts +31 -16
- package/dist/cjs/errors/errors.js +57 -43
- package/dist/cjs/errors/errors.js.map +1 -1
- package/dist/cjs/errors/httpError.d.ts +21 -17
- package/dist/cjs/errors/httpError.js +63 -66
- package/dist/cjs/errors/httpError.js.map +1 -1
- package/dist/cjs/errors/utils/baseErrorRootCause.d.ts +8 -3
- package/dist/cjs/errors/utils/baseErrorRootCause.js +12 -15
- package/dist/cjs/errors/utils/baseErrorRootCause.js.map +1 -1
- package/dist/cjs/errors/utils/rootCause.d.ts +5 -1
- package/dist/cjs/errors/utils/rootCause.js +7 -8
- package/dist/cjs/errors/utils/rootCause.js.map +1 -1
- package/dist/cjs/index.d.ts +56 -46
- package/dist/cjs/index.js +130 -119
- package/dist/cjs/types/actions.d.ts +32 -7
- package/dist/cjs/types/actions.js +0 -3
- package/dist/cjs/types/core.d.ts +181 -164
- package/dist/cjs/types/core.js +0 -3
- package/dist/cjs/types/execution.d.ts +28 -0
- package/dist/cjs/types/execution.js +0 -0
- package/dist/cjs/types/request.d.ts +6 -2
- package/dist/cjs/types/request.js +0 -3
- package/dist/cjs/utils/checkPackageUpdates.d.ts +5 -1
- package/dist/cjs/utils/checkPackageUpdates.js +11 -16
- package/dist/cjs/utils/checkPackageUpdates.js.map +1 -1
- package/dist/cjs/utils/convertQuoteToRoute.d.ts +20 -5
- package/dist/cjs/utils/convertQuoteToRoute.js +72 -85
- package/dist/cjs/utils/convertQuoteToRoute.js.map +1 -1
- package/dist/cjs/utils/decode.d.ts +5 -1
- package/dist/cjs/utils/decode.js +5 -10
- package/dist/cjs/utils/decode.js.map +1 -1
- package/dist/cjs/utils/fetchTxErrorDetails.d.ts +5 -1
- package/dist/cjs/utils/fetchTxErrorDetails.js +9 -9
- package/dist/cjs/utils/fetchTxErrorDetails.js.map +1 -1
- package/dist/cjs/utils/formatUnits.d.ts +8 -1
- package/dist/cjs/utils/formatUnits.js +15 -15
- package/dist/cjs/utils/formatUnits.js.map +1 -1
- package/dist/cjs/utils/getTransactionMessage.d.ts +8 -3
- package/dist/cjs/utils/getTransactionMessage.js +8 -10
- package/dist/cjs/utils/getTransactionMessage.js.map +1 -1
- package/dist/cjs/utils/isHex.d.ts +9 -3
- package/dist/cjs/utils/isHex.js +8 -10
- package/dist/cjs/utils/isHex.js.map +1 -1
- package/dist/cjs/utils/isRoutesRequest.d.ts +7 -2
- package/dist/cjs/utils/isRoutesRequest.js +7 -14
- package/dist/cjs/utils/isRoutesRequest.js.map +1 -1
- package/dist/cjs/utils/isStep.d.ts +7 -2
- package/dist/cjs/utils/isStep.js +16 -25
- package/dist/cjs/utils/isStep.js.map +1 -1
- package/dist/cjs/utils/isToken.d.ts +7 -2
- package/dist/cjs/utils/isToken.js +6 -7
- package/dist/cjs/utils/isToken.js.map +1 -1
- package/dist/cjs/utils/parseUnits.d.ts +8 -1
- package/dist/cjs/utils/parseUnits.js +32 -41
- package/dist/cjs/utils/parseUnits.js.map +1 -1
- package/dist/cjs/utils/request.d.ts +10 -5
- package/dist/cjs/utils/request.js +53 -69
- package/dist/cjs/utils/request.js.map +1 -1
- package/dist/cjs/utils/sleep.d.ts +5 -1
- package/dist/cjs/utils/sleep.js +8 -6
- package/dist/cjs/utils/sleep.js.map +1 -1
- package/dist/cjs/utils/toQueryString.d.ts +5 -0
- package/dist/cjs/utils/toQueryString.js +17 -0
- package/dist/cjs/utils/toQueryString.js.map +1 -0
- package/dist/cjs/utils/waitForResult.d.ts +14 -1
- package/dist/cjs/utils/waitForResult.js +33 -26
- package/dist/cjs/utils/waitForResult.js.map +1 -1
- package/dist/cjs/utils/withDedupe.d.ts +21 -4
- package/dist/cjs/utils/withDedupe.js +31 -27
- package/dist/cjs/utils/withDedupe.js.map +1 -1
- package/dist/cjs/utils/withTimeout.d.ts +26 -0
- package/dist/cjs/utils/withTimeout.js +35 -0
- package/dist/cjs/utils/withTimeout.js.map +1 -0
- package/dist/cjs/version.d.ts +6 -2
- package/dist/cjs/version.js +8 -5
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/actions/getChains.d.ts +16 -11
- package/dist/esm/actions/getChains.d.ts.map +1 -0
- package/dist/esm/actions/getChains.js +22 -24
- package/dist/esm/actions/getChains.js.map +1 -1
- package/dist/esm/actions/getConnections.d.ts +14 -9
- package/dist/esm/actions/getConnections.d.ts.map +1 -0
- package/dist/esm/actions/getConnections.js +30 -39
- package/dist/esm/actions/getConnections.js.map +1 -1
- package/dist/esm/actions/getContractCallsQuote.d.ts +15 -10
- package/dist/esm/actions/getContractCallsQuote.d.ts.map +1 -0
- package/dist/esm/actions/getContractCallsQuote.js +41 -51
- package/dist/esm/actions/getContractCallsQuote.js.map +1 -1
- package/dist/esm/actions/getGasRecommendation.d.ts +15 -10
- package/dist/esm/actions/getGasRecommendation.d.ts.map +1 -0
- package/dist/esm/actions/getGasRecommendation.js +20 -24
- package/dist/esm/actions/getGasRecommendation.js.map +1 -1
- package/dist/esm/actions/getNameServiceAddress.d.ts +14 -9
- package/dist/esm/actions/getNameServiceAddress.d.ts.map +1 -0
- package/dist/esm/actions/getNameServiceAddress.js +25 -31
- package/dist/esm/actions/getNameServiceAddress.js.map +1 -1
- package/dist/esm/actions/getQuote.d.ts +17 -12
- package/dist/esm/actions/getQuote.d.ts.map +1 -0
- package/dist/esm/actions/getQuote.js +33 -44
- package/dist/esm/actions/getQuote.js.map +1 -1
- package/dist/esm/actions/getRelayedTransactionStatus.d.ts +15 -10
- package/dist/esm/actions/getRelayedTransactionStatus.d.ts.map +1 -0
- package/dist/esm/actions/getRelayedTransactionStatus.js +26 -32
- package/dist/esm/actions/getRelayedTransactionStatus.js.map +1 -1
- package/dist/esm/actions/getRelayerQuote.d.ts +16 -11
- package/dist/esm/actions/getRelayerQuote.d.ts.map +1 -0
- package/dist/esm/actions/getRelayerQuote.js +40 -50
- package/dist/esm/actions/getRelayerQuote.js.map +1 -1
- package/dist/esm/actions/getRoutes.d.ts +16 -10
- package/dist/esm/actions/getRoutes.d.ts.map +1 -0
- package/dist/esm/actions/getRoutes.js +28 -29
- package/dist/esm/actions/getRoutes.js.map +1 -1
- package/dist/esm/actions/getStatus.d.ts +16 -11
- package/dist/esm/actions/getStatus.d.ts.map +1 -0
- package/dist/esm/actions/getStatus.js +18 -19
- package/dist/esm/actions/getStatus.js.map +1 -1
- package/dist/esm/actions/getStepTransaction.d.ts +16 -10
- package/dist/esm/actions/getStepTransaction.d.ts.map +1 -0
- package/dist/esm/actions/getStepTransaction.js +32 -31
- package/dist/esm/actions/getStepTransaction.js.map +1 -1
- package/dist/esm/actions/getToken.d.ts +16 -11
- package/dist/esm/actions/getToken.d.ts.map +1 -0
- package/dist/esm/actions/getToken.js +22 -24
- package/dist/esm/actions/getToken.js.map +1 -1
- package/dist/esm/actions/getTokenBalance.d.ts +16 -11
- package/dist/esm/actions/getTokenBalance.d.ts.map +1 -0
- package/dist/esm/actions/getTokenBalance.js +16 -12
- package/dist/esm/actions/getTokenBalance.js.map +1 -1
- package/dist/esm/actions/getTokenBalances.d.ts +16 -11
- package/dist/esm/actions/getTokenBalances.d.ts.map +1 -0
- package/dist/esm/actions/getTokenBalances.js +12 -12
- package/dist/esm/actions/getTokenBalances.js.map +1 -1
- package/dist/esm/actions/getTokenBalancesByChain.d.ts +18 -13
- package/dist/esm/actions/getTokenBalancesByChain.d.ts.map +1 -0
- package/dist/esm/actions/getTokenBalancesByChain.js +22 -37
- package/dist/esm/actions/getTokenBalancesByChain.js.map +1 -1
- package/dist/esm/actions/getTokens.d.ts +17 -12
- package/dist/esm/actions/getTokens.d.ts.map +1 -0
- package/dist/esm/actions/getTokens.js +14 -16
- package/dist/esm/actions/getTokens.js.map +1 -1
- package/dist/esm/actions/getTools.d.ts +14 -9
- package/dist/esm/actions/getTools.d.ts.map +1 -0
- package/dist/esm/actions/getTools.js +17 -18
- package/dist/esm/actions/getTools.js.map +1 -1
- package/dist/esm/actions/getTransactionHistory.d.ts +25 -15
- package/dist/esm/actions/getTransactionHistory.d.ts.map +1 -0
- package/dist/esm/actions/getTransactionHistory.js +27 -31
- package/dist/esm/actions/getTransactionHistory.js.map +1 -1
- package/dist/esm/actions/getWalletBalances.d.ts +15 -10
- package/dist/esm/actions/getWalletBalances.d.ts.map +1 -0
- package/dist/esm/actions/getWalletBalances.js +16 -17
- package/dist/esm/actions/getWalletBalances.js.map +1 -1
- package/dist/esm/actions/index.d.ts +174 -166
- package/dist/esm/actions/index.d.ts.map +1 -0
- package/dist/esm/actions/index.js +49 -45
- package/dist/esm/actions/index.js.map +1 -1
- package/dist/esm/actions/patchContractCalls.d.ts +14 -9
- package/dist/esm/actions/patchContractCalls.d.ts.map +1 -0
- package/dist/esm/actions/patchContractCalls.js +12 -10
- package/dist/esm/actions/patchContractCalls.js.map +1 -1
- package/dist/esm/actions/relayTransaction.d.ts +15 -10
- package/dist/esm/actions/relayTransaction.d.ts.map +1 -0
- package/dist/esm/actions/relayTransaction.js +30 -41
- package/dist/esm/actions/relayTransaction.js.map +1 -1
- package/dist/esm/client/createClient.d.ts +7 -2
- package/dist/esm/client/createClient.d.ts.map +1 -0
- package/dist/esm/client/createClient.js +67 -74
- package/dist/esm/client/createClient.js.map +1 -1
- package/dist/esm/client/getClientStorage.d.ts +14 -8
- package/dist/esm/client/getClientStorage.d.ts.map +1 -0
- package/dist/esm/client/getClientStorage.js +45 -48
- package/dist/esm/client/getClientStorage.js.map +1 -1
- package/dist/esm/core/BaseStepExecutionTask.d.ts +10 -0
- package/dist/esm/core/BaseStepExecutionTask.d.ts.map +1 -0
- package/dist/esm/core/BaseStepExecutionTask.js +10 -0
- package/dist/esm/core/BaseStepExecutionTask.js.map +1 -0
- package/dist/esm/core/BaseStepExecutor.d.ts +23 -11
- package/dist/esm/core/BaseStepExecutor.d.ts.map +1 -0
- package/dist/esm/core/BaseStepExecutor.js +67 -24
- package/dist/esm/core/BaseStepExecutor.js.map +1 -1
- package/dist/esm/core/StatusManager.d.ts +80 -64
- package/dist/esm/core/StatusManager.d.ts.map +1 -0
- package/dist/esm/core/StatusManager.js +157 -181
- package/dist/esm/core/StatusManager.js.map +1 -1
- package/dist/esm/core/TaskPipeline.d.ts +12 -0
- package/dist/esm/core/TaskPipeline.d.ts.map +1 -0
- package/dist/esm/core/TaskPipeline.js +20 -0
- package/dist/esm/core/TaskPipeline.js.map +1 -0
- package/dist/esm/core/actionMessages.d.ts +9 -4
- package/dist/esm/core/actionMessages.d.ts.map +1 -0
- package/dist/esm/core/actionMessages.js +72 -56
- package/dist/esm/core/actionMessages.js.map +1 -1
- package/dist/esm/core/execution.d.ts +42 -37
- package/dist/esm/core/execution.d.ts.map +1 -0
- package/dist/esm/core/execution.js +126 -162
- package/dist/esm/core/execution.js.map +1 -1
- package/dist/esm/core/executionState.d.ts +17 -13
- package/dist/esm/core/executionState.d.ts.map +1 -0
- package/dist/esm/core/executionState.js +26 -24
- package/dist/esm/core/executionState.js.map +1 -1
- package/dist/esm/core/prepareRestart.d.ts +7 -2
- package/dist/esm/core/prepareRestart.d.ts.map +1 -0
- package/dist/esm/core/prepareRestart.js +18 -20
- package/dist/esm/core/prepareRestart.js.map +1 -1
- package/dist/esm/core/storage.d.ts +21 -0
- package/dist/esm/core/storage.d.ts.map +1 -0
- package/dist/esm/core/storage.js +32 -0
- package/dist/esm/core/storage.js.map +1 -0
- package/dist/esm/core/tasks/CheckBalanceTask.d.ts +19 -0
- package/dist/esm/core/tasks/CheckBalanceTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/CheckBalanceTask.js +34 -0
- package/dist/esm/core/tasks/CheckBalanceTask.js.map +1 -0
- package/dist/esm/core/tasks/PrepareTransactionTask.d.ts +10 -0
- package/dist/esm/core/tasks/PrepareTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/PrepareTransactionTask.js +29 -0
- package/dist/esm/core/tasks/PrepareTransactionTask.js.map +1 -0
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts +13 -0
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.js +61 -0
- package/dist/esm/core/tasks/WaitForTransactionStatusTask.js.map +1 -0
- package/dist/esm/core/tasks/helpers/checkBalance.d.ts +30 -0
- package/dist/esm/core/tasks/helpers/checkBalance.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/checkBalance.js +107 -0
- package/dist/esm/core/tasks/helpers/checkBalance.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts +7 -0
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.js +24 -0
- package/dist/esm/core/tasks/helpers/getTransactionRequestData.js.map +1 -0
- package/dist/esm/core/tasks/helpers/stepComparison.d.ts +21 -0
- package/dist/esm/core/tasks/helpers/stepComparison.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/stepComparison.js +31 -0
- package/dist/esm/core/tasks/helpers/stepComparison.js.map +1 -0
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts +9 -0
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js +47 -0
- package/dist/esm/core/tasks/helpers/waitForTransactionStatus.js.map +1 -0
- package/dist/esm/core/utils.d.ts +16 -93
- package/dist/esm/core/utils.d.ts.map +1 -0
- package/dist/esm/core/utils.js +36 -45
- package/dist/esm/core/utils.js.map +1 -1
- package/dist/esm/errors/SDKError.d.ts +16 -11
- package/dist/esm/errors/SDKError.d.ts.map +1 -0
- package/dist/esm/errors/SDKError.js +22 -20
- package/dist/esm/errors/SDKError.js.map +1 -1
- package/dist/esm/errors/baseError.d.ts +10 -5
- package/dist/esm/errors/baseError.d.ts.map +1 -0
- package/dist/esm/errors/baseError.js +17 -17
- package/dist/esm/errors/baseError.js.map +1 -1
- package/dist/esm/errors/constants.d.ts +52 -47
- package/dist/esm/errors/constants.d.ts.map +1 -0
- package/dist/esm/errors/constants.js +57 -52
- package/dist/esm/errors/constants.js.map +1 -1
- package/dist/esm/errors/errors.d.ts +31 -16
- package/dist/esm/errors/errors.d.ts.map +1 -0
- package/dist/esm/errors/errors.js +53 -37
- package/dist/esm/errors/errors.js.map +1 -1
- package/dist/esm/errors/httpError.d.ts +21 -17
- package/dist/esm/errors/httpError.d.ts.map +1 -0
- package/dist/esm/errors/httpError.js +63 -63
- package/dist/esm/errors/httpError.js.map +1 -1
- package/dist/esm/errors/utils/baseErrorRootCause.d.ts +8 -3
- package/dist/esm/errors/utils/baseErrorRootCause.d.ts.map +1 -0
- package/dist/esm/errors/utils/baseErrorRootCause.js +13 -13
- package/dist/esm/errors/utils/baseErrorRootCause.js.map +1 -1
- package/dist/esm/errors/utils/rootCause.d.ts +5 -1
- package/dist/esm/errors/utils/rootCause.d.ts.map +1 -0
- package/dist/esm/errors/utils/rootCause.js +8 -6
- package/dist/esm/errors/utils/rootCause.js.map +1 -1
- package/dist/esm/index.d.ts +56 -46
- package/dist/esm/index.js +53 -47
- package/dist/esm/package.json +1 -1
- package/dist/esm/types/actions.d.ts +32 -7
- package/dist/esm/types/actions.d.ts.map +1 -0
- package/dist/esm/types/actions.js +0 -1
- package/dist/esm/types/core.d.ts +181 -167
- package/dist/esm/types/core.d.ts.map +1 -0
- package/dist/esm/types/core.js +0 -1
- package/dist/esm/types/execution.d.ts +28 -0
- package/dist/esm/types/execution.d.ts.map +1 -0
- package/dist/esm/types/execution.js +1 -0
- package/dist/esm/types/request.d.ts +6 -2
- package/dist/esm/types/request.d.ts.map +1 -0
- package/dist/esm/types/request.js +0 -1
- package/dist/esm/utils/checkPackageUpdates.d.ts +5 -1
- package/dist/esm/utils/checkPackageUpdates.d.ts.map +1 -0
- package/dist/esm/utils/checkPackageUpdates.js +12 -15
- package/dist/esm/utils/checkPackageUpdates.js.map +1 -1
- package/dist/esm/utils/convertQuoteToRoute.d.ts +19 -15
- package/dist/esm/utils/convertQuoteToRoute.d.ts.map +1 -0
- package/dist/esm/utils/convertQuoteToRoute.js +72 -92
- package/dist/esm/utils/convertQuoteToRoute.js.map +1 -1
- package/dist/esm/utils/decode.d.ts +5 -1
- package/dist/esm/utils/decode.d.ts.map +1 -0
- package/dist/esm/utils/decode.js +6 -8
- package/dist/esm/utils/decode.js.map +1 -1
- package/dist/esm/utils/fetchTxErrorDetails.d.ts +5 -1
- package/dist/esm/utils/fetchTxErrorDetails.d.ts.map +1 -0
- package/dist/esm/utils/fetchTxErrorDetails.js +10 -7
- package/dist/esm/utils/fetchTxErrorDetails.js.map +1 -1
- package/dist/esm/utils/formatUnits.d.ts +7 -3
- package/dist/esm/utils/formatUnits.d.ts.map +1 -0
- package/dist/esm/utils/formatUnits.js +14 -15
- package/dist/esm/utils/formatUnits.js.map +1 -1
- package/dist/esm/utils/getTransactionMessage.d.ts +8 -3
- package/dist/esm/utils/getTransactionMessage.d.ts.map +1 -0
- package/dist/esm/utils/getTransactionMessage.js +9 -8
- package/dist/esm/utils/getTransactionMessage.js.map +1 -1
- package/dist/esm/utils/isHex.d.ts +9 -3
- package/dist/esm/utils/isHex.d.ts.map +1 -0
- package/dist/esm/utils/isHex.js +8 -8
- package/dist/esm/utils/isHex.js.map +1 -1
- package/dist/esm/utils/isRoutesRequest.d.ts +7 -2
- package/dist/esm/utils/isRoutesRequest.d.ts.map +1 -0
- package/dist/esm/utils/isRoutesRequest.js +8 -12
- package/dist/esm/utils/isRoutesRequest.js.map +1 -1
- package/dist/esm/utils/isStep.d.ts +7 -2
- package/dist/esm/utils/isStep.d.ts.map +1 -0
- package/dist/esm/utils/isStep.js +17 -23
- package/dist/esm/utils/isStep.js.map +1 -1
- package/dist/esm/utils/isToken.d.ts +7 -2
- package/dist/esm/utils/isToken.d.ts.map +1 -0
- package/dist/esm/utils/isToken.js +7 -5
- package/dist/esm/utils/isToken.js.map +1 -1
- package/dist/esm/utils/parseUnits.d.ts +7 -3
- package/dist/esm/utils/parseUnits.d.ts.map +1 -0
- package/dist/esm/utils/parseUnits.js +31 -43
- package/dist/esm/utils/parseUnits.js.map +1 -1
- package/dist/esm/utils/request.d.ts +10 -5
- package/dist/esm/utils/request.d.ts.map +1 -0
- package/dist/esm/utils/request.js +52 -67
- package/dist/esm/utils/request.js.map +1 -1
- package/dist/esm/utils/sleep.d.ts +5 -1
- package/dist/esm/utils/sleep.d.ts.map +1 -0
- package/dist/esm/utils/sleep.js +8 -4
- package/dist/esm/utils/sleep.js.map +1 -1
- package/dist/esm/utils/toQueryString.d.ts +5 -0
- package/dist/esm/utils/toQueryString.d.ts.map +1 -0
- package/dist/esm/utils/toQueryString.js +16 -0
- package/dist/esm/utils/toQueryString.js.map +1 -0
- package/dist/esm/utils/waitForResult.d.ts +13 -9
- package/dist/esm/utils/waitForResult.d.ts.map +1 -0
- package/dist/esm/utils/waitForResult.js +32 -31
- package/dist/esm/utils/waitForResult.js.map +1 -1
- package/dist/esm/utils/withDedupe.d.ts +20 -4
- package/dist/esm/utils/withDedupe.d.ts.map +1 -0
- package/dist/esm/utils/withDedupe.js +26 -28
- package/dist/esm/utils/withDedupe.js.map +1 -1
- package/dist/esm/utils/withTimeout.d.ts +26 -0
- package/dist/esm/utils/withTimeout.d.ts.map +1 -0
- package/dist/esm/utils/withTimeout.js +34 -0
- package/dist/esm/utils/withTimeout.js.map +1 -0
- package/dist/esm/version.d.ts +6 -2
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +6 -2
- package/dist/esm/version.js.map +1 -1
- package/package.json +6 -5
- package/src/actions/getChains.ts +2 -1
- package/src/actions/getQuote.ts +7 -3
- package/src/actions/getRelayedTransactionStatus.ts +1 -1
- package/src/actions/getRelayerQuote.ts +4 -1
- package/src/actions/getRoutes.ts +2 -1
- package/src/actions/getStepTransaction.ts +16 -7
- package/src/actions/getTokens.ts +6 -3
- package/src/actions/getTools.ts +2 -1
- package/src/actions/index.ts +8 -5
- package/src/client/createClient.ts +9 -7
- package/src/client/getClientStorage.ts +9 -1
- package/src/core/BaseStepExecutionTask.ts +9 -0
- package/src/core/BaseStepExecutor.ts +90 -2
- package/src/core/StatusManager.ts +62 -61
- package/src/core/TaskPipeline.ts +28 -0
- package/src/core/actionMessages.ts +20 -3
- package/src/core/execution.ts +17 -3
- package/src/core/prepareRestart.ts +3 -4
- package/src/core/storage.ts +42 -0
- package/src/core/tasks/CheckBalanceTask.ts +46 -0
- package/src/core/tasks/PrepareTransactionTask.ts +62 -0
- package/src/core/tasks/WaitForTransactionStatusTask.ts +114 -0
- package/src/core/tasks/helpers/checkBalance.ts +218 -0
- 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} +10 -7
- package/src/core/utils.ts +1 -1
- package/src/errors/constants.ts +1 -0
- package/src/errors/errors.ts +24 -0
- package/src/errors/httpError.ts +4 -6
- package/src/errors/utils/baseErrorRootCause.ts +2 -2
- package/src/errors/utils/rootCause.ts +1 -1
- package/src/index.ts +35 -4
- package/src/types/actions.ts +29 -0
- package/src/types/core.ts +23 -17
- package/src/types/execution.ts +32 -0
- package/src/utils/checkPackageUpdates.ts +1 -1
- package/src/utils/convertQuoteToRoute.ts +1 -1
- package/src/utils/decode.ts +1 -1
- package/src/utils/fetchTxErrorDetails.ts +7 -2
- package/src/utils/formatUnits.ts +1 -1
- package/src/utils/isStep.ts +4 -1
- package/src/utils/parseUnits.ts +1 -1
- package/src/utils/toQueryString.ts +35 -0
- package/src/utils/waitForResult.ts +9 -4
- package/src/utils/withDedupe.ts +2 -2
- package/src/utils/withTimeout.ts +50 -0
- package/src/version.ts +1 -1
- package/dist/cjs/core/checkBalance.d.ts +0 -3
- package/dist/cjs/core/checkBalance.js +0 -37
- package/dist/cjs/core/checkBalance.js.map +0 -1
- package/dist/cjs/core/stepComparison.d.ts +0 -4
- package/dist/cjs/core/stepComparison.js +0 -25
- 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 -71
- package/dist/cjs/core/waitForDestinationChainTransaction.js.map +0 -1
- package/dist/cjs/core/waitForTransactionStatus.d.ts +0 -4
- package/dist/cjs/core/waitForTransactionStatus.js +0 -54
- package/dist/cjs/core/waitForTransactionStatus.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/types/actions.js.map +0 -1
- package/dist/cjs/types/core.js.map +0 -1
- package/dist/cjs/types/request.js.map +0 -1
- package/dist/esm/core/checkBalance.d.ts +0 -3
- package/dist/esm/core/checkBalance.js +0 -34
- package/dist/esm/core/checkBalance.js.map +0 -1
- package/dist/esm/core/stepComparison.d.ts +0 -16
- package/dist/esm/core/stepComparison.js +0 -35
- 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 -74
- package/dist/esm/core/waitForDestinationChainTransaction.js.map +0 -1
- package/dist/esm/core/waitForTransactionStatus.d.ts +0 -4
- package/dist/esm/core/waitForTransactionStatus.js +0 -51
- package/dist/esm/core/waitForTransactionStatus.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/types/actions.js.map +0 -1
- package/dist/esm/types/core.js.map +0 -1
- package/dist/esm/types/request.js.map +0 -1
- package/dist/types/actions/getChains.d.ts +0 -13
- package/dist/types/actions/getChains.d.ts.map +0 -1
- package/dist/types/actions/getConnections.d.ts +0 -11
- package/dist/types/actions/getConnections.d.ts.map +0 -1
- package/dist/types/actions/getContractCallsQuote.d.ts +0 -12
- package/dist/types/actions/getContractCallsQuote.d.ts.map +0 -1
- package/dist/types/actions/getGasRecommendation.d.ts +0 -12
- package/dist/types/actions/getGasRecommendation.d.ts.map +0 -1
- package/dist/types/actions/getNameServiceAddress.d.ts +0 -11
- package/dist/types/actions/getNameServiceAddress.d.ts.map +0 -1
- package/dist/types/actions/getQuote.d.ts +0 -14
- package/dist/types/actions/getQuote.d.ts.map +0 -1
- package/dist/types/actions/getRelayedTransactionStatus.d.ts +0 -12
- package/dist/types/actions/getRelayedTransactionStatus.d.ts.map +0 -1
- package/dist/types/actions/getRelayerQuote.d.ts +0 -13
- package/dist/types/actions/getRelayerQuote.d.ts.map +0 -1
- package/dist/types/actions/getRoutes.d.ts +0 -12
- package/dist/types/actions/getRoutes.d.ts.map +0 -1
- package/dist/types/actions/getStatus.d.ts +0 -13
- package/dist/types/actions/getStatus.d.ts.map +0 -1
- package/dist/types/actions/getStepTransaction.d.ts +0 -12
- package/dist/types/actions/getStepTransaction.d.ts.map +0 -1
- package/dist/types/actions/getToken.d.ts +0 -13
- package/dist/types/actions/getToken.d.ts.map +0 -1
- package/dist/types/actions/getTokenBalance.d.ts +0 -13
- package/dist/types/actions/getTokenBalance.d.ts.map +0 -1
- package/dist/types/actions/getTokenBalances.d.ts +0 -13
- package/dist/types/actions/getTokenBalances.d.ts.map +0 -1
- package/dist/types/actions/getTokenBalancesByChain.d.ts +0 -17
- package/dist/types/actions/getTokenBalancesByChain.d.ts.map +0 -1
- package/dist/types/actions/getTokens.d.ts +0 -16
- package/dist/types/actions/getTokens.d.ts.map +0 -1
- package/dist/types/actions/getTools.d.ts +0 -11
- package/dist/types/actions/getTools.d.ts.map +0 -1
- package/dist/types/actions/getTransactionHistory.d.ts +0 -17
- package/dist/types/actions/getTransactionHistory.d.ts.map +0 -1
- package/dist/types/actions/getWalletBalances.d.ts +0 -12
- package/dist/types/actions/getWalletBalances.d.ts.map +0 -1
- package/dist/types/actions/index.d.ts +0 -168
- package/dist/types/actions/index.d.ts.map +0 -1
- package/dist/types/actions/patchContractCalls.d.ts +0 -11
- package/dist/types/actions/patchContractCalls.d.ts.map +0 -1
- package/dist/types/actions/relayTransaction.d.ts +0 -12
- package/dist/types/actions/relayTransaction.d.ts.map +0 -1
- package/dist/types/client/createClient.d.ts +0 -3
- package/dist/types/client/createClient.d.ts.map +0 -1
- package/dist/types/client/getClientStorage.d.ts +0 -9
- package/dist/types/client/getClientStorage.d.ts.map +0 -1
- package/dist/types/core/BaseStepExecutor.d.ts +0 -13
- package/dist/types/core/BaseStepExecutor.d.ts.map +0 -1
- package/dist/types/core/StatusManager.d.ts +0 -68
- package/dist/types/core/StatusManager.d.ts.map +0 -1
- package/dist/types/core/actionMessages.d.ts +0 -5
- package/dist/types/core/actionMessages.d.ts.map +0 -1
- package/dist/types/core/checkBalance.d.ts +0 -4
- package/dist/types/core/checkBalance.d.ts.map +0 -1
- package/dist/types/core/execution.d.ts +0 -44
- package/dist/types/core/execution.d.ts.map +0 -1
- package/dist/types/core/executionState.d.ts +0 -18
- package/dist/types/core/executionState.d.ts.map +0 -1
- package/dist/types/core/prepareRestart.d.ts +0 -3
- package/dist/types/core/prepareRestart.d.ts.map +0 -1
- package/dist/types/core/stepComparison.d.ts +0 -17
- package/dist/types/core/stepComparison.d.ts.map +0 -1
- package/dist/types/core/utils.d.ts +0 -95
- package/dist/types/core/utils.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/dist/types/errors/SDKError.d.ts +0 -13
- package/dist/types/errors/SDKError.d.ts.map +0 -1
- package/dist/types/errors/baseError.d.ts +0 -7
- package/dist/types/errors/baseError.d.ts.map +0 -1
- package/dist/types/errors/constants.d.ts +0 -51
- package/dist/types/errors/constants.d.ts.map +0 -1
- package/dist/types/errors/errors.d.ts +0 -24
- package/dist/types/errors/errors.d.ts.map +0 -1
- package/dist/types/errors/httpError.d.ts +0 -21
- package/dist/types/errors/httpError.d.ts.map +0 -1
- package/dist/types/errors/utils/baseErrorRootCause.d.ts +0 -4
- package/dist/types/errors/utils/baseErrorRootCause.d.ts.map +0 -1
- package/dist/types/errors/utils/rootCause.d.ts +0 -2
- package/dist/types/errors/utils/rootCause.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -47
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/types/actions.d.ts +0 -10
- package/dist/types/types/actions.d.ts.map +0 -1
- package/dist/types/types/core.d.ts +0 -171
- package/dist/types/types/core.d.ts.map +0 -1
- package/dist/types/types/request.d.ts +0 -4
- package/dist/types/types/request.d.ts.map +0 -1
- package/dist/types/utils/checkPackageUpdates.d.ts +0 -2
- package/dist/types/utils/checkPackageUpdates.d.ts.map +0 -1
- package/dist/types/utils/convertQuoteToRoute.d.ts +0 -19
- package/dist/types/utils/convertQuoteToRoute.d.ts.map +0 -1
- package/dist/types/utils/decode.d.ts +0 -2
- package/dist/types/utils/decode.d.ts.map +0 -1
- package/dist/types/utils/fetchTxErrorDetails.d.ts +0 -2
- package/dist/types/utils/fetchTxErrorDetails.d.ts.map +0 -1
- package/dist/types/utils/formatUnits.d.ts +0 -5
- package/dist/types/utils/formatUnits.d.ts.map +0 -1
- package/dist/types/utils/getTransactionMessage.d.ts +0 -4
- package/dist/types/utils/getTransactionMessage.d.ts.map +0 -1
- package/dist/types/utils/isHex.d.ts +0 -5
- package/dist/types/utils/isHex.d.ts.map +0 -1
- package/dist/types/utils/isRoutesRequest.d.ts +0 -3
- package/dist/types/utils/isRoutesRequest.d.ts.map +0 -1
- package/dist/types/utils/isStep.d.ts +0 -3
- package/dist/types/utils/isStep.d.ts.map +0 -1
- package/dist/types/utils/isToken.d.ts +0 -3
- package/dist/types/utils/isToken.d.ts.map +0 -1
- package/dist/types/utils/parseUnits.d.ts +0 -5
- package/dist/types/utils/parseUnits.d.ts.map +0 -1
- package/dist/types/utils/request.d.ts +0 -7
- package/dist/types/utils/request.d.ts.map +0 -1
- package/dist/types/utils/sleep.d.ts +0 -2
- package/dist/types/utils/sleep.d.ts.map +0 -1
- package/dist/types/utils/waitForResult.d.ts +0 -11
- package/dist/types/utils/waitForResult.d.ts.map +0 -1
- package/dist/types/utils/withDedupe.d.ts +0 -8
- package/dist/types/utils/withDedupe.d.ts.map +0 -1
- package/dist/types/version.d.ts +0 -3
- package/dist/types/version.d.ts.map +0 -1
- package/src/core/checkBalance.ts +0 -51
- package/src/core/waitForDestinationChainTransaction.ts +0 -112
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import type { LiFiStep, Token, TokenAmount } from '@lifi/types'
|
|
2
|
+
import { BalanceError } from '../../../errors/errors.js'
|
|
3
|
+
import type { SDKClient } from '../../../types/core.js'
|
|
4
|
+
import { formatUnits } from '../../../utils/formatUnits.js'
|
|
5
|
+
import { sleep } from '../../../utils/sleep.js'
|
|
6
|
+
import { withTimeout } from '../../../utils/withTimeout.js'
|
|
7
|
+
|
|
8
|
+
const MAX_ATTEMPTS = 6
|
|
9
|
+
// Exponential backoff: 150, 300, 600, 1200, 2400 → ≈4.65s of sleep total.
|
|
10
|
+
const BACKOFF_BASE_MS = 150
|
|
11
|
+
const OVERALL_TIMEOUT_MS = 10_000
|
|
12
|
+
const SLIPPAGE_PRECISION = 1_000_000_000n
|
|
13
|
+
|
|
14
|
+
type Bucket = 'source' | 'gas' | 'fee'
|
|
15
|
+
|
|
16
|
+
type Requirement = {
|
|
17
|
+
token: Token
|
|
18
|
+
sourcePart: bigint // step.action.fromAmount
|
|
19
|
+
gasPart: bigint // step.estimate.gasCosts in this token
|
|
20
|
+
feePart: bigint // non-included step.estimate.feeCosts in this token
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type CheckBalanceOptions = {
|
|
24
|
+
/**
|
|
25
|
+
* Set to `false` when outer-tx gas is paid by something other than
|
|
26
|
+
* `walletAddress` (SCA executor, 4337 bundler / paymaster, relayer):
|
|
27
|
+
* `gasPart` is excluded from the sufficiency check and slippage rescue.
|
|
28
|
+
* Source amount and non-included fees (e.g. LZ `msg.value`) are still
|
|
29
|
+
* verified. Defaults to `true` (strict, today's behavior).
|
|
30
|
+
*/
|
|
31
|
+
walletPaysGas?: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Verifies that the wallet holds enough of every token required to execute
|
|
36
|
+
* the step on its source chain — the source-token amount, any gas costs, and
|
|
37
|
+
* any non-included fee costs. Reads all balances in one batched provider
|
|
38
|
+
* call, retries within a bounded budget to absorb transient RPC failures and
|
|
39
|
+
* post-confirmation propagation lag, and applies slippage to the source-token
|
|
40
|
+
* portion only as a last resort (overhead is never trimmed).
|
|
41
|
+
*
|
|
42
|
+
* Throws BalanceError("The balance is too low.") on a genuine shortfall, or
|
|
43
|
+
* BalanceError("Could not read wallet balance.") if the balance can't be read
|
|
44
|
+
* after retries.
|
|
45
|
+
*/
|
|
46
|
+
export const checkBalance = async (
|
|
47
|
+
client: SDKClient,
|
|
48
|
+
walletAddress: string,
|
|
49
|
+
step: LiFiStep,
|
|
50
|
+
options: CheckBalanceOptions = {}
|
|
51
|
+
): Promise<void> => {
|
|
52
|
+
const fromChainId = step.action.fromChainId
|
|
53
|
+
// Chains with non-standard native decimals (e.g. Tempo, Stable) report
|
|
54
|
+
// gas costs in units that don't align with wallet balances — drop the
|
|
55
|
+
// gas portion of the check on those chains.
|
|
56
|
+
const fromChain = await client.getChainById(fromChainId)
|
|
57
|
+
const walletPaysGas =
|
|
58
|
+
(options.walletPaysGas ?? true) && !fromChain.nonStandardNativeDecimals
|
|
59
|
+
const requirements = new Map<string, Requirement>()
|
|
60
|
+
const add = (token: Token, amount: bigint, bucket: Bucket): void => {
|
|
61
|
+
if (token.chainId !== fromChainId || amount === 0n) {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
const key = token.address.toLowerCase()
|
|
65
|
+
const req = requirements.get(key) ?? {
|
|
66
|
+
token,
|
|
67
|
+
sourcePart: 0n,
|
|
68
|
+
gasPart: 0n,
|
|
69
|
+
feePart: 0n,
|
|
70
|
+
}
|
|
71
|
+
if (bucket === 'source') {
|
|
72
|
+
req.sourcePart += amount
|
|
73
|
+
} else if (bucket === 'gas') {
|
|
74
|
+
req.gasPart += amount
|
|
75
|
+
} else {
|
|
76
|
+
req.feePart += amount
|
|
77
|
+
}
|
|
78
|
+
requirements.set(key, req)
|
|
79
|
+
}
|
|
80
|
+
add(step.action.fromToken, BigInt(step.action.fromAmount), 'source')
|
|
81
|
+
for (const gas of step.estimate?.gasCosts ?? []) {
|
|
82
|
+
add(gas.token, BigInt(gas.amount), 'gas')
|
|
83
|
+
}
|
|
84
|
+
for (const fee of step.estimate?.feeCosts ?? []) {
|
|
85
|
+
// Included fees are already part of fromAmount — don't count twice.
|
|
86
|
+
if (!fee.included) {
|
|
87
|
+
add(fee.token, BigInt(fee.amount), 'fee')
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const reservedOverhead = (r: Requirement): bigint =>
|
|
92
|
+
r.feePart + (walletPaysGas ? r.gasPart : 0n)
|
|
93
|
+
const need = (r: Requirement): bigint => r.sourcePart + reservedOverhead(r)
|
|
94
|
+
|
|
95
|
+
// Drop pure-gas entries when `walletPaysGas` is false (e.g. native ETH
|
|
96
|
+
// on Safe Apps with only `gasPart`) — saves one balance read each.
|
|
97
|
+
for (const [key, req] of requirements) {
|
|
98
|
+
if (need(req) === 0n) {
|
|
99
|
+
requirements.delete(key)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (requirements.size === 0) {
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Provider is dispatched by wallet address; all requirements share the
|
|
108
|
+
// source chain, which matches this provider by virtue of the address.
|
|
109
|
+
const provider = client.providers.find((p) => p.isAddress(walletAddress))
|
|
110
|
+
if (!provider) {
|
|
111
|
+
throw new Error(`SDK Token Provider for ${walletAddress} is not found.`)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const reqs = Array.from(requirements.values())
|
|
115
|
+
const tokens = reqs.map((r) => r.token)
|
|
116
|
+
const slippage = step.action.slippage ?? 0
|
|
117
|
+
const slippageScaled = BigInt(
|
|
118
|
+
Math.floor((1 - slippage) * Number(SLIPPAGE_PRECISION))
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
await withTimeout(
|
|
122
|
+
async () => {
|
|
123
|
+
for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
|
|
124
|
+
const isFinal = attempt === MAX_ATTEMPTS - 1
|
|
125
|
+
|
|
126
|
+
let balances: TokenAmount[]
|
|
127
|
+
try {
|
|
128
|
+
balances = await provider.getBalance(client, walletAddress, tokens)
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (isFinal) {
|
|
131
|
+
throw new BalanceError(
|
|
132
|
+
'Could not read wallet balance.',
|
|
133
|
+
error as Error
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
await sleep(BACKOFF_BASE_MS * 2 ** attempt)
|
|
137
|
+
continue
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const balanceByAddress = new Map(
|
|
141
|
+
balances.map((b) => [b.address.toLowerCase(), b.amount] as const)
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
const unknown: Token[] = []
|
|
145
|
+
const insufficient: { req: Requirement; have: bigint }[] = []
|
|
146
|
+
for (const req of reqs) {
|
|
147
|
+
const have = balanceByAddress.get(req.token.address.toLowerCase())
|
|
148
|
+
if (have === undefined) {
|
|
149
|
+
unknown.push(req.token)
|
|
150
|
+
} else if (have < need(req)) {
|
|
151
|
+
insufficient.push({ req, have })
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (unknown.length === 0 && insufficient.length === 0) {
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Final-attempt slippage rescue: only when the sole shortfall is
|
|
160
|
+
// the source-token portion. Trim source to (balance − reserved
|
|
161
|
+
// overhead) so the overhead reserve is preserved.
|
|
162
|
+
if (
|
|
163
|
+
isFinal &&
|
|
164
|
+
unknown.length === 0 &&
|
|
165
|
+
insufficient.length === 1 &&
|
|
166
|
+
insufficient[0].req.sourcePart > 0n
|
|
167
|
+
) {
|
|
168
|
+
const { req, have } = insufficient[0]
|
|
169
|
+
const reserved = reservedOverhead(req)
|
|
170
|
+
const minAcceptable =
|
|
171
|
+
(req.sourcePart * slippageScaled) / SLIPPAGE_PRECISION + reserved
|
|
172
|
+
if (have >= minAcceptable) {
|
|
173
|
+
const newFromAmount = (have - reserved).toString()
|
|
174
|
+
step.action.fromAmount = newFromAmount
|
|
175
|
+
if (step.includedSteps?.length) {
|
|
176
|
+
step.includedSteps[0].action.fromAmount = newFromAmount
|
|
177
|
+
}
|
|
178
|
+
return
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (isFinal) {
|
|
183
|
+
if (unknown.length > 0) {
|
|
184
|
+
throw new BalanceError(
|
|
185
|
+
'Could not read wallet balance.',
|
|
186
|
+
new Error(
|
|
187
|
+
`Could not read balance for: ${unknown
|
|
188
|
+
.map((t) => t.symbol || t.address)
|
|
189
|
+
.join(', ')}.`
|
|
190
|
+
)
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
const lines = insufficient.map(({ req, have }) => {
|
|
194
|
+
const needed = formatUnits(need(req), req.token.decimals)
|
|
195
|
+
const current = formatUnits(have, req.token.decimals)
|
|
196
|
+
const symbol = req.token.symbol
|
|
197
|
+
// The "fees" branch covers pure-overhead tokens; with
|
|
198
|
+
// walletPaysGas=false, gas is excluded from `need(req)` so it
|
|
199
|
+
// only fires for genuine fee shortfalls.
|
|
200
|
+
return req.sourcePart > 0n
|
|
201
|
+
? `Your ${symbol} balance is too low, you try to transfer ${needed} ${symbol}, but your wallet only holds ${current} ${symbol}.`
|
|
202
|
+
: `Insufficient ${symbol} for fees: need ${needed} ${symbol}, have ${current} ${symbol}.`
|
|
203
|
+
})
|
|
204
|
+
throw new BalanceError(
|
|
205
|
+
'The balance is too low.',
|
|
206
|
+
new Error(`${lines.join(' ')} No funds have been sent.`)
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
await sleep(BACKOFF_BASE_MS * 2 ** attempt)
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
timeout: OVERALL_TIMEOUT_MS,
|
|
215
|
+
errorInstance: new BalanceError('Could not read wallet balance.'),
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LiFiErrorCode } from '../../../errors/constants.js'
|
|
2
|
+
import { TransactionError } from '../../../errors/errors.js'
|
|
3
|
+
import type {
|
|
4
|
+
ExecutionOptions,
|
|
5
|
+
LiFiStepExtended,
|
|
6
|
+
TransactionParameters,
|
|
7
|
+
} from '../../../types/core.js'
|
|
8
|
+
|
|
9
|
+
export const getTransactionRequestData = async (
|
|
10
|
+
step: LiFiStepExtended,
|
|
11
|
+
executionOptions?: ExecutionOptions
|
|
12
|
+
): Promise<string> => {
|
|
13
|
+
if (!step.transactionRequest?.data) {
|
|
14
|
+
throw new TransactionError(
|
|
15
|
+
LiFiErrorCode.TransactionUnprepared,
|
|
16
|
+
'Unable to prepare transaction. Transaction request data is not found.'
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let transactionRequest: TransactionParameters = {
|
|
21
|
+
data: step.transactionRequest.data,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (executionOptions?.updateTransactionRequestHook) {
|
|
25
|
+
const customizedTransactionRequest: TransactionParameters =
|
|
26
|
+
await executionOptions.updateTransactionRequestHook({
|
|
27
|
+
requestType: 'transaction',
|
|
28
|
+
...transactionRequest,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
transactionRequest = {
|
|
32
|
+
...transactionRequest,
|
|
33
|
+
...customizedTransactionRequest,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const transactionRequestData = transactionRequest.data
|
|
38
|
+
|
|
39
|
+
if (!transactionRequestData) {
|
|
40
|
+
throw new TransactionError(
|
|
41
|
+
LiFiErrorCode.TransactionUnprepared,
|
|
42
|
+
'Unable to prepare transaction. Transaction request data is not found.'
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return transactionRequestData
|
|
47
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { LiFiStep } from '@lifi/types'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
2
|
+
import type { StatusManager } from '../../../core/StatusManager.js'
|
|
3
|
+
import { checkStepSlippageThreshold } from '../../../core/utils.js'
|
|
4
|
+
import { LiFiErrorCode } from '../../../errors/constants.js'
|
|
5
|
+
import { TransactionError } from '../../../errors/errors.js'
|
|
6
|
+
import type { ExecutionOptions } from '../../../types/core.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* This method checks whether the new and updated Step meets the required exchange rate conditions.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { FullStatusData, LiFiStep, StatusResponse } from '@lifi/types'
|
|
2
|
-
import { getStatus } from '
|
|
3
|
-
import { ServerError } from '
|
|
4
|
-
import type { ExecutionActionType, SDKClient } from '
|
|
5
|
-
import { waitForResult } from '
|
|
6
|
-
import { getSubstatusMessage } from '
|
|
7
|
-
import type { StatusManager } from '
|
|
2
|
+
import { getStatus } from '../../../actions/getStatus.js'
|
|
3
|
+
import { ServerError } from '../../../errors/errors.js'
|
|
4
|
+
import type { ExecutionActionType, SDKClient } from '../../../types/core.js'
|
|
5
|
+
import { waitForResult } from '../../../utils/waitForResult.js'
|
|
6
|
+
import { getSubstatusMessage } from '../../actionMessages.js'
|
|
7
|
+
import type { StatusManager } from '../../StatusManager.js'
|
|
8
8
|
|
|
9
9
|
const TRANSACTION_HASH_OBSERVERS: Record<string, Promise<StatusResponse>> = {}
|
|
10
10
|
|
|
@@ -23,6 +23,7 @@ export async function waitForTransactionStatus(
|
|
|
23
23
|
toChain: step.action.toChainId,
|
|
24
24
|
txHash,
|
|
25
25
|
...(step.tool !== 'custom' && { bridge: step.tool }),
|
|
26
|
+
...(step.transactionId && { transactionId: step.transactionId }),
|
|
26
27
|
})
|
|
27
28
|
.then((statusResponse) => {
|
|
28
29
|
switch (statusResponse.status) {
|
|
@@ -57,7 +58,9 @@ export async function waitForTransactionStatus(
|
|
|
57
58
|
let status = TRANSACTION_HASH_OBSERVERS[txHash]
|
|
58
59
|
|
|
59
60
|
if (!status) {
|
|
60
|
-
status = waitForResult(_getStatus, interval)
|
|
61
|
+
status = waitForResult(_getStatus, interval).finally(() => {
|
|
62
|
+
delete TRANSACTION_HASH_OBSERVERS[txHash]
|
|
63
|
+
})
|
|
61
64
|
TRANSACTION_HASH_OBSERVERS[txHash] = status
|
|
62
65
|
}
|
|
63
66
|
|
package/src/core/utils.ts
CHANGED
|
@@ -34,7 +34,7 @@ export function getRpcUrlsFromChains(
|
|
|
34
34
|
existingRpcUrls: RPCUrls,
|
|
35
35
|
chains: ExtendedChain[],
|
|
36
36
|
skipChains?: ChainId[]
|
|
37
|
-
) {
|
|
37
|
+
): RPCUrls {
|
|
38
38
|
const rpcUrlsFromChains = chains.reduce((rpcUrls, chain) => {
|
|
39
39
|
if (chain.metamask?.rpcUrls?.length) {
|
|
40
40
|
rpcUrls[chain.id as ChainId] = chain.metamask.rpcUrls
|
package/src/errors/constants.ts
CHANGED
package/src/errors/errors.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExecuteStepRetryParams } from '../types/core.js'
|
|
1
2
|
import { BaseError } from './baseError.js'
|
|
2
3
|
import { ErrorName, LiFiErrorCode } from './constants.js'
|
|
3
4
|
|
|
@@ -42,3 +43,26 @@ export class ValidationError extends BaseError {
|
|
|
42
43
|
super(ErrorName.ValidationError, LiFiErrorCode.ValidationError, message)
|
|
43
44
|
}
|
|
44
45
|
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Thrown by a step executor when executeStep should be retried with the given params
|
|
49
|
+
* (e.g. wallet rejected 7702 upgrade → retry with atomicityNotReady).
|
|
50
|
+
* The execution layer catches this and retries executeStep(client, step, retryParams).
|
|
51
|
+
*/
|
|
52
|
+
export class ExecuteStepRetryError extends BaseError {
|
|
53
|
+
readonly retryParams: ExecuteStepRetryParams
|
|
54
|
+
|
|
55
|
+
constructor(
|
|
56
|
+
message: string,
|
|
57
|
+
retryParams: ExecuteStepRetryParams,
|
|
58
|
+
cause?: Error
|
|
59
|
+
) {
|
|
60
|
+
super(
|
|
61
|
+
ErrorName.ExecuteStepRetryError,
|
|
62
|
+
LiFiErrorCode.InternalError,
|
|
63
|
+
message,
|
|
64
|
+
cause
|
|
65
|
+
)
|
|
66
|
+
this.retryParams = retryParams
|
|
67
|
+
}
|
|
68
|
+
}
|
package/src/errors/httpError.ts
CHANGED
|
@@ -74,7 +74,7 @@ export class HTTPError extends BaseError {
|
|
|
74
74
|
this.fetchOptions = options
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
async buildAdditionalDetails() {
|
|
77
|
+
async buildAdditionalDetails(): Promise<void> {
|
|
78
78
|
if (this.type) {
|
|
79
79
|
this.message = `[${this.type}] ${this.message}`
|
|
80
80
|
}
|
|
@@ -82,13 +82,11 @@ export class HTTPError extends BaseError {
|
|
|
82
82
|
try {
|
|
83
83
|
this.responseBody = await this.response.json()
|
|
84
84
|
|
|
85
|
-
if (this.responseBody) {
|
|
85
|
+
if (this.responseBody?.message) {
|
|
86
86
|
this.message += this.message.endsWith('.')
|
|
87
|
-
? ` ${this.responseBody
|
|
88
|
-
: `. ${this.responseBody
|
|
87
|
+
? ` ${this.responseBody.message.toString()}`
|
|
88
|
+
: `. ${this.responseBody.message.toString()}`
|
|
89
89
|
}
|
|
90
90
|
} catch {}
|
|
91
|
-
|
|
92
|
-
return this
|
|
93
91
|
}
|
|
94
92
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseError } from '../baseError.js'
|
|
2
2
|
import { HTTPError } from '../httpError.js'
|
|
3
3
|
|
|
4
|
-
export const getRootCauseBaseError = (e: Error) => {
|
|
4
|
+
export const getRootCauseBaseError = (e: Error): BaseError => {
|
|
5
5
|
let rootCause = e
|
|
6
6
|
while (rootCause.cause && rootCause.cause instanceof BaseError) {
|
|
7
7
|
rootCause = rootCause.cause as BaseError
|
|
@@ -9,7 +9,7 @@ export const getRootCauseBaseError = (e: Error) => {
|
|
|
9
9
|
return rootCause as BaseError
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const getRootCauseBaseErrorMessage = (e: Error) => {
|
|
12
|
+
export const getRootCauseBaseErrorMessage = (e: Error): string => {
|
|
13
13
|
const rootCause = getRootCauseBaseError(e)
|
|
14
14
|
|
|
15
15
|
return rootCause instanceof HTTPError
|
package/src/index.ts
CHANGED
|
@@ -24,8 +24,9 @@ export { actions } from './actions/index.js'
|
|
|
24
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 {
|
|
30
31
|
executeRoute,
|
|
31
32
|
getActiveRoute,
|
|
@@ -35,13 +36,28 @@ export {
|
|
|
35
36
|
updateRouteExecution,
|
|
36
37
|
} from './core/execution.js'
|
|
37
38
|
export { StatusManager } from './core/StatusManager.js'
|
|
38
|
-
export {
|
|
39
|
-
export {
|
|
39
|
+
export type { SDKStorage } from './core/storage.js'
|
|
40
|
+
export {
|
|
41
|
+
createDefaultStorage,
|
|
42
|
+
InMemoryStorage,
|
|
43
|
+
LocalStorageAdapter,
|
|
44
|
+
} from './core/storage.js'
|
|
45
|
+
export { TaskPipeline } from './core/TaskPipeline.js'
|
|
46
|
+
export { CheckBalanceTask } from './core/tasks/CheckBalanceTask.js'
|
|
47
|
+
export {
|
|
48
|
+
type CheckBalanceOptions,
|
|
49
|
+
checkBalance,
|
|
50
|
+
} from './core/tasks/helpers/checkBalance.js'
|
|
51
|
+
export { getTransactionRequestData } from './core/tasks/helpers/getTransactionRequestData.js'
|
|
52
|
+
export { stepComparison } from './core/tasks/helpers/stepComparison.js'
|
|
53
|
+
export { PrepareTransactionTask } from './core/tasks/PrepareTransactionTask.js'
|
|
54
|
+
export { WaitForTransactionStatusTask } from './core/tasks/WaitForTransactionStatusTask.js'
|
|
40
55
|
export { BaseError } from './errors/baseError.js'
|
|
41
56
|
export type { ErrorCode } from './errors/constants.js'
|
|
42
57
|
export { ErrorMessage, ErrorName, LiFiErrorCode } from './errors/constants.js'
|
|
43
58
|
export {
|
|
44
59
|
BalanceError,
|
|
60
|
+
ExecuteStepRetryError,
|
|
45
61
|
ProviderError,
|
|
46
62
|
RPCError,
|
|
47
63
|
ServerError,
|
|
@@ -51,6 +67,13 @@ export {
|
|
|
51
67
|
} from './errors/errors.js'
|
|
52
68
|
export { HTTPError } from './errors/httpError.js'
|
|
53
69
|
export { SDKError } from './errors/SDKError.js'
|
|
70
|
+
export type {
|
|
71
|
+
GetStatusRequestExtended,
|
|
72
|
+
LiFiStepRequest,
|
|
73
|
+
QuoteRequest,
|
|
74
|
+
QuoteRequestFromAmount,
|
|
75
|
+
QuoteRequestToAmount,
|
|
76
|
+
} from './types/actions.js'
|
|
54
77
|
export type {
|
|
55
78
|
AcceptExchangeRateUpdateHook,
|
|
56
79
|
AcceptSlippageUpdateHook,
|
|
@@ -58,6 +81,7 @@ export type {
|
|
|
58
81
|
ContractCallParams,
|
|
59
82
|
ContractTool,
|
|
60
83
|
ExchangeRateUpdateParams,
|
|
84
|
+
ExecuteStepRetryParams,
|
|
61
85
|
Execution,
|
|
62
86
|
ExecutionAction,
|
|
63
87
|
ExecutionActionStatus,
|
|
@@ -87,6 +111,12 @@ export type {
|
|
|
87
111
|
TransactionRequestUpdateHook,
|
|
88
112
|
UpdateRouteHook,
|
|
89
113
|
} from './types/core.js'
|
|
114
|
+
export type {
|
|
115
|
+
StepExecutorBaseContext,
|
|
116
|
+
StepExecutorContext,
|
|
117
|
+
TaskResult,
|
|
118
|
+
TaskStatus,
|
|
119
|
+
} from './types/execution.js'
|
|
90
120
|
export { checkPackageUpdates } from './utils/checkPackageUpdates.js'
|
|
91
121
|
export { convertQuoteToRoute } from './utils/convertQuoteToRoute.js'
|
|
92
122
|
export { fetchTxErrorDetails } from './utils/fetchTxErrorDetails.js'
|
|
@@ -95,4 +125,5 @@ export { isHex } from './utils/isHex.js'
|
|
|
95
125
|
export { parseUnits } from './utils/parseUnits.js'
|
|
96
126
|
export { sleep } from './utils/sleep.js'
|
|
97
127
|
export { waitForResult } from './utils/waitForResult.js'
|
|
98
|
-
export { withDedupe } from './utils/withDedupe.js'
|
|
128
|
+
export { LruMap, withDedupe } from './utils/withDedupe.js'
|
|
129
|
+
export { withTimeout } from './utils/withTimeout.js'
|
package/src/types/actions.ts
CHANGED
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
Action,
|
|
2
3
|
GetStatusRequest,
|
|
4
|
+
LiFiStep,
|
|
3
5
|
QuoteRequest as QuoteRequestBase,
|
|
6
|
+
RoutesRequest as RoutesRequestBase,
|
|
7
|
+
SignedLiFiStep,
|
|
4
8
|
} from '@lifi/types'
|
|
5
9
|
|
|
6
10
|
export type GetStatusRequestExtended = GetStatusRequest & {
|
|
7
11
|
fromAddress?: string
|
|
8
12
|
}
|
|
9
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Optional limit-order fields. Supplying them opts a request into limit-order
|
|
16
|
+
* handling; resolution happens on the backend.
|
|
17
|
+
*/
|
|
18
|
+
type OrderFields = {
|
|
19
|
+
toAmount?: string
|
|
20
|
+
validUntil?: number
|
|
21
|
+
partiallyFillable?: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type RoutesRequest = Omit<RoutesRequestBase, 'options'> &
|
|
25
|
+
OrderFields & {
|
|
26
|
+
options?: RoutesRequestBase['options'] & {
|
|
27
|
+
/** (default: false) Whether to request private routes */
|
|
28
|
+
private?: boolean
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A step request that may carry the optional limit-order `action` fields.
|
|
34
|
+
*/
|
|
35
|
+
export type LiFiStepRequest = (LiFiStep | SignedLiFiStep) & {
|
|
36
|
+
action: Action & OrderFields
|
|
37
|
+
}
|
|
38
|
+
|
|
10
39
|
export type QuoteRequestFromAmount = QuoteRequestBase
|
|
11
40
|
|
|
12
41
|
export type QuoteRequestToAmount = Omit<QuoteRequestBase, 'fromAmount'> & {
|
package/src/types/core.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
Token,
|
|
15
15
|
TokenAmount,
|
|
16
16
|
} from '@lifi/types'
|
|
17
|
+
import type { SDKStorage } from '../core/storage.js'
|
|
17
18
|
import type { ExtendedRequestInit } from './request.js'
|
|
18
19
|
|
|
19
20
|
export type RequestInterceptor = (
|
|
@@ -34,10 +35,12 @@ export interface SDKBaseConfig {
|
|
|
34
35
|
preloadChains?: boolean
|
|
35
36
|
chainsRefetchInterval?: number
|
|
36
37
|
requestInterceptor?: RequestInterceptor
|
|
38
|
+
storage?: SDKStorage
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
export interface SDKConfig extends Partial<Omit<SDKBaseConfig, 'integrator'>> {
|
|
40
42
|
integrator: string
|
|
43
|
+
providers?: SDKProvider[]
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export type RPCUrls = Partial<Record<ChainId, string[]>>
|
|
@@ -82,13 +85,20 @@ export interface InteractionSettings {
|
|
|
82
85
|
allowExecution?: boolean
|
|
83
86
|
}
|
|
84
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Params passed when retrying executeStep after an ExecuteStepRetryError.
|
|
90
|
+
* Providers can use this to pass strategy-specific retry options (e.g. atomicityNotReady for Ethereum 7702).
|
|
91
|
+
*/
|
|
92
|
+
export type ExecuteStepRetryParams = Record<string, unknown>
|
|
93
|
+
|
|
85
94
|
export interface StepExecutor {
|
|
86
95
|
allowUserInteraction: boolean
|
|
87
96
|
allowExecution: boolean
|
|
88
97
|
setInteraction(settings?: InteractionSettings): void
|
|
89
98
|
executeStep(
|
|
90
99
|
client: SDKClient,
|
|
91
|
-
step: LiFiStepExtended
|
|
100
|
+
step: LiFiStepExtended,
|
|
101
|
+
retryParams?: ExecuteStepRetryParams
|
|
92
102
|
): Promise<LiFiStepExtended>
|
|
93
103
|
}
|
|
94
104
|
|
|
@@ -195,11 +205,6 @@ export interface ExecutionOptions {
|
|
|
195
205
|
getContractCalls?: GetContractCallsHook
|
|
196
206
|
adjustZeroOutputFromPreviousStep?: boolean
|
|
197
207
|
executeInBackground?: boolean
|
|
198
|
-
disableMessageSigning?: boolean
|
|
199
|
-
/**
|
|
200
|
-
* @deprecated
|
|
201
|
-
*/
|
|
202
|
-
infiniteApproval?: boolean
|
|
203
208
|
}
|
|
204
209
|
|
|
205
210
|
export type ExecutionStatus = 'ACTION_REQUIRED' | 'PENDING' | 'FAILED' | 'DONE'
|
|
@@ -215,8 +220,11 @@ export type ExecutionActionStatus =
|
|
|
215
220
|
| 'CANCELLED'
|
|
216
221
|
|
|
217
222
|
export type ExecutionActionType =
|
|
218
|
-
| 'TOKEN_ALLOWANCE'
|
|
219
223
|
| 'PERMIT'
|
|
224
|
+
| 'CHECK_ALLOWANCE'
|
|
225
|
+
| 'NATIVE_PERMIT'
|
|
226
|
+
| 'RESET_ALLOWANCE'
|
|
227
|
+
| 'SET_ALLOWANCE'
|
|
220
228
|
| 'SWAP'
|
|
221
229
|
| 'CROSS_CHAIN'
|
|
222
230
|
| 'RECEIVING_CHAIN'
|
|
@@ -224,21 +232,17 @@ export type ExecutionActionType =
|
|
|
224
232
|
export type ExecutionAction = {
|
|
225
233
|
type: ExecutionActionType
|
|
226
234
|
status: ExecutionActionStatus
|
|
235
|
+
message?: string
|
|
227
236
|
substatus?: Substatus
|
|
237
|
+
substatusMessage?: string
|
|
228
238
|
chainId?: number
|
|
229
239
|
txHash?: string
|
|
230
|
-
taskId?: string
|
|
231
240
|
txLink?: string
|
|
241
|
+
taskId?: string
|
|
232
242
|
txType?: TransactionMethodType
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
message: string
|
|
237
|
-
htmlMessage?: string
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// additional information
|
|
241
|
-
[key: string]: any
|
|
243
|
+
txHex?: string
|
|
244
|
+
// Errors occured during the action execution (within tasks)
|
|
245
|
+
error?: { code: string | number; message: string; htmlMessage?: string }
|
|
242
246
|
}
|
|
243
247
|
|
|
244
248
|
export interface Execution {
|
|
@@ -253,6 +257,8 @@ export interface Execution {
|
|
|
253
257
|
gasCosts?: GasCost[]
|
|
254
258
|
internalTxLink?: string
|
|
255
259
|
externalTxLink?: string
|
|
260
|
+
// Errors occured outside of actions (e.g. during context creation)
|
|
261
|
+
error?: { code: string | number; message: string; htmlMessage?: string }
|
|
256
262
|
}
|
|
257
263
|
|
|
258
264
|
export type TransactionMethodType = 'standard' | 'relayed' | 'batched'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ExtendedChain } from '@lifi/types'
|
|
2
|
+
import type { StatusManager } from '../core/StatusManager.js'
|
|
3
|
+
import type {
|
|
4
|
+
ExecuteStepRetryParams,
|
|
5
|
+
ExecutionOptions,
|
|
6
|
+
LiFiStepExtended,
|
|
7
|
+
SDKClient,
|
|
8
|
+
} from './core.js'
|
|
9
|
+
|
|
10
|
+
export interface StepExecutorBaseContext {
|
|
11
|
+
statusManager: StatusManager
|
|
12
|
+
executionOptions?: ExecutionOptions
|
|
13
|
+
fromChain: ExtendedChain
|
|
14
|
+
toChain: ExtendedChain
|
|
15
|
+
isBridgeExecution: boolean
|
|
16
|
+
client: SDKClient
|
|
17
|
+
step: LiFiStepExtended
|
|
18
|
+
allowUserInteraction: boolean
|
|
19
|
+
retryParams?: ExecuteStepRetryParams
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface StepExecutorContext extends StepExecutorBaseContext {
|
|
23
|
+
pollingIntervalMs?: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface TaskResult<TContext = Record<string, unknown>> {
|
|
27
|
+
status: TaskStatus
|
|
28
|
+
/** Optional: data produced for downstream tasks. Pipeline merges into the executor context. */
|
|
29
|
+
context?: TContext
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type TaskStatus = 'COMPLETED' | 'PAUSED'
|