@lifi/sdk-provider-ethereum 4.0.14 → 4.2.0
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 +36 -0
- package/README.md +24 -8
- package/dist/cjs/EthereumProvider.d.ts +1 -2
- package/dist/cjs/EthereumProvider.js +5 -0
- package/dist/cjs/EthereumProvider.js.map +1 -1
- package/dist/cjs/actions/checkPermitSupport.d.ts +1 -2
- package/dist/cjs/actions/constants.d.ts +6 -7
- package/dist/cjs/actions/getAccountCode.d.ts +1 -2
- package/dist/cjs/actions/getAllowance.d.ts +4 -5
- package/dist/cjs/actions/getEthereumBalance.d.ts +1 -2
- package/dist/cjs/actions/getMaxPriorityFeePerGas.d.ts +1 -2
- package/dist/cjs/actions/getMulticallAddress.d.ts +1 -2
- package/dist/cjs/actions/isBatchingSupported.d.ts +1 -2
- package/dist/cjs/actions/isSafeSignature.d.ts +2 -3
- package/dist/cjs/actions/isSafeWallet.d.ts +1 -2
- package/dist/cjs/actions/isSmartContractWallet.d.ts +1 -2
- package/dist/cjs/actions/resolveENSAddress.d.ts +1 -2
- package/dist/cjs/actions/resolveEthereumAddress.d.ts +1 -2
- package/dist/cjs/actions/resolveTransactionHash.d.ts +1 -2
- package/dist/cjs/actions/resolveUNSAddress.d.ts +1 -2
- package/dist/cjs/actions/setAllowance.d.ts +3 -4
- package/dist/cjs/actions/waitForBatchTransactionReceipt.d.ts +1 -2
- package/dist/cjs/actions/waitForRelayedTransactionReceipt.d.ts +1 -2
- package/dist/cjs/actions/waitForSafeTransactionExecution.d.ts +2 -3
- package/dist/cjs/actions/waitForTransactionReceipt.d.ts +1 -2
- package/dist/cjs/client/publicClient.d.ts +1 -2
- package/dist/cjs/client/safeClient.d.ts +3 -4
- package/dist/cjs/client/types.d.ts +3 -4
- package/dist/cjs/core/EthereumStepExecutor.d.ts +1 -2
- package/dist/cjs/core/EthereumStepExecutor.js +2 -0
- package/dist/cjs/core/EthereumStepExecutor.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumBatchedWaitForTransactionTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.d.ts +3 -4
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.js +6 -5
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumCheckPermitsTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumCheckPermitsTask.js +11 -29
- package/dist/cjs/core/tasks/EthereumCheckPermitsTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumNativePermitTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumNativePermitTask.js +2 -0
- package/dist/cjs/core/tasks/EthereumNativePermitTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumPermit2AllowanceTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumPermit2AllowanceTask.js +33 -0
- package/dist/cjs/core/tasks/EthereumPermit2AllowanceTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js +6 -4
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js +14 -27
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumRelayedWaitForTransactionTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumResetAllowanceTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumSetAllowanceTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumSetAllowanceTask.js +2 -3
- package/dist/cjs/core/tasks/EthereumSetAllowanceTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumSignAndExecuteTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js +3 -4
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumStandardWaitForTransactionTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumWaitForTransactionStatusTask.d.ts +1 -2
- package/dist/cjs/core/tasks/EthereumWaitForTransactionTask.d.ts +1 -2
- package/dist/cjs/core/tasks/helpers/estimateTransactionRequest.d.ts +1 -2
- package/dist/cjs/core/tasks/helpers/findSignedNativePermit.d.ts +7 -0
- package/dist/cjs/core/tasks/helpers/findSignedNativePermit.js +15 -0
- package/dist/cjs/core/tasks/helpers/findSignedNativePermit.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getApprovalAmount.d.ts +6 -0
- package/dist/cjs/core/tasks/helpers/getApprovalAmount.js +16 -0
- package/dist/cjs/core/tasks/helpers/getApprovalAmount.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +7 -2
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js +12 -4
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/getTxLink.d.ts +1 -2
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.d.ts +3 -3
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.js +4 -4
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/hasPermit2AllowanceInFlight.d.ts +8 -0
- package/dist/cjs/core/tasks/helpers/hasPermit2AllowanceInFlight.js +17 -0
- package/dist/cjs/core/tasks/helpers/hasPermit2AllowanceInFlight.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/isTypedDataAlreadySigned.d.ts +6 -0
- package/dist/cjs/core/tasks/helpers/isTypedDataAlreadySigned.js +29 -0
- package/dist/cjs/core/tasks/helpers/isTypedDataAlreadySigned.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/preservePermit2Allowances.d.ts +11 -0
- package/dist/cjs/core/tasks/helpers/preservePermit2Allowances.js +22 -0
- package/dist/cjs/core/tasks/helpers/preservePermit2Allowances.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/resolvePermit2Support.d.ts +1 -2
- package/dist/cjs/core/tasks/helpers/resolvePermit2Support.js +2 -1
- package/dist/cjs/core/tasks/helpers/resolvePermit2Support.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/shouldCheckForAllowance.d.ts +1 -2
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.d.ts +1 -2
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js +3 -3
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.d.ts +13 -0
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js +37 -0
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/switchChain.d.ts +1 -2
- package/dist/cjs/core/tasks/helpers/updateActionWithReceipt.d.ts +1 -2
- package/dist/cjs/errors/parseEthereumErrors.d.ts +2 -3
- package/dist/cjs/hyperliquid/agentWallet.d.ts +2 -3
- package/dist/cjs/hyperliquid/isHyperliquidAgentStep.d.ts +4 -5
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/permits/acceptsRawEcdsaSignature.d.ts +1 -2
- package/dist/cjs/permits/allowanceTransfer.d.ts +12 -13
- package/dist/cjs/permits/canAccountUseNativePermits.d.ts +1 -2
- package/dist/cjs/permits/canAccountUsePermit2.d.ts +1 -2
- package/dist/cjs/permits/constants.d.ts +20 -21
- package/dist/cjs/permits/domain.d.ts +1 -2
- package/dist/cjs/permits/encodeNativePermitData.d.ts +1 -2
- package/dist/cjs/permits/encodePermit2Data.d.ts +1 -2
- package/dist/cjs/permits/getNativePermit.d.ts +1 -2
- package/dist/cjs/permits/getPermitTransferFromValues.d.ts +1 -2
- package/dist/cjs/permits/invariant.d.ts +1 -2
- package/dist/cjs/permits/isDelegationDesignatorCode.d.ts +1 -2
- package/dist/cjs/permits/isNativePermitValid.d.ts +1 -2
- package/dist/cjs/permits/signPermit2Message.d.ts +1 -2
- package/dist/cjs/permits/signatureTransfer.d.ts +11 -12
- package/dist/cjs/permits/types.d.ts +3 -4
- package/dist/cjs/types.d.ts +13 -14
- package/dist/cjs/utils/abi.d.ts +6 -7
- package/dist/cjs/utils/convertExtendedChain.d.ts +1 -2
- package/dist/cjs/utils/getActionWithFallback.d.ts +1 -2
- package/dist/cjs/utils/getDomainChainId.d.ts +1 -2
- package/dist/cjs/utils/getSafeApiKey.d.ts +1 -2
- package/dist/cjs/utils/getTypedDataLane.d.ts +15 -0
- package/dist/cjs/utils/getTypedDataLane.js +33 -0
- package/dist/cjs/utils/getTypedDataLane.js.map +1 -0
- package/dist/cjs/utils/isContractCallStep.d.ts +1 -2
- package/dist/cjs/utils/isExtendedChain.d.ts +1 -2
- package/dist/cjs/utils/isGaslessStep.d.ts +4 -3
- package/dist/cjs/utils/isGaslessStep.js +7 -1
- package/dist/cjs/utils/isGaslessStep.js.map +1 -1
- package/dist/cjs/utils/isValidSignature.d.ts +2 -3
- package/dist/cjs/utils/isZeroAddress.d.ts +3 -4
- package/dist/cjs/utils/median.d.ts +1 -2
- package/dist/cjs/version.d.ts +2 -3
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/EthereumProvider.d.ts +1 -2
- package/dist/esm/EthereumProvider.d.ts.map +1 -1
- package/dist/esm/EthereumProvider.js +5 -0
- package/dist/esm/EthereumProvider.js.map +1 -1
- package/dist/esm/actions/checkPermitSupport.d.ts +1 -2
- package/dist/esm/actions/checkPermitSupport.d.ts.map +1 -1
- package/dist/esm/actions/constants.d.ts +6 -7
- package/dist/esm/actions/constants.d.ts.map +1 -1
- package/dist/esm/actions/getAccountCode.d.ts +1 -2
- package/dist/esm/actions/getAccountCode.d.ts.map +1 -1
- package/dist/esm/actions/getAllowance.d.ts +4 -5
- package/dist/esm/actions/getAllowance.d.ts.map +1 -1
- package/dist/esm/actions/getEthereumBalance.d.ts +1 -2
- package/dist/esm/actions/getEthereumBalance.d.ts.map +1 -1
- package/dist/esm/actions/getMaxPriorityFeePerGas.d.ts +1 -2
- package/dist/esm/actions/getMaxPriorityFeePerGas.d.ts.map +1 -1
- package/dist/esm/actions/getMulticallAddress.d.ts +1 -2
- package/dist/esm/actions/getMulticallAddress.d.ts.map +1 -1
- package/dist/esm/actions/isBatchingSupported.d.ts +1 -2
- package/dist/esm/actions/isBatchingSupported.d.ts.map +1 -1
- package/dist/esm/actions/isSafeSignature.d.ts +2 -3
- package/dist/esm/actions/isSafeSignature.d.ts.map +1 -1
- package/dist/esm/actions/isSafeWallet.d.ts +1 -2
- package/dist/esm/actions/isSafeWallet.d.ts.map +1 -1
- package/dist/esm/actions/isSmartContractWallet.d.ts +1 -2
- package/dist/esm/actions/isSmartContractWallet.d.ts.map +1 -1
- package/dist/esm/actions/resolveENSAddress.d.ts +1 -2
- package/dist/esm/actions/resolveENSAddress.d.ts.map +1 -1
- package/dist/esm/actions/resolveEthereumAddress.d.ts +1 -2
- package/dist/esm/actions/resolveEthereumAddress.d.ts.map +1 -1
- package/dist/esm/actions/resolveTransactionHash.d.ts +1 -2
- package/dist/esm/actions/resolveTransactionHash.d.ts.map +1 -1
- package/dist/esm/actions/resolveUNSAddress.d.ts +1 -2
- package/dist/esm/actions/resolveUNSAddress.d.ts.map +1 -1
- package/dist/esm/actions/setAllowance.d.ts +3 -4
- package/dist/esm/actions/setAllowance.d.ts.map +1 -1
- package/dist/esm/actions/waitForBatchTransactionReceipt.d.ts +1 -2
- package/dist/esm/actions/waitForBatchTransactionReceipt.d.ts.map +1 -1
- package/dist/esm/actions/waitForRelayedTransactionReceipt.d.ts +1 -2
- package/dist/esm/actions/waitForRelayedTransactionReceipt.d.ts.map +1 -1
- package/dist/esm/actions/waitForSafeTransactionExecution.d.ts +2 -3
- package/dist/esm/actions/waitForSafeTransactionExecution.d.ts.map +1 -1
- package/dist/esm/actions/waitForTransactionReceipt.d.ts +1 -2
- package/dist/esm/actions/waitForTransactionReceipt.d.ts.map +1 -1
- package/dist/esm/client/publicClient.d.ts +1 -2
- package/dist/esm/client/publicClient.d.ts.map +1 -1
- package/dist/esm/client/safeClient.d.ts +3 -4
- package/dist/esm/client/safeClient.d.ts.map +1 -1
- package/dist/esm/client/types.d.ts +3 -4
- package/dist/esm/client/types.d.ts.map +1 -1
- package/dist/esm/core/EthereumStepExecutor.d.ts +1 -2
- package/dist/esm/core/EthereumStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/EthereumStepExecutor.js +2 -0
- package/dist/esm/core/EthereumStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumBatchedWaitForTransactionTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumBatchedWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckAllowanceTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumCheckAllowanceTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.d.ts +3 -4
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.js +6 -5
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.js +11 -29
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumNativePermitTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumNativePermitTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumNativePermitTask.js +2 -0
- package/dist/esm/core/tasks/EthereumNativePermitTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.js +32 -0
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js +6 -4
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js +14 -27
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumResetAllowanceTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumResetAllowanceTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.js +2 -3
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js +3 -4
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumStandardWaitForTransactionTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumStandardWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumWaitForTransactionStatusTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumWaitForTransactionStatusTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.d.ts +1 -2
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/estimateTransactionRequest.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/estimateTransactionRequest.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.d.ts +7 -0
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.js +14 -0
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.d.ts +6 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.js +15 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +7 -2
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js +12 -4
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
- package/dist/esm/core/tasks/helpers/getTxLink.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/getTxLink.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getUpdatedStep.d.ts +3 -3
- package/dist/esm/core/tasks/helpers/getUpdatedStep.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getUpdatedStep.js +4 -4
- package/dist/esm/core/tasks/helpers/getUpdatedStep.js.map +1 -1
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.d.ts +8 -0
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.js +15 -0
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.js.map +1 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.d.ts +6 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.js +28 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.js.map +1 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.d.ts +11 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.js +21 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.js.map +1 -0
- package/dist/esm/core/tasks/helpers/resolvePermit2Support.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/resolvePermit2Support.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/resolvePermit2Support.js +2 -1
- package/dist/esm/core/tasks/helpers/resolvePermit2Support.js.map +1 -1
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js +3 -3
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts +13 -0
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.js +36 -0
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.js.map +1 -0
- package/dist/esm/core/tasks/helpers/switchChain.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/switchChain.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/updateActionWithReceipt.d.ts +1 -2
- package/dist/esm/core/tasks/helpers/updateActionWithReceipt.d.ts.map +1 -1
- package/dist/esm/errors/parseEthereumErrors.d.ts +2 -3
- package/dist/esm/errors/parseEthereumErrors.d.ts.map +1 -1
- package/dist/esm/hyperliquid/agentWallet.d.ts +2 -3
- package/dist/esm/hyperliquid/agentWallet.d.ts.map +1 -1
- package/dist/esm/hyperliquid/isHyperliquidAgentStep.d.ts +4 -5
- package/dist/esm/hyperliquid/isHyperliquidAgentStep.d.ts.map +1 -1
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +2 -3
- package/dist/esm/permits/acceptsRawEcdsaSignature.d.ts +1 -2
- package/dist/esm/permits/acceptsRawEcdsaSignature.d.ts.map +1 -1
- package/dist/esm/permits/allowanceTransfer.d.ts +12 -13
- package/dist/esm/permits/allowanceTransfer.d.ts.map +1 -1
- package/dist/esm/permits/canAccountUseNativePermits.d.ts +1 -2
- package/dist/esm/permits/canAccountUseNativePermits.d.ts.map +1 -1
- package/dist/esm/permits/canAccountUsePermit2.d.ts +1 -2
- package/dist/esm/permits/canAccountUsePermit2.d.ts.map +1 -1
- package/dist/esm/permits/constants.d.ts +20 -21
- package/dist/esm/permits/constants.d.ts.map +1 -1
- package/dist/esm/permits/domain.d.ts +1 -2
- package/dist/esm/permits/domain.d.ts.map +1 -1
- package/dist/esm/permits/encodeNativePermitData.d.ts +1 -2
- package/dist/esm/permits/encodeNativePermitData.d.ts.map +1 -1
- package/dist/esm/permits/encodePermit2Data.d.ts +1 -2
- package/dist/esm/permits/encodePermit2Data.d.ts.map +1 -1
- package/dist/esm/permits/getNativePermit.d.ts +1 -2
- package/dist/esm/permits/getNativePermit.d.ts.map +1 -1
- package/dist/esm/permits/getPermitTransferFromValues.d.ts +1 -2
- package/dist/esm/permits/getPermitTransferFromValues.d.ts.map +1 -1
- package/dist/esm/permits/invariant.d.ts +1 -2
- package/dist/esm/permits/invariant.d.ts.map +1 -1
- package/dist/esm/permits/isDelegationDesignatorCode.d.ts +1 -2
- package/dist/esm/permits/isDelegationDesignatorCode.d.ts.map +1 -1
- package/dist/esm/permits/isNativePermitValid.d.ts +1 -2
- package/dist/esm/permits/isNativePermitValid.d.ts.map +1 -1
- package/dist/esm/permits/signPermit2Message.d.ts +1 -2
- package/dist/esm/permits/signPermit2Message.d.ts.map +1 -1
- package/dist/esm/permits/signatureTransfer.d.ts +11 -12
- package/dist/esm/permits/signatureTransfer.d.ts.map +1 -1
- package/dist/esm/permits/types.d.ts +3 -4
- package/dist/esm/permits/types.d.ts.map +1 -1
- package/dist/esm/types.d.ts +13 -14
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/utils/abi.d.ts +6 -7
- package/dist/esm/utils/abi.d.ts.map +1 -1
- package/dist/esm/utils/convertExtendedChain.d.ts +1 -2
- package/dist/esm/utils/convertExtendedChain.d.ts.map +1 -1
- package/dist/esm/utils/getActionWithFallback.d.ts +1 -2
- package/dist/esm/utils/getActionWithFallback.d.ts.map +1 -1
- package/dist/esm/utils/getDomainChainId.d.ts +1 -2
- package/dist/esm/utils/getDomainChainId.d.ts.map +1 -1
- package/dist/esm/utils/getSafeApiKey.d.ts +1 -2
- package/dist/esm/utils/getSafeApiKey.d.ts.map +1 -1
- package/dist/esm/utils/getTypedDataLane.d.ts +15 -0
- package/dist/esm/utils/getTypedDataLane.d.ts.map +1 -0
- package/dist/esm/utils/getTypedDataLane.js +28 -0
- package/dist/esm/utils/getTypedDataLane.js.map +1 -0
- package/dist/esm/utils/isContractCallStep.d.ts +1 -2
- package/dist/esm/utils/isContractCallStep.d.ts.map +1 -1
- package/dist/esm/utils/isExtendedChain.d.ts +1 -2
- package/dist/esm/utils/isExtendedChain.d.ts.map +1 -1
- package/dist/esm/utils/isGaslessStep.d.ts +4 -3
- package/dist/esm/utils/isGaslessStep.d.ts.map +1 -1
- package/dist/esm/utils/isGaslessStep.js +7 -2
- package/dist/esm/utils/isGaslessStep.js.map +1 -1
- package/dist/esm/utils/isValidSignature.d.ts +2 -3
- package/dist/esm/utils/isValidSignature.d.ts.map +1 -1
- package/dist/esm/utils/isZeroAddress.d.ts +3 -4
- package/dist/esm/utils/isZeroAddress.d.ts.map +1 -1
- package/dist/esm/utils/median.d.ts +1 -2
- package/dist/esm/utils/median.d.ts.map +1 -1
- package/dist/esm/version.d.ts +2 -3
- package/dist/esm/version.d.ts.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +3 -3
- package/src/EthereumProvider.ts +6 -0
- package/src/core/EthereumStepExecutor.ts +2 -0
- package/src/core/tasks/EthereumCheckBalanceTask.ts +6 -7
- package/src/core/tasks/EthereumCheckPermitsTask.ts +31 -63
- package/src/core/tasks/EthereumNativePermitTask.ts +5 -0
- package/src/core/tasks/EthereumPermit2AllowanceTask.ts +53 -0
- package/src/core/tasks/EthereumPrepareTransactionTask.ts +11 -2
- package/src/core/tasks/EthereumRelayedSignAndExecuteTask.ts +25 -47
- package/src/core/tasks/EthereumSetAllowanceTask.ts +2 -3
- package/src/core/tasks/EthereumStandardSignAndExecuteTask.ts +2 -9
- package/src/core/tasks/helpers/findSignedNativePermit.ts +23 -0
- package/src/core/tasks/helpers/getApprovalAmount.ts +30 -0
- package/src/core/tasks/helpers/getEthereumExecutionStrategy.ts +31 -5
- package/src/core/tasks/helpers/getUpdatedStep.ts +7 -2
- package/src/core/tasks/helpers/hasPermit2AllowanceInFlight.ts +31 -0
- package/src/core/tasks/helpers/isTypedDataAlreadySigned.ts +56 -0
- package/src/core/tasks/helpers/preservePermit2Allowances.ts +44 -0
- package/src/core/tasks/helpers/resolvePermit2Support.ts +3 -1
- package/src/core/tasks/helpers/signHyperliquidTypedData.ts +3 -3
- package/src/core/tasks/helpers/signTypedDataEntries.ts +70 -0
- package/src/index.ts +0 -1
- package/src/utils/getTypedDataLane.ts +76 -0
- package/src/utils/isGaslessStep.ts +22 -9
- package/src/version.ts +1 -1
- package/dist/cjs/utils/isRelayerStep.d.ts +0 -7
- package/dist/cjs/utils/isRelayerStep.js +0 -9
- package/dist/cjs/utils/isRelayerStep.js.map +0 -1
- package/dist/esm/utils/isRelayerStep.d.ts +0 -7
- package/dist/esm/utils/isRelayerStep.d.ts.map +0 -1
- package/dist/esm/utils/isRelayerStep.js +0 -8
- package/dist/esm/utils/isRelayerStep.js.map +0 -1
- package/src/utils/isRelayerStep.ts +0 -8
|
@@ -2,34 +2,28 @@ import {
|
|
|
2
2
|
BaseStepExecutionTask,
|
|
3
3
|
LiFiErrorCode,
|
|
4
4
|
relayTransaction,
|
|
5
|
+
type SignedTypedData,
|
|
5
6
|
type TaskResult,
|
|
6
7
|
TransactionError,
|
|
7
8
|
} from '@lifi/sdk'
|
|
8
9
|
import type { Hash } from 'viem'
|
|
9
|
-
import { signTypedData } from 'viem/actions'
|
|
10
|
-
import { getAction } from 'viem/utils'
|
|
11
10
|
import { isHyperliquidAgentStep } from '../../hyperliquid/isHyperliquidAgentStep.js'
|
|
12
11
|
import { isNativePermitValid } from '../../permits/isNativePermitValid.js'
|
|
13
12
|
import type { EthereumStepExecutorContext } from '../../types.js'
|
|
14
|
-
import {
|
|
15
|
-
import { assertValidSignature } from '../../utils/isValidSignature.js'
|
|
13
|
+
import { isTypedDataAlreadySigned } from './helpers/isTypedDataAlreadySigned.js'
|
|
16
14
|
import { signHyperliquidTypedData } from './helpers/signHyperliquidTypedData.js'
|
|
15
|
+
import { signTypedDataEntries } from './helpers/signTypedDataEntries.js'
|
|
17
16
|
|
|
18
17
|
export class EthereumRelayedSignAndExecuteTask extends BaseStepExecutionTask {
|
|
19
18
|
async run(context: EthereumStepExecutorContext): Promise<TaskResult> {
|
|
20
19
|
const {
|
|
21
20
|
step,
|
|
22
|
-
fromChain,
|
|
23
21
|
client,
|
|
24
22
|
statusManager,
|
|
25
|
-
allowUserInteraction,
|
|
26
|
-
checkClient,
|
|
27
23
|
isBridgeExecution,
|
|
28
24
|
signedTypedData: currentSignedTypedData,
|
|
29
25
|
} = context
|
|
30
26
|
|
|
31
|
-
const signedTypedData = [...currentSignedTypedData]
|
|
32
|
-
|
|
33
27
|
const action = statusManager.findAction(
|
|
34
28
|
step,
|
|
35
29
|
isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'
|
|
@@ -42,66 +36,50 @@ export class EthereumRelayedSignAndExecuteTask extends BaseStepExecutionTask {
|
|
|
42
36
|
)
|
|
43
37
|
}
|
|
44
38
|
|
|
45
|
-
const
|
|
39
|
+
const allowanceTypedData = step.typedData?.filter(
|
|
46
40
|
(typedData) =>
|
|
47
|
-
!
|
|
41
|
+
!currentSignedTypedData.some((signedPermit) =>
|
|
48
42
|
isNativePermitValid(signedPermit, typedData)
|
|
49
43
|
)
|
|
50
44
|
)
|
|
51
|
-
if (!
|
|
45
|
+
if (!allowanceTypedData?.length) {
|
|
52
46
|
throw new TransactionError(
|
|
53
47
|
LiFiErrorCode.TransactionUnprepared,
|
|
54
48
|
'Unable to prepare transaction. Typed data for transfer is not found.'
|
|
55
49
|
)
|
|
56
50
|
}
|
|
57
51
|
|
|
58
|
-
|
|
52
|
+
// An entry we already hold a signature for is relayed as it is.
|
|
53
|
+
const unsignedTypedData = allowanceTypedData.filter(
|
|
54
|
+
(typedData) =>
|
|
55
|
+
!isTypedDataAlreadySigned(currentSignedTypedData, typedData)
|
|
56
|
+
)
|
|
59
57
|
|
|
58
|
+
let signedTypedData: SignedTypedData[]
|
|
60
59
|
if (isHyperliquidAgentStep(step)) {
|
|
60
|
+
statusManager.updateAction(step, action.type, 'MESSAGE_REQUIRED')
|
|
61
|
+
|
|
61
62
|
const signedResults = await signHyperliquidTypedData(
|
|
62
63
|
context,
|
|
63
|
-
|
|
64
|
+
unsignedTypedData
|
|
64
65
|
)
|
|
65
66
|
|
|
66
67
|
if (!signedResults) {
|
|
67
68
|
return { status: 'PAUSED' }
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
signedTypedData
|
|
71
|
+
signedTypedData = [...currentSignedTypedData, ...signedResults]
|
|
71
72
|
} else {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// Switch to the typed data's chain if needed
|
|
81
|
-
const updatedClient = await checkClient(step, typedDataChainId)
|
|
82
|
-
if (!updatedClient) {
|
|
83
|
-
return { status: 'PAUSED' }
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const signature = await getAction(
|
|
87
|
-
updatedClient,
|
|
88
|
-
signTypedData,
|
|
89
|
-
'signTypedData'
|
|
90
|
-
)({
|
|
91
|
-
account: updatedClient.account!,
|
|
92
|
-
primaryType: typedData.primaryType,
|
|
93
|
-
domain: typedData.domain,
|
|
94
|
-
types: typedData.types,
|
|
95
|
-
message: typedData.message,
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
assertValidSignature(signature)
|
|
99
|
-
|
|
100
|
-
signedTypedData.push({
|
|
101
|
-
...typedData,
|
|
102
|
-
signature: signature,
|
|
103
|
-
})
|
|
73
|
+
const result = await signTypedDataEntries(
|
|
74
|
+
context,
|
|
75
|
+
unsignedTypedData,
|
|
76
|
+
action.type,
|
|
77
|
+
'MESSAGE_REQUIRED'
|
|
78
|
+
)
|
|
79
|
+
if (result.status === 'PAUSED') {
|
|
80
|
+
return { status: 'PAUSED' }
|
|
104
81
|
}
|
|
82
|
+
signedTypedData = result.signedTypedData
|
|
105
83
|
}
|
|
106
84
|
|
|
107
85
|
statusManager.updateAction(step, action.type, 'PENDING')
|
|
@@ -3,8 +3,8 @@ import type { Address } from 'viem'
|
|
|
3
3
|
import { resolveTransactionHash } from '../../actions/resolveTransactionHash.js'
|
|
4
4
|
import { setAllowance } from '../../actions/setAllowance.js'
|
|
5
5
|
import { waitForTransactionReceipt } from '../../actions/waitForTransactionReceipt.js'
|
|
6
|
-
import { MaxUint256 } from '../../permits/constants.js'
|
|
7
6
|
import type { EthereumStepExecutorContext } from '../../types.js'
|
|
7
|
+
import { getApprovalAmount } from './helpers/getApprovalAmount.js'
|
|
8
8
|
import { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'
|
|
9
9
|
import { getTxLink } from './helpers/getTxLink.js'
|
|
10
10
|
import { resolvePermit2Support } from './helpers/resolvePermit2Support.js'
|
|
@@ -53,8 +53,7 @@ export class EthereumSetAllowanceTask extends BaseStepExecutionTask {
|
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
// Set new allowance
|
|
56
|
-
const
|
|
57
|
-
const approveAmount = permit2Supported ? MaxUint256 : fromAmount
|
|
56
|
+
const approveAmount = getApprovalAmount(context, permit2Supported)
|
|
58
57
|
|
|
59
58
|
// Check if chain has Permit2 contract deployed. Permit2 should not be available for atomic batch.
|
|
60
59
|
const spenderAddress = permit2Supported
|
|
@@ -13,9 +13,8 @@ import { encodePermit2Data } from '../../permits/encodePermit2Data.js'
|
|
|
13
13
|
import { signPermit2Message } from '../../permits/signPermit2Message.js'
|
|
14
14
|
import type { EthereumStepExecutorContext } from '../../types.js'
|
|
15
15
|
import { convertExtendedChain } from '../../utils/convertExtendedChain.js'
|
|
16
|
-
import { getDomainChainId } from '../../utils/getDomainChainId.js'
|
|
17
|
-
import { isValidSignature } from '../../utils/isValidSignature.js'
|
|
18
16
|
import { estimateTransactionRequest } from './helpers/estimateTransactionRequest.js'
|
|
17
|
+
import { findSignedNativePermit } from './helpers/findSignedNativePermit.js'
|
|
19
18
|
import { getTxLink } from './helpers/getTxLink.js'
|
|
20
19
|
import { resolvePermit2Support } from './helpers/resolvePermit2Support.js'
|
|
21
20
|
|
|
@@ -28,7 +27,6 @@ export class EthereumStandardSignAndExecuteTask extends BaseStepExecutionTask {
|
|
|
28
27
|
statusManager,
|
|
29
28
|
checkClient,
|
|
30
29
|
transactionRequest,
|
|
31
|
-
signedTypedData,
|
|
32
30
|
allowUserInteraction,
|
|
33
31
|
isBridgeExecution,
|
|
34
32
|
} = context
|
|
@@ -57,12 +55,7 @@ export class EthereumStandardSignAndExecuteTask extends BaseStepExecutionTask {
|
|
|
57
55
|
return { status: 'PAUSED' }
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
const signedNativePermitTypedData =
|
|
61
|
-
(p) =>
|
|
62
|
-
p.primaryType === 'Permit' &&
|
|
63
|
-
getDomainChainId(p.domain) === fromChain.id &&
|
|
64
|
-
isValidSignature(p.signature)
|
|
65
|
-
)
|
|
58
|
+
const signedNativePermitTypedData = findSignedNativePermit(context)
|
|
66
59
|
// Resolved *after* the native-permit lookup, and short-circuited when one
|
|
67
60
|
// is found: a matching permit always wins, so resolving the gate first
|
|
68
61
|
// would spend an `eth_getCode` on a verdict this task never reads. The
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SignedTypedData } from '@lifi/sdk'
|
|
2
|
+
import type { EthereumStepExecutorContext } from '../../../types.js'
|
|
3
|
+
import { getDomainChainId } from '../../../utils/getDomainChainId.js'
|
|
4
|
+
import { isValidSignature } from '../../../utils/isValidSignature.js'
|
|
5
|
+
import { isPermit2AllowanceLaneInFlight } from './hasPermit2AllowanceInFlight.js'
|
|
6
|
+
|
|
7
|
+
/** The signed native EIP-2612 permit this step should execute through, if any. */
|
|
8
|
+
export function findSignedNativePermit(
|
|
9
|
+
context: EthereumStepExecutorContext
|
|
10
|
+
): SignedTypedData | undefined {
|
|
11
|
+
const { fromChain, signedTypedData } = context
|
|
12
|
+
|
|
13
|
+
if (isPermit2AllowanceLaneInFlight(context)) {
|
|
14
|
+
return undefined
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return signedTypedData.find(
|
|
18
|
+
(typedData) =>
|
|
19
|
+
typedData.primaryType === 'Permit' &&
|
|
20
|
+
getDomainChainId(typedData.domain) === fromChain.id &&
|
|
21
|
+
isValidSignature(typedData.signature)
|
|
22
|
+
)
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MaxUint256 } from '../../../permits/constants.js'
|
|
2
|
+
import type { EthereumStepExecutorContext } from '../../../types.js'
|
|
3
|
+
import { getTypedDataInLane } from '../../../utils/getTypedDataLane.js'
|
|
4
|
+
|
|
5
|
+
/** How much of the source token to approve to the step's approval address. */
|
|
6
|
+
export function getApprovalAmount(
|
|
7
|
+
context: EthereumStepExecutorContext,
|
|
8
|
+
permit2Supported: boolean
|
|
9
|
+
): bigint {
|
|
10
|
+
const { step, fromChain, disableMessageSigning } = context
|
|
11
|
+
|
|
12
|
+
if (permit2Supported) {
|
|
13
|
+
return MaxUint256
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const permit2Allowances = disableMessageSigning
|
|
17
|
+
? []
|
|
18
|
+
: getTypedDataInLane(step, 'permit2-allowance', fromChain)
|
|
19
|
+
|
|
20
|
+
const approvalAddress = step.estimate.approvalAddress?.toLowerCase()
|
|
21
|
+
const targetsApprovalAddress =
|
|
22
|
+
permit2Allowances.length > 0 &&
|
|
23
|
+
!!approvalAddress &&
|
|
24
|
+
permit2Allowances.every(
|
|
25
|
+
(typedData) =>
|
|
26
|
+
typedData.domain.verifyingContract?.toLowerCase() === approvalAddress
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
return targetsApprovalAddress ? MaxUint256 : BigInt(step.action.fromAmount)
|
|
30
|
+
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import type { TransactionMethodType } from '@lifi/sdk'
|
|
2
2
|
import { isBatchingSupported } from '../../../actions/isBatchingSupported.js'
|
|
3
3
|
import type { EthereumStepExecutorContext } from '../../../types.js'
|
|
4
|
-
import {
|
|
4
|
+
import { isPermit2AllowanceLane } from '../../../utils/getTypedDataLane.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Determines the execution strategy: 'relayed', 'batched', or 'standard'.
|
|
8
8
|
* Falls back to 'standard' when EIP-5792 batching is unavailable,
|
|
9
9
|
* the wallet rejected the 7702 upgrade, or the tool doesn't support it.
|
|
10
|
+
*
|
|
11
|
+
* `afterPrepare` marks the single call from `EthereumPrepareTransactionTask`.
|
|
12
|
+
* The step has just been re-quoted, so the cached verdict is stale and, for the
|
|
13
|
+
* first time, the absence of a `transactionRequest` is final rather than merely
|
|
14
|
+
* not-yet-known. Both effects come from that one fact, which is why they share
|
|
15
|
+
* a parameter.
|
|
10
16
|
*/
|
|
11
17
|
export async function getEthereumExecutionStrategy(
|
|
12
18
|
context: EthereumStepExecutorContext,
|
|
13
|
-
|
|
19
|
+
afterPrepare: boolean = false
|
|
14
20
|
): Promise<TransactionMethodType> {
|
|
15
21
|
const {
|
|
16
22
|
step,
|
|
@@ -22,13 +28,33 @@ export async function getEthereumExecutionStrategy(
|
|
|
22
28
|
executionStrategy: executionStrategyContext,
|
|
23
29
|
} = context
|
|
24
30
|
|
|
25
|
-
if (!
|
|
31
|
+
if (!afterPrepare && executionStrategyContext) {
|
|
26
32
|
return executionStrategyContext
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
const atomicityNotReady = !!retryParams?.atomicityNotReady
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
// Declared by the backend. It is the only signal that reaches the allowance
|
|
37
|
+
// tasks, which run before a `transactionRequest` can exist.
|
|
38
|
+
if (step.executionType === 'message') {
|
|
39
|
+
return 'relayed'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Typed data the user does not sign for its own send: gasless, `Order`,
|
|
43
|
+
// Hyperliquid. A Permit2 allowance is the one shape excluded, because its signer
|
|
44
|
+
// and its sender are the same person.
|
|
45
|
+
if (step.typedData?.length && !isPermit2AllowanceLane(step, fromChain)) {
|
|
46
|
+
return 'relayed'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// After prepare, missing means never: the step carries typed data and the user
|
|
50
|
+
// has nothing to send, so the relayer is the only lane that can execute it.
|
|
51
|
+
// This is a derivation, not a guess — no other strategy can run such a step.
|
|
52
|
+
//
|
|
53
|
+
// Before prepare the same expression is unsound. A Permit2 allowance that will
|
|
54
|
+
// receive its transaction from `/stepTransaction` is indistinguishable from
|
|
55
|
+
// one that never will, and calling it relayed there costs the step its
|
|
56
|
+
// EIP-5792 batching.
|
|
57
|
+
if (afterPrepare && step.typedData?.length && !step.transactionRequest) {
|
|
32
58
|
return 'relayed'
|
|
33
59
|
}
|
|
34
60
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
convertQuoteToRoute,
|
|
3
3
|
type ExecutionOptions,
|
|
4
|
+
type ExtendedChain,
|
|
4
5
|
getContractCallsQuote,
|
|
5
6
|
getRelayerQuote,
|
|
6
7
|
getStepTransaction,
|
|
@@ -14,18 +15,22 @@ import {
|
|
|
14
15
|
import { PatcherMagicNumber } from '../../../permits/constants.js'
|
|
15
16
|
import { isContractCallStep } from '../../../utils/isContractCallStep.js'
|
|
16
17
|
import { isGaslessStep } from '../../../utils/isGaslessStep.js'
|
|
17
|
-
import { isRelayerStep } from '../../../utils/isRelayerStep.js'
|
|
18
18
|
|
|
19
|
+
/** Re-quotes the step through the endpoint that matches how it will execute. */
|
|
19
20
|
export const getUpdatedStep = async (
|
|
20
21
|
client: SDKClient,
|
|
21
22
|
step: LiFiStepExtended,
|
|
23
|
+
fromChain: ExtendedChain,
|
|
22
24
|
executionOptions?: ExecutionOptions,
|
|
23
25
|
signedTypedData?: SignedTypedData[]
|
|
24
26
|
): Promise<LiFiStepExtended> => {
|
|
25
27
|
if (isContractCallStep(step)) {
|
|
26
28
|
return getContractCallUpdatedStep(client, step, executionOptions)
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
// Do NOT substitute `hasRelayerMessage` for `isGaslessStep`: an `Order` retry
|
|
31
|
+
// would fetch a relayer quote instead of `/advanced/stepTransaction`. Pinned
|
|
32
|
+
// by `re-quotes an Order step ...` in `getUpdatedStep.unit.spec.ts`.
|
|
33
|
+
if (isGaslessStep(step, fromChain)) {
|
|
29
34
|
return getRelayerUpdatedStep(client, step)
|
|
30
35
|
}
|
|
31
36
|
return getStandardUpdatedStep(client, step, signedTypedData)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { EthereumStepExecutorContext } from '../../../types.js'
|
|
2
|
+
import {
|
|
3
|
+
getTypedDataLane,
|
|
4
|
+
hasPermit2Allowance,
|
|
5
|
+
hasRelayerMessage,
|
|
6
|
+
} from '../../../utils/getTypedDataLane.js'
|
|
7
|
+
|
|
8
|
+
/** Whether this execution carries a caller-supplied Permit2 allowance, declared or signed. */
|
|
9
|
+
export function hasPermit2AllowanceInFlight(
|
|
10
|
+
context: EthereumStepExecutorContext
|
|
11
|
+
): boolean {
|
|
12
|
+
const { step, fromChain, signedTypedData } = context
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
hasPermit2Allowance(step, fromChain) ||
|
|
16
|
+
signedTypedData.some(
|
|
17
|
+
(typedData) =>
|
|
18
|
+
getTypedDataLane(typedData, fromChain) === 'permit2-allowance'
|
|
19
|
+
)
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** `isPermit2AllowanceLane`, for gates that run after prepare may have replaced `step.typedData`. */
|
|
24
|
+
export function isPermit2AllowanceLaneInFlight(
|
|
25
|
+
context: EthereumStepExecutorContext
|
|
26
|
+
): boolean {
|
|
27
|
+
return (
|
|
28
|
+
hasPermit2AllowanceInFlight(context) &&
|
|
29
|
+
!hasRelayerMessage(context.step, context.fromChain)
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { SignedTypedData, TypedData } from '@lifi/sdk'
|
|
2
|
+
import { isValidSignature } from '../../../utils/isValidSignature.js'
|
|
3
|
+
|
|
4
|
+
/** Whether `signedTypedData` already holds a signature for this exact entry. */
|
|
5
|
+
export function isTypedDataAlreadySigned(
|
|
6
|
+
signedTypedData: SignedTypedData[],
|
|
7
|
+
typedData: TypedData
|
|
8
|
+
): boolean {
|
|
9
|
+
// `Permit` stays with `isNativePermitValid`, which also checks the deadline,
|
|
10
|
+
// the amount and the salt. Equality alone would drop those checks.
|
|
11
|
+
if (typedData.primaryType === 'Permit') {
|
|
12
|
+
return false
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return signedTypedData.some(
|
|
16
|
+
(signed) =>
|
|
17
|
+
signed.primaryType === typedData.primaryType &&
|
|
18
|
+
isValidSignature(signed.signature) &&
|
|
19
|
+
isSameValue(signed.domain, typedData.domain) &&
|
|
20
|
+
isSameValue(signed.message, typedData.message)
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* `domain` and `message` are decoded JSON, so compare them structurally: a
|
|
26
|
+
* round trip through the API rebuilds the objects, and `JSON.stringify` both
|
|
27
|
+
* depends on key order and throws on a `bigint`. Scalars compare by string
|
|
28
|
+
* form, because `1`, `1n` and `'1'` are one EIP-712 value.
|
|
29
|
+
*/
|
|
30
|
+
function isSameValue(a: unknown, b: unknown): boolean {
|
|
31
|
+
if (a === b) {
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
35
|
+
return (
|
|
36
|
+
Array.isArray(a) &&
|
|
37
|
+
Array.isArray(b) &&
|
|
38
|
+
a.length === b.length &&
|
|
39
|
+
a.every((item, index) => isSameValue(item, b[index]))
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
if (isRecord(a) && isRecord(b)) {
|
|
43
|
+
const keys = Object.keys(a)
|
|
44
|
+
return (
|
|
45
|
+
keys.length === Object.keys(b).length &&
|
|
46
|
+
keys.every((key) => key in b && isSameValue(a[key], b[key]))
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
if (a == null || b == null) {
|
|
50
|
+
return false
|
|
51
|
+
}
|
|
52
|
+
return String(a) === String(b)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
56
|
+
typeof value === 'object' && value !== null
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtendedChain,
|
|
3
|
+
LiFiStep,
|
|
4
|
+
LiFiStepExtended,
|
|
5
|
+
TypedData,
|
|
6
|
+
} from '@lifi/sdk'
|
|
7
|
+
import {
|
|
8
|
+
getTypedDataInLane,
|
|
9
|
+
getTypedDataLane,
|
|
10
|
+
isPermit2AllowanceLane,
|
|
11
|
+
} from '../../../utils/getTypedDataLane.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `??` keeps the Permit2 allowance only when the answer omits `typedData`. An
|
|
15
|
+
* answer that carries entries of its own — native permits, or `[]` from a
|
|
16
|
+
* third-party backend — would drop it, and `signedTypedData` resets per
|
|
17
|
+
* `executeStep`, so a retry would let the Permit2 proxy hijack the calldata.
|
|
18
|
+
*/
|
|
19
|
+
export function preservePermit2Allowances(
|
|
20
|
+
step: LiFiStepExtended | LiFiStep,
|
|
21
|
+
updatedTypedData: TypedData[] | undefined,
|
|
22
|
+
chain: ExtendedChain
|
|
23
|
+
): TypedData[] | undefined {
|
|
24
|
+
if (!updatedTypedData) {
|
|
25
|
+
return step.typedData
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!isPermit2AllowanceLane(step, chain)) {
|
|
29
|
+
return updatedTypedData
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const answerDeclaresLane = updatedTypedData.some((typedData) => {
|
|
33
|
+
const lane = getTypedDataLane(typedData, chain)
|
|
34
|
+
return lane === 'permit2-allowance' || lane === 'relayer-message'
|
|
35
|
+
})
|
|
36
|
+
if (answerDeclaresLane) {
|
|
37
|
+
return updatedTypedData
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return [
|
|
41
|
+
...updatedTypedData,
|
|
42
|
+
...getTypedDataInLane(step, 'permit2-allowance', chain),
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { TransactionMethodType } from '@lifi/sdk'
|
|
|
2
2
|
import type { Address } from 'viem'
|
|
3
3
|
import { canAccountUsePermit2 } from '../../../permits/canAccountUsePermit2.js'
|
|
4
4
|
import type { EthereumStepExecutorContext } from '../../../types.js'
|
|
5
|
+
import { isPermit2AllowanceLaneInFlight } from './hasPermit2AllowanceInFlight.js'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Cheap, synchronous part of the gate: does the step/chain combination allow
|
|
@@ -22,7 +23,8 @@ const isPermit2SupportedForStep = (
|
|
|
22
23
|
// Approval address is not required for Permit2 per se, but we use it to skip allowance checks for direct transfers
|
|
23
24
|
!!step.estimate.approvalAddress &&
|
|
24
25
|
!step.estimate.skipApproval &&
|
|
25
|
-
!step.estimate.skipPermit
|
|
26
|
+
!step.estimate.skipPermit &&
|
|
27
|
+
!isPermit2AllowanceLaneInFlight(context)
|
|
26
28
|
)
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -13,7 +13,7 @@ import { assertValidSignature } from '../../../utils/isValidSignature.js'
|
|
|
13
13
|
|
|
14
14
|
export const signHyperliquidTypedData = async (
|
|
15
15
|
context: EthereumStepExecutorContext,
|
|
16
|
-
|
|
16
|
+
allowanceTypedData: TypedData[]
|
|
17
17
|
): Promise<SignedTypedData[] | undefined> => {
|
|
18
18
|
const {
|
|
19
19
|
step,
|
|
@@ -33,7 +33,7 @@ export const signHyperliquidTypedData = async (
|
|
|
33
33
|
const ownerAddress = ethereumClient.account!.address
|
|
34
34
|
const storage = getStorage(client)
|
|
35
35
|
|
|
36
|
-
const approveMessage =
|
|
36
|
+
const approveMessage = allowanceTypedData.find(isApproveAgentMessage)
|
|
37
37
|
const existingAgentAddress = approveMessage?.message.agentAddress as
|
|
38
38
|
| string
|
|
39
39
|
| undefined
|
|
@@ -44,7 +44,7 @@ export const signHyperliquidTypedData = async (
|
|
|
44
44
|
expiresAt,
|
|
45
45
|
} = await getOrCreateAgentWallet(storage, ownerAddress, existingAgentAddress)
|
|
46
46
|
|
|
47
|
-
for (const typedData of
|
|
47
|
+
for (const typedData of allowanceTypedData) {
|
|
48
48
|
if (isApproveAgentMessage(typedData)) {
|
|
49
49
|
if (!needsApproval) {
|
|
50
50
|
continue
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExecutionActionStatus,
|
|
3
|
+
ExecutionActionType,
|
|
4
|
+
SignedTypedData,
|
|
5
|
+
TypedData,
|
|
6
|
+
} from '@lifi/sdk'
|
|
7
|
+
import { signTypedData } from 'viem/actions'
|
|
8
|
+
import { getAction } from 'viem/utils'
|
|
9
|
+
import type { EthereumStepExecutorContext } from '../../../types.js'
|
|
10
|
+
import { getDomainChainId } from '../../../utils/getDomainChainId.js'
|
|
11
|
+
import { assertValidSignature } from '../../../utils/isValidSignature.js'
|
|
12
|
+
|
|
13
|
+
export type SignTypedDataEntriesResult =
|
|
14
|
+
| { status: 'PAUSED' }
|
|
15
|
+
| { status: 'COMPLETED'; signedTypedData: SignedTypedData[] }
|
|
16
|
+
|
|
17
|
+
/** Signs the entries in order, switching chains per entry, and appends the signatures. */
|
|
18
|
+
export async function signTypedDataEntries(
|
|
19
|
+
context: EthereumStepExecutorContext,
|
|
20
|
+
entries: TypedData[],
|
|
21
|
+
actionType: ExecutionActionType,
|
|
22
|
+
actionStatus: ExecutionActionStatus = 'ACTION_REQUIRED'
|
|
23
|
+
): Promise<SignTypedDataEntriesResult> {
|
|
24
|
+
const {
|
|
25
|
+
step,
|
|
26
|
+
statusManager,
|
|
27
|
+
allowUserInteraction,
|
|
28
|
+
checkClient,
|
|
29
|
+
signedTypedData: currentSignedTypedData,
|
|
30
|
+
} = context
|
|
31
|
+
|
|
32
|
+
const signedTypedData = [...currentSignedTypedData]
|
|
33
|
+
|
|
34
|
+
// Announced once for the round, not once per entry. Relay-from-Hyperliquid
|
|
35
|
+
// carries two messages, and main told the consumer `MESSAGE_REQUIRED` once.
|
|
36
|
+
if (entries.length) {
|
|
37
|
+
statusManager.updateAction(step, actionType, actionStatus)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
for (const typedData of entries) {
|
|
41
|
+
if (!allowUserInteraction) {
|
|
42
|
+
return { status: 'PAUSED' }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const typedDataChainId =
|
|
46
|
+
getDomainChainId(typedData.domain) || step.action.fromChainId
|
|
47
|
+
|
|
48
|
+
const client = await checkClient(step, typedDataChainId)
|
|
49
|
+
if (!client) {
|
|
50
|
+
return { status: 'PAUSED' }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const signature = await getAction(
|
|
54
|
+
client,
|
|
55
|
+
signTypedData,
|
|
56
|
+
'signTypedData'
|
|
57
|
+
)({
|
|
58
|
+
account: client.account!,
|
|
59
|
+
domain: typedData.domain,
|
|
60
|
+
types: typedData.types,
|
|
61
|
+
primaryType: typedData.primaryType,
|
|
62
|
+
message: typedData.message,
|
|
63
|
+
})
|
|
64
|
+
assertValidSignature(signature)
|
|
65
|
+
|
|
66
|
+
signedTypedData.push({ ...typedData, signature })
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return { status: 'COMPLETED', signedTypedData }
|
|
70
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -28,5 +28,4 @@ export { convertExtendedChain } from './utils/convertExtendedChain.js'
|
|
|
28
28
|
export { isContractCallStep } from './utils/isContractCallStep.js'
|
|
29
29
|
export { isExtendedChain } from './utils/isExtendedChain.js'
|
|
30
30
|
export { isGaslessStep } from './utils/isGaslessStep.js'
|
|
31
|
-
export { isRelayerStep } from './utils/isRelayerStep.js'
|
|
32
31
|
export { isZeroAddress } from './utils/isZeroAddress.js'
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtendedChain,
|
|
3
|
+
LiFiStep,
|
|
4
|
+
LiFiStepExtended,
|
|
5
|
+
TypedData,
|
|
6
|
+
} from '@lifi/sdk'
|
|
7
|
+
import { isGaslessTypedData } from './isGaslessStep.js'
|
|
8
|
+
|
|
9
|
+
/** Which execution lane one `step.typedData` entry belongs to. */
|
|
10
|
+
export type TypedDataLane =
|
|
11
|
+
| 'native-permit'
|
|
12
|
+
| 'permit2-allowance'
|
|
13
|
+
| 'relayer-message'
|
|
14
|
+
|
|
15
|
+
// `chain` is required, and nothing else enforces it: `chain?` compiles and
|
|
16
|
+
// every test still passes, but a relayer message then classifies as
|
|
17
|
+
// `permit2-allowance` and gets signed inline. Do NOT relax it.
|
|
18
|
+
export function getTypedDataLane(
|
|
19
|
+
typedData: TypedData,
|
|
20
|
+
chain: ExtendedChain
|
|
21
|
+
): TypedDataLane {
|
|
22
|
+
// A native `Permit` is classified BEFORE the gasless rule: LI.FI's relayer
|
|
23
|
+
// signs a permit whose spender is `chain.permit2`, and calling that a relayer
|
|
24
|
+
// message makes a gasless step ask the user to fund an approval.
|
|
25
|
+
if (typedData.primaryType === 'Permit') {
|
|
26
|
+
return 'native-permit'
|
|
27
|
+
}
|
|
28
|
+
if (isGaslessTypedData(typedData, chain)) {
|
|
29
|
+
return 'relayer-message'
|
|
30
|
+
}
|
|
31
|
+
if (typedData.primaryType === 'PermitSingle') {
|
|
32
|
+
return 'permit2-allowance'
|
|
33
|
+
}
|
|
34
|
+
return 'relayer-message'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Whether the step carries a Permit2 allowance the SDK signs for a caller's own spender. */
|
|
38
|
+
export function hasPermit2Allowance(
|
|
39
|
+
step: LiFiStepExtended | LiFiStep,
|
|
40
|
+
chain: ExtendedChain
|
|
41
|
+
): boolean {
|
|
42
|
+
return !!step.typedData?.some(
|
|
43
|
+
(typedData) => getTypedDataLane(typedData, chain) === 'permit2-allowance'
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The step's typed-data entries that belong to `lane`. */
|
|
48
|
+
export function getTypedDataInLane(
|
|
49
|
+
step: LiFiStepExtended | LiFiStep,
|
|
50
|
+
lane: TypedDataLane,
|
|
51
|
+
chain: ExtendedChain
|
|
52
|
+
): TypedData[] {
|
|
53
|
+
return (
|
|
54
|
+
step.typedData?.filter(
|
|
55
|
+
(typedData) => getTypedDataLane(typedData, chain) === lane
|
|
56
|
+
) ?? []
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Whether the step still carries typed data a relayer must sign and submit. */
|
|
61
|
+
export function hasRelayerMessage(
|
|
62
|
+
step: LiFiStepExtended | LiFiStep,
|
|
63
|
+
chain: ExtendedChain
|
|
64
|
+
): boolean {
|
|
65
|
+
return !!step.typedData?.some(
|
|
66
|
+
(typedData) => getTypedDataLane(typedData, chain) === 'relayer-message'
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Whether the step carries a Permit2 allowance and nothing a relayer must sign. */
|
|
71
|
+
export function isPermit2AllowanceLane(
|
|
72
|
+
step: LiFiStepExtended | LiFiStep,
|
|
73
|
+
chain: ExtendedChain
|
|
74
|
+
): boolean {
|
|
75
|
+
return hasPermit2Allowance(step, chain) && !hasRelayerMessage(step, chain)
|
|
76
|
+
}
|