@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
package/package.json
CHANGED
|
@@ -1,110 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk",
|
|
3
|
-
"version": "2.3.1",
|
|
4
3
|
"description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"build": "yarn clean && tsc --project ./tsconfig.json && tsc --project ./tsconfig.cjs.json",
|
|
11
|
-
"clean": "node tools/cleanup",
|
|
12
|
-
"package": "npm run build && npm pack",
|
|
13
|
-
"test": "vitest --run --dangerouslyIgnoreUnhandledErrors",
|
|
14
|
-
"test:unit": "yarn test .unit.spec.ts",
|
|
15
|
-
"test:cov": "yarn test --coverage",
|
|
16
|
-
"test:e2e": "yarn test -c vitest.e2e.config.ts",
|
|
17
|
-
"addscope": "node tools/packagejson name @lifi/sdk",
|
|
18
|
-
"pre-commit": "lint-staged",
|
|
19
|
-
"pre-push": "yarn types:check && yarn build && yarn test:unit",
|
|
20
|
-
"lint": "eslint --ext .tsx --ext .ts ./src",
|
|
21
|
-
"lint:fix": "eslint --ext .tsx --ext .ts ./src --fix",
|
|
22
|
-
"types:check": "tsc --noEmit",
|
|
23
|
-
"prettier:fix": "prettier --write ./src/.",
|
|
24
|
-
"use:npmReadme": "mv 'README.md' 'git.README.md' && mv 'npm.README.md' 'README.md'",
|
|
25
|
-
"use:gitReadme": "mv 'README.md' 'npm.README.md' && mv 'git.README.md' 'README.md'",
|
|
26
|
-
"prepublishOnly": "run-s build use:npmReadme && pinst --enable",
|
|
27
|
-
"postpublish": "npm run use:gitReadme && pinst --enable",
|
|
28
|
-
"prepare": "husky install",
|
|
29
|
-
"release": "standard-version -a",
|
|
30
|
-
"release:beta": "standard-version -a --prerelease beta --skip.changelog"
|
|
31
|
-
},
|
|
32
|
-
"standard-version": {
|
|
33
|
-
"scripts": {
|
|
34
|
-
"postbump": "node scripts/version.js && git add ."
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"lint-staged": {
|
|
38
|
-
"src/**/*.{ts,tsx}": [
|
|
39
|
-
"yarn run lint:fix",
|
|
40
|
-
"yarn run prettier:fix"
|
|
41
|
-
]
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@lifi/types": "^9.0.0-alpha.15",
|
|
6
|
+
"@solana/web3.js": "^1.78.4",
|
|
7
|
+
"eth-rpc-errors": "^4.0.3",
|
|
8
|
+
"viem": "^1.10.4"
|
|
42
9
|
},
|
|
10
|
+
"version": "3.0.0-alpha.10",
|
|
43
11
|
"files": [
|
|
44
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"!dist/**/*.tsbuildinfo"
|
|
45
14
|
],
|
|
46
|
-
"
|
|
47
|
-
"
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/types/index.d.ts",
|
|
18
|
+
"import": "./dist/esm/index.js",
|
|
19
|
+
"default": "./dist/cjs/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
48
22
|
},
|
|
49
|
-
"
|
|
23
|
+
"main": "./dist/cjs/index.js",
|
|
24
|
+
"module": "./dist/esm/index.js",
|
|
25
|
+
"types": "./dist/types/index.d.ts",
|
|
26
|
+
"typings": "./dist/types/index.d.ts",
|
|
50
27
|
"license": "Apache-2.0",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+ssh://git@github.com/lifinance/sdk.git"
|
|
31
|
+
},
|
|
51
32
|
"keywords": [
|
|
52
|
-
"sdk",
|
|
53
|
-
"ethereum",
|
|
54
|
-
"dapp",
|
|
55
33
|
"bridge",
|
|
56
|
-
"
|
|
57
|
-
"web3",
|
|
58
|
-
"lifi",
|
|
59
|
-
"ethers",
|
|
34
|
+
"bridge-aggregation",
|
|
60
35
|
"cross-chain",
|
|
61
|
-
"defi",
|
|
62
|
-
"web3-react",
|
|
63
36
|
"cross-chain-applications",
|
|
64
37
|
"cross-chain-bridge",
|
|
65
|
-
"
|
|
38
|
+
"dapp",
|
|
39
|
+
"defi",
|
|
40
|
+
"ethereum",
|
|
41
|
+
"ethers",
|
|
42
|
+
"lifi",
|
|
43
|
+
"metamask",
|
|
66
44
|
"multi-chain",
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
"bugs": {
|
|
75
|
-
"url": "https://github.com/lifinance/sdk/issues"
|
|
76
|
-
},
|
|
77
|
-
"dependencies": {
|
|
78
|
-
"@ethersproject/abi": "^5.7.0",
|
|
79
|
-
"@ethersproject/contracts": "^5.7.0",
|
|
80
|
-
"@lifi/types": "^8.4.0",
|
|
81
|
-
"bignumber.js": "^9.1.1",
|
|
82
|
-
"eth-rpc-errors": "^4.0.3",
|
|
83
|
-
"ethers": "^5.7.2"
|
|
84
|
-
},
|
|
85
|
-
"devDependencies": {
|
|
86
|
-
"@commitlint/cli": "^17.6.7",
|
|
87
|
-
"@commitlint/config-conventional": "^17.6.7",
|
|
88
|
-
"@mswjs/interceptors": "^0.22.16",
|
|
89
|
-
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
|
90
|
-
"@typescript-eslint/parser": "^6.1.0",
|
|
91
|
-
"@vitest/coverage-c8": "^0.33.0",
|
|
92
|
-
"cross-fetch": "^4.0.0",
|
|
93
|
-
"eslint": "^8.45.0",
|
|
94
|
-
"eslint-config-prettier": "^8.8.0",
|
|
95
|
-
"eslint-plugin-prettier": "^5.0.0",
|
|
96
|
-
"husky": "^8.0.3",
|
|
97
|
-
"lint-staged": "^13.2.3",
|
|
98
|
-
"msw": "1.0.1",
|
|
99
|
-
"npm-run-all": "^4.1.5",
|
|
100
|
-
"pinst": "^3.0.0",
|
|
101
|
-
"prettier": "^3.0.0",
|
|
102
|
-
"standard-version": "^9.5.0",
|
|
103
|
-
"typescript": "^5.1.6",
|
|
104
|
-
"vitest": "^0.33.0"
|
|
105
|
-
},
|
|
106
|
-
"directories": {
|
|
107
|
-
"test": "test"
|
|
108
|
-
},
|
|
109
|
-
"packageManager": "yarn@3.6.1"
|
|
45
|
+
"sdk",
|
|
46
|
+
"swap",
|
|
47
|
+
"viem",
|
|
48
|
+
"wagmi",
|
|
49
|
+
"web3",
|
|
50
|
+
"web3-react"
|
|
51
|
+
]
|
|
110
52
|
}
|
package/dist/LiFi.d.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { FallbackProvider } from '@ethersproject/providers';
|
|
2
|
-
import { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
|
|
3
|
-
import { Signer } from 'ethers';
|
|
4
|
-
import { ApproveTokenRequest, RevokeApprovalRequest } from './allowance';
|
|
5
|
-
import { RouteExecutionManager } from './execution/RouteExecutionManager';
|
|
6
|
-
import { Config, ConfigUpdate, RevokeTokenData } from './types';
|
|
7
|
-
export declare class LiFi extends RouteExecutionManager {
|
|
8
|
-
private chainsService;
|
|
9
|
-
constructor(configUpdate: ConfigUpdate);
|
|
10
|
-
/**
|
|
11
|
-
* Get the current configuration of the SDK
|
|
12
|
-
* @return {Config} - The config object
|
|
13
|
-
*/
|
|
14
|
-
getConfig: () => Config;
|
|
15
|
-
/**
|
|
16
|
-
* Get the SDK configuration after all setup calls are finished
|
|
17
|
-
* @return {Promise<Config>} - The config object
|
|
18
|
-
*/
|
|
19
|
-
getConfigAsync: () => Promise<Config>;
|
|
20
|
-
/**
|
|
21
|
-
* Get an instance of a provider for a specific chain
|
|
22
|
-
* @param {number} chainId - Id of the chain the provider is for
|
|
23
|
-
* @param {boolean} archive - Whether to use an archive provider that is based on a default rpc or not. defaults to false
|
|
24
|
-
* @return {FallbackProvider} The provider for the given chain
|
|
25
|
-
*/
|
|
26
|
-
getRpcProvider: (chainId: number, archive?: boolean) => Promise<FallbackProvider>;
|
|
27
|
-
/**
|
|
28
|
-
* Set a new confuration for the SDK
|
|
29
|
-
* @param {ConfigUpdate} configUpdate - An object containing the configuration fields that should be updated.
|
|
30
|
-
* @return {Config} The renewed config object
|
|
31
|
-
*/
|
|
32
|
-
setConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
|
|
33
|
-
/**
|
|
34
|
-
* Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
|
|
35
|
-
* @param {PossibilitiesRequest} request - Object defining preferences regarding chain, exchanges and bridges
|
|
36
|
-
* @return {Promise<PossibilitiesResponse>} Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
|
|
37
|
-
* @throws {LifiError} Throws a LifiError if request fails.
|
|
38
|
-
* @deprecated We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
|
|
39
|
-
*/
|
|
40
|
-
getPossibilities: (request?: PossibilitiesRequest, options?: RequestOptions) => Promise<PossibilitiesResponse>;
|
|
41
|
-
/**
|
|
42
|
-
* Fetch information about a Token
|
|
43
|
-
* @param {ChainKey | ChainId} chain - Id or key of the chain that contains the token
|
|
44
|
-
* @param {string} token - Address or symbol of the token on the requested chain
|
|
45
|
-
* @throws {LifiError} - Throws a LifiError if request fails
|
|
46
|
-
*/
|
|
47
|
-
getToken: (chain: ChainKey | ChainId, token: string, options?: RequestOptions) => Promise<Token>;
|
|
48
|
-
/**
|
|
49
|
-
* Get a quote for a token transfer
|
|
50
|
-
* @param {QuoteRequest} request - The configuration of the requested quote
|
|
51
|
-
* @throws {LifiError} - Throws a LifiError if request fails
|
|
52
|
-
*/
|
|
53
|
-
getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
|
|
54
|
-
/**
|
|
55
|
-
* Get a quote for a destination contract call
|
|
56
|
-
* @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
|
|
57
|
-
* @throws {LifiError} - Throws a LifiError if request fails
|
|
58
|
-
*/
|
|
59
|
-
getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
|
|
60
|
-
/**
|
|
61
|
-
* Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
|
|
62
|
-
* @param {GetStatusRequest} request - Configuration of the requested status
|
|
63
|
-
* @throws {LifiError} - Throws a LifiError if request fails
|
|
64
|
-
*/
|
|
65
|
-
getStatus: (request: GetStatusRequest, options?: RequestOptions) => Promise<StatusResponse>;
|
|
66
|
-
/**
|
|
67
|
-
* Get the available tools to bridge and swap tokens.
|
|
68
|
-
* @param {ToolsRequest?} request - The configuration of the requested tools
|
|
69
|
-
* @returns The tools that are available on the requested chains
|
|
70
|
-
*/
|
|
71
|
-
getTools: (request?: ToolsRequest, options?: RequestOptions) => Promise<ToolsResponse>;
|
|
72
|
-
/**
|
|
73
|
-
* Get all known tokens.
|
|
74
|
-
* @param {TokensRequest?} request - The configuration of the requested tokens
|
|
75
|
-
* @returns The tokens that are available on the requested chains
|
|
76
|
-
*/
|
|
77
|
-
getTokens: (request?: TokensRequest, options?: RequestOptions) => Promise<TokensResponse>;
|
|
78
|
-
/**
|
|
79
|
-
* Get all available chains
|
|
80
|
-
* @return {Promise<Chain[]>} A list of all available chains
|
|
81
|
-
* @throws {LifiError} Throws a LifiError if request fails.
|
|
82
|
-
*/
|
|
83
|
-
getChains: () => Promise<ExtendedChain[]>;
|
|
84
|
-
/**
|
|
85
|
-
* Get a set of routes for a request that describes a transfer of tokens.
|
|
86
|
-
* @param {RoutesRequest} request - A description of the transfer.
|
|
87
|
-
* @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
|
|
88
|
-
* @throws {LifiError} Throws a LifiError if request fails.
|
|
89
|
-
*/
|
|
90
|
-
getRoutes: (request: RoutesRequest, options?: RequestOptions) => Promise<RoutesResponse>;
|
|
91
|
-
/**
|
|
92
|
-
* Get the transaction data for a single step of a route
|
|
93
|
-
* @param {LifiStep} step - The step object.
|
|
94
|
-
* @return {Promise<LifiStep>} The step populated with the transaction data.
|
|
95
|
-
* @throws {LifiError} Throws a LifiError if request fails.
|
|
96
|
-
*/
|
|
97
|
-
getStepTransaction: (step: LifiStep, options?: RequestOptions) => Promise<LifiStep>;
|
|
98
|
-
/**
|
|
99
|
-
* Get gas recommendation for a certain chain
|
|
100
|
-
* @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
|
|
101
|
-
* @throws {LifiError} Throws a LifiError if request fails.
|
|
102
|
-
*/
|
|
103
|
-
getGasRecommendation: (request: GasRecommendationRequest, options?: RequestOptions) => Promise<GasRecommendationResponse>;
|
|
104
|
-
/**
|
|
105
|
-
* Returns the balances of a specific token a wallet holds across all aggregated chains.
|
|
106
|
-
* @param {string} walletAddress - A wallet address.
|
|
107
|
-
* @param {Token} token - A Token object.
|
|
108
|
-
* @return {Promise<TokenAmount | null>} An object containing the token and the amounts on different chains.
|
|
109
|
-
* @throws {ValidationError} Throws a ValidationError if parameters are invalid.
|
|
110
|
-
*/
|
|
111
|
-
getTokenBalance: (walletAddress: string, token: Token) => Promise<TokenAmount | null>;
|
|
112
|
-
/**
|
|
113
|
-
* Returns the balances for a list tokens a wallet holds across all aggregated chains.
|
|
114
|
-
* @param {string} walletAddress - A wallet address.
|
|
115
|
-
* @param {Token[]} tokens - A list of Token objects.
|
|
116
|
-
* @return {Promise<TokenAmount[]>} A list of objects containing the tokens and the amounts on different chains.
|
|
117
|
-
* @throws {ValidationError} Throws a ValidationError if parameters are invalid.
|
|
118
|
-
*/
|
|
119
|
-
getTokenBalances: (walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
|
|
120
|
-
/**
|
|
121
|
-
* This method queries the balances of tokens for a specific list of chains for a given wallet.
|
|
122
|
-
* @param {string} walletAddress - A walletaddress.
|
|
123
|
-
* @param {{ [chainId: number]: Token[] }} tokensByChain - A list of Token objects organized by chain ids.
|
|
124
|
-
* @return {Promise<{ [chainId: number]: TokenAmount[] }>} A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.
|
|
125
|
-
* @throws {ValidationError} Throws a ValidationError if parameters are invalid.
|
|
126
|
-
*/
|
|
127
|
-
getTokenBalancesForChains: (walletAddress: string, tokensByChain: {
|
|
128
|
-
[chainId: number]: Token[];
|
|
129
|
-
}) => Promise<{
|
|
130
|
-
[chainId: number]: TokenAmount[];
|
|
131
|
-
}>;
|
|
132
|
-
/**
|
|
133
|
-
* Get the current approval for a certain token.
|
|
134
|
-
* @param signer - The signer owning the token
|
|
135
|
-
* @param token - The token that should be checked
|
|
136
|
-
* @param approvalAddress - The address that has be approved
|
|
137
|
-
*/
|
|
138
|
-
getTokenApproval: (signer: Signer, token: Token, approvalAddress: string) => Promise<string | undefined>;
|
|
139
|
-
/**
|
|
140
|
-
* Get the current approval for a list of token / approval address pairs.
|
|
141
|
-
* @param signer - The signer owning the tokens
|
|
142
|
-
* @param tokenData - A list of token and approval address pairs
|
|
143
|
-
*/
|
|
144
|
-
bulkGetTokenApproval: (signer: Signer, tokenData: RevokeTokenData[]) => Promise<{
|
|
145
|
-
token: Token;
|
|
146
|
-
approval: string | undefined;
|
|
147
|
-
}[]>;
|
|
148
|
-
/**
|
|
149
|
-
* Set approval for a certain token and amount.
|
|
150
|
-
* @param { ApproveTokenRequest } request - The approval request
|
|
151
|
-
*/
|
|
152
|
-
approveToken: (request: ApproveTokenRequest) => Promise<void>;
|
|
153
|
-
/**
|
|
154
|
-
* Revoke approval for a certain token.
|
|
155
|
-
* @param { RevokeApprovalRequest } request - The revoke request
|
|
156
|
-
*/
|
|
157
|
-
revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<void>;
|
|
158
|
-
/**
|
|
159
|
-
* Get all the available connections for swap/bridging tokens
|
|
160
|
-
* @param connectionRequest ConnectionsRequest
|
|
161
|
-
* @returns ConnectionsResponse
|
|
162
|
-
*/
|
|
163
|
-
getConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
|
|
164
|
-
}
|
package/dist/LiFi.js
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { approveToken, bulkGetTokenApproval, getTokenApproval, revokeTokenApproval, } from './allowance';
|
|
2
|
-
import * as balance from './balance';
|
|
3
|
-
import { getRpcProvider } from './connectors';
|
|
4
|
-
import { RouteExecutionManager } from './execution/RouteExecutionManager';
|
|
5
|
-
import { checkPackageUpdates } from './helpers';
|
|
6
|
-
import ApiService from './services/ApiService';
|
|
7
|
-
import ChainsService from './services/ChainsService';
|
|
8
|
-
import { isToken } from './typeguards';
|
|
9
|
-
import { ValidationError } from './utils/errors';
|
|
10
|
-
import { name, version } from './version';
|
|
11
|
-
export class LiFi extends RouteExecutionManager {
|
|
12
|
-
constructor(configUpdate) {
|
|
13
|
-
super(configUpdate);
|
|
14
|
-
/**
|
|
15
|
-
* Get the current configuration of the SDK
|
|
16
|
-
* @return {Config} - The config object
|
|
17
|
-
*/
|
|
18
|
-
this.getConfig = () => {
|
|
19
|
-
return this.configService.getConfig();
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Get the SDK configuration after all setup calls are finished
|
|
23
|
-
* @return {Promise<Config>} - The config object
|
|
24
|
-
*/
|
|
25
|
-
this.getConfigAsync = () => {
|
|
26
|
-
return this.configService.getConfigAsync();
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Get an instance of a provider for a specific chain
|
|
30
|
-
* @param {number} chainId - Id of the chain the provider is for
|
|
31
|
-
* @param {boolean} archive - Whether to use an archive provider that is based on a default rpc or not. defaults to false
|
|
32
|
-
* @return {FallbackProvider} The provider for the given chain
|
|
33
|
-
*/
|
|
34
|
-
this.getRpcProvider = (chainId, archive = false) => {
|
|
35
|
-
return getRpcProvider(chainId, archive);
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Set a new confuration for the SDK
|
|
39
|
-
* @param {ConfigUpdate} configUpdate - An object containing the configuration fields that should be updated.
|
|
40
|
-
* @return {Config} The renewed config object
|
|
41
|
-
*/
|
|
42
|
-
this.setConfig = (configUpdate) => {
|
|
43
|
-
return this.configService.updateConfig(configUpdate);
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
|
|
47
|
-
* @param {PossibilitiesRequest} request - Object defining preferences regarding chain, exchanges and bridges
|
|
48
|
-
* @return {Promise<PossibilitiesResponse>} Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
|
|
49
|
-
* @throws {LifiError} Throws a LifiError if request fails.
|
|
50
|
-
* @deprecated We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
|
|
51
|
-
*/
|
|
52
|
-
this.getPossibilities = async (request, options) => {
|
|
53
|
-
return ApiService.getPossibilities(request, options);
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Fetch information about a Token
|
|
57
|
-
* @param {ChainKey | ChainId} chain - Id or key of the chain that contains the token
|
|
58
|
-
* @param {string} token - Address or symbol of the token on the requested chain
|
|
59
|
-
* @throws {LifiError} - Throws a LifiError if request fails
|
|
60
|
-
*/
|
|
61
|
-
this.getToken = async (chain, token, options) => {
|
|
62
|
-
return ApiService.getToken(chain, token, options);
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Get a quote for a token transfer
|
|
66
|
-
* @param {QuoteRequest} request - The configuration of the requested quote
|
|
67
|
-
* @throws {LifiError} - Throws a LifiError if request fails
|
|
68
|
-
*/
|
|
69
|
-
this.getQuote = async (request, options) => {
|
|
70
|
-
return ApiService.getQuote(request, options);
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Get a quote for a destination contract call
|
|
74
|
-
* @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
|
|
75
|
-
* @throws {LifiError} - Throws a LifiError if request fails
|
|
76
|
-
*/
|
|
77
|
-
this.getContractCallQuote = async (request, options) => {
|
|
78
|
-
return ApiService.getContractCallQuote(request, options);
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
|
|
82
|
-
* @param {GetStatusRequest} request - Configuration of the requested status
|
|
83
|
-
* @throws {LifiError} - Throws a LifiError if request fails
|
|
84
|
-
*/
|
|
85
|
-
this.getStatus = async (request, options) => {
|
|
86
|
-
return ApiService.getStatus(request, options);
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Get the available tools to bridge and swap tokens.
|
|
90
|
-
* @param {ToolsRequest?} request - The configuration of the requested tools
|
|
91
|
-
* @returns The tools that are available on the requested chains
|
|
92
|
-
*/
|
|
93
|
-
this.getTools = async (request, options) => {
|
|
94
|
-
return ApiService.getTools(request || {}, options);
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Get all known tokens.
|
|
98
|
-
* @param {TokensRequest?} request - The configuration of the requested tokens
|
|
99
|
-
* @returns The tokens that are available on the requested chains
|
|
100
|
-
*/
|
|
101
|
-
this.getTokens = async (request, options) => {
|
|
102
|
-
return ApiService.getTokens(request || {}, options);
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Get all available chains
|
|
106
|
-
* @return {Promise<Chain[]>} A list of all available chains
|
|
107
|
-
* @throws {LifiError} Throws a LifiError if request fails.
|
|
108
|
-
*/
|
|
109
|
-
this.getChains = async () => {
|
|
110
|
-
return this.chainsService.getChains();
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Get a set of routes for a request that describes a transfer of tokens.
|
|
114
|
-
* @param {RoutesRequest} request - A description of the transfer.
|
|
115
|
-
* @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
|
|
116
|
-
* @throws {LifiError} Throws a LifiError if request fails.
|
|
117
|
-
*/
|
|
118
|
-
this.getRoutes = async (request, options) => {
|
|
119
|
-
return ApiService.getRoutes(request, options);
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Get the transaction data for a single step of a route
|
|
123
|
-
* @param {LifiStep} step - The step object.
|
|
124
|
-
* @return {Promise<LifiStep>} The step populated with the transaction data.
|
|
125
|
-
* @throws {LifiError} Throws a LifiError if request fails.
|
|
126
|
-
*/
|
|
127
|
-
this.getStepTransaction = async (step, options) => {
|
|
128
|
-
return ApiService.getStepTransaction(step, options);
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Get gas recommendation for a certain chain
|
|
132
|
-
* @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
|
|
133
|
-
* @throws {LifiError} Throws a LifiError if request fails.
|
|
134
|
-
*/
|
|
135
|
-
this.getGasRecommendation = async (request, options) => {
|
|
136
|
-
return ApiService.getGasRecommendation(request, options);
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* Returns the balances of a specific token a wallet holds across all aggregated chains.
|
|
140
|
-
* @param {string} walletAddress - A wallet address.
|
|
141
|
-
* @param {Token} token - A Token object.
|
|
142
|
-
* @return {Promise<TokenAmount | null>} An object containing the token and the amounts on different chains.
|
|
143
|
-
* @throws {ValidationError} Throws a ValidationError if parameters are invalid.
|
|
144
|
-
*/
|
|
145
|
-
this.getTokenBalance = async (walletAddress, token) => {
|
|
146
|
-
if (!walletAddress) {
|
|
147
|
-
throw new ValidationError('Missing walletAddress.');
|
|
148
|
-
}
|
|
149
|
-
if (!isToken(token)) {
|
|
150
|
-
throw new ValidationError(`Invalid token passed: address "${token.address}" on chainId "${token.chainId}"`);
|
|
151
|
-
}
|
|
152
|
-
return balance.getTokenBalance(walletAddress, token);
|
|
153
|
-
};
|
|
154
|
-
/**
|
|
155
|
-
* Returns the balances for a list tokens a wallet holds across all aggregated chains.
|
|
156
|
-
* @param {string} walletAddress - A wallet address.
|
|
157
|
-
* @param {Token[]} tokens - A list of Token objects.
|
|
158
|
-
* @return {Promise<TokenAmount[]>} A list of objects containing the tokens and the amounts on different chains.
|
|
159
|
-
* @throws {ValidationError} Throws a ValidationError if parameters are invalid.
|
|
160
|
-
*/
|
|
161
|
-
this.getTokenBalances = async (walletAddress, tokens) => {
|
|
162
|
-
if (!walletAddress) {
|
|
163
|
-
throw new ValidationError('Missing walletAddress.');
|
|
164
|
-
}
|
|
165
|
-
const invalidTokens = tokens.filter((token) => !isToken(token));
|
|
166
|
-
if (invalidTokens.length) {
|
|
167
|
-
throw new ValidationError(`Invalid token passed: address "${invalidTokens[0].address}" on chainId "${invalidTokens[0].chainId}"`);
|
|
168
|
-
}
|
|
169
|
-
return balance.getTokenBalances(walletAddress, tokens);
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* This method queries the balances of tokens for a specific list of chains for a given wallet.
|
|
173
|
-
* @param {string} walletAddress - A walletaddress.
|
|
174
|
-
* @param {{ [chainId: number]: Token[] }} tokensByChain - A list of Token objects organized by chain ids.
|
|
175
|
-
* @return {Promise<{ [chainId: number]: TokenAmount[] }>} A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.
|
|
176
|
-
* @throws {ValidationError} Throws a ValidationError if parameters are invalid.
|
|
177
|
-
*/
|
|
178
|
-
this.getTokenBalancesForChains = async (walletAddress, tokensByChain) => {
|
|
179
|
-
if (!walletAddress) {
|
|
180
|
-
throw new ValidationError('Missing walletAddress.');
|
|
181
|
-
}
|
|
182
|
-
const tokenList = Object.values(tokensByChain).flat();
|
|
183
|
-
const invalidTokens = tokenList.filter((token) => !isToken(token));
|
|
184
|
-
if (invalidTokens.length) {
|
|
185
|
-
throw new ValidationError(`Invalid token passed: address "${invalidTokens[0].address}" on chainId "${invalidTokens[0].chainId}"`);
|
|
186
|
-
}
|
|
187
|
-
return balance.getTokenBalancesForChains(walletAddress, tokensByChain);
|
|
188
|
-
};
|
|
189
|
-
/**
|
|
190
|
-
* Get the current approval for a certain token.
|
|
191
|
-
* @param signer - The signer owning the token
|
|
192
|
-
* @param token - The token that should be checked
|
|
193
|
-
* @param approvalAddress - The address that has be approved
|
|
194
|
-
*/
|
|
195
|
-
this.getTokenApproval = async (signer, token, approvalAddress) => {
|
|
196
|
-
return getTokenApproval(signer, token, approvalAddress);
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Get the current approval for a list of token / approval address pairs.
|
|
200
|
-
* @param signer - The signer owning the tokens
|
|
201
|
-
* @param tokenData - A list of token and approval address pairs
|
|
202
|
-
*/
|
|
203
|
-
this.bulkGetTokenApproval = async (signer, tokenData) => {
|
|
204
|
-
return bulkGetTokenApproval(signer, tokenData);
|
|
205
|
-
};
|
|
206
|
-
/**
|
|
207
|
-
* Set approval for a certain token and amount.
|
|
208
|
-
* @param { ApproveTokenRequest } request - The approval request
|
|
209
|
-
*/
|
|
210
|
-
this.approveToken = (request) => {
|
|
211
|
-
return approveToken(request);
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* Revoke approval for a certain token.
|
|
215
|
-
* @param { RevokeApprovalRequest } request - The revoke request
|
|
216
|
-
*/
|
|
217
|
-
this.revokeTokenApproval = (request) => {
|
|
218
|
-
return revokeTokenApproval(request);
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* Get all the available connections for swap/bridging tokens
|
|
222
|
-
* @param connectionRequest ConnectionsRequest
|
|
223
|
-
* @returns ConnectionsResponse
|
|
224
|
-
*/
|
|
225
|
-
this.getConnections = async (connectionRequest) => {
|
|
226
|
-
const connections = await ApiService.getAvailableConnections(connectionRequest);
|
|
227
|
-
return connections;
|
|
228
|
-
};
|
|
229
|
-
this.chainsService = ChainsService.getInstance();
|
|
230
|
-
this.chainsService.getChains().then((chains) => {
|
|
231
|
-
this.configService.updateChains(chains);
|
|
232
|
-
});
|
|
233
|
-
checkPackageUpdates(name, version, configUpdate.disableVersionCheck);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { PopulatedTransaction, Signer } from 'ethers';
|
|
2
|
-
import { StatusManager } from '../execution/StatusManager';
|
|
3
|
-
import { Chain, InternalExecutionSettings, LifiStep } from '../types';
|
|
4
|
-
export declare const checkAllowance: (signer: Signer, step: LifiStep, statusManager: StatusManager, settings: InternalExecutionSettings, chain: Chain, allowUserInteraction?: boolean, shouldBatchTransactions?: boolean) => Promise<void | PopulatedTransaction>;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { constants, } from 'ethers';
|
|
3
|
-
import { getApproved, setApproval } from '../allowance/utils';
|
|
4
|
-
import { getProvider } from '../utils/getProvider';
|
|
5
|
-
import { parseError } from '../utils/parseError';
|
|
6
|
-
export const checkAllowance = async (signer, step, statusManager, settings, chain, allowUserInteraction = false, shouldBatchTransactions = false) => {
|
|
7
|
-
// Ask the user to set an allowance
|
|
8
|
-
let allowanceProcess = statusManager.findOrCreateProcess(step, 'TOKEN_ALLOWANCE');
|
|
9
|
-
// Check allowance
|
|
10
|
-
try {
|
|
11
|
-
if (allowanceProcess.txHash && allowanceProcess.status !== 'DONE') {
|
|
12
|
-
if (allowanceProcess.status !== 'PENDING') {
|
|
13
|
-
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'PENDING');
|
|
14
|
-
}
|
|
15
|
-
await getProvider(signer).waitForTransaction(allowanceProcess.txHash);
|
|
16
|
-
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
const approvalRequest = {
|
|
20
|
-
from: step.action.fromToken.address,
|
|
21
|
-
to: step.estimate.approvalAddress,
|
|
22
|
-
};
|
|
23
|
-
if (settings.updateTransactionRequestHook) {
|
|
24
|
-
const config = await settings.updateTransactionRequestHook(approvalRequest);
|
|
25
|
-
approvalRequest.gasLimit = config.gasLimit;
|
|
26
|
-
approvalRequest.gasPrice = config.gasPrice;
|
|
27
|
-
approvalRequest.maxFeePerGas = config.maxFeePerGas;
|
|
28
|
-
approvalRequest.maxPriorityFeePerGas = config.maxPriorityFeePerGas;
|
|
29
|
-
}
|
|
30
|
-
if (!approvalRequest.from) {
|
|
31
|
-
throw new Error('Missing Signer address');
|
|
32
|
-
}
|
|
33
|
-
if (!approvalRequest.to) {
|
|
34
|
-
throw new Error('Missing ERC20 contract address');
|
|
35
|
-
}
|
|
36
|
-
const approved = await getApproved(signer, approvalRequest.from, approvalRequest.to);
|
|
37
|
-
if (new BigNumber(step.action.fromAmount).gt(approved)) {
|
|
38
|
-
if (!allowUserInteraction) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const approvalAmount = settings.infiniteApproval
|
|
42
|
-
? constants.MaxUint256.toString()
|
|
43
|
-
: step.action.fromAmount;
|
|
44
|
-
if (shouldBatchTransactions) {
|
|
45
|
-
const populatedTransaction = await setApproval(signer, step.action.fromToken.address, step.estimate.approvalAddress, approvalAmount, true);
|
|
46
|
-
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
|
|
47
|
-
return populatedTransaction;
|
|
48
|
-
}
|
|
49
|
-
const approveTx = (await setApproval(signer, step.action.fromToken.address, step.estimate.approvalAddress, approvalAmount));
|
|
50
|
-
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'PENDING', {
|
|
51
|
-
txHash: approveTx.hash,
|
|
52
|
-
txLink: chain.metamask.blockExplorerUrls[0] + 'tx/' + approveTx.hash,
|
|
53
|
-
});
|
|
54
|
-
// Wait for the transcation
|
|
55
|
-
await approveTx.wait();
|
|
56
|
-
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
if (e.code === 'TRANSACTION_REPLACED' && e.replacement) {
|
|
65
|
-
await transactionReplaced(e.replacement, allowanceProcess, step, chain, statusManager);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
const error = await parseError(e, step, allowanceProcess);
|
|
69
|
-
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'FAILED', {
|
|
70
|
-
error: {
|
|
71
|
-
message: error.message,
|
|
72
|
-
htmlMessage: error.htmlMessage,
|
|
73
|
-
code: error.code,
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
statusManager.updateExecution(step, 'FAILED');
|
|
77
|
-
throw error;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const transactionReplaced = async (replacementTx, allowanceProcess, step, chain, statusManager) => {
|
|
82
|
-
try {
|
|
83
|
-
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'PENDING', {
|
|
84
|
-
txHash: replacementTx.hash,
|
|
85
|
-
txLink: chain.metamask.blockExplorerUrls[0] + 'tx/' + replacementTx.hash,
|
|
86
|
-
});
|
|
87
|
-
await replacementTx.wait();
|
|
88
|
-
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
if (e.code === 'TRANSACTION_REPLACED' && e.replacement) {
|
|
92
|
-
await transactionReplaced(e.replacement, allowanceProcess, step, chain, statusManager);
|
|
93
|
-
}
|
|
94
|
-
throw e;
|
|
95
|
-
}
|
|
96
|
-
};
|
package/dist/allowance/index.js
DELETED