@lifi/sdk 0.0.0-preview-f5cf9f8
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 +1213 -0
- package/LICENSE +201 -0
- package/README.md +79 -0
- package/dist/cjs/actions/getChains.d.ts +17 -0
- package/dist/cjs/actions/getChains.js +28 -0
- package/dist/cjs/actions/getChains.js.map +1 -0
- package/dist/cjs/actions/getConnections.d.ts +15 -0
- package/dist/cjs/actions/getConnections.js +34 -0
- package/dist/cjs/actions/getConnections.js.map +1 -0
- package/dist/cjs/actions/getContractCallsQuote.d.ts +16 -0
- package/dist/cjs/actions/getContractCallsQuote.js +45 -0
- package/dist/cjs/actions/getContractCallsQuote.js.map +1 -0
- package/dist/cjs/actions/getGasRecommendation.d.ts +16 -0
- package/dist/cjs/actions/getGasRecommendation.js +24 -0
- package/dist/cjs/actions/getGasRecommendation.js.map +1 -0
- package/dist/cjs/actions/getNameServiceAddress.d.ts +15 -0
- package/dist/cjs/actions/getNameServiceAddress.js +29 -0
- package/dist/cjs/actions/getNameServiceAddress.js.map +1 -0
- package/dist/cjs/actions/getQuote.d.ts +18 -0
- package/dist/cjs/actions/getQuote.js +35 -0
- package/dist/cjs/actions/getQuote.js.map +1 -0
- package/dist/cjs/actions/getRelayedTransactionStatus.d.ts +16 -0
- package/dist/cjs/actions/getRelayedTransactionStatus.js +30 -0
- package/dist/cjs/actions/getRelayedTransactionStatus.js.map +1 -0
- package/dist/cjs/actions/getRelayerQuote.d.ts +17 -0
- package/dist/cjs/actions/getRelayerQuote.js +44 -0
- package/dist/cjs/actions/getRelayerQuote.js.map +1 -0
- package/dist/cjs/actions/getRoutes.d.ts +16 -0
- package/dist/cjs/actions/getRoutes.js +32 -0
- package/dist/cjs/actions/getRoutes.js.map +1 -0
- package/dist/cjs/actions/getStatus.d.ts +17 -0
- package/dist/cjs/actions/getStatus.js +22 -0
- package/dist/cjs/actions/getStatus.js.map +1 -0
- package/dist/cjs/actions/getStepTransaction.d.ts +16 -0
- package/dist/cjs/actions/getStepTransaction.js +36 -0
- package/dist/cjs/actions/getStepTransaction.js.map +1 -0
- package/dist/cjs/actions/getToken.d.ts +17 -0
- package/dist/cjs/actions/getToken.js +26 -0
- package/dist/cjs/actions/getToken.js.map +1 -0
- package/dist/cjs/actions/getTokenBalance.d.ts +17 -0
- package/dist/cjs/actions/getTokenBalance.js +20 -0
- package/dist/cjs/actions/getTokenBalance.js.map +1 -0
- package/dist/cjs/actions/getTokenBalances.d.ts +17 -0
- package/dist/cjs/actions/getTokenBalances.js +15 -0
- package/dist/cjs/actions/getTokenBalances.js.map +1 -0
- package/dist/cjs/actions/getTokenBalancesByChain.d.ts +21 -0
- package/dist/cjs/actions/getTokenBalancesByChain.js +25 -0
- package/dist/cjs/actions/getTokenBalancesByChain.js.map +1 -0
- package/dist/cjs/actions/getTokens.d.ts +20 -0
- package/dist/cjs/actions/getTokens.js +17 -0
- package/dist/cjs/actions/getTokens.js.map +1 -0
- package/dist/cjs/actions/getTools.d.ts +15 -0
- package/dist/cjs/actions/getTools.js +21 -0
- package/dist/cjs/actions/getTools.js.map +1 -0
- package/dist/cjs/actions/getTransactionHistory.d.ts +26 -0
- package/dist/cjs/actions/getTransactionHistory.js +31 -0
- package/dist/cjs/actions/getTransactionHistory.js.map +1 -0
- package/dist/cjs/actions/getWalletBalances.d.ts +16 -0
- package/dist/cjs/actions/getWalletBalances.js +20 -0
- package/dist/cjs/actions/getWalletBalances.js.map +1 -0
- package/dist/cjs/actions/index.d.ts +172 -0
- package/dist/cjs/actions/index.js +52 -0
- package/dist/cjs/actions/index.js.map +1 -0
- package/dist/cjs/actions/patchContractCalls.d.ts +15 -0
- package/dist/cjs/actions/patchContractCalls.js +15 -0
- package/dist/cjs/actions/patchContractCalls.js.map +1 -0
- package/dist/cjs/actions/relayTransaction.d.ts +16 -0
- package/dist/cjs/actions/relayTransaction.js +34 -0
- package/dist/cjs/actions/relayTransaction.js.map +1 -0
- package/dist/cjs/client/createClient.d.ts +7 -0
- package/dist/cjs/client/createClient.js +70 -0
- package/dist/cjs/client/createClient.js.map +1 -0
- package/dist/cjs/client/getClientStorage.d.ts +14 -0
- package/dist/cjs/client/getClientStorage.js +48 -0
- package/dist/cjs/client/getClientStorage.js.map +1 -0
- 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 +24 -0
- package/dist/cjs/core/BaseStepExecutor.js +71 -0
- package/dist/cjs/core/BaseStepExecutor.js.map +1 -0
- package/dist/cjs/core/StatusManager.d.ts +83 -0
- package/dist/cjs/core/StatusManager.js +160 -0
- package/dist/cjs/core/StatusManager.js.map +1 -0
- 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 -0
- package/dist/cjs/core/actionMessages.js +81 -0
- package/dist/cjs/core/actionMessages.js.map +1 -0
- package/dist/cjs/core/execution.d.ts +48 -0
- package/dist/cjs/core/execution.js +147 -0
- package/dist/cjs/core/execution.js.map +1 -0
- package/dist/cjs/core/executionState.d.ts +21 -0
- package/dist/cjs/core/executionState.js +29 -0
- package/dist/cjs/core/executionState.js.map +1 -0
- package/dist/cjs/core/prepareRestart.d.ts +7 -0
- package/dist/cjs/core/prepareRestart.js +21 -0
- package/dist/cjs/core/prepareRestart.js.map +1 -0
- 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 -0
- package/dist/cjs/core/utils.js +42 -0
- package/dist/cjs/core/utils.js.map +1 -0
- package/dist/cjs/errors/SDKError.d.ts +17 -0
- package/dist/cjs/errors/SDKError.js +24 -0
- package/dist/cjs/errors/SDKError.js.map +1 -0
- package/dist/cjs/errors/baseError.d.ts +11 -0
- package/dist/cjs/errors/baseError.js +19 -0
- package/dist/cjs/errors/baseError.js.map +1 -0
- package/dist/cjs/errors/constants.d.ts +55 -0
- package/dist/cjs/errors/constants.js +61 -0
- package/dist/cjs/errors/constants.js.map +1 -0
- package/dist/cjs/errors/errors.d.ts +38 -0
- package/dist/cjs/errors/errors.js +62 -0
- package/dist/cjs/errors/errors.js.map +1 -0
- package/dist/cjs/errors/httpError.d.ts +24 -0
- package/dist/cjs/errors/httpError.js +70 -0
- package/dist/cjs/errors/httpError.js.map +1 -0
- package/dist/cjs/errors/utils/baseErrorRootCause.d.ts +8 -0
- package/dist/cjs/errors/utils/baseErrorRootCause.js +18 -0
- package/dist/cjs/errors/utils/baseErrorRootCause.js.map +1 -0
- package/dist/cjs/errors/utils/rootCause.d.ts +5 -0
- package/dist/cjs/errors/utils/rootCause.js +11 -0
- package/dist/cjs/errors/utils/rootCause.js.map +1 -0
- package/dist/cjs/index.d.ts +55 -0
- package/dist/cjs/index.js +130 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types/actions.d.ts +14 -0
- package/dist/cjs/types/actions.js +0 -0
- package/dist/cjs/types/core.d.ts +184 -0
- package/dist/cjs/types/core.js +0 -0
- package/dist/cjs/types/execution.d.ts +28 -0
- package/dist/cjs/types/execution.js +0 -0
- package/dist/cjs/types/request.d.ts +7 -0
- package/dist/cjs/types/request.js +0 -0
- package/dist/cjs/utils/checkPackageUpdates.d.ts +5 -0
- package/dist/cjs/utils/checkPackageUpdates.js +15 -0
- package/dist/cjs/utils/checkPackageUpdates.js.map +1 -0
- package/dist/cjs/utils/convertQuoteToRoute.d.ts +22 -0
- package/dist/cjs/utils/convertQuoteToRoute.js +88 -0
- package/dist/cjs/utils/convertQuoteToRoute.js.map +1 -0
- package/dist/cjs/utils/decode.d.ts +5 -0
- package/dist/cjs/utils/decode.js +9 -0
- package/dist/cjs/utils/decode.js.map +1 -0
- package/dist/cjs/utils/fetchTxErrorDetails.d.ts +5 -0
- package/dist/cjs/utils/fetchTxErrorDetails.js +13 -0
- package/dist/cjs/utils/fetchTxErrorDetails.js.map +1 -0
- package/dist/cjs/utils/formatUnits.d.ts +8 -0
- package/dist/cjs/utils/formatUnits.js +18 -0
- package/dist/cjs/utils/formatUnits.js.map +1 -0
- package/dist/cjs/utils/getTransactionMessage.d.ts +8 -0
- package/dist/cjs/utils/getTransactionMessage.js +12 -0
- package/dist/cjs/utils/getTransactionMessage.js.map +1 -0
- package/dist/cjs/utils/isHex.d.ts +10 -0
- package/dist/cjs/utils/isHex.js +11 -0
- package/dist/cjs/utils/isHex.js.map +1 -0
- package/dist/cjs/utils/isRoutesRequest.d.ts +7 -0
- package/dist/cjs/utils/isRoutesRequest.js +11 -0
- package/dist/cjs/utils/isRoutesRequest.js.map +1 -0
- package/dist/cjs/utils/isStep.d.ts +7 -0
- package/dist/cjs/utils/isStep.js +23 -0
- package/dist/cjs/utils/isStep.js.map +1 -0
- package/dist/cjs/utils/isToken.d.ts +7 -0
- package/dist/cjs/utils/isToken.js +10 -0
- package/dist/cjs/utils/isToken.js.map +1 -0
- package/dist/cjs/utils/parseUnits.d.ts +8 -0
- package/dist/cjs/utils/parseUnits.js +35 -0
- package/dist/cjs/utils/parseUnits.js.map +1 -0
- package/dist/cjs/utils/request.d.ts +11 -0
- package/dist/cjs/utils/request.js +56 -0
- package/dist/cjs/utils/request.js.map +1 -0
- package/dist/cjs/utils/sleep.d.ts +5 -0
- package/dist/cjs/utils/sleep.js +11 -0
- package/dist/cjs/utils/sleep.js.map +1 -0
- package/dist/cjs/utils/waitForResult.d.ts +14 -0
- package/dist/cjs/utils/waitForResult.js +36 -0
- package/dist/cjs/utils/waitForResult.js.map +1 -0
- package/dist/cjs/utils/withDedupe.d.ts +23 -0
- package/dist/cjs/utils/withDedupe.js +34 -0
- package/dist/cjs/utils/withDedupe.js.map +1 -0
- 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 -0
- package/dist/cjs/version.js +9 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/actions/getChains.d.ts +17 -0
- package/dist/esm/actions/getChains.d.ts.map +1 -0
- package/dist/esm/actions/getChains.js +26 -0
- package/dist/esm/actions/getChains.js.map +1 -0
- package/dist/esm/actions/getConnections.d.ts +15 -0
- package/dist/esm/actions/getConnections.d.ts.map +1 -0
- package/dist/esm/actions/getConnections.js +33 -0
- package/dist/esm/actions/getConnections.js.map +1 -0
- package/dist/esm/actions/getContractCallsQuote.d.ts +16 -0
- package/dist/esm/actions/getContractCallsQuote.d.ts.map +1 -0
- package/dist/esm/actions/getContractCallsQuote.js +44 -0
- package/dist/esm/actions/getContractCallsQuote.js.map +1 -0
- package/dist/esm/actions/getGasRecommendation.d.ts +16 -0
- package/dist/esm/actions/getGasRecommendation.d.ts.map +1 -0
- package/dist/esm/actions/getGasRecommendation.js +23 -0
- package/dist/esm/actions/getGasRecommendation.js.map +1 -0
- package/dist/esm/actions/getNameServiceAddress.d.ts +15 -0
- package/dist/esm/actions/getNameServiceAddress.d.ts.map +1 -0
- package/dist/esm/actions/getNameServiceAddress.js +28 -0
- package/dist/esm/actions/getNameServiceAddress.js.map +1 -0
- package/dist/esm/actions/getQuote.d.ts +18 -0
- package/dist/esm/actions/getQuote.d.ts.map +1 -0
- package/dist/esm/actions/getQuote.js +34 -0
- package/dist/esm/actions/getQuote.js.map +1 -0
- package/dist/esm/actions/getRelayedTransactionStatus.d.ts +16 -0
- package/dist/esm/actions/getRelayedTransactionStatus.d.ts.map +1 -0
- package/dist/esm/actions/getRelayedTransactionStatus.js +29 -0
- package/dist/esm/actions/getRelayedTransactionStatus.js.map +1 -0
- package/dist/esm/actions/getRelayerQuote.d.ts +17 -0
- package/dist/esm/actions/getRelayerQuote.d.ts.map +1 -0
- package/dist/esm/actions/getRelayerQuote.js +43 -0
- package/dist/esm/actions/getRelayerQuote.js.map +1 -0
- package/dist/esm/actions/getRoutes.d.ts +16 -0
- package/dist/esm/actions/getRoutes.d.ts.map +1 -0
- package/dist/esm/actions/getRoutes.js +31 -0
- package/dist/esm/actions/getRoutes.js.map +1 -0
- package/dist/esm/actions/getStatus.d.ts +17 -0
- package/dist/esm/actions/getStatus.d.ts.map +1 -0
- package/dist/esm/actions/getStatus.js +21 -0
- package/dist/esm/actions/getStatus.js.map +1 -0
- package/dist/esm/actions/getStepTransaction.d.ts +16 -0
- package/dist/esm/actions/getStepTransaction.d.ts.map +1 -0
- package/dist/esm/actions/getStepTransaction.js +35 -0
- package/dist/esm/actions/getStepTransaction.js.map +1 -0
- package/dist/esm/actions/getToken.d.ts +17 -0
- package/dist/esm/actions/getToken.d.ts.map +1 -0
- package/dist/esm/actions/getToken.js +25 -0
- package/dist/esm/actions/getToken.js.map +1 -0
- package/dist/esm/actions/getTokenBalance.d.ts +17 -0
- package/dist/esm/actions/getTokenBalance.d.ts.map +1 -0
- package/dist/esm/actions/getTokenBalance.js +19 -0
- package/dist/esm/actions/getTokenBalance.js.map +1 -0
- package/dist/esm/actions/getTokenBalances.d.ts +17 -0
- package/dist/esm/actions/getTokenBalances.d.ts.map +1 -0
- package/dist/esm/actions/getTokenBalances.js +14 -0
- package/dist/esm/actions/getTokenBalances.js.map +1 -0
- package/dist/esm/actions/getTokenBalancesByChain.d.ts +21 -0
- package/dist/esm/actions/getTokenBalancesByChain.d.ts.map +1 -0
- package/dist/esm/actions/getTokenBalancesByChain.js +24 -0
- package/dist/esm/actions/getTokenBalancesByChain.js.map +1 -0
- package/dist/esm/actions/getTokens.d.ts +20 -0
- package/dist/esm/actions/getTokens.d.ts.map +1 -0
- package/dist/esm/actions/getTokens.js +16 -0
- package/dist/esm/actions/getTokens.js.map +1 -0
- package/dist/esm/actions/getTools.d.ts +15 -0
- package/dist/esm/actions/getTools.d.ts.map +1 -0
- package/dist/esm/actions/getTools.js +20 -0
- package/dist/esm/actions/getTools.js.map +1 -0
- package/dist/esm/actions/getTransactionHistory.d.ts +26 -0
- package/dist/esm/actions/getTransactionHistory.d.ts.map +1 -0
- package/dist/esm/actions/getTransactionHistory.js +30 -0
- package/dist/esm/actions/getTransactionHistory.js.map +1 -0
- package/dist/esm/actions/getWalletBalances.d.ts +16 -0
- package/dist/esm/actions/getWalletBalances.d.ts.map +1 -0
- package/dist/esm/actions/getWalletBalances.js +19 -0
- package/dist/esm/actions/getWalletBalances.js.map +1 -0
- package/dist/esm/actions/index.d.ts +172 -0
- package/dist/esm/actions/index.d.ts.map +1 -0
- package/dist/esm/actions/index.js +51 -0
- package/dist/esm/actions/index.js.map +1 -0
- package/dist/esm/actions/patchContractCalls.d.ts +15 -0
- package/dist/esm/actions/patchContractCalls.d.ts.map +1 -0
- package/dist/esm/actions/patchContractCalls.js +14 -0
- package/dist/esm/actions/patchContractCalls.js.map +1 -0
- package/dist/esm/actions/relayTransaction.d.ts +16 -0
- package/dist/esm/actions/relayTransaction.d.ts.map +1 -0
- package/dist/esm/actions/relayTransaction.js +33 -0
- package/dist/esm/actions/relayTransaction.js.map +1 -0
- package/dist/esm/client/createClient.d.ts +7 -0
- package/dist/esm/client/createClient.d.ts.map +1 -0
- package/dist/esm/client/createClient.js +69 -0
- package/dist/esm/client/createClient.js.map +1 -0
- package/dist/esm/client/getClientStorage.d.ts +14 -0
- package/dist/esm/client/getClientStorage.d.ts.map +1 -0
- package/dist/esm/client/getClientStorage.js +47 -0
- package/dist/esm/client/getClientStorage.js.map +1 -0
- 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 +24 -0
- package/dist/esm/core/BaseStepExecutor.d.ts.map +1 -0
- package/dist/esm/core/BaseStepExecutor.js +70 -0
- package/dist/esm/core/BaseStepExecutor.js.map +1 -0
- package/dist/esm/core/StatusManager.d.ts +83 -0
- package/dist/esm/core/StatusManager.d.ts.map +1 -0
- package/dist/esm/core/StatusManager.js +159 -0
- package/dist/esm/core/StatusManager.js.map +1 -0
- 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 -0
- package/dist/esm/core/actionMessages.d.ts.map +1 -0
- package/dist/esm/core/actionMessages.js +79 -0
- package/dist/esm/core/actionMessages.js.map +1 -0
- package/dist/esm/core/execution.d.ts +48 -0
- package/dist/esm/core/execution.d.ts.map +1 -0
- package/dist/esm/core/execution.js +141 -0
- package/dist/esm/core/execution.js.map +1 -0
- package/dist/esm/core/executionState.d.ts +21 -0
- package/dist/esm/core/executionState.d.ts.map +1 -0
- package/dist/esm/core/executionState.js +28 -0
- package/dist/esm/core/executionState.js.map +1 -0
- package/dist/esm/core/prepareRestart.d.ts +7 -0
- package/dist/esm/core/prepareRestart.d.ts.map +1 -0
- package/dist/esm/core/prepareRestart.js +20 -0
- package/dist/esm/core/prepareRestart.js.map +1 -0
- 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 +17 -0
- package/dist/esm/core/utils.d.ts.map +1 -0
- package/dist/esm/core/utils.js +40 -0
- package/dist/esm/core/utils.js.map +1 -0
- package/dist/esm/errors/SDKError.d.ts +17 -0
- package/dist/esm/errors/SDKError.d.ts.map +1 -0
- package/dist/esm/errors/SDKError.js +23 -0
- package/dist/esm/errors/SDKError.js.map +1 -0
- package/dist/esm/errors/baseError.d.ts +11 -0
- package/dist/esm/errors/baseError.d.ts.map +1 -0
- package/dist/esm/errors/baseError.js +18 -0
- package/dist/esm/errors/baseError.js.map +1 -0
- package/dist/esm/errors/constants.d.ts +55 -0
- package/dist/esm/errors/constants.d.ts.map +1 -0
- package/dist/esm/errors/constants.js +58 -0
- package/dist/esm/errors/constants.js.map +1 -0
- package/dist/esm/errors/errors.d.ts +38 -0
- package/dist/esm/errors/errors.d.ts.map +1 -0
- package/dist/esm/errors/errors.js +54 -0
- package/dist/esm/errors/errors.js.map +1 -0
- package/dist/esm/errors/httpError.d.ts +24 -0
- package/dist/esm/errors/httpError.d.ts.map +1 -0
- package/dist/esm/errors/httpError.js +69 -0
- package/dist/esm/errors/httpError.js.map +1 -0
- package/dist/esm/errors/utils/baseErrorRootCause.d.ts +8 -0
- package/dist/esm/errors/utils/baseErrorRootCause.d.ts.map +1 -0
- package/dist/esm/errors/utils/baseErrorRootCause.js +16 -0
- package/dist/esm/errors/utils/baseErrorRootCause.js.map +1 -0
- package/dist/esm/errors/utils/rootCause.d.ts +5 -0
- package/dist/esm/errors/utils/rootCause.d.ts.map +1 -0
- package/dist/esm/errors/utils/rootCause.js +10 -0
- package/dist/esm/errors/utils/rootCause.js.map +1 -0
- package/dist/esm/index.d.ts +55 -0
- package/dist/esm/index.js +53 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/types/actions.d.ts +14 -0
- package/dist/esm/types/actions.d.ts.map +1 -0
- package/dist/esm/types/actions.js +1 -0
- package/dist/esm/types/core.d.ts +184 -0
- package/dist/esm/types/core.d.ts.map +1 -0
- package/dist/esm/types/core.js +1 -0
- 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 +7 -0
- package/dist/esm/types/request.d.ts.map +1 -0
- package/dist/esm/types/request.js +1 -0
- package/dist/esm/utils/checkPackageUpdates.d.ts +5 -0
- package/dist/esm/utils/checkPackageUpdates.d.ts.map +1 -0
- package/dist/esm/utils/checkPackageUpdates.js +14 -0
- package/dist/esm/utils/checkPackageUpdates.js.map +1 -0
- package/dist/esm/utils/convertQuoteToRoute.d.ts +22 -0
- package/dist/esm/utils/convertQuoteToRoute.d.ts.map +1 -0
- package/dist/esm/utils/convertQuoteToRoute.js +86 -0
- package/dist/esm/utils/convertQuoteToRoute.js.map +1 -0
- package/dist/esm/utils/decode.d.ts +5 -0
- package/dist/esm/utils/decode.d.ts.map +1 -0
- package/dist/esm/utils/decode.js +8 -0
- package/dist/esm/utils/decode.js.map +1 -0
- package/dist/esm/utils/fetchTxErrorDetails.d.ts +5 -0
- package/dist/esm/utils/fetchTxErrorDetails.d.ts.map +1 -0
- package/dist/esm/utils/fetchTxErrorDetails.js +12 -0
- package/dist/esm/utils/fetchTxErrorDetails.js.map +1 -0
- package/dist/esm/utils/formatUnits.d.ts +8 -0
- package/dist/esm/utils/formatUnits.d.ts.map +1 -0
- package/dist/esm/utils/formatUnits.js +17 -0
- package/dist/esm/utils/formatUnits.js.map +1 -0
- package/dist/esm/utils/getTransactionMessage.d.ts +8 -0
- package/dist/esm/utils/getTransactionMessage.d.ts.map +1 -0
- package/dist/esm/utils/getTransactionMessage.js +11 -0
- package/dist/esm/utils/getTransactionMessage.js.map +1 -0
- package/dist/esm/utils/isHex.d.ts +10 -0
- package/dist/esm/utils/isHex.d.ts.map +1 -0
- package/dist/esm/utils/isHex.js +10 -0
- package/dist/esm/utils/isHex.js.map +1 -0
- package/dist/esm/utils/isRoutesRequest.d.ts +7 -0
- package/dist/esm/utils/isRoutesRequest.d.ts.map +1 -0
- package/dist/esm/utils/isRoutesRequest.js +10 -0
- package/dist/esm/utils/isRoutesRequest.js.map +1 -0
- package/dist/esm/utils/isStep.d.ts +7 -0
- package/dist/esm/utils/isStep.d.ts.map +1 -0
- package/dist/esm/utils/isStep.js +22 -0
- package/dist/esm/utils/isStep.js.map +1 -0
- package/dist/esm/utils/isToken.d.ts +7 -0
- package/dist/esm/utils/isToken.d.ts.map +1 -0
- package/dist/esm/utils/isToken.js +9 -0
- package/dist/esm/utils/isToken.js.map +1 -0
- package/dist/esm/utils/parseUnits.d.ts +8 -0
- package/dist/esm/utils/parseUnits.d.ts.map +1 -0
- package/dist/esm/utils/parseUnits.js +34 -0
- package/dist/esm/utils/parseUnits.js.map +1 -0
- package/dist/esm/utils/request.d.ts +11 -0
- package/dist/esm/utils/request.d.ts.map +1 -0
- package/dist/esm/utils/request.js +54 -0
- package/dist/esm/utils/request.js.map +1 -0
- package/dist/esm/utils/sleep.d.ts +5 -0
- package/dist/esm/utils/sleep.d.ts.map +1 -0
- package/dist/esm/utils/sleep.js +10 -0
- package/dist/esm/utils/sleep.js.map +1 -0
- package/dist/esm/utils/waitForResult.d.ts +14 -0
- package/dist/esm/utils/waitForResult.d.ts.map +1 -0
- package/dist/esm/utils/waitForResult.js +35 -0
- package/dist/esm/utils/waitForResult.js.map +1 -0
- package/dist/esm/utils/withDedupe.d.ts +23 -0
- package/dist/esm/utils/withDedupe.d.ts.map +1 -0
- package/dist/esm/utils/withDedupe.js +32 -0
- package/dist/esm/utils/withDedupe.js.map +1 -0
- 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 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +7 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +75 -0
- package/src/actions/getChains.ts +55 -0
- package/src/actions/getConnections.ts +55 -0
- package/src/actions/getContractCallsQuote.ts +81 -0
- package/src/actions/getGasRecommendation.ts +47 -0
- package/src/actions/getNameServiceAddress.ts +42 -0
- package/src/actions/getQuote.ts +105 -0
- package/src/actions/getRelayedTransactionStatus.ts +67 -0
- package/src/actions/getRelayerQuote.ts +86 -0
- package/src/actions/getRoutes.ts +43 -0
- package/src/actions/getStatus.ts +41 -0
- package/src/actions/getStepTransaction.ts +52 -0
- package/src/actions/getToken.ts +47 -0
- package/src/actions/getTokenBalance.ts +21 -0
- package/src/actions/getTokenBalances.ts +47 -0
- package/src/actions/getTokenBalancesByChain.ts +76 -0
- package/src/actions/getTokens.ts +57 -0
- package/src/actions/getTools.ts +34 -0
- package/src/actions/getTransactionHistory.ts +54 -0
- package/src/actions/getWalletBalances.ts +36 -0
- package/src/actions/index.ts +347 -0
- package/src/actions/patchContractCalls.ts +30 -0
- package/src/actions/relayTransaction.ts +74 -0
- package/src/client/createClient.ts +100 -0
- package/src/client/getClientStorage.ts +65 -0
- package/src/core/BaseStepExecutionTask.ts +9 -0
- package/src/core/BaseStepExecutor.ts +129 -0
- package/src/core/StatusManager.ts +245 -0
- package/src/core/TaskPipeline.ts +28 -0
- package/src/core/actionMessages.ts +103 -0
- package/src/core/execution.ts +243 -0
- package/src/core/executionState.ts +48 -0
- package/src/core/prepareRestart.ts +28 -0
- 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/tasks/helpers/stepComparison.ts +50 -0
- package/src/core/tasks/helpers/waitForTransactionStatus.ts +76 -0
- package/src/core/utils.ts +59 -0
- package/src/errors/SDKError.ts +26 -0
- package/src/errors/baseError.ts +22 -0
- package/src/errors/constants.ts +54 -0
- package/src/errors/errors.ts +68 -0
- package/src/errors/httpError.ts +92 -0
- package/src/errors/utils/baseErrorRootCause.ts +18 -0
- package/src/errors/utils/rootCause.ts +7 -0
- package/src/index.ts +122 -0
- package/src/types/actions.ts +16 -0
- package/src/types/core.ts +264 -0
- package/src/types/execution.ts +32 -0
- package/src/types/request.ts +3 -0
- package/src/utils/checkPackageUpdates.ts +22 -0
- package/src/utils/convertQuoteToRoute.ts +154 -0
- package/src/utils/decode.ts +13 -0
- package/src/utils/fetchTxErrorDetails.ts +15 -0
- package/src/utils/formatUnits.ts +22 -0
- package/src/utils/getTransactionMessage.ts +17 -0
- package/src/utils/isHex.ts +14 -0
- package/src/utils/isRoutesRequest.ts +31 -0
- package/src/utils/isStep.ts +41 -0
- package/src/utils/isToken.ts +11 -0
- package/src/utils/parseUnits.ts +50 -0
- package/src/utils/request.ts +100 -0
- package/src/utils/sleep.ts +5 -0
- package/src/utils/waitForResult.ts +45 -0
- package/src/utils/withDedupe.ts +45 -0
- package/src/utils/withTimeout.ts +50 -0
- package/src/version.ts +2 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { UnavailableRoutes } from '@lifi/types'
|
|
2
|
+
import type { ExtendedRequestInit } from '../types/request.js'
|
|
3
|
+
import { BaseError } from './baseError.js'
|
|
4
|
+
import { ErrorMessage, ErrorName, LiFiErrorCode } from './constants.js'
|
|
5
|
+
|
|
6
|
+
interface ServerErrorResponseBody {
|
|
7
|
+
code: number
|
|
8
|
+
message: string
|
|
9
|
+
errors?: UnavailableRoutes
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const statusCodeToErrorClassificationMap = new Map([
|
|
13
|
+
[
|
|
14
|
+
400,
|
|
15
|
+
{ type: ErrorName.ValidationError, code: LiFiErrorCode.ValidationError },
|
|
16
|
+
],
|
|
17
|
+
[404, { type: ErrorName.NotFoundError, code: LiFiErrorCode.NotFound }],
|
|
18
|
+
[
|
|
19
|
+
409,
|
|
20
|
+
{
|
|
21
|
+
type: ErrorName.SlippageError,
|
|
22
|
+
code: LiFiErrorCode.SlippageError,
|
|
23
|
+
message: ErrorMessage.SlippageError,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
[424, { type: ErrorName.ServerError, code: LiFiErrorCode.ThirdPartyError }],
|
|
27
|
+
[429, { type: ErrorName.ServerError, code: LiFiErrorCode.RateLimitExceeded }],
|
|
28
|
+
[500, { type: ErrorName.ServerError, code: LiFiErrorCode.InternalError }],
|
|
29
|
+
])
|
|
30
|
+
|
|
31
|
+
const getErrorClassificationFromStatusCode = (code: number) =>
|
|
32
|
+
statusCodeToErrorClassificationMap.get(code) ?? {
|
|
33
|
+
type: ErrorName.ServerError,
|
|
34
|
+
code: LiFiErrorCode.InternalError,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const createInitialMessage = (response: Response) => {
|
|
38
|
+
const statusCode =
|
|
39
|
+
response.status || response.status === 0 ? response.status : ''
|
|
40
|
+
const title = response.statusText || ''
|
|
41
|
+
const status = `${statusCode} ${title}`.trim()
|
|
42
|
+
const reason = status ? `status code ${status}` : 'an unknown error'
|
|
43
|
+
return `Request failed with ${reason}`
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class HTTPError extends BaseError {
|
|
47
|
+
public response: Response
|
|
48
|
+
public status: number
|
|
49
|
+
public url: RequestInfo | URL
|
|
50
|
+
public fetchOptions: ExtendedRequestInit
|
|
51
|
+
public type?: ErrorName
|
|
52
|
+
public responseBody?: ServerErrorResponseBody
|
|
53
|
+
|
|
54
|
+
constructor(
|
|
55
|
+
response: Response,
|
|
56
|
+
url: RequestInfo | URL,
|
|
57
|
+
options: ExtendedRequestInit
|
|
58
|
+
) {
|
|
59
|
+
const errorClassification = getErrorClassificationFromStatusCode(
|
|
60
|
+
response.status
|
|
61
|
+
)
|
|
62
|
+
const additionalMessage = errorClassification?.message
|
|
63
|
+
? `\n${errorClassification.message}`
|
|
64
|
+
: ''
|
|
65
|
+
const message = createInitialMessage(response) + additionalMessage
|
|
66
|
+
|
|
67
|
+
super(ErrorName.HTTPError, errorClassification.code, message)
|
|
68
|
+
|
|
69
|
+
this.type = errorClassification.type
|
|
70
|
+
this.response = response
|
|
71
|
+
this.status = response.status
|
|
72
|
+
this.message = message
|
|
73
|
+
this.url = url
|
|
74
|
+
this.fetchOptions = options
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async buildAdditionalDetails(): Promise<void> {
|
|
78
|
+
if (this.type) {
|
|
79
|
+
this.message = `[${this.type}] ${this.message}`
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
this.responseBody = await this.response.json()
|
|
84
|
+
|
|
85
|
+
if (this.responseBody?.message) {
|
|
86
|
+
this.message += this.message.endsWith('.')
|
|
87
|
+
? ` ${this.responseBody.message.toString()}`
|
|
88
|
+
: `. ${this.responseBody.message.toString()}`
|
|
89
|
+
}
|
|
90
|
+
} catch {}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseError } from '../baseError.js'
|
|
2
|
+
import { HTTPError } from '../httpError.js'
|
|
3
|
+
|
|
4
|
+
export const getRootCauseBaseError = (e: Error): BaseError => {
|
|
5
|
+
let rootCause = e
|
|
6
|
+
while (rootCause.cause && rootCause.cause instanceof BaseError) {
|
|
7
|
+
rootCause = rootCause.cause as BaseError
|
|
8
|
+
}
|
|
9
|
+
return rootCause as BaseError
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const getRootCauseBaseErrorMessage = (e: Error): string => {
|
|
13
|
+
const rootCause = getRootCauseBaseError(e)
|
|
14
|
+
|
|
15
|
+
return rootCause instanceof HTTPError
|
|
16
|
+
? (rootCause as HTTPError).responseBody?.message || rootCause.message
|
|
17
|
+
: rootCause.message
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// biome-ignore lint/performance/noBarrelFile: module entrypoint
|
|
2
|
+
// biome-ignore lint/performance/noReExportAll: types
|
|
3
|
+
export * from '@lifi/types'
|
|
4
|
+
export { getChains } from './actions/getChains.js'
|
|
5
|
+
export { getConnections } from './actions/getConnections.js'
|
|
6
|
+
export { getContractCallsQuote } from './actions/getContractCallsQuote.js'
|
|
7
|
+
export { getGasRecommendation } from './actions/getGasRecommendation.js'
|
|
8
|
+
export { getNameServiceAddress } from './actions/getNameServiceAddress.js'
|
|
9
|
+
export { getQuote } from './actions/getQuote.js'
|
|
10
|
+
export { getRelayedTransactionStatus } from './actions/getRelayedTransactionStatus.js'
|
|
11
|
+
export { getRelayerQuote } from './actions/getRelayerQuote.js'
|
|
12
|
+
export { getRoutes } from './actions/getRoutes.js'
|
|
13
|
+
export { getStatus } from './actions/getStatus.js'
|
|
14
|
+
export { getStepTransaction } from './actions/getStepTransaction.js'
|
|
15
|
+
export { getToken } from './actions/getToken.js'
|
|
16
|
+
export { getTokenBalance } from './actions/getTokenBalance.js'
|
|
17
|
+
export { getTokenBalances } from './actions/getTokenBalances.js'
|
|
18
|
+
export { getTokenBalancesByChain } from './actions/getTokenBalancesByChain.js'
|
|
19
|
+
export { getTokens } from './actions/getTokens.js'
|
|
20
|
+
export { getTools } from './actions/getTools.js'
|
|
21
|
+
export { getTransactionHistory } from './actions/getTransactionHistory.js'
|
|
22
|
+
export { getWalletBalances } from './actions/getWalletBalances.js'
|
|
23
|
+
export { actions } from './actions/index.js'
|
|
24
|
+
export { patchContractCalls } from './actions/patchContractCalls.js'
|
|
25
|
+
export { relayTransaction } from './actions/relayTransaction.js'
|
|
26
|
+
export { createClient } from './client/createClient.js'
|
|
27
|
+
export { getActionMessage, getSubstatusMessage } from './core/actionMessages.js'
|
|
28
|
+
export { BaseStepExecutionTask } from './core/BaseStepExecutionTask.js'
|
|
29
|
+
export { BaseStepExecutor } from './core/BaseStepExecutor.js'
|
|
30
|
+
export {
|
|
31
|
+
executeRoute,
|
|
32
|
+
getActiveRoute,
|
|
33
|
+
getActiveRoutes,
|
|
34
|
+
resumeRoute,
|
|
35
|
+
stopRouteExecution,
|
|
36
|
+
updateRouteExecution,
|
|
37
|
+
} from './core/execution.js'
|
|
38
|
+
export { StatusManager } from './core/StatusManager.js'
|
|
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'
|
|
55
|
+
export { BaseError } from './errors/baseError.js'
|
|
56
|
+
export type { ErrorCode } from './errors/constants.js'
|
|
57
|
+
export { ErrorMessage, ErrorName, LiFiErrorCode } from './errors/constants.js'
|
|
58
|
+
export {
|
|
59
|
+
BalanceError,
|
|
60
|
+
ExecuteStepRetryError,
|
|
61
|
+
ProviderError,
|
|
62
|
+
RPCError,
|
|
63
|
+
ServerError,
|
|
64
|
+
TransactionError,
|
|
65
|
+
UnknownError,
|
|
66
|
+
ValidationError,
|
|
67
|
+
} from './errors/errors.js'
|
|
68
|
+
export { HTTPError } from './errors/httpError.js'
|
|
69
|
+
export { SDKError } from './errors/SDKError.js'
|
|
70
|
+
export type {
|
|
71
|
+
AcceptExchangeRateUpdateHook,
|
|
72
|
+
AcceptSlippageUpdateHook,
|
|
73
|
+
AcceptSlippageUpdateHookParams,
|
|
74
|
+
ContractCallParams,
|
|
75
|
+
ContractTool,
|
|
76
|
+
ExchangeRateUpdateParams,
|
|
77
|
+
ExecuteStepRetryParams,
|
|
78
|
+
Execution,
|
|
79
|
+
ExecutionAction,
|
|
80
|
+
ExecutionActionStatus,
|
|
81
|
+
ExecutionActionType,
|
|
82
|
+
ExecutionOptions,
|
|
83
|
+
ExecutionStatus,
|
|
84
|
+
GetContractCallsHook,
|
|
85
|
+
GetContractCallsResult,
|
|
86
|
+
InteractionSettings,
|
|
87
|
+
LiFiStepExtended,
|
|
88
|
+
RequestInterceptor,
|
|
89
|
+
RouteExecutionData,
|
|
90
|
+
RouteExecutionDataDictionary,
|
|
91
|
+
RouteExecutionDictionary,
|
|
92
|
+
RouteExtended,
|
|
93
|
+
RPCUrls,
|
|
94
|
+
SDKBaseConfig,
|
|
95
|
+
SDKClient,
|
|
96
|
+
SDKConfig,
|
|
97
|
+
SDKProvider,
|
|
98
|
+
StepExecutor,
|
|
99
|
+
StepExecutorOptions,
|
|
100
|
+
StepExtended,
|
|
101
|
+
TransactionMethodType,
|
|
102
|
+
TransactionParameters,
|
|
103
|
+
TransactionRequestParameters,
|
|
104
|
+
TransactionRequestUpdateHook,
|
|
105
|
+
UpdateRouteHook,
|
|
106
|
+
} from './types/core.js'
|
|
107
|
+
export type {
|
|
108
|
+
StepExecutorBaseContext,
|
|
109
|
+
StepExecutorContext,
|
|
110
|
+
TaskResult,
|
|
111
|
+
TaskStatus,
|
|
112
|
+
} from './types/execution.js'
|
|
113
|
+
export { checkPackageUpdates } from './utils/checkPackageUpdates.js'
|
|
114
|
+
export { convertQuoteToRoute } from './utils/convertQuoteToRoute.js'
|
|
115
|
+
export { fetchTxErrorDetails } from './utils/fetchTxErrorDetails.js'
|
|
116
|
+
export { formatUnits } from './utils/formatUnits.js'
|
|
117
|
+
export { isHex } from './utils/isHex.js'
|
|
118
|
+
export { parseUnits } from './utils/parseUnits.js'
|
|
119
|
+
export { sleep } from './utils/sleep.js'
|
|
120
|
+
export { waitForResult } from './utils/waitForResult.js'
|
|
121
|
+
export { LruMap, withDedupe } from './utils/withDedupe.js'
|
|
122
|
+
export { withTimeout } from './utils/withTimeout.js'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GetStatusRequest,
|
|
3
|
+
QuoteRequest as QuoteRequestBase,
|
|
4
|
+
} from '@lifi/types'
|
|
5
|
+
|
|
6
|
+
export type GetStatusRequestExtended = GetStatusRequest & {
|
|
7
|
+
fromAddress?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type QuoteRequestFromAmount = QuoteRequestBase
|
|
11
|
+
|
|
12
|
+
export type QuoteRequestToAmount = Omit<QuoteRequestBase, 'fromAmount'> & {
|
|
13
|
+
toAmount: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type QuoteRequest = QuoteRequestFromAmount | QuoteRequestToAmount
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChainId,
|
|
3
|
+
ChainType,
|
|
4
|
+
CoinKey,
|
|
5
|
+
ContractCall,
|
|
6
|
+
ExtendedChain,
|
|
7
|
+
FeeCost,
|
|
8
|
+
GasCost,
|
|
9
|
+
LiFiStep,
|
|
10
|
+
Route,
|
|
11
|
+
RouteOptions,
|
|
12
|
+
Step,
|
|
13
|
+
Substatus,
|
|
14
|
+
Token,
|
|
15
|
+
TokenAmount,
|
|
16
|
+
} from '@lifi/types'
|
|
17
|
+
import type { SDKStorage } from '../core/storage.js'
|
|
18
|
+
import type { ExtendedRequestInit } from './request.js'
|
|
19
|
+
|
|
20
|
+
export type RequestInterceptor = (
|
|
21
|
+
request: ExtendedRequestInit
|
|
22
|
+
) => ExtendedRequestInit | Promise<ExtendedRequestInit>
|
|
23
|
+
|
|
24
|
+
export interface SDKBaseConfig {
|
|
25
|
+
apiKey?: string
|
|
26
|
+
apiUrl: string
|
|
27
|
+
integrator: string
|
|
28
|
+
userId?: string
|
|
29
|
+
routeOptions?: RouteOptions
|
|
30
|
+
executionOptions?: ExecutionOptions
|
|
31
|
+
rpcUrls: RPCUrls
|
|
32
|
+
disableVersionCheck?: boolean
|
|
33
|
+
widgetVersion?: string
|
|
34
|
+
debug: boolean
|
|
35
|
+
preloadChains?: boolean
|
|
36
|
+
chainsRefetchInterval?: number
|
|
37
|
+
requestInterceptor?: RequestInterceptor
|
|
38
|
+
storage?: SDKStorage
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface SDKConfig extends Partial<Omit<SDKBaseConfig, 'integrator'>> {
|
|
42
|
+
integrator: string
|
|
43
|
+
providers?: SDKProvider[]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type RPCUrls = Partial<Record<ChainId, string[]>>
|
|
47
|
+
|
|
48
|
+
export interface SDKProvider {
|
|
49
|
+
readonly type: ChainType
|
|
50
|
+
isAddress(address: string): boolean
|
|
51
|
+
resolveAddress(
|
|
52
|
+
name: string,
|
|
53
|
+
client: SDKClient,
|
|
54
|
+
chainId?: ChainId,
|
|
55
|
+
token?: CoinKey
|
|
56
|
+
): Promise<string | undefined>
|
|
57
|
+
getStepExecutor(options: StepExecutorOptions): Promise<StepExecutor>
|
|
58
|
+
getBalance(
|
|
59
|
+
client: SDKClient,
|
|
60
|
+
walletAddress: string,
|
|
61
|
+
tokens: Token[]
|
|
62
|
+
): Promise<TokenAmount[]>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface SDKClient {
|
|
66
|
+
config: SDKBaseConfig
|
|
67
|
+
providers: SDKProvider[]
|
|
68
|
+
getProvider(type: ChainType): SDKProvider | undefined
|
|
69
|
+
setProviders(providers: SDKProvider[]): void
|
|
70
|
+
setChains(chains: ExtendedChain[]): void
|
|
71
|
+
getChains(): Promise<ExtendedChain[]>
|
|
72
|
+
getChainById(chainId: ChainId): Promise<ExtendedChain>
|
|
73
|
+
getRpcUrls(): Promise<RPCUrls>
|
|
74
|
+
getRpcUrlsByChainId(chainId: ChainId): Promise<string[]>
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface StepExecutorOptions {
|
|
78
|
+
routeId: string
|
|
79
|
+
executionOptions?: ExecutionOptions
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface InteractionSettings {
|
|
83
|
+
allowInteraction?: boolean
|
|
84
|
+
allowUpdates?: boolean
|
|
85
|
+
allowExecution?: boolean
|
|
86
|
+
}
|
|
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
|
+
|
|
94
|
+
export interface StepExecutor {
|
|
95
|
+
allowUserInteraction: boolean
|
|
96
|
+
allowExecution: boolean
|
|
97
|
+
setInteraction(settings?: InteractionSettings): void
|
|
98
|
+
executeStep(
|
|
99
|
+
client: SDKClient,
|
|
100
|
+
step: LiFiStepExtended,
|
|
101
|
+
retryParams?: ExecuteStepRetryParams
|
|
102
|
+
): Promise<LiFiStepExtended>
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface RouteExecutionData {
|
|
106
|
+
route: Route
|
|
107
|
+
executors: StepExecutor[]
|
|
108
|
+
executionOptions?: ExecutionOptions
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type RouteExecutionDataDictionary = Partial<
|
|
112
|
+
Record<string, RouteExecutionData>
|
|
113
|
+
>
|
|
114
|
+
|
|
115
|
+
export interface RouteExtended extends Omit<Route, 'steps'> {
|
|
116
|
+
steps: LiFiStepExtended[]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface LiFiStepExtended extends LiFiStep {
|
|
120
|
+
execution?: Execution
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export type StepExtended = Step & {
|
|
124
|
+
execution?: Execution
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type TransactionParameters = {
|
|
128
|
+
chainId?: number
|
|
129
|
+
to?: string
|
|
130
|
+
from?: string
|
|
131
|
+
nonce?: number
|
|
132
|
+
data?: string
|
|
133
|
+
value?: bigint
|
|
134
|
+
gas?: bigint
|
|
135
|
+
gasPrice?: bigint
|
|
136
|
+
maxFeePerGas?: bigint
|
|
137
|
+
maxPriorityFeePerGas?: bigint
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type RouteExecutionDictionary = Partial<Record<string, Promise<Route>>>
|
|
141
|
+
|
|
142
|
+
export type UpdateRouteHook = (updatedRoute: RouteExtended) => void
|
|
143
|
+
|
|
144
|
+
export interface TransactionRequestParameters extends TransactionParameters {
|
|
145
|
+
requestType: 'approve' | 'transaction'
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export type TransactionRequestUpdateHook = (
|
|
149
|
+
updatedTxRequest: TransactionRequestParameters
|
|
150
|
+
) => Promise<TransactionParameters>
|
|
151
|
+
|
|
152
|
+
export interface AcceptSlippageUpdateHookParams {
|
|
153
|
+
toToken: Token
|
|
154
|
+
oldToAmount: string
|
|
155
|
+
newToAmount: string
|
|
156
|
+
oldSlippage: number
|
|
157
|
+
newSlippage: number
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export type AcceptSlippageUpdateHook = (
|
|
161
|
+
params: AcceptSlippageUpdateHookParams
|
|
162
|
+
) => Promise<boolean | undefined>
|
|
163
|
+
|
|
164
|
+
export interface ExchangeRateUpdateParams {
|
|
165
|
+
toToken: Token
|
|
166
|
+
oldToAmount: string
|
|
167
|
+
newToAmount: string
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type AcceptExchangeRateUpdateHook = (
|
|
171
|
+
params: ExchangeRateUpdateParams
|
|
172
|
+
) => Promise<boolean | undefined>
|
|
173
|
+
|
|
174
|
+
export interface ContractCallParams {
|
|
175
|
+
fromChainId: number
|
|
176
|
+
toChainId: number
|
|
177
|
+
fromTokenAddress: string
|
|
178
|
+
toTokenAddress: string
|
|
179
|
+
fromAddress: string
|
|
180
|
+
toAddress?: string
|
|
181
|
+
fromAmount: bigint
|
|
182
|
+
toAmount: bigint
|
|
183
|
+
slippage?: number
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface ContractTool {
|
|
187
|
+
name: string
|
|
188
|
+
logoURI: string
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface GetContractCallsResult {
|
|
192
|
+
contractCalls: ContractCall[]
|
|
193
|
+
patcher?: boolean
|
|
194
|
+
contractTool?: ContractTool
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export type GetContractCallsHook = (
|
|
198
|
+
params: ContractCallParams
|
|
199
|
+
) => Promise<GetContractCallsResult>
|
|
200
|
+
|
|
201
|
+
export interface ExecutionOptions {
|
|
202
|
+
acceptExchangeRateUpdateHook?: AcceptExchangeRateUpdateHook
|
|
203
|
+
updateRouteHook?: UpdateRouteHook
|
|
204
|
+
updateTransactionRequestHook?: TransactionRequestUpdateHook
|
|
205
|
+
getContractCalls?: GetContractCallsHook
|
|
206
|
+
adjustZeroOutputFromPreviousStep?: boolean
|
|
207
|
+
executeInBackground?: boolean
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export type ExecutionStatus = 'ACTION_REQUIRED' | 'PENDING' | 'FAILED' | 'DONE'
|
|
211
|
+
|
|
212
|
+
export type ExecutionActionStatus =
|
|
213
|
+
| 'STARTED'
|
|
214
|
+
| 'ACTION_REQUIRED'
|
|
215
|
+
| 'MESSAGE_REQUIRED'
|
|
216
|
+
| 'RESET_REQUIRED'
|
|
217
|
+
| 'PENDING'
|
|
218
|
+
| 'FAILED'
|
|
219
|
+
| 'DONE'
|
|
220
|
+
| 'CANCELLED'
|
|
221
|
+
|
|
222
|
+
export type ExecutionActionType =
|
|
223
|
+
| 'PERMIT'
|
|
224
|
+
| 'CHECK_ALLOWANCE'
|
|
225
|
+
| 'NATIVE_PERMIT'
|
|
226
|
+
| 'RESET_ALLOWANCE'
|
|
227
|
+
| 'SET_ALLOWANCE'
|
|
228
|
+
| 'SWAP'
|
|
229
|
+
| 'CROSS_CHAIN'
|
|
230
|
+
| 'RECEIVING_CHAIN'
|
|
231
|
+
|
|
232
|
+
export type ExecutionAction = {
|
|
233
|
+
type: ExecutionActionType
|
|
234
|
+
status: ExecutionActionStatus
|
|
235
|
+
message?: string
|
|
236
|
+
substatus?: Substatus
|
|
237
|
+
substatusMessage?: string
|
|
238
|
+
chainId?: number
|
|
239
|
+
txHash?: string
|
|
240
|
+
txLink?: string
|
|
241
|
+
taskId?: string
|
|
242
|
+
txType?: TransactionMethodType
|
|
243
|
+
txHex?: string
|
|
244
|
+
// Errors occured during the action execution (within tasks)
|
|
245
|
+
error?: { code: string | number; message: string; htmlMessage?: string }
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface Execution {
|
|
249
|
+
startedAt: number
|
|
250
|
+
signedAt?: number
|
|
251
|
+
status: ExecutionStatus
|
|
252
|
+
actions: Array<ExecutionAction>
|
|
253
|
+
fromAmount?: string
|
|
254
|
+
toAmount?: string
|
|
255
|
+
toToken?: Token
|
|
256
|
+
feeCosts?: FeeCost[]
|
|
257
|
+
gasCosts?: GasCost[]
|
|
258
|
+
internalTxLink?: string
|
|
259
|
+
externalTxLink?: string
|
|
260
|
+
// Errors occured outside of actions (e.g. during context creation)
|
|
261
|
+
error?: { code: string | number; message: string; htmlMessage?: string }
|
|
262
|
+
}
|
|
263
|
+
|
|
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'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { name, version } from '../version.js'
|
|
2
|
+
|
|
3
|
+
export const checkPackageUpdates = async (
|
|
4
|
+
packageName?: string,
|
|
5
|
+
packageVersion?: string
|
|
6
|
+
): Promise<void> => {
|
|
7
|
+
try {
|
|
8
|
+
const pkgName = packageName ?? name
|
|
9
|
+
const response = await fetch(`https://registry.npmjs.org/${pkgName}/latest`)
|
|
10
|
+
const reponseBody = await response.json()
|
|
11
|
+
const latestVersion = reponseBody.version
|
|
12
|
+
const currentVersion = packageVersion ?? version
|
|
13
|
+
|
|
14
|
+
if (latestVersion > currentVersion) {
|
|
15
|
+
console.warn(
|
|
16
|
+
`${pkgName}: new package version is available. Please update as soon as possible to enjoy the newest features. Current version: ${currentVersion}. Latest version: ${latestVersion}.`
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
} catch (_error) {
|
|
20
|
+
// Cannot verify version, might be network error etc. We don't bother showing anything in that case
|
|
21
|
+
}
|
|
22
|
+
}
|