@lifi/sdk-provider-ethereum 4.2.11 → 4.2.12

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/actions/isSafeWallet.js +1 -1
  3. package/dist/cjs/core/EthereumStepExecutor.js +5 -3
  4. package/dist/cjs/core/EthereumStepExecutor.js.map +1 -1
  5. package/dist/cjs/core/tasks/EthereumCheckAllowanceAfterPrepareTask.d.ts +20 -0
  6. package/dist/cjs/core/tasks/EthereumCheckAllowanceAfterPrepareTask.js +34 -0
  7. package/dist/cjs/core/tasks/EthereumCheckAllowanceAfterPrepareTask.js.map +1 -0
  8. package/dist/cjs/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.d.ts +11 -0
  9. package/dist/cjs/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.js +17 -0
  10. package/dist/cjs/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.js.map +1 -0
  11. package/dist/cjs/index.js +2 -2
  12. package/dist/cjs/permits/getNativePermit.js +1 -1
  13. package/dist/cjs/version.d.ts +1 -1
  14. package/dist/cjs/version.js +1 -1
  15. package/dist/cjs/version.js.map +1 -1
  16. package/dist/esm/actions/isSafeWallet.js +1 -1
  17. package/dist/esm/core/EthereumStepExecutor.d.ts.map +1 -1
  18. package/dist/esm/core/EthereumStepExecutor.js +5 -3
  19. package/dist/esm/core/EthereumStepExecutor.js.map +1 -1
  20. package/dist/esm/core/tasks/EthereumCheckAllowanceAfterPrepareTask.d.ts +20 -0
  21. package/dist/esm/core/tasks/EthereumCheckAllowanceAfterPrepareTask.d.ts.map +1 -0
  22. package/dist/esm/core/tasks/EthereumCheckAllowanceAfterPrepareTask.js +33 -0
  23. package/dist/esm/core/tasks/EthereumCheckAllowanceAfterPrepareTask.js.map +1 -0
  24. package/dist/esm/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.d.ts +11 -0
  25. package/dist/esm/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.d.ts.map +1 -0
  26. package/dist/esm/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.js +16 -0
  27. package/dist/esm/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.js.map +1 -0
  28. package/dist/esm/index.js +2 -2
  29. package/dist/esm/permits/getNativePermit.js +1 -1
  30. package/dist/esm/version.d.ts +1 -1
  31. package/dist/esm/version.js +1 -1
  32. package/dist/esm/version.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/core/EthereumStepExecutor.ts +2 -0
  35. package/src/core/tasks/EthereumCheckAllowanceAfterPrepareTask.ts +34 -0
  36. package/src/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.ts +29 -0
  37. package/src/version.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @lifi/sdk-provider-ethereum
2
2
 
3
+ ## 4.2.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [#521](https://github.com/lifinance/sdk/pull/521) [`7d9a726`](https://github.com/lifinance/sdk/commit/7d9a726e565345e75852a87ec5b65656c49140d7) Thanks [@Kayanski](https://github.com/Kayanski)! - An ERC-20 step can now get its spender from `/stepTransaction`. Some providers, such as Relay, only know the spender once they build the executable transaction, so the routing-time step carries no `estimate.approvalAddress`. Before, such a step skipped the allowance tasks, and its transaction went out against a spender with no allowance and reverted.
8
+
9
+ Now a new task runs after the transaction is prepared and before it is signed. When the step had no `approvalAddress` before prepare and the re-quote brings one, the task reads the allowance for it, and resets and sets it only if it falls short. In `batched`, the approval goes into the batch with the transaction.
10
+
11
+ On a chain with Permit2, the approval goes to the Permit2 contract, as it would before prepare.
12
+
13
+ A step that already had an `approvalAddress` before prepare behaves as before, even if the re-quote changes it. The task also does not run when the step skips approval.
14
+
3
15
  ## 4.2.11
4
16
 
5
17
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_actions_getAccountCode = require("./getAccountCode.js");
3
- const require_actions_isSmartContractWallet = require("./isSmartContractWallet.js");
4
3
  const require_client_safeClient = require("../client/safeClient.js");
4
+ const require_actions_isSmartContractWallet = require("./isSmartContractWallet.js");
5
5
  //#region src/actions/isSafeWallet.ts
6
6
  const safeWalletCache = new (require("@lifi/sdk")).LruMap(12);
7
7
  /**
@@ -2,17 +2,18 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils_isZeroAddress = require("../utils/isZeroAddress.js");
3
3
  const require_errors_parseEthereumErrors = require("../errors/parseEthereumErrors.js");
4
4
  const require_core_tasks_EthereumCheckAllowanceTask = require("./tasks/EthereumCheckAllowanceTask.js");
5
+ const require_core_tasks_EthereumResetAllowanceTask = require("./tasks/EthereumResetAllowanceTask.js");
6
+ const require_core_tasks_EthereumSetAllowanceTask = require("./tasks/EthereumSetAllowanceTask.js");
7
+ const require_core_tasks_helpers_shouldCheckForAllowance = require("./tasks/helpers/shouldCheckForAllowance.js");
8
+ const require_core_tasks_EthereumCheckAllowanceAfterPrepareTask = require("./tasks/EthereumCheckAllowanceAfterPrepareTask.js");
5
9
  const require_core_tasks_EthereumCheckBalanceTask = require("./tasks/EthereumCheckBalanceTask.js");
6
10
  const require_core_tasks_EthereumCheckPermitsTask = require("./tasks/EthereumCheckPermitsTask.js");
7
11
  const require_core_tasks_EthereumNativePermitTask = require("./tasks/EthereumNativePermitTask.js");
8
12
  const require_core_tasks_EthereumPermit2AllowanceTask = require("./tasks/EthereumPermit2AllowanceTask.js");
9
13
  const require_core_tasks_EthereumPrepareTransactionTask = require("./tasks/EthereumPrepareTransactionTask.js");
10
- const require_core_tasks_EthereumResetAllowanceTask = require("./tasks/EthereumResetAllowanceTask.js");
11
- const require_core_tasks_EthereumSetAllowanceTask = require("./tasks/EthereumSetAllowanceTask.js");
12
14
  const require_core_tasks_EthereumSignAndExecuteTask = require("./tasks/EthereumSignAndExecuteTask.js");
13
15
  const require_core_tasks_EthereumWaitForTransactionStatusTask = require("./tasks/EthereumWaitForTransactionStatusTask.js");
14
16
  const require_core_tasks_EthereumWaitForTransactionTask = require("./tasks/EthereumWaitForTransactionTask.js");
15
- const require_core_tasks_helpers_shouldCheckForAllowance = require("./tasks/helpers/shouldCheckForAllowance.js");
16
17
  const require_core_tasks_helpers_switchChain = require("./tasks/helpers/switchChain.js");
17
18
  let _lifi_sdk = require("@lifi/sdk");
18
19
  let viem_actions = require("viem/actions");
@@ -68,6 +69,7 @@ var EthereumStepExecutor = class extends _lifi_sdk.BaseStepExecutor {
68
69
  new require_core_tasks_EthereumCheckBalanceTask.EthereumCheckBalanceTask(),
69
70
  new require_core_tasks_EthereumPermit2AllowanceTask.EthereumPermit2AllowanceTask(),
70
71
  new require_core_tasks_EthereumPrepareTransactionTask.EthereumPrepareTransactionTask(),
72
+ new require_core_tasks_EthereumCheckAllowanceAfterPrepareTask.EthereumCheckAllowanceAfterPrepareTask(),
71
73
  new require_core_tasks_EthereumSignAndExecuteTask.EthereumSignAndExecuteTask(),
72
74
  new require_core_tasks_EthereumWaitForTransactionTask.EthereumWaitForTransactionTask(),
73
75
  new require_core_tasks_EthereumWaitForTransactionStatusTask.EthereumWaitForTransactionStatusTask()
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumStepExecutor.js","names":["BaseStepExecutor","createDefaultStorage","parseEthereumErrors","switchChain","getAction","getAddresses","TransactionError","LiFiErrorCode","isZeroAddress","EthereumCheckPermitsTask","EthereumCheckAllowanceTask","EthereumNativePermitTask","EthereumResetAllowanceTask","EthereumSetAllowanceTask","EthereumCheckBalanceTask","EthereumPermit2AllowanceTask","EthereumPrepareTransactionTask","EthereumSignAndExecuteTask","EthereumWaitForTransactionTask","EthereumWaitForTransactionStatusTask","shouldCheckForAllowance","hasOpenTransaction","TaskPipeline"],"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,cAA0CA,UAAAA,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,YAAA,GAAWC,UAAAA,qBAAAA,CAAqB;EAE/D,OAAO,KAAK;CACd;CAEA,eACE,OACA,MACA,QACA,gBAEAC,mCAAAA,oBAAoB,OAAO,MAAM,QAAQ,WAAW;CAGtD,cAAc,OACZ,MACA,kBACgC;EAChC,MAAM,gBAAgB,MAAMC,uCAAAA,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,OAAA,GALeC,WAAAA,UAAAA,CAC9B,KAAK,QACLC,aAAAA,cACA,cACF,CAAC,CAAC,KAAA,CAAS,EAAA,GACyB;EAEtC,IACE,gBAAgB,YAAY,MAAM,KAAK,OAAO,aAAa,YAAY,GAEvE,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,8BACd,mHACF;EAEF,OAAO;CACT;CAEA,gBAAyB,OACvB,gBACyC;EACzC,MAAM,EAAE,MAAM,cAAc;EAE5B,MAAM,oBACJ,UAAU,YAAY,YAAY,KAAK,OAAO,UAAU,WACxDC,4BAAAA,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,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,8CAAAA,2BAA2B;GAC/B,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,8CAAAA,2BAA2B;GAC/B,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,gDAAAA,6BAA6B;GACjC,IAAIC,kDAAAA,+BAA+B;GACnC,IAAIC,8CAAAA,2BAA2B;GAC/B,IAAIC,kDAAAA,+BAA+B;GACnC,IAAIC,wDAAAA,qCAAqC;EAC3C;EAEA,MAAM,mBAAmBC,mDAAAA,wBACvB,MACA,mBACA,mBACA,KAAK,aACP;EAEA,IAAI;EAKJ,IAAI,kBACF,YAAYX,4CAAAA;OACP;GACL,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,MACtC;GAGA,aAAA,GAAYY,UAAAA,mBAAAA,CAAmB,kBAAkB,IAC7C,oBAAoB,WAAW,SAC7BF,wDAAAA,uCACAD,kDAAAA,iCACFJ,4CAAAA;EACN;EAIA,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,gBAAgB,SACjC;EACA,IAAI,mBAAmB,IACrB,MAAM,IAAIR,UAAAA,iBACRC,UAAAA,cAAc,eACd,2DACF;EAGF,MAAM,aAAa,MAAM,MAAM,cAAc;EAE7C,OAAO,IAAIe,UAAAA,aAAa,UAAU;CACpC;AACF"}
1
+ {"version":3,"file":"EthereumStepExecutor.js","names":["BaseStepExecutor","createDefaultStorage","parseEthereumErrors","switchChain","getAction","getAddresses","TransactionError","LiFiErrorCode","isZeroAddress","EthereumCheckPermitsTask","EthereumCheckAllowanceTask","EthereumNativePermitTask","EthereumResetAllowanceTask","EthereumSetAllowanceTask","EthereumCheckBalanceTask","EthereumPermit2AllowanceTask","EthereumPrepareTransactionTask","EthereumCheckAllowanceAfterPrepareTask","EthereumSignAndExecuteTask","EthereumWaitForTransactionTask","EthereumWaitForTransactionStatusTask","shouldCheckForAllowance","hasOpenTransaction","TaskPipeline"],"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 { EthereumCheckAllowanceAfterPrepareTask } from './tasks/EthereumCheckAllowanceAfterPrepareTask.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 EthereumCheckAllowanceAfterPrepareTask(),\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":";;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,uBAAb,cAA0CA,UAAAA,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,YAAA,GAAWC,UAAAA,qBAAAA,CAAqB;EAE/D,OAAO,KAAK;CACd;CAEA,eACE,OACA,MACA,QACA,gBAEAC,mCAAAA,oBAAoB,OAAO,MAAM,QAAQ,WAAW;CAGtD,cAAc,OACZ,MACA,kBACgC;EAChC,MAAM,gBAAgB,MAAMC,uCAAAA,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,OAAA,GALeC,WAAAA,UAAAA,CAC9B,KAAK,QACLC,aAAAA,cACA,cACF,CAAC,CAAC,KAAA,CAAS,EAAA,GACyB;EAEtC,IACE,gBAAgB,YAAY,MAAM,KAAK,OAAO,aAAa,YAAY,GAEvE,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,8BACd,mHACF;EAEF,OAAO;CACT;CAEA,gBAAyB,OACvB,gBACyC;EACzC,MAAM,EAAE,MAAM,cAAc;EAE5B,MAAM,oBACJ,UAAU,YAAY,YAAY,KAAK,OAAO,UAAU,WACxDC,4BAAAA,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,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,8CAAAA,2BAA2B;GAC/B,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,8CAAAA,2BAA2B;GAC/B,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,gDAAAA,6BAA6B;GACjC,IAAIC,kDAAAA,+BAA+B;GACnC,IAAIC,0DAAAA,uCAAuC;GAC3C,IAAIC,8CAAAA,2BAA2B;GAC/B,IAAIC,kDAAAA,+BAA+B;GACnC,IAAIC,wDAAAA,qCAAqC;EAC3C;EAEA,MAAM,mBAAmBC,mDAAAA,wBACvB,MACA,mBACA,mBACA,KAAK,aACP;EAEA,IAAI;EAKJ,IAAI,kBACF,YAAYZ,4CAAAA;OACP;GACL,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,MACtC;GAGA,aAAA,GAAYa,UAAAA,mBAAAA,CAAmB,kBAAkB,IAC7C,oBAAoB,WAAW,SAC7BF,wDAAAA,uCACAD,kDAAAA,iCACFL,4CAAAA;EACN;EAIA,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,gBAAgB,SACjC;EACA,IAAI,mBAAmB,IACrB,MAAM,IAAIR,UAAAA,iBACRC,UAAAA,cAAc,eACd,2DACF;EAGF,MAAM,aAAa,MAAM,MAAM,cAAc;EAE7C,OAAO,IAAIgB,UAAAA,aAAa,UAAU;CACpC;AACF"}
@@ -0,0 +1,20 @@
1
+ import { EthereumStepExecutorContext } from "../../types.js";
2
+ import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
3
+ //#region src/core/tasks/EthereumCheckAllowanceAfterPrepareTask.d.ts
4
+ /**
5
+ * Runs after PrepareTransaction. Some providers only know the spender once
6
+ * `/stepTransaction` builds the executable transaction, so the routing-time
7
+ * step carries no `estimate.approvalAddress` and the allowance tasks before
8
+ * prepare do not run. When the re-quote brings one, the allowance is read for
9
+ * it, and reset and set only if it falls short, before the transaction is
10
+ * signed.
11
+ *
12
+ * A spender that was already set before prepare is not checked again here.
13
+ */
14
+ export declare class EthereumCheckAllowanceAfterPrepareTask extends BaseStepExecutionTask {
15
+ private readonly allowancePipeline;
16
+ override shouldRun(context: EthereumStepExecutorContext): Promise<boolean>;
17
+ run(context: EthereumStepExecutorContext): Promise<TaskResult>;
18
+ }
19
+ //#endregion
20
+ //# sourceMappingURL=EthereumCheckAllowanceAfterPrepareTask.d.ts.map
@@ -0,0 +1,34 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_core_tasks_EthereumCheckAllowanceTask = require("./EthereumCheckAllowanceTask.js");
3
+ const require_core_tasks_EthereumResetAllowanceTask = require("./EthereumResetAllowanceTask.js");
4
+ const require_core_tasks_EthereumSetAllowanceTask = require("./EthereumSetAllowanceTask.js");
5
+ const require_core_tasks_helpers_hasApprovalAddressAppearedAtPrepare = require("./helpers/hasApprovalAddressAppearedAtPrepare.js");
6
+ let _lifi_sdk = require("@lifi/sdk");
7
+ //#region src/core/tasks/EthereumCheckAllowanceAfterPrepareTask.ts
8
+ /**
9
+ * Runs after PrepareTransaction. Some providers only know the spender once
10
+ * `/stepTransaction` builds the executable transaction, so the routing-time
11
+ * step carries no `estimate.approvalAddress` and the allowance tasks before
12
+ * prepare do not run. When the re-quote brings one, the allowance is read for
13
+ * it, and reset and set only if it falls short, before the transaction is
14
+ * signed.
15
+ *
16
+ * A spender that was already set before prepare is not checked again here.
17
+ */
18
+ var EthereumCheckAllowanceAfterPrepareTask = class extends _lifi_sdk.BaseStepExecutionTask {
19
+ allowancePipeline = new _lifi_sdk.TaskPipeline([
20
+ new require_core_tasks_EthereumCheckAllowanceTask.EthereumCheckAllowanceTask(),
21
+ new require_core_tasks_EthereumResetAllowanceTask.EthereumResetAllowanceTask(),
22
+ new require_core_tasks_EthereumSetAllowanceTask.EthereumSetAllowanceTask()
23
+ ]);
24
+ async shouldRun(context) {
25
+ return require_core_tasks_helpers_hasApprovalAddressAppearedAtPrepare.hasApprovalAddressAppearedAtPrepare(context);
26
+ }
27
+ async run(context) {
28
+ return this.allowancePipeline.run(context);
29
+ }
30
+ };
31
+ //#endregion
32
+ exports.EthereumCheckAllowanceAfterPrepareTask = EthereumCheckAllowanceAfterPrepareTask;
33
+
34
+ //# sourceMappingURL=EthereumCheckAllowanceAfterPrepareTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthereumCheckAllowanceAfterPrepareTask.js","names":["BaseStepExecutionTask","TaskPipeline","EthereumCheckAllowanceTask","EthereumResetAllowanceTask","EthereumSetAllowanceTask","hasApprovalAddressAppearedAtPrepare"],"sources":["../../../../src/core/tasks/EthereumCheckAllowanceAfterPrepareTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, TaskPipeline, type TaskResult } from '@lifi/sdk'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { EthereumCheckAllowanceTask } from './EthereumCheckAllowanceTask.js'\nimport { EthereumResetAllowanceTask } from './EthereumResetAllowanceTask.js'\nimport { EthereumSetAllowanceTask } from './EthereumSetAllowanceTask.js'\nimport { hasApprovalAddressAppearedAtPrepare } from './helpers/hasApprovalAddressAppearedAtPrepare.js'\n\n/**\n * Runs after PrepareTransaction. Some providers only know the spender once\n * `/stepTransaction` builds the executable transaction, so the routing-time\n * step carries no `estimate.approvalAddress` and the allowance tasks before\n * prepare do not run. When the re-quote brings one, the allowance is read for\n * it, and reset and set only if it falls short, before the transaction is\n * signed.\n *\n * A spender that was already set before prepare is not checked again here.\n */\nexport class EthereumCheckAllowanceAfterPrepareTask extends BaseStepExecutionTask {\n private readonly allowancePipeline = new TaskPipeline([\n new EthereumCheckAllowanceTask(),\n new EthereumResetAllowanceTask(),\n new EthereumSetAllowanceTask(),\n ])\n\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n return hasApprovalAddressAppearedAtPrepare(context)\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n return this.allowancePipeline.run(context)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,IAAa,yCAAb,cAA4DA,UAAAA,sBAAsB;CAChF,oBAAqC,IAAIC,UAAAA,aAAa;EACpD,IAAIC,8CAAAA,2BAA2B;EAC/B,IAAIC,8CAAAA,2BAA2B;EAC/B,IAAIC,4CAAAA,yBAAyB;CAC/B,CAAC;CAED,MAAe,UACb,SACkB;EAClB,OAAOC,+DAAAA,oCAAoC,OAAO;CACpD;CAEA,MAAM,IAAI,SAA2D;EACnE,OAAO,KAAK,kBAAkB,IAAI,OAAO;CAC3C;AACF"}
@@ -0,0 +1,11 @@
1
+ import { EthereumStepExecutorContext } from "../../../types.js";
2
+ //#region src/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.d.ts
3
+ /**
4
+ * Whether the step had no `estimate.approvalAddress` before prepare and the
5
+ * re-quote brought one. No allowance was checked then (`allowanceSpender` is
6
+ * unset), and the step now needs it checked. The allowance tasks resolve the
7
+ * spender themselves, so on a Permit2 chain they approve `fromChain.permit2`.
8
+ */
9
+ export declare const hasApprovalAddressAppearedAtPrepare: (context: EthereumStepExecutorContext) => boolean;
10
+ //#endregion
11
+ //# sourceMappingURL=hasApprovalAddressAppearedAtPrepare.d.ts.map
@@ -0,0 +1,17 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_core_tasks_helpers_shouldCheckForAllowance = require("./shouldCheckForAllowance.js");
3
+ //#region src/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.ts
4
+ /**
5
+ * Whether the step had no `estimate.approvalAddress` before prepare and the
6
+ * re-quote brought one. No allowance was checked then (`allowanceSpender` is
7
+ * unset), and the step now needs it checked. The allowance tasks resolve the
8
+ * spender themselves, so on a Permit2 chain they approve `fromChain.permit2`.
9
+ */
10
+ const hasApprovalAddressAppearedAtPrepare = (context) => {
11
+ const { step, allowanceSpender, isBridgeExecution, isFromNativeToken, statusManager } = context;
12
+ return !allowanceSpender && require_core_tasks_helpers_shouldCheckForAllowance.shouldCheckForAllowance(step, isBridgeExecution, isFromNativeToken, statusManager);
13
+ };
14
+ //#endregion
15
+ exports.hasApprovalAddressAppearedAtPrepare = hasApprovalAddressAppearedAtPrepare;
16
+
17
+ //# sourceMappingURL=hasApprovalAddressAppearedAtPrepare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasApprovalAddressAppearedAtPrepare.js","names":["shouldCheckForAllowance"],"sources":["../../../../../src/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.ts"],"sourcesContent":["import type { EthereumStepExecutorContext } from '../../../types.js'\nimport { shouldCheckForAllowance } from './shouldCheckForAllowance.js'\n\n/**\n * Whether the step had no `estimate.approvalAddress` before prepare and the\n * re-quote brought one. No allowance was checked then (`allowanceSpender` is\n * unset), and the step now needs it checked. The allowance tasks resolve the\n * spender themselves, so on a Permit2 chain they approve `fromChain.permit2`.\n */\nexport const hasApprovalAddressAppearedAtPrepare = (\n context: EthereumStepExecutorContext\n): boolean => {\n const {\n step,\n allowanceSpender,\n isBridgeExecution,\n isFromNativeToken,\n statusManager,\n } = context\n return (\n !allowanceSpender &&\n shouldCheckForAllowance(\n step,\n isBridgeExecution,\n isFromNativeToken,\n statusManager\n )\n )\n}\n"],"mappings":";;;;;;;;;AASA,MAAa,uCACX,YACY;CACZ,MAAM,EACJ,MACA,kBACA,mBACA,mBACA,kBACE;CACJ,OACE,CAAC,oBACDA,mDAAAA,wBACE,MACA,mBACA,mBACA,aACF;AAEJ"}
package/dist/cjs/index.js CHANGED
@@ -3,12 +3,12 @@ const require_utils_isZeroAddress = require("./utils/isZeroAddress.js");
3
3
  const require_actions_getAllowance = require("./actions/getAllowance.js");
4
4
  const require_actions_isBatchingSupported = require("./actions/isBatchingSupported.js");
5
5
  const require_utils_isGaslessStep = require("./utils/isGaslessStep.js");
6
+ const require_types = require("./types.js");
6
7
  const require_permits_isDelegationDesignatorCode = require("./permits/isDelegationDesignatorCode.js");
8
+ const require_actions_setAllowance = require("./actions/setAllowance.js");
7
9
  const require_permits_constants = require("./permits/constants.js");
8
10
  const require_permits_getNativePermit = require("./permits/getNativePermit.js");
9
11
  const require_utils_isContractCallStep = require("./utils/isContractCallStep.js");
10
- const require_types = require("./types.js");
11
- const require_actions_setAllowance = require("./actions/setAllowance.js");
12
12
  const require_hyperliquid_isHyperliquidAgentStep = require("./hyperliquid/isHyperliquidAgentStep.js");
13
13
  const require_utils_convertExtendedChain = require("./utils/convertExtendedChain.js");
14
14
  const require_EthereumProvider = require("./EthereumProvider.js");
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils_abi = require("../utils/abi.js");
3
3
  const require_actions_getMulticallAddress = require("../actions/getMulticallAddress.js");
4
4
  const require_utils_getActionWithFallback = require("../utils/getActionWithFallback.js");
5
- const require_permits_canAccountUseNativePermits = require("./canAccountUseNativePermits.js");
6
5
  const require_permits_constants = require("./constants.js");
6
+ const require_permits_canAccountUseNativePermits = require("./canAccountUseNativePermits.js");
7
7
  let viem = require("viem");
8
8
  let viem_actions = require("viem/actions");
9
9
  //#region src/permits/getNativePermit.ts
@@ -1,5 +1,5 @@
1
1
  //#region src/version.d.ts
2
2
  export declare const name = "@lifi/sdk-provider-ethereum";
3
- export declare const version = "4.2.11";
3
+ export declare const version = "4.2.12";
4
4
  //#endregion
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/version.ts
3
3
  const name = "@lifi/sdk-provider-ethereum";
4
- const version = "4.2.11";
4
+ const version = "4.2.12";
5
5
  //#endregion
6
6
  exports.name = name;
7
7
  exports.version = version;
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-ethereum'\nexport const version = '4.2.11'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-ethereum'\nexport const version = '4.2.12'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
@@ -1,6 +1,6 @@
1
1
  import { getAccountCode } from "./getAccountCode.js";
2
- import { isSmartContractWalletCode } from "./isSmartContractWallet.js";
3
2
  import { getSafeClient } from "../client/safeClient.js";
3
+ import { isSmartContractWalletCode } from "./isSmartContractWallet.js";
4
4
  import { LruMap } from "@lifi/sdk";
5
5
  //#region src/actions/isSafeWallet.ts
6
6
  const safeWalletCache = new LruMap(12);
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumStepExecutor.d.ts","names":[],"sources":["../../../src/core/EthereumStepExecutor.ts"],"mappings":";;;;UAqCU,oCAAoC;EAC5C,QAAQ;EACR,eAAe,oBAAoB,QAAQ;EAC3C;;qBAGW,6BAA6B;UAChC;UACA;UACA;UACA;EAER,YAAY,SAAS;UAOb;WAOC,cACP,OAAO,OACP,OAAO,kBACP,SAAS,iBACT,cAAc,2BACb,QAAQ,WAAW;EAItB,cACE,MAAM,kBACN,2BACC,QAAQ;WAgCF,gBACP,aAAa,4BACZ,QAAQ;WA0BF,iBACP,SAAS,gCACR"}
1
+ {"version":3,"file":"EthereumStepExecutor.d.ts","names":[],"sources":["../../../src/core/EthereumStepExecutor.ts"],"mappings":";;;;UAsCU,oCAAoC;EAC5C,QAAQ;EACR,eAAe,oBAAoB,QAAQ;EAC3C;;qBAGW,6BAA6B;UAChC;UACA;UACA;UACA;EAER,YAAY,SAAS;UAOb;WAOC,cACP,OAAO,OACP,OAAO,kBACP,SAAS,iBACT,cAAc,2BACb,QAAQ,WAAW;EAItB,cACE,MAAM,kBACN,2BACC,QAAQ;WAgCF,gBACP,aAAa,4BACZ,QAAQ;WA0BF,iBACP,SAAS,gCACR"}
@@ -1,17 +1,18 @@
1
1
  import { isZeroAddress } from "../utils/isZeroAddress.js";
2
2
  import { parseEthereumErrors } from "../errors/parseEthereumErrors.js";
3
3
  import { EthereumCheckAllowanceTask } from "./tasks/EthereumCheckAllowanceTask.js";
4
+ import { EthereumResetAllowanceTask } from "./tasks/EthereumResetAllowanceTask.js";
5
+ import { EthereumSetAllowanceTask } from "./tasks/EthereumSetAllowanceTask.js";
6
+ import { shouldCheckForAllowance } from "./tasks/helpers/shouldCheckForAllowance.js";
7
+ import { EthereumCheckAllowanceAfterPrepareTask } from "./tasks/EthereumCheckAllowanceAfterPrepareTask.js";
4
8
  import { EthereumCheckBalanceTask } from "./tasks/EthereumCheckBalanceTask.js";
5
9
  import { EthereumCheckPermitsTask } from "./tasks/EthereumCheckPermitsTask.js";
6
10
  import { EthereumNativePermitTask } from "./tasks/EthereumNativePermitTask.js";
7
11
  import { EthereumPermit2AllowanceTask } from "./tasks/EthereumPermit2AllowanceTask.js";
8
12
  import { EthereumPrepareTransactionTask } from "./tasks/EthereumPrepareTransactionTask.js";
9
- import { EthereumResetAllowanceTask } from "./tasks/EthereumResetAllowanceTask.js";
10
- import { EthereumSetAllowanceTask } from "./tasks/EthereumSetAllowanceTask.js";
11
13
  import { EthereumSignAndExecuteTask } from "./tasks/EthereumSignAndExecuteTask.js";
12
14
  import { EthereumWaitForTransactionStatusTask } from "./tasks/EthereumWaitForTransactionStatusTask.js";
13
15
  import { EthereumWaitForTransactionTask } from "./tasks/EthereumWaitForTransactionTask.js";
14
- import { shouldCheckForAllowance } from "./tasks/helpers/shouldCheckForAllowance.js";
15
16
  import { switchChain } from "./tasks/helpers/switchChain.js";
16
17
  import { BaseStepExecutor, LiFiErrorCode, TaskPipeline, TransactionError, createDefaultStorage, hasOpenTransaction } from "@lifi/sdk";
17
18
  import { getAddresses } from "viem/actions";
@@ -67,6 +68,7 @@ var EthereumStepExecutor = class extends BaseStepExecutor {
67
68
  new EthereumCheckBalanceTask(),
68
69
  new EthereumPermit2AllowanceTask(),
69
70
  new EthereumPrepareTransactionTask(),
71
+ new EthereumCheckAllowanceAfterPrepareTask(),
70
72
  new EthereumSignAndExecuteTask(),
71
73
  new EthereumWaitForTransactionTask(),
72
74
  new EthereumWaitForTransactionStatusTask()
@@ -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 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
+ {"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 { EthereumCheckAllowanceAfterPrepareTask } from './tasks/EthereumCheckAllowanceAfterPrepareTask.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 EthereumCheckAllowanceAfterPrepareTask(),\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":";;;;;;;;;;;;;;;;;;;;AA4CA,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,uCAAuC;GAC3C,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"}
@@ -0,0 +1,20 @@
1
+ import { EthereumStepExecutorContext } from "../../types.js";
2
+ import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
3
+ //#region src/core/tasks/EthereumCheckAllowanceAfterPrepareTask.d.ts
4
+ /**
5
+ * Runs after PrepareTransaction. Some providers only know the spender once
6
+ * `/stepTransaction` builds the executable transaction, so the routing-time
7
+ * step carries no `estimate.approvalAddress` and the allowance tasks before
8
+ * prepare do not run. When the re-quote brings one, the allowance is read for
9
+ * it, and reset and set only if it falls short, before the transaction is
10
+ * signed.
11
+ *
12
+ * A spender that was already set before prepare is not checked again here.
13
+ */
14
+ export declare class EthereumCheckAllowanceAfterPrepareTask extends BaseStepExecutionTask {
15
+ private readonly allowancePipeline;
16
+ override shouldRun(context: EthereumStepExecutorContext): Promise<boolean>;
17
+ run(context: EthereumStepExecutorContext): Promise<TaskResult>;
18
+ }
19
+ //#endregion
20
+ //# sourceMappingURL=EthereumCheckAllowanceAfterPrepareTask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthereumCheckAllowanceAfterPrepareTask.d.ts","names":[],"sources":["../../../../src/core/tasks/EthereumCheckAllowanceAfterPrepareTask.ts"],"mappings":";;;;;;;;;;;;;qBAiBa,+CAA+C;mBACzC;WAMF,UACb,SAAS,8BACR;EAIH,IAAU,SAAS,8BAA8B,QAAQ"}
@@ -0,0 +1,33 @@
1
+ import { EthereumCheckAllowanceTask } from "./EthereumCheckAllowanceTask.js";
2
+ import { EthereumResetAllowanceTask } from "./EthereumResetAllowanceTask.js";
3
+ import { EthereumSetAllowanceTask } from "./EthereumSetAllowanceTask.js";
4
+ import { hasApprovalAddressAppearedAtPrepare } from "./helpers/hasApprovalAddressAppearedAtPrepare.js";
5
+ import { BaseStepExecutionTask, TaskPipeline } from "@lifi/sdk";
6
+ //#region src/core/tasks/EthereumCheckAllowanceAfterPrepareTask.ts
7
+ /**
8
+ * Runs after PrepareTransaction. Some providers only know the spender once
9
+ * `/stepTransaction` builds the executable transaction, so the routing-time
10
+ * step carries no `estimate.approvalAddress` and the allowance tasks before
11
+ * prepare do not run. When the re-quote brings one, the allowance is read for
12
+ * it, and reset and set only if it falls short, before the transaction is
13
+ * signed.
14
+ *
15
+ * A spender that was already set before prepare is not checked again here.
16
+ */
17
+ var EthereumCheckAllowanceAfterPrepareTask = class extends BaseStepExecutionTask {
18
+ allowancePipeline = new TaskPipeline([
19
+ new EthereumCheckAllowanceTask(),
20
+ new EthereumResetAllowanceTask(),
21
+ new EthereumSetAllowanceTask()
22
+ ]);
23
+ async shouldRun(context) {
24
+ return hasApprovalAddressAppearedAtPrepare(context);
25
+ }
26
+ async run(context) {
27
+ return this.allowancePipeline.run(context);
28
+ }
29
+ };
30
+ //#endregion
31
+ export { EthereumCheckAllowanceAfterPrepareTask };
32
+
33
+ //# sourceMappingURL=EthereumCheckAllowanceAfterPrepareTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthereumCheckAllowanceAfterPrepareTask.js","names":[],"sources":["../../../../src/core/tasks/EthereumCheckAllowanceAfterPrepareTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, TaskPipeline, type TaskResult } from '@lifi/sdk'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { EthereumCheckAllowanceTask } from './EthereumCheckAllowanceTask.js'\nimport { EthereumResetAllowanceTask } from './EthereumResetAllowanceTask.js'\nimport { EthereumSetAllowanceTask } from './EthereumSetAllowanceTask.js'\nimport { hasApprovalAddressAppearedAtPrepare } from './helpers/hasApprovalAddressAppearedAtPrepare.js'\n\n/**\n * Runs after PrepareTransaction. Some providers only know the spender once\n * `/stepTransaction` builds the executable transaction, so the routing-time\n * step carries no `estimate.approvalAddress` and the allowance tasks before\n * prepare do not run. When the re-quote brings one, the allowance is read for\n * it, and reset and set only if it falls short, before the transaction is\n * signed.\n *\n * A spender that was already set before prepare is not checked again here.\n */\nexport class EthereumCheckAllowanceAfterPrepareTask extends BaseStepExecutionTask {\n private readonly allowancePipeline = new TaskPipeline([\n new EthereumCheckAllowanceTask(),\n new EthereumResetAllowanceTask(),\n new EthereumSetAllowanceTask(),\n ])\n\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n return hasApprovalAddressAppearedAtPrepare(context)\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n return this.allowancePipeline.run(context)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAa,yCAAb,cAA4D,sBAAsB;CAChF,oBAAqC,IAAI,aAAa;EACpD,IAAI,2BAA2B;EAC/B,IAAI,2BAA2B;EAC/B,IAAI,yBAAyB;CAC/B,CAAC;CAED,MAAe,UACb,SACkB;EAClB,OAAO,oCAAoC,OAAO;CACpD;CAEA,MAAM,IAAI,SAA2D;EACnE,OAAO,KAAK,kBAAkB,IAAI,OAAO;CAC3C;AACF"}
@@ -0,0 +1,11 @@
1
+ import { EthereumStepExecutorContext } from "../../../types.js";
2
+ //#region src/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.d.ts
3
+ /**
4
+ * Whether the step had no `estimate.approvalAddress` before prepare and the
5
+ * re-quote brought one. No allowance was checked then (`allowanceSpender` is
6
+ * unset), and the step now needs it checked. The allowance tasks resolve the
7
+ * spender themselves, so on a Permit2 chain they approve `fromChain.permit2`.
8
+ */
9
+ export declare const hasApprovalAddressAppearedAtPrepare: (context: EthereumStepExecutorContext) => boolean;
10
+ //#endregion
11
+ //# sourceMappingURL=hasApprovalAddressAppearedAtPrepare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasApprovalAddressAppearedAtPrepare.d.ts","names":[],"sources":["../../../../../src/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.ts"],"mappings":";;;;;;;;qBASa,sCACX,SAAS"}
@@ -0,0 +1,16 @@
1
+ import { shouldCheckForAllowance } from "./shouldCheckForAllowance.js";
2
+ //#region src/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.ts
3
+ /**
4
+ * Whether the step had no `estimate.approvalAddress` before prepare and the
5
+ * re-quote brought one. No allowance was checked then (`allowanceSpender` is
6
+ * unset), and the step now needs it checked. The allowance tasks resolve the
7
+ * spender themselves, so on a Permit2 chain they approve `fromChain.permit2`.
8
+ */
9
+ const hasApprovalAddressAppearedAtPrepare = (context) => {
10
+ const { step, allowanceSpender, isBridgeExecution, isFromNativeToken, statusManager } = context;
11
+ return !allowanceSpender && shouldCheckForAllowance(step, isBridgeExecution, isFromNativeToken, statusManager);
12
+ };
13
+ //#endregion
14
+ export { hasApprovalAddressAppearedAtPrepare };
15
+
16
+ //# sourceMappingURL=hasApprovalAddressAppearedAtPrepare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasApprovalAddressAppearedAtPrepare.js","names":[],"sources":["../../../../../src/core/tasks/helpers/hasApprovalAddressAppearedAtPrepare.ts"],"sourcesContent":["import type { EthereumStepExecutorContext } from '../../../types.js'\nimport { shouldCheckForAllowance } from './shouldCheckForAllowance.js'\n\n/**\n * Whether the step had no `estimate.approvalAddress` before prepare and the\n * re-quote brought one. No allowance was checked then (`allowanceSpender` is\n * unset), and the step now needs it checked. The allowance tasks resolve the\n * spender themselves, so on a Permit2 chain they approve `fromChain.permit2`.\n */\nexport const hasApprovalAddressAppearedAtPrepare = (\n context: EthereumStepExecutorContext\n): boolean => {\n const {\n step,\n allowanceSpender,\n isBridgeExecution,\n isFromNativeToken,\n statusManager,\n } = context\n return (\n !allowanceSpender &&\n shouldCheckForAllowance(\n step,\n isBridgeExecution,\n isFromNativeToken,\n statusManager\n )\n )\n}\n"],"mappings":";;;;;;;;AASA,MAAa,uCACX,YACY;CACZ,MAAM,EACJ,MACA,kBACA,mBACA,mBACA,kBACE;CACJ,OACE,CAAC,oBACD,wBACE,MACA,mBACA,mBACA,aACF;AAEJ"}
package/dist/esm/index.js CHANGED
@@ -2,12 +2,12 @@ import { isZeroAddress } from "./utils/isZeroAddress.js";
2
2
  import { getTokenAllowance, getTokenAllowanceMulticall } from "./actions/getAllowance.js";
3
3
  import { isBatchingSupported } from "./actions/isBatchingSupported.js";
4
4
  import { isGaslessStep } from "./utils/isGaslessStep.js";
5
+ import { isEthereumProvider } from "./types.js";
5
6
  import { isDelegationDesignatorCode } from "./permits/isDelegationDesignatorCode.js";
7
+ import { revokeTokenApproval, setAllowance, setTokenAllowance } from "./actions/setAllowance.js";
6
8
  import { PatcherMagicNumber } from "./permits/constants.js";
7
9
  import { getNativePermit } from "./permits/getNativePermit.js";
8
10
  import { isContractCallStep } from "./utils/isContractCallStep.js";
9
- import { isEthereumProvider } from "./types.js";
10
- import { revokeTokenApproval, setAllowance, setTokenAllowance } from "./actions/setAllowance.js";
11
11
  import { isHyperliquidAgentStep, isHyperliquidOrderMessage } from "./hyperliquid/isHyperliquidAgentStep.js";
12
12
  import { convertExtendedChain } from "./utils/convertExtendedChain.js";
13
13
  import { EthereumProvider } from "./EthereumProvider.js";
@@ -1,8 +1,8 @@
1
1
  import { eip2612Abi } from "../utils/abi.js";
2
2
  import { getMulticallAddress } from "../actions/getMulticallAddress.js";
3
3
  import { getActionWithFallback } from "../utils/getActionWithFallback.js";
4
- import { canAccountUseNativePermits } from "./canAccountUseNativePermits.js";
5
4
  import { EIP712_DOMAIN_TYPEHASH, EIP712_DOMAIN_TYPEHASH_WITH_SALT, eip2612Types } from "./constants.js";
5
+ import { canAccountUseNativePermits } from "./canAccountUseNativePermits.js";
6
6
  import { encodeAbiParameters, keccak256, pad, parseAbiParameters, toBytes, toHex, zeroHash } from "viem";
7
7
  import { multicall, readContract } from "viem/actions";
8
8
  //#region src/permits/getNativePermit.ts
@@ -1,5 +1,5 @@
1
1
  //#region src/version.d.ts
2
2
  export declare const name = "@lifi/sdk-provider-ethereum";
3
- export declare const version = "4.2.11";
3
+ export declare const version = "4.2.12";
4
4
  //#endregion
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1,6 +1,6 @@
1
1
  //#region src/version.ts
2
2
  const name = "@lifi/sdk-provider-ethereum";
3
- const version = "4.2.11";
3
+ const version = "4.2.12";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-ethereum'\nexport const version = '4.2.11'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-ethereum'\nexport const version = '4.2.12'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk-provider-ethereum",
3
- "version": "4.2.11",
3
+ "version": "4.2.12",
4
4
  "description": "LI.FI Ethereum SDK Provider for Any-to-Any Cross-Chain-Swap",
5
5
  "homepage": "https://github.com/lifinance/sdk",
6
6
  "bugs": {
@@ -21,6 +21,7 @@ import { getAction } from 'viem/utils'
21
21
  import { parseEthereumErrors } from '../errors/parseEthereumErrors.js'
22
22
  import type { EthereumStepExecutorContext } from '../types.js'
23
23
  import { isZeroAddress } from '../utils/isZeroAddress.js'
24
+ import { EthereumCheckAllowanceAfterPrepareTask } from './tasks/EthereumCheckAllowanceAfterPrepareTask.js'
24
25
  import { EthereumCheckAllowanceTask } from './tasks/EthereumCheckAllowanceTask.js'
25
26
  import { EthereumCheckBalanceTask } from './tasks/EthereumCheckBalanceTask.js'
26
27
  import { EthereumCheckPermitsTask } from './tasks/EthereumCheckPermitsTask.js'
@@ -147,6 +148,7 @@ export class EthereumStepExecutor extends BaseStepExecutor {
147
148
  new EthereumCheckBalanceTask(),
148
149
  new EthereumPermit2AllowanceTask(),
149
150
  new EthereumPrepareTransactionTask(),
151
+ new EthereumCheckAllowanceAfterPrepareTask(),
150
152
  new EthereumSignAndExecuteTask(),
151
153
  new EthereumWaitForTransactionTask(),
152
154
  new EthereumWaitForTransactionStatusTask(),
@@ -0,0 +1,34 @@
1
+ import { BaseStepExecutionTask, TaskPipeline, type TaskResult } from '@lifi/sdk'
2
+ import type { EthereumStepExecutorContext } from '../../types.js'
3
+ import { EthereumCheckAllowanceTask } from './EthereumCheckAllowanceTask.js'
4
+ import { EthereumResetAllowanceTask } from './EthereumResetAllowanceTask.js'
5
+ import { EthereumSetAllowanceTask } from './EthereumSetAllowanceTask.js'
6
+ import { hasApprovalAddressAppearedAtPrepare } from './helpers/hasApprovalAddressAppearedAtPrepare.js'
7
+
8
+ /**
9
+ * Runs after PrepareTransaction. Some providers only know the spender once
10
+ * `/stepTransaction` builds the executable transaction, so the routing-time
11
+ * step carries no `estimate.approvalAddress` and the allowance tasks before
12
+ * prepare do not run. When the re-quote brings one, the allowance is read for
13
+ * it, and reset and set only if it falls short, before the transaction is
14
+ * signed.
15
+ *
16
+ * A spender that was already set before prepare is not checked again here.
17
+ */
18
+ export class EthereumCheckAllowanceAfterPrepareTask extends BaseStepExecutionTask {
19
+ private readonly allowancePipeline = new TaskPipeline([
20
+ new EthereumCheckAllowanceTask(),
21
+ new EthereumResetAllowanceTask(),
22
+ new EthereumSetAllowanceTask(),
23
+ ])
24
+
25
+ override async shouldRun(
26
+ context: EthereumStepExecutorContext
27
+ ): Promise<boolean> {
28
+ return hasApprovalAddressAppearedAtPrepare(context)
29
+ }
30
+
31
+ async run(context: EthereumStepExecutorContext): Promise<TaskResult> {
32
+ return this.allowancePipeline.run(context)
33
+ }
34
+ }
@@ -0,0 +1,29 @@
1
+ import type { EthereumStepExecutorContext } from '../../../types.js'
2
+ import { shouldCheckForAllowance } from './shouldCheckForAllowance.js'
3
+
4
+ /**
5
+ * Whether the step had no `estimate.approvalAddress` before prepare and the
6
+ * re-quote brought one. No allowance was checked then (`allowanceSpender` is
7
+ * unset), and the step now needs it checked. The allowance tasks resolve the
8
+ * spender themselves, so on a Permit2 chain they approve `fromChain.permit2`.
9
+ */
10
+ export const hasApprovalAddressAppearedAtPrepare = (
11
+ context: EthereumStepExecutorContext
12
+ ): boolean => {
13
+ const {
14
+ step,
15
+ allowanceSpender,
16
+ isBridgeExecution,
17
+ isFromNativeToken,
18
+ statusManager,
19
+ } = context
20
+ return (
21
+ !allowanceSpender &&
22
+ shouldCheckForAllowance(
23
+ step,
24
+ isBridgeExecution,
25
+ isFromNativeToken,
26
+ statusManager
27
+ )
28
+ )
29
+ }
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk-provider-ethereum'
2
- export const version = '4.2.11'
2
+ export const version = '4.2.12'