@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
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertQuoteToRoute,
|
|
3
|
+
type ExecutionOptions,
|
|
4
|
+
getContractCallsQuote,
|
|
5
|
+
getRelayerQuote,
|
|
6
|
+
getStepTransaction,
|
|
7
|
+
LiFiErrorCode,
|
|
8
|
+
type LiFiStepExtended,
|
|
9
|
+
patchContractCalls,
|
|
10
|
+
type SDKClient,
|
|
11
|
+
type SignedTypedData,
|
|
12
|
+
TransactionError,
|
|
13
|
+
} from '@lifi/sdk'
|
|
14
|
+
import { PatcherMagicNumber } from '../../../permits/constants.js'
|
|
15
|
+
import { isContractCallStep } from '../../../utils/isContractCallStep.js'
|
|
16
|
+
import { isGaslessStep } from '../../../utils/isGaslessStep.js'
|
|
17
|
+
import { isRelayerStep } from '../../../utils/isRelayerStep.js'
|
|
18
|
+
|
|
19
|
+
export const getUpdatedStep = async (
|
|
20
|
+
client: SDKClient,
|
|
21
|
+
step: LiFiStepExtended,
|
|
22
|
+
executionOptions?: ExecutionOptions,
|
|
23
|
+
signedTypedData?: SignedTypedData[]
|
|
24
|
+
): Promise<LiFiStepExtended> => {
|
|
25
|
+
if (isContractCallStep(step)) {
|
|
26
|
+
return getContractCallUpdatedStep(client, step, executionOptions)
|
|
27
|
+
}
|
|
28
|
+
if (isRelayerStep(step) && isGaslessStep(step)) {
|
|
29
|
+
return getRelayerUpdatedStep(client, step)
|
|
30
|
+
}
|
|
31
|
+
return getStandardUpdatedStep(client, step, signedTypedData)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const getContractCallUpdatedStep = async (
|
|
35
|
+
client: SDKClient,
|
|
36
|
+
step: LiFiStepExtended,
|
|
37
|
+
executionOptions?: ExecutionOptions
|
|
38
|
+
): Promise<LiFiStepExtended> => {
|
|
39
|
+
const contractCallsResult = await executionOptions?.getContractCalls?.({
|
|
40
|
+
fromAddress: step.action.fromAddress!,
|
|
41
|
+
fromAmount: BigInt(step.action.fromAmount),
|
|
42
|
+
fromChainId: step.action.fromChainId,
|
|
43
|
+
fromTokenAddress: step.action.fromToken.address,
|
|
44
|
+
slippage: step.action.slippage,
|
|
45
|
+
toAddress: step.action.toAddress,
|
|
46
|
+
toAmount: BigInt(step.estimate.toAmount),
|
|
47
|
+
toChainId: step.action.toChainId,
|
|
48
|
+
toTokenAddress: step.action.toToken.address,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
if (!contractCallsResult?.contractCalls?.length) {
|
|
52
|
+
throw new TransactionError(
|
|
53
|
+
LiFiErrorCode.TransactionUnprepared,
|
|
54
|
+
'Unable to prepare transaction. Contract calls are not found.'
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (contractCallsResult.patcher) {
|
|
59
|
+
const patchedContractCalls = await patchContractCalls(
|
|
60
|
+
client,
|
|
61
|
+
contractCallsResult.contractCalls.map((call) => ({
|
|
62
|
+
chainId: step.action.toChainId,
|
|
63
|
+
fromTokenAddress: call.fromTokenAddress,
|
|
64
|
+
targetContractAddress: call.toContractAddress,
|
|
65
|
+
callDataToPatch: call.toContractCallData,
|
|
66
|
+
delegateCall: false,
|
|
67
|
+
patches: [
|
|
68
|
+
{
|
|
69
|
+
amountToReplace: PatcherMagicNumber.toString(),
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
}))
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
contractCallsResult.contractCalls.forEach((call, index) => {
|
|
76
|
+
call.toContractAddress = patchedContractCalls[index].target
|
|
77
|
+
call.toContractCallData = patchedContractCalls[index].callData
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Limitations of the retry logic for contract calls:
|
|
83
|
+
* - denyBridges and denyExchanges are not supported
|
|
84
|
+
* - allowBridges and allowExchanges are not supported
|
|
85
|
+
* - fee is not supported
|
|
86
|
+
* - toAmount is not supported
|
|
87
|
+
*/
|
|
88
|
+
const contractCallQuote = await getContractCallsQuote(client, {
|
|
89
|
+
fromAddress: step.action.fromAddress!,
|
|
90
|
+
fromChain: step.action.fromChainId,
|
|
91
|
+
fromToken: step.action.fromToken.address,
|
|
92
|
+
fromAmount: step.action.fromAmount,
|
|
93
|
+
toChain: step.action.toChainId,
|
|
94
|
+
toToken: step.action.toToken.address,
|
|
95
|
+
contractCalls: contractCallsResult.contractCalls,
|
|
96
|
+
toFallbackAddress: step.action.toAddress,
|
|
97
|
+
slippage: step.action.slippage,
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
contractCallQuote.action.toToken = step.action.toToken
|
|
101
|
+
|
|
102
|
+
const customStep = contractCallQuote.includedSteps?.find(
|
|
103
|
+
(s) => s.type === 'custom'
|
|
104
|
+
)
|
|
105
|
+
if (customStep && contractCallsResult?.contractTool) {
|
|
106
|
+
const toolDetails = {
|
|
107
|
+
key: contractCallsResult.contractTool.name,
|
|
108
|
+
name: contractCallsResult.contractTool.name,
|
|
109
|
+
logoURI: contractCallsResult.contractTool.logoURI,
|
|
110
|
+
}
|
|
111
|
+
customStep.toolDetails = toolDetails
|
|
112
|
+
contractCallQuote.toolDetails = toolDetails
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const route = convertQuoteToRoute(contractCallQuote, {
|
|
116
|
+
adjustZeroOutputFromPreviousStep:
|
|
117
|
+
executionOptions?.adjustZeroOutputFromPreviousStep,
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
...route.steps[0],
|
|
122
|
+
id: step.id,
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const getRelayerUpdatedStep = async (
|
|
127
|
+
client: SDKClient,
|
|
128
|
+
step: LiFiStepExtended
|
|
129
|
+
): Promise<LiFiStepExtended> => {
|
|
130
|
+
const updatedRelayedStep = await getRelayerQuote(client, {
|
|
131
|
+
fromChain: step.action.fromChainId,
|
|
132
|
+
fromToken: step.action.fromToken.address,
|
|
133
|
+
fromAddress: step.action.fromAddress!,
|
|
134
|
+
fromAmount: step.action.fromAmount,
|
|
135
|
+
toChain: step.action.toChainId,
|
|
136
|
+
toToken: step.action.toToken.address,
|
|
137
|
+
slippage: step.action.slippage,
|
|
138
|
+
toAddress: step.action.toAddress,
|
|
139
|
+
allowBridges: [step.tool],
|
|
140
|
+
})
|
|
141
|
+
return {
|
|
142
|
+
...updatedRelayedStep,
|
|
143
|
+
id: step.id,
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const getStandardUpdatedStep = async (
|
|
148
|
+
client: SDKClient,
|
|
149
|
+
step: LiFiStepExtended,
|
|
150
|
+
signedTypedData?: SignedTypedData[]
|
|
151
|
+
): Promise<LiFiStepExtended> => {
|
|
152
|
+
const filteredSignedTypedData = signedTypedData?.filter(
|
|
153
|
+
(item) => item.signature
|
|
154
|
+
)
|
|
155
|
+
const { typedData: _, ...restStep } = step
|
|
156
|
+
const params = filteredSignedTypedData?.length
|
|
157
|
+
? { ...restStep, typedData: filteredSignedTypedData }
|
|
158
|
+
: restStep
|
|
159
|
+
return getStepTransaction(client, params)
|
|
160
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtendedChain,
|
|
3
|
+
LiFiStepExtended,
|
|
4
|
+
TransactionMethodType,
|
|
5
|
+
} from '@lifi/sdk'
|
|
6
|
+
|
|
7
|
+
/* Check if chain has Permit2 contract deployed.
|
|
8
|
+
* Permit2 should not be available for atomic batch.
|
|
9
|
+
*/
|
|
10
|
+
export const isPermit2Supported = (
|
|
11
|
+
step: LiFiStepExtended,
|
|
12
|
+
fromChain: ExtendedChain,
|
|
13
|
+
isFromNativeToken: boolean,
|
|
14
|
+
disableMessageSigning: boolean,
|
|
15
|
+
strategy: TransactionMethodType
|
|
16
|
+
): boolean => {
|
|
17
|
+
return (
|
|
18
|
+
!!fromChain.permit2 &&
|
|
19
|
+
!!fromChain.permit2Proxy &&
|
|
20
|
+
!isFromNativeToken &&
|
|
21
|
+
!disableMessageSigning &&
|
|
22
|
+
strategy !== 'batched' &&
|
|
23
|
+
// Approval address is not required for Permit2 per se, but we use it to skip allowance checks for direct transfers
|
|
24
|
+
!!step.estimate.approvalAddress &&
|
|
25
|
+
!step.estimate.skipApproval &&
|
|
26
|
+
!step.estimate.skipPermit
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LiFiStepExtended, StatusManager } from '@lifi/sdk'
|
|
2
|
+
|
|
3
|
+
export const shouldCheckForAllowance = (
|
|
4
|
+
step: LiFiStepExtended,
|
|
5
|
+
isBridgeExecution: boolean,
|
|
6
|
+
isFromNativeToken: boolean,
|
|
7
|
+
statusManager: StatusManager
|
|
8
|
+
): boolean => {
|
|
9
|
+
const exchangeActionType = isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'
|
|
10
|
+
|
|
11
|
+
const swapOrBridgeAction = statusManager.findAction(step, exchangeActionType)
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
// No existing swap/bridge transaction is pending
|
|
15
|
+
!swapOrBridgeAction?.txHash &&
|
|
16
|
+
// No existing swap/bridge batch/order is pending
|
|
17
|
+
!swapOrBridgeAction?.taskId &&
|
|
18
|
+
// Token is not native (address is not zero)
|
|
19
|
+
!isFromNativeToken &&
|
|
20
|
+
// Approval address is required for allowance checks, but may be null in special cases (e.g. direct transfers)
|
|
21
|
+
!!step.estimate.approvalAddress &&
|
|
22
|
+
!step.estimate.skipApproval
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { SignedTypedData, TypedData } from '@lifi/sdk'
|
|
2
|
+
import { signTypedData } from 'viem/actions'
|
|
3
|
+
import { getAction } from 'viem/utils'
|
|
4
|
+
import { getOrCreateAgentWallet } from '../../../hyperliquid/agentWallet.js'
|
|
5
|
+
import {
|
|
6
|
+
isApproveAgentMessage,
|
|
7
|
+
isApproveBuilderFeeMessage,
|
|
8
|
+
isHyperliquidOrderMessage,
|
|
9
|
+
} from '../../../hyperliquid/isHyperliquidAgentStep.js'
|
|
10
|
+
import type { EthereumStepExecutorContext } from '../../../types.js'
|
|
11
|
+
import { getDomainChainId } from '../../../utils/getDomainChainId.js'
|
|
12
|
+
|
|
13
|
+
export const signHyperliquidTypedData = async (
|
|
14
|
+
context: EthereumStepExecutorContext,
|
|
15
|
+
intentTypedData: TypedData[]
|
|
16
|
+
): Promise<SignedTypedData[] | undefined> => {
|
|
17
|
+
const {
|
|
18
|
+
step,
|
|
19
|
+
fromChain,
|
|
20
|
+
client,
|
|
21
|
+
allowUserInteraction,
|
|
22
|
+
checkClient,
|
|
23
|
+
ethereumClient,
|
|
24
|
+
getStorage,
|
|
25
|
+
} = context
|
|
26
|
+
|
|
27
|
+
if (!allowUserInteraction) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const signedResults: SignedTypedData[] = []
|
|
32
|
+
const ownerAddress = ethereumClient.account!.address
|
|
33
|
+
const storage = getStorage(client)
|
|
34
|
+
|
|
35
|
+
const approveMessage = intentTypedData.find(isApproveAgentMessage)
|
|
36
|
+
const existingAgentAddress = approveMessage?.message.agentAddress as
|
|
37
|
+
| string
|
|
38
|
+
| undefined
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
account: agentAccount,
|
|
42
|
+
needsApproval,
|
|
43
|
+
expiresAt,
|
|
44
|
+
} = await getOrCreateAgentWallet(storage, ownerAddress, existingAgentAddress)
|
|
45
|
+
|
|
46
|
+
for (const typedData of intentTypedData) {
|
|
47
|
+
if (isApproveAgentMessage(typedData)) {
|
|
48
|
+
if (!needsApproval) {
|
|
49
|
+
continue
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const message = {
|
|
53
|
+
...typedData.message,
|
|
54
|
+
agentAddress: agentAccount.address.toLowerCase(),
|
|
55
|
+
agentName: `${typedData.message.agentName} valid_until ${expiresAt}`,
|
|
56
|
+
}
|
|
57
|
+
const typedDataChainId =
|
|
58
|
+
getDomainChainId(typedData.domain) || fromChain.id
|
|
59
|
+
|
|
60
|
+
const updatedClient = await checkClient(step, typedDataChainId)
|
|
61
|
+
if (!updatedClient) {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const signature = await getAction(
|
|
66
|
+
updatedClient,
|
|
67
|
+
signTypedData,
|
|
68
|
+
'signTypedData'
|
|
69
|
+
)({
|
|
70
|
+
account: updatedClient.account!,
|
|
71
|
+
primaryType: typedData.primaryType,
|
|
72
|
+
domain: typedData.domain,
|
|
73
|
+
types: typedData.types,
|
|
74
|
+
message,
|
|
75
|
+
})
|
|
76
|
+
signedResults.push({ ...typedData, message, signature })
|
|
77
|
+
} else if (isApproveBuilderFeeMessage(typedData)) {
|
|
78
|
+
const typedDataChainId =
|
|
79
|
+
getDomainChainId(typedData.domain) || fromChain.id
|
|
80
|
+
|
|
81
|
+
const updatedClient = await checkClient(step, typedDataChainId)
|
|
82
|
+
if (!updatedClient) {
|
|
83
|
+
return
|
|
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
|
+
signedResults.push({ ...typedData, signature })
|
|
98
|
+
} else if (isHyperliquidOrderMessage(typedData)) {
|
|
99
|
+
const signature = await agentAccount.signTypedData({
|
|
100
|
+
domain: typedData.domain,
|
|
101
|
+
types: typedData.types,
|
|
102
|
+
primaryType: typedData.primaryType,
|
|
103
|
+
message: typedData.message,
|
|
104
|
+
})
|
|
105
|
+
signedResults.push({ ...typedData, signature })
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return signedResults
|
|
110
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { LiFiErrorCode, ProviderError } from '@lifi/sdk'
|
|
2
|
+
import type { Client, GetChainIdReturnType } from 'viem'
|
|
3
|
+
import { getChainId } from 'viem/actions'
|
|
4
|
+
import { getAction } from 'viem/utils'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This method checks whether the wallet client is configured for the correct chain.
|
|
8
|
+
* If yes it returns the wallet clien.
|
|
9
|
+
* If no and if user interaction is allowed it triggers the switchChain callback. If no user interaction is allowed it aborts.
|
|
10
|
+
*
|
|
11
|
+
* Account Type: local -
|
|
12
|
+
* We need to create and return a new connector client from the switchChain callback in order to continue execution on a new chain.
|
|
13
|
+
*
|
|
14
|
+
* Account Type: json-rpc -
|
|
15
|
+
* We can switch chain and return existing connector client from the switchChain callback in order to continue execution on a new chain.
|
|
16
|
+
* @param client The client to switch the chain for
|
|
17
|
+
* @param targetChainId The target chain id to switch to
|
|
18
|
+
* @param allowUserInteraction Whether user interaction is allowed
|
|
19
|
+
* @param switchChainCallback The callback to switch the chain
|
|
20
|
+
* @returns New connector client
|
|
21
|
+
*/
|
|
22
|
+
export const switchChain = async (
|
|
23
|
+
client: Client,
|
|
24
|
+
targetChainId: number,
|
|
25
|
+
allowUserInteraction: boolean,
|
|
26
|
+
switchChainCallback?: (chainId: number) => Promise<Client | undefined>
|
|
27
|
+
): Promise<Client | undefined> => {
|
|
28
|
+
// if we are already on the correct chain we can proceed directly
|
|
29
|
+
const currentChainId = (await getAction(
|
|
30
|
+
client,
|
|
31
|
+
getChainId,
|
|
32
|
+
'getChainId'
|
|
33
|
+
)(undefined)) as GetChainIdReturnType
|
|
34
|
+
if (currentChainId === targetChainId) {
|
|
35
|
+
return client
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!allowUserInteraction) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
if (!switchChainCallback) {
|
|
42
|
+
throw new ProviderError(
|
|
43
|
+
LiFiErrorCode.ChainSwitchError,
|
|
44
|
+
'Chain switch hook is not provided.'
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
const updatedClient = await switchChainCallback(targetChainId)
|
|
48
|
+
let updatedChainId: number | undefined
|
|
49
|
+
if (updatedClient) {
|
|
50
|
+
updatedChainId = (await getAction(
|
|
51
|
+
updatedClient,
|
|
52
|
+
getChainId,
|
|
53
|
+
'getChainId'
|
|
54
|
+
)(undefined)) as GetChainIdReturnType
|
|
55
|
+
}
|
|
56
|
+
if (updatedChainId !== targetChainId) {
|
|
57
|
+
throw new ProviderError(
|
|
58
|
+
LiFiErrorCode.ChainSwitchError,
|
|
59
|
+
'Chain switch required.'
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return updatedClient
|
|
64
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExecutionAction,
|
|
3
|
+
ExtendedChain,
|
|
4
|
+
LiFiStepExtended,
|
|
5
|
+
StatusManager,
|
|
6
|
+
} from '@lifi/sdk'
|
|
7
|
+
import type { TransactionReceipt } from 'viem'
|
|
8
|
+
import { isHex } from 'viem/utils'
|
|
9
|
+
import type { WalletCallReceipt } from '../../../types.js'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Update action to PENDING with txHash/txLink from a transaction receipt when the receipt hash differs from current action.
|
|
13
|
+
* Returns the updated action or the same action if no update.
|
|
14
|
+
*/
|
|
15
|
+
export function updateActionWithReceipt(
|
|
16
|
+
statusManager: StatusManager,
|
|
17
|
+
step: LiFiStepExtended,
|
|
18
|
+
fromChain: ExtendedChain,
|
|
19
|
+
receipt: TransactionReceipt | WalletCallReceipt | undefined,
|
|
20
|
+
action: ExecutionAction
|
|
21
|
+
): ExecutionAction {
|
|
22
|
+
// Update pending action if the transaction hash from the receipt is different.
|
|
23
|
+
// This might happen if the transaction was replaced or we used taskId instead of txHash.
|
|
24
|
+
if (!receipt?.transactionHash || receipt.transactionHash === action.txHash) {
|
|
25
|
+
return action
|
|
26
|
+
}
|
|
27
|
+
// Validate if transaction hash is a valid hex string that can be used on-chain
|
|
28
|
+
// Some custom integrations may return non-hex identifiers to support custom status tracking
|
|
29
|
+
const txHash = isHex(receipt.transactionHash, { strict: true })
|
|
30
|
+
? receipt.transactionHash
|
|
31
|
+
: undefined
|
|
32
|
+
return statusManager.updateAction(step, action.type, 'PENDING', {
|
|
33
|
+
txHash,
|
|
34
|
+
txLink:
|
|
35
|
+
(receipt as WalletCallReceipt).transactionLink ||
|
|
36
|
+
(txHash
|
|
37
|
+
? `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`
|
|
38
|
+
: undefined),
|
|
39
|
+
})
|
|
40
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseError,
|
|
3
3
|
ErrorMessage,
|
|
4
|
+
ExecuteStepRetryError,
|
|
5
|
+
type ExecuteStepRetryParams,
|
|
4
6
|
type ExecutionAction,
|
|
5
7
|
fetchTxErrorDetails,
|
|
6
8
|
LiFiErrorCode,
|
|
@@ -14,8 +16,20 @@ import { AtomicReadyWalletRejectedUpgradeError } from 'viem'
|
|
|
14
16
|
export const parseEthereumErrors = async (
|
|
15
17
|
e: Error,
|
|
16
18
|
step?: LiFiStep,
|
|
17
|
-
action?: ExecutionAction
|
|
18
|
-
|
|
19
|
+
action?: ExecutionAction,
|
|
20
|
+
retryParams?: ExecuteStepRetryParams
|
|
21
|
+
): Promise<SDKError | ExecuteStepRetryError> => {
|
|
22
|
+
if (
|
|
23
|
+
isAtomicReadyWalletRejectedUpgradeError(e) &&
|
|
24
|
+
!retryParams?.atomicityNotReady
|
|
25
|
+
) {
|
|
26
|
+
return new ExecuteStepRetryError(
|
|
27
|
+
'Wallet rejected 7702 upgrade based on the EIP-5792 capabilities; retry with atomicityNotReady',
|
|
28
|
+
{ atomicityNotReady: true },
|
|
29
|
+
e
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
if (e instanceof SDKError) {
|
|
20
34
|
e.step = e.step ?? step
|
|
21
35
|
e.action = e.action ?? action
|
|
@@ -92,7 +106,7 @@ const handleSpecificErrors = async (
|
|
|
92
106
|
step.action.fromChainId
|
|
93
107
|
)
|
|
94
108
|
|
|
95
|
-
const errorMessage = response?.error_message
|
|
109
|
+
const errorMessage = (response as Record<string, string>)?.error_message
|
|
96
110
|
|
|
97
111
|
if (errorMessage?.toLowerCase().includes('out of gas')) {
|
|
98
112
|
return new TransactionError(
|
|
@@ -110,7 +124,7 @@ const handleSpecificErrors = async (
|
|
|
110
124
|
return new UnknownError(e.message || ErrorMessage.UnknownError, e)
|
|
111
125
|
}
|
|
112
126
|
|
|
113
|
-
export const isAtomicReadyWalletRejectedUpgradeError = (e: any) => {
|
|
127
|
+
export const isAtomicReadyWalletRejectedUpgradeError = (e: any): boolean => {
|
|
114
128
|
if (e.cause?.code === AtomicReadyWalletRejectedUpgradeError.code) {
|
|
115
129
|
return true
|
|
116
130
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { SDKStorage } from '@lifi/sdk'
|
|
2
|
+
import type { Hex, LocalAccount } from 'viem'
|
|
3
|
+
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
|
|
4
|
+
|
|
5
|
+
const DEFAULT_STORAGE_KEY_PREFIX = 'li.fi-sdk:hyperliquid:agent'
|
|
6
|
+
const DEFAULT_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1000 // 1 week
|
|
7
|
+
const EXPIRATION_BUFFER_MS = 60 * 60 * 1000 // 1 hour
|
|
8
|
+
|
|
9
|
+
// Private keys are encrypted with AES-GCM using a key derived (PBKDF2) from
|
|
10
|
+
// the owner's wallet address. This is obfuscation -- the wallet address is
|
|
11
|
+
// public, so anyone who knows the scheme can derive the same key. It prevents
|
|
12
|
+
// raw key exposure in storage but does not defend against a targeted attack.
|
|
13
|
+
const ENCRYPTION_SALT = 'li.fi-sdk:agent-wallet-encryption'
|
|
14
|
+
|
|
15
|
+
interface StoredAgentWallet {
|
|
16
|
+
address: string
|
|
17
|
+
pkey: string
|
|
18
|
+
expiresAt: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AgentWalletResult {
|
|
22
|
+
account: LocalAccount
|
|
23
|
+
needsApproval: boolean
|
|
24
|
+
expiresAt: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getStorageKey(
|
|
28
|
+
ownerAddress: string,
|
|
29
|
+
keyPrefix = DEFAULT_STORAGE_KEY_PREFIX
|
|
30
|
+
): string {
|
|
31
|
+
return `${keyPrefix}:${ownerAddress.toLowerCase()}`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const encoder = new TextEncoder()
|
|
35
|
+
const decoder = new TextDecoder()
|
|
36
|
+
|
|
37
|
+
async function deriveKey(ownerAddress: string): Promise<CryptoKey> {
|
|
38
|
+
const keyMaterial = await crypto.subtle.importKey(
|
|
39
|
+
'raw',
|
|
40
|
+
encoder.encode(ownerAddress.toLowerCase()),
|
|
41
|
+
'PBKDF2',
|
|
42
|
+
false,
|
|
43
|
+
['deriveKey']
|
|
44
|
+
)
|
|
45
|
+
return crypto.subtle.deriveKey(
|
|
46
|
+
{
|
|
47
|
+
name: 'PBKDF2',
|
|
48
|
+
salt: encoder.encode(ENCRYPTION_SALT),
|
|
49
|
+
iterations: 100_000,
|
|
50
|
+
hash: 'SHA-256',
|
|
51
|
+
},
|
|
52
|
+
keyMaterial,
|
|
53
|
+
{ name: 'AES-GCM', length: 256 },
|
|
54
|
+
false,
|
|
55
|
+
['encrypt', 'decrypt']
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function encrypt(plaintext: string, key: CryptoKey): Promise<string> {
|
|
60
|
+
const iv = crypto.getRandomValues(new Uint8Array(12))
|
|
61
|
+
const ciphertext = await crypto.subtle.encrypt(
|
|
62
|
+
{ name: 'AES-GCM', iv },
|
|
63
|
+
key,
|
|
64
|
+
encoder.encode(plaintext)
|
|
65
|
+
)
|
|
66
|
+
const combined = new Uint8Array(iv.length + new Uint8Array(ciphertext).length)
|
|
67
|
+
combined.set(iv)
|
|
68
|
+
combined.set(new Uint8Array(ciphertext), iv.length)
|
|
69
|
+
return btoa(String.fromCharCode(...combined))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function decrypt(encoded: string, key: CryptoKey): Promise<string> {
|
|
73
|
+
const combined = Uint8Array.from(atob(encoded), (c) => c.charCodeAt(0))
|
|
74
|
+
const iv = combined.slice(0, 12)
|
|
75
|
+
const ciphertext = combined.slice(12)
|
|
76
|
+
const plaintext = await crypto.subtle.decrypt(
|
|
77
|
+
{ name: 'AES-GCM', iv },
|
|
78
|
+
key,
|
|
79
|
+
ciphertext
|
|
80
|
+
)
|
|
81
|
+
return decoder.decode(plaintext)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function saveAgentWallet(
|
|
85
|
+
storage: SDKStorage,
|
|
86
|
+
ownerAddress: string,
|
|
87
|
+
accountAddress: string,
|
|
88
|
+
privateKey: Hex,
|
|
89
|
+
keyPrefix?: string
|
|
90
|
+
): Promise<void> {
|
|
91
|
+
const encryptionKey = await deriveKey(ownerAddress)
|
|
92
|
+
const data: StoredAgentWallet = {
|
|
93
|
+
address: accountAddress,
|
|
94
|
+
pkey: await encrypt(privateKey, encryptionKey),
|
|
95
|
+
expiresAt: Date.now() + DEFAULT_EXPIRATION_MS,
|
|
96
|
+
}
|
|
97
|
+
await storage.set(
|
|
98
|
+
getStorageKey(ownerAddress, keyPrefix),
|
|
99
|
+
JSON.stringify(data)
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function loadAgentWallet(
|
|
104
|
+
storage: SDKStorage,
|
|
105
|
+
ownerAddress: string,
|
|
106
|
+
keyPrefix?: string
|
|
107
|
+
): Promise<{ account: LocalAccount; expiresAt: number } | null> {
|
|
108
|
+
const raw = await storage.get(getStorageKey(ownerAddress, keyPrefix))
|
|
109
|
+
if (!raw) {
|
|
110
|
+
return null
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const data: StoredAgentWallet = JSON.parse(raw)
|
|
114
|
+
const encryptionKey = await deriveKey(ownerAddress)
|
|
115
|
+
const privateKey = (await decrypt(data.pkey, encryptionKey)) as Hex
|
|
116
|
+
return {
|
|
117
|
+
account: privateKeyToAccount(privateKey),
|
|
118
|
+
expiresAt: data.expiresAt,
|
|
119
|
+
}
|
|
120
|
+
} catch {
|
|
121
|
+
return null
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function getOrCreateAgentWallet(
|
|
126
|
+
storage: SDKStorage,
|
|
127
|
+
ownerAddress: string,
|
|
128
|
+
existingAgentAddress?: string,
|
|
129
|
+
keyPrefix?: string
|
|
130
|
+
): Promise<AgentWalletResult> {
|
|
131
|
+
if (existingAgentAddress) {
|
|
132
|
+
const existing = await loadAgentWallet(storage, ownerAddress, keyPrefix)
|
|
133
|
+
if (
|
|
134
|
+
existing?.account.address.toLowerCase() ===
|
|
135
|
+
existingAgentAddress.toLowerCase() &&
|
|
136
|
+
existing.expiresAt - Date.now() > EXPIRATION_BUFFER_MS
|
|
137
|
+
) {
|
|
138
|
+
return {
|
|
139
|
+
account: existing.account,
|
|
140
|
+
needsApproval: false,
|
|
141
|
+
expiresAt: existing.expiresAt,
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const privateKey = generatePrivateKey()
|
|
147
|
+
const account = privateKeyToAccount(privateKey)
|
|
148
|
+
const expiresAt = Date.now() + DEFAULT_EXPIRATION_MS
|
|
149
|
+
await saveAgentWallet(
|
|
150
|
+
storage,
|
|
151
|
+
ownerAddress,
|
|
152
|
+
account.address,
|
|
153
|
+
privateKey,
|
|
154
|
+
keyPrefix
|
|
155
|
+
)
|
|
156
|
+
return { account, needsApproval: true, expiresAt }
|
|
157
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LiFiStep, LiFiStepExtended, TypedData } from '@lifi/sdk'
|
|
2
|
+
|
|
3
|
+
export function isHyperliquidAgentStep(
|
|
4
|
+
step: LiFiStepExtended | LiFiStep
|
|
5
|
+
): boolean {
|
|
6
|
+
return (
|
|
7
|
+
step.tool === 'hyperliquidSpotProtocol' &&
|
|
8
|
+
!!step.typedData?.some(
|
|
9
|
+
(p) => p.primaryType === 'HyperliquidTransaction:ApproveAgent'
|
|
10
|
+
)
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isApproveAgentMessage(typedData: TypedData): boolean {
|
|
15
|
+
return typedData.primaryType === 'HyperliquidTransaction:ApproveAgent'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function isApproveBuilderFeeMessage(typedData: TypedData): boolean {
|
|
19
|
+
return typedData.primaryType === 'HyperliquidTransaction:ApproveBuilderFee'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function isHyperliquidOrderMessage(typedData: TypedData): boolean {
|
|
23
|
+
return typedData.primaryType === 'Agent' && typedData.message.connectionId
|
|
24
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,10 @@ export {
|
|
|
11
11
|
setTokenAllowance,
|
|
12
12
|
} from './actions/setAllowance.js'
|
|
13
13
|
export { EthereumProvider } from './EthereumProvider.js'
|
|
14
|
+
export {
|
|
15
|
+
isHyperliquidAgentStep,
|
|
16
|
+
isHyperliquidOrderMessage,
|
|
17
|
+
} from './hyperliquid/isHyperliquidAgentStep.js'
|
|
14
18
|
export { PatcherMagicNumber } from './permits/constants.js'
|
|
15
19
|
export { getNativePermit } from './permits/getNativePermit.js'
|
|
16
20
|
export { isDelegationDesignatorCode } from './permits/isDelegationDesignatorCode.js'
|