@lifi/sdk 3.0.0-alpha.6 → 3.0.0-alpha.60
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/package.json +40 -88
- package/src/_cjs/config.js +90 -0
- package/src/_cjs/config.js.map +1 -0
- package/{dist/cjs → src/_cjs}/constants.js +3 -5
- package/src/_cjs/constants.js.map +1 -0
- package/src/_cjs/core/BaseStepExecutor.js +55 -0
- package/src/_cjs/core/BaseStepExecutor.js.map +1 -0
- package/src/_cjs/core/EVM/EVM.js +43 -0
- package/src/_cjs/core/EVM/EVM.js.map +1 -0
- package/src/_cjs/core/EVM/EVMStepExecutor.js +304 -0
- package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -0
- package/{dist/cjs/types → src/_cjs/core/EVM}/abi.js +1 -0
- package/src/_cjs/core/EVM/abi.js.map +1 -0
- package/{dist/cjs/execution → src/_cjs/core/EVM}/checkAllowance.js +19 -12
- package/src/_cjs/core/EVM/checkAllowance.js.map +1 -0
- package/{dist/cjs/allowance → src/_cjs/core/EVM}/getAllowance.js +13 -17
- package/src/_cjs/core/EVM/getAllowance.js.map +1 -0
- package/src/_cjs/core/EVM/getENSAddress.js +20 -0
- package/src/_cjs/core/EVM/getENSAddress.js.map +1 -0
- package/{dist/cjs/balance/getBalance.js → src/_cjs/core/EVM/getEVMBalance.js} +20 -22
- package/src/_cjs/core/EVM/getEVMBalance.js.map +1 -0
- package/{dist/cjs/execution → src/_cjs/core/EVM}/multisig.js +7 -11
- package/src/_cjs/core/EVM/multisig.js.map +1 -0
- package/src/_cjs/core/EVM/publicClient.js +43 -0
- package/src/_cjs/core/EVM/publicClient.js.map +1 -0
- package/{dist/cjs/allowance → src/_cjs/core/EVM}/setAllowance.js +11 -12
- package/src/_cjs/core/EVM/setAllowance.js.map +1 -0
- package/src/_cjs/core/EVM/switchChain.js +38 -0
- package/src/_cjs/core/EVM/switchChain.js.map +1 -0
- package/src/_cjs/core/EVM/types.js +9 -0
- package/src/_cjs/core/EVM/types.js.map +1 -0
- package/{dist/cjs/utils/getMaxPriorityFeePerGas.js → src/_cjs/core/EVM/utils.js} +13 -3
- package/src/_cjs/core/EVM/utils.js.map +1 -0
- package/src/_cjs/core/Solana/Solana.js +38 -0
- package/src/_cjs/core/Solana/Solana.js.map +1 -0
- package/src/_cjs/core/Solana/SolanaStepExecutor.js +174 -0
- package/src/_cjs/core/Solana/SolanaStepExecutor.js.map +1 -0
- package/src/_cjs/core/Solana/connection.js +19 -0
- package/src/_cjs/core/Solana/connection.js.map +1 -0
- package/src/_cjs/core/Solana/getSNSAddress.js +26 -0
- package/src/_cjs/core/Solana/getSNSAddress.js.map +1 -0
- package/src/_cjs/core/Solana/getSolanaBalance.js +60 -0
- package/src/_cjs/core/Solana/getSolanaBalance.js.map +1 -0
- package/src/_cjs/core/Solana/isAddress.js +15 -0
- package/src/_cjs/core/Solana/isAddress.js.map +1 -0
- package/src/_cjs/core/Solana/types.js +10 -0
- package/src/_cjs/core/Solana/types.js.map +1 -0
- package/src/_cjs/core/StatusManager.js +167 -0
- package/src/_cjs/core/StatusManager.js.map +1 -0
- package/{dist/cjs/execution → src/_cjs/core}/checkBalance.js +6 -6
- package/src/_cjs/core/checkBalance.js.map +1 -0
- package/src/_cjs/core/execution.js +134 -0
- package/src/_cjs/core/execution.js.map +1 -0
- package/src/_cjs/core/executionState.js +29 -0
- package/src/_cjs/core/executionState.js.map +1 -0
- package/src/_cjs/core/index.js +7 -0
- package/src/_cjs/core/index.js.map +1 -0
- package/src/_cjs/core/prepareRestart.js +23 -0
- package/src/_cjs/core/prepareRestart.js.map +1 -0
- package/src/_cjs/core/provider.js +15 -0
- package/src/_cjs/core/provider.js.map +1 -0
- package/src/_cjs/core/rpc.js +18 -0
- package/src/_cjs/core/rpc.js.map +1 -0
- package/src/_cjs/core/stepComparison.js +25 -0
- package/src/_cjs/core/stepComparison.js.map +1 -0
- package/{dist/cjs/allowance → src/_cjs/core}/types.js +1 -0
- package/src/_cjs/core/types.js.map +1 -0
- package/{dist/cjs/execution → src/_cjs/core}/utils.js +2 -11
- package/src/_cjs/core/utils.js.map +1 -0
- package/{dist/cjs/execution → src/_cjs/core}/waitForReceivingTransaction.js +13 -14
- package/src/_cjs/core/waitForReceivingTransaction.js.map +1 -0
- package/src/_cjs/createConfig.js +32 -0
- package/src/_cjs/createConfig.js.map +1 -0
- package/src/_cjs/helpers.js +57 -0
- package/src/_cjs/helpers.js.map +1 -0
- package/src/_cjs/index.js +23 -0
- package/src/_cjs/index.js.map +1 -0
- package/src/_cjs/package.json +1 -0
- package/src/_cjs/request.js +66 -0
- package/src/_cjs/request.js.map +1 -0
- package/src/_cjs/services/api.js +309 -0
- package/src/_cjs/services/api.js.map +1 -0
- package/src/_cjs/services/balance.js +49 -0
- package/src/_cjs/services/balance.js.map +1 -0
- package/src/_cjs/services/getNameServiceAddress.js +29 -0
- package/src/_cjs/services/getNameServiceAddress.js.map +1 -0
- package/{dist/cjs → src/_cjs}/typeguards.js +1 -0
- package/src/_cjs/typeguards.js.map +1 -0
- package/src/_cjs/types/index.js +5 -0
- package/src/_cjs/types/index.js.map +1 -0
- package/{dist/cjs/types/internal.types.js → src/_cjs/types/internal.js} +1 -0
- package/src/_cjs/types/internal.js.map +1 -0
- package/{dist/cjs → src/_cjs}/utils/errors.js +26 -3
- package/src/_cjs/utils/errors.js.map +1 -0
- package/src/_cjs/utils/getTransactionMessage.js +31 -0
- package/src/_cjs/utils/getTransactionMessage.js.map +1 -0
- package/src/_cjs/utils/index.js +9 -0
- package/src/_cjs/utils/index.js.map +1 -0
- package/{dist/cjs → src/_cjs}/utils/median.js +1 -0
- package/src/_cjs/utils/median.js.map +1 -0
- package/src/_cjs/utils/parseBackendError.js +27 -0
- package/src/_cjs/utils/parseBackendError.js.map +1 -0
- package/src/_cjs/utils/parseError.js +69 -0
- package/src/_cjs/utils/parseError.js.map +1 -0
- package/{dist/cjs → src/_cjs}/utils/utils.js +5 -11
- package/src/_cjs/utils/utils.js.map +1 -0
- package/{dist/cjs → src/_cjs}/version.js +2 -1
- package/src/_cjs/version.js.map +1 -0
- package/src/_esm/config.js +87 -0
- package/src/_esm/config.js.map +1 -0
- package/{dist → src/_esm}/constants.js +2 -4
- package/src/_esm/constants.js.map +1 -0
- package/src/_esm/core/BaseStepExecutor.js +52 -0
- package/src/_esm/core/BaseStepExecutor.js.map +1 -0
- package/src/_esm/core/EVM/EVM.js +39 -0
- package/src/_esm/core/EVM/EVM.js.map +1 -0
- package/src/_esm/core/EVM/EVMStepExecutor.js +329 -0
- package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -0
- package/{dist/types → src/_esm/core/EVM}/abi.js +1 -0
- package/src/_esm/core/EVM/abi.js.map +1 -0
- package/{dist/execution → src/_esm/core/EVM}/checkAllowance.js +14 -5
- package/src/_esm/core/EVM/checkAllowance.js.map +1 -0
- package/{dist/allowance → src/_esm/core/EVM}/getAllowance.js +19 -6
- package/src/_esm/core/EVM/getAllowance.js.map +1 -0
- package/src/_esm/core/EVM/getENSAddress.js +17 -0
- package/src/_esm/core/EVM/getENSAddress.js.map +1 -0
- package/{dist/balance/getBalance.js → src/_esm/core/EVM/getEVMBalance.js} +10 -12
- package/src/_esm/core/EVM/getEVMBalance.js.map +1 -0
- package/{dist/execution → src/_esm/core/EVM}/multisig.js +5 -6
- package/src/_esm/core/EVM/multisig.js.map +1 -0
- package/src/_esm/core/EVM/publicClient.js +46 -0
- package/src/_esm/core/EVM/publicClient.js.map +1 -0
- package/{dist/allowance → src/_esm/core/EVM}/setAllowance.js +23 -4
- package/src/_esm/core/EVM/setAllowance.js.map +1 -0
- package/{dist/execution → src/_esm/core/EVM}/switchChain.js +7 -4
- package/src/_esm/core/EVM/switchChain.js.map +1 -0
- package/src/_esm/core/EVM/types.js +6 -0
- package/src/_esm/core/EVM/types.js.map +1 -0
- package/{dist/utils/getMaxPriorityFeePerGas.js → src/_esm/core/EVM/utils.js} +12 -1
- package/src/_esm/core/EVM/utils.js.map +1 -0
- package/src/_esm/core/Solana/Solana.js +34 -0
- package/src/_esm/core/Solana/Solana.js.map +1 -0
- package/src/_esm/core/Solana/SolanaStepExecutor.js +176 -0
- package/src/_esm/core/Solana/SolanaStepExecutor.js.map +1 -0
- package/src/_esm/core/Solana/connection.js +20 -0
- package/src/_esm/core/Solana/connection.js.map +1 -0
- package/src/_esm/core/Solana/getSNSAddress.js +26 -0
- package/src/_esm/core/Solana/getSNSAddress.js.map +1 -0
- package/src/_esm/core/Solana/getSolanaBalance.js +56 -0
- package/src/_esm/core/Solana/getSolanaBalance.js.map +1 -0
- package/src/_esm/core/Solana/isAddress.js +11 -0
- package/src/_esm/core/Solana/isAddress.js.map +1 -0
- package/src/_esm/core/Solana/types.js +7 -0
- package/src/_esm/core/Solana/types.js.map +1 -0
- package/src/_esm/core/StatusManager.js +203 -0
- package/src/_esm/core/StatusManager.js.map +1 -0
- package/{dist/execution → src/_esm/core}/checkBalance.js +4 -3
- package/src/_esm/core/checkBalance.js.map +1 -0
- package/src/_esm/core/execution.js +172 -0
- package/src/_esm/core/execution.js.map +1 -0
- package/src/_esm/core/executionState.js +26 -0
- package/src/_esm/core/executionState.js.map +1 -0
- package/src/_esm/core/index.js +4 -0
- package/src/_esm/core/index.js.map +1 -0
- package/src/_esm/core/prepareRestart.js +64 -0
- package/src/_esm/core/prepareRestart.js.map +1 -0
- package/src/_esm/core/provider.js +11 -0
- package/src/_esm/core/provider.js.map +1 -0
- package/src/_esm/core/rpc.js +14 -0
- package/src/_esm/core/rpc.js.map +1 -0
- package/{dist/execution → src/_esm/core}/stepComparison.js +7 -5
- package/src/_esm/core/stepComparison.js.map +1 -0
- package/src/_esm/core/types.js +2 -0
- package/src/_esm/core/types.js.map +1 -0
- package/{dist/execution → src/_esm/core}/utils.js +4 -3
- package/src/_esm/core/utils.js.map +1 -0
- package/{dist/execution → src/_esm/core}/waitForReceivingTransaction.js +11 -9
- package/src/_esm/core/waitForReceivingTransaction.js.map +1 -0
- package/src/_esm/createConfig.js +28 -0
- package/src/_esm/createConfig.js.map +1 -0
- package/{dist → src/_esm}/helpers.js +5 -17
- package/src/_esm/helpers.js.map +1 -0
- package/src/_esm/index.js +14 -0
- package/src/_esm/index.js.map +1 -0
- package/src/_esm/package.json +1 -0
- package/{dist → src/_esm}/request.js +23 -13
- package/src/_esm/request.js.map +1 -0
- package/src/_esm/services/api.js +378 -0
- package/src/_esm/services/api.js.map +1 -0
- package/src/_esm/services/balance.js +65 -0
- package/src/_esm/services/balance.js.map +1 -0
- package/src/_esm/services/getNameServiceAddress.js +25 -0
- package/src/_esm/services/getNameServiceAddress.js.map +1 -0
- package/{dist → src/_esm}/typeguards.js +1 -0
- package/src/_esm/typeguards.js.map +1 -0
- package/src/_esm/types/index.js +2 -0
- package/src/_esm/types/index.js.map +1 -0
- package/src/_esm/types/internal.js +2 -0
- package/src/_esm/types/internal.js.map +1 -0
- package/{dist → src/_esm}/utils/errors.js +26 -0
- package/src/_esm/utils/errors.js.map +1 -0
- package/src/_esm/utils/getTransactionMessage.js +28 -0
- package/src/_esm/utils/getTransactionMessage.js.map +1 -0
- package/src/_esm/utils/index.js +6 -0
- package/src/_esm/utils/index.js.map +1 -0
- package/{dist → src/_esm}/utils/median.js +1 -0
- package/src/_esm/utils/median.js.map +1 -0
- package/src/_esm/utils/parseBackendError.js +24 -0
- package/src/_esm/utils/parseBackendError.js.map +1 -0
- package/{dist → src/_esm}/utils/parseError.js +6 -53
- package/src/_esm/utils/parseError.js.map +1 -0
- package/{dist → src/_esm}/utils/utils.js +2 -1
- package/src/_esm/utils/utils.js.map +1 -0
- package/src/_esm/version.js +3 -0
- package/src/_esm/version.js.map +1 -0
- package/src/_types/config.d.ts +15 -0
- package/src/_types/config.d.ts.map +1 -0
- package/{dist/cjs → src/_types}/constants.d.ts +2 -4
- package/src/_types/constants.d.ts.map +1 -0
- package/src/_types/core/BaseStepExecutor.d.ts +13 -0
- package/src/_types/core/BaseStepExecutor.d.ts.map +1 -0
- package/src/_types/core/EVM/EVM.d.ts +3 -0
- package/src/_types/core/EVM/EVM.d.ts.map +1 -0
- package/src/_types/core/EVM/EVMStepExecutor.d.ts +17 -0
- package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -0
- package/{dist/cjs/types → src/_types/core/EVM}/abi.d.ts +1 -0
- package/src/_types/core/EVM/abi.d.ts.map +1 -0
- package/src/_types/core/EVM/checkAllowance.d.ts +6 -0
- package/src/_types/core/EVM/checkAllowance.d.ts.map +1 -0
- package/{dist/cjs/allowance → src/_types/core/EVM}/getAllowance.d.ts +15 -1
- package/src/_types/core/EVM/getAllowance.d.ts.map +1 -0
- package/src/_types/core/EVM/getENSAddress.d.ts +2 -0
- package/src/_types/core/EVM/getENSAddress.d.ts.map +1 -0
- package/src/_types/core/EVM/getEVMBalance.d.ts +3 -0
- package/src/_types/core/EVM/getEVMBalance.d.ts.map +1 -0
- package/src/_types/core/EVM/multisig.d.ts +6 -0
- package/src/_types/core/EVM/multisig.d.ts.map +1 -0
- package/src/_types/core/EVM/publicClient.d.ts +8 -0
- package/src/_types/core/EVM/publicClient.d.ts.map +1 -0
- package/src/_types/core/EVM/setAllowance.d.ts +25 -0
- package/src/_types/core/EVM/setAllowance.d.ts.map +1 -0
- package/{dist/cjs/execution → src/_types/core/EVM}/switchChain.d.ts +5 -4
- package/src/_types/core/EVM/switchChain.d.ts.map +1 -0
- package/src/_types/core/EVM/types.d.ts +55 -0
- package/src/_types/core/EVM/types.d.ts.map +1 -0
- package/src/_types/core/EVM/utils.d.ts +10 -0
- package/src/_types/core/EVM/utils.d.ts.map +1 -0
- package/src/_types/core/Solana/Solana.d.ts +3 -0
- package/src/_types/core/Solana/Solana.d.ts.map +1 -0
- package/src/_types/core/Solana/SolanaStepExecutor.d.ts +13 -0
- package/src/_types/core/Solana/SolanaStepExecutor.d.ts.map +1 -0
- package/src/_types/core/Solana/connection.d.ts +8 -0
- package/src/_types/core/Solana/connection.d.ts.map +1 -0
- package/src/_types/core/Solana/getSNSAddress.d.ts +2 -0
- package/src/_types/core/Solana/getSNSAddress.d.ts.map +1 -0
- package/src/_types/core/Solana/getSolanaBalance.d.ts +3 -0
- package/src/_types/core/Solana/getSolanaBalance.d.ts.map +1 -0
- package/src/_types/core/Solana/isAddress.d.ts +2 -0
- package/src/_types/core/Solana/isAddress.d.ts.map +1 -0
- package/src/_types/core/Solana/types.d.ts +13 -0
- package/src/_types/core/Solana/types.d.ts.map +1 -0
- package/{dist/cjs/execution → src/_types/core}/StatusManager.d.ts +15 -28
- package/src/_types/core/StatusManager.d.ts.map +1 -0
- package/src/_types/core/checkBalance.d.ts +3 -0
- package/src/_types/core/checkBalance.d.ts.map +1 -0
- package/src/_types/core/execution.d.ts +42 -0
- package/src/_types/core/execution.d.ts.map +1 -0
- package/src/_types/core/executionState.d.ts +17 -0
- package/src/_types/core/executionState.d.ts.map +1 -0
- package/src/_types/core/index.d.ts +4 -0
- package/src/_types/core/index.d.ts.map +1 -0
- package/src/_types/core/prepareRestart.d.ts +3 -0
- package/src/_types/core/prepareRestart.d.ts.map +1 -0
- package/src/_types/core/provider.d.ts +3 -0
- package/src/_types/core/provider.d.ts.map +1 -0
- package/src/_types/core/rpc.d.ts +4 -0
- package/src/_types/core/rpc.d.ts.map +1 -0
- package/{dist/execution → src/_types/core}/stepComparison.d.ts +7 -4
- package/src/_types/core/stepComparison.d.ts.map +1 -0
- package/src/_types/core/types.d.ts +81 -0
- package/src/_types/core/types.d.ts.map +1 -0
- package/{dist/execution → src/_types/core}/utils.d.ts +3 -2
- package/src/_types/core/utils.d.ts.map +1 -0
- package/src/_types/core/waitForReceivingTransaction.d.ts +4 -0
- package/src/_types/core/waitForReceivingTransaction.d.ts.map +1 -0
- package/src/_types/createConfig.d.ts +4 -0
- package/src/_types/createConfig.d.ts.map +1 -0
- package/{dist → src/_types}/helpers.d.ts +4 -3
- package/src/_types/helpers.d.ts.map +1 -0
- package/src/_types/index.d.ts +15 -0
- package/src/_types/index.d.ts.map +1 -0
- package/{dist → src/_types}/request.d.ts +1 -0
- package/src/_types/request.d.ts.map +1 -0
- package/src/_types/services/api.d.ts +89 -0
- package/src/_types/services/api.d.ts.map +1 -0
- package/src/_types/services/balance.d.ts +30 -0
- package/src/_types/services/balance.d.ts.map +1 -0
- package/src/_types/services/getNameServiceAddress.d.ts +3 -0
- package/src/_types/services/getNameServiceAddress.d.ts.map +1 -0
- package/{dist/cjs → src/_types}/typeguards.d.ts +3 -2
- package/src/_types/typeguards.d.ts.map +1 -0
- package/src/_types/types/index.d.ts +2 -0
- package/src/_types/types/index.d.ts.map +1 -0
- package/src/_types/types/internal.d.ts +59 -0
- package/src/_types/types/internal.d.ts.map +1 -0
- package/{dist → src/_types}/utils/errors.d.ts +3 -1
- package/src/_types/utils/errors.d.ts.map +1 -0
- package/src/_types/utils/getTransactionMessage.d.ts +4 -0
- package/src/_types/utils/getTransactionMessage.d.ts.map +1 -0
- package/src/_types/utils/index.d.ts +6 -0
- package/src/_types/utils/index.d.ts.map +1 -0
- package/{dist/cjs → src/_types}/utils/median.d.ts +1 -0
- package/src/_types/utils/median.d.ts.map +1 -0
- package/src/_types/utils/parseBackendError.d.ts +3 -0
- package/src/_types/utils/parseBackendError.d.ts.map +1 -0
- package/{dist → src/_types}/utils/parseError.d.ts +4 -6
- package/src/_types/utils/parseError.d.ts.map +1 -0
- package/{dist → src/_types}/utils/utils.d.ts +1 -0
- package/src/_types/utils/utils.d.ts.map +1 -0
- package/src/_types/version.d.ts +3 -0
- package/src/_types/version.d.ts.map +1 -0
- package/src/config.ts +91 -0
- package/src/constants.ts +4 -0
- package/src/core/BaseStepExecutor.ts +40 -0
- package/src/core/EVM/EVM.ts +47 -0
- package/src/core/EVM/EVMStepExecutor.ts +503 -0
- package/src/core/EVM/abi.ts +47 -0
- package/src/core/EVM/checkAllowance.ts +168 -0
- package/src/core/EVM/getAllowance.ts +144 -0
- package/src/core/EVM/getENSAddress.ts +18 -0
- package/src/core/EVM/getEVMBalance.ts +118 -0
- package/src/core/EVM/multisig.ts +53 -0
- package/src/core/EVM/publicClient.ts +54 -0
- package/src/core/EVM/setAllowance.ts +144 -0
- package/src/core/EVM/switchChain.ts +77 -0
- package/src/core/EVM/types.ts +73 -0
- package/src/core/EVM/utils.ts +48 -0
- package/src/core/Solana/Solana.ts +41 -0
- package/src/core/Solana/SolanaStepExecutor.ts +272 -0
- package/src/core/Solana/connection.ts +20 -0
- package/src/core/Solana/getSNSAddress.ts +33 -0
- package/src/core/Solana/getSolanaBalance.ts +72 -0
- package/src/core/Solana/isAddress.ts +10 -0
- package/src/core/Solana/types.ts +18 -0
- package/src/core/StatusManager.ts +231 -0
- package/src/core/checkBalance.ts +48 -0
- package/src/core/execution.ts +210 -0
- package/src/core/executionState.ts +44 -0
- package/src/core/index.ts +3 -0
- package/src/core/prepareRestart.ts +82 -0
- package/src/core/provider.ts +12 -0
- package/src/core/rpc.ts +15 -0
- package/src/core/stepComparison.ts +51 -0
- package/src/core/types.ts +118 -0
- package/src/core/utils.ts +105 -0
- package/src/core/waitForReceivingTransaction.ts +74 -0
- package/src/createConfig.ts +33 -0
- package/src/helpers.ts +83 -0
- package/src/index.ts +18 -0
- package/src/request.ts +79 -0
- package/src/services/api.ts +509 -0
- package/src/services/balance.ts +93 -0
- package/src/services/getNameServiceAddress.ts +30 -0
- package/src/typeguards.ts +89 -0
- package/src/types/index.ts +1 -0
- package/src/types/internal.ts +62 -0
- package/src/utils/errors.ts +232 -0
- package/src/utils/getTransactionMessage.ts +46 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/median.ts +11 -0
- package/src/utils/parseBackendError.ts +50 -0
- package/src/utils/parseError.ts +210 -0
- package/src/utils/utils.ts +48 -0
- package/src/version.ts +2 -0
- package/dist/LiFi.d.ts +0 -175
- package/dist/LiFi.js +0 -250
- package/dist/allowance/getAllowance.d.ts +0 -6
- package/dist/allowance/index.d.ts +0 -3
- package/dist/allowance/index.js +0 -3
- package/dist/allowance/setAllowance.d.ts +0 -6
- package/dist/allowance/types.d.ts +0 -27
- package/dist/allowance/types.js +0 -1
- package/dist/balance/getBalance.d.ts +0 -2
- package/dist/balance/getTokenBalance.d.ts +0 -8
- package/dist/balance/getTokenBalance.js +0 -27
- package/dist/balance/index.d.ts +0 -2
- package/dist/balance/index.js +0 -2
- package/dist/cjs/LiFi.d.ts +0 -175
- package/dist/cjs/LiFi.js +0 -280
- package/dist/cjs/allowance/index.d.ts +0 -3
- package/dist/cjs/allowance/index.js +0 -19
- package/dist/cjs/allowance/setAllowance.d.ts +0 -6
- package/dist/cjs/allowance/types.d.ts +0 -27
- package/dist/cjs/balance/getBalance.d.ts +0 -2
- package/dist/cjs/balance/getTokenBalance.d.ts +0 -8
- package/dist/cjs/balance/getTokenBalance.js +0 -33
- package/dist/cjs/balance/index.d.ts +0 -2
- package/dist/cjs/balance/index.js +0 -18
- package/dist/cjs/connectors.d.ts +0 -8
- package/dist/cjs/connectors.js +0 -75
- package/dist/cjs/execution/RouteExecutionManager.d.ts +0 -59
- package/dist/cjs/execution/RouteExecutionManager.js +0 -202
- package/dist/cjs/execution/StatusManager.js +0 -171
- package/dist/cjs/execution/StepExecutionManager.d.ts +0 -7
- package/dist/cjs/execution/StepExecutionManager.js +0 -272
- package/dist/cjs/execution/StepExecutor.d.ts +0 -15
- package/dist/cjs/execution/StepExecutor.js +0 -62
- package/dist/cjs/execution/checkAllowance.d.ts +0 -4
- package/dist/cjs/execution/checkBalance.d.ts +0 -2
- package/dist/cjs/execution/index.d.ts +0 -1
- package/dist/cjs/execution/index.js +0 -17
- package/dist/cjs/execution/multisig.d.ts +0 -4
- package/dist/cjs/execution/prepareRestart.d.ts +0 -3
- package/dist/cjs/execution/prepareRestart.js +0 -65
- package/dist/cjs/execution/stepComparison.d.ts +0 -14
- package/dist/cjs/execution/stepComparison.js +0 -37
- package/dist/cjs/execution/switchChain.js +0 -54
- package/dist/cjs/execution/utils.d.ts +0 -12
- package/dist/cjs/execution/waitForReceivingTransaction.d.ts +0 -3
- package/dist/cjs/helpers.d.ts +0 -18
- package/dist/cjs/helpers.js +0 -84
- package/dist/cjs/index.d.ts +0 -5
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/request.d.ts +0 -9
- package/dist/cjs/request.js +0 -60
- package/dist/cjs/services/ApiService.d.ts +0 -17
- package/dist/cjs/services/ApiService.js +0 -326
- package/dist/cjs/services/ChainsService.d.ts +0 -11
- package/dist/cjs/services/ChainsService.js +0 -39
- package/dist/cjs/services/ConfigService.d.ts +0 -23
- package/dist/cjs/services/ConfigService.js +0 -101
- package/dist/cjs/types/index.d.ts +0 -4
- package/dist/cjs/types/index.js +0 -22
- package/dist/cjs/types/internal.types.d.ts +0 -145
- package/dist/cjs/utils/errors.d.ts +0 -107
- package/dist/cjs/utils/getMaxPriorityFeePerGas.d.ts +0 -2
- package/dist/cjs/utils/index.d.ts +0 -5
- package/dist/cjs/utils/index.js +0 -21
- package/dist/cjs/utils/parseError.d.ts +0 -37
- package/dist/cjs/utils/parseError.js +0 -157
- package/dist/cjs/utils/utils.d.ts +0 -10
- package/dist/cjs/version.d.ts +0 -2
- package/dist/connectors.d.ts +0 -8
- package/dist/connectors.js +0 -41
- package/dist/constants.d.ts +0 -6
- package/dist/execution/RouteExecutionManager.d.ts +0 -59
- package/dist/execution/RouteExecutionManager.js +0 -195
- package/dist/execution/StatusManager.d.ts +0 -67
- package/dist/execution/StatusManager.js +0 -167
- package/dist/execution/StepExecutionManager.d.ts +0 -7
- package/dist/execution/StepExecutionManager.js +0 -265
- package/dist/execution/StepExecutor.d.ts +0 -15
- package/dist/execution/StepExecutor.js +0 -58
- package/dist/execution/checkAllowance.d.ts +0 -4
- package/dist/execution/checkBalance.d.ts +0 -2
- package/dist/execution/index.d.ts +0 -1
- package/dist/execution/index.js +0 -1
- package/dist/execution/multisig.d.ts +0 -4
- package/dist/execution/prepareRestart.d.ts +0 -3
- package/dist/execution/prepareRestart.js +0 -61
- package/dist/execution/switchChain.d.ts +0 -21
- package/dist/execution/waitForReceivingTransaction.d.ts +0 -3
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -6
- package/dist/services/ApiService.d.ts +0 -17
- package/dist/services/ApiService.js +0 -321
- package/dist/services/ChainsService.d.ts +0 -11
- package/dist/services/ChainsService.js +0 -33
- package/dist/services/ConfigService.d.ts +0 -23
- package/dist/services/ConfigService.js +0 -99
- package/dist/typeguards.d.ts +0 -4
- package/dist/types/abi.d.ts +0 -5
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.js +0 -4
- package/dist/types/internal.types.d.ts +0 -145
- package/dist/types/internal.types.js +0 -1
- package/dist/utils/getMaxPriorityFeePerGas.d.ts +0 -2
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.js +0 -5
- package/dist/utils/median.d.ts +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -2
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtendedTransactionInfo,
|
|
3
|
+
FullStatusData,
|
|
4
|
+
Process,
|
|
5
|
+
} from '@lifi/types'
|
|
6
|
+
import type {
|
|
7
|
+
Address,
|
|
8
|
+
Hash,
|
|
9
|
+
PublicClient,
|
|
10
|
+
ReplacementReason,
|
|
11
|
+
SendTransactionParameters,
|
|
12
|
+
WalletClient,
|
|
13
|
+
} from 'viem'
|
|
14
|
+
import { publicActions } from 'viem'
|
|
15
|
+
import { config } from '../../config.js'
|
|
16
|
+
import { getStepTransaction } from '../../services/api.js'
|
|
17
|
+
import {
|
|
18
|
+
LiFiErrorCode,
|
|
19
|
+
TransactionError,
|
|
20
|
+
ValidationError,
|
|
21
|
+
getTransactionFailedMessage,
|
|
22
|
+
isZeroAddress,
|
|
23
|
+
parseError,
|
|
24
|
+
} from '../../utils/index.js'
|
|
25
|
+
import { BaseStepExecutor } from '../BaseStepExecutor.js'
|
|
26
|
+
import { checkBalance } from '../checkBalance.js'
|
|
27
|
+
import { stepComparison } from '../stepComparison.js'
|
|
28
|
+
import type {
|
|
29
|
+
LiFiStepExtended,
|
|
30
|
+
StepExecutorOptions,
|
|
31
|
+
TransactionParameters,
|
|
32
|
+
} from '../types.js'
|
|
33
|
+
import { getSubstatusMessage } from '../utils.js'
|
|
34
|
+
import { waitForReceivingTransaction } from '../waitForReceivingTransaction.js'
|
|
35
|
+
import { checkAllowance } from './checkAllowance.js'
|
|
36
|
+
import { updateMultisigRouteProcess } from './multisig.js'
|
|
37
|
+
import { switchChain } from './switchChain.js'
|
|
38
|
+
import type { MultisigConfig, MultisigTransaction } from './types.js'
|
|
39
|
+
import { getMaxPriorityFeePerGas, retryCount, retryDelay } from './utils.js'
|
|
40
|
+
|
|
41
|
+
export interface EVMStepExecutorOptions extends StepExecutorOptions {
|
|
42
|
+
walletClient: WalletClient
|
|
43
|
+
multisig?: MultisigConfig
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class EVMStepExecutor extends BaseStepExecutor {
|
|
47
|
+
private walletClient: WalletClient
|
|
48
|
+
private multisig?: MultisigConfig
|
|
49
|
+
|
|
50
|
+
constructor(options: EVMStepExecutorOptions) {
|
|
51
|
+
super(options)
|
|
52
|
+
this.walletClient = options.walletClient
|
|
53
|
+
this.multisig = options.multisig
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Ensure that we are using the right chain and wallet when executing transactions.
|
|
57
|
+
checkWalletClient = async (
|
|
58
|
+
step: LiFiStepExtended,
|
|
59
|
+
process?: Process
|
|
60
|
+
): Promise<WalletClient | undefined> => {
|
|
61
|
+
const updatedWalletClient = await switchChain(
|
|
62
|
+
this.walletClient,
|
|
63
|
+
this.statusManager,
|
|
64
|
+
step,
|
|
65
|
+
this.allowUserInteraction,
|
|
66
|
+
this.executionOptions?.switchChainHook
|
|
67
|
+
)
|
|
68
|
+
if (updatedWalletClient) {
|
|
69
|
+
this.walletClient = updatedWalletClient
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Prevent execution of the quote by wallet different from the one which requested the quote
|
|
73
|
+
if (this.walletClient.account?.address !== step.action.fromAddress) {
|
|
74
|
+
let processToUpdate = process
|
|
75
|
+
if (!processToUpdate) {
|
|
76
|
+
// We need to create some process if we don't have one so we can show the error
|
|
77
|
+
processToUpdate = this.statusManager.findOrCreateProcess(
|
|
78
|
+
step,
|
|
79
|
+
'TRANSACTION'
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
const errorMessage =
|
|
83
|
+
'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'
|
|
84
|
+
this.statusManager.updateProcess(step, processToUpdate.type, 'FAILED', {
|
|
85
|
+
error: {
|
|
86
|
+
code: LiFiErrorCode.WalletChangedDuringExecution,
|
|
87
|
+
message: errorMessage,
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
this.statusManager.updateExecution(step, 'FAILED')
|
|
91
|
+
throw new TransactionError(
|
|
92
|
+
LiFiErrorCode.WalletChangedDuringExecution,
|
|
93
|
+
errorMessage
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
return updatedWalletClient
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
executeStep = async (step: LiFiStepExtended): Promise<LiFiStepExtended> => {
|
|
100
|
+
step.execution = this.statusManager.initExecutionObject(step)
|
|
101
|
+
|
|
102
|
+
// Find if it's bridging and the step is waiting for a transaction on the receiving chain
|
|
103
|
+
const recievingChainProcess = step.execution?.process.find(
|
|
104
|
+
(process) => process.type === 'RECEIVING_CHAIN'
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
// Make sure that the chain is still correct
|
|
108
|
+
// If the step is waiting for a transaction on the receiving chain, we do not switch the chain
|
|
109
|
+
// All changes are already done from the source chain
|
|
110
|
+
// Return the step
|
|
111
|
+
if (recievingChainProcess?.substatus !== 'WAIT_DESTINATION_TRANSACTION') {
|
|
112
|
+
const updatedWalletClient = await this.checkWalletClient(step)
|
|
113
|
+
if (!updatedWalletClient) {
|
|
114
|
+
return step
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const isMultisigWalletClient = !!this.multisig?.isMultisigWalletClient
|
|
119
|
+
const multisigBatchTransactions: MultisigTransaction[] = []
|
|
120
|
+
|
|
121
|
+
const shouldBatchTransactions =
|
|
122
|
+
this.multisig?.shouldBatchTransactions &&
|
|
123
|
+
!!this.multisig.sendBatchTransaction
|
|
124
|
+
|
|
125
|
+
const fromChain = await config.getChainById(step.action.fromChainId)
|
|
126
|
+
const toChain = await config.getChainById(step.action.toChainId)
|
|
127
|
+
|
|
128
|
+
const isBridgeExecution = fromChain.id !== toChain.id
|
|
129
|
+
const currentProcessType = isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'
|
|
130
|
+
|
|
131
|
+
// STEP 1: Check allowance
|
|
132
|
+
const existingProcess = step.execution.process.find(
|
|
133
|
+
(p) => p.type === currentProcessType
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
// Check token approval only if fromToken is not the native token => no approval needed in that case
|
|
137
|
+
const checkForAllowance =
|
|
138
|
+
!existingProcess?.txHash &&
|
|
139
|
+
!isZeroAddress(step.action.fromToken.address) &&
|
|
140
|
+
(shouldBatchTransactions || !isMultisigWalletClient)
|
|
141
|
+
|
|
142
|
+
if (checkForAllowance) {
|
|
143
|
+
const data = await checkAllowance(
|
|
144
|
+
fromChain,
|
|
145
|
+
step,
|
|
146
|
+
this.walletClient,
|
|
147
|
+
this.statusManager,
|
|
148
|
+
this.executionOptions,
|
|
149
|
+
this.allowUserInteraction,
|
|
150
|
+
shouldBatchTransactions
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
if (data) {
|
|
154
|
+
// allowance doesn't need value
|
|
155
|
+
const baseTransaction: MultisigTransaction = {
|
|
156
|
+
to: step.action.fromToken.address,
|
|
157
|
+
data,
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
multisigBatchTransactions.push(baseTransaction)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// STEP 2: Get transaction
|
|
165
|
+
let process = this.statusManager.findOrCreateProcess(
|
|
166
|
+
step,
|
|
167
|
+
currentProcessType
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
if (process.status !== 'DONE') {
|
|
171
|
+
const multisigProcess = step.execution.process.find(
|
|
172
|
+
(p) => !!p.multisigTxHash
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
if (isMultisigWalletClient && multisigProcess) {
|
|
177
|
+
const multisigTxHash = multisigProcess.multisigTxHash as Hash
|
|
178
|
+
if (!multisigTxHash) {
|
|
179
|
+
throw new ValidationError(
|
|
180
|
+
'Multisig internal transaction hash is undefined.'
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
await updateMultisigRouteProcess(
|
|
184
|
+
multisigTxHash,
|
|
185
|
+
step,
|
|
186
|
+
process.type,
|
|
187
|
+
fromChain,
|
|
188
|
+
this.statusManager,
|
|
189
|
+
this.multisig
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
let txHash: Hash
|
|
194
|
+
if (process.txHash) {
|
|
195
|
+
// Make sure that the chain is still correct
|
|
196
|
+
const updatedWalletClient = await this.checkWalletClient(
|
|
197
|
+
step,
|
|
198
|
+
process
|
|
199
|
+
)
|
|
200
|
+
if (!updatedWalletClient) {
|
|
201
|
+
return step
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Wait for exiting transaction
|
|
205
|
+
txHash = process.txHash as Hash
|
|
206
|
+
} else {
|
|
207
|
+
process = this.statusManager.updateProcess(
|
|
208
|
+
step,
|
|
209
|
+
process.type,
|
|
210
|
+
'STARTED'
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
// Check balance
|
|
214
|
+
await checkBalance(this.walletClient.account!.address, step)
|
|
215
|
+
|
|
216
|
+
// Create new transaction
|
|
217
|
+
if (!step.transactionRequest) {
|
|
218
|
+
const { execution, ...stepBase } = step
|
|
219
|
+
const updatedStep = await getStepTransaction(stepBase)
|
|
220
|
+
const comparedStep = await stepComparison(
|
|
221
|
+
this.statusManager,
|
|
222
|
+
step,
|
|
223
|
+
updatedStep,
|
|
224
|
+
this.allowUserInteraction,
|
|
225
|
+
this.executionOptions
|
|
226
|
+
)
|
|
227
|
+
step = {
|
|
228
|
+
...comparedStep,
|
|
229
|
+
execution: step.execution,
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (!step.transactionRequest) {
|
|
234
|
+
throw new TransactionError(
|
|
235
|
+
LiFiErrorCode.TransactionUnprepared,
|
|
236
|
+
'Unable to prepare transaction.'
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// STEP 3: Send the transaction
|
|
241
|
+
// Make sure that the chain is still correct
|
|
242
|
+
const updatedWalletClient = await this.checkWalletClient(
|
|
243
|
+
step,
|
|
244
|
+
process
|
|
245
|
+
)
|
|
246
|
+
if (!updatedWalletClient) {
|
|
247
|
+
return step
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
process = this.statusManager.updateProcess(
|
|
251
|
+
step,
|
|
252
|
+
process.type,
|
|
253
|
+
'ACTION_REQUIRED'
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
if (!this.allowUserInteraction) {
|
|
257
|
+
return step
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
let transactionRequest: TransactionParameters = {
|
|
261
|
+
to: step.transactionRequest.to as Hash,
|
|
262
|
+
from: step.transactionRequest.from as Hash,
|
|
263
|
+
data: step.transactionRequest.data as Hash,
|
|
264
|
+
value: step.transactionRequest.value
|
|
265
|
+
? BigInt(step.transactionRequest.value as string)
|
|
266
|
+
: undefined,
|
|
267
|
+
gas: step.transactionRequest.gasLimit
|
|
268
|
+
? BigInt(step.transactionRequest.gasLimit as string)
|
|
269
|
+
: undefined,
|
|
270
|
+
// gasPrice: step.transactionRequest.gasPrice
|
|
271
|
+
// ? BigInt(step.transactionRequest.gasPrice as string)
|
|
272
|
+
// : undefined,
|
|
273
|
+
// maxFeePerGas: step.transactionRequest.maxFeePerGas
|
|
274
|
+
// ? BigInt(step.transactionRequest.maxFeePerGas as string)
|
|
275
|
+
// : undefined,
|
|
276
|
+
maxPriorityFeePerGas:
|
|
277
|
+
this.walletClient.account?.type === 'local'
|
|
278
|
+
? await getMaxPriorityFeePerGas(
|
|
279
|
+
this.walletClient.extend(publicActions) as PublicClient
|
|
280
|
+
)
|
|
281
|
+
: step.transactionRequest.maxPriorityFeePerGas
|
|
282
|
+
? BigInt(
|
|
283
|
+
step.transactionRequest.maxPriorityFeePerGas as string
|
|
284
|
+
)
|
|
285
|
+
: undefined,
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (this.executionOptions?.updateTransactionRequestHook) {
|
|
289
|
+
const customizedTransactionRequest: TransactionParameters =
|
|
290
|
+
await this.executionOptions.updateTransactionRequestHook({
|
|
291
|
+
requestType: 'transaction',
|
|
292
|
+
...transactionRequest,
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
transactionRequest = {
|
|
296
|
+
...transactionRequest,
|
|
297
|
+
...customizedTransactionRequest,
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (shouldBatchTransactions && this.multisig?.sendBatchTransaction) {
|
|
302
|
+
if (transactionRequest.to && transactionRequest.data) {
|
|
303
|
+
const populatedTransaction: MultisigTransaction = {
|
|
304
|
+
value: transactionRequest.value,
|
|
305
|
+
to: transactionRequest.to,
|
|
306
|
+
data: transactionRequest.data,
|
|
307
|
+
}
|
|
308
|
+
multisigBatchTransactions.push(populatedTransaction)
|
|
309
|
+
|
|
310
|
+
txHash = await this.multisig?.sendBatchTransaction(
|
|
311
|
+
multisigBatchTransactions
|
|
312
|
+
)
|
|
313
|
+
} else {
|
|
314
|
+
throw new TransactionError(
|
|
315
|
+
LiFiErrorCode.TransactionUnprepared,
|
|
316
|
+
'Unable to prepare transaction.'
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
} else {
|
|
320
|
+
txHash = await this.walletClient.sendTransaction({
|
|
321
|
+
to: transactionRequest.to as Address,
|
|
322
|
+
account: this.walletClient.account!,
|
|
323
|
+
data: transactionRequest.data,
|
|
324
|
+
value: transactionRequest.value,
|
|
325
|
+
gas: transactionRequest.gas,
|
|
326
|
+
gasPrice: transactionRequest.gasPrice,
|
|
327
|
+
maxFeePerGas: transactionRequest.maxFeePerGas,
|
|
328
|
+
maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas,
|
|
329
|
+
chain: null,
|
|
330
|
+
} as SendTransactionParameters)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// STEP 4: Wait for the transaction
|
|
334
|
+
if (isMultisigWalletClient) {
|
|
335
|
+
process = this.statusManager.updateProcess(
|
|
336
|
+
step,
|
|
337
|
+
process.type,
|
|
338
|
+
'ACTION_REQUIRED',
|
|
339
|
+
{
|
|
340
|
+
multisigTxHash: txHash,
|
|
341
|
+
}
|
|
342
|
+
)
|
|
343
|
+
} else {
|
|
344
|
+
process = this.statusManager.updateProcess(
|
|
345
|
+
step,
|
|
346
|
+
process.type,
|
|
347
|
+
'PENDING',
|
|
348
|
+
{
|
|
349
|
+
txHash: txHash,
|
|
350
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`,
|
|
351
|
+
}
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
let replacementReason: ReplacementReason | undefined
|
|
357
|
+
const transactionReceipt = await this.walletClient
|
|
358
|
+
.extend(publicActions)
|
|
359
|
+
.waitForTransactionReceipt({
|
|
360
|
+
hash: txHash,
|
|
361
|
+
onReplaced: (response) => {
|
|
362
|
+
replacementReason = response.reason
|
|
363
|
+
this.statusManager.updateProcess(step, process.type, 'PENDING', {
|
|
364
|
+
txHash: response.transaction.hash,
|
|
365
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.hash}`,
|
|
366
|
+
})
|
|
367
|
+
},
|
|
368
|
+
retryCount,
|
|
369
|
+
retryDelay,
|
|
370
|
+
})
|
|
371
|
+
|
|
372
|
+
if (transactionReceipt.status === 'reverted') {
|
|
373
|
+
throw new TransactionError(
|
|
374
|
+
LiFiErrorCode.TransactionFailed,
|
|
375
|
+
'Transaction was reverted.'
|
|
376
|
+
)
|
|
377
|
+
}
|
|
378
|
+
if (replacementReason === 'cancelled') {
|
|
379
|
+
throw new TransactionError(
|
|
380
|
+
LiFiErrorCode.TransactionCanceled,
|
|
381
|
+
'User canceled transaction.'
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// if it's multisig wallet client and the process is in ACTION_REQUIRED
|
|
386
|
+
// then signatures are still needed
|
|
387
|
+
if (isMultisigWalletClient && process.status === 'ACTION_REQUIRED') {
|
|
388
|
+
await updateMultisigRouteProcess(
|
|
389
|
+
transactionReceipt.transactionHash,
|
|
390
|
+
step,
|
|
391
|
+
process.type,
|
|
392
|
+
fromChain,
|
|
393
|
+
this.statusManager,
|
|
394
|
+
this.multisig
|
|
395
|
+
)
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (!isMultisigWalletClient) {
|
|
399
|
+
process = this.statusManager.updateProcess(
|
|
400
|
+
step,
|
|
401
|
+
process.type,
|
|
402
|
+
'PENDING',
|
|
403
|
+
{
|
|
404
|
+
txHash: transactionReceipt.transactionHash,
|
|
405
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${transactionReceipt.transactionHash}`,
|
|
406
|
+
}
|
|
407
|
+
)
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (isBridgeExecution) {
|
|
411
|
+
process = this.statusManager.updateProcess(step, process.type, 'DONE')
|
|
412
|
+
}
|
|
413
|
+
} catch (e: any) {
|
|
414
|
+
const error = await parseError(e, step, process)
|
|
415
|
+
process = this.statusManager.updateProcess(
|
|
416
|
+
step,
|
|
417
|
+
process.type,
|
|
418
|
+
'FAILED',
|
|
419
|
+
{
|
|
420
|
+
error: {
|
|
421
|
+
message: error.message,
|
|
422
|
+
htmlMessage: error.htmlMessage,
|
|
423
|
+
code: error.code,
|
|
424
|
+
},
|
|
425
|
+
}
|
|
426
|
+
)
|
|
427
|
+
this.statusManager.updateExecution(step, 'FAILED')
|
|
428
|
+
throw error
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// STEP 5: Wait for the receiving chain
|
|
433
|
+
const processTxHash = process.txHash
|
|
434
|
+
if (isBridgeExecution) {
|
|
435
|
+
process = this.statusManager.findOrCreateProcess(
|
|
436
|
+
step,
|
|
437
|
+
'RECEIVING_CHAIN',
|
|
438
|
+
'PENDING'
|
|
439
|
+
)
|
|
440
|
+
}
|
|
441
|
+
let statusResponse: FullStatusData
|
|
442
|
+
|
|
443
|
+
try {
|
|
444
|
+
if (!processTxHash) {
|
|
445
|
+
throw new Error('Transaction hash is undefined.')
|
|
446
|
+
}
|
|
447
|
+
statusResponse = (await waitForReceivingTransaction(
|
|
448
|
+
processTxHash,
|
|
449
|
+
this.statusManager,
|
|
450
|
+
process.type,
|
|
451
|
+
step
|
|
452
|
+
)) as FullStatusData
|
|
453
|
+
|
|
454
|
+
const statusReceiving =
|
|
455
|
+
statusResponse.receiving as ExtendedTransactionInfo
|
|
456
|
+
|
|
457
|
+
process = this.statusManager.updateProcess(step, process.type, 'DONE', {
|
|
458
|
+
substatus: statusResponse.substatus,
|
|
459
|
+
substatusMessage:
|
|
460
|
+
statusResponse.substatusMessage ||
|
|
461
|
+
getSubstatusMessage(statusResponse.status, statusResponse.substatus),
|
|
462
|
+
txHash: statusReceiving?.txHash,
|
|
463
|
+
txLink: `${toChain.metamask.blockExplorerUrls[0]}tx/${statusReceiving?.txHash}`,
|
|
464
|
+
})
|
|
465
|
+
|
|
466
|
+
this.statusManager.updateExecution(step, 'DONE', {
|
|
467
|
+
fromAmount: statusResponse.sending.amount,
|
|
468
|
+
toAmount: statusReceiving?.amount,
|
|
469
|
+
toToken: statusReceiving?.token,
|
|
470
|
+
gasCosts: [
|
|
471
|
+
{
|
|
472
|
+
amount: statusResponse.sending.gasAmount,
|
|
473
|
+
amountUSD: statusResponse.sending.gasAmountUSD,
|
|
474
|
+
token: statusResponse.sending.gasToken,
|
|
475
|
+
estimate: statusResponse.sending.gasUsed,
|
|
476
|
+
limit: statusResponse.sending.gasUsed,
|
|
477
|
+
price: statusResponse.sending.gasPrice,
|
|
478
|
+
type: 'SEND',
|
|
479
|
+
},
|
|
480
|
+
],
|
|
481
|
+
})
|
|
482
|
+
} catch (e: unknown) {
|
|
483
|
+
const htmlMessage = await getTransactionFailedMessage(
|
|
484
|
+
step,
|
|
485
|
+
process.txLink
|
|
486
|
+
)
|
|
487
|
+
|
|
488
|
+
process = this.statusManager.updateProcess(step, process.type, 'FAILED', {
|
|
489
|
+
error: {
|
|
490
|
+
code: LiFiErrorCode.TransactionFailed,
|
|
491
|
+
message: 'Failed while waiting for receiving chain.',
|
|
492
|
+
htmlMessage,
|
|
493
|
+
},
|
|
494
|
+
})
|
|
495
|
+
this.statusManager.updateExecution(step, 'FAILED')
|
|
496
|
+
console.warn(e)
|
|
497
|
+
throw e
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// DONE
|
|
501
|
+
return step
|
|
502
|
+
}
|
|
503
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Abi } from 'viem'
|
|
2
|
+
|
|
3
|
+
export const approveAbi: Abi = [
|
|
4
|
+
{
|
|
5
|
+
name: 'approve',
|
|
6
|
+
inputs: [
|
|
7
|
+
{ internalType: 'address', name: 'spender', type: 'address' },
|
|
8
|
+
{ internalType: 'uint256', name: 'amount', type: 'uint256' },
|
|
9
|
+
],
|
|
10
|
+
outputs: [{ internalType: 'bool', name: 'approved', type: 'bool' }],
|
|
11
|
+
stateMutability: 'nonpayable',
|
|
12
|
+
type: 'function',
|
|
13
|
+
},
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
export const allowanceAbi: Abi = [
|
|
17
|
+
{
|
|
18
|
+
name: 'allowance',
|
|
19
|
+
inputs: [
|
|
20
|
+
{ internalType: 'address', name: 'owner', type: 'address' },
|
|
21
|
+
{ internalType: 'address', name: 'spender', type: 'address' },
|
|
22
|
+
],
|
|
23
|
+
outputs: [{ internalType: 'uint256', name: 'allowance', type: 'uint256' }],
|
|
24
|
+
stateMutability: 'view',
|
|
25
|
+
type: 'function',
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
export const getEthBalanceAbi: Abi = [
|
|
30
|
+
{
|
|
31
|
+
inputs: [{ name: '_owner', type: 'address' }],
|
|
32
|
+
name: 'getEthBalance',
|
|
33
|
+
outputs: [{ name: 'balance', type: 'uint256' }],
|
|
34
|
+
type: 'function',
|
|
35
|
+
stateMutability: 'view',
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
export const balanceOfAbi: Abi = [
|
|
40
|
+
{
|
|
41
|
+
inputs: [{ name: '_owner', type: 'address' }],
|
|
42
|
+
name: 'balanceOf',
|
|
43
|
+
outputs: [{ name: 'balance', type: 'uint256' }],
|
|
44
|
+
type: 'function',
|
|
45
|
+
stateMutability: 'view',
|
|
46
|
+
},
|
|
47
|
+
]
|