@lifi/sdk-provider-ethereum 4.2.6 → 4.2.8
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 +33 -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.d.ts +25 -1
- package/dist/cjs/actions/waitForBatchTransactionReceipt.js +55 -7
- 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 +1 -1
- package/dist/cjs/core/EthereumStepExecutor.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js +3 -0
- package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumBatchedWaitForTransactionTask.js +7 -3
- package/dist/cjs/core/tasks/EthereumBatchedWaitForTransactionTask.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 +10 -2
- 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.d.ts +25 -1
- package/dist/esm/actions/waitForBatchTransactionReceipt.d.ts.map +1 -1
- package/dist/esm/actions/waitForBatchTransactionReceipt.js +55 -7
- 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 +2 -2
- 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 +4 -1
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumBatchedWaitForTransactionTask.js +7 -3
- package/dist/esm/core/tasks/EthereumBatchedWaitForTransactionTask.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 +10 -2
- 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 +119 -13
- 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 +8 -6
- package/src/core/tasks/EthereumBatchedSignAndExecuteTask.ts +11 -0
- package/src/core/tasks/EthereumBatchedWaitForTransactionTask.ts +17 -13
- 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 +18 -10
- package/src/types.ts +6 -0
- package/src/version.ts +1 -1
|
@@ -10,9 +10,13 @@ var EthereumBatchedWaitForTransactionTask = class extends _lifi_sdk.BaseStepExec
|
|
|
10
10
|
if (!action) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
11
11
|
const updatedClient = await checkClient(step);
|
|
12
12
|
if (!updatedClient) return { status: "PAUSED" };
|
|
13
|
-
const transactionReceipt = await require_actions_waitForBatchTransactionReceipt.waitForBatchTransactionReceipt(updatedClient, action.taskId,
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const transactionReceipt = await require_actions_waitForBatchTransactionReceipt.waitForBatchTransactionReceipt(updatedClient, action.taskId, {
|
|
14
|
+
onFailed: (result) => {
|
|
15
|
+
const receipt = result.receipts?.find((r) => r.status === "reverted");
|
|
16
|
+
if (receipt) require_core_tasks_helpers_updateActionWithReceipt.updateActionWithReceipt(statusManager, step, fromChain, receipt, action);
|
|
17
|
+
},
|
|
18
|
+
signedAt: step.execution?.signedAt,
|
|
19
|
+
callCount: action.callCount
|
|
16
20
|
});
|
|
17
21
|
require_core_tasks_helpers_updateActionWithReceipt.updateActionWithReceipt(statusManager, step, fromChain, transactionReceipt, action);
|
|
18
22
|
if (isBridgeExecution) statusManager.updateAction(step, action.type, "DONE");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumBatchedWaitForTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","waitForBatchTransactionReceipt"],"sources":["../../../../src/core/tasks/EthereumBatchedWaitForTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport { waitForBatchTransactionReceipt } from '../../actions/waitForBatchTransactionReceipt.js'\nimport type {\n EthereumStepExecutorContext,\n WalletCallReceipt,\n} from '../../types.js'\nimport { updateActionWithReceipt } from './helpers/updateActionWithReceipt.js'\n\nexport class EthereumBatchedWaitForTransactionTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const { step, statusManager, fromChain, isBridgeExecution, checkClient } =\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 updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const transactionReceipt = await waitForBatchTransactionReceipt(\n updatedClient,\n action.taskId as Hash,\n (result) => {\n
|
|
1
|
+
{"version":3,"file":"EthereumBatchedWaitForTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","waitForBatchTransactionReceipt"],"sources":["../../../../src/core/tasks/EthereumBatchedWaitForTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport { waitForBatchTransactionReceipt } from '../../actions/waitForBatchTransactionReceipt.js'\nimport type {\n EthereumStepExecutorContext,\n WalletCallReceipt,\n} from '../../types.js'\nimport { updateActionWithReceipt } from './helpers/updateActionWithReceipt.js'\n\nexport class EthereumBatchedWaitForTransactionTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const { step, statusManager, fromChain, isBridgeExecution, checkClient } =\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 updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const transactionReceipt = await waitForBatchTransactionReceipt(\n updatedClient,\n action.taskId as Hash,\n {\n onFailed: (result) => {\n const receipt = result.receipts?.find(\n (r) => r.status === 'reverted'\n ) as WalletCallReceipt | undefined\n if (receipt) {\n updateActionWithReceipt(\n statusManager,\n step,\n fromChain,\n receipt,\n action\n )\n }\n },\n signedAt: step.execution?.signedAt,\n callCount: action.callCount,\n }\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":";;;;;AAcA,IAAa,wCAAb,cAA2DA,UAAAA,sBAAsB;CAC/E,MAAM,IAAI,SAA2D;EACnE,MAAM,EAAE,MAAM,eAAe,WAAW,mBAAmB,gBACzD;EAEF,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EAEA,IAAI,CAAC,QACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAGF,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,qBAAqB,MAAMC,+CAAAA,+BAC/B,eACA,OAAO,QACP;GACE,WAAW,WAAW;IACpB,MAAM,UAAU,OAAO,UAAU,MAC9B,MAAM,EAAE,WAAW,UACtB;IACA,IAAI,SACF,mDAAA,wBACE,eACA,MACA,WACA,SACA,MACF;GAEJ;GACA,UAAU,KAAK,WAAW;GAC1B,WAAW,OAAO;EACpB,CACF;EAEA,mDAAA,wBACE,eACA,MACA,WACA,oBACA,MACF;EAEA,IAAI,mBACF,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAGtD,OAAO,EAAE,QAAQ,YAAY;CAC/B;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_actions_getAllowance = require("../../actions/getAllowance.js");
|
|
3
3
|
const require_core_tasks_helpers_getEthereumExecutionStrategy = require("./helpers/getEthereumExecutionStrategy.js");
|
|
4
|
-
const
|
|
4
|
+
const require_core_tasks_helpers_resolveAllowanceSpender = require("./helpers/resolveAllowanceSpender.js");
|
|
5
5
|
let _lifi_sdk = require("@lifi/sdk");
|
|
6
6
|
//#region src/core/tasks/EthereumCheckAllowanceTask.ts
|
|
7
7
|
var EthereumCheckAllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
@@ -9,7 +9,7 @@ var EthereumCheckAllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
|
9
9
|
return !context.hasMatchingPermit;
|
|
10
10
|
}
|
|
11
11
|
async run(context) {
|
|
12
|
-
const { step, checkClient,
|
|
12
|
+
const { step, checkClient, client, statusManager } = context;
|
|
13
13
|
const action = statusManager.initializeAction({
|
|
14
14
|
step,
|
|
15
15
|
type: "CHECK_ALLOWANCE",
|
|
@@ -17,7 +17,7 @@ var EthereumCheckAllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
|
17
17
|
status: "STARTED"
|
|
18
18
|
});
|
|
19
19
|
const executionStrategy = await require_core_tasks_helpers_getEthereumExecutionStrategy.getEthereumExecutionStrategy(context);
|
|
20
|
-
const spenderAddress = await
|
|
20
|
+
const { spenderAddress } = await require_core_tasks_helpers_resolveAllowanceSpender.resolveAllowanceSpender(context, executionStrategy);
|
|
21
21
|
const fromAmount = BigInt(step.action.fromAmount);
|
|
22
22
|
const updatedClient = await checkClient(step);
|
|
23
23
|
if (!updatedClient) return { status: "PAUSED" };
|
|
@@ -28,7 +28,8 @@ var EthereumCheckAllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
|
28
28
|
context: {
|
|
29
29
|
hasAllowance: allowance > 0n,
|
|
30
30
|
hasSufficientAllowance: fromAmount <= allowance,
|
|
31
|
-
executionStrategy
|
|
31
|
+
executionStrategy,
|
|
32
|
+
allowanceSpender: spenderAddress
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumCheckAllowanceTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","
|
|
1
|
+
{"version":3,"file":"EthereumCheckAllowanceTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","resolveAllowanceSpender","getAllowance"],"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,cAAgDA,UAAAA,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,MAAMC,wDAAAA,6BAA6B,OAAO;EACpE,MAAM,EAAE,mBAAmB,MAAMC,mDAAAA,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,MAAMC,6BAAAA,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"}
|
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_core_tasks_helpers_getEthereumExecutionStrategy = require("./helpers/getEthereumExecutionStrategy.js");
|
|
3
3
|
const require_actions_getMaxPriorityFeePerGas = require("../../actions/getMaxPriorityFeePerGas.js");
|
|
4
4
|
const require_core_tasks_helpers_getUpdatedStep = require("./helpers/getUpdatedStep.js");
|
|
5
|
+
const require_core_tasks_helpers_isAllowancePreparedForAnotherStrategy = require("./helpers/isAllowancePreparedForAnotherStrategy.js");
|
|
5
6
|
const require_core_tasks_helpers_preservePermit2Allowances = require("./helpers/preservePermit2Allowances.js");
|
|
6
7
|
let _lifi_sdk = require("@lifi/sdk");
|
|
7
8
|
//#region src/core/tasks/EthereumPrepareTransactionTask.ts
|
|
@@ -9,6 +10,7 @@ var EthereumPrepareTransactionTask = class extends _lifi_sdk.BaseStepExecutionTa
|
|
|
9
10
|
async run(context) {
|
|
10
11
|
const { step, client, executionOptions, statusManager, allowUserInteraction, checkClient, isBridgeExecution, signedTypedData, ethereumClient, fromChain } = context;
|
|
11
12
|
if (!statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP")) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
13
|
+
const typedDataBeforePrepare = step.typedData;
|
|
12
14
|
const updatedStep = await require_core_tasks_helpers_getUpdatedStep.getUpdatedStep(client, step, fromChain, executionOptions, signedTypedData);
|
|
13
15
|
const comparedStep = await (0, _lifi_sdk.stepComparison)(statusManager, step, updatedStep, allowUserInteraction, executionOptions);
|
|
14
16
|
const answeredTypedData = updatedStep.typedData ?? step.typedData;
|
|
@@ -18,6 +20,14 @@ var EthereumPrepareTransactionTask = class extends _lifi_sdk.BaseStepExecutionTa
|
|
|
18
20
|
typedData: require_core_tasks_helpers_preservePermit2Allowances.preservePermit2Allowances(step, updatedStep.typedData, fromChain)
|
|
19
21
|
});
|
|
20
22
|
if (!step.transactionRequest && !answeredTypedData?.length) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Transaction request is not found.");
|
|
23
|
+
const executionStrategy = await require_core_tasks_helpers_getEthereumExecutionStrategy.getEthereumExecutionStrategy(context, true);
|
|
24
|
+
const allowanceStrategy = context.executionStrategy;
|
|
25
|
+
const isReplay = context.retryParams !== void 0;
|
|
26
|
+
if (allowanceStrategy && (allowanceStrategy === "batched" || isReplay) && await require_core_tasks_helpers_isAllowancePreparedForAnotherStrategy.isAllowancePreparedForAnotherStrategy(context, allowanceStrategy, executionStrategy)) {
|
|
27
|
+
if (isReplay) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, `Unable to prepare transaction. The step resolved to the ${executionStrategy} strategy after its allowance was prepared for ${allowanceStrategy}.`);
|
|
28
|
+
step.typedData = typedDataBeforePrepare;
|
|
29
|
+
throw new _lifi_sdk.ExecuteStepRetryError(`The step resolved to the ${executionStrategy} strategy after its allowance was prepared for ${allowanceStrategy}; retry in that strategy`, { [require_core_tasks_helpers_getEthereumExecutionStrategy.STRATEGY_AFTER_PREPARE]: executionStrategy });
|
|
30
|
+
}
|
|
21
31
|
let transactionRequest;
|
|
22
32
|
if (step.transactionRequest) {
|
|
23
33
|
let maxPriorityFeePerGas;
|
|
@@ -46,7 +56,6 @@ var EthereumPrepareTransactionTask = class extends _lifi_sdk.BaseStepExecutionTa
|
|
|
46
56
|
...customizedTransactionRequest
|
|
47
57
|
};
|
|
48
58
|
}
|
|
49
|
-
const executionStrategy = await require_core_tasks_helpers_getEthereumExecutionStrategy.getEthereumExecutionStrategy(context, true);
|
|
50
59
|
return {
|
|
51
60
|
status: "COMPLETED",
|
|
52
61
|
context: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumPrepareTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","getUpdatedStep","stepComparison","preservePermit2Allowances","
|
|
1
|
+
{"version":3,"file":"EthereumPrepareTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","getUpdatedStep","stepComparison","preservePermit2Allowances","getEthereumExecutionStrategy","isAllowancePreparedForAnotherStrategy","ExecuteStepRetryError","STRATEGY_AFTER_PREPARE","getMaxPriorityFeePerGas"],"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,cAAoDA,UAAAA,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,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAIF,MAAM,yBAAyB,KAAK;EAGpC,MAAM,cAAc,MAAMC,0CAAAA,eACxB,QACA,MACA,WACA,kBACA,eACF;EAEA,MAAM,eAAe,OAAA,GAAMC,UAAAA,eAAAA,CACzB,eACA,MACA,aACA,sBACA,gBACF;EAEA,MAAM,oBAAoB,YAAY,aAAa,KAAK;EAExD,OAAO,OAAO,MAAM;GAClB,GAAG;GACH,WAAW,KAAK;GAChB,WAAWC,qDAAAA,0BACT,MACA,YAAY,WACZ,SACF;EACF,CAAC;EAED,IAAI,CAAC,KAAK,sBAAsB,CAAC,mBAAmB,QAClD,MAAM,IAAIJ,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kEACF;EAIF,MAAM,oBAAoB,MAAMI,wDAAAA,6BAA6B,SAAS,IAAI;EAY1E,MAAM,oBAAoB,QAAQ;EAClC,MAAM,WAAW,QAAQ,gBAAgB,KAAA;EACzC,IACE,sBACC,sBAAsB,aAAa,aACnC,MAAMC,iEAAAA,sCACL,SACA,mBACA,iBACF,GACA;GAEA,IAAI,UACF,MAAM,IAAIN,UAAAA,iBACRC,UAAAA,cAAc,uBACd,2DAA2D,kBAAkB,iDAAiD,kBAAkB,EAClJ;GAEF,KAAK,YAAY;GACjB,MAAM,IAAIM,UAAAA,sBACR,4BAA4B,kBAAkB,iDAAiD,kBAAkB,2BACjH,GAAGC,wDAAAA,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,MAAMC,wCAAAA,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"}
|
|
@@ -14,17 +14,19 @@ var EthereumRelayedSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutio
|
|
|
14
14
|
const allowanceTypedData = step.typedData?.filter((typedData) => !currentSignedTypedData.some((signedPermit) => require_permits_isNativePermitValid.isNativePermitValid(signedPermit, typedData)));
|
|
15
15
|
if (!allowanceTypedData?.length) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Typed data for transfer is not found.");
|
|
16
16
|
const unsignedTypedData = allowanceTypedData.filter((typedData) => !require_core_tasks_helpers_isTypedDataAlreadySigned.isTypedDataAlreadySigned(currentSignedTypedData, typedData));
|
|
17
|
+
const assertNoMergedTransaction = () => (0, _lifi_sdk.assertNoOpenTransaction)(statusManager.findAction(step, action.type));
|
|
17
18
|
let signedTypedData;
|
|
18
19
|
if (require_hyperliquid_isHyperliquidAgentStep.isHyperliquidAgentStep(step)) {
|
|
19
20
|
statusManager.updateAction(step, action.type, "MESSAGE_REQUIRED");
|
|
20
|
-
const signedResults = await require_core_tasks_helpers_signHyperliquidTypedData.signHyperliquidTypedData(context, unsignedTypedData);
|
|
21
|
+
const signedResults = await require_core_tasks_helpers_signHyperliquidTypedData.signHyperliquidTypedData(context, unsignedTypedData, assertNoMergedTransaction);
|
|
21
22
|
if (!signedResults) return { status: "PAUSED" };
|
|
22
23
|
signedTypedData = [...currentSignedTypedData, ...signedResults];
|
|
23
24
|
} else {
|
|
24
|
-
const result = await require_core_tasks_helpers_signTypedDataEntries.signTypedDataEntries(context, unsignedTypedData, action.type, "MESSAGE_REQUIRED");
|
|
25
|
+
const result = await require_core_tasks_helpers_signTypedDataEntries.signTypedDataEntries(context, unsignedTypedData, action.type, "MESSAGE_REQUIRED", assertNoMergedTransaction);
|
|
25
26
|
if (result.status === "PAUSED") return { status: "PAUSED" };
|
|
26
27
|
signedTypedData = result.signedTypedData;
|
|
27
28
|
}
|
|
29
|
+
assertNoMergedTransaction();
|
|
28
30
|
statusManager.updateAction(step, action.type, "PENDING");
|
|
29
31
|
const { execution, ...stepBase } = step;
|
|
30
32
|
const relayedTransaction = await (0, _lifi_sdk.relayTransaction)(client, {
|
|
@@ -32,6 +34,7 @@ var EthereumRelayedSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutio
|
|
|
32
34
|
typedData: signedTypedData
|
|
33
35
|
});
|
|
34
36
|
statusManager.updateAction(step, action.type, "PENDING", {
|
|
37
|
+
..._lifi_sdk.CLEARED_TRANSACTION_FIELDS,
|
|
35
38
|
taskId: relayedTransaction.taskId,
|
|
36
39
|
txType: "relayed",
|
|
37
40
|
txLink: relayedTransaction.txLink,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumRelayedSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","isNativePermitValid","isTypedDataAlreadySigned","isHyperliquidAgentStep","signHyperliquidTypedData","signTypedDataEntries","relayTransaction"],"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":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","isNativePermitValid","isTypedDataAlreadySigned","assertNoOpenTransaction","isHyperliquidAgentStep","signHyperliquidTypedData","signTypedDataEntries","relayTransaction","CLEARED_TRANSACTION_FIELDS"],"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,cAAuDA,UAAAA,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,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAGF,MAAM,qBAAqB,KAAK,WAAW,QACxC,cACC,CAAC,uBAAuB,MAAM,iBAC5BC,oCAAAA,oBAAoB,cAAc,SAAS,CAC7C,CACJ;EACA,IAAI,CAAC,oBAAoB,QACvB,MAAM,IAAIF,UAAAA,iBACRC,UAAAA,cAAc,uBACd,sEACF;EAIF,MAAM,oBAAoB,mBAAmB,QAC1C,cACC,CAACE,oDAAAA,yBAAyB,wBAAwB,SAAS,CAC/D;EAKA,MAAM,mCAAA,GACJC,UAAAA,wBAAAA,CAAwB,cAAc,WAAW,MAAM,OAAO,IAAI,CAAC;EAErE,IAAI;EACJ,IAAIC,2CAAAA,uBAAuB,IAAI,GAAG;GAChC,cAAc,aAAa,MAAM,OAAO,MAAM,kBAAkB;GAEhE,MAAM,gBAAgB,MAAMC,oDAAAA,yBAC1B,SACA,mBACA,yBACF;GAEA,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;GAG5B,kBAAkB,CAAC,GAAG,wBAAwB,GAAG,aAAa;EAChE,OAAO;GACL,MAAM,SAAS,MAAMC,gDAAAA,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,OAAA,GAAMC,UAAAA,iBAAAA,CAAiB,QAAQ;GACxD,GAAG;GACH,WAAW;EACb,CAAC;EAED,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GAGvD,GAAGC,UAAAA;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"}
|
|
@@ -3,12 +3,20 @@ const require_core_tasks_helpers_updateActionWithReceipt = require("./helpers/up
|
|
|
3
3
|
const require_actions_waitForRelayedTransactionReceipt = require("../../actions/waitForRelayedTransactionReceipt.js");
|
|
4
4
|
let _lifi_sdk = require("@lifi/sdk");
|
|
5
5
|
//#region src/core/tasks/EthereumRelayedWaitForTransactionTask.ts
|
|
6
|
+
/** The same check as the SDK's internal `isAbortError`. */
|
|
7
|
+
const isAbortError = (error) => typeof error === "object" && error !== null && "name" in error && error.name === "AbortError";
|
|
6
8
|
var EthereumRelayedWaitForTransactionTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
7
9
|
async run(context) {
|
|
8
|
-
const { client, step, statusManager, fromChain, isBridgeExecution } = context;
|
|
10
|
+
const { client, step, statusManager, fromChain, isBridgeExecution, signal } = context;
|
|
9
11
|
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
10
12
|
if (!action) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
11
|
-
|
|
13
|
+
let transactionReceipt;
|
|
14
|
+
try {
|
|
15
|
+
transactionReceipt = await require_actions_waitForRelayedTransactionReceipt.waitForRelayedTransactionReceipt(client, action.taskId, step, void 0, signal);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (signal?.aborted && isAbortError(error)) return { status: "PAUSED" };
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
12
20
|
require_core_tasks_helpers_updateActionWithReceipt.updateActionWithReceipt(statusManager, step, fromChain, transactionReceipt, action);
|
|
13
21
|
if (isBridgeExecution) statusManager.updateAction(step, action.type, "DONE");
|
|
14
22
|
return { status: "COMPLETED" };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumRelayedWaitForTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","waitForRelayedTransactionReceipt"],"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":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","waitForRelayedTransactionReceipt"],"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,cAA2DA,UAAAA,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,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAGF,IAAI;EACJ,IAAI;GAGF,qBAAqB,MAAMC,iDAAAA,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,mDAAA,wBACE,eACA,MACA,WACA,oBACA,MACF;EAEA,IAAI,mBACF,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAGtD,OAAO,EAAE,QAAQ,YAAY;CAC/B;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_core_tasks_helpers_getEthereumExecutionStrategy = require("./helpers/getEthereumExecutionStrategy.js");
|
|
3
|
-
const
|
|
3
|
+
const require_core_tasks_helpers_resolveAllowanceSpender = require("./helpers/resolveAllowanceSpender.js");
|
|
4
4
|
const require_actions_resolveTransactionHash = require("../../actions/resolveTransactionHash.js");
|
|
5
5
|
const require_actions_setAllowance = require("../../actions/setAllowance.js");
|
|
6
6
|
const require_actions_waitForTransactionReceipt = require("../../actions/waitForTransactionReceipt.js");
|
|
@@ -27,7 +27,7 @@ var EthereumResetAllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
|
27
27
|
if (!allowUserInteraction) return { status: "PAUSED" };
|
|
28
28
|
const executionStrategy = await require_core_tasks_helpers_getEthereumExecutionStrategy.getEthereumExecutionStrategy(context);
|
|
29
29
|
const batchingSupported = executionStrategy === "batched";
|
|
30
|
-
const spenderAddress = await
|
|
30
|
+
const { spenderAddress } = await require_core_tasks_helpers_resolveAllowanceSpender.resolveAllowanceSpender(context, executionStrategy);
|
|
31
31
|
const updatedClient = await checkClient(step);
|
|
32
32
|
if (!updatedClient) return { status: "PAUSED" };
|
|
33
33
|
const resetResult = await require_actions_setAllowance.setAllowance(client, updatedClient, step.action.fromToken.address, spenderAddress, 0n, executionOptions, batchingSupported);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumResetAllowanceTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","
|
|
1
|
+
{"version":3,"file":"EthereumResetAllowanceTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","resolveAllowanceSpender","setAllowance","resolveTransactionHash","getTxLink","waitForTransactionReceipt"],"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,cAAgDA,UAAAA,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,MAAMC,wDAAAA,6BAA6B,OAAO;EACpE,MAAM,oBAAoB,sBAAsB;EAChD,MAAM,EAAE,mBAAmB,MAAMC,mDAAAA,wBAC/B,SACA,iBACF;EAEA,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAI5B,MAAM,cAAc,MAAMC,6BAAAA,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,MAAMC,uCAAAA,uBAC3B,QACA,eACA,aACA,UAAU,EACZ;GACA,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;IACvD,QAAQ;IACR,QAAQC,qCAAAA,UAAU,WAAW,cAAc;GAC7C,CAAC;GAeD,MAAM,aAAY,MAbeC,0CAAAA,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,QAAQD,qCAAAA,UAAU,WAAW,OAAO;KACtC,CAAC;IACH;GACF,CAAC,EAAA,EAEqC,mBAAmB;GACzD,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;IACvD,QAAQ;IACR,QAAQA,qCAAAA,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,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_core_tasks_helpers_getEthereumExecutionStrategy = require("./helpers/getEthereumExecutionStrategy.js");
|
|
3
|
-
const
|
|
3
|
+
const require_core_tasks_helpers_resolveAllowanceSpender = require("./helpers/resolveAllowanceSpender.js");
|
|
4
4
|
const require_actions_resolveTransactionHash = require("../../actions/resolveTransactionHash.js");
|
|
5
5
|
const require_actions_setAllowance = require("../../actions/setAllowance.js");
|
|
6
6
|
const require_actions_waitForTransactionReceipt = require("../../actions/waitForTransactionReceipt.js");
|
|
@@ -27,9 +27,8 @@ var EthereumSetAllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
|
27
27
|
if (!allowUserInteraction) return { status: "PAUSED" };
|
|
28
28
|
const executionStrategy = await require_core_tasks_helpers_getEthereumExecutionStrategy.getEthereumExecutionStrategy(context);
|
|
29
29
|
const batchingSupported = executionStrategy === "batched";
|
|
30
|
-
const permit2Supported = await
|
|
30
|
+
const { permit2Supported, spenderAddress } = await require_core_tasks_helpers_resolveAllowanceSpender.resolveAllowanceSpender(context, executionStrategy);
|
|
31
31
|
const approveAmount = require_core_tasks_helpers_getApprovalAmount.getApprovalAmount(context, permit2Supported);
|
|
32
|
-
const spenderAddress = permit2Supported ? fromChain.permit2 : step.estimate.approvalAddress;
|
|
33
32
|
const updatedClient = await checkClient(step);
|
|
34
33
|
if (!updatedClient) return { status: "PAUSED" };
|
|
35
34
|
const approveResult = await require_actions_setAllowance.setAllowance(client, updatedClient, step.action.fromToken.address, spenderAddress, approveAmount, executionOptions, batchingSupported);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumSetAllowanceTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","
|
|
1
|
+
{"version":3,"file":"EthereumSetAllowanceTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","resolveAllowanceSpender","getApprovalAmount","setAllowance","resolveTransactionHash","getTxLink","waitForTransactionReceipt"],"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,cAA8CA,UAAAA,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,MAAMC,wDAAAA,6BAA6B,OAAO;EACpE,MAAM,oBAAoB,sBAAsB;EAEhD,MAAM,EAAE,kBAAkB,mBAAmB,MAAMC,mDAAAA,wBACjD,SACA,iBACF;EAGA,MAAM,gBAAgBC,6CAAAA,kBAAkB,SAAS,gBAAgB;EAEjE,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,gBAAgB,MAAMC,6BAAAA,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,MAAMC,uCAAAA,uBAC3B,QACA,eACA,eACA,UAAU,EACZ;GACA,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;IACvD,QAAQ;IACR,QAAQC,qCAAAA,UAAU,WAAW,cAAc;GAC7C,CAAC;GAeD,MAAM,aAAY,MAbeC,0CAAAA,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,QAAQD,qCAAAA,UAAU,WAAW,OAAO;KACtC,CAAC;IACH;GACF,CAAC,EAAA,EAEqC,mBAAmB;GACzD,cAAc,aAAa,MAAM,OAAO,MAAM,QAAQ;IACpD,QAAQ;IACR,QAAQA,qCAAAA,UAAU,WAAW,SAAS;GACxC,CAAC;EACH;EAEA,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAO;GAAkB;EACtC;CACF;AACF"}
|
|
@@ -10,6 +10,7 @@ var EthereumSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
|
10
10
|
const { step, statusManager, allowUserInteraction, transactionRequest, isBridgeExecution } = context;
|
|
11
11
|
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
12
12
|
if (!action) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
13
|
+
(0, _lifi_sdk.assertNoOpenTransaction)(action);
|
|
13
14
|
statusManager.updateAction(step, action.type, "ACTION_REQUIRED");
|
|
14
15
|
if (!allowUserInteraction) return { status: "PAUSED" };
|
|
15
16
|
const executionStrategy = await require_core_tasks_helpers_getEthereumExecutionStrategy.getEthereumExecutionStrategy(context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","getEthereumExecutionStrategy","EthereumBatchedSignAndExecuteTask","EthereumRelayedSignAndExecuteTask","EthereumStandardSignAndExecuteTask"],"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":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","getEthereumExecutionStrategy","EthereumBatchedSignAndExecuteTask","EthereumRelayedSignAndExecuteTask","EthereumStandardSignAndExecuteTask"],"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,cAAgDA,UAAAA,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,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAKF,CAAA,GAAA,UAAA,wBAAA,CAAwB,MAAM;EAE9B,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;EAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,oBAAoB,MAAMC,wDAAAA,6BAA6B,OAAO;EACpE,IAAI,sBAAsB,aAAa,oBACrC,OAAO,IAAIC,qDAAAA,kCAAkC,CAAC,CAAC,IAAI,OAAO;EAE5D,IAAI,sBAAsB,WACxB,OAAO,IAAIC,qDAAAA,kCAAkC,CAAC,CAAC,IAAI,OAAO;EAE5D,OAAO,IAAIC,sDAAAA,mCAAmC,CAAC,CAAC,IAAI,OAAO;CAC7D;AACF"}
|
|
@@ -45,6 +45,7 @@ var EthereumStandardSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecuti
|
|
|
45
45
|
};
|
|
46
46
|
finalTransactionRequest = await require_core_tasks_helpers_estimateTransactionRequest.estimateTransactionRequest(client, updatedClient, finalTransactionRequest);
|
|
47
47
|
}
|
|
48
|
+
(0, _lifi_sdk.assertNoOpenTransaction)(statusManager.findAction(step, action.type));
|
|
48
49
|
const txHash = await (0, viem_utils.getAction)(updatedClient, viem_actions.sendTransaction, "sendTransaction")({
|
|
49
50
|
to: finalTransactionRequest.to,
|
|
50
51
|
account: updatedClient.account,
|
|
@@ -58,6 +59,7 @@ var EthereumStandardSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecuti
|
|
|
58
59
|
});
|
|
59
60
|
const resolvedTxHash = await require_actions_resolveTransactionHash.resolveTransactionHash(client, updatedClient, txHash, fromChain.id);
|
|
60
61
|
statusManager.updateAction(step, action.type, "PENDING", {
|
|
62
|
+
..._lifi_sdk.CLEARED_TRANSACTION_FIELDS,
|
|
61
63
|
txHash: resolvedTxHash,
|
|
62
64
|
txLink: require_core_tasks_helpers_getTxLink.getTxLink(fromChain, resolvedTxHash),
|
|
63
65
|
txType: "standard",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumStandardSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","findSignedNativePermit","resolvePermit2Support","encodeNativePermitData","signPermit2Message","encodePermit2Data","estimateTransactionRequest","getAction","sendTransaction","convertExtendedChain","resolveTransactionHash","getTxLink"],"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":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","findSignedNativePermit","resolvePermit2Support","encodeNativePermitData","signPermit2Message","encodePermit2Data","estimateTransactionRequest","getAction","sendTransaction","convertExtendedChain","resolveTransactionHash","CLEARED_TRANSACTION_FIELDS","getTxLink"],"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,cAAwDA,UAAAA,sBAAsB;CAC5E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,WACA,eACA,aACA,oBACA,sBACA,sBACE;EAEJ,IAAI,CAAC,oBACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kEACF;EAGF,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAIF,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,8BAA8BC,kDAAAA,uBAAuB,OAAO;EAKlE,MAAM,mBAAmB,8BACrB,QACA,MAAMC,iDAAAA,sBAAsB,SAAS,UAAU;EACnD,IAAI,6BACF,mBAAmB,OAAOC,uCAAAA,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,MAAMC,mCAAAA,mBAAmB,QAAQ;IACxD,QAAQ;IACR,OAAO;IACP,cAAc,KAAK,OAAO,UAAU;IACpC,QAAQ,OAAO,KAAK,OAAO,UAAU;IACrC,MAAM,mBAAmB;GAC3B,CAAC;GACD,mBAAmB,OAAOC,kCAAAA,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,MAAMC,sDAAAA,2BAC9B,QACA,eACA,uBACF;EACF;EAKA,CAAA,GAAA,UAAA,wBAAA,CAAwB,cAAc,WAAW,MAAM,OAAO,IAAI,CAAC;EAEnE,MAAM,SAAS,OAAA,GAAMC,WAAAA,UAAAA,CACnB,eACAC,aAAAA,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,OAAOC,mCAAAA,qBAAqB,SAAS;EACvC,CAA8B;EAE9B,MAAM,iBAAiB,MAAMC,uCAAAA,uBAC3B,QACA,eACA,QACA,UAAU,EACZ;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GAGvD,GAAGC,UAAAA;GACH,QAAQ;GACR,QAAQC,qCAAAA,UAAU,WAAW,cAAc;GAC3C,QAAQ;GACR,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GACL,QAAQ;GACR,SAAS,EACP,oBAAoB,wBACtB;EACF;CACF;AACF"}
|
|
@@ -5,9 +5,16 @@ const require_core_tasks_EthereumRelayedWaitForTransactionTask = require("./Ethe
|
|
|
5
5
|
const require_core_tasks_EthereumStandardWaitForTransactionTask = require("./EthereumStandardWaitForTransactionTask.js");
|
|
6
6
|
let _lifi_sdk = require("@lifi/sdk");
|
|
7
7
|
//#region src/core/tasks/EthereumWaitForTransactionTask.ts
|
|
8
|
+
const TRANSACTION_METHOD_TYPES = [
|
|
9
|
+
"standard",
|
|
10
|
+
"batched",
|
|
11
|
+
"relayed"
|
|
12
|
+
];
|
|
8
13
|
var EthereumWaitForTransactionTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
9
14
|
async run(context) {
|
|
10
|
-
const
|
|
15
|
+
const { step, statusManager, isBridgeExecution } = context;
|
|
16
|
+
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
17
|
+
const executionStrategy = ((0, _lifi_sdk.hasOpenTransaction)(action) && action?.txType && TRANSACTION_METHOD_TYPES.includes(action.txType) ? action.txType : void 0) ?? await require_core_tasks_helpers_getEthereumExecutionStrategy.getEthereumExecutionStrategy(context);
|
|
11
18
|
if (executionStrategy === "batched") return new require_core_tasks_EthereumBatchedWaitForTransactionTask.EthereumBatchedWaitForTransactionTask().run(context);
|
|
12
19
|
if (executionStrategy === "relayed") return new require_core_tasks_EthereumRelayedWaitForTransactionTask.EthereumRelayedWaitForTransactionTask().run(context);
|
|
13
20
|
return new require_core_tasks_EthereumStandardWaitForTransactionTask.EthereumStandardWaitForTransactionTask().run(context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumWaitForTransactionTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","EthereumBatchedWaitForTransactionTask","EthereumRelayedWaitForTransactionTask","EthereumStandardWaitForTransactionTask"],"sources":["../../../../src/core/tasks/EthereumWaitForTransactionTask.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"EthereumWaitForTransactionTask.js","names":["BaseStepExecutionTask","hasOpenTransaction","getEthereumExecutionStrategy","EthereumBatchedWaitForTransactionTask","EthereumRelayedWaitForTransactionTask","EthereumStandardWaitForTransactionTask"],"sources":["../../../../src/core/tasks/EthereumWaitForTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n hasOpenTransaction,\n type TaskResult,\n type TransactionMethodType,\n} from '@lifi/sdk'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { EthereumBatchedWaitForTransactionTask } from './EthereumBatchedWaitForTransactionTask.js'\nimport { EthereumRelayedWaitForTransactionTask } from './EthereumRelayedWaitForTransactionTask.js'\nimport { EthereumStandardWaitForTransactionTask } from './EthereumStandardWaitForTransactionTask.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\n\nconst TRANSACTION_METHOD_TYPES: readonly TransactionMethodType[] = [\n 'standard',\n 'batched',\n 'relayed',\n]\n\nexport class EthereumWaitForTransactionTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const { step, statusManager, isBridgeExecution } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n // The lane that sent the open transaction waits for it. The sign task\n // stores that lane in `txType`, and a resume keeps it. The step content\n // cannot always tell it again: a step that prepare sent to the relayer\n // only because it had no `transactionRequest` reads as a standard or a\n // batched step on resume. The guard skips a `txType` left on an action\n // without an open transaction. Routes stored without `txType` derive the\n // lane from the step.\n const storedStrategy =\n hasOpenTransaction(action) &&\n action?.txType &&\n TRANSACTION_METHOD_TYPES.includes(action.txType)\n ? action.txType\n : undefined\n const executionStrategy =\n storedStrategy ?? (await getEthereumExecutionStrategy(context))\n if (executionStrategy === 'batched') {\n return new EthereumBatchedWaitForTransactionTask().run(context)\n }\n if (executionStrategy === 'relayed') {\n return new EthereumRelayedWaitForTransactionTask().run(context)\n }\n return new EthereumStandardWaitForTransactionTask().run(context)\n }\n}\n"],"mappings":";;;;;;;AAYA,MAAM,2BAA6D;CACjE;CACA;CACA;AACF;AAEA,IAAa,iCAAb,cAAoDA,UAAAA,sBAAsB;CACxE,MAAM,IAAI,SAA2D;EACnE,MAAM,EAAE,MAAM,eAAe,sBAAsB;EAEnD,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EAcA,MAAM,sBAAA,GALJC,UAAAA,mBAAAA,CAAmB,MAAM,KACzB,QAAQ,UACR,yBAAyB,SAAS,OAAO,MAAM,IAC3C,OAAO,SACP,KAAA,MAEe,MAAMC,wDAAAA,6BAA6B,OAAO;EAC/D,IAAI,sBAAsB,WACxB,OAAO,IAAIC,yDAAAA,sCAAsC,CAAC,CAAC,IAAI,OAAO;EAEhE,IAAI,sBAAsB,WACxB,OAAO,IAAIC,yDAAAA,sCAAsC,CAAC,CAAC,IAAI,OAAO;EAEhE,OAAO,IAAIC,0DAAAA,uCAAuC,CAAC,CAAC,IAAI,OAAO;CACjE;AACF"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { EthereumStepExecutorContext } from "../../../types.js";
|
|
2
2
|
import { TransactionMethodType } from "@lifi/sdk";
|
|
3
3
|
//#region src/core/tasks/helpers/getEthereumExecutionStrategy.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Retry param set by `EthereumPrepareTransactionTask`: the strategy prepare
|
|
6
|
+
* established when the allowance work done for `batched` did not fit it. The
|
|
7
|
+
* replay starts in this strategy.
|
|
8
|
+
*/
|
|
9
|
+
export declare const STRATEGY_AFTER_PREPARE = "strategyAfterPrepare";
|
|
4
10
|
/**
|
|
5
11
|
* Determines the execution strategy: 'relayed', 'batched', or 'standard'.
|
|
6
12
|
* Falls back to 'standard' when EIP-5792 batching is unavailable,
|
|
@@ -3,6 +3,18 @@ const require_actions_isBatchingSupported = require("../../../actions/isBatching
|
|
|
3
3
|
const require_utils_getTypedDataLane = require("../../../utils/getTypedDataLane.js");
|
|
4
4
|
//#region src/core/tasks/helpers/getEthereumExecutionStrategy.ts
|
|
5
5
|
/**
|
|
6
|
+
* Retry param set by `EthereumPrepareTransactionTask`: the strategy prepare
|
|
7
|
+
* established when the allowance work done for `batched` did not fit it. The
|
|
8
|
+
* replay starts in this strategy.
|
|
9
|
+
*/
|
|
10
|
+
const STRATEGY_AFTER_PREPARE = "strategyAfterPrepare";
|
|
11
|
+
const TRANSACTION_METHOD_TYPES = {
|
|
12
|
+
standard: true,
|
|
13
|
+
relayed: true,
|
|
14
|
+
batched: true
|
|
15
|
+
};
|
|
16
|
+
const isTransactionMethodType = (value) => typeof value === "string" && Object.hasOwn(TRANSACTION_METHOD_TYPES, value);
|
|
17
|
+
/**
|
|
6
18
|
* Determines the execution strategy: 'relayed', 'batched', or 'standard'.
|
|
7
19
|
* Falls back to 'standard' when EIP-5792 batching is unavailable,
|
|
8
20
|
* the wallet rejected the 7702 upgrade, or the tool doesn't support it.
|
|
@@ -16,6 +28,8 @@ const require_utils_getTypedDataLane = require("../../../utils/getTypedDataLane.
|
|
|
16
28
|
async function getEthereumExecutionStrategy(context, afterPrepare = false) {
|
|
17
29
|
const { step, checkClient, retryParams, client, fromChain, ethereumClient, executionStrategy: executionStrategyContext } = context;
|
|
18
30
|
if (!afterPrepare && executionStrategyContext) return executionStrategyContext;
|
|
31
|
+
const strategyAfterPrepare = retryParams?.[STRATEGY_AFTER_PREPARE];
|
|
32
|
+
if (!afterPrepare && isTransactionMethodType(strategyAfterPrepare)) return strategyAfterPrepare;
|
|
19
33
|
const atomicityNotReady = !!retryParams?.atomicityNotReady;
|
|
20
34
|
if (step.executionType === "message") return "relayed";
|
|
21
35
|
if (step.typedData?.length && !require_utils_getTypedDataLane.isPermit2AllowanceLane(step, fromChain)) return "relayed";
|
|
@@ -28,6 +42,7 @@ async function getEthereumExecutionStrategy(context, afterPrepare = false) {
|
|
|
28
42
|
}) ? "batched" : "standard";
|
|
29
43
|
}
|
|
30
44
|
//#endregion
|
|
45
|
+
exports.STRATEGY_AFTER_PREPARE = STRATEGY_AFTER_PREPARE;
|
|
31
46
|
exports.getEthereumExecutionStrategy = getEthereumExecutionStrategy;
|
|
32
47
|
|
|
33
48
|
//# sourceMappingURL=getEthereumExecutionStrategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEthereumExecutionStrategy.js","names":["isPermit2AllowanceLane","isBatchingSupported"],"sources":["../../../../../src/core/tasks/helpers/getEthereumExecutionStrategy.ts"],"sourcesContent":["import type { TransactionMethodType } from '@lifi/sdk'\nimport { isBatchingSupported } from '../../../actions/isBatchingSupported.js'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { isPermit2AllowanceLane } from '../../../utils/getTypedDataLane.js'\n\n/**\n * Determines the execution strategy: 'relayed', 'batched', or 'standard'.\n * Falls back to 'standard' when EIP-5792 batching is unavailable,\n * the wallet rejected the 7702 upgrade, or the tool doesn't support it.\n *\n * `afterPrepare` marks the single call from `EthereumPrepareTransactionTask`.\n * The step has just been re-quoted, so the cached verdict is stale and, for the\n * first time, the absence of a `transactionRequest` is final rather than merely\n * not-yet-known. Both effects come from that one fact, which is why they share\n * a parameter.\n */\nexport async function getEthereumExecutionStrategy(\n context: EthereumStepExecutorContext,\n afterPrepare: boolean = false\n): Promise<TransactionMethodType> {\n const {\n step,\n checkClient,\n retryParams,\n client,\n fromChain,\n ethereumClient,\n executionStrategy: executionStrategyContext,\n } = context\n\n if (!afterPrepare && executionStrategyContext) {\n return executionStrategyContext\n }\n\n const atomicityNotReady = !!retryParams?.atomicityNotReady\n // Declared by the backend. It is the only signal that reaches the allowance\n // tasks, which run before a `transactionRequest` can exist.\n if (step.executionType === 'message') {\n return 'relayed'\n }\n\n // Typed data the user does not sign for its own send: gasless, `Order`,\n // Hyperliquid. A Permit2 allowance is the one shape excluded, because its signer\n // and its sender are the same person.\n if (step.typedData?.length && !isPermit2AllowanceLane(step, fromChain)) {\n return 'relayed'\n }\n\n // After prepare, missing means never: the step carries typed data and the user\n // has nothing to send, so the relayer is the only lane that can execute it.\n // This is a derivation, not a guess — no other strategy can run such a step.\n //\n // Before prepare the same expression is unsound. A Permit2 allowance that will\n // receive its transaction from `/stepTransaction` is indistinguishable from\n // one that never will, and calling it relayed there costs the step its\n // EIP-5792 batching.\n if (afterPrepare && step.typedData?.length && !step.transactionRequest) {\n return 'relayed'\n }\n\n if (atomicityNotReady || step.tool === 'thorswap') {\n return 'standard'\n }\n\n const updatedClient = (await checkClient(step)) ?? ethereumClient\n const batchingSupported = await isBatchingSupported(client, {\n client: updatedClient,\n chainId: fromChain.id,\n })\n return batchingSupported ? 'batched' : 'standard'\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getEthereumExecutionStrategy.js","names":["isPermit2AllowanceLane","isBatchingSupported"],"sources":["../../../../../src/core/tasks/helpers/getEthereumExecutionStrategy.ts"],"sourcesContent":["import type { TransactionMethodType } from '@lifi/sdk'\nimport { isBatchingSupported } from '../../../actions/isBatchingSupported.js'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { isPermit2AllowanceLane } from '../../../utils/getTypedDataLane.js'\n\n/**\n * Retry param set by `EthereumPrepareTransactionTask`: the strategy prepare\n * established when the allowance work done for `batched` did not fit it. The\n * replay starts in this strategy.\n */\nexport const STRATEGY_AFTER_PREPARE = 'strategyAfterPrepare'\n\n// A `Record` over the union, so a new strategy fails to compile here instead of\n// being ignored by the replay.\nconst TRANSACTION_METHOD_TYPES: Record<TransactionMethodType, true> = {\n standard: true,\n relayed: true,\n batched: true,\n}\n\nconst isTransactionMethodType = (\n value: unknown\n): value is TransactionMethodType =>\n typeof value === 'string' && Object.hasOwn(TRANSACTION_METHOD_TYPES, value)\n\n/**\n * Determines the execution strategy: 'relayed', 'batched', or 'standard'.\n * Falls back to 'standard' when EIP-5792 batching is unavailable,\n * the wallet rejected the 7702 upgrade, or the tool doesn't support it.\n *\n * `afterPrepare` marks the single call from `EthereumPrepareTransactionTask`.\n * The step has just been re-quoted, so the cached verdict is stale and, for the\n * first time, the absence of a `transactionRequest` is final rather than merely\n * not-yet-known. Both effects come from that one fact, which is why they share\n * a parameter.\n */\nexport async function getEthereumExecutionStrategy(\n context: EthereumStepExecutorContext,\n afterPrepare: boolean = false\n): Promise<TransactionMethodType> {\n const {\n step,\n checkClient,\n retryParams,\n client,\n fromChain,\n ethereumClient,\n executionStrategy: executionStrategyContext,\n } = context\n\n if (!afterPrepare && executionStrategyContext) {\n return executionStrategyContext\n }\n\n // A replay starts in the strategy its first prepare established. Prepare\n // restored the step's typed data before the replay, so nothing on the step\n // shows that strategy yet.\n const strategyAfterPrepare = retryParams?.[STRATEGY_AFTER_PREPARE]\n if (!afterPrepare && isTransactionMethodType(strategyAfterPrepare)) {\n return strategyAfterPrepare\n }\n\n const atomicityNotReady = !!retryParams?.atomicityNotReady\n // Declared by the backend. It is the only signal that reaches the allowance\n // tasks, which run before a `transactionRequest` can exist.\n if (step.executionType === 'message') {\n return 'relayed'\n }\n\n // Typed data the user does not sign for its own send: gasless, `Order`,\n // Hyperliquid. A Permit2 allowance is the one shape excluded, because its signer\n // and its sender are the same person.\n if (step.typedData?.length && !isPermit2AllowanceLane(step, fromChain)) {\n return 'relayed'\n }\n\n // After prepare, missing means never: the step carries typed data and the user\n // has nothing to send, so the relayer is the only lane that can execute it.\n // This is a derivation, not a guess — no other strategy can run such a step.\n //\n // Before prepare the same expression is unsound. A Permit2 allowance that will\n // receive its transaction from `/stepTransaction` is indistinguishable from\n // one that never will, and calling it relayed there costs the step its\n // EIP-5792 batching.\n if (afterPrepare && step.typedData?.length && !step.transactionRequest) {\n return 'relayed'\n }\n\n if (atomicityNotReady || step.tool === 'thorswap') {\n return 'standard'\n }\n\n const updatedClient = (await checkClient(step)) ?? ethereumClient\n const batchingSupported = await isBatchingSupported(client, {\n client: updatedClient,\n chainId: fromChain.id,\n })\n return batchingSupported ? 'batched' : 'standard'\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,yBAAyB;AAItC,MAAM,2BAAgE;CACpE,UAAU;CACV,SAAS;CACT,SAAS;AACX;AAEA,MAAM,2BACJ,UAEA,OAAO,UAAU,YAAY,OAAO,OAAO,0BAA0B,KAAK;;;;;;;;;;;;AAa5E,eAAsB,6BACpB,SACA,eAAwB,OACQ;CAChC,MAAM,EACJ,MACA,aACA,aACA,QACA,WACA,gBACA,mBAAmB,6BACjB;CAEJ,IAAI,CAAC,gBAAgB,0BACnB,OAAO;CAMT,MAAM,uBAAuB,cAAc;CAC3C,IAAI,CAAC,gBAAgB,wBAAwB,oBAAoB,GAC/D,OAAO;CAGT,MAAM,oBAAoB,CAAC,CAAC,aAAa;CAGzC,IAAI,KAAK,kBAAkB,WACzB,OAAO;CAMT,IAAI,KAAK,WAAW,UAAU,CAACA,+BAAAA,uBAAuB,MAAM,SAAS,GACnE,OAAO;CAWT,IAAI,gBAAgB,KAAK,WAAW,UAAU,CAAC,KAAK,oBAClD,OAAO;CAGT,IAAI,qBAAqB,KAAK,SAAS,YACrC,OAAO;CAGT,MAAM,gBAAiB,MAAM,YAAY,IAAI,KAAM;CAKnD,OAAO,MAJyBC,oCAAAA,oBAAoB,QAAQ;EAC1D,QAAQ;EACR,SAAS,UAAU;CACrB,CAAC,IAC0B,YAAY;AACzC"}
|