@lifi/sdk-provider-ethereum 4.0.1-alpha.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +88 -5
- package/dist/cjs/EthereumProvider.d.ts +7 -2
- package/dist/cjs/EthereumProvider.js +36 -39
- package/dist/cjs/EthereumProvider.js.map +1 -1
- package/dist/cjs/actions/checkPermitSupport.d.ts +32 -10
- package/dist/cjs/actions/checkPermitSupport.js +39 -30
- package/dist/cjs/actions/checkPermitSupport.js.map +1 -1
- package/dist/cjs/actions/constants.d.ts +53 -48
- package/dist/cjs/actions/constants.js +85 -75
- package/dist/cjs/actions/constants.js.map +1 -1
- package/dist/cjs/actions/getAccountCode.d.ts +30 -0
- package/dist/cjs/actions/getAccountCode.js +30 -0
- package/dist/cjs/actions/getAccountCode.js.map +1 -0
- package/dist/cjs/actions/getAllowance.d.ts +27 -7
- package/dist/cjs/actions/getAllowance.js +68 -69
- package/dist/cjs/actions/getAllowance.js.map +1 -1
- package/dist/cjs/actions/getEthereumBalance.d.ts +8 -3
- package/dist/cjs/actions/getEthereumBalance.js +70 -89
- package/dist/cjs/actions/getEthereumBalance.js.map +1 -1
- package/dist/cjs/actions/getMaxPriorityFeePerGas.d.ts +8 -3
- package/dist/cjs/actions/getMaxPriorityFeePerGas.js +14 -24
- package/dist/cjs/actions/getMaxPriorityFeePerGas.js.map +1 -1
- package/dist/cjs/actions/getMulticallAddress.d.ts +8 -3
- package/dist/cjs/actions/getMulticallAddress.js +6 -6
- package/dist/cjs/actions/getMulticallAddress.js.map +1 -1
- package/dist/cjs/actions/isBatchingSupported.d.ts +15 -6
- package/dist/cjs/actions/isBatchingSupported.js +17 -25
- package/dist/cjs/actions/isBatchingSupported.js.map +1 -1
- package/dist/cjs/actions/isSafeSignature.d.ts +23 -0
- package/dist/cjs/actions/isSafeSignature.js +24 -0
- package/dist/cjs/actions/isSafeSignature.js.map +1 -0
- package/dist/cjs/actions/isSafeWallet.d.ts +23 -0
- package/dist/cjs/actions/isSafeWallet.js +37 -0
- package/dist/cjs/actions/isSafeWallet.js.map +1 -0
- package/dist/cjs/actions/isSmartContractWallet.d.ts +10 -0
- package/dist/cjs/actions/isSmartContractWallet.js +13 -0
- package/dist/cjs/actions/isSmartContractWallet.js.map +1 -0
- package/dist/cjs/actions/resolveENSAddress.d.ts +7 -2
- package/dist/cjs/actions/resolveENSAddress.js +12 -16
- package/dist/cjs/actions/resolveENSAddress.js.map +1 -1
- package/dist/cjs/actions/resolveEthereumAddress.d.ts +7 -2
- package/dist/cjs/actions/resolveEthereumAddress.js +9 -8
- package/dist/cjs/actions/resolveEthereumAddress.js.map +1 -1
- package/dist/cjs/actions/resolveTransactionHash.d.ts +8 -0
- package/dist/cjs/actions/resolveTransactionHash.js +24 -0
- package/dist/cjs/actions/resolveTransactionHash.js.map +1 -0
- package/dist/cjs/actions/resolveUNSAddress.d.ts +7 -2
- package/dist/cjs/actions/resolveUNSAddress.js +62 -77
- package/dist/cjs/actions/resolveUNSAddress.js.map +1 -1
- package/dist/cjs/actions/setAllowance.d.ts +39 -6
- package/dist/cjs/actions/setAllowance.js +66 -62
- package/dist/cjs/actions/setAllowance.js.map +1 -1
- package/dist/cjs/actions/waitForBatchTransactionReceipt.d.ts +9 -4
- package/dist/cjs/actions/waitForBatchTransactionReceipt.js +24 -26
- package/dist/cjs/actions/waitForBatchTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/waitForRelayedTransactionReceipt.d.ts +9 -5
- package/dist/cjs/actions/waitForRelayedTransactionReceipt.js +31 -39
- package/dist/cjs/actions/waitForRelayedTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/waitForSafeTransactionExecution.d.ts +30 -0
- package/dist/cjs/actions/waitForSafeTransactionExecution.js +54 -0
- package/dist/cjs/actions/waitForSafeTransactionExecution.js.map +1 -0
- package/dist/cjs/actions/waitForTransactionReceipt.d.ts +17 -8
- package/dist/cjs/actions/waitForTransactionReceipt.js +33 -35
- package/dist/cjs/actions/waitForTransactionReceipt.js.map +1 -1
- package/dist/cjs/client/publicClient.d.ts +14 -3
- package/dist/cjs/client/publicClient.js +43 -50
- package/dist/cjs/client/publicClient.js.map +1 -1
- package/dist/cjs/client/safeClient.d.ts +17 -0
- package/dist/cjs/client/safeClient.js +44 -0
- package/dist/cjs/client/safeClient.js.map +1 -0
- package/dist/cjs/client/types.d.ts +22 -0
- package/dist/cjs/client/types.js +0 -0
- package/dist/cjs/core/EthereumStepExecutor.d.ts +25 -0
- package/dist/cjs/core/EthereumStepExecutor.js +87 -0
- package/dist/cjs/core/EthereumStepExecutor.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js +40 -0
- package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumBatchedWaitForTransactionTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumBatchedWaitForTransactionTask.js +24 -0
- package/dist/cjs/core/tasks/EthereumBatchedWaitForTransactionTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.d.ts +11 -0
- package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.js +39 -0
- package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.d.ts +19 -0
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.js +32 -0
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumCheckPermitsTask.d.ts +11 -0
- package/dist/cjs/core/tasks/EthereumCheckPermitsTask.js +54 -0
- package/dist/cjs/core/tasks/EthereumCheckPermitsTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumNativePermitTask.d.ts +11 -0
- package/dist/cjs/core/tasks/EthereumNativePermitTask.js +70 -0
- package/dist/cjs/core/tasks/EthereumNativePermitTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js +60 -0
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js +60 -0
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumRelayedWaitForTransactionTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumRelayedWaitForTransactionTask.js +19 -0
- package/dist/cjs/core/tasks/EthereumRelayedWaitForTransactionTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumResetAllowanceTask.d.ts +11 -0
- package/dist/cjs/core/tasks/EthereumResetAllowanceTask.js +76 -0
- package/dist/cjs/core/tasks/EthereumResetAllowanceTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumSetAllowanceTask.d.ts +11 -0
- package/dist/cjs/core/tasks/EthereumSetAllowanceTask.js +80 -0
- package/dist/cjs/core/tasks/EthereumSetAllowanceTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumSignAndExecuteTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumSignAndExecuteTask.js +24 -0
- package/dist/cjs/core/tasks/EthereumSignAndExecuteTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js +74 -0
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumStandardWaitForTransactionTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumStandardWaitForTransactionTask.js +31 -0
- package/dist/cjs/core/tasks/EthereumStandardWaitForTransactionTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumWaitForTransactionStatusTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumWaitForTransactionStatusTask.js +17 -0
- package/dist/cjs/core/tasks/EthereumWaitForTransactionStatusTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumWaitForTransactionTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumWaitForTransactionTask.js +19 -0
- package/dist/cjs/core/tasks/EthereumWaitForTransactionTask.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/estimateTransactionRequest.d.ts +8 -0
- package/dist/cjs/core/tasks/helpers/estimateTransactionRequest.js +23 -0
- package/dist/cjs/core/tasks/helpers/estimateTransactionRequest.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +13 -0
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js +24 -0
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getTxLink.d.ts +8 -0
- package/dist/cjs/core/tasks/helpers/getTxLink.js +9 -0
- package/dist/cjs/core/tasks/helpers/getTxLink.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.d.ts +7 -0
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.js +101 -0
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/isPermit2Supported.d.ts +7 -0
- package/dist/cjs/core/tasks/helpers/isPermit2Supported.js +9 -0
- package/dist/cjs/core/tasks/helpers/isPermit2Supported.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/shouldCheckForAllowance.d.ts +7 -0
- package/dist/cjs/core/tasks/helpers/shouldCheckForAllowance.js +11 -0
- package/dist/cjs/core/tasks/helpers/shouldCheckForAllowance.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.d.ts +8 -0
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js +68 -0
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/switchChain.d.ts +23 -0
- package/dist/cjs/core/tasks/helpers/switchChain.js +35 -0
- package/dist/cjs/core/tasks/helpers/switchChain.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/updateActionWithReceipt.d.ts +13 -0
- package/dist/cjs/core/tasks/helpers/updateActionWithReceipt.js +19 -0
- package/dist/cjs/core/tasks/helpers/updateActionWithReceipt.js.map +1 -0
- package/dist/cjs/errors/parseEthereumErrors.d.ts +8 -3
- package/dist/cjs/errors/parseEthereumErrors.js +48 -55
- package/dist/cjs/errors/parseEthereumErrors.js.map +1 -1
- package/dist/cjs/hyperliquid/agentWallet.d.ts +13 -0
- package/dist/cjs/hyperliquid/agentWallet.js +90 -0
- package/dist/cjs/hyperliquid/agentWallet.js.map +1 -0
- package/dist/cjs/hyperliquid/isHyperliquidAgentStep.d.ts +10 -0
- package/dist/cjs/hyperliquid/isHyperliquidAgentStep.js +21 -0
- package/dist/cjs/hyperliquid/isHyperliquidAgentStep.js.map +1 -0
- package/dist/cjs/index.d.ts +17 -16
- package/dist/cjs/index.js +37 -37
- package/dist/cjs/permits/allowanceTransfer.d.ts +38 -33
- package/dist/cjs/permits/allowanceTransfer.js +114 -80
- package/dist/cjs/permits/allowanceTransfer.js.map +1 -1
- package/dist/cjs/permits/canAccountUseNativePermits.d.ts +14 -0
- package/dist/cjs/permits/canAccountUseNativePermits.js +25 -0
- package/dist/cjs/permits/canAccountUseNativePermits.js.map +1 -0
- package/dist/cjs/permits/constants.d.ts +81 -53
- package/dist/cjs/permits/constants.js +109 -45
- package/dist/cjs/permits/constants.js.map +1 -1
- package/dist/cjs/permits/domain.d.ts +7 -2
- package/dist/cjs/permits/domain.js +11 -9
- package/dist/cjs/permits/domain.js.map +1 -1
- package/dist/cjs/permits/encodeNativePermitData.d.ts +7 -2
- package/dist/cjs/permits/encodeNativePermitData.js +20 -12
- package/dist/cjs/permits/encodeNativePermitData.js.map +1 -1
- package/dist/cjs/permits/encodePermit2Data.d.ts +7 -3
- package/dist/cjs/permits/encodePermit2Data.js +33 -28
- package/dist/cjs/permits/encodePermit2Data.js.map +1 -1
- package/dist/cjs/permits/getNativePermit.d.ts +30 -11
- package/dist/cjs/permits/getNativePermit.js +234 -302
- package/dist/cjs/permits/getNativePermit.js.map +1 -1
- package/dist/cjs/permits/getPermitTransferFromValues.d.ts +9 -4
- package/dist/cjs/permits/getPermitTransferFromValues.js +22 -21
- package/dist/cjs/permits/getPermitTransferFromValues.js.map +1 -1
- package/dist/cjs/permits/invariant.d.ts +20 -1
- package/dist/cjs/permits/invariant.js +27 -14
- package/dist/cjs/permits/invariant.js.map +1 -1
- package/dist/cjs/permits/isDelegationDesignatorCode.d.ts +26 -1
- package/dist/cjs/permits/isDelegationDesignatorCode.js +26 -4
- package/dist/cjs/permits/isDelegationDesignatorCode.js.map +1 -1
- package/dist/cjs/permits/isNativePermitValid.d.ts +10 -2
- package/dist/cjs/permits/isNativePermitValid.js +16 -30
- package/dist/cjs/permits/isNativePermitValid.js.map +1 -1
- package/dist/cjs/permits/signPermit2Message.d.ts +14 -10
- package/dist/cjs/permits/signPermit2Message.js +40 -41
- package/dist/cjs/permits/signPermit2Message.js.map +1 -1
- package/dist/cjs/permits/signatureTransfer.d.ts +39 -34
- package/dist/cjs/permits/signatureTransfer.js +145 -104
- package/dist/cjs/permits/signatureTransfer.js.map +1 -1
- package/dist/cjs/permits/types.d.ts +19 -14
- package/dist/cjs/permits/types.js +0 -3
- package/dist/cjs/types.d.ts +65 -40
- package/dist/cjs/types.js +7 -5
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/abi.d.ts +12 -212
- package/dist/cjs/utils/abi.js +28 -29
- package/dist/cjs/utils/abi.js.map +1 -1
- package/dist/cjs/utils/convertExtendedChain.d.ts +8 -3
- package/dist/cjs/utils/convertExtendedChain.js +19 -22
- package/dist/cjs/utils/convertExtendedChain.js.map +1 -1
- package/dist/cjs/utils/getActionWithFallback.d.ts +23 -4
- package/dist/cjs/utils/getActionWithFallback.js +28 -19
- package/dist/cjs/utils/getActionWithFallback.js.map +1 -1
- package/dist/cjs/utils/getDomainChainId.d.ts +12 -2
- package/dist/cjs/utils/getDomainChainId.js +17 -16
- package/dist/cjs/utils/getDomainChainId.js.map +1 -1
- package/dist/cjs/utils/getSafeApiKey.d.ts +7 -0
- package/dist/cjs/utils/getSafeApiKey.js +12 -0
- package/dist/cjs/utils/getSafeApiKey.js.map +1 -0
- package/dist/cjs/utils/isContractCallStep.d.ts +7 -2
- package/dist/cjs/utils/isContractCallStep.js +6 -4
- package/dist/cjs/utils/isContractCallStep.js.map +1 -1
- package/dist/cjs/utils/isExtendedChain.d.ts +7 -2
- package/dist/cjs/utils/isExtendedChain.js +6 -14
- package/dist/cjs/utils/isExtendedChain.js.map +1 -1
- package/dist/cjs/utils/isGaslessStep.d.ts +8 -3
- package/dist/cjs/utils/isGaslessStep.js +6 -6
- package/dist/cjs/utils/isGaslessStep.js.map +1 -1
- package/dist/cjs/utils/isRelayerStep.d.ts +8 -3
- package/dist/cjs/utils/isRelayerStep.js +6 -4
- package/dist/cjs/utils/isRelayerStep.js.map +1 -1
- package/dist/cjs/utils/isZeroAddress.d.ts +7 -3
- package/dist/cjs/utils/isZeroAddress.js +10 -9
- package/dist/cjs/utils/isZeroAddress.js.map +1 -1
- package/dist/cjs/utils/median.d.ts +5 -1
- package/dist/cjs/utils/median.js +9 -12
- package/dist/cjs/utils/median.js.map +1 -1
- package/dist/cjs/version.d.ts +6 -2
- package/dist/cjs/version.js +8 -5
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/EthereumProvider.d.ts +7 -2
- package/dist/esm/EthereumProvider.d.ts.map +1 -0
- package/dist/esm/EthereumProvider.js +36 -37
- package/dist/esm/EthereumProvider.js.map +1 -1
- package/dist/esm/actions/checkPermitSupport.d.ts +31 -24
- package/dist/esm/actions/checkPermitSupport.d.ts.map +1 -0
- package/dist/esm/actions/checkPermitSupport.js +38 -40
- package/dist/esm/actions/checkPermitSupport.js.map +1 -1
- package/dist/esm/actions/constants.d.ts +53 -48
- package/dist/esm/actions/constants.d.ts.map +1 -0
- package/dist/esm/actions/constants.js +79 -71
- package/dist/esm/actions/constants.js.map +1 -1
- package/dist/esm/actions/getAccountCode.d.ts +30 -0
- package/dist/esm/actions/getAccountCode.d.ts.map +1 -0
- package/dist/esm/actions/getAccountCode.js +29 -0
- package/dist/esm/actions/getAccountCode.js.map +1 -0
- package/dist/esm/actions/getAllowance.d.ts +25 -20
- package/dist/esm/actions/getAllowance.d.ts.map +1 -0
- package/dist/esm/actions/getAllowance.js +67 -84
- package/dist/esm/actions/getAllowance.js.map +1 -1
- package/dist/esm/actions/getEthereumBalance.d.ts +8 -3
- package/dist/esm/actions/getEthereumBalance.d.ts.map +1 -0
- package/dist/esm/actions/getEthereumBalance.js +70 -86
- package/dist/esm/actions/getEthereumBalance.js.map +1 -1
- package/dist/esm/actions/getMaxPriorityFeePerGas.d.ts +8 -3
- package/dist/esm/actions/getMaxPriorityFeePerGas.d.ts.map +1 -0
- package/dist/esm/actions/getMaxPriorityFeePerGas.js +15 -22
- package/dist/esm/actions/getMaxPriorityFeePerGas.js.map +1 -1
- package/dist/esm/actions/getMulticallAddress.d.ts +8 -3
- package/dist/esm/actions/getMulticallAddress.d.ts.map +1 -0
- package/dist/esm/actions/getMulticallAddress.js +7 -4
- package/dist/esm/actions/getMulticallAddress.js.map +1 -1
- package/dist/esm/actions/isBatchingSupported.d.ts +15 -6
- package/dist/esm/actions/isBatchingSupported.d.ts.map +1 -0
- package/dist/esm/actions/isBatchingSupported.js +16 -24
- package/dist/esm/actions/isBatchingSupported.js.map +1 -1
- package/dist/esm/actions/isSafeSignature.d.ts +23 -0
- package/dist/esm/actions/isSafeSignature.d.ts.map +1 -0
- package/dist/esm/actions/isSafeSignature.js +23 -0
- package/dist/esm/actions/isSafeSignature.js.map +1 -0
- package/dist/esm/actions/isSafeWallet.d.ts +23 -0
- package/dist/esm/actions/isSafeWallet.d.ts.map +1 -0
- package/dist/esm/actions/isSafeWallet.js +37 -0
- package/dist/esm/actions/isSafeWallet.js.map +1 -0
- package/dist/esm/actions/isSmartContractWallet.d.ts +10 -0
- package/dist/esm/actions/isSmartContractWallet.d.ts.map +1 -0
- package/dist/esm/actions/isSmartContractWallet.js +12 -0
- package/dist/esm/actions/isSmartContractWallet.js.map +1 -0
- package/dist/esm/actions/resolveENSAddress.d.ts +7 -2
- package/dist/esm/actions/resolveENSAddress.d.ts.map +1 -0
- package/dist/esm/actions/resolveENSAddress.js +13 -15
- package/dist/esm/actions/resolveENSAddress.js.map +1 -1
- package/dist/esm/actions/resolveEthereumAddress.d.ts +7 -2
- package/dist/esm/actions/resolveEthereumAddress.d.ts.map +1 -0
- package/dist/esm/actions/resolveEthereumAddress.js +9 -6
- package/dist/esm/actions/resolveEthereumAddress.js.map +1 -1
- package/dist/esm/actions/resolveTransactionHash.d.ts +8 -0
- package/dist/esm/actions/resolveTransactionHash.d.ts.map +1 -0
- package/dist/esm/actions/resolveTransactionHash.js +23 -0
- package/dist/esm/actions/resolveTransactionHash.js.map +1 -0
- package/dist/esm/actions/resolveUNSAddress.d.ts +7 -2
- package/dist/esm/actions/resolveUNSAddress.d.ts.map +1 -0
- package/dist/esm/actions/resolveUNSAddress.js +62 -76
- package/dist/esm/actions/resolveUNSAddress.js.map +1 -1
- package/dist/esm/actions/setAllowance.d.ts +37 -23
- package/dist/esm/actions/setAllowance.d.ts.map +1 -0
- package/dist/esm/actions/setAllowance.js +65 -79
- package/dist/esm/actions/setAllowance.js.map +1 -1
- package/dist/esm/actions/waitForBatchTransactionReceipt.d.ts +9 -4
- package/dist/esm/actions/waitForBatchTransactionReceipt.d.ts.map +1 -0
- package/dist/esm/actions/waitForBatchTransactionReceipt.js +25 -24
- package/dist/esm/actions/waitForBatchTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/waitForRelayedTransactionReceipt.d.ts +9 -5
- package/dist/esm/actions/waitForRelayedTransactionReceipt.d.ts.map +1 -0
- package/dist/esm/actions/waitForRelayedTransactionReceipt.js +32 -37
- package/dist/esm/actions/waitForRelayedTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/waitForSafeTransactionExecution.d.ts +30 -0
- package/dist/esm/actions/waitForSafeTransactionExecution.d.ts.map +1 -0
- package/dist/esm/actions/waitForSafeTransactionExecution.js +53 -0
- package/dist/esm/actions/waitForSafeTransactionExecution.js.map +1 -0
- package/dist/esm/actions/waitForTransactionReceipt.d.ts +17 -8
- package/dist/esm/actions/waitForTransactionReceipt.d.ts.map +1 -0
- package/dist/esm/actions/waitForTransactionReceipt.js +32 -35
- package/dist/esm/actions/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/client/publicClient.d.ts +13 -8
- package/dist/esm/client/publicClient.d.ts.map +1 -0
- package/dist/esm/client/publicClient.js +43 -56
- package/dist/esm/client/publicClient.js.map +1 -1
- package/dist/esm/client/safeClient.d.ts +17 -0
- package/dist/esm/client/safeClient.d.ts.map +1 -0
- package/dist/esm/client/safeClient.js +43 -0
- package/dist/esm/client/safeClient.js.map +1 -0
- package/dist/esm/client/types.d.ts +22 -0
- package/dist/esm/client/types.d.ts.map +1 -0
- package/dist/esm/client/types.js +1 -0
- package/dist/esm/core/EthereumStepExecutor.d.ts +25 -0
- package/dist/esm/core/EthereumStepExecutor.d.ts.map +1 -0
- package/dist/esm/core/EthereumStepExecutor.js +86 -0
- package/dist/esm/core/EthereumStepExecutor.js.map +1 -0
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js +39 -0
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumBatchedWaitForTransactionTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumBatchedWaitForTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumBatchedWaitForTransactionTask.js +23 -0
- package/dist/esm/core/tasks/EthereumBatchedWaitForTransactionTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumCheckAllowanceTask.d.ts +11 -0
- package/dist/esm/core/tasks/EthereumCheckAllowanceTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumCheckAllowanceTask.js +38 -0
- package/dist/esm/core/tasks/EthereumCheckAllowanceTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.d.ts +19 -0
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.js +31 -0
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.d.ts +11 -0
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.js +53 -0
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumNativePermitTask.d.ts +11 -0
- package/dist/esm/core/tasks/EthereumNativePermitTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumNativePermitTask.js +69 -0
- package/dist/esm/core/tasks/EthereumNativePermitTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js +59 -0
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js +59 -0
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.js +18 -0
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumResetAllowanceTask.d.ts +11 -0
- package/dist/esm/core/tasks/EthereumResetAllowanceTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumResetAllowanceTask.js +75 -0
- package/dist/esm/core/tasks/EthereumResetAllowanceTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.d.ts +11 -0
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.js +79 -0
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.js +23 -0
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js +73 -0
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumStandardWaitForTransactionTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumStandardWaitForTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumStandardWaitForTransactionTask.js +30 -0
- package/dist/esm/core/tasks/EthereumStandardWaitForTransactionTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumWaitForTransactionStatusTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumWaitForTransactionStatusTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumWaitForTransactionStatusTask.js +16 -0
- package/dist/esm/core/tasks/EthereumWaitForTransactionStatusTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.js +18 -0
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.js.map +1 -0
- package/dist/esm/core/tasks/helpers/estimateTransactionRequest.d.ts +8 -0
- package/dist/esm/core/tasks/helpers/estimateTransactionRequest.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/estimateTransactionRequest.js +22 -0
- package/dist/esm/core/tasks/helpers/estimateTransactionRequest.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +13 -0
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js +23 -0
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getTxLink.d.ts +8 -0
- package/dist/esm/core/tasks/helpers/getTxLink.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/getTxLink.js +8 -0
- package/dist/esm/core/tasks/helpers/getTxLink.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getUpdatedStep.d.ts +7 -0
- package/dist/esm/core/tasks/helpers/getUpdatedStep.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/getUpdatedStep.js +100 -0
- package/dist/esm/core/tasks/helpers/getUpdatedStep.js.map +1 -0
- package/dist/esm/core/tasks/helpers/isPermit2Supported.d.ts +7 -0
- package/dist/esm/core/tasks/helpers/isPermit2Supported.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/isPermit2Supported.js +8 -0
- package/dist/esm/core/tasks/helpers/isPermit2Supported.js.map +1 -0
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.d.ts +7 -0
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.js +10 -0
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.js.map +1 -0
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts +8 -0
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js +67 -0
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -0
- package/dist/esm/core/tasks/helpers/switchChain.d.ts +23 -0
- package/dist/esm/core/tasks/helpers/switchChain.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/switchChain.js +34 -0
- package/dist/esm/core/tasks/helpers/switchChain.js.map +1 -0
- package/dist/esm/core/tasks/helpers/updateActionWithReceipt.d.ts +13 -0
- package/dist/esm/core/tasks/helpers/updateActionWithReceipt.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/updateActionWithReceipt.js +18 -0
- package/dist/esm/core/tasks/helpers/updateActionWithReceipt.js.map +1 -0
- package/dist/esm/errors/parseEthereumErrors.d.ts +8 -3
- package/dist/esm/errors/parseEthereumErrors.d.ts.map +1 -0
- package/dist/esm/errors/parseEthereumErrors.js +48 -75
- package/dist/esm/errors/parseEthereumErrors.js.map +1 -1
- package/dist/esm/hyperliquid/agentWallet.d.ts +13 -0
- package/dist/esm/hyperliquid/agentWallet.d.ts.map +1 -0
- package/dist/esm/hyperliquid/agentWallet.js +89 -0
- package/dist/esm/hyperliquid/agentWallet.js.map +1 -0
- package/dist/esm/hyperliquid/isHyperliquidAgentStep.d.ts +10 -0
- package/dist/esm/hyperliquid/isHyperliquidAgentStep.d.ts.map +1 -0
- package/dist/esm/hyperliquid/isHyperliquidAgentStep.js +17 -0
- package/dist/esm/hyperliquid/isHyperliquidAgentStep.js.map +1 -0
- package/dist/esm/index.d.ts +17 -16
- package/dist/esm/index.js +17 -17
- package/dist/esm/package.json +1 -1
- package/dist/esm/permits/allowanceTransfer.d.ts +38 -33
- package/dist/esm/permits/allowanceTransfer.d.ts.map +1 -0
- package/dist/esm/permits/allowanceTransfer.js +111 -77
- package/dist/esm/permits/allowanceTransfer.js.map +1 -1
- package/dist/esm/permits/canAccountUseNativePermits.d.ts +14 -0
- package/dist/esm/permits/canAccountUseNativePermits.d.ts.map +1 -0
- package/dist/esm/permits/canAccountUseNativePermits.js +24 -0
- package/dist/esm/permits/canAccountUseNativePermits.js.map +1 -0
- package/dist/esm/permits/constants.d.ts +77 -72
- package/dist/esm/permits/constants.d.ts.map +1 -0
- package/dist/esm/permits/constants.js +85 -66
- package/dist/esm/permits/constants.js.map +1 -1
- package/dist/esm/permits/domain.d.ts +7 -2
- package/dist/esm/permits/domain.d.ts.map +1 -0
- package/dist/esm/permits/domain.js +11 -7
- package/dist/esm/permits/domain.js.map +1 -1
- package/dist/esm/permits/encodeNativePermitData.d.ts +7 -2
- package/dist/esm/permits/encodeNativePermitData.d.ts.map +1 -0
- package/dist/esm/permits/encodeNativePermitData.js +21 -10
- package/dist/esm/permits/encodeNativePermitData.js.map +1 -1
- package/dist/esm/permits/encodePermit2Data.d.ts +7 -3
- package/dist/esm/permits/encodePermit2Data.d.ts.map +1 -0
- package/dist/esm/permits/encodePermit2Data.js +34 -26
- package/dist/esm/permits/encodePermit2Data.js.map +1 -1
- package/dist/esm/permits/getNativePermit.d.ts +29 -19
- package/dist/esm/permits/getNativePermit.d.ts.map +1 -0
- package/dist/esm/permits/getNativePermit.js +232 -346
- package/dist/esm/permits/getNativePermit.js.map +1 -1
- package/dist/esm/permits/getPermitTransferFromValues.d.ts +9 -4
- package/dist/esm/permits/getPermitTransferFromValues.d.ts.map +1 -0
- package/dist/esm/permits/getPermitTransferFromValues.js +23 -19
- package/dist/esm/permits/getPermitTransferFromValues.js.map +1 -1
- package/dist/esm/permits/invariant.d.ts +19 -20
- package/dist/esm/permits/invariant.d.ts.map +1 -0
- package/dist/esm/permits/invariant.js +26 -40
- package/dist/esm/permits/invariant.js.map +1 -1
- package/dist/esm/permits/isDelegationDesignatorCode.d.ts +25 -21
- package/dist/esm/permits/isDelegationDesignatorCode.d.ts.map +1 -0
- package/dist/esm/permits/isDelegationDesignatorCode.js +25 -21
- package/dist/esm/permits/isDelegationDesignatorCode.js.map +1 -1
- package/dist/esm/permits/isNativePermitValid.d.ts +9 -4
- package/dist/esm/permits/isNativePermitValid.d.ts.map +1 -0
- package/dist/esm/permits/isNativePermitValid.js +16 -38
- package/dist/esm/permits/isNativePermitValid.js.map +1 -1
- package/dist/esm/permits/signPermit2Message.d.ts +14 -10
- package/dist/esm/permits/signPermit2Message.d.ts.map +1 -0
- package/dist/esm/permits/signPermit2Message.js +40 -40
- package/dist/esm/permits/signPermit2Message.js.map +1 -1
- package/dist/esm/permits/signatureTransfer.d.ts +39 -34
- package/dist/esm/permits/signatureTransfer.d.ts.map +1 -0
- package/dist/esm/permits/signatureTransfer.js +145 -102
- package/dist/esm/permits/signatureTransfer.js.map +1 -1
- package/dist/esm/permits/types.d.ts +19 -14
- package/dist/esm/permits/types.d.ts.map +1 -0
- package/dist/esm/permits/types.js +0 -1
- package/dist/esm/types.d.ts +65 -43
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +7 -3
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/abi.d.ts +12 -212
- package/dist/esm/utils/abi.d.ts.map +1 -0
- package/dist/esm/utils/abi.js +22 -27
- package/dist/esm/utils/abi.js.map +1 -1
- package/dist/esm/utils/convertExtendedChain.d.ts +8 -3
- package/dist/esm/utils/convertExtendedChain.d.ts.map +1 -0
- package/dist/esm/utils/convertExtendedChain.js +20 -20
- package/dist/esm/utils/convertExtendedChain.js.map +1 -1
- package/dist/esm/utils/getActionWithFallback.d.ts +22 -17
- package/dist/esm/utils/getActionWithFallback.d.ts.map +1 -0
- package/dist/esm/utils/getActionWithFallback.js +28 -32
- package/dist/esm/utils/getActionWithFallback.js.map +1 -1
- package/dist/esm/utils/getDomainChainId.d.ts +11 -6
- package/dist/esm/utils/getDomainChainId.d.ts.map +1 -0
- package/dist/esm/utils/getDomainChainId.js +17 -20
- package/dist/esm/utils/getDomainChainId.js.map +1 -1
- package/dist/esm/utils/getSafeApiKey.d.ts +7 -0
- package/dist/esm/utils/getSafeApiKey.d.ts.map +1 -0
- package/dist/esm/utils/getSafeApiKey.js +11 -0
- package/dist/esm/utils/getSafeApiKey.js.map +1 -0
- package/dist/esm/utils/isContractCallStep.d.ts +7 -2
- package/dist/esm/utils/isContractCallStep.d.ts.map +1 -0
- package/dist/esm/utils/isContractCallStep.js +6 -2
- package/dist/esm/utils/isContractCallStep.js.map +1 -1
- package/dist/esm/utils/isExtendedChain.d.ts +7 -2
- package/dist/esm/utils/isExtendedChain.d.ts.map +1 -0
- package/dist/esm/utils/isExtendedChain.js +6 -12
- package/dist/esm/utils/isExtendedChain.js.map +1 -1
- package/dist/esm/utils/isGaslessStep.d.ts +8 -3
- package/dist/esm/utils/isGaslessStep.d.ts.map +1 -0
- package/dist/esm/utils/isGaslessStep.js +6 -4
- package/dist/esm/utils/isGaslessStep.js.map +1 -1
- package/dist/esm/utils/isRelayerStep.d.ts +8 -3
- package/dist/esm/utils/isRelayerStep.d.ts.map +1 -0
- package/dist/esm/utils/isRelayerStep.js +6 -2
- package/dist/esm/utils/isRelayerStep.js.map +1 -1
- package/dist/esm/utils/isZeroAddress.d.ts +7 -3
- package/dist/esm/utils/isZeroAddress.d.ts.map +1 -0
- package/dist/esm/utils/isZeroAddress.js +9 -7
- package/dist/esm/utils/isZeroAddress.js.map +1 -1
- package/dist/esm/utils/median.d.ts +5 -1
- package/dist/esm/utils/median.d.ts.map +1 -0
- package/dist/esm/utils/median.js +10 -10
- package/dist/esm/utils/median.js.map +1 -1
- package/dist/esm/version.d.ts +6 -2
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +6 -2
- package/dist/esm/version.js.map +1 -1
- package/package.json +7 -6
- package/src/EthereumProvider.ts +2 -1
- package/src/actions/constants.ts +2 -0
- package/src/actions/getAccountCode.ts +41 -0
- package/src/actions/getAllowance.ts +1 -1
- package/src/actions/getEthereumBalance.ts +11 -2
- package/src/actions/isSafeSignature.ts +34 -0
- package/src/actions/isSafeWallet.ts +55 -0
- package/src/actions/isSmartContractWallet.ts +9 -0
- package/src/actions/resolveTransactionHash.ts +36 -0
- package/src/actions/setAllowance.ts +8 -2
- package/src/actions/waitForSafeTransactionExecution.ts +126 -0
- package/src/client/safeClient.ts +112 -0
- package/src/client/types.ts +18 -0
- package/src/core/EthereumStepExecutor.ts +183 -0
- package/src/core/tasks/EthereumBatchedSignAndExecuteTask.ts +76 -0
- package/src/core/tasks/EthereumBatchedWaitForTransactionTask.ts +70 -0
- package/src/core/tasks/EthereumCheckAllowanceTask.ts +72 -0
- package/src/core/tasks/EthereumCheckBalanceTask.ts +50 -0
- package/src/core/tasks/EthereumCheckPermitsTask.ts +94 -0
- package/src/core/tasks/EthereumNativePermitTask.ts +129 -0
- package/src/core/tasks/EthereumPrepareTransactionTask.ts +128 -0
- package/src/core/tasks/EthereumRelayedSignAndExecuteTask.ts +121 -0
- package/src/core/tasks/EthereumRelayedWaitForTransactionTask.ts +48 -0
- package/src/core/tasks/EthereumResetAllowanceTask.ts +131 -0
- package/src/core/tasks/EthereumSetAllowanceTask.ts +132 -0
- package/src/core/tasks/EthereumSignAndExecuteTask.ts +49 -0
- package/src/core/tasks/EthereumStandardSignAndExecuteTask.ts +158 -0
- package/src/core/tasks/EthereumStandardWaitForTransactionTask.ts +65 -0
- package/src/core/tasks/EthereumWaitForTransactionStatusTask.ts +33 -0
- package/src/core/tasks/EthereumWaitForTransactionTask.ts +19 -0
- package/src/core/tasks/helpers/estimateTransactionRequest.ts +42 -0
- package/src/core/tasks/helpers/getEthereumExecutionStrategy.ts +45 -0
- package/src/core/tasks/helpers/getTxLink.ts +6 -0
- package/src/core/tasks/helpers/getUpdatedStep.ts +160 -0
- package/src/core/tasks/helpers/isPermit2Supported.ts +28 -0
- package/src/core/tasks/helpers/shouldCheckForAllowance.ts +24 -0
- package/src/core/tasks/helpers/signHyperliquidTypedData.ts +110 -0
- package/src/core/tasks/helpers/switchChain.ts +64 -0
- package/src/core/tasks/helpers/updateActionWithReceipt.ts +40 -0
- package/src/errors/parseEthereumErrors.ts +18 -4
- package/src/hyperliquid/agentWallet.ts +157 -0
- package/src/hyperliquid/isHyperliquidAgentStep.ts +24 -0
- package/src/index.ts +4 -0
- package/src/permits/allowanceTransfer.ts +5 -5
- package/src/permits/canAccountUseNativePermits.ts +31 -0
- package/src/permits/constants.ts +13 -11
- package/src/permits/getNativePermit.ts +19 -55
- package/src/permits/getPermitTransferFromValues.ts +1 -1
- package/src/permits/isDelegationDesignatorCode.ts +2 -2
- package/src/permits/signatureTransfer.ts +2 -2
- package/src/types.ts +34 -4
- package/src/utils/abi.ts +7 -7
- package/src/utils/getSafeApiKey.ts +10 -0
- package/src/version.ts +1 -1
- package/dist/cjs/EthereumStepExecutor.d.ts +0 -23
- package/dist/cjs/EthereumStepExecutor.js +0 -515
- package/dist/cjs/EthereumStepExecutor.js.map +0 -1
- package/dist/cjs/actions/checkAllowance.d.ts +0 -28
- package/dist/cjs/actions/checkAllowance.js +0 -236
- package/dist/cjs/actions/checkAllowance.js.map +0 -1
- package/dist/cjs/actions/switchChain.d.ts +0 -3
- package/dist/cjs/actions/switchChain.js +0 -40
- package/dist/cjs/actions/switchChain.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/permits/types.js.map +0 -1
- package/dist/esm/EthereumStepExecutor.d.ts +0 -23
- package/dist/esm/EthereumStepExecutor.js +0 -570
- package/dist/esm/EthereumStepExecutor.js.map +0 -1
- package/dist/esm/actions/checkAllowance.d.ts +0 -28
- package/dist/esm/actions/checkAllowance.js +0 -256
- package/dist/esm/actions/checkAllowance.js.map +0 -1
- package/dist/esm/actions/switchChain.d.ts +0 -20
- package/dist/esm/actions/switchChain.js +0 -54
- package/dist/esm/actions/switchChain.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/permits/types.js.map +0 -1
- package/dist/types/EthereumProvider.d.ts +0 -3
- package/dist/types/EthereumProvider.d.ts.map +0 -1
- package/dist/types/EthereumStepExecutor.d.ts +0 -24
- package/dist/types/EthereumStepExecutor.d.ts.map +0 -1
- package/dist/types/actions/checkAllowance.d.ts +0 -29
- package/dist/types/actions/checkAllowance.d.ts.map +0 -1
- package/dist/types/actions/checkPermitSupport.d.ts +0 -29
- package/dist/types/actions/checkPermitSupport.d.ts.map +0 -1
- package/dist/types/actions/constants.d.ts +0 -51
- package/dist/types/actions/constants.d.ts.map +0 -1
- package/dist/types/actions/getAllowance.d.ts +0 -23
- package/dist/types/actions/getAllowance.d.ts.map +0 -1
- package/dist/types/actions/getEthereumBalance.d.ts +0 -4
- package/dist/types/actions/getEthereumBalance.d.ts.map +0 -1
- package/dist/types/actions/getMaxPriorityFeePerGas.d.ts +0 -4
- package/dist/types/actions/getMaxPriorityFeePerGas.d.ts.map +0 -1
- package/dist/types/actions/getMulticallAddress.d.ts +0 -4
- package/dist/types/actions/getMulticallAddress.d.ts.map +0 -1
- package/dist/types/actions/isBatchingSupported.d.ts +0 -8
- package/dist/types/actions/isBatchingSupported.d.ts.map +0 -1
- package/dist/types/actions/resolveENSAddress.d.ts +0 -3
- package/dist/types/actions/resolveENSAddress.d.ts.map +0 -1
- package/dist/types/actions/resolveEthereumAddress.d.ts +0 -3
- package/dist/types/actions/resolveEthereumAddress.d.ts.map +0 -1
- package/dist/types/actions/resolveUNSAddress.d.ts +0 -3
- package/dist/types/actions/resolveUNSAddress.d.ts.map +0 -1
- package/dist/types/actions/setAllowance.d.ts +0 -26
- package/dist/types/actions/setAllowance.d.ts.map +0 -1
- package/dist/types/actions/switchChain.d.ts +0 -21
- package/dist/types/actions/switchChain.d.ts.map +0 -1
- package/dist/types/actions/waitForBatchTransactionReceipt.d.ts +0 -5
- package/dist/types/actions/waitForBatchTransactionReceipt.d.ts.map +0 -1
- package/dist/types/actions/waitForRelayedTransactionReceipt.d.ts +0 -6
- package/dist/types/actions/waitForRelayedTransactionReceipt.d.ts.map +0 -1
- package/dist/types/actions/waitForTransactionReceipt.d.ts +0 -11
- package/dist/types/actions/waitForTransactionReceipt.d.ts.map +0 -1
- package/dist/types/client/publicClient.d.ts +0 -10
- package/dist/types/client/publicClient.d.ts.map +0 -1
- package/dist/types/errors/parseEthereumErrors.d.ts +0 -4
- package/dist/types/errors/parseEthereumErrors.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -17
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/permits/allowanceTransfer.d.ts +0 -41
- package/dist/types/permits/allowanceTransfer.d.ts.map +0 -1
- package/dist/types/permits/constants.d.ts +0 -79
- package/dist/types/permits/constants.d.ts.map +0 -1
- package/dist/types/permits/domain.d.ts +0 -3
- package/dist/types/permits/domain.d.ts.map +0 -1
- package/dist/types/permits/encodeNativePermitData.d.ts +0 -3
- package/dist/types/permits/encodeNativePermitData.d.ts.map +0 -1
- package/dist/types/permits/encodePermit2Data.d.ts +0 -4
- package/dist/types/permits/encodePermit2Data.d.ts.map +0 -1
- package/dist/types/permits/getNativePermit.d.ts +0 -23
- package/dist/types/permits/getNativePermit.d.ts.map +0 -1
- package/dist/types/permits/getPermitTransferFromValues.d.ts +0 -5
- package/dist/types/permits/getPermitTransferFromValues.d.ts.map +0 -1
- package/dist/types/permits/invariant.d.ts +0 -22
- package/dist/types/permits/invariant.d.ts.map +0 -1
- package/dist/types/permits/isDelegationDesignatorCode.d.ts +0 -23
- package/dist/types/permits/isDelegationDesignatorCode.d.ts.map +0 -1
- package/dist/types/permits/isNativePermitValid.d.ts +0 -6
- package/dist/types/permits/isNativePermitValid.d.ts.map +0 -1
- package/dist/types/permits/signPermit2Message.d.ts +0 -13
- package/dist/types/permits/signPermit2Message.d.ts.map +0 -1
- package/dist/types/permits/signatureTransfer.d.ts +0 -41
- package/dist/types/permits/signatureTransfer.d.ts.map +0 -1
- package/dist/types/permits/types.d.ts +0 -18
- package/dist/types/permits/types.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -54
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utils/abi.d.ts +0 -213
- package/dist/types/utils/abi.d.ts.map +0 -1
- package/dist/types/utils/convertExtendedChain.d.ts +0 -4
- package/dist/types/utils/convertExtendedChain.d.ts.map +0 -1
- package/dist/types/utils/getActionWithFallback.d.ts +0 -20
- package/dist/types/utils/getActionWithFallback.d.ts.map +0 -1
- package/dist/types/utils/getDomainChainId.d.ts +0 -8
- package/dist/types/utils/getDomainChainId.d.ts.map +0 -1
- package/dist/types/utils/isContractCallStep.d.ts +0 -3
- package/dist/types/utils/isContractCallStep.d.ts.map +0 -1
- package/dist/types/utils/isExtendedChain.d.ts +0 -3
- package/dist/types/utils/isExtendedChain.d.ts.map +0 -1
- package/dist/types/utils/isGaslessStep.d.ts +0 -4
- package/dist/types/utils/isGaslessStep.d.ts.map +0 -1
- package/dist/types/utils/isRelayerStep.d.ts +0 -4
- package/dist/types/utils/isRelayerStep.d.ts.map +0 -1
- package/dist/types/utils/isZeroAddress.d.ts +0 -4
- package/dist/types/utils/isZeroAddress.d.ts.map +0 -1
- package/dist/types/utils/median.d.ts +0 -2
- package/dist/types/utils/median.d.ts.map +0 -1
- package/dist/types/version.d.ts +0 -3
- package/dist/types/version.d.ts.map +0 -1
- package/src/EthereumStepExecutor.ts +0 -860
- package/src/actions/checkAllowance.ts +0 -442
- package/src/actions/switchChain.ts +0 -85
|
@@ -1,442 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ExecutionAction,
|
|
3
|
-
ExecutionActionType,
|
|
4
|
-
ExecutionOptions,
|
|
5
|
-
ExtendedChain,
|
|
6
|
-
LiFiStep,
|
|
7
|
-
LiFiStepExtended,
|
|
8
|
-
SDKClient,
|
|
9
|
-
SignedTypedData,
|
|
10
|
-
StatusManager,
|
|
11
|
-
} from '@lifi/sdk'
|
|
12
|
-
import type { Address, Client, Hash } from 'viem'
|
|
13
|
-
import { signTypedData } from 'viem/actions'
|
|
14
|
-
import { getAction } from 'viem/utils'
|
|
15
|
-
import { parseEthereumErrors } from '../errors/parseEthereumErrors.js'
|
|
16
|
-
import { MaxUint256 } from '../permits/constants.js'
|
|
17
|
-
import { getNativePermit } from '../permits/getNativePermit.js'
|
|
18
|
-
import { isNativePermitValid } from '../permits/isNativePermitValid.js'
|
|
19
|
-
import type { NativePermitData } from '../permits/types.js'
|
|
20
|
-
import type { Call } from '../types.js'
|
|
21
|
-
import { getActionWithFallback } from '../utils/getActionWithFallback.js'
|
|
22
|
-
import { getDomainChainId } from '../utils/getDomainChainId.js'
|
|
23
|
-
import { getAllowance } from './getAllowance.js'
|
|
24
|
-
import { setAllowance } from './setAllowance.js'
|
|
25
|
-
import { waitForTransactionReceipt } from './waitForTransactionReceipt.js'
|
|
26
|
-
|
|
27
|
-
type CheckAllowanceParams = {
|
|
28
|
-
checkClient(
|
|
29
|
-
step: LiFiStepExtended,
|
|
30
|
-
action: ExecutionAction,
|
|
31
|
-
targetChainId?: number
|
|
32
|
-
): Promise<Client | undefined>
|
|
33
|
-
chain: ExtendedChain
|
|
34
|
-
step: LiFiStep
|
|
35
|
-
statusManager: StatusManager
|
|
36
|
-
executionOptions?: ExecutionOptions
|
|
37
|
-
allowUserInteraction?: boolean
|
|
38
|
-
batchingSupported?: boolean
|
|
39
|
-
permit2Supported?: boolean
|
|
40
|
-
disableMessageSigning?: boolean
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
type AllowanceResult =
|
|
44
|
-
| {
|
|
45
|
-
status: 'ACTION_REQUIRED'
|
|
46
|
-
}
|
|
47
|
-
| {
|
|
48
|
-
status: 'BATCH_APPROVAL'
|
|
49
|
-
data: { calls: Call[]; signedTypedData: SignedTypedData[] }
|
|
50
|
-
}
|
|
51
|
-
| {
|
|
52
|
-
status: 'NATIVE_PERMIT' | 'DONE'
|
|
53
|
-
data: SignedTypedData[]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const checkAllowance = async (
|
|
57
|
-
client: SDKClient,
|
|
58
|
-
{
|
|
59
|
-
checkClient,
|
|
60
|
-
chain,
|
|
61
|
-
step,
|
|
62
|
-
statusManager,
|
|
63
|
-
executionOptions,
|
|
64
|
-
allowUserInteraction = false,
|
|
65
|
-
batchingSupported = false,
|
|
66
|
-
permit2Supported = false,
|
|
67
|
-
disableMessageSigning = false,
|
|
68
|
-
}: CheckAllowanceParams
|
|
69
|
-
): Promise<AllowanceResult> => {
|
|
70
|
-
let sharedAction: ExecutionAction | undefined
|
|
71
|
-
let signedTypedData: SignedTypedData[] = []
|
|
72
|
-
try {
|
|
73
|
-
// First, try to sign all permits in step.typedData
|
|
74
|
-
const permitTypedData = step.typedData?.filter(
|
|
75
|
-
(typedData) => typedData.primaryType === 'Permit'
|
|
76
|
-
)
|
|
77
|
-
if (!disableMessageSigning && permitTypedData?.length) {
|
|
78
|
-
sharedAction = statusManager.findOrCreateAction({
|
|
79
|
-
step,
|
|
80
|
-
type: 'PERMIT',
|
|
81
|
-
chainId: step.action.fromChainId,
|
|
82
|
-
})
|
|
83
|
-
signedTypedData = sharedAction.signedTypedData ?? signedTypedData
|
|
84
|
-
for (const typedData of permitTypedData) {
|
|
85
|
-
// Check if we already have a valid permit for this chain and requirements
|
|
86
|
-
const signedTypedDataForChain = signedTypedData.find(
|
|
87
|
-
(signedTypedData) => isNativePermitValid(signedTypedData, typedData)
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
if (signedTypedDataForChain) {
|
|
91
|
-
// Skip signing if we already have a valid permit
|
|
92
|
-
continue
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
sharedAction = statusManager.updateAction(
|
|
96
|
-
step,
|
|
97
|
-
sharedAction.type,
|
|
98
|
-
'ACTION_REQUIRED'
|
|
99
|
-
)
|
|
100
|
-
if (!allowUserInteraction) {
|
|
101
|
-
return { status: 'ACTION_REQUIRED' }
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const typedDataChainId =
|
|
105
|
-
getDomainChainId(typedData.domain) || step.action.fromChainId
|
|
106
|
-
// Switch to the permit's chain if needed
|
|
107
|
-
const permitClient = await checkClient(
|
|
108
|
-
step,
|
|
109
|
-
sharedAction,
|
|
110
|
-
typedDataChainId
|
|
111
|
-
)
|
|
112
|
-
if (!permitClient) {
|
|
113
|
-
return { status: 'ACTION_REQUIRED' }
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const signature = await getAction(
|
|
117
|
-
permitClient,
|
|
118
|
-
signTypedData,
|
|
119
|
-
'signTypedData'
|
|
120
|
-
)({
|
|
121
|
-
account: permitClient.account!,
|
|
122
|
-
domain: typedData.domain,
|
|
123
|
-
types: typedData.types,
|
|
124
|
-
primaryType: typedData.primaryType,
|
|
125
|
-
message: typedData.message,
|
|
126
|
-
})
|
|
127
|
-
const signedPermit: SignedTypedData = {
|
|
128
|
-
...typedData,
|
|
129
|
-
signature,
|
|
130
|
-
}
|
|
131
|
-
signedTypedData.push(signedPermit)
|
|
132
|
-
sharedAction = statusManager.updateAction(
|
|
133
|
-
step,
|
|
134
|
-
sharedAction.type,
|
|
135
|
-
'ACTION_REQUIRED',
|
|
136
|
-
{
|
|
137
|
-
signedTypedData,
|
|
138
|
-
}
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
statusManager.updateAction(step, sharedAction.type, 'DONE', {
|
|
143
|
-
signedTypedData,
|
|
144
|
-
})
|
|
145
|
-
// Check if there's a signed permit for the source transaction chain
|
|
146
|
-
const matchingPermit = signedTypedData.find(
|
|
147
|
-
(signedTypedData) =>
|
|
148
|
-
getDomainChainId(signedTypedData.domain) === step.action.fromChainId
|
|
149
|
-
)
|
|
150
|
-
if (matchingPermit) {
|
|
151
|
-
return {
|
|
152
|
-
status: 'NATIVE_PERMIT',
|
|
153
|
-
data: signedTypedData,
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Find existing or create new allowance action
|
|
159
|
-
sharedAction = statusManager.findOrCreateAction({
|
|
160
|
-
step,
|
|
161
|
-
type: 'TOKEN_ALLOWANCE',
|
|
162
|
-
chainId: step.action.fromChainId,
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
const updatedClient = await checkClient(step, sharedAction)
|
|
166
|
-
if (!updatedClient) {
|
|
167
|
-
return { status: 'ACTION_REQUIRED' }
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Handle existing pending transaction
|
|
171
|
-
if (sharedAction.txHash && sharedAction.status !== 'DONE') {
|
|
172
|
-
await waitForApprovalTransaction(
|
|
173
|
-
client,
|
|
174
|
-
updatedClient,
|
|
175
|
-
sharedAction.txHash as Address,
|
|
176
|
-
sharedAction.type,
|
|
177
|
-
step,
|
|
178
|
-
chain,
|
|
179
|
-
statusManager
|
|
180
|
-
)
|
|
181
|
-
return { status: 'DONE', data: signedTypedData }
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Start new allowance check
|
|
185
|
-
statusManager.updateAction(step, sharedAction.type, 'STARTED')
|
|
186
|
-
|
|
187
|
-
const spenderAddress = permit2Supported
|
|
188
|
-
? chain.permit2
|
|
189
|
-
: step.estimate.approvalAddress
|
|
190
|
-
|
|
191
|
-
const fromAmount = BigInt(step.action.fromAmount)
|
|
192
|
-
|
|
193
|
-
const approved = await getAllowance(
|
|
194
|
-
client,
|
|
195
|
-
updatedClient,
|
|
196
|
-
step.action.fromToken.address as Address,
|
|
197
|
-
updatedClient.account!.address,
|
|
198
|
-
spenderAddress as Address
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
// Return early if already approved
|
|
202
|
-
if (fromAmount <= approved) {
|
|
203
|
-
statusManager.updateAction(step, sharedAction.type, 'DONE')
|
|
204
|
-
return { status: 'DONE', data: signedTypedData }
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Check if proxy contract is available and message signing is not disabled, also not available for atomic batch
|
|
208
|
-
const isNativePermitAvailable =
|
|
209
|
-
!!chain.permit2Proxy &&
|
|
210
|
-
!batchingSupported &&
|
|
211
|
-
!disableMessageSigning &&
|
|
212
|
-
!step.estimate.skipPermit
|
|
213
|
-
|
|
214
|
-
let nativePermitData: NativePermitData | undefined
|
|
215
|
-
if (isNativePermitAvailable) {
|
|
216
|
-
nativePermitData = await getActionWithFallback(
|
|
217
|
-
client,
|
|
218
|
-
updatedClient,
|
|
219
|
-
getNativePermit,
|
|
220
|
-
'getNativePermit',
|
|
221
|
-
{
|
|
222
|
-
client,
|
|
223
|
-
viemClient: updatedClient,
|
|
224
|
-
chainId: chain.id,
|
|
225
|
-
tokenAddress: step.action.fromToken.address as Address,
|
|
226
|
-
spenderAddress: chain.permit2Proxy as Address,
|
|
227
|
-
amount: fromAmount,
|
|
228
|
-
}
|
|
229
|
-
)
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (isNativePermitAvailable && nativePermitData) {
|
|
233
|
-
signedTypedData = signedTypedData.length
|
|
234
|
-
? signedTypedData
|
|
235
|
-
: sharedAction.signedTypedData || []
|
|
236
|
-
// Check if we already have a valid permit for this chain and requirements
|
|
237
|
-
const signedTypedDataForChain = signedTypedData.find((signedTypedData) =>
|
|
238
|
-
isNativePermitValid(signedTypedData, nativePermitData)
|
|
239
|
-
)
|
|
240
|
-
|
|
241
|
-
if (!signedTypedDataForChain) {
|
|
242
|
-
statusManager.updateAction(step, sharedAction.type, 'ACTION_REQUIRED')
|
|
243
|
-
|
|
244
|
-
if (!allowUserInteraction) {
|
|
245
|
-
return { status: 'ACTION_REQUIRED' }
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// Sign the permit
|
|
249
|
-
const signature = await getAction(
|
|
250
|
-
updatedClient,
|
|
251
|
-
signTypedData,
|
|
252
|
-
'signTypedData'
|
|
253
|
-
)({
|
|
254
|
-
account: updatedClient.account!,
|
|
255
|
-
domain: nativePermitData.domain,
|
|
256
|
-
types: nativePermitData.types,
|
|
257
|
-
primaryType: nativePermitData.primaryType,
|
|
258
|
-
message: nativePermitData.message,
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
// Add the new permit to the signed permits array
|
|
262
|
-
const signedPermit: SignedTypedData = {
|
|
263
|
-
...nativePermitData,
|
|
264
|
-
signature,
|
|
265
|
-
}
|
|
266
|
-
signedTypedData.push(signedPermit)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
statusManager.updateAction(step, sharedAction.type, 'DONE', {
|
|
270
|
-
signedTypedData,
|
|
271
|
-
})
|
|
272
|
-
return {
|
|
273
|
-
status: 'NATIVE_PERMIT',
|
|
274
|
-
data: signedTypedData,
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const shouldResetApproval = step.estimate.approvalReset && approved > 0n
|
|
279
|
-
const resetApprovalStatus = shouldResetApproval
|
|
280
|
-
? 'RESET_REQUIRED'
|
|
281
|
-
: 'ACTION_REQUIRED'
|
|
282
|
-
|
|
283
|
-
// Clear the txHash and txLink from potential previous approval transaction
|
|
284
|
-
statusManager.updateAction(step, sharedAction.type, resetApprovalStatus, {
|
|
285
|
-
txHash: undefined,
|
|
286
|
-
txLink: undefined,
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
if (!allowUserInteraction) {
|
|
290
|
-
return { status: 'ACTION_REQUIRED' }
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Reset allowance to 0 if required
|
|
294
|
-
let approvalResetTxHash: Hash | undefined
|
|
295
|
-
if (shouldResetApproval) {
|
|
296
|
-
approvalResetTxHash = await setAllowance(
|
|
297
|
-
client,
|
|
298
|
-
updatedClient,
|
|
299
|
-
step.action.fromToken.address as Address,
|
|
300
|
-
spenderAddress as Address,
|
|
301
|
-
0n,
|
|
302
|
-
executionOptions,
|
|
303
|
-
batchingSupported
|
|
304
|
-
)
|
|
305
|
-
|
|
306
|
-
// If batching is NOT supported, wait for the reset transaction
|
|
307
|
-
if (!batchingSupported) {
|
|
308
|
-
await waitForApprovalTransaction(
|
|
309
|
-
client,
|
|
310
|
-
updatedClient,
|
|
311
|
-
approvalResetTxHash,
|
|
312
|
-
sharedAction.type,
|
|
313
|
-
step,
|
|
314
|
-
chain,
|
|
315
|
-
statusManager
|
|
316
|
-
)
|
|
317
|
-
|
|
318
|
-
statusManager.updateAction(step, sharedAction.type, 'ACTION_REQUIRED', {
|
|
319
|
-
txHash: undefined,
|
|
320
|
-
txLink: undefined,
|
|
321
|
-
})
|
|
322
|
-
|
|
323
|
-
if (!allowUserInteraction) {
|
|
324
|
-
return { status: 'ACTION_REQUIRED' }
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// Set new allowance
|
|
330
|
-
const approveAmount = permit2Supported ? MaxUint256 : fromAmount
|
|
331
|
-
const approveTxHash = await setAllowance(
|
|
332
|
-
client,
|
|
333
|
-
updatedClient,
|
|
334
|
-
step.action.fromToken.address as Address,
|
|
335
|
-
spenderAddress as Address,
|
|
336
|
-
approveAmount,
|
|
337
|
-
executionOptions,
|
|
338
|
-
// We need to return the populated transaction is batching is supported
|
|
339
|
-
// instead of executing transaction on-chain
|
|
340
|
-
batchingSupported
|
|
341
|
-
)
|
|
342
|
-
|
|
343
|
-
// If batching is supported, we need to return the batch approval data
|
|
344
|
-
// because allowance was't set by standard approval transaction
|
|
345
|
-
if (batchingSupported) {
|
|
346
|
-
statusManager.updateAction(step, sharedAction.type, 'DONE')
|
|
347
|
-
const calls: Call[] = []
|
|
348
|
-
|
|
349
|
-
// Add reset call first if approval reset is required
|
|
350
|
-
if (shouldResetApproval && approvalResetTxHash) {
|
|
351
|
-
calls.push({
|
|
352
|
-
to: step.action.fromToken.address as Address,
|
|
353
|
-
data: approvalResetTxHash,
|
|
354
|
-
chainId: step.action.fromToken.chainId,
|
|
355
|
-
})
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// Add approval call
|
|
359
|
-
calls.push({
|
|
360
|
-
to: step.action.fromToken.address as Address,
|
|
361
|
-
data: approveTxHash,
|
|
362
|
-
chainId: step.action.fromToken.chainId,
|
|
363
|
-
})
|
|
364
|
-
|
|
365
|
-
return {
|
|
366
|
-
status: 'BATCH_APPROVAL',
|
|
367
|
-
data: {
|
|
368
|
-
calls,
|
|
369
|
-
signedTypedData,
|
|
370
|
-
},
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
await waitForApprovalTransaction(
|
|
375
|
-
client,
|
|
376
|
-
updatedClient,
|
|
377
|
-
approveTxHash,
|
|
378
|
-
sharedAction.type,
|
|
379
|
-
step,
|
|
380
|
-
chain,
|
|
381
|
-
statusManager
|
|
382
|
-
)
|
|
383
|
-
|
|
384
|
-
return { status: 'DONE', data: signedTypedData }
|
|
385
|
-
} catch (e: any) {
|
|
386
|
-
if (!sharedAction) {
|
|
387
|
-
sharedAction = statusManager.findOrCreateAction({
|
|
388
|
-
step,
|
|
389
|
-
type: 'TOKEN_ALLOWANCE',
|
|
390
|
-
chainId: step.action.fromChainId,
|
|
391
|
-
})
|
|
392
|
-
}
|
|
393
|
-
const error = await parseEthereumErrors(e, step, sharedAction)
|
|
394
|
-
statusManager.updateAction(step, sharedAction.type, 'FAILED', {
|
|
395
|
-
error: {
|
|
396
|
-
message: error.cause.message,
|
|
397
|
-
code: error.code,
|
|
398
|
-
},
|
|
399
|
-
})
|
|
400
|
-
throw error
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
const waitForApprovalTransaction = async (
|
|
405
|
-
client: SDKClient,
|
|
406
|
-
viemClient: Client,
|
|
407
|
-
txHash: Hash,
|
|
408
|
-
actionType: ExecutionActionType,
|
|
409
|
-
step: LiFiStep,
|
|
410
|
-
chain: ExtendedChain,
|
|
411
|
-
statusManager: StatusManager,
|
|
412
|
-
approvalReset: boolean = false
|
|
413
|
-
) => {
|
|
414
|
-
const baseExplorerUrl = chain.metamask.blockExplorerUrls[0]
|
|
415
|
-
const getTxLink = (hash: Hash) => `${baseExplorerUrl}tx/${hash}`
|
|
416
|
-
|
|
417
|
-
statusManager.updateAction(step, actionType, 'PENDING', {
|
|
418
|
-
txHash,
|
|
419
|
-
txLink: getTxLink(txHash),
|
|
420
|
-
})
|
|
421
|
-
|
|
422
|
-
const transactionReceipt = await waitForTransactionReceipt(client, {
|
|
423
|
-
client: viemClient,
|
|
424
|
-
chainId: chain.id,
|
|
425
|
-
txHash,
|
|
426
|
-
onReplaced(response) {
|
|
427
|
-
const newHash = response.transaction.hash
|
|
428
|
-
statusManager.updateAction(step, actionType, 'PENDING', {
|
|
429
|
-
txHash: newHash,
|
|
430
|
-
txLink: getTxLink(newHash),
|
|
431
|
-
})
|
|
432
|
-
},
|
|
433
|
-
})
|
|
434
|
-
|
|
435
|
-
const finalHash = transactionReceipt?.transactionHash || txHash
|
|
436
|
-
if (!approvalReset) {
|
|
437
|
-
statusManager.updateAction(step, actionType, 'DONE', {
|
|
438
|
-
txHash: finalHash,
|
|
439
|
-
txLink: getTxLink(finalHash),
|
|
440
|
-
})
|
|
441
|
-
}
|
|
442
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ExecutionAction,
|
|
3
|
-
LiFiErrorCode,
|
|
4
|
-
type LiFiStepExtended,
|
|
5
|
-
ProviderError,
|
|
6
|
-
type StatusManager,
|
|
7
|
-
} from '@lifi/sdk'
|
|
8
|
-
import type { Client, GetChainIdReturnType } from 'viem'
|
|
9
|
-
import { getChainId } from 'viem/actions'
|
|
10
|
-
import { getAction } from 'viem/utils'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* This method checks whether the wallet client is configured for the correct chain.
|
|
14
|
-
* If yes it returns the wallet clien.
|
|
15
|
-
* If no and if user interaction is allowed it triggers the switchChain callback. If no user interaction is allowed it aborts.
|
|
16
|
-
*
|
|
17
|
-
* Account Type: local -
|
|
18
|
-
* We need to create and return a new connector client from the switchChain callback in order to continue execution on a new chain.
|
|
19
|
-
*
|
|
20
|
-
* Account Type: json-rpc -
|
|
21
|
-
* We can switch chain and return existing connector client from the switchChain callback in order to continue execution on a new chain.
|
|
22
|
-
* @param client
|
|
23
|
-
* @param statusManager
|
|
24
|
-
* @param step
|
|
25
|
-
* @param switchChain
|
|
26
|
-
* @param allowUserInteraction
|
|
27
|
-
* @returns New connector client
|
|
28
|
-
*/
|
|
29
|
-
export const switchChain = async (
|
|
30
|
-
client: Client,
|
|
31
|
-
statusManager: StatusManager,
|
|
32
|
-
step: LiFiStepExtended,
|
|
33
|
-
action: ExecutionAction,
|
|
34
|
-
targetChainId: number,
|
|
35
|
-
allowUserInteraction: boolean,
|
|
36
|
-
switchChain?: (chainId: number) => Promise<Client | undefined>
|
|
37
|
-
): Promise<Client | undefined> => {
|
|
38
|
-
// if we are already on the correct chain we can proceed directly
|
|
39
|
-
const currentChainId = (await getAction(
|
|
40
|
-
client,
|
|
41
|
-
getChainId,
|
|
42
|
-
'getChainId'
|
|
43
|
-
)(undefined)) as GetChainIdReturnType
|
|
44
|
-
if (currentChainId === targetChainId) {
|
|
45
|
-
return client
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (!allowUserInteraction) {
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
if (!switchChain) {
|
|
54
|
-
throw new ProviderError(
|
|
55
|
-
LiFiErrorCode.ChainSwitchError,
|
|
56
|
-
'Chain switch hook is not provided.'
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
const updatedClient = await switchChain(targetChainId)
|
|
60
|
-
let updatedChainId: number | undefined
|
|
61
|
-
if (updatedClient) {
|
|
62
|
-
updatedChainId = (await getAction(
|
|
63
|
-
updatedClient,
|
|
64
|
-
getChainId,
|
|
65
|
-
'getChainId'
|
|
66
|
-
)(undefined)) as GetChainIdReturnType
|
|
67
|
-
}
|
|
68
|
-
if (updatedChainId !== targetChainId) {
|
|
69
|
-
throw new ProviderError(
|
|
70
|
-
LiFiErrorCode.ChainSwitchError,
|
|
71
|
-
'Chain switch required.'
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return updatedClient
|
|
76
|
-
} catch (error: any) {
|
|
77
|
-
statusManager.updateAction(step, action.type, 'FAILED', {
|
|
78
|
-
error: {
|
|
79
|
-
message: error.message,
|
|
80
|
-
code: LiFiErrorCode.ChainSwitchError,
|
|
81
|
-
},
|
|
82
|
-
})
|
|
83
|
-
throw error
|
|
84
|
-
}
|
|
85
|
-
}
|