@lifi/sdk-provider-ethereum 4.2.5 → 4.2.7
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 +21 -0
- package/README.md +9 -0
- package/dist/cjs/EthereumProvider.js +5 -1
- package/dist/cjs/EthereumProvider.js.map +1 -1
- package/dist/cjs/actions/waitForBatchTransactionReceipt.js +7 -2
- package/dist/cjs/actions/waitForBatchTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/waitForRelayedTransactionReceipt.d.ts +13 -1
- package/dist/cjs/actions/waitForRelayedTransactionReceipt.js +19 -5
- package/dist/cjs/actions/waitForRelayedTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/waitForSafeTransactionExecution.js +2 -2
- package/dist/cjs/actions/waitForSafeTransactionExecution.js.map +1 -1
- package/dist/cjs/actions/waitForTransactionReceipt.js +2 -2
- package/dist/cjs/actions/waitForTransactionReceipt.js.map +1 -1
- package/dist/cjs/client/publicClient.js +14 -5
- package/dist/cjs/client/publicClient.js.map +1 -1
- package/dist/cjs/core/EthereumStepExecutor.js +5 -4
- package/dist/cjs/core/EthereumStepExecutor.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js +2 -0
- package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.js +5 -4
- package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js +10 -1
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js +5 -2
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumRelayedWaitForTransactionTask.js +10 -2
- package/dist/cjs/core/tasks/EthereumRelayedWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumResetAllowanceTask.js +2 -2
- package/dist/cjs/core/tasks/EthereumResetAllowanceTask.js.map +1 -1
- 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.js +1 -0
- package/dist/cjs/core/tasks/EthereumSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js +2 -0
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumWaitForTransactionTask.js +8 -1
- package/dist/cjs/core/tasks/EthereumWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +6 -0
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js +15 -0
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.d.ts +17 -0
- package/dist/cjs/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js +27 -0
- package/dist/cjs/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/resolveAllowanceSpender.d.ts +16 -0
- package/dist/cjs/core/tasks/helpers/resolveAllowanceSpender.js +21 -0
- package/dist/cjs/core/tasks/helpers/resolveAllowanceSpender.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/shouldCheckForAllowance.js +2 -1
- package/dist/cjs/core/tasks/helpers/shouldCheckForAllowance.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.d.ts +5 -1
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js +8 -1
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.d.ts +6 -2
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js +7 -2
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js.map +1 -1
- package/dist/cjs/errors/parseEthereumErrors.js +2 -1
- package/dist/cjs/errors/parseEthereumErrors.js.map +1 -1
- package/dist/cjs/types.d.ts +6 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/EthereumProvider.d.ts.map +1 -1
- package/dist/esm/EthereumProvider.js +5 -1
- package/dist/esm/EthereumProvider.js.map +1 -1
- package/dist/esm/actions/waitForBatchTransactionReceipt.js +7 -2
- package/dist/esm/actions/waitForBatchTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/waitForRelayedTransactionReceipt.d.ts +13 -1
- package/dist/esm/actions/waitForRelayedTransactionReceipt.d.ts.map +1 -1
- package/dist/esm/actions/waitForRelayedTransactionReceipt.js +19 -5
- package/dist/esm/actions/waitForRelayedTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/waitForSafeTransactionExecution.js +2 -2
- package/dist/esm/actions/waitForSafeTransactionExecution.js.map +1 -1
- package/dist/esm/actions/waitForTransactionReceipt.js +2 -2
- package/dist/esm/actions/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/client/publicClient.d.ts.map +1 -1
- package/dist/esm/client/publicClient.js +14 -5
- package/dist/esm/client/publicClient.js.map +1 -1
- package/dist/esm/core/EthereumStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/EthereumStepExecutor.js +6 -5
- package/dist/esm/core/EthereumStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js +3 -1
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckAllowanceTask.js +5 -4
- package/dist/esm/core/tasks/EthereumCheckAllowanceTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js +12 -3
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js +6 -3
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.js +10 -2
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumResetAllowanceTask.js +2 -2
- package/dist/esm/core/tasks/EthereumResetAllowanceTask.js.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.map +1 -1
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.js +2 -1
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js +3 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.js +9 -2
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +6 -0
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js +15 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
- package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.d.ts +17 -0
- package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js +26 -0
- package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js.map +1 -0
- package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.d.ts +16 -0
- package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.js +20 -0
- package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.js.map +1 -0
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.js +2 -1
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.js.map +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts +5 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js +8 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts +6 -2
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.js +7 -2
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.js.map +1 -1
- package/dist/esm/errors/parseEthereumErrors.d.ts.map +1 -1
- package/dist/esm/errors/parseEthereumErrors.js +2 -1
- package/dist/esm/errors/parseEthereumErrors.js.map +1 -1
- package/dist/esm/types.d.ts +6 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/version.d.ts +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 -1
- package/src/actions/waitForBatchTransactionReceipt.ts +25 -3
- package/src/actions/waitForRelayedTransactionReceipt.ts +45 -10
- package/src/actions/waitForSafeTransactionExecution.ts +6 -2
- package/src/actions/waitForTransactionReceipt.ts +6 -2
- package/src/client/publicClient.ts +20 -8
- package/src/core/EthereumStepExecutor.ts +23 -9
- package/src/core/tasks/EthereumBatchedSignAndExecuteTask.ts +10 -0
- package/src/core/tasks/EthereumCheckAllowanceTask.ts +5 -7
- package/src/core/tasks/EthereumPrepareTransactionTask.ts +47 -4
- package/src/core/tasks/EthereumRelayedSignAndExecuteTask.ts +22 -2
- package/src/core/tasks/EthereumRelayedWaitForTransactionTask.ts +40 -8
- package/src/core/tasks/EthereumResetAllowanceTask.ts +3 -6
- package/src/core/tasks/EthereumSetAllowanceTask.ts +4 -8
- package/src/core/tasks/EthereumSignAndExecuteTask.ts +5 -0
- package/src/core/tasks/EthereumStandardSignAndExecuteTask.ts +10 -0
- package/src/core/tasks/EthereumWaitForTransactionTask.ts +33 -2
- package/src/core/tasks/helpers/getEthereumExecutionStrategy.ts +28 -0
- package/src/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.ts +37 -0
- package/src/core/tasks/helpers/resolveAllowanceSpender.ts +24 -0
- package/src/core/tasks/helpers/shouldCheckForAllowance.ts +9 -5
- package/src/core/tasks/helpers/signHyperliquidTypedData.ts +9 -1
- package/src/core/tasks/helpers/signTypedDataEntries.ts +8 -2
- package/src/errors/parseEthereumErrors.ts +8 -4
- package/src/types.ts +6 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumStepExecutor.js","names":[],"sources":["../../../src/core/EthereumStepExecutor.ts"],"sourcesContent":["import {\n BaseStepExecutor,\n createDefaultStorage,\n type ExecuteStepRetryError,\n type ExecuteStepRetryParams,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStepExtended,\n type SDKClient,\n type SDKError,\n type SDKStorage,\n type StepExecutorBaseContext,\n type StepExecutorOptions,\n TaskPipeline,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Client, GetAddressesReturnType } from 'viem'\nimport { getAddresses } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { parseEthereumErrors } from '../errors/parseEthereumErrors.js'\nimport type { EthereumStepExecutorContext } from '../types.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { EthereumCheckAllowanceTask } from './tasks/EthereumCheckAllowanceTask.js'\nimport { EthereumCheckBalanceTask } from './tasks/EthereumCheckBalanceTask.js'\nimport { EthereumCheckPermitsTask } from './tasks/EthereumCheckPermitsTask.js'\nimport { EthereumNativePermitTask } from './tasks/EthereumNativePermitTask.js'\nimport { EthereumPermit2AllowanceTask } from './tasks/EthereumPermit2AllowanceTask.js'\nimport { EthereumPrepareTransactionTask } from './tasks/EthereumPrepareTransactionTask.js'\nimport { EthereumResetAllowanceTask } from './tasks/EthereumResetAllowanceTask.js'\nimport { EthereumSetAllowanceTask } from './tasks/EthereumSetAllowanceTask.js'\nimport { EthereumSignAndExecuteTask } from './tasks/EthereumSignAndExecuteTask.js'\nimport { EthereumWaitForTransactionStatusTask } from './tasks/EthereumWaitForTransactionStatusTask.js'\nimport { EthereumWaitForTransactionTask } from './tasks/EthereumWaitForTransactionTask.js'\nimport { shouldCheckForAllowance } from './tasks/helpers/shouldCheckForAllowance.js'\nimport { switchChain } from './tasks/helpers/switchChain.js'\n\ninterface EthereumStepExecutorOptions extends StepExecutorOptions {\n client: Client\n switchChain?: (chainId: number) => Promise<Client | undefined>\n disableMessageSigning?: boolean\n}\n\nexport class EthereumStepExecutor extends BaseStepExecutor {\n private client: Client\n private switchChain?: (chainId: number) => Promise<Client | undefined>\n private storage?: SDKStorage\n private disableMessageSigning?: boolean\n\n constructor(options: EthereumStepExecutorOptions) {\n super(options)\n this.client = options.client\n this.switchChain = options.switchChain\n this.disableMessageSigning = options.disableMessageSigning\n }\n\n private getStorage = (client: SDKClient): SDKStorage => {\n if (!this.storage) {\n this.storage = client.config.storage ?? createDefaultStorage()\n }\n return this.storage\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n ): Promise<SDKError | ExecuteStepRetryError> =>\n parseEthereumErrors(error, step, action, retryParams)\n\n // Ensure that we are using the right chain and wallet when executing transactions.\n checkClient = async (\n step: LiFiStepExtended,\n targetChainId?: number\n ): Promise<Client | undefined> => {\n const updatedClient = await switchChain(\n this.client,\n targetChainId ?? step.action.fromChainId,\n this.allowUserInteraction,\n this.switchChain\n )\n if (updatedClient) {\n this.client = updatedClient\n }\n\n // Prevent execution of the quote by wallet different from the one which requested the quote\n let accountAddress = this.client.account?.address\n if (!accountAddress) {\n const accountAddresses = (await getAction(\n this.client,\n getAddresses,\n 'getAddresses'\n )(undefined)) as GetAddressesReturnType\n accountAddress = accountAddresses?.[0]\n }\n if (\n accountAddress?.toLowerCase() !== step.action.fromAddress?.toLowerCase()\n ) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n return updatedClient\n }\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<EthereumStepExecutorContext> => {\n const { step, fromChain } = baseContext\n\n const isFromNativeToken =\n fromChain.nativeToken.address === step.action.fromToken.address &&\n isZeroAddress(step.action.fromToken.address)\n\n // Check if message signing is disabled - useful for smart contract wallets\n // We also disable message signing for custom steps\n const disableMessageSigning =\n !!this.disableMessageSigning || step.type !== 'lifi'\n\n return {\n ...baseContext,\n isFromNativeToken,\n disableMessageSigning,\n ethereumClient: this.client,\n checkClient: this.checkClient,\n getStorage: this.getStorage,\n // Signed typed data for native permits and other messages\n signedTypedData: [],\n // Calls for atomic batch transactions (EIP-5792)\n calls: [],\n }\n }\n\n override createPipeline = (\n context: EthereumStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution, isFromNativeToken } = context\n\n const tasks = [\n new EthereumCheckPermitsTask(),\n new EthereumCheckAllowanceTask(),\n new EthereumNativePermitTask(),\n new EthereumResetAllowanceTask(),\n new EthereumSetAllowanceTask(),\n new EthereumCheckBalanceTask(),\n new EthereumPermit2AllowanceTask(),\n new EthereumPrepareTransactionTask(),\n new EthereumSignAndExecuteTask(),\n new EthereumWaitForTransactionTask(),\n new EthereumWaitForTransactionStatusTask(),\n ]\n\n const doCheckAllowance = shouldCheckForAllowance(\n step,\n isBridgeExecution,\n isFromNativeToken,\n this.statusManager\n )\n\n let
|
|
1
|
+
{"version":3,"file":"EthereumStepExecutor.js","names":[],"sources":["../../../src/core/EthereumStepExecutor.ts"],"sourcesContent":["import {\n BaseStepExecutor,\n createDefaultStorage,\n type ExecuteStepRetryError,\n type ExecuteStepRetryParams,\n type ExecutionAction,\n hasOpenTransaction,\n LiFiErrorCode,\n type LiFiStepExtended,\n type SDKClient,\n type SDKError,\n type SDKStorage,\n type StepExecutorBaseContext,\n type StepExecutorOptions,\n TaskPipeline,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Client, GetAddressesReturnType } from 'viem'\nimport { getAddresses } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { parseEthereumErrors } from '../errors/parseEthereumErrors.js'\nimport type { EthereumStepExecutorContext } from '../types.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { EthereumCheckAllowanceTask } from './tasks/EthereumCheckAllowanceTask.js'\nimport { EthereumCheckBalanceTask } from './tasks/EthereumCheckBalanceTask.js'\nimport { EthereumCheckPermitsTask } from './tasks/EthereumCheckPermitsTask.js'\nimport { EthereumNativePermitTask } from './tasks/EthereumNativePermitTask.js'\nimport { EthereumPermit2AllowanceTask } from './tasks/EthereumPermit2AllowanceTask.js'\nimport { EthereumPrepareTransactionTask } from './tasks/EthereumPrepareTransactionTask.js'\nimport { EthereumResetAllowanceTask } from './tasks/EthereumResetAllowanceTask.js'\nimport { EthereumSetAllowanceTask } from './tasks/EthereumSetAllowanceTask.js'\nimport { EthereumSignAndExecuteTask } from './tasks/EthereumSignAndExecuteTask.js'\nimport { EthereumWaitForTransactionStatusTask } from './tasks/EthereumWaitForTransactionStatusTask.js'\nimport { EthereumWaitForTransactionTask } from './tasks/EthereumWaitForTransactionTask.js'\nimport { shouldCheckForAllowance } from './tasks/helpers/shouldCheckForAllowance.js'\nimport { switchChain } from './tasks/helpers/switchChain.js'\n\ninterface EthereumStepExecutorOptions extends StepExecutorOptions {\n client: Client\n switchChain?: (chainId: number) => Promise<Client | undefined>\n disableMessageSigning?: boolean\n}\n\nexport class EthereumStepExecutor extends BaseStepExecutor {\n private client: Client\n private switchChain?: (chainId: number) => Promise<Client | undefined>\n private storage?: SDKStorage\n private disableMessageSigning?: boolean\n\n constructor(options: EthereumStepExecutorOptions) {\n super(options)\n this.client = options.client\n this.switchChain = options.switchChain\n this.disableMessageSigning = options.disableMessageSigning\n }\n\n private getStorage = (client: SDKClient): SDKStorage => {\n if (!this.storage) {\n this.storage = client.config.storage ?? createDefaultStorage()\n }\n return this.storage\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n ): Promise<SDKError | ExecuteStepRetryError> =>\n parseEthereumErrors(error, step, action, retryParams)\n\n // Ensure that we are using the right chain and wallet when executing transactions.\n checkClient = async (\n step: LiFiStepExtended,\n targetChainId?: number\n ): Promise<Client | undefined> => {\n const updatedClient = await switchChain(\n this.client,\n targetChainId ?? step.action.fromChainId,\n this.allowUserInteraction,\n this.switchChain\n )\n if (updatedClient) {\n this.client = updatedClient\n }\n\n // Prevent execution of the quote by wallet different from the one which requested the quote\n let accountAddress = this.client.account?.address\n if (!accountAddress) {\n const accountAddresses = (await getAction(\n this.client,\n getAddresses,\n 'getAddresses'\n )(undefined)) as GetAddressesReturnType\n accountAddress = accountAddresses?.[0]\n }\n if (\n accountAddress?.toLowerCase() !== step.action.fromAddress?.toLowerCase()\n ) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n return updatedClient\n }\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<EthereumStepExecutorContext> => {\n const { step, fromChain } = baseContext\n\n const isFromNativeToken =\n fromChain.nativeToken.address === step.action.fromToken.address &&\n isZeroAddress(step.action.fromToken.address)\n\n // Check if message signing is disabled - useful for smart contract wallets\n // We also disable message signing for custom steps\n const disableMessageSigning =\n !!this.disableMessageSigning || step.type !== 'lifi'\n\n return {\n ...baseContext,\n isFromNativeToken,\n disableMessageSigning,\n ethereumClient: this.client,\n checkClient: this.checkClient,\n getStorage: this.getStorage,\n // Signed typed data for native permits and other messages\n signedTypedData: [],\n // Calls for atomic batch transactions (EIP-5792)\n calls: [],\n }\n }\n\n override createPipeline = (\n context: EthereumStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution, isFromNativeToken } = context\n\n const tasks = [\n new EthereumCheckPermitsTask(),\n new EthereumCheckAllowanceTask(),\n new EthereumNativePermitTask(),\n new EthereumResetAllowanceTask(),\n new EthereumSetAllowanceTask(),\n new EthereumCheckBalanceTask(),\n new EthereumPermit2AllowanceTask(),\n new EthereumPrepareTransactionTask(),\n new EthereumSignAndExecuteTask(),\n new EthereumWaitForTransactionTask(),\n new EthereumWaitForTransactionStatusTask(),\n ]\n\n const doCheckAllowance = shouldCheckForAllowance(\n step,\n isBridgeExecution,\n isFromNativeToken,\n this.statusManager\n )\n\n let firstTask:\n | typeof EthereumCheckPermitsTask\n | typeof EthereumCheckBalanceTask\n | typeof EthereumWaitForTransactionTask\n | typeof EthereumWaitForTransactionStatusTask\n if (doCheckAllowance) {\n firstTask = EthereumCheckPermitsTask\n } else {\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n // Same predicate as the pre-sign guard: an open transaction is waited\n // for, a FAILED action with a final outcome signs again.\n firstTask = hasOpenTransaction(swapOrBridgeAction)\n ? swapOrBridgeAction?.status === 'DONE'\n ? EthereumWaitForTransactionStatusTask\n : EthereumWaitForTransactionTask\n : EthereumCheckBalanceTask\n }\n\n // Compare classes, not names: a minifier can give two task classes the\n // same name.\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor === firstTask\n )\n if (firstTaskIndex === -1) {\n throw new TransactionError(\n LiFiErrorCode.InternalError,\n 'EthereumStepExecutor.createPipeline: first task not found'\n )\n }\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA2CA,IAAa,uBAAb,cAA0C,iBAAiB;CACzD;CACA;CACA;CACA;CAEA,YAAY,SAAsC;EAChD,MAAM,OAAO;EACb,KAAK,SAAS,QAAQ;EACtB,KAAK,cAAc,QAAQ;EAC3B,KAAK,wBAAwB,QAAQ;CACvC;CAEA,cAAsB,WAAkC;EACtD,IAAI,CAAC,KAAK,SACR,KAAK,UAAU,OAAO,OAAO,WAAW,qBAAqB;EAE/D,OAAO,KAAK;CACd;CAEA,eACE,OACA,MACA,QACA,gBAEA,oBAAoB,OAAO,MAAM,QAAQ,WAAW;CAGtD,cAAc,OACZ,MACA,kBACgC;EAChC,MAAM,gBAAgB,MAAM,YAC1B,KAAK,QACL,iBAAiB,KAAK,OAAO,aAC7B,KAAK,sBACL,KAAK,WACP;EACA,IAAI,eACF,KAAK,SAAS;EAIhB,IAAI,iBAAiB,KAAK,OAAO,SAAS;EAC1C,IAAI,CAAC,gBAMH,kBAAiB,MALe,UAC9B,KAAK,QACL,cACA,cACF,CAAC,CAAC,KAAA,CAAS,EAAA,GACyB;EAEtC,IACE,gBAAgB,YAAY,MAAM,KAAK,OAAO,aAAa,YAAY,GAEvE,MAAM,IAAI,iBACR,cAAc,8BACd,mHACF;EAEF,OAAO;CACT;CAEA,gBAAyB,OACvB,gBACyC;EACzC,MAAM,EAAE,MAAM,cAAc;EAE5B,MAAM,oBACJ,UAAU,YAAY,YAAY,KAAK,OAAO,UAAU,WACxD,cAAc,KAAK,OAAO,UAAU,OAAO;EAI7C,MAAM,wBACJ,CAAC,CAAC,KAAK,yBAAyB,KAAK,SAAS;EAEhD,OAAO;GACL,GAAG;GACH;GACA;GACA,gBAAgB,KAAK;GACrB,aAAa,KAAK;GAClB,YAAY,KAAK;GAEjB,iBAAiB,CAAC;GAElB,OAAO,CAAC;EACV;CACF;CAEA,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,mBAAmB,sBAAsB;EAEvD,MAAM,QAAQ;GACZ,IAAI,yBAAyB;GAC7B,IAAI,2BAA2B;GAC/B,IAAI,yBAAyB;GAC7B,IAAI,2BAA2B;GAC/B,IAAI,yBAAyB;GAC7B,IAAI,yBAAyB;GAC7B,IAAI,6BAA6B;GACjC,IAAI,+BAA+B;GACnC,IAAI,2BAA2B;GAC/B,IAAI,+BAA+B;GACnC,IAAI,qCAAqC;EAC3C;EAEA,MAAM,mBAAmB,wBACvB,MACA,mBACA,mBACA,KAAK,aACP;EAEA,IAAI;EAKJ,IAAI,kBACF,YAAY;OACP;GACL,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,MACtC;GAGA,YAAY,mBAAmB,kBAAkB,IAC7C,oBAAoB,WAAW,SAC7B,uCACA,iCACF;EACN;EAIA,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,gBAAgB,SACjC;EACA,IAAI,mBAAmB,IACrB,MAAM,IAAI,iBACR,cAAc,eACd,2DACF;EAGF,MAAM,aAAa,MAAM,MAAM,cAAc;EAE7C,OAAO,IAAI,aAAa,UAAU;CACpC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumBatchedSignAndExecuteTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumBatchedSignAndExecuteTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EthereumBatchedSignAndExecuteTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumBatchedSignAndExecuteTask.ts"],"mappings":";;;qBAaa,0CAA0C;EACrD,IAAU,SAAS,8BAA8B,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseStepExecutionTask, LiFiErrorCode, TransactionError } from "@lifi/sdk";
|
|
1
|
+
import { BaseStepExecutionTask, CLEARED_TRANSACTION_FIELDS, LiFiErrorCode, TransactionError, assertNoOpenTransaction } from "@lifi/sdk";
|
|
2
2
|
import { sendCalls } from "viem/actions";
|
|
3
3
|
import { getAction } from "viem/utils";
|
|
4
4
|
//#region src/core/tasks/EthereumBatchedSignAndExecuteTask.ts
|
|
@@ -18,11 +18,13 @@ var EthereumBatchedSignAndExecuteTask = class extends BaseStepExecutionTask {
|
|
|
18
18
|
value: transactionRequest.value
|
|
19
19
|
};
|
|
20
20
|
calls.push(transferCall);
|
|
21
|
+
assertNoOpenTransaction(statusManager.findAction(step, action.type));
|
|
21
22
|
const { id } = await getAction(updatedClient, sendCalls, "sendCalls")({
|
|
22
23
|
account: updatedClient.account,
|
|
23
24
|
calls
|
|
24
25
|
});
|
|
25
26
|
statusManager.updateAction(step, action.type, "PENDING", {
|
|
27
|
+
...CLEARED_TRANSACTION_FIELDS,
|
|
26
28
|
taskId: id,
|
|
27
29
|
txType: "batched",
|
|
28
30
|
signedAt: Date.now()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumBatchedSignAndExecuteTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumBatchedSignAndExecuteTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Address, Hash, Hex } from 'viem'\nimport { sendCalls } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { Call, EthereumStepExecutorContext } from '../../types.js'\n\nexport class EthereumBatchedSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n fromChain,\n statusManager,\n checkClient,\n transactionRequest,\n calls: currentCalls,\n isBridgeExecution,\n } = context\n\n const calls = [...currentCalls]\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Make sure that the chain is still correct\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n if (!transactionRequest) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request is not found.'\n )\n }\n\n const transferCall: Call = {\n chainId: fromChain.id,\n data: transactionRequest.data as Hex,\n to: transactionRequest.to as Address,\n value: transactionRequest.value,\n }\n\n calls.push(transferCall)\n\n const { id } = await getAction(\n updatedClient,\n sendCalls,\n 'sendCalls'\n )({\n account: updatedClient.account!,\n calls,\n })\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n taskId: id as Hash,\n txType: 'batched',\n signedAt: Date.now(),\n })\n\n return { status: 'COMPLETED', context: { calls } }\n }\n}\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"EthereumBatchedSignAndExecuteTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumBatchedSignAndExecuteTask.ts"],"sourcesContent":["import {\n assertNoOpenTransaction,\n BaseStepExecutionTask,\n CLEARED_TRANSACTION_FIELDS,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Address, Hash, Hex } from 'viem'\nimport { sendCalls } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { Call, EthereumStepExecutorContext } from '../../types.js'\n\nexport class EthereumBatchedSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n fromChain,\n statusManager,\n checkClient,\n transactionRequest,\n calls: currentCalls,\n isBridgeExecution,\n } = context\n\n const calls = [...currentCalls]\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Make sure that the chain is still correct\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n if (!transactionRequest) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request is not found.'\n )\n }\n\n const transferCall: Call = {\n chainId: fromChain.id,\n data: transactionRequest.data as Hex,\n to: transactionRequest.to as Address,\n value: transactionRequest.value,\n }\n\n calls.push(transferCall)\n\n // Checked again right before the wallet: a late write of an older run\n // can merge its transaction into this action during the awaits above\n // (strategy, chain switch).\n assertNoOpenTransaction(statusManager.findAction(step, action.type))\n\n const { id } = await getAction(\n updatedClient,\n sendCalls,\n 'sendCalls'\n )({\n account: updatedClient.account!,\n calls,\n })\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n // A new transaction: nothing of the previous one may survive, least of\n // all its `txFinal` verdict.\n ...CLEARED_TRANSACTION_FIELDS,\n taskId: id as Hash,\n txType: 'batched',\n signedAt: Date.now(),\n })\n\n return { status: 'COMPLETED', context: { calls } }\n }\n}\n"],"mappings":";;;;AAaA,IAAa,oCAAb,cAAuD,sBAAsB;CAC3E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,WACA,eACA,aACA,oBACA,OAAO,cACP,sBACE;EAEJ,MAAM,QAAQ,CAAC,GAAG,YAAY;EAE9B,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAI,iBACR,cAAc,uBACd,kDACF;EAIF,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,IAAI,CAAC,oBACH,MAAM,IAAI,iBACR,cAAc,uBACd,kEACF;EAGF,MAAM,eAAqB;GACzB,SAAS,UAAU;GACnB,MAAM,mBAAmB;GACzB,IAAI,mBAAmB;GACvB,OAAO,mBAAmB;EAC5B;EAEA,MAAM,KAAK,YAAY;EAKvB,wBAAwB,cAAc,WAAW,MAAM,OAAO,IAAI,CAAC;EAEnE,MAAM,EAAE,OAAO,MAAM,UACnB,eACA,WACA,WACF,CAAC,CAAC;GACA,SAAS,cAAc;GACvB;EACF,CAAC;EAED,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GAGvD,GAAG;GACH,QAAQ;GACR,QAAQ;GACR,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GAAE,QAAQ;GAAa,SAAS,EAAE,MAAM;EAAE;CACnD;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getAllowance } from "../../actions/getAllowance.js";
|
|
2
2
|
import { getEthereumExecutionStrategy } from "./helpers/getEthereumExecutionStrategy.js";
|
|
3
|
-
import {
|
|
3
|
+
import { resolveAllowanceSpender } from "./helpers/resolveAllowanceSpender.js";
|
|
4
4
|
import { BaseStepExecutionTask } from "@lifi/sdk";
|
|
5
5
|
//#region src/core/tasks/EthereumCheckAllowanceTask.ts
|
|
6
6
|
var EthereumCheckAllowanceTask = class extends BaseStepExecutionTask {
|
|
@@ -8,7 +8,7 @@ var EthereumCheckAllowanceTask = class extends BaseStepExecutionTask {
|
|
|
8
8
|
return !context.hasMatchingPermit;
|
|
9
9
|
}
|
|
10
10
|
async run(context) {
|
|
11
|
-
const { step, checkClient,
|
|
11
|
+
const { step, checkClient, client, statusManager } = context;
|
|
12
12
|
const action = statusManager.initializeAction({
|
|
13
13
|
step,
|
|
14
14
|
type: "CHECK_ALLOWANCE",
|
|
@@ -16,7 +16,7 @@ var EthereumCheckAllowanceTask = class extends BaseStepExecutionTask {
|
|
|
16
16
|
status: "STARTED"
|
|
17
17
|
});
|
|
18
18
|
const executionStrategy = await getEthereumExecutionStrategy(context);
|
|
19
|
-
const spenderAddress = await
|
|
19
|
+
const { spenderAddress } = await resolveAllowanceSpender(context, executionStrategy);
|
|
20
20
|
const fromAmount = BigInt(step.action.fromAmount);
|
|
21
21
|
const updatedClient = await checkClient(step);
|
|
22
22
|
if (!updatedClient) return { status: "PAUSED" };
|
|
@@ -27,7 +27,8 @@ var EthereumCheckAllowanceTask = class extends BaseStepExecutionTask {
|
|
|
27
27
|
context: {
|
|
28
28
|
hasAllowance: allowance > 0n,
|
|
29
29
|
hasSufficientAllowance: fromAmount <= allowance,
|
|
30
|
-
executionStrategy
|
|
30
|
+
executionStrategy,
|
|
31
|
+
allowanceSpender: spenderAddress
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumCheckAllowanceTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumCheckAllowanceTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { getAllowance } from '../../actions/getAllowance.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\nimport {
|
|
1
|
+
{"version":3,"file":"EthereumCheckAllowanceTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumCheckAllowanceTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { getAllowance } from '../../actions/getAllowance.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\nimport { resolveAllowanceSpender } from './helpers/resolveAllowanceSpender.js'\n\nexport class EthereumCheckAllowanceTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n return !context.hasMatchingPermit\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const { step, checkClient, client, statusManager } = context\n\n // Start new allowance check\n const action = statusManager.initializeAction({\n step,\n type: 'CHECK_ALLOWANCE',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const { spenderAddress } = await resolveAllowanceSpender(\n context,\n executionStrategy\n )\n\n const fromAmount = BigInt(step.action.fromAmount)\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const allowance = await getAllowance(\n client,\n updatedClient,\n step.action.fromToken.address as Address,\n updatedClient.account!.address,\n spenderAddress\n )\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: {\n hasAllowance: allowance > 0n,\n hasSufficientAllowance: fromAmount <= allowance,\n executionStrategy,\n allowanceSpender: spenderAddress,\n },\n }\n }\n}\n"],"mappings":";;;;;AAOA,IAAa,6BAAb,cAAgD,sBAAsB;CACpE,MAAe,UACb,SACkB;EAClB,OAAO,CAAC,QAAQ;CAClB;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EAAE,MAAM,aAAa,QAAQ,kBAAkB;EAGrD,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,oBAAoB,MAAM,6BAA6B,OAAO;EACpE,MAAM,EAAE,mBAAmB,MAAM,wBAC/B,SACA,iBACF;EAEA,MAAM,aAAa,OAAO,KAAK,OAAO,UAAU;EAEhD,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,YAAY,MAAM,aACtB,QACA,eACA,KAAK,OAAO,UAAU,SACtB,cAAc,QAAS,SACvB,cACF;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IACP,cAAc,YAAY;IAC1B,wBAAwB,cAAc;IACtC;IACA,kBAAkB;GACpB;EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumPrepareTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumPrepareTransactionTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EthereumPrepareTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumPrepareTransactionTask.ts"],"mappings":";;;qBAmBa,uCAAuC;EAClD,IAAU,SAAS,8BAA8B,QAAQ"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { getEthereumExecutionStrategy } from "./helpers/getEthereumExecutionStrategy.js";
|
|
1
|
+
import { STRATEGY_AFTER_PREPARE, getEthereumExecutionStrategy } from "./helpers/getEthereumExecutionStrategy.js";
|
|
2
2
|
import { getMaxPriorityFeePerGas } from "../../actions/getMaxPriorityFeePerGas.js";
|
|
3
3
|
import { getUpdatedStep } from "./helpers/getUpdatedStep.js";
|
|
4
|
+
import { isAllowancePreparedForAnotherStrategy } from "./helpers/isAllowancePreparedForAnotherStrategy.js";
|
|
4
5
|
import { preservePermit2Allowances } from "./helpers/preservePermit2Allowances.js";
|
|
5
|
-
import { BaseStepExecutionTask, LiFiErrorCode, TransactionError, stepComparison } from "@lifi/sdk";
|
|
6
|
+
import { BaseStepExecutionTask, ExecuteStepRetryError, LiFiErrorCode, TransactionError, stepComparison } from "@lifi/sdk";
|
|
6
7
|
//#region src/core/tasks/EthereumPrepareTransactionTask.ts
|
|
7
8
|
var EthereumPrepareTransactionTask = class extends BaseStepExecutionTask {
|
|
8
9
|
async run(context) {
|
|
9
10
|
const { step, client, executionOptions, statusManager, allowUserInteraction, checkClient, isBridgeExecution, signedTypedData, ethereumClient, fromChain } = context;
|
|
10
11
|
if (!statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP")) throw new TransactionError(LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
12
|
+
const typedDataBeforePrepare = step.typedData;
|
|
11
13
|
const updatedStep = await getUpdatedStep(client, step, fromChain, executionOptions, signedTypedData);
|
|
12
14
|
const comparedStep = await stepComparison(statusManager, step, updatedStep, allowUserInteraction, executionOptions);
|
|
13
15
|
const answeredTypedData = updatedStep.typedData ?? step.typedData;
|
|
@@ -17,6 +19,14 @@ var EthereumPrepareTransactionTask = class extends BaseStepExecutionTask {
|
|
|
17
19
|
typedData: preservePermit2Allowances(step, updatedStep.typedData, fromChain)
|
|
18
20
|
});
|
|
19
21
|
if (!step.transactionRequest && !answeredTypedData?.length) throw new TransactionError(LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Transaction request is not found.");
|
|
22
|
+
const executionStrategy = await getEthereumExecutionStrategy(context, true);
|
|
23
|
+
const allowanceStrategy = context.executionStrategy;
|
|
24
|
+
const isReplay = context.retryParams !== void 0;
|
|
25
|
+
if (allowanceStrategy && (allowanceStrategy === "batched" || isReplay) && await isAllowancePreparedForAnotherStrategy(context, allowanceStrategy, executionStrategy)) {
|
|
26
|
+
if (isReplay) throw new TransactionError(LiFiErrorCode.TransactionUnprepared, `Unable to prepare transaction. The step resolved to the ${executionStrategy} strategy after its allowance was prepared for ${allowanceStrategy}.`);
|
|
27
|
+
step.typedData = typedDataBeforePrepare;
|
|
28
|
+
throw new ExecuteStepRetryError(`The step resolved to the ${executionStrategy} strategy after its allowance was prepared for ${allowanceStrategy}; retry in that strategy`, { [STRATEGY_AFTER_PREPARE]: executionStrategy });
|
|
29
|
+
}
|
|
20
30
|
let transactionRequest;
|
|
21
31
|
if (step.transactionRequest) {
|
|
22
32
|
let maxPriorityFeePerGas;
|
|
@@ -45,7 +55,6 @@ var EthereumPrepareTransactionTask = class extends BaseStepExecutionTask {
|
|
|
45
55
|
...customizedTransactionRequest
|
|
46
56
|
};
|
|
47
57
|
}
|
|
48
|
-
const executionStrategy = await getEthereumExecutionStrategy(context, true);
|
|
49
58
|
return {
|
|
50
59
|
status: "COMPLETED",
|
|
51
60
|
context: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumPrepareTransactionTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumPrepareTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n stepComparison,\n type TaskResult,\n TransactionError,\n type TransactionParameters,\n} from '@lifi/sdk'\nimport { getMaxPriorityFeePerGas } from '../../actions/getMaxPriorityFeePerGas.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport {
|
|
1
|
+
{"version":3,"file":"EthereumPrepareTransactionTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumPrepareTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n ExecuteStepRetryError,\n LiFiErrorCode,\n stepComparison,\n type TaskResult,\n TransactionError,\n type TransactionParameters,\n} from '@lifi/sdk'\nimport { getMaxPriorityFeePerGas } from '../../actions/getMaxPriorityFeePerGas.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport {\n getEthereumExecutionStrategy,\n STRATEGY_AFTER_PREPARE,\n} from './helpers/getEthereumExecutionStrategy.js'\nimport { getUpdatedStep } from './helpers/getUpdatedStep.js'\nimport { isAllowancePreparedForAnotherStrategy } from './helpers/isAllowancePreparedForAnotherStrategy.js'\nimport { preservePermit2Allowances } from './helpers/preservePermit2Allowances.js'\n\nexport class EthereumPrepareTransactionTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n executionOptions,\n statusManager,\n allowUserInteraction,\n checkClient,\n isBridgeExecution,\n signedTypedData,\n ethereumClient,\n fromChain,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // A replay restores it, so the replay re-quotes like this attempt did.\n const typedDataBeforePrepare = step.typedData\n\n // Try to prepare a new transaction request and update the step with typed data\n const updatedStep = await getUpdatedStep(\n client,\n step,\n fromChain,\n executionOptions,\n signedTypedData\n )\n\n const comparedStep = await stepComparison(\n statusManager,\n step,\n updatedStep,\n allowUserInteraction,\n executionOptions\n )\n\n const answeredTypedData = updatedStep.typedData ?? step.typedData\n\n Object.assign(step, {\n ...comparedStep,\n execution: step.execution,\n typedData: preservePermit2Allowances(\n step,\n updatedStep.typedData,\n fromChain\n ),\n })\n\n if (!step.transactionRequest && !answeredTypedData?.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request is not found.'\n )\n }\n\n // Recompute execution strategy after PrepareTransaction mutates step\n const executionStrategy = await getEthereumExecutionStrategy(context, true)\n\n // The allowance tasks ran before prepare, in the strategy the step seemed\n // to have. In `batched` they only queued their work. If the re-quote moves\n // the step to a strategy that work does not fit, replay the step in the new\n // strategy (JUMEMB-102): only the batched task sends queued calls, and the\n // new strategy can need another spender. Sending the queued calls instead\n // could approve that wrong spender.\n //\n // A first run in `standard` is not replayed: its approval can already be\n // on-chain, and a signer that fails the Permit2 probe cannot use the relayed\n // lane anyway. A replay is checked again, whatever its strategy.\n const allowanceStrategy = context.executionStrategy\n const isReplay = context.retryParams !== undefined\n if (\n allowanceStrategy &&\n (allowanceStrategy === 'batched' || isReplay) &&\n (await isAllowancePreparedForAnotherStrategy(\n context,\n allowanceStrategy,\n executionStrategy\n ))\n ) {\n // `executeRoute` replays a step only once, so a second change fails it.\n if (isReplay) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n `Unable to prepare transaction. The step resolved to the ${executionStrategy} strategy after its allowance was prepared for ${allowanceStrategy}.`\n )\n }\n step.typedData = typedDataBeforePrepare\n throw new ExecuteStepRetryError(\n `The step resolved to the ${executionStrategy} strategy after its allowance was prepared for ${allowanceStrategy}; retry in that strategy`,\n { [STRATEGY_AFTER_PREPARE]: executionStrategy }\n )\n }\n\n let transactionRequest: TransactionParameters | undefined\n if (step.transactionRequest) {\n // Only fetch maxPriorityFeePerGas for local accounts\n let maxPriorityFeePerGas: bigint | undefined\n if (ethereumClient.account?.type === 'local') {\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n maxPriorityFeePerGas = await getMaxPriorityFeePerGas(\n client,\n updatedClient\n )\n } else {\n maxPriorityFeePerGas = step.transactionRequest.maxPriorityFeePerGas\n ? BigInt(step.transactionRequest.maxPriorityFeePerGas)\n : undefined\n }\n transactionRequest = {\n chainId: step.transactionRequest.chainId,\n to: step.transactionRequest.to,\n from: step.transactionRequest.from,\n data: step.transactionRequest.data,\n value: step.transactionRequest.value\n ? BigInt(step.transactionRequest.value)\n : undefined,\n gas: step.transactionRequest.gasLimit\n ? BigInt(step.transactionRequest.gasLimit)\n : undefined,\n // gasPrice: step.transactionRequest.gasPrice\n // ? BigInt(step.transactionRequest.gasPrice as string)\n // : undefined,\n // maxFeePerGas: step.transactionRequest.maxFeePerGas\n // ? BigInt(step.transactionRequest.maxFeePerGas as string)\n // : undefined,\n maxPriorityFeePerGas,\n }\n }\n\n if (executionOptions?.updateTransactionRequestHook && transactionRequest) {\n const customizedTransactionRequest: TransactionParameters =\n await executionOptions.updateTransactionRequestHook({\n requestType: 'transaction',\n ...transactionRequest,\n })\n transactionRequest = {\n ...transactionRequest,\n ...customizedTransactionRequest,\n }\n }\n\n return {\n status: 'COMPLETED',\n context: { transactionRequest, executionStrategy },\n }\n }\n}\n"],"mappings":";;;;;;;AAmBA,IAAa,iCAAb,cAAoD,sBAAsB;CACxE,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,kBACA,eACA,sBACA,aACA,mBACA,iBACA,gBACA,cACE;EAOJ,IAAI,CALW,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MAG5B,GACR,MAAM,IAAI,iBACR,cAAc,uBACd,kDACF;EAIF,MAAM,yBAAyB,KAAK;EAGpC,MAAM,cAAc,MAAM,eACxB,QACA,MACA,WACA,kBACA,eACF;EAEA,MAAM,eAAe,MAAM,eACzB,eACA,MACA,aACA,sBACA,gBACF;EAEA,MAAM,oBAAoB,YAAY,aAAa,KAAK;EAExD,OAAO,OAAO,MAAM;GAClB,GAAG;GACH,WAAW,KAAK;GAChB,WAAW,0BACT,MACA,YAAY,WACZ,SACF;EACF,CAAC;EAED,IAAI,CAAC,KAAK,sBAAsB,CAAC,mBAAmB,QAClD,MAAM,IAAI,iBACR,cAAc,uBACd,kEACF;EAIF,MAAM,oBAAoB,MAAM,6BAA6B,SAAS,IAAI;EAY1E,MAAM,oBAAoB,QAAQ;EAClC,MAAM,WAAW,QAAQ,gBAAgB,KAAA;EACzC,IACE,sBACC,sBAAsB,aAAa,aACnC,MAAM,sCACL,SACA,mBACA,iBACF,GACA;GAEA,IAAI,UACF,MAAM,IAAI,iBACR,cAAc,uBACd,2DAA2D,kBAAkB,iDAAiD,kBAAkB,EAClJ;GAEF,KAAK,YAAY;GACjB,MAAM,IAAI,sBACR,4BAA4B,kBAAkB,iDAAiD,kBAAkB,2BACjH,GAAG,yBAAyB,kBAAkB,CAChD;EACF;EAEA,IAAI;EACJ,IAAI,KAAK,oBAAoB;GAE3B,IAAI;GACJ,IAAI,eAAe,SAAS,SAAS,SAAS;IAC5C,MAAM,gBAAgB,MAAM,YAAY,IAAI;IAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;IAE5B,uBAAuB,MAAM,wBAC3B,QACA,aACF;GACF,OACE,uBAAuB,KAAK,mBAAmB,uBAC3C,OAAO,KAAK,mBAAmB,oBAAoB,IACnD,KAAA;GAEN,qBAAqB;IACnB,SAAS,KAAK,mBAAmB;IACjC,IAAI,KAAK,mBAAmB;IAC5B,MAAM,KAAK,mBAAmB;IAC9B,MAAM,KAAK,mBAAmB;IAC9B,OAAO,KAAK,mBAAmB,QAC3B,OAAO,KAAK,mBAAmB,KAAK,IACpC,KAAA;IACJ,KAAK,KAAK,mBAAmB,WACzB,OAAO,KAAK,mBAAmB,QAAQ,IACvC,KAAA;IAOJ;GACF;EACF;EAEA,IAAI,kBAAkB,gCAAgC,oBAAoB;GACxE,MAAM,+BACJ,MAAM,iBAAiB,6BAA6B;IAClD,aAAa;IACb,GAAG;GACL,CAAC;GACH,qBAAqB;IACnB,GAAG;IACH,GAAG;GACL;EACF;EAEA,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAoB;GAAkB;EACnD;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumRelayedSignAndExecuteTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumRelayedSignAndExecuteTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EthereumRelayedSignAndExecuteTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumRelayedSignAndExecuteTask.ts"],"mappings":";;;qBAkBa,0CAA0C;EACrD,IAAU,SAAS,8BAA8B,QAAQ"}
|
|
@@ -3,7 +3,7 @@ import { isNativePermitValid } from "../../permits/isNativePermitValid.js";
|
|
|
3
3
|
import { isHyperliquidAgentStep } from "../../hyperliquid/isHyperliquidAgentStep.js";
|
|
4
4
|
import { isTypedDataAlreadySigned } from "./helpers/isTypedDataAlreadySigned.js";
|
|
5
5
|
import { signHyperliquidTypedData } from "./helpers/signHyperliquidTypedData.js";
|
|
6
|
-
import { BaseStepExecutionTask, LiFiErrorCode, TransactionError, relayTransaction } from "@lifi/sdk";
|
|
6
|
+
import { BaseStepExecutionTask, CLEARED_TRANSACTION_FIELDS, LiFiErrorCode, TransactionError, assertNoOpenTransaction, relayTransaction } from "@lifi/sdk";
|
|
7
7
|
//#region src/core/tasks/EthereumRelayedSignAndExecuteTask.ts
|
|
8
8
|
var EthereumRelayedSignAndExecuteTask = class extends BaseStepExecutionTask {
|
|
9
9
|
async run(context) {
|
|
@@ -13,17 +13,19 @@ var EthereumRelayedSignAndExecuteTask = class extends BaseStepExecutionTask {
|
|
|
13
13
|
const allowanceTypedData = step.typedData?.filter((typedData) => !currentSignedTypedData.some((signedPermit) => isNativePermitValid(signedPermit, typedData)));
|
|
14
14
|
if (!allowanceTypedData?.length) throw new TransactionError(LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Typed data for transfer is not found.");
|
|
15
15
|
const unsignedTypedData = allowanceTypedData.filter((typedData) => !isTypedDataAlreadySigned(currentSignedTypedData, typedData));
|
|
16
|
+
const assertNoMergedTransaction = () => assertNoOpenTransaction(statusManager.findAction(step, action.type));
|
|
16
17
|
let signedTypedData;
|
|
17
18
|
if (isHyperliquidAgentStep(step)) {
|
|
18
19
|
statusManager.updateAction(step, action.type, "MESSAGE_REQUIRED");
|
|
19
|
-
const signedResults = await signHyperliquidTypedData(context, unsignedTypedData);
|
|
20
|
+
const signedResults = await signHyperliquidTypedData(context, unsignedTypedData, assertNoMergedTransaction);
|
|
20
21
|
if (!signedResults) return { status: "PAUSED" };
|
|
21
22
|
signedTypedData = [...currentSignedTypedData, ...signedResults];
|
|
22
23
|
} else {
|
|
23
|
-
const result = await signTypedDataEntries(context, unsignedTypedData, action.type, "MESSAGE_REQUIRED");
|
|
24
|
+
const result = await signTypedDataEntries(context, unsignedTypedData, action.type, "MESSAGE_REQUIRED", assertNoMergedTransaction);
|
|
24
25
|
if (result.status === "PAUSED") return { status: "PAUSED" };
|
|
25
26
|
signedTypedData = result.signedTypedData;
|
|
26
27
|
}
|
|
28
|
+
assertNoMergedTransaction();
|
|
27
29
|
statusManager.updateAction(step, action.type, "PENDING");
|
|
28
30
|
const { execution, ...stepBase } = step;
|
|
29
31
|
const relayedTransaction = await relayTransaction(client, {
|
|
@@ -31,6 +33,7 @@ var EthereumRelayedSignAndExecuteTask = class extends BaseStepExecutionTask {
|
|
|
31
33
|
typedData: signedTypedData
|
|
32
34
|
});
|
|
33
35
|
statusManager.updateAction(step, action.type, "PENDING", {
|
|
36
|
+
...CLEARED_TRANSACTION_FIELDS,
|
|
34
37
|
taskId: relayedTransaction.taskId,
|
|
35
38
|
txType: "relayed",
|
|
36
39
|
txLink: relayedTransaction.txLink,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumRelayedSignAndExecuteTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumRelayedSignAndExecuteTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n relayTransaction,\n type SignedTypedData,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport { isHyperliquidAgentStep } from '../../hyperliquid/isHyperliquidAgentStep.js'\nimport { isNativePermitValid } from '../../permits/isNativePermitValid.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { isTypedDataAlreadySigned } from './helpers/isTypedDataAlreadySigned.js'\nimport { signHyperliquidTypedData } from './helpers/signHyperliquidTypedData.js'\nimport { signTypedDataEntries } from './helpers/signTypedDataEntries.js'\n\nexport class EthereumRelayedSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n statusManager,\n isBridgeExecution,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n const allowanceTypedData = step.typedData?.filter(\n (typedData) =>\n !currentSignedTypedData.some((signedPermit) =>\n isNativePermitValid(signedPermit, typedData)\n )\n )\n if (!allowanceTypedData?.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Typed data for transfer is not found.'\n )\n }\n\n // An entry we already hold a signature for is relayed as it is.\n const unsignedTypedData = allowanceTypedData.filter(\n (typedData) =>\n !isTypedDataAlreadySigned(currentSignedTypedData, typedData)\n )\n\n let signedTypedData: SignedTypedData[]\n if (isHyperliquidAgentStep(step)) {\n statusManager.updateAction(step, action.type, 'MESSAGE_REQUIRED')\n\n const signedResults = await signHyperliquidTypedData(\n context,\n unsignedTypedData\n )\n\n if (!signedResults) {\n return { status: 'PAUSED' }\n }\n\n signedTypedData = [...currentSignedTypedData, ...signedResults]\n } else {\n const result = await signTypedDataEntries(\n context,\n unsignedTypedData,\n action.type,\n 'MESSAGE_REQUIRED'\n )\n if (result.status === 'PAUSED') {\n return { status: 'PAUSED' }\n }\n signedTypedData = result.signedTypedData\n }\n\n statusManager.updateAction(step, action.type, 'PENDING')\n\n const { execution, ...stepBase } = step\n const relayedTransaction = await relayTransaction(client, {\n ...stepBase,\n typedData: signedTypedData,\n })\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n taskId: relayedTransaction.taskId as Hash,\n txType: 'relayed',\n txLink: relayedTransaction.txLink,\n signedAt: Date.now(),\n })\n\n return { status: 'COMPLETED', context: { signedTypedData } }\n }\n}\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"EthereumRelayedSignAndExecuteTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumRelayedSignAndExecuteTask.ts"],"sourcesContent":["import {\n assertNoOpenTransaction,\n BaseStepExecutionTask,\n CLEARED_TRANSACTION_FIELDS,\n LiFiErrorCode,\n relayTransaction,\n type SignedTypedData,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport { isHyperliquidAgentStep } from '../../hyperliquid/isHyperliquidAgentStep.js'\nimport { isNativePermitValid } from '../../permits/isNativePermitValid.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { isTypedDataAlreadySigned } from './helpers/isTypedDataAlreadySigned.js'\nimport { signHyperliquidTypedData } from './helpers/signHyperliquidTypedData.js'\nimport { signTypedDataEntries } from './helpers/signTypedDataEntries.js'\n\nexport class EthereumRelayedSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n statusManager,\n isBridgeExecution,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n const allowanceTypedData = step.typedData?.filter(\n (typedData) =>\n !currentSignedTypedData.some((signedPermit) =>\n isNativePermitValid(signedPermit, typedData)\n )\n )\n if (!allowanceTypedData?.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Typed data for transfer is not found.'\n )\n }\n\n // An entry we already hold a signature for is relayed as it is.\n const unsignedTypedData = allowanceTypedData.filter(\n (typedData) =>\n !isTypedDataAlreadySigned(currentSignedTypedData, typedData)\n )\n\n // Checked again right before each signature: a late write of an older\n // run can merge its transaction into this action during the awaits\n // before it (strategy, chain switch, earlier prompts).\n const assertNoMergedTransaction = (): void =>\n assertNoOpenTransaction(statusManager.findAction(step, action.type))\n\n let signedTypedData: SignedTypedData[]\n if (isHyperliquidAgentStep(step)) {\n statusManager.updateAction(step, action.type, 'MESSAGE_REQUIRED')\n\n const signedResults = await signHyperliquidTypedData(\n context,\n unsignedTypedData,\n assertNoMergedTransaction\n )\n\n if (!signedResults) {\n return { status: 'PAUSED' }\n }\n\n signedTypedData = [...currentSignedTypedData, ...signedResults]\n } else {\n const result = await signTypedDataEntries(\n context,\n unsignedTypedData,\n action.type,\n 'MESSAGE_REQUIRED',\n assertNoMergedTransaction\n )\n if (result.status === 'PAUSED') {\n return { status: 'PAUSED' }\n }\n signedTypedData = result.signedTypedData\n }\n\n // Checked once more after the wallet, also when every entry was signed\n // already: a stopped run's late write can merge its task id while a\n // prompt is open. Nothing awaits from here to `relayTransaction`. A\n // merge during the relay await is not caught: both are relayed, and the\n // write below replaces the merged task id.\n assertNoMergedTransaction()\n\n statusManager.updateAction(step, action.type, 'PENDING')\n\n const { execution, ...stepBase } = step\n const relayedTransaction = await relayTransaction(client, {\n ...stepBase,\n typedData: signedTypedData,\n })\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n // A new transaction: nothing of the previous one may survive, least of\n // all its `txFinal` verdict.\n ...CLEARED_TRANSACTION_FIELDS,\n taskId: relayedTransaction.taskId as Hash,\n txType: 'relayed',\n txLink: relayedTransaction.txLink,\n signedAt: Date.now(),\n })\n\n return { status: 'COMPLETED', context: { signedTypedData } }\n }\n}\n"],"mappings":";;;;;;;AAkBA,IAAa,oCAAb,cAAuD,sBAAsB;CAC3E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,eACA,mBACA,iBAAiB,2BACf;EAEJ,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EAEA,IAAI,CAAC,QACH,MAAM,IAAI,iBACR,cAAc,uBACd,kDACF;EAGF,MAAM,qBAAqB,KAAK,WAAW,QACxC,cACC,CAAC,uBAAuB,MAAM,iBAC5B,oBAAoB,cAAc,SAAS,CAC7C,CACJ;EACA,IAAI,CAAC,oBAAoB,QACvB,MAAM,IAAI,iBACR,cAAc,uBACd,sEACF;EAIF,MAAM,oBAAoB,mBAAmB,QAC1C,cACC,CAAC,yBAAyB,wBAAwB,SAAS,CAC/D;EAKA,MAAM,kCACJ,wBAAwB,cAAc,WAAW,MAAM,OAAO,IAAI,CAAC;EAErE,IAAI;EACJ,IAAI,uBAAuB,IAAI,GAAG;GAChC,cAAc,aAAa,MAAM,OAAO,MAAM,kBAAkB;GAEhE,MAAM,gBAAgB,MAAM,yBAC1B,SACA,mBACA,yBACF;GAEA,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;GAG5B,kBAAkB,CAAC,GAAG,wBAAwB,GAAG,aAAa;EAChE,OAAO;GACL,MAAM,SAAS,MAAM,qBACnB,SACA,mBACA,OAAO,MACP,oBACA,yBACF;GACA,IAAI,OAAO,WAAW,UACpB,OAAO,EAAE,QAAQ,SAAS;GAE5B,kBAAkB,OAAO;EAC3B;EAOA,0BAA0B;EAE1B,cAAc,aAAa,MAAM,OAAO,MAAM,SAAS;EAEvD,MAAM,EAAE,WAAW,GAAG,aAAa;EACnC,MAAM,qBAAqB,MAAM,iBAAiB,QAAQ;GACxD,GAAG;GACH,WAAW;EACb,CAAC;EAED,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GAGvD,GAAG;GACH,QAAQ,mBAAmB;GAC3B,QAAQ;GACR,QAAQ,mBAAmB;GAC3B,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GAAE,QAAQ;GAAa,SAAS,EAAE,gBAAgB;EAAE;CAC7D;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumRelayedWaitForTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumRelayedWaitForTransactionTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EthereumRelayedWaitForTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumRelayedWaitForTransactionTask.ts"],"mappings":";;;qBAqBa,8CAA8C;EACzD,IAAU,SAAS,8BAA8B,QAAQ"}
|
|
@@ -2,12 +2,20 @@ import { updateActionWithReceipt } from "./helpers/updateActionWithReceipt.js";
|
|
|
2
2
|
import { waitForRelayedTransactionReceipt } from "../../actions/waitForRelayedTransactionReceipt.js";
|
|
3
3
|
import { BaseStepExecutionTask, LiFiErrorCode, TransactionError } from "@lifi/sdk";
|
|
4
4
|
//#region src/core/tasks/EthereumRelayedWaitForTransactionTask.ts
|
|
5
|
+
/** The same check as the SDK's internal `isAbortError`. */
|
|
6
|
+
const isAbortError = (error) => typeof error === "object" && error !== null && "name" in error && error.name === "AbortError";
|
|
5
7
|
var EthereumRelayedWaitForTransactionTask = class extends BaseStepExecutionTask {
|
|
6
8
|
async run(context) {
|
|
7
|
-
const { client, step, statusManager, fromChain, isBridgeExecution } = context;
|
|
9
|
+
const { client, step, statusManager, fromChain, isBridgeExecution, signal } = context;
|
|
8
10
|
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
9
11
|
if (!action) throw new TransactionError(LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
10
|
-
|
|
12
|
+
let transactionReceipt;
|
|
13
|
+
try {
|
|
14
|
+
transactionReceipt = await waitForRelayedTransactionReceipt(client, action.taskId, step, void 0, signal);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (signal?.aborted && isAbortError(error)) return { status: "PAUSED" };
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
11
19
|
updateActionWithReceipt(statusManager, step, fromChain, transactionReceipt, action);
|
|
12
20
|
if (isBridgeExecution) statusManager.updateAction(step, action.type, "DONE");
|
|
13
21
|
return { status: "COMPLETED" };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumRelayedWaitForTransactionTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumRelayedWaitForTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport { waitForRelayedTransactionReceipt } from '../../actions/waitForRelayedTransactionReceipt.js'\nimport type {
|
|
1
|
+
{"version":3,"file":"EthereumRelayedWaitForTransactionTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumRelayedWaitForTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport { waitForRelayedTransactionReceipt } from '../../actions/waitForRelayedTransactionReceipt.js'\nimport type {\n EthereumStepExecutorContext,\n WalletCallReceipt,\n} from '../../types.js'\nimport { updateActionWithReceipt } from './helpers/updateActionWithReceipt.js'\n\n/** The same check as the SDK's internal `isAbortError`. */\nconst isAbortError = (error: unknown): boolean =>\n typeof error === 'object' &&\n error !== null &&\n 'name' in error &&\n error.name === 'AbortError'\n\nexport class EthereumRelayedWaitForTransactionTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n client,\n step,\n statusManager,\n fromChain,\n isBridgeExecution,\n signal,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n let transactionReceipt: WalletCallReceipt\n try {\n // The wait starts after the relay request, so it may take the signal of\n // `stopRouteExecution`.\n transactionReceipt = await waitForRelayedTransactionReceipt(\n client,\n action.taskId as Hash,\n step,\n undefined,\n signal\n )\n } catch (error) {\n // `stopRouteExecution` ended the wait; the outcome of the relayed\n // transaction is still unknown. Pause like a stopped step, with no\n // write: the stored action keeps its task id, and a resume waits for it\n // again.\n if (signal?.aborted && isAbortError(error)) {\n return { status: 'PAUSED' }\n }\n throw error\n }\n\n updateActionWithReceipt(\n statusManager,\n step,\n fromChain,\n transactionReceipt,\n action\n )\n\n if (isBridgeExecution) {\n statusManager.updateAction(step, action.type, 'DONE')\n }\n\n return { status: 'COMPLETED' }\n }\n}\n"],"mappings":";;;;;AAeA,MAAM,gBAAgB,UACpB,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;AAEjB,IAAa,wCAAb,cAA2D,sBAAsB;CAC/E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,QACA,MACA,eACA,WACA,mBACA,WACE;EAEJ,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAI,iBACR,cAAc,uBACd,kDACF;EAGF,IAAI;EACJ,IAAI;GAGF,qBAAqB,MAAM,iCACzB,QACA,OAAO,QACP,MACA,KAAA,GACA,MACF;EACF,SAAS,OAAO;GAKd,IAAI,QAAQ,WAAW,aAAa,KAAK,GACvC,OAAO,EAAE,QAAQ,SAAS;GAE5B,MAAM;EACR;EAEA,wBACE,eACA,MACA,WACA,oBACA,MACF;EAEA,IAAI,mBACF,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAGtD,OAAO,EAAE,QAAQ,YAAY;CAC/B;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getEthereumExecutionStrategy } from "./helpers/getEthereumExecutionStrategy.js";
|
|
2
|
-
import {
|
|
2
|
+
import { resolveAllowanceSpender } from "./helpers/resolveAllowanceSpender.js";
|
|
3
3
|
import { resolveTransactionHash } from "../../actions/resolveTransactionHash.js";
|
|
4
4
|
import { setAllowance } from "../../actions/setAllowance.js";
|
|
5
5
|
import { waitForTransactionReceipt } from "../../actions/waitForTransactionReceipt.js";
|
|
@@ -26,7 +26,7 @@ var EthereumResetAllowanceTask = class extends BaseStepExecutionTask {
|
|
|
26
26
|
if (!allowUserInteraction) return { status: "PAUSED" };
|
|
27
27
|
const executionStrategy = await getEthereumExecutionStrategy(context);
|
|
28
28
|
const batchingSupported = executionStrategy === "batched";
|
|
29
|
-
const spenderAddress = await
|
|
29
|
+
const { spenderAddress } = await resolveAllowanceSpender(context, executionStrategy);
|
|
30
30
|
const updatedClient = await checkClient(step);
|
|
31
31
|
if (!updatedClient) return { status: "PAUSED" };
|
|
32
32
|
const resetResult = await setAllowance(client, updatedClient, step.action.fromToken.address, spenderAddress, 0n, executionOptions, batchingSupported);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumResetAllowanceTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumResetAllowanceTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { resolveTransactionHash } from '../../actions/resolveTransactionHash.js'\nimport { setAllowance } from '../../actions/setAllowance.js'\nimport { waitForTransactionReceipt } from '../../actions/waitForTransactionReceipt.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\nimport { getTxLink } from './helpers/getTxLink.js'\nimport {
|
|
1
|
+
{"version":3,"file":"EthereumResetAllowanceTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumResetAllowanceTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { resolveTransactionHash } from '../../actions/resolveTransactionHash.js'\nimport { setAllowance } from '../../actions/setAllowance.js'\nimport { waitForTransactionReceipt } from '../../actions/waitForTransactionReceipt.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\nimport { getTxLink } from './helpers/getTxLink.js'\nimport { resolveAllowanceSpender } from './helpers/resolveAllowanceSpender.js'\n\nexport class EthereumResetAllowanceTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const { step, hasMatchingPermit, hasSufficientAllowance, hasAllowance } =\n context\n\n return (\n !hasMatchingPermit &&\n !hasSufficientAllowance &&\n !!step.estimate.approvalReset &&\n !!hasAllowance\n )\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n statusManager,\n allowUserInteraction,\n checkClient,\n fromChain,\n executionOptions,\n client,\n calls: currentCalls,\n } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'RESET_ALLOWANCE',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n statusManager.updateAction(step, action.type, 'RESET_REQUIRED', {\n txHash: undefined,\n txLink: undefined,\n })\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const batchingSupported = executionStrategy === 'batched'\n const { spenderAddress } = await resolveAllowanceSpender(\n context,\n executionStrategy\n )\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n // Reset allowance to 0 if required\n const resetResult = await setAllowance(\n client,\n updatedClient,\n step.action.fromToken.address as Address,\n spenderAddress,\n 0n,\n executionOptions,\n batchingSupported\n )\n\n const calls = [...currentCalls]\n if (batchingSupported) {\n calls.push({\n to: step.action.fromToken.address as Address,\n data: resetResult,\n chainId: step.action.fromToken.chainId,\n })\n } else {\n const resolvedTxHash = await resolveTransactionHash(\n client,\n updatedClient,\n resetResult,\n fromChain.id\n )\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: resolvedTxHash,\n txLink: getTxLink(fromChain, resolvedTxHash),\n })\n\n const transactionReceipt = await waitForTransactionReceipt(client, {\n client: updatedClient,\n chainId: fromChain.id,\n txHash: resetResult as Address,\n onReplaced(response) {\n const newHash = response.transaction.hash\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: newHash,\n txLink: getTxLink(fromChain, newHash),\n })\n },\n })\n\n const finalHash = transactionReceipt?.transactionHash || resolvedTxHash\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: finalHash,\n txLink: getTxLink(fromChain, finalHash),\n })\n }\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: { calls, executionStrategy },\n }\n }\n}\n"],"mappings":";;;;;;;;AAUA,IAAa,6BAAb,cAAgD,sBAAsB;CACpE,MAAe,UACb,SACkB;EAClB,MAAM,EAAE,MAAM,mBAAmB,wBAAwB,iBACvD;EAEF,OACE,CAAC,qBACD,CAAC,0BACD,CAAC,CAAC,KAAK,SAAS,iBAChB,CAAC,CAAC;CAEN;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,eACA,sBACA,aACA,WACA,kBACA,QACA,OAAO,iBACL;EAEJ,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,cAAc,aAAa,MAAM,OAAO,MAAM,kBAAkB;GAC9D,QAAQ,KAAA;GACR,QAAQ,KAAA;EACV,CAAC;EAED,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,oBAAoB,MAAM,6BAA6B,OAAO;EACpE,MAAM,oBAAoB,sBAAsB;EAChD,MAAM,EAAE,mBAAmB,MAAM,wBAC/B,SACA,iBACF;EAEA,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAI5B,MAAM,cAAc,MAAM,aACxB,QACA,eACA,KAAK,OAAO,UAAU,SACtB,gBACA,IACA,kBACA,iBACF;EAEA,MAAM,QAAQ,CAAC,GAAG,YAAY;EAC9B,IAAI,mBACF,MAAM,KAAK;GACT,IAAI,KAAK,OAAO,UAAU;GAC1B,MAAM;GACN,SAAS,KAAK,OAAO,UAAU;EACjC,CAAC;OACI;GACL,MAAM,iBAAiB,MAAM,uBAC3B,QACA,eACA,aACA,UAAU,EACZ;GACA,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;IACvD,QAAQ;IACR,QAAQ,UAAU,WAAW,cAAc;GAC7C,CAAC;GAeD,MAAM,aAAY,MAbe,0BAA0B,QAAQ;IACjE,QAAQ;IACR,SAAS,UAAU;IACnB,QAAQ;IACR,WAAW,UAAU;KACnB,MAAM,UAAU,SAAS,YAAY;KACrC,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;MACvD,QAAQ;MACR,QAAQ,UAAU,WAAW,OAAO;KACtC,CAAC;IACH;GACF,CAAC,EAAA,EAEqC,mBAAmB;GACzD,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;IACvD,QAAQ;IACR,QAAQ,UAAU,WAAW,SAAS;GACxC,CAAC;EACH;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAO;GAAkB;EACtC;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getEthereumExecutionStrategy } from "./helpers/getEthereumExecutionStrategy.js";
|
|
2
|
-
import {
|
|
2
|
+
import { resolveAllowanceSpender } from "./helpers/resolveAllowanceSpender.js";
|
|
3
3
|
import { resolveTransactionHash } from "../../actions/resolveTransactionHash.js";
|
|
4
4
|
import { setAllowance } from "../../actions/setAllowance.js";
|
|
5
5
|
import { waitForTransactionReceipt } from "../../actions/waitForTransactionReceipt.js";
|
|
@@ -26,9 +26,8 @@ var EthereumSetAllowanceTask = class extends BaseStepExecutionTask {
|
|
|
26
26
|
if (!allowUserInteraction) return { status: "PAUSED" };
|
|
27
27
|
const executionStrategy = await getEthereumExecutionStrategy(context);
|
|
28
28
|
const batchingSupported = executionStrategy === "batched";
|
|
29
|
-
const permit2Supported = await
|
|
29
|
+
const { permit2Supported, spenderAddress } = await resolveAllowanceSpender(context, executionStrategy);
|
|
30
30
|
const approveAmount = getApprovalAmount(context, permit2Supported);
|
|
31
|
-
const spenderAddress = permit2Supported ? fromChain.permit2 : step.estimate.approvalAddress;
|
|
32
31
|
const updatedClient = await checkClient(step);
|
|
33
32
|
if (!updatedClient) return { status: "PAUSED" };
|
|
34
33
|
const approveResult = await setAllowance(client, updatedClient, step.action.fromToken.address, spenderAddress, approveAmount, executionOptions, batchingSupported);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumSetAllowanceTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumSetAllowanceTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { resolveTransactionHash } from '../../actions/resolveTransactionHash.js'\nimport { setAllowance } from '../../actions/setAllowance.js'\nimport { waitForTransactionReceipt } from '../../actions/waitForTransactionReceipt.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getApprovalAmount } from './helpers/getApprovalAmount.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\nimport { getTxLink } from './helpers/getTxLink.js'\nimport {
|
|
1
|
+
{"version":3,"file":"EthereumSetAllowanceTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumSetAllowanceTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { resolveTransactionHash } from '../../actions/resolveTransactionHash.js'\nimport { setAllowance } from '../../actions/setAllowance.js'\nimport { waitForTransactionReceipt } from '../../actions/waitForTransactionReceipt.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getApprovalAmount } from './helpers/getApprovalAmount.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\nimport { getTxLink } from './helpers/getTxLink.js'\nimport { resolveAllowanceSpender } from './helpers/resolveAllowanceSpender.js'\n\nexport class EthereumSetAllowanceTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n return !context.hasMatchingPermit && !context.hasSufficientAllowance\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n statusManager,\n executionOptions,\n fromChain,\n allowUserInteraction,\n checkClient,\n calls: currentCalls,\n } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'SET_ALLOWANCE',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n // Clear the txHash and txLink from potential previous approval transaction\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED', {\n txHash: undefined,\n txLink: undefined,\n })\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const batchingSupported = executionStrategy === 'batched'\n // Check if chain has Permit2 contract deployed. Permit2 should not be available for atomic batch.\n const { permit2Supported, spenderAddress } = await resolveAllowanceSpender(\n context,\n executionStrategy\n )\n\n // Set new allowance\n const approveAmount = getApprovalAmount(context, permit2Supported)\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const approveResult = await setAllowance(\n client,\n updatedClient,\n step.action.fromToken.address as Address,\n spenderAddress,\n approveAmount,\n executionOptions,\n // We need to return the populated transaction when batching is supported\n // instead of executing transaction on-chain\n batchingSupported\n )\n\n const calls = [...currentCalls]\n if (batchingSupported) {\n calls.push({\n to: step.action.fromToken.address as Address,\n data: approveResult,\n chainId: step.action.fromToken.chainId,\n })\n\n statusManager.updateAction(step, action.type, 'DONE')\n } else {\n const resolvedTxHash = await resolveTransactionHash(\n client,\n updatedClient,\n approveResult,\n fromChain.id\n )\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: resolvedTxHash,\n txLink: getTxLink(fromChain, resolvedTxHash),\n })\n\n const transactionReceipt = await waitForTransactionReceipt(client, {\n client: updatedClient,\n chainId: fromChain.id,\n txHash: approveResult,\n onReplaced(response) {\n const newHash = response.transaction.hash\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: newHash,\n txLink: getTxLink(fromChain, newHash),\n })\n },\n })\n\n const finalHash = transactionReceipt?.transactionHash || resolvedTxHash\n statusManager.updateAction(step, action.type, 'DONE', {\n txHash: finalHash,\n txLink: getTxLink(fromChain, finalHash),\n })\n }\n\n return {\n status: 'COMPLETED',\n context: { calls, executionStrategy },\n }\n }\n}\n"],"mappings":";;;;;;;;;AAWA,IAAa,2BAAb,cAA8C,sBAAsB;CAClE,MAAe,UACb,SACkB;EAClB,OAAO,CAAC,QAAQ,qBAAqB,CAAC,QAAQ;CAChD;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,eACA,kBACA,WACA,sBACA,aACA,OAAO,iBACL;EAEJ,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAGD,cAAc,aAAa,MAAM,OAAO,MAAM,mBAAmB;GAC/D,QAAQ,KAAA;GACR,QAAQ,KAAA;EACV,CAAC;EAED,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,oBAAoB,MAAM,6BAA6B,OAAO;EACpE,MAAM,oBAAoB,sBAAsB;EAEhD,MAAM,EAAE,kBAAkB,mBAAmB,MAAM,wBACjD,SACA,iBACF;EAGA,MAAM,gBAAgB,kBAAkB,SAAS,gBAAgB;EAEjE,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,gBAAgB,MAAM,aAC1B,QACA,eACA,KAAK,OAAO,UAAU,SACtB,gBACA,eACA,kBAGA,iBACF;EAEA,MAAM,QAAQ,CAAC,GAAG,YAAY;EAC9B,IAAI,mBAAmB;GACrB,MAAM,KAAK;IACT,IAAI,KAAK,OAAO,UAAU;IAC1B,MAAM;IACN,SAAS,KAAK,OAAO,UAAU;GACjC,CAAC;GAED,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EACtD,OAAO;GACL,MAAM,iBAAiB,MAAM,uBAC3B,QACA,eACA,eACA,UAAU,EACZ;GACA,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;IACvD,QAAQ;IACR,QAAQ,UAAU,WAAW,cAAc;GAC7C,CAAC;GAeD,MAAM,aAAY,MAbe,0BAA0B,QAAQ;IACjE,QAAQ;IACR,SAAS,UAAU;IACnB,QAAQ;IACR,WAAW,UAAU;KACnB,MAAM,UAAU,SAAS,YAAY;KACrC,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;MACvD,QAAQ;MACR,QAAQ,UAAU,WAAW,OAAO;KACtC,CAAC;IACH;GACF,CAAC,EAAA,EAEqC,mBAAmB;GACzD,cAAc,aAAa,MAAM,OAAO,MAAM,QAAQ;IACpD,QAAQ;IACR,QAAQ,UAAU,WAAW,SAAS;GACxC,CAAC;EACH;EAEA,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAO;GAAkB;EACtC;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumSignAndExecuteTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumSignAndExecuteTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EthereumSignAndExecuteTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumSignAndExecuteTask.ts"],"mappings":";;;qBAaa,mCAAmC;EAC9C,IAAU,SAAS,8BAA8B,QAAQ"}
|
|
@@ -2,13 +2,14 @@ import { getEthereumExecutionStrategy } from "./helpers/getEthereumExecutionStra
|
|
|
2
2
|
import { EthereumBatchedSignAndExecuteTask } from "./EthereumBatchedSignAndExecuteTask.js";
|
|
3
3
|
import { EthereumRelayedSignAndExecuteTask } from "./EthereumRelayedSignAndExecuteTask.js";
|
|
4
4
|
import { EthereumStandardSignAndExecuteTask } from "./EthereumStandardSignAndExecuteTask.js";
|
|
5
|
-
import { BaseStepExecutionTask, LiFiErrorCode, TransactionError } from "@lifi/sdk";
|
|
5
|
+
import { BaseStepExecutionTask, LiFiErrorCode, TransactionError, assertNoOpenTransaction } from "@lifi/sdk";
|
|
6
6
|
//#region src/core/tasks/EthereumSignAndExecuteTask.ts
|
|
7
7
|
var EthereumSignAndExecuteTask = class extends BaseStepExecutionTask {
|
|
8
8
|
async run(context) {
|
|
9
9
|
const { step, statusManager, allowUserInteraction, transactionRequest, isBridgeExecution } = context;
|
|
10
10
|
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
11
11
|
if (!action) throw new TransactionError(LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
12
|
+
assertNoOpenTransaction(action);
|
|
12
13
|
statusManager.updateAction(step, action.type, "ACTION_REQUIRED");
|
|
13
14
|
if (!allowUserInteraction) return { status: "PAUSED" };
|
|
14
15
|
const executionStrategy = await getEthereumExecutionStrategy(context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumSignAndExecuteTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumSignAndExecuteTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { EthereumBatchedSignAndExecuteTask } from './EthereumBatchedSignAndExecuteTask.js'\nimport { EthereumRelayedSignAndExecuteTask } from './EthereumRelayedSignAndExecuteTask.js'\nimport { EthereumStandardSignAndExecuteTask } from './EthereumStandardSignAndExecuteTask.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\n\nexport class EthereumSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n statusManager,\n allowUserInteraction,\n transactionRequest,\n isBridgeExecution,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n if (executionStrategy === 'batched' && transactionRequest) {\n return new EthereumBatchedSignAndExecuteTask().run(context)\n }\n if (executionStrategy === 'relayed') {\n return new EthereumRelayedSignAndExecuteTask().run(context)\n }\n return new EthereumStandardSignAndExecuteTask().run(context)\n }\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"EthereumSignAndExecuteTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumSignAndExecuteTask.ts"],"sourcesContent":["import {\n assertNoOpenTransaction,\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { EthereumBatchedSignAndExecuteTask } from './EthereumBatchedSignAndExecuteTask.js'\nimport { EthereumRelayedSignAndExecuteTask } from './EthereumRelayedSignAndExecuteTask.js'\nimport { EthereumStandardSignAndExecuteTask } from './EthereumStandardSignAndExecuteTask.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\n\nexport class EthereumSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n statusManager,\n allowUserInteraction,\n transactionRequest,\n isBridgeExecution,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Defence in depth for every lane below: the selector never routes an open\n // transaction here, and signing again could execute the swap twice.\n assertNoOpenTransaction(action)\n\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n if (executionStrategy === 'batched' && transactionRequest) {\n return new EthereumBatchedSignAndExecuteTask().run(context)\n }\n if (executionStrategy === 'relayed') {\n return new EthereumRelayedSignAndExecuteTask().run(context)\n }\n return new EthereumStandardSignAndExecuteTask().run(context)\n }\n}\n"],"mappings":";;;;;;AAaA,IAAa,6BAAb,cAAgD,sBAAsB;CACpE,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,eACA,sBACA,oBACA,sBACE;EAEJ,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAI,iBACR,cAAc,uBACd,kDACF;EAKF,wBAAwB,MAAM;EAE9B,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;EAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,oBAAoB,MAAM,6BAA6B,OAAO;EACpE,IAAI,sBAAsB,aAAa,oBACrC,OAAO,IAAI,kCAAkC,CAAC,CAAC,IAAI,OAAO;EAE5D,IAAI,sBAAsB,WACxB,OAAO,IAAI,kCAAkC,CAAC,CAAC,IAAI,OAAO;EAE5D,OAAO,IAAI,mCAAmC,CAAC,CAAC,IAAI,OAAO;CAC7D;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumStandardSignAndExecuteTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumStandardSignAndExecuteTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EthereumStandardSignAndExecuteTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumStandardSignAndExecuteTask.ts"],"mappings":";;;qBAsBa,2CAA2C;EACtD,IAAU,SAAS,8BAA8B,QAAQ"}
|
|
@@ -7,7 +7,7 @@ import { signPermit2Message } from "../../permits/signPermit2Message.js";
|
|
|
7
7
|
import { convertExtendedChain } from "../../utils/convertExtendedChain.js";
|
|
8
8
|
import { estimateTransactionRequest } from "./helpers/estimateTransactionRequest.js";
|
|
9
9
|
import { findSignedNativePermit } from "./helpers/findSignedNativePermit.js";
|
|
10
|
-
import { BaseStepExecutionTask, LiFiErrorCode, TransactionError } from "@lifi/sdk";
|
|
10
|
+
import { BaseStepExecutionTask, CLEARED_TRANSACTION_FIELDS, LiFiErrorCode, TransactionError, assertNoOpenTransaction } from "@lifi/sdk";
|
|
11
11
|
import { sendTransaction } from "viem/actions";
|
|
12
12
|
import { getAction } from "viem/utils";
|
|
13
13
|
//#region src/core/tasks/EthereumStandardSignAndExecuteTask.ts
|
|
@@ -44,6 +44,7 @@ var EthereumStandardSignAndExecuteTask = class extends BaseStepExecutionTask {
|
|
|
44
44
|
};
|
|
45
45
|
finalTransactionRequest = await estimateTransactionRequest(client, updatedClient, finalTransactionRequest);
|
|
46
46
|
}
|
|
47
|
+
assertNoOpenTransaction(statusManager.findAction(step, action.type));
|
|
47
48
|
const txHash = await getAction(updatedClient, sendTransaction, "sendTransaction")({
|
|
48
49
|
to: finalTransactionRequest.to,
|
|
49
50
|
account: updatedClient.account,
|
|
@@ -57,6 +58,7 @@ var EthereumStandardSignAndExecuteTask = class extends BaseStepExecutionTask {
|
|
|
57
58
|
});
|
|
58
59
|
const resolvedTxHash = await resolveTransactionHash(client, updatedClient, txHash, fromChain.id);
|
|
59
60
|
statusManager.updateAction(step, action.type, "PENDING", {
|
|
61
|
+
...CLEARED_TRANSACTION_FIELDS,
|
|
60
62
|
txHash: resolvedTxHash,
|
|
61
63
|
txLink: getTxLink(fromChain, resolvedTxHash),
|
|
62
64
|
txType: "standard",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumStandardSignAndExecuteTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumStandardSignAndExecuteTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Address, Hex, SendTransactionParameters } from 'viem'\nimport { sendTransaction } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { resolveTransactionHash } from '../../actions/resolveTransactionHash.js'\nimport { encodeNativePermitData } from '../../permits/encodeNativePermitData.js'\nimport { encodePermit2Data } from '../../permits/encodePermit2Data.js'\nimport { signPermit2Message } from '../../permits/signPermit2Message.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { convertExtendedChain } from '../../utils/convertExtendedChain.js'\nimport { estimateTransactionRequest } from './helpers/estimateTransactionRequest.js'\nimport { findSignedNativePermit } from './helpers/findSignedNativePermit.js'\nimport { getTxLink } from './helpers/getTxLink.js'\nimport { resolvePermit2Support } from './helpers/resolvePermit2Support.js'\n\nexport class EthereumStandardSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n fromChain,\n statusManager,\n checkClient,\n transactionRequest,\n allowUserInteraction,\n isBridgeExecution,\n } = context\n\n if (!transactionRequest) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request is not found.'\n )\n }\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Make sure that the chain is still correct\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const signedNativePermitTypedData = findSignedNativePermit(context)\n // Resolved *after* the native-permit lookup, and short-circuited when one\n // is found: a matching permit always wins, so resolving the gate first\n // would spend an `eth_getCode` on a verdict this task never reads. The\n // ternary also makes the two routes explicitly exclusive.\n const permit2Supported = signedNativePermitTypedData\n ? false\n : await resolvePermit2Support(context, 'standard')\n if (signedNativePermitTypedData) {\n transactionRequest.data = encodeNativePermitData(\n step.action.fromToken.address as Address,\n BigInt(step.action.fromAmount),\n signedNativePermitTypedData.message.deadline,\n signedNativePermitTypedData.signature,\n transactionRequest.data as Hex\n )\n } else if (permit2Supported) {\n statusManager.updateAction(step, action.type, 'MESSAGE_REQUIRED')\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n const permit2Signature = await signPermit2Message(client, {\n client: updatedClient,\n chain: fromChain,\n tokenAddress: step.action.fromToken.address as Address,\n amount: BigInt(step.action.fromAmount),\n data: transactionRequest.data as Hex,\n })\n transactionRequest.data = encodePermit2Data(\n step.action.fromToken.address as Address,\n BigInt(step.action.fromAmount),\n permit2Signature.message.nonce,\n permit2Signature.message.deadline,\n transactionRequest.data as Hex,\n permit2Signature.signature\n )\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n }\n\n let finalTransactionRequest = transactionRequest\n if (signedNativePermitTypedData || permit2Supported) {\n // Target address should be the Permit2 proxy contract in case of native permit or Permit2\n finalTransactionRequest = {\n ...transactionRequest,\n to: fromChain.permit2Proxy as Address,\n }\n finalTransactionRequest = await estimateTransactionRequest(\n client,\n updatedClient,\n finalTransactionRequest\n )\n }\n\n const txHash = await getAction(\n updatedClient,\n sendTransaction,\n 'sendTransaction'\n )({\n to: finalTransactionRequest.to as Address,\n account: updatedClient.account!,\n data: finalTransactionRequest.data as Hex,\n value: finalTransactionRequest.value,\n gas: finalTransactionRequest.gas,\n gasPrice: finalTransactionRequest.gasPrice,\n maxFeePerGas: finalTransactionRequest.maxFeePerGas,\n maxPriorityFeePerGas: finalTransactionRequest.maxPriorityFeePerGas,\n chain: convertExtendedChain(fromChain),\n } as SendTransactionParameters)\n\n const resolvedTxHash = await resolveTransactionHash(\n client,\n updatedClient,\n txHash,\n fromChain.id\n )\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: resolvedTxHash,\n txLink: getTxLink(fromChain, resolvedTxHash),\n txType: 'standard',\n signedAt: Date.now(),\n })\n\n return {\n status: 'COMPLETED',\n context: {\n transactionRequest: finalTransactionRequest,\n },\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"EthereumStandardSignAndExecuteTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumStandardSignAndExecuteTask.ts"],"sourcesContent":["import {\n assertNoOpenTransaction,\n BaseStepExecutionTask,\n CLEARED_TRANSACTION_FIELDS,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Address, Hex, SendTransactionParameters } from 'viem'\nimport { sendTransaction } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { resolveTransactionHash } from '../../actions/resolveTransactionHash.js'\nimport { encodeNativePermitData } from '../../permits/encodeNativePermitData.js'\nimport { encodePermit2Data } from '../../permits/encodePermit2Data.js'\nimport { signPermit2Message } from '../../permits/signPermit2Message.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { convertExtendedChain } from '../../utils/convertExtendedChain.js'\nimport { estimateTransactionRequest } from './helpers/estimateTransactionRequest.js'\nimport { findSignedNativePermit } from './helpers/findSignedNativePermit.js'\nimport { getTxLink } from './helpers/getTxLink.js'\nimport { resolvePermit2Support } from './helpers/resolvePermit2Support.js'\n\nexport class EthereumStandardSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n fromChain,\n statusManager,\n checkClient,\n transactionRequest,\n allowUserInteraction,\n isBridgeExecution,\n } = context\n\n if (!transactionRequest) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request is not found.'\n )\n }\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Make sure that the chain is still correct\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const signedNativePermitTypedData = findSignedNativePermit(context)\n // Resolved *after* the native-permit lookup, and short-circuited when one\n // is found: a matching permit always wins, so resolving the gate first\n // would spend an `eth_getCode` on a verdict this task never reads. The\n // ternary also makes the two routes explicitly exclusive.\n const permit2Supported = signedNativePermitTypedData\n ? false\n : await resolvePermit2Support(context, 'standard')\n if (signedNativePermitTypedData) {\n transactionRequest.data = encodeNativePermitData(\n step.action.fromToken.address as Address,\n BigInt(step.action.fromAmount),\n signedNativePermitTypedData.message.deadline,\n signedNativePermitTypedData.signature,\n transactionRequest.data as Hex\n )\n } else if (permit2Supported) {\n statusManager.updateAction(step, action.type, 'MESSAGE_REQUIRED')\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n const permit2Signature = await signPermit2Message(client, {\n client: updatedClient,\n chain: fromChain,\n tokenAddress: step.action.fromToken.address as Address,\n amount: BigInt(step.action.fromAmount),\n data: transactionRequest.data as Hex,\n })\n transactionRequest.data = encodePermit2Data(\n step.action.fromToken.address as Address,\n BigInt(step.action.fromAmount),\n permit2Signature.message.nonce,\n permit2Signature.message.deadline,\n transactionRequest.data as Hex,\n permit2Signature.signature\n )\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n }\n\n let finalTransactionRequest = transactionRequest\n if (signedNativePermitTypedData || permit2Supported) {\n // Target address should be the Permit2 proxy contract in case of native permit or Permit2\n finalTransactionRequest = {\n ...transactionRequest,\n to: fromChain.permit2Proxy as Address,\n }\n finalTransactionRequest = await estimateTransactionRequest(\n client,\n updatedClient,\n finalTransactionRequest\n )\n }\n\n // Checked again right before the wallet: a late write of an older run\n // can merge its transaction into this action during the awaits above\n // (strategy, chain switch, permit prompt, gas estimate).\n assertNoOpenTransaction(statusManager.findAction(step, action.type))\n\n const txHash = await getAction(\n updatedClient,\n sendTransaction,\n 'sendTransaction'\n )({\n to: finalTransactionRequest.to as Address,\n account: updatedClient.account!,\n data: finalTransactionRequest.data as Hex,\n value: finalTransactionRequest.value,\n gas: finalTransactionRequest.gas,\n gasPrice: finalTransactionRequest.gasPrice,\n maxFeePerGas: finalTransactionRequest.maxFeePerGas,\n maxPriorityFeePerGas: finalTransactionRequest.maxPriorityFeePerGas,\n chain: convertExtendedChain(fromChain),\n } as SendTransactionParameters)\n\n const resolvedTxHash = await resolveTransactionHash(\n client,\n updatedClient,\n txHash,\n fromChain.id\n )\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n // A new transaction: nothing of the previous one may survive, least of\n // all its `txFinal` verdict.\n ...CLEARED_TRANSACTION_FIELDS,\n txHash: resolvedTxHash,\n txLink: getTxLink(fromChain, resolvedTxHash),\n txType: 'standard',\n signedAt: Date.now(),\n })\n\n return {\n status: 'COMPLETED',\n context: {\n transactionRequest: finalTransactionRequest,\n },\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAsBA,IAAa,qCAAb,cAAwD,sBAAsB;CAC5E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,WACA,eACA,aACA,oBACA,sBACA,sBACE;EAEJ,IAAI,CAAC,oBACH,MAAM,IAAI,iBACR,cAAc,uBACd,kEACF;EAGF,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAI,iBACR,cAAc,uBACd,kDACF;EAIF,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,8BAA8B,uBAAuB,OAAO;EAKlE,MAAM,mBAAmB,8BACrB,QACA,MAAM,sBAAsB,SAAS,UAAU;EACnD,IAAI,6BACF,mBAAmB,OAAO,uBACxB,KAAK,OAAO,UAAU,SACtB,OAAO,KAAK,OAAO,UAAU,GAC7B,4BAA4B,QAAQ,UACpC,4BAA4B,WAC5B,mBAAmB,IACrB;OACK,IAAI,kBAAkB;GAC3B,cAAc,aAAa,MAAM,OAAO,MAAM,kBAAkB;GAChE,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAE5B,MAAM,mBAAmB,MAAM,mBAAmB,QAAQ;IACxD,QAAQ;IACR,OAAO;IACP,cAAc,KAAK,OAAO,UAAU;IACpC,QAAQ,OAAO,KAAK,OAAO,UAAU;IACrC,MAAM,mBAAmB;GAC3B,CAAC;GACD,mBAAmB,OAAO,kBACxB,KAAK,OAAO,UAAU,SACtB,OAAO,KAAK,OAAO,UAAU,GAC7B,iBAAiB,QAAQ,OACzB,iBAAiB,QAAQ,UACzB,mBAAmB,MACnB,iBAAiB,SACnB;GACA,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;GAC/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;EAE9B;EAEA,IAAI,0BAA0B;EAC9B,IAAI,+BAA+B,kBAAkB;GAEnD,0BAA0B;IACxB,GAAG;IACH,IAAI,UAAU;GAChB;GACA,0BAA0B,MAAM,2BAC9B,QACA,eACA,uBACF;EACF;EAKA,wBAAwB,cAAc,WAAW,MAAM,OAAO,IAAI,CAAC;EAEnE,MAAM,SAAS,MAAM,UACnB,eACA,iBACA,iBACF,CAAC,CAAC;GACA,IAAI,wBAAwB;GAC5B,SAAS,cAAc;GACvB,MAAM,wBAAwB;GAC9B,OAAO,wBAAwB;GAC/B,KAAK,wBAAwB;GAC7B,UAAU,wBAAwB;GAClC,cAAc,wBAAwB;GACtC,sBAAsB,wBAAwB;GAC9C,OAAO,qBAAqB,SAAS;EACvC,CAA8B;EAE9B,MAAM,iBAAiB,MAAM,uBAC3B,QACA,eACA,QACA,UAAU,EACZ;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GAGvD,GAAG;GACH,QAAQ;GACR,QAAQ,UAAU,WAAW,cAAc;GAC3C,QAAQ;GACR,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GACL,QAAQ;GACR,SAAS,EACP,oBAAoB,wBACtB;EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumWaitForTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumWaitForTransactionTask.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EthereumWaitForTransactionTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumWaitForTransactionTask.ts"],"mappings":";;;qBAkBa,uCAAuC;EAClD,IAAU,SAAS,8BAA8B,QAAQ"}
|
|
@@ -2,11 +2,18 @@ import { getEthereumExecutionStrategy } from "./helpers/getEthereumExecutionStra
|
|
|
2
2
|
import { EthereumBatchedWaitForTransactionTask } from "./EthereumBatchedWaitForTransactionTask.js";
|
|
3
3
|
import { EthereumRelayedWaitForTransactionTask } from "./EthereumRelayedWaitForTransactionTask.js";
|
|
4
4
|
import { EthereumStandardWaitForTransactionTask } from "./EthereumStandardWaitForTransactionTask.js";
|
|
5
|
-
import { BaseStepExecutionTask } from "@lifi/sdk";
|
|
5
|
+
import { BaseStepExecutionTask, hasOpenTransaction } from "@lifi/sdk";
|
|
6
6
|
//#region src/core/tasks/EthereumWaitForTransactionTask.ts
|
|
7
|
+
const TRANSACTION_METHOD_TYPES = [
|
|
8
|
+
"standard",
|
|
9
|
+
"batched",
|
|
10
|
+
"relayed"
|
|
11
|
+
];
|
|
7
12
|
var EthereumWaitForTransactionTask = class extends BaseStepExecutionTask {
|
|
8
13
|
async run(context) {
|
|
9
|
-
const
|
|
14
|
+
const { step, statusManager, isBridgeExecution } = context;
|
|
15
|
+
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
16
|
+
const executionStrategy = (hasOpenTransaction(action) && action?.txType && TRANSACTION_METHOD_TYPES.includes(action.txType) ? action.txType : void 0) ?? await getEthereumExecutionStrategy(context);
|
|
10
17
|
if (executionStrategy === "batched") return new EthereumBatchedWaitForTransactionTask().run(context);
|
|
11
18
|
if (executionStrategy === "relayed") return new EthereumRelayedWaitForTransactionTask().run(context);
|
|
12
19
|
return new EthereumStandardWaitForTransactionTask().run(context);
|