@lifi/sdk 2.3.1 → 3.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/LiFi.js +222 -250
- package/dist/cjs/LiFi.js.map +1 -0
- package/dist/cjs/allowance/getAllowance.js +82 -0
- package/dist/cjs/allowance/getAllowance.js.map +1 -0
- package/dist/cjs/allowance/index.js +5 -16
- package/dist/cjs/allowance/index.js.map +1 -0
- package/dist/cjs/allowance/setAllowance.js +71 -0
- package/dist/cjs/allowance/setAllowance.js.map +1 -0
- package/dist/cjs/{types/internal.types.js → allowance/types.js} +1 -0
- package/dist/cjs/allowance/types.js.map +1 -0
- package/dist/cjs/balance/getBalance.js +97 -0
- package/dist/cjs/balance/getBalance.js.map +1 -0
- package/dist/cjs/balance/getTokenBalance.js +7 -10
- package/dist/cjs/balance/getTokenBalance.js.map +1 -0
- package/dist/cjs/balance/index.js +4 -24
- package/dist/cjs/balance/index.js.map +1 -0
- package/dist/cjs/connectors.js +28 -48
- package/dist/cjs/connectors.js.map +1 -0
- package/dist/cjs/constants.js +7 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/execution/BaseStepExecutor.js +54 -0
- package/dist/cjs/execution/BaseStepExecutor.js.map +1 -0
- package/dist/cjs/execution/EVMStepExecutor.js +271 -0
- package/dist/cjs/execution/EVMStepExecutor.js.map +1 -0
- package/dist/cjs/execution/RouteExecutionManager.js +196 -197
- package/dist/cjs/execution/RouteExecutionManager.js.map +1 -0
- package/dist/cjs/execution/StatusManager.js +142 -136
- package/dist/cjs/execution/StatusManager.js.map +1 -0
- package/dist/cjs/execution/StepExecutionManager.js +220 -233
- package/dist/cjs/execution/StepExecutionManager.js.map +1 -0
- package/dist/cjs/execution/checkAllowance.js +76 -0
- package/dist/cjs/execution/checkAllowance.js.map +1 -0
- package/dist/cjs/execution/checkBalance.js +42 -0
- package/dist/cjs/execution/checkBalance.js.map +1 -0
- package/dist/cjs/execution/index.js +4 -15
- package/dist/cjs/execution/index.js.map +1 -0
- package/dist/cjs/execution/multisig.js +13 -17
- package/dist/cjs/execution/multisig.js.map +1 -0
- package/dist/cjs/execution/prepareRestart.js +23 -0
- package/dist/cjs/execution/prepareRestart.js.map +1 -0
- package/dist/cjs/execution/stepComparison.js +5 -17
- package/dist/cjs/execution/stepComparison.js.map +1 -0
- package/dist/cjs/execution/switchChain.js +10 -22
- package/dist/cjs/execution/switchChain.js.map +1 -0
- package/dist/cjs/execution/types.js +3 -0
- package/dist/cjs/execution/types.js.map +1 -0
- package/dist/cjs/execution/utils.js +12 -67
- package/dist/cjs/execution/utils.js.map +1 -0
- package/dist/cjs/execution/waitForReceivingTransaction.js +56 -0
- package/dist/cjs/execution/waitForReceivingTransaction.js.map +1 -0
- package/dist/cjs/helpers.js +12 -58
- package/dist/cjs/helpers.js.map +1 -0
- package/dist/cjs/index.js +16 -22
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/providers/EVM.js +35 -0
- package/dist/cjs/providers/EVM.js.map +1 -0
- package/dist/cjs/providers/Solana.js +38 -0
- package/dist/cjs/providers/Solana.js.map +1 -0
- package/dist/cjs/providers/index.js +5 -0
- package/dist/cjs/providers/index.js.map +1 -0
- package/dist/cjs/providers/types.js +9 -0
- package/dist/cjs/providers/types.js.map +1 -0
- package/dist/cjs/request.js +10 -13
- package/dist/cjs/request.js.map +1 -0
- package/dist/cjs/services/ApiService.js +70 -86
- package/dist/cjs/services/ApiService.js.map +1 -0
- package/dist/cjs/services/ChainsService.js +19 -9
- package/dist/cjs/services/ChainsService.js.map +1 -0
- package/dist/cjs/services/ConfigService.js +94 -67
- package/dist/cjs/services/ConfigService.js.map +1 -0
- package/dist/cjs/typeguards.js +1 -0
- package/dist/cjs/typeguards.js.map +1 -0
- package/dist/cjs/types/abi.js +46 -0
- package/dist/cjs/types/abi.js.map +1 -0
- package/dist/cjs/types/index.js +4 -20
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/internal.js +3 -0
- package/dist/cjs/types/internal.js.map +1 -0
- package/dist/cjs/utils/errors.js +63 -40
- package/dist/cjs/utils/errors.js.map +1 -0
- package/dist/cjs/utils/getMaxPriorityFeePerGas.js +23 -0
- package/dist/cjs/utils/getMaxPriorityFeePerGas.js.map +1 -0
- package/dist/cjs/utils/index.js +9 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/median.js +16 -0
- package/dist/cjs/utils/median.js.map +1 -0
- package/dist/cjs/utils/parseError.js +55 -92
- package/dist/cjs/utils/parseError.js.map +1 -0
- package/dist/cjs/utils/utils.js +10 -85
- package/dist/cjs/utils/utils.js.map +1 -0
- package/dist/cjs/version.js +2 -1
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/LiFi.js +375 -0
- package/dist/esm/LiFi.js.map +1 -0
- package/dist/esm/allowance/getAllowance.js +79 -0
- package/dist/esm/allowance/getAllowance.js.map +1 -0
- package/dist/esm/allowance/index.js +4 -0
- package/dist/esm/allowance/index.js.map +1 -0
- package/dist/esm/allowance/setAllowance.js +67 -0
- package/dist/esm/allowance/setAllowance.js.map +1 -0
- package/dist/esm/allowance/types.js +2 -0
- package/dist/esm/allowance/types.js.map +1 -0
- package/dist/esm/balance/getBalance.js +93 -0
- package/dist/esm/balance/getBalance.js.map +1 -0
- package/dist/{balance → esm/balance}/getTokenBalance.js +5 -4
- package/dist/esm/balance/getTokenBalance.js.map +1 -0
- package/dist/esm/balance/index.js +3 -0
- package/dist/esm/balance/index.js.map +1 -0
- package/dist/esm/connectors.js +42 -0
- package/dist/esm/connectors.js.map +1 -0
- package/dist/esm/constants.js +7 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/execution/BaseStepExecutor.js +51 -0
- package/dist/esm/execution/BaseStepExecutor.js.map +1 -0
- package/dist/esm/execution/EVMStepExecutor.js +299 -0
- package/dist/esm/execution/EVMStepExecutor.js.map +1 -0
- package/dist/esm/execution/RouteExecutionManager.js +268 -0
- package/dist/esm/execution/RouteExecutionManager.js.map +1 -0
- package/dist/esm/execution/StatusManager.js +216 -0
- package/dist/esm/execution/StatusManager.js.map +1 -0
- package/dist/esm/execution/StepExecutionManager.js +280 -0
- package/dist/esm/execution/StepExecutionManager.js.map +1 -0
- package/dist/esm/execution/checkAllowance.js +74 -0
- package/dist/esm/execution/checkAllowance.js.map +1 -0
- package/dist/esm/execution/checkBalance.js +39 -0
- package/dist/esm/execution/checkBalance.js.map +1 -0
- package/dist/esm/execution/index.js +3 -0
- package/dist/esm/execution/index.js.map +1 -0
- package/dist/esm/execution/multisig.js +26 -0
- package/dist/esm/execution/multisig.js.map +1 -0
- package/dist/esm/execution/prepareRestart.js +64 -0
- package/dist/esm/execution/prepareRestart.js.map +1 -0
- package/dist/{execution → esm/execution}/stepComparison.js +5 -4
- package/dist/esm/execution/stepComparison.js.map +1 -0
- package/dist/{execution → esm/execution}/switchChain.js +19 -12
- package/dist/esm/execution/switchChain.js.map +1 -0
- package/dist/esm/execution/types.js +2 -0
- package/dist/esm/execution/types.js.map +1 -0
- package/dist/esm/execution/utils.js +80 -0
- package/dist/esm/execution/utils.js.map +1 -0
- package/dist/esm/execution/waitForReceivingTransaction.js +52 -0
- package/dist/esm/execution/waitForReceivingTransaction.js.map +1 -0
- package/dist/{helpers.js → esm/helpers.js} +9 -37
- package/dist/esm/helpers.js.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/providers/EVM.js +30 -0
- package/dist/esm/providers/EVM.js.map +1 -0
- package/dist/esm/providers/Solana.js +34 -0
- package/dist/esm/providers/Solana.js.map +1 -0
- package/dist/esm/providers/index.js +2 -0
- package/dist/esm/providers/index.js.map +1 -0
- package/dist/esm/providers/types.js +6 -0
- package/dist/esm/providers/types.js.map +1 -0
- package/dist/{request.js → esm/request.js} +6 -5
- package/dist/esm/request.js.map +1 -0
- package/dist/{services → esm/services}/ApiService.js +29 -26
- package/dist/esm/services/ApiService.js.map +1 -0
- package/dist/{services → esm/services}/ChainsService.js +16 -4
- package/dist/esm/services/ChainsService.js.map +1 -0
- package/dist/esm/services/ConfigService.js +143 -0
- package/dist/esm/services/ConfigService.js.map +1 -0
- package/dist/{typeguards.js → esm/typeguards.js} +1 -0
- package/dist/esm/typeguards.js.map +1 -0
- package/dist/esm/types/abi.js +43 -0
- package/dist/esm/types/abi.js.map +1 -0
- package/dist/esm/types/index.js +3 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/internal.js +2 -0
- package/dist/esm/types/internal.js.map +1 -0
- package/dist/{utils → esm/utils}/errors.js +61 -35
- package/dist/esm/utils/errors.js.map +1 -0
- package/dist/esm/utils/getMaxPriorityFeePerGas.js +19 -0
- package/dist/esm/utils/getMaxPriorityFeePerGas.js.map +1 -0
- package/dist/esm/utils/index.js +6 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/median.js +12 -0
- package/dist/esm/utils/median.js.map +1 -0
- package/dist/{utils → esm/utils}/parseError.js +45 -41
- package/dist/esm/utils/parseError.js.map +1 -0
- package/dist/esm/utils/utils.js +38 -0
- package/dist/esm/utils/utils.js.map +1 -0
- package/dist/esm/version.js +3 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/types/LiFi.d.ts +179 -0
- package/dist/types/LiFi.d.ts.map +1 -0
- package/dist/types/allowance/getAllowance.d.ts +7 -0
- package/dist/types/allowance/getAllowance.d.ts.map +1 -0
- package/dist/types/allowance/index.d.ts +4 -0
- package/dist/types/allowance/index.d.ts.map +1 -0
- package/dist/types/allowance/setAllowance.d.ts +7 -0
- package/dist/types/allowance/setAllowance.d.ts.map +1 -0
- package/dist/types/allowance/types.d.ts +28 -0
- package/dist/types/allowance/types.d.ts.map +1 -0
- package/dist/types/balance/getBalance.d.ts +3 -0
- package/dist/types/balance/getBalance.d.ts.map +1 -0
- package/dist/{balance → types/balance}/getTokenBalance.d.ts +3 -2
- package/dist/types/balance/getTokenBalance.d.ts.map +1 -0
- package/dist/types/balance/index.d.ts +3 -0
- package/dist/types/balance/index.d.ts.map +1 -0
- package/dist/types/connectors.d.ts +9 -0
- package/dist/types/connectors.d.ts.map +1 -0
- package/dist/types/constants.d.ts +7 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/execution/BaseStepExecutor.d.ts +13 -0
- package/dist/types/execution/BaseStepExecutor.d.ts.map +1 -0
- package/dist/types/execution/EVMStepExecutor.d.ts +14 -0
- package/dist/types/execution/EVMStepExecutor.d.ts.map +1 -0
- package/dist/types/execution/RouteExecutionManager.d.ts +61 -0
- package/dist/types/execution/RouteExecutionManager.d.ts.map +1 -0
- package/dist/types/execution/StatusManager.d.ts +69 -0
- package/dist/types/execution/StatusManager.d.ts.map +1 -0
- package/dist/types/execution/StepExecutionManager.d.ts +8 -0
- package/dist/types/execution/StepExecutionManager.d.ts.map +1 -0
- package/dist/types/execution/checkAllowance.d.ts +6 -0
- package/dist/types/execution/checkAllowance.d.ts.map +1 -0
- package/dist/types/execution/checkBalance.d.ts +3 -0
- package/dist/types/execution/checkBalance.d.ts.map +1 -0
- package/dist/types/execution/index.d.ts +3 -0
- package/dist/types/execution/index.d.ts.map +1 -0
- package/dist/types/execution/multisig.d.ts +5 -0
- package/dist/types/execution/multisig.d.ts.map +1 -0
- package/dist/types/execution/prepareRestart.d.ts +3 -0
- package/dist/types/execution/prepareRestart.d.ts.map +1 -0
- package/dist/{execution → types/execution}/stepComparison.d.ts +6 -4
- package/dist/types/execution/stepComparison.d.ts.map +1 -0
- package/dist/types/execution/switchChain.d.ts +23 -0
- package/dist/types/execution/switchChain.d.ts.map +1 -0
- package/dist/types/execution/types.d.ts +83 -0
- package/dist/types/execution/types.d.ts.map +1 -0
- package/dist/types/execution/utils.d.ts +13 -0
- package/dist/types/execution/utils.d.ts.map +1 -0
- package/dist/types/execution/waitForReceivingTransaction.d.ts +4 -0
- package/dist/types/execution/waitForReceivingTransaction.d.ts.map +1 -0
- package/dist/types/helpers.d.ts +19 -0
- package/dist/types/helpers.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -3
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/providers/EVM.d.ts +11 -0
- package/dist/types/providers/EVM.d.ts.map +1 -0
- package/dist/types/providers/Solana.d.ts +10 -0
- package/dist/types/providers/Solana.d.ts.map +1 -0
- package/dist/types/providers/index.d.ts +2 -0
- package/dist/types/providers/index.d.ts.map +1 -0
- package/dist/types/providers/types.d.ts +13 -0
- package/dist/types/providers/types.d.ts.map +1 -0
- package/dist/{request.d.ts → types/request.d.ts} +1 -0
- package/dist/types/request.d.ts.map +1 -0
- package/dist/{cjs → types}/services/ApiService.d.ts +5 -5
- package/dist/types/services/ApiService.d.ts.map +1 -0
- package/dist/{services → types/services}/ChainsService.d.ts +3 -2
- package/dist/types/services/ChainsService.d.ts.map +1 -0
- package/dist/{services → types/services}/ConfigService.d.ts +10 -6
- package/dist/types/services/ConfigService.d.ts.map +1 -0
- package/dist/{cjs → types}/typeguards.d.ts +3 -2
- package/dist/types/typeguards.d.ts.map +1 -0
- package/dist/types/types/abi.d.ts +6 -0
- package/dist/types/types/abi.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/internal.d.ts +61 -0
- package/dist/types/types/internal.d.ts.map +1 -0
- package/dist/{cjs → types}/utils/errors.d.ts +16 -14
- package/dist/types/utils/errors.d.ts.map +1 -0
- package/dist/types/utils/getMaxPriorityFeePerGas.d.ts +3 -0
- package/dist/types/utils/getMaxPriorityFeePerGas.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +6 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/median.d.ts +2 -0
- package/dist/types/utils/median.d.ts.map +1 -0
- package/dist/{utils → types/utils}/parseError.d.ts +7 -6
- package/dist/types/utils/parseError.d.ts.map +1 -0
- package/dist/types/utils/utils.d.ts +11 -0
- package/dist/types/utils/utils.d.ts.map +1 -0
- package/dist/types/version.d.ts +3 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +37 -95
- package/dist/LiFi.d.ts +0 -164
- package/dist/LiFi.js +0 -235
- package/dist/allowance/checkAllowance.d.ts +0 -4
- package/dist/allowance/checkAllowance.js +0 -96
- package/dist/allowance/index.d.ts +0 -2
- package/dist/allowance/index.js +0 -2
- package/dist/allowance/tokenApproval.d.ts +0 -22
- package/dist/allowance/tokenApproval.js +0 -59
- package/dist/allowance/utils.d.ts +0 -14
- package/dist/allowance/utils.js +0 -72
- package/dist/balance/checkBalance.d.ts +0 -3
- package/dist/balance/checkBalance.js +0 -38
- package/dist/balance/index.d.ts +0 -13
- package/dist/balance/index.js +0 -10
- package/dist/balance/utils.d.ts +0 -6
- package/dist/balance/utils.js +0 -143
- package/dist/cjs/LiFi.d.ts +0 -164
- package/dist/cjs/allowance/checkAllowance.d.ts +0 -4
- package/dist/cjs/allowance/checkAllowance.js +0 -103
- package/dist/cjs/allowance/index.d.ts +0 -2
- package/dist/cjs/allowance/tokenApproval.d.ts +0 -22
- package/dist/cjs/allowance/tokenApproval.js +0 -69
- package/dist/cjs/allowance/utils.d.ts +0 -14
- package/dist/cjs/allowance/utils.js +0 -82
- package/dist/cjs/balance/checkBalance.d.ts +0 -3
- package/dist/cjs/balance/checkBalance.js +0 -45
- package/dist/cjs/balance/getTokenBalance.d.ts +0 -8
- package/dist/cjs/balance/index.d.ts +0 -13
- package/dist/cjs/balance/utils.d.ts +0 -6
- package/dist/cjs/balance/utils.js +0 -150
- package/dist/cjs/connectors.d.ts +0 -6
- package/dist/cjs/execution/RouteExecutionManager.d.ts +0 -65
- package/dist/cjs/execution/StatusManager.d.ts +0 -68
- package/dist/cjs/execution/StepExecutionManager.d.ts +0 -7
- package/dist/cjs/execution/StepExecutor.d.ts +0 -15
- package/dist/cjs/execution/StepExecutor.js +0 -62
- package/dist/cjs/execution/index.d.ts +0 -1
- package/dist/cjs/execution/multisig.d.ts +0 -3
- package/dist/cjs/execution/stepComparison.d.ts +0 -14
- package/dist/cjs/execution/switchChain.d.ts +0 -16
- package/dist/cjs/execution/utils.d.ts +0 -6
- package/dist/cjs/helpers.d.ts +0 -28
- package/dist/cjs/index.d.ts +0 -5
- package/dist/cjs/request.d.ts +0 -9
- package/dist/cjs/services/ChainsService.d.ts +0 -11
- package/dist/cjs/services/ConfigService.d.ts +0 -23
- package/dist/cjs/types/ERC20.d.ts +0 -22
- package/dist/cjs/types/ERC20.js +0 -53
- package/dist/cjs/types/index.d.ts +0 -4
- package/dist/cjs/types/internal.types.d.ts +0 -151
- package/dist/cjs/utils/getProvider.d.ts +0 -3
- package/dist/cjs/utils/getProvider.js +0 -11
- package/dist/cjs/utils/multicall.d.ts +0 -10
- package/dist/cjs/utils/multicall.js +0 -68
- package/dist/cjs/utils/multicallAbi.json +0 -313
- package/dist/cjs/utils/parseError.d.ts +0 -37
- package/dist/cjs/utils/preRestart.d.ts +0 -3
- package/dist/cjs/utils/preRestart.js +0 -56
- package/dist/cjs/utils/utils.d.ts +0 -25
- package/dist/cjs/version.d.ts +0 -2
- package/dist/connectors.d.ts +0 -6
- package/dist/connectors.js +0 -57
- package/dist/execution/RouteExecutionManager.d.ts +0 -65
- package/dist/execution/RouteExecutionManager.js +0 -213
- package/dist/execution/StatusManager.d.ts +0 -68
- package/dist/execution/StatusManager.js +0 -168
- package/dist/execution/StepExecutionManager.d.ts +0 -7
- package/dist/execution/StepExecutionManager.js +0 -267
- package/dist/execution/StepExecutor.d.ts +0 -15
- package/dist/execution/StepExecutor.js +0 -58
- package/dist/execution/index.d.ts +0 -1
- package/dist/execution/index.js +0 -1
- package/dist/execution/multisig.d.ts +0 -3
- package/dist/execution/multisig.js +0 -27
- package/dist/execution/switchChain.d.ts +0 -16
- package/dist/execution/utils.d.ts +0 -6
- package/dist/execution/utils.js +0 -122
- package/dist/helpers.d.ts +0 -28
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -6
- package/dist/services/ApiService.d.ts +0 -17
- package/dist/services/ConfigService.js +0 -101
- package/dist/typeguards.d.ts +0 -4
- package/dist/types/ERC20.d.ts +0 -22
- package/dist/types/ERC20.js +0 -50
- package/dist/types/index.js +0 -4
- package/dist/types/internal.types.d.ts +0 -151
- package/dist/types/internal.types.js +0 -1
- package/dist/utils/errors.d.ts +0 -106
- package/dist/utils/getProvider.d.ts +0 -3
- package/dist/utils/getProvider.js +0 -7
- package/dist/utils/multicall.d.ts +0 -10
- package/dist/utils/multicall.js +0 -61
- package/dist/utils/multicallAbi.json +0 -313
- package/dist/utils/preRestart.d.ts +0 -3
- package/dist/utils/preRestart.js +0 -52
- package/dist/utils/utils.d.ts +0 -25
- package/dist/utils/utils.js +0 -99
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -2
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { ChainId, } from '../types';
|
|
2
|
-
const DefaultExecutionSettings = {
|
|
3
|
-
/* eslint-disable-next-line @typescript-eslint/no-empty-function */
|
|
4
|
-
updateRouteHook: () => { },
|
|
5
|
-
switchChainHook: () => Promise.resolve(undefined),
|
|
6
|
-
acceptExchangeRateUpdateHook: () => Promise.resolve(undefined),
|
|
7
|
-
infiniteApproval: false,
|
|
8
|
-
executeInBackground: false,
|
|
9
|
-
};
|
|
10
|
-
class ConfigService {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.resolveSetupPromise = undefined;
|
|
13
|
-
/**
|
|
14
|
-
* This call immediately returns the current config. It does not make sure that all chain data is already loaded
|
|
15
|
-
* Use this if you need access to basic information like API urls or settings
|
|
16
|
-
*/
|
|
17
|
-
this.getConfig = () => {
|
|
18
|
-
return this.config;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* This call waits for all setup promises to be done.
|
|
22
|
-
* Use this if you need access to chain data (RPCs or multicalls)
|
|
23
|
-
*/
|
|
24
|
-
this.getConfigAsync = async () => {
|
|
25
|
-
await this.setupPromise;
|
|
26
|
-
return this.config;
|
|
27
|
-
};
|
|
28
|
-
this.updateConfig = (configUpdate) => {
|
|
29
|
-
// API
|
|
30
|
-
this.config.apiUrl = configUpdate.apiUrl || this.config.apiUrl;
|
|
31
|
-
// RPCS
|
|
32
|
-
this.config.rpcs = Object.assign(this.config.rpcs, configUpdate.rpcs);
|
|
33
|
-
// MULTICALL
|
|
34
|
-
this.config.multicallAddresses = Object.assign(this.config.multicallAddresses, configUpdate.multicallAddresses);
|
|
35
|
-
// SETTINGS
|
|
36
|
-
this.config.defaultExecutionSettings = Object.assign(this.config.defaultExecutionSettings, configUpdate.defaultExecutionSettings);
|
|
37
|
-
// OPTIONS
|
|
38
|
-
this.config.defaultRouteOptions = Object.assign(this.config.defaultRouteOptions, configUpdate.defaultRouteOptions);
|
|
39
|
-
this.config.apiKey = configUpdate.apiKey || this.config.apiKey;
|
|
40
|
-
this.config.userId = configUpdate.userId || this.config.userId;
|
|
41
|
-
this.config.integrator = configUpdate.integrator || this.config.integrator;
|
|
42
|
-
this.config.defaultRouteOptions.integrator =
|
|
43
|
-
configUpdate.integrator ||
|
|
44
|
-
configUpdate.defaultRouteOptions?.integrator ||
|
|
45
|
-
this.config.integrator;
|
|
46
|
-
this.config.widgetVersion =
|
|
47
|
-
configUpdate.widgetVersion || this.config.widgetVersion;
|
|
48
|
-
this.config.multisigConfig =
|
|
49
|
-
configUpdate.multisigConfig || this.config.multisigConfig;
|
|
50
|
-
return this.config;
|
|
51
|
-
};
|
|
52
|
-
this.updateChains = (chains) => {
|
|
53
|
-
for (const chain of chains) {
|
|
54
|
-
const chainId = chain.id;
|
|
55
|
-
// set RPCs if they were not configured by the user before
|
|
56
|
-
if (!this.config.rpcs[chainId]?.length) {
|
|
57
|
-
this.config.rpcs[chainId] = chain.metamask.rpcUrls;
|
|
58
|
-
}
|
|
59
|
-
// set multicall addresses if they exist and were not configured by the user before
|
|
60
|
-
if (chain.multicallAddress && !this.config.multicallAddresses[chainId]) {
|
|
61
|
-
this.config.multicallAddresses[chainId] = chain.multicallAddress;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
this.resolveSetupPromise?.();
|
|
65
|
-
return this.config;
|
|
66
|
-
};
|
|
67
|
-
this.config = ConfigService.getDefaultConfig();
|
|
68
|
-
this.setupPromise = new Promise((resolve) => {
|
|
69
|
-
this.resolveSetupPromise = resolve;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
static chainIdToObject(val) {
|
|
73
|
-
const result = {};
|
|
74
|
-
const values = Object.values(ChainId);
|
|
75
|
-
values.forEach((chainId) => {
|
|
76
|
-
if (typeof chainId !== 'string') {
|
|
77
|
-
result[chainId] = val ? JSON.parse(JSON.stringify(val)) : val;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
static getInstance() {
|
|
83
|
-
if (!this.instance) {
|
|
84
|
-
this.instance = new ConfigService();
|
|
85
|
-
}
|
|
86
|
-
return this.instance;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
ConfigService.getDefaultConfig = () => {
|
|
90
|
-
return {
|
|
91
|
-
apiUrl: 'https://li.quest/v1',
|
|
92
|
-
rpcs: ConfigService.chainIdToObject([]),
|
|
93
|
-
multicallAddresses: ConfigService.chainIdToObject(undefined),
|
|
94
|
-
defaultExecutionSettings: DefaultExecutionSettings,
|
|
95
|
-
defaultRouteOptions: {
|
|
96
|
-
integrator: 'lifi-sdk',
|
|
97
|
-
},
|
|
98
|
-
integrator: 'lifi-sdk',
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
export default ConfigService;
|
package/dist/typeguards.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { LifiStep, RoutesRequest, StaticToken } from './types';
|
|
2
|
-
export declare const isRoutesRequest: (routesRequest: RoutesRequest) => routesRequest is RoutesRequest;
|
|
3
|
-
export declare const isStep: (step: LifiStep) => step is LifiStep;
|
|
4
|
-
export declare const isToken: (token: StaticToken) => token is StaticToken;
|
package/dist/types/ERC20.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseContract, BigNumber, BigNumberish, CallOverrides, ContractTransaction, Overrides } from 'ethers';
|
|
2
|
-
export declare const ERC20_ABI: {
|
|
3
|
-
name: string;
|
|
4
|
-
inputs: {
|
|
5
|
-
internalType: string;
|
|
6
|
-
name: string;
|
|
7
|
-
type: string;
|
|
8
|
-
}[];
|
|
9
|
-
outputs: {
|
|
10
|
-
internalType: string;
|
|
11
|
-
name: string;
|
|
12
|
-
type: string;
|
|
13
|
-
}[];
|
|
14
|
-
stateMutability: string;
|
|
15
|
-
type: string;
|
|
16
|
-
}[];
|
|
17
|
-
export interface ERC20Contract extends BaseContract {
|
|
18
|
-
allowance(owner: string, spender: string, overrides?: CallOverrides): Promise<BigNumber>;
|
|
19
|
-
approve(spender: string, amount: BigNumberish, overrides?: Overrides & {
|
|
20
|
-
from?: string | Promise<string>;
|
|
21
|
-
}): Promise<ContractTransaction>;
|
|
22
|
-
}
|
package/dist/types/ERC20.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export const ERC20_ABI = [
|
|
2
|
-
{
|
|
3
|
-
name: 'approve',
|
|
4
|
-
inputs: [
|
|
5
|
-
{
|
|
6
|
-
internalType: 'address',
|
|
7
|
-
name: 'spender',
|
|
8
|
-
type: 'address',
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
internalType: 'uint256',
|
|
12
|
-
name: 'amount',
|
|
13
|
-
type: 'uint256',
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
outputs: [
|
|
17
|
-
{
|
|
18
|
-
internalType: 'bool',
|
|
19
|
-
name: '',
|
|
20
|
-
type: 'bool',
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
stateMutability: 'nonpayable',
|
|
24
|
-
type: 'function',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: 'allowance',
|
|
28
|
-
inputs: [
|
|
29
|
-
{
|
|
30
|
-
internalType: 'address',
|
|
31
|
-
name: 'owner',
|
|
32
|
-
type: 'address',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
internalType: 'address',
|
|
36
|
-
name: 'spender',
|
|
37
|
-
type: 'address',
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
outputs: [
|
|
41
|
-
{
|
|
42
|
-
internalType: 'uint256',
|
|
43
|
-
name: '',
|
|
44
|
-
type: 'uint256',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
stateMutability: 'view',
|
|
48
|
-
type: 'function',
|
|
49
|
-
},
|
|
50
|
-
];
|
package/dist/types/index.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { TransactionRequest } from '@ethersproject/abstract-provider';
|
|
2
|
-
import { LifiStep, Route, RouteOptions, Token } from '@lifi/types';
|
|
3
|
-
import BigNumber from 'bignumber.js';
|
|
4
|
-
import { Signer } from 'ethers';
|
|
5
|
-
import { ChainId } from '.';
|
|
6
|
-
import { StatusManager } from '../execution/StatusManager';
|
|
7
|
-
import { StepExecutor } from '../execution/StepExecutor';
|
|
8
|
-
export interface TokenWithAmounts extends Token {
|
|
9
|
-
amount?: BigNumber;
|
|
10
|
-
amountRendered?: string;
|
|
11
|
-
}
|
|
12
|
-
export type ParsedReceipt = {
|
|
13
|
-
fromAmount?: string;
|
|
14
|
-
toAmount: string;
|
|
15
|
-
gasUsed: string;
|
|
16
|
-
gasPrice: string;
|
|
17
|
-
gasFee: string;
|
|
18
|
-
toTokenAddress?: string;
|
|
19
|
-
};
|
|
20
|
-
export interface ExecutionParams {
|
|
21
|
-
signer: Signer;
|
|
22
|
-
step: LifiStep;
|
|
23
|
-
statusManager: StatusManager;
|
|
24
|
-
settings: InternalExecutionSettings;
|
|
25
|
-
}
|
|
26
|
-
export type UpdateRouteHook = (updatedRoute: Route) => void;
|
|
27
|
-
export type TransactionRequestUpdateHook = (updatedTxRequest: TransactionRequest) => Promise<TransactionRequest>;
|
|
28
|
-
export type Config = {
|
|
29
|
-
apiUrl: string;
|
|
30
|
-
apiKey?: string;
|
|
31
|
-
rpcs: Record<ChainId, string[]>;
|
|
32
|
-
multicallAddresses: Record<ChainId, string | undefined>;
|
|
33
|
-
defaultExecutionSettings: InternalExecutionSettings;
|
|
34
|
-
defaultRouteOptions: RouteOptions;
|
|
35
|
-
disableVersionCheck?: boolean;
|
|
36
|
-
userId?: string;
|
|
37
|
-
integrator: string;
|
|
38
|
-
widgetVersion?: string;
|
|
39
|
-
multisigConfig?: MultisigConfig;
|
|
40
|
-
};
|
|
41
|
-
export interface MultisigTxDetails {
|
|
42
|
-
status: 'DONE' | 'FAILED' | 'PENDING' | 'CANCELLED';
|
|
43
|
-
txHash?: string;
|
|
44
|
-
}
|
|
45
|
-
export interface MultisigTransactionResponse {
|
|
46
|
-
hash: string;
|
|
47
|
-
}
|
|
48
|
-
export interface BaseTransaction {
|
|
49
|
-
to: string;
|
|
50
|
-
value: string;
|
|
51
|
-
data: string;
|
|
52
|
-
}
|
|
53
|
-
export interface MultisigConfig {
|
|
54
|
-
isMultisigSigner?: boolean;
|
|
55
|
-
getMultisigTransactionDetails?: (txHash: string, fromChainId: number, updateIntermediateStatus?: () => void) => Promise<MultisigTxDetails>;
|
|
56
|
-
sendBatchTransaction?: (batchTransactions: BaseTransaction[]) => Promise<MultisigTransactionResponse>;
|
|
57
|
-
shouldBatchTransactions?: boolean;
|
|
58
|
-
}
|
|
59
|
-
export type ConfigUpdate = {
|
|
60
|
-
apiUrl?: string;
|
|
61
|
-
apiKey?: string;
|
|
62
|
-
rpcs?: Record<number, string[]>;
|
|
63
|
-
multicallAddresses?: Record<number, string | undefined>;
|
|
64
|
-
defaultExecutionSettings?: ExecutionSettings;
|
|
65
|
-
defaultRouteOptions?: RouteOptions;
|
|
66
|
-
disableVersionCheck?: boolean;
|
|
67
|
-
userId?: string;
|
|
68
|
-
integrator: string;
|
|
69
|
-
widgetVersion?: string;
|
|
70
|
-
multisigConfig?: MultisigConfig;
|
|
71
|
-
};
|
|
72
|
-
export type SwitchChainHook = (requiredChainId: number) => Promise<Signer | undefined>;
|
|
73
|
-
export interface AcceptSlippageUpdateHookParams {
|
|
74
|
-
toToken: Token;
|
|
75
|
-
oldToAmount: string;
|
|
76
|
-
newToAmount: string;
|
|
77
|
-
oldSlippage: number;
|
|
78
|
-
newSlippage: number;
|
|
79
|
-
}
|
|
80
|
-
export type AcceptSlippageUpdateHook = (params: AcceptSlippageUpdateHookParams) => Promise<boolean | undefined>;
|
|
81
|
-
export interface ExchangeRateUpdateParams {
|
|
82
|
-
toToken: Token;
|
|
83
|
-
oldToAmount: string;
|
|
84
|
-
newToAmount: string;
|
|
85
|
-
}
|
|
86
|
-
export type AcceptExchangeRateUpdateHook = (params: ExchangeRateUpdateParams) => Promise<boolean | undefined>;
|
|
87
|
-
export interface RouteExecutionData {
|
|
88
|
-
route: Route;
|
|
89
|
-
executors: StepExecutor[];
|
|
90
|
-
settings: InternalExecutionSettings;
|
|
91
|
-
}
|
|
92
|
-
export type ExecutionSettings = Partial<InternalExecutionSettings>;
|
|
93
|
-
export interface InternalExecutionSettings {
|
|
94
|
-
acceptExchangeRateUpdateHook: AcceptExchangeRateUpdateHook;
|
|
95
|
-
switchChainHook: SwitchChainHook;
|
|
96
|
-
updateRouteHook: UpdateRouteHook;
|
|
97
|
-
updateTransactionRequestHook?: TransactionRequestUpdateHook;
|
|
98
|
-
executeInBackground: boolean;
|
|
99
|
-
infiniteApproval: boolean;
|
|
100
|
-
}
|
|
101
|
-
export type RouteExecutionDictionary = Partial<Record<string, RouteExecutionData>>;
|
|
102
|
-
export type RouteExecutionPromiseDictionary = Partial<Record<string, Promise<Route>>>;
|
|
103
|
-
export type RevokeTokenData = {
|
|
104
|
-
token: Token;
|
|
105
|
-
approvalAddress: string;
|
|
106
|
-
};
|
|
107
|
-
export interface InteractionSettings {
|
|
108
|
-
allowInteraction?: boolean;
|
|
109
|
-
allowUpdates?: boolean;
|
|
110
|
-
stopExecution?: boolean;
|
|
111
|
-
}
|
|
112
|
-
export interface TenderlyResponse {
|
|
113
|
-
hash: string;
|
|
114
|
-
block_hash: string;
|
|
115
|
-
block_number: number;
|
|
116
|
-
from: string;
|
|
117
|
-
gas: number;
|
|
118
|
-
gas_price: number;
|
|
119
|
-
gas_fee_cap: number;
|
|
120
|
-
gas_tip_cap: number;
|
|
121
|
-
cumulative_gas_used: number;
|
|
122
|
-
gas_used: number;
|
|
123
|
-
effective_gas_price: number;
|
|
124
|
-
input: string;
|
|
125
|
-
nonce: number;
|
|
126
|
-
to: string;
|
|
127
|
-
index: number;
|
|
128
|
-
value: string;
|
|
129
|
-
access_list: any;
|
|
130
|
-
status: boolean;
|
|
131
|
-
addresses: string[];
|
|
132
|
-
contract_ids: string[];
|
|
133
|
-
network_id: string;
|
|
134
|
-
timestamp: string;
|
|
135
|
-
function_selector: string;
|
|
136
|
-
l1_block_number: number;
|
|
137
|
-
l1_timestamp: number;
|
|
138
|
-
deposit_tx: boolean;
|
|
139
|
-
system_tx: boolean;
|
|
140
|
-
mint: number;
|
|
141
|
-
sig: Signature;
|
|
142
|
-
error_message: string;
|
|
143
|
-
method: string;
|
|
144
|
-
decoded_input: any;
|
|
145
|
-
call_trace: any;
|
|
146
|
-
}
|
|
147
|
-
export interface Signature {
|
|
148
|
-
v: string;
|
|
149
|
-
r: string;
|
|
150
|
-
s: string;
|
|
151
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils/errors.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
declare enum ErrorType {
|
|
2
|
-
RPCError = "RPCError",
|
|
3
|
-
ProviderError = "ProviderError",
|
|
4
|
-
ServerError = "ServerError",
|
|
5
|
-
TransactionError = "TransactionError",
|
|
6
|
-
ValidationError = "ValidationError",
|
|
7
|
-
NotFoundError = "NotFoundError",
|
|
8
|
-
UnknownError = "UnknownError",
|
|
9
|
-
SlippageError = "SlippageError"
|
|
10
|
-
}
|
|
11
|
-
export declare enum LifiErrorCode {
|
|
12
|
-
InternalError = 1000,
|
|
13
|
-
ValidationError = 1001,
|
|
14
|
-
TransactionUnderpriced = 1002,
|
|
15
|
-
TransactionFailed = 1003,
|
|
16
|
-
Timeout = 1004,
|
|
17
|
-
ProviderUnavailable = 1005,
|
|
18
|
-
NotFound = 1006,
|
|
19
|
-
ChainSwitchError = 1007,
|
|
20
|
-
TransactionUnprepared = 1008,
|
|
21
|
-
GasLimitError = 1009,
|
|
22
|
-
TransactionCanceled = 1010,
|
|
23
|
-
SlippageError = 1011,
|
|
24
|
-
TransactionRejected = 1012,
|
|
25
|
-
BalanceError = 1013,
|
|
26
|
-
AllowanceRequired = 1014,
|
|
27
|
-
InsufficientFunds = 1015
|
|
28
|
-
}
|
|
29
|
-
export declare enum EthersErrorType {
|
|
30
|
-
ActionRejected = "ACTION_REJECTED",
|
|
31
|
-
CallExecption = "CALL_EXCEPTION",
|
|
32
|
-
InsufficientFunds = "INSUFFICIENT_FUNDS"
|
|
33
|
-
}
|
|
34
|
-
export declare enum EthersErrorMessage {
|
|
35
|
-
ERC20Allowance = "ERC20: transfer amount exceeds allowance",
|
|
36
|
-
LowGas = "intrinsic gas too low",
|
|
37
|
-
OutOfGas = "out of gas",
|
|
38
|
-
Underpriced = "underpriced",
|
|
39
|
-
LowReplacementFee = "replacement fee too low"
|
|
40
|
-
}
|
|
41
|
-
export declare enum ErrorMessage {
|
|
42
|
-
UnknownError = "Unknown error occurred.",
|
|
43
|
-
SlippageError = "The slippage is larger than the defined threshold. Please request a new route to get a fresh quote.",
|
|
44
|
-
GasLimitLow = "Gas limit is too low.",
|
|
45
|
-
TransactionUnderpriced = "Transaction is underpriced.",
|
|
46
|
-
Default = "Something went wrong."
|
|
47
|
-
}
|
|
48
|
-
export declare enum MetaMaskRPCErrorCode {
|
|
49
|
-
invalidInput = -32000,
|
|
50
|
-
resourceNotFound = -32001,
|
|
51
|
-
resourceUnavailable = -32002,
|
|
52
|
-
transactionRejected = -32003,
|
|
53
|
-
methodNotSupported = -32004,
|
|
54
|
-
limitExceeded = -32005,
|
|
55
|
-
parse = -32700,
|
|
56
|
-
invalidRequest = -32600,
|
|
57
|
-
methodNotFound = -32601,
|
|
58
|
-
invalidParams = -32602,
|
|
59
|
-
internal = -32603
|
|
60
|
-
}
|
|
61
|
-
export declare enum MetaMaskProviderErrorCode {
|
|
62
|
-
userRejectedRequest = 4001,
|
|
63
|
-
unauthorized = 4100,
|
|
64
|
-
unsupportedMethod = 4200,
|
|
65
|
-
disconnected = 4900,
|
|
66
|
-
chainDisconnected = 4901
|
|
67
|
-
}
|
|
68
|
-
export type ErrorCode = LifiErrorCode | MetaMaskRPCErrorCode | MetaMaskProviderErrorCode;
|
|
69
|
-
export declare class LifiError extends Error {
|
|
70
|
-
code: ErrorCode;
|
|
71
|
-
htmlMessage?: string;
|
|
72
|
-
constructor(type: ErrorType, code: number, message: string, htmlMessage?: string, stack?: string);
|
|
73
|
-
}
|
|
74
|
-
export declare class RPCError extends LifiError {
|
|
75
|
-
constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
|
|
76
|
-
}
|
|
77
|
-
export declare class ProviderError extends LifiError {
|
|
78
|
-
constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
|
|
79
|
-
}
|
|
80
|
-
export declare class ServerError extends LifiError {
|
|
81
|
-
constructor(message: string, htmlMessage?: string, stack?: string);
|
|
82
|
-
}
|
|
83
|
-
export declare class ValidationError extends LifiError {
|
|
84
|
-
constructor(message: string, htmlMessage?: string, stack?: string);
|
|
85
|
-
}
|
|
86
|
-
export declare class TransactionError extends LifiError {
|
|
87
|
-
constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
|
|
88
|
-
}
|
|
89
|
-
export declare class SlippageError extends LifiError {
|
|
90
|
-
constructor(message: string, htmlMessage?: string, stack?: string);
|
|
91
|
-
}
|
|
92
|
-
export declare class BalanceError extends LifiError {
|
|
93
|
-
constructor(message: string, htmlMessage?: string, stack?: string);
|
|
94
|
-
}
|
|
95
|
-
export declare class NotFoundError extends LifiError {
|
|
96
|
-
constructor(message: string, htmlMessage?: string, stack?: string);
|
|
97
|
-
}
|
|
98
|
-
export declare class UnknownError extends LifiError {
|
|
99
|
-
constructor(code: ErrorCode, message: string, htmlMessage?: string, stack?: string);
|
|
100
|
-
}
|
|
101
|
-
export declare class HTTPError extends Error {
|
|
102
|
-
response: Response;
|
|
103
|
-
status: number;
|
|
104
|
-
constructor(response: Response);
|
|
105
|
-
}
|
|
106
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Fragment, JsonFragment } from '@ethersproject/abi';
|
|
2
|
-
export type MultiCallData = {
|
|
3
|
-
address: string;
|
|
4
|
-
name: string;
|
|
5
|
-
params?: any[];
|
|
6
|
-
};
|
|
7
|
-
export declare const fetchDataUsingMulticall: (calls: Array<MultiCallData>, abi: ReadonlyArray<Fragment | JsonFragment | string>, chainId: number, multicallAddress: string, requireSuccess?: boolean) => Promise<{
|
|
8
|
-
data: unknown;
|
|
9
|
-
blockNumber: number;
|
|
10
|
-
}[]>;
|
package/dist/utils/multicall.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Interface } from '@ethersproject/abi';
|
|
2
|
-
import { Contract } from '@ethersproject/contracts';
|
|
3
|
-
import { getRpcProvider } from '../connectors';
|
|
4
|
-
import { splitListIntoChunks } from './utils';
|
|
5
|
-
import MULTICALL_ABI from './multicallAbi.json';
|
|
6
|
-
const MAX_MULTICALL_SIZE = 100;
|
|
7
|
-
export const fetchDataUsingMulticall = async (calls, abi, chainId, multicallAddress, requireSuccess = false) => {
|
|
8
|
-
// 1. create contract using multicall contract address and abi...
|
|
9
|
-
const provider = await getRpcProvider(chainId);
|
|
10
|
-
const multicallContract = new Contract(multicallAddress, MULTICALL_ABI, provider);
|
|
11
|
-
const abiInterface = new Interface(abi);
|
|
12
|
-
// split up lists into chunks to stay below multicall limit
|
|
13
|
-
const chunkedList = splitListIntoChunks(calls, MAX_MULTICALL_SIZE);
|
|
14
|
-
const chunkedResults = await Promise.all(chunkedList.map(async (chunkedCalls) => {
|
|
15
|
-
const callData = chunkedCalls.map((call) => [
|
|
16
|
-
call.address.toLowerCase(),
|
|
17
|
-
abiInterface.encodeFunctionData(call.name, call.params),
|
|
18
|
-
]);
|
|
19
|
-
try {
|
|
20
|
-
// 3. get bytes array from multicall contract by process aggregate method...
|
|
21
|
-
const { blockNumber, returnData } = await multicallContract.tryBlockAndAggregate(requireSuccess, callData);
|
|
22
|
-
// 4. decode bytes array to useful data array...
|
|
23
|
-
return returnData
|
|
24
|
-
.map(({ success, returnData }, i) => {
|
|
25
|
-
if (!success) {
|
|
26
|
-
// requested function failed
|
|
27
|
-
console.error(`Multicall unsuccessful for address "${chunkedCalls[i].address}", ` +
|
|
28
|
-
`function "${chunkedCalls[i].name}", chainId "${chainId}"`);
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
if (returnData.toString() === '0x') {
|
|
32
|
-
// requested function does probably not exist
|
|
33
|
-
console.error(`Multicall no response for address "${chunkedCalls[i].address}", ` +
|
|
34
|
-
`function "${chunkedCalls[i].name}", chainId "${chainId}"`);
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
try {
|
|
38
|
-
return abiInterface.decodeFunctionResult(chunkedCalls[i].name, returnData);
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
// requested function returns other data than expected
|
|
42
|
-
console.error(`Multicall parsing unsuccessful for address "${chunkedCalls[i].address}", ` +
|
|
43
|
-
`function "${chunkedCalls[i].name}", chainId "${chainId}"`);
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
.map((data) => {
|
|
48
|
-
return {
|
|
49
|
-
data: data[0],
|
|
50
|
-
blockNumber: blockNumber.toNumber(),
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
// whole rpc call failed, probably an rpc issue
|
|
56
|
-
console.error(`Multicall failed on chainId "${chainId}"`, chunkedList, e);
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
}));
|
|
60
|
-
return chunkedResults.flat();
|
|
61
|
-
};
|