@lifi/sdk-provider-ethereum 4.1.0 → 4.2.1
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 +32 -0
- package/README.md +24 -8
- package/dist/cjs/core/EthereumStepExecutor.js +2 -0
- package/dist/cjs/core/EthereumStepExecutor.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.d.ts +2 -2
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.js +6 -5
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumCheckPermitsTask.js +11 -29
- package/dist/cjs/core/tasks/EthereumCheckPermitsTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumNativePermitTask.js +2 -0
- package/dist/cjs/core/tasks/EthereumNativePermitTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumPermit2AllowanceTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumPermit2AllowanceTask.js +33 -0
- package/dist/cjs/core/tasks/EthereumPermit2AllowanceTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js +6 -4
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js +14 -27
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.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/EthereumStandardSignAndExecuteTask.js +3 -4
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/findSignedNativePermit.d.ts +7 -0
- package/dist/cjs/core/tasks/helpers/findSignedNativePermit.js +15 -0
- package/dist/cjs/core/tasks/helpers/findSignedNativePermit.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getApprovalAmount.d.ts +6 -0
- package/dist/cjs/core/tasks/helpers/getApprovalAmount.js +16 -0
- package/dist/cjs/core/tasks/helpers/getApprovalAmount.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +7 -1
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js +12 -4
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.d.ts +3 -2
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.js +4 -4
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/hasPermit2AllowanceInFlight.d.ts +8 -0
- package/dist/cjs/core/tasks/helpers/hasPermit2AllowanceInFlight.js +17 -0
- package/dist/cjs/core/tasks/helpers/hasPermit2AllowanceInFlight.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/isTypedDataAlreadySigned.d.ts +6 -0
- package/dist/cjs/core/tasks/helpers/isTypedDataAlreadySigned.js +29 -0
- package/dist/cjs/core/tasks/helpers/isTypedDataAlreadySigned.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/preservePermit2Allowances.d.ts +11 -0
- package/dist/cjs/core/tasks/helpers/preservePermit2Allowances.js +22 -0
- package/dist/cjs/core/tasks/helpers/preservePermit2Allowances.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/resolvePermit2Support.js +2 -1
- package/dist/cjs/core/tasks/helpers/resolvePermit2Support.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.d.ts +1 -1
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js +3 -3
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.d.ts +13 -0
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js +37 -0
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/utils/getTypedDataLane.d.ts +15 -0
- package/dist/cjs/utils/getTypedDataLane.js +33 -0
- package/dist/cjs/utils/getTypedDataLane.js.map +1 -0
- package/dist/cjs/utils/isGaslessStep.d.ts +3 -1
- package/dist/cjs/utils/isGaslessStep.js +7 -1
- package/dist/cjs/utils/isGaslessStep.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/core/EthereumStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/EthereumStepExecutor.js +2 -0
- package/dist/esm/core/EthereumStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.d.ts +2 -2
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.js +6 -5
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.js +11 -29
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumNativePermitTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumNativePermitTask.js +2 -0
- package/dist/esm/core/tasks/EthereumNativePermitTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.js +32 -0
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js +6 -4
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js +14 -27
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.js +2 -3
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js +3 -4
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.d.ts +7 -0
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.js +14 -0
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.d.ts +6 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.js +15 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +7 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js +12 -4
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
- package/dist/esm/core/tasks/helpers/getUpdatedStep.d.ts +3 -2
- package/dist/esm/core/tasks/helpers/getUpdatedStep.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getUpdatedStep.js +4 -4
- package/dist/esm/core/tasks/helpers/getUpdatedStep.js.map +1 -1
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.d.ts +8 -0
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.js +15 -0
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.js.map +1 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.d.ts +6 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.js +28 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.js.map +1 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.d.ts +11 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.js +21 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.js.map +1 -0
- package/dist/esm/core/tasks/helpers/resolvePermit2Support.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/resolvePermit2Support.js +2 -1
- package/dist/esm/core/tasks/helpers/resolvePermit2Support.js.map +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js +3 -3
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts +13 -0
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.js +36 -0
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.js.map +1 -0
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +2 -3
- package/dist/esm/utils/getTypedDataLane.d.ts +15 -0
- package/dist/esm/utils/getTypedDataLane.d.ts.map +1 -0
- package/dist/esm/utils/getTypedDataLane.js +28 -0
- package/dist/esm/utils/getTypedDataLane.js.map +1 -0
- package/dist/esm/utils/isGaslessStep.d.ts +3 -1
- package/dist/esm/utils/isGaslessStep.d.ts.map +1 -1
- package/dist/esm/utils/isGaslessStep.js +7 -2
- package/dist/esm/utils/isGaslessStep.js.map +1 -1
- package/dist/esm/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/core/EthereumStepExecutor.ts +2 -0
- package/src/core/tasks/EthereumCheckBalanceTask.ts +6 -7
- package/src/core/tasks/EthereumCheckPermitsTask.ts +31 -63
- package/src/core/tasks/EthereumNativePermitTask.ts +5 -0
- package/src/core/tasks/EthereumPermit2AllowanceTask.ts +53 -0
- package/src/core/tasks/EthereumPrepareTransactionTask.ts +11 -2
- package/src/core/tasks/EthereumRelayedSignAndExecuteTask.ts +25 -47
- package/src/core/tasks/EthereumSetAllowanceTask.ts +2 -3
- package/src/core/tasks/EthereumStandardSignAndExecuteTask.ts +2 -9
- package/src/core/tasks/helpers/findSignedNativePermit.ts +23 -0
- package/src/core/tasks/helpers/getApprovalAmount.ts +30 -0
- package/src/core/tasks/helpers/getEthereumExecutionStrategy.ts +31 -5
- package/src/core/tasks/helpers/getUpdatedStep.ts +7 -2
- package/src/core/tasks/helpers/hasPermit2AllowanceInFlight.ts +31 -0
- package/src/core/tasks/helpers/isTypedDataAlreadySigned.ts +56 -0
- package/src/core/tasks/helpers/preservePermit2Allowances.ts +44 -0
- package/src/core/tasks/helpers/resolvePermit2Support.ts +3 -1
- package/src/core/tasks/helpers/signHyperliquidTypedData.ts +3 -3
- package/src/core/tasks/helpers/signTypedDataEntries.ts +70 -0
- package/src/index.ts +0 -1
- package/src/utils/getTypedDataLane.ts +76 -0
- package/src/utils/isGaslessStep.ts +22 -9
- package/src/version.ts +1 -1
- package/dist/cjs/utils/isRelayerStep.d.ts +0 -6
- package/dist/cjs/utils/isRelayerStep.js +0 -9
- package/dist/cjs/utils/isRelayerStep.js.map +0 -1
- package/dist/esm/utils/isRelayerStep.d.ts +0 -6
- package/dist/esm/utils/isRelayerStep.d.ts.map +0 -1
- package/dist/esm/utils/isRelayerStep.js +0 -8
- package/dist/esm/utils/isRelayerStep.js.map +0 -1
- package/src/utils/isRelayerStep.ts +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumRelayedSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","isNativePermitValid","
|
|
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":";;;;;;;;AAgBA,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;EAEA,IAAI;EACJ,IAAIC,2CAAAA,uBAAuB,IAAI,GAAG;GAChC,cAAc,aAAa,MAAM,OAAO,MAAM,kBAAkB;GAEhE,MAAM,gBAAgB,MAAMC,oDAAAA,yBAC1B,SACA,iBACF;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,kBACF;GACA,IAAI,OAAO,WAAW,UACpB,OAAO,EAAE,QAAQ,SAAS;GAE5B,kBAAkB,OAAO;EAC3B;EAEA,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;GACvD,QAAQ,mBAAmB;GAC3B,QAAQ;GACR,QAAQ,mBAAmB;GAC3B,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GAAE,QAAQ;GAAa,SAAS,EAAE,gBAAgB;EAAE;CAC7D;AACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_core_tasks_helpers_getEthereumExecutionStrategy = require("./helpers/getEthereumExecutionStrategy.js");
|
|
3
3
|
const require_core_tasks_helpers_resolvePermit2Support = require("./helpers/resolvePermit2Support.js");
|
|
4
|
-
const require_permits_constants = require("../../permits/constants.js");
|
|
5
4
|
const require_actions_resolveTransactionHash = require("../../actions/resolveTransactionHash.js");
|
|
6
5
|
const require_actions_setAllowance = require("../../actions/setAllowance.js");
|
|
7
6
|
const require_actions_waitForTransactionReceipt = require("../../actions/waitForTransactionReceipt.js");
|
|
8
7
|
const require_core_tasks_helpers_getTxLink = require("./helpers/getTxLink.js");
|
|
8
|
+
const require_core_tasks_helpers_getApprovalAmount = require("./helpers/getApprovalAmount.js");
|
|
9
9
|
let _lifi_sdk = require("@lifi/sdk");
|
|
10
10
|
//#region src/core/tasks/EthereumSetAllowanceTask.ts
|
|
11
11
|
var EthereumSetAllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
@@ -28,8 +28,7 @@ var EthereumSetAllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
|
28
28
|
const executionStrategy = await require_core_tasks_helpers_getEthereumExecutionStrategy.getEthereumExecutionStrategy(context);
|
|
29
29
|
const batchingSupported = executionStrategy === "batched";
|
|
30
30
|
const permit2Supported = await require_core_tasks_helpers_resolvePermit2Support.resolvePermit2Support(context, executionStrategy);
|
|
31
|
-
const
|
|
32
|
-
const approveAmount = permit2Supported ? require_permits_constants.MaxUint256 : fromAmount;
|
|
31
|
+
const approveAmount = require_core_tasks_helpers_getApprovalAmount.getApprovalAmount(context, permit2Supported);
|
|
33
32
|
const spenderAddress = permit2Supported ? fromChain.permit2 : step.estimate.approvalAddress;
|
|
34
33
|
const updatedClient = await checkClient(step);
|
|
35
34
|
if (!updatedClient) return { status: "PAUSED" };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumSetAllowanceTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","resolvePermit2Support","
|
|
1
|
+
{"version":3,"file":"EthereumSetAllowanceTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","resolvePermit2Support","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 { resolvePermit2Support } from './helpers/resolvePermit2Support.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 const permit2Supported = await resolvePermit2Support(\n context,\n executionStrategy\n )\n\n // Set new allowance\n const approveAmount = getApprovalAmount(context, permit2Supported)\n\n // Check if chain has Permit2 contract deployed. Permit2 should not be available for atomic batch.\n const spenderAddress = permit2Supported\n ? fromChain.permit2\n : step.estimate.approvalAddress\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 as Address,\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;EAChD,MAAM,mBAAmB,MAAMC,iDAAAA,sBAC7B,SACA,iBACF;EAGA,MAAM,gBAAgBC,6CAAAA,kBAAkB,SAAS,gBAAgB;EAGjE,MAAM,iBAAiB,mBACnB,UAAU,UACV,KAAK,SAAS;EAElB,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"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_core_tasks_helpers_resolvePermit2Support = require("./helpers/resolvePermit2Support.js");
|
|
3
|
-
const require_utils_getDomainChainId = require("../../utils/getDomainChainId.js");
|
|
4
|
-
const require_utils_isValidSignature = require("../../utils/isValidSignature.js");
|
|
5
3
|
const require_actions_resolveTransactionHash = require("../../actions/resolveTransactionHash.js");
|
|
6
4
|
const require_core_tasks_helpers_getTxLink = require("./helpers/getTxLink.js");
|
|
7
5
|
const require_permits_encodeNativePermitData = require("../../permits/encodeNativePermitData.js");
|
|
@@ -9,19 +7,20 @@ const require_permits_encodePermit2Data = require("../../permits/encodePermit2Da
|
|
|
9
7
|
const require_permits_signPermit2Message = require("../../permits/signPermit2Message.js");
|
|
10
8
|
const require_utils_convertExtendedChain = require("../../utils/convertExtendedChain.js");
|
|
11
9
|
const require_core_tasks_helpers_estimateTransactionRequest = require("./helpers/estimateTransactionRequest.js");
|
|
10
|
+
const require_core_tasks_helpers_findSignedNativePermit = require("./helpers/findSignedNativePermit.js");
|
|
12
11
|
let _lifi_sdk = require("@lifi/sdk");
|
|
13
12
|
let viem_actions = require("viem/actions");
|
|
14
13
|
let viem_utils = require("viem/utils");
|
|
15
14
|
//#region src/core/tasks/EthereumStandardSignAndExecuteTask.ts
|
|
16
15
|
var EthereumStandardSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
17
16
|
async run(context) {
|
|
18
|
-
const { step, client, fromChain, statusManager, checkClient, transactionRequest,
|
|
17
|
+
const { step, client, fromChain, statusManager, checkClient, transactionRequest, allowUserInteraction, isBridgeExecution } = context;
|
|
19
18
|
if (!transactionRequest) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Transaction request is not found.");
|
|
20
19
|
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
21
20
|
if (!action) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
22
21
|
const updatedClient = await checkClient(step);
|
|
23
22
|
if (!updatedClient) return { status: "PAUSED" };
|
|
24
|
-
const signedNativePermitTypedData =
|
|
23
|
+
const signedNativePermitTypedData = require_core_tasks_helpers_findSignedNativePermit.findSignedNativePermit(context);
|
|
25
24
|
const permit2Supported = signedNativePermitTypedData ? false : await require_core_tasks_helpers_resolvePermit2Support.resolvePermit2Support(context, "standard");
|
|
26
25
|
if (signedNativePermitTypedData) transactionRequest.data = require_permits_encodeNativePermitData.encodeNativePermitData(step.action.fromToken.address, BigInt(step.action.fromAmount), signedNativePermitTypedData.message.deadline, signedNativePermitTypedData.signature, transactionRequest.data);
|
|
27
26
|
else if (permit2Supported) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumStandardSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","
|
|
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":";;;;;;;;;;;;;;AAoBA,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;EAEA,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;GACvD,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EthereumStepExecutorContext } from "../../../types.js";
|
|
2
|
+
import { SignedTypedData } from "@lifi/sdk";
|
|
3
|
+
//#region src/core/tasks/helpers/findSignedNativePermit.d.ts
|
|
4
|
+
/** The signed native EIP-2612 permit this step should execute through, if any. */
|
|
5
|
+
export declare function findSignedNativePermit(context: EthereumStepExecutorContext): SignedTypedData | undefined;
|
|
6
|
+
//#endregion
|
|
7
|
+
//# sourceMappingURL=findSignedNativePermit.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_core_tasks_helpers_hasPermit2AllowanceInFlight = require("./hasPermit2AllowanceInFlight.js");
|
|
3
|
+
const require_utils_getDomainChainId = require("../../../utils/getDomainChainId.js");
|
|
4
|
+
const require_utils_isValidSignature = require("../../../utils/isValidSignature.js");
|
|
5
|
+
//#region src/core/tasks/helpers/findSignedNativePermit.ts
|
|
6
|
+
/** The signed native EIP-2612 permit this step should execute through, if any. */
|
|
7
|
+
function findSignedNativePermit(context) {
|
|
8
|
+
const { fromChain, signedTypedData } = context;
|
|
9
|
+
if (require_core_tasks_helpers_hasPermit2AllowanceInFlight.isPermit2AllowanceLaneInFlight(context)) return;
|
|
10
|
+
return signedTypedData.find((typedData) => typedData.primaryType === "Permit" && require_utils_getDomainChainId.getDomainChainId(typedData.domain) === fromChain.id && require_utils_isValidSignature.isValidSignature(typedData.signature));
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.findSignedNativePermit = findSignedNativePermit;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=findSignedNativePermit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findSignedNativePermit.js","names":["isPermit2AllowanceLaneInFlight","getDomainChainId","isValidSignature"],"sources":["../../../../../src/core/tasks/helpers/findSignedNativePermit.ts"],"sourcesContent":["import type { SignedTypedData } from '@lifi/sdk'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { getDomainChainId } from '../../../utils/getDomainChainId.js'\nimport { isValidSignature } from '../../../utils/isValidSignature.js'\nimport { isPermit2AllowanceLaneInFlight } from './hasPermit2AllowanceInFlight.js'\n\n/** The signed native EIP-2612 permit this step should execute through, if any. */\nexport function findSignedNativePermit(\n context: EthereumStepExecutorContext\n): SignedTypedData | undefined {\n const { fromChain, signedTypedData } = context\n\n if (isPermit2AllowanceLaneInFlight(context)) {\n return undefined\n }\n\n return signedTypedData.find(\n (typedData) =>\n typedData.primaryType === 'Permit' &&\n getDomainChainId(typedData.domain) === fromChain.id &&\n isValidSignature(typedData.signature)\n )\n}\n"],"mappings":";;;;;;AAOA,SAAgB,uBACd,SAC6B;CAC7B,MAAM,EAAE,WAAW,oBAAoB;CAEvC,IAAIA,uDAAAA,+BAA+B,OAAO,GACxC;CAGF,OAAO,gBAAgB,MACpB,cACC,UAAU,gBAAgB,YAC1BC,+BAAAA,iBAAiB,UAAU,MAAM,MAAM,UAAU,MACjDC,+BAAAA,iBAAiB,UAAU,SAAS,CACxC;AACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EthereumStepExecutorContext } from "../../../types.js";
|
|
2
|
+
//#region src/core/tasks/helpers/getApprovalAmount.d.ts
|
|
3
|
+
/** How much of the source token to approve to the step's approval address. */
|
|
4
|
+
export declare function getApprovalAmount(context: EthereumStepExecutorContext, permit2Supported: boolean): bigint;
|
|
5
|
+
//#endregion
|
|
6
|
+
//# sourceMappingURL=getApprovalAmount.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_getTypedDataLane = require("../../../utils/getTypedDataLane.js");
|
|
3
|
+
const require_permits_constants = require("../../../permits/constants.js");
|
|
4
|
+
//#region src/core/tasks/helpers/getApprovalAmount.ts
|
|
5
|
+
/** How much of the source token to approve to the step's approval address. */
|
|
6
|
+
function getApprovalAmount(context, permit2Supported) {
|
|
7
|
+
const { step, fromChain, disableMessageSigning } = context;
|
|
8
|
+
if (permit2Supported) return require_permits_constants.MaxUint256;
|
|
9
|
+
const permit2Allowances = disableMessageSigning ? [] : require_utils_getTypedDataLane.getTypedDataInLane(step, "permit2-allowance", fromChain);
|
|
10
|
+
const approvalAddress = step.estimate.approvalAddress?.toLowerCase();
|
|
11
|
+
return permit2Allowances.length > 0 && !!approvalAddress && permit2Allowances.every((typedData) => typedData.domain.verifyingContract?.toLowerCase() === approvalAddress) ? require_permits_constants.MaxUint256 : BigInt(step.action.fromAmount);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.getApprovalAmount = getApprovalAmount;
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=getApprovalAmount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getApprovalAmount.js","names":["MaxUint256","getTypedDataInLane"],"sources":["../../../../../src/core/tasks/helpers/getApprovalAmount.ts"],"sourcesContent":["import { MaxUint256 } from '../../../permits/constants.js'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { getTypedDataInLane } from '../../../utils/getTypedDataLane.js'\n\n/** How much of the source token to approve to the step's approval address. */\nexport function getApprovalAmount(\n context: EthereumStepExecutorContext,\n permit2Supported: boolean\n): bigint {\n const { step, fromChain, disableMessageSigning } = context\n\n if (permit2Supported) {\n return MaxUint256\n }\n\n const permit2Allowances = disableMessageSigning\n ? []\n : getTypedDataInLane(step, 'permit2-allowance', fromChain)\n\n const approvalAddress = step.estimate.approvalAddress?.toLowerCase()\n const targetsApprovalAddress =\n permit2Allowances.length > 0 &&\n !!approvalAddress &&\n permit2Allowances.every(\n (typedData) =>\n typedData.domain.verifyingContract?.toLowerCase() === approvalAddress\n )\n\n return targetsApprovalAddress ? MaxUint256 : BigInt(step.action.fromAmount)\n}\n"],"mappings":";;;;;AAKA,SAAgB,kBACd,SACA,kBACQ;CACR,MAAM,EAAE,MAAM,WAAW,0BAA0B;CAEnD,IAAI,kBACF,OAAOA,0BAAAA;CAGT,MAAM,oBAAoB,wBACtB,CAAC,IACDC,+BAAAA,mBAAmB,MAAM,qBAAqB,SAAS;CAE3D,MAAM,kBAAkB,KAAK,SAAS,iBAAiB,YAAY;CASnE,OAPE,kBAAkB,SAAS,KAC3B,CAAC,CAAC,mBACF,kBAAkB,OACf,cACC,UAAU,OAAO,mBAAmB,YAAY,MAAM,eAC1D,IAE8BD,0BAAAA,aAAa,OAAO,KAAK,OAAO,UAAU;AAC5E"}
|
|
@@ -5,7 +5,13 @@ import { TransactionMethodType } from "@lifi/sdk";
|
|
|
5
5
|
* Determines the execution strategy: 'relayed', 'batched', or 'standard'.
|
|
6
6
|
* Falls back to 'standard' when EIP-5792 batching is unavailable,
|
|
7
7
|
* the wallet rejected the 7702 upgrade, or the tool doesn't support it.
|
|
8
|
+
*
|
|
9
|
+
* `afterPrepare` marks the single call from `EthereumPrepareTransactionTask`.
|
|
10
|
+
* The step has just been re-quoted, so the cached verdict is stale and, for the
|
|
11
|
+
* first time, the absence of a `transactionRequest` is final rather than merely
|
|
12
|
+
* not-yet-known. Both effects come from that one fact, which is why they share
|
|
13
|
+
* a parameter.
|
|
8
14
|
*/
|
|
9
|
-
export declare function getEthereumExecutionStrategy(context: EthereumStepExecutorContext,
|
|
15
|
+
export declare function getEthereumExecutionStrategy(context: EthereumStepExecutorContext, afterPrepare?: boolean): Promise<TransactionMethodType>;
|
|
10
16
|
//#endregion
|
|
11
17
|
//# sourceMappingURL=getEthereumExecutionStrategy.d.ts.map
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_actions_isBatchingSupported = require("../../../actions/isBatchingSupported.js");
|
|
3
|
-
const
|
|
3
|
+
const require_utils_getTypedDataLane = require("../../../utils/getTypedDataLane.js");
|
|
4
4
|
//#region src/core/tasks/helpers/getEthereumExecutionStrategy.ts
|
|
5
5
|
/**
|
|
6
6
|
* Determines the execution strategy: 'relayed', 'batched', or 'standard'.
|
|
7
7
|
* Falls back to 'standard' when EIP-5792 batching is unavailable,
|
|
8
8
|
* the wallet rejected the 7702 upgrade, or the tool doesn't support it.
|
|
9
|
+
*
|
|
10
|
+
* `afterPrepare` marks the single call from `EthereumPrepareTransactionTask`.
|
|
11
|
+
* The step has just been re-quoted, so the cached verdict is stale and, for the
|
|
12
|
+
* first time, the absence of a `transactionRequest` is final rather than merely
|
|
13
|
+
* not-yet-known. Both effects come from that one fact, which is why they share
|
|
14
|
+
* a parameter.
|
|
9
15
|
*/
|
|
10
|
-
async function getEthereumExecutionStrategy(context,
|
|
16
|
+
async function getEthereumExecutionStrategy(context, afterPrepare = false) {
|
|
11
17
|
const { step, checkClient, retryParams, client, fromChain, ethereumClient, executionStrategy: executionStrategyContext } = context;
|
|
12
|
-
if (!
|
|
18
|
+
if (!afterPrepare && executionStrategyContext) return executionStrategyContext;
|
|
13
19
|
const atomicityNotReady = !!retryParams?.atomicityNotReady;
|
|
14
|
-
if (
|
|
20
|
+
if (step.executionType === "message") return "relayed";
|
|
21
|
+
if (step.typedData?.length && !require_utils_getTypedDataLane.isPermit2AllowanceLane(step, fromChain)) return "relayed";
|
|
22
|
+
if (afterPrepare && step.typedData?.length && !step.transactionRequest) return "relayed";
|
|
15
23
|
if (atomicityNotReady || step.tool === "thorswap") return "standard";
|
|
16
24
|
const updatedClient = await checkClient(step) ?? ethereumClient;
|
|
17
25
|
return await require_actions_isBatchingSupported.isBatchingSupported(client, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEthereumExecutionStrategy.js","names":["
|
|
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":";;;;;;;;;;;;;;;AAgBA,eAAsB,6BACpB,SACA,eAAwB,OACQ;CAChC,MAAM,EACJ,MACA,aACA,aACA,QACA,WACA,gBACA,mBAAmB,6BACjB;CAEJ,IAAI,CAAC,gBAAgB,0BACnB,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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ExecutionOptions, LiFiStepExtended, SDKClient, SignedTypedData } from "@lifi/sdk";
|
|
1
|
+
import { ExecutionOptions, ExtendedChain, LiFiStepExtended, SDKClient, SignedTypedData } from "@lifi/sdk";
|
|
2
2
|
//#region src/core/tasks/helpers/getUpdatedStep.d.ts
|
|
3
|
-
|
|
3
|
+
/** Re-quotes the step through the endpoint that matches how it will execute. */
|
|
4
|
+
export declare const getUpdatedStep: (client: SDKClient, step: LiFiStepExtended, fromChain: ExtendedChain, executionOptions?: ExecutionOptions, signedTypedData?: SignedTypedData[]) => Promise<LiFiStepExtended>;
|
|
4
5
|
//#endregion
|
|
5
6
|
//# sourceMappingURL=getUpdatedStep.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_utils_isGaslessStep = require("../../../utils/isGaslessStep.js");
|
|
3
3
|
const require_permits_constants = require("../../../permits/constants.js");
|
|
4
4
|
const require_utils_isContractCallStep = require("../../../utils/isContractCallStep.js");
|
|
5
|
-
const require_utils_isGaslessStep = require("../../../utils/isGaslessStep.js");
|
|
6
5
|
let _lifi_sdk = require("@lifi/sdk");
|
|
7
6
|
//#region src/core/tasks/helpers/getUpdatedStep.ts
|
|
8
|
-
|
|
7
|
+
/** Re-quotes the step through the endpoint that matches how it will execute. */
|
|
8
|
+
const getUpdatedStep = async (client, step, fromChain, executionOptions, signedTypedData) => {
|
|
9
9
|
if (require_utils_isContractCallStep.isContractCallStep(step)) return getContractCallUpdatedStep(client, step, executionOptions);
|
|
10
|
-
if (
|
|
10
|
+
if (require_utils_isGaslessStep.isGaslessStep(step, fromChain)) return getRelayerUpdatedStep(client, step);
|
|
11
11
|
return getStandardUpdatedStep(client, step, signedTypedData);
|
|
12
12
|
};
|
|
13
13
|
const getContractCallUpdatedStep = async (client, step, executionOptions) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUpdatedStep.js","names":["isContractCallStep","
|
|
1
|
+
{"version":3,"file":"getUpdatedStep.js","names":["isContractCallStep","isGaslessStep","TransactionError","LiFiErrorCode","patchContractCalls","PatcherMagicNumber","getContractCallsQuote","convertQuoteToRoute","getRelayerQuote","getStepTransaction"],"sources":["../../../../../src/core/tasks/helpers/getUpdatedStep.ts"],"sourcesContent":["import {\n convertQuoteToRoute,\n type ExecutionOptions,\n type ExtendedChain,\n getContractCallsQuote,\n getRelayerQuote,\n getStepTransaction,\n LiFiErrorCode,\n type LiFiStepExtended,\n patchContractCalls,\n type SDKClient,\n type SignedTypedData,\n TransactionError,\n} from '@lifi/sdk'\nimport { PatcherMagicNumber } from '../../../permits/constants.js'\nimport { isContractCallStep } from '../../../utils/isContractCallStep.js'\nimport { isGaslessStep } from '../../../utils/isGaslessStep.js'\n\n/** Re-quotes the step through the endpoint that matches how it will execute. */\nexport const getUpdatedStep = async (\n client: SDKClient,\n step: LiFiStepExtended,\n fromChain: ExtendedChain,\n executionOptions?: ExecutionOptions,\n signedTypedData?: SignedTypedData[]\n): Promise<LiFiStepExtended> => {\n if (isContractCallStep(step)) {\n return getContractCallUpdatedStep(client, step, executionOptions)\n }\n // Do NOT substitute `hasRelayerMessage` for `isGaslessStep`: an `Order` retry\n // would fetch a relayer quote instead of `/advanced/stepTransaction`. Pinned\n // by `re-quotes an Order step ...` in `getUpdatedStep.unit.spec.ts`.\n if (isGaslessStep(step, fromChain)) {\n return getRelayerUpdatedStep(client, step)\n }\n return getStandardUpdatedStep(client, step, signedTypedData)\n}\n\nconst getContractCallUpdatedStep = async (\n client: SDKClient,\n step: LiFiStepExtended,\n executionOptions?: ExecutionOptions\n): Promise<LiFiStepExtended> => {\n const contractCallsResult = await executionOptions?.getContractCalls?.({\n fromAddress: step.action.fromAddress!,\n fromAmount: BigInt(step.action.fromAmount),\n fromChainId: step.action.fromChainId,\n fromTokenAddress: step.action.fromToken.address,\n slippage: step.action.slippage,\n toAddress: step.action.toAddress,\n toAmount: BigInt(step.estimate.toAmount),\n toChainId: step.action.toChainId,\n toTokenAddress: step.action.toToken.address,\n })\n\n if (!contractCallsResult?.contractCalls?.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Contract calls are not found.'\n )\n }\n\n if (contractCallsResult.patcher) {\n const patchedContractCalls = await patchContractCalls(\n client,\n contractCallsResult.contractCalls.map((call) => ({\n chainId: step.action.toChainId,\n fromTokenAddress: call.fromTokenAddress,\n targetContractAddress: call.toContractAddress,\n callDataToPatch: call.toContractCallData,\n delegateCall: false,\n patches: [\n {\n amountToReplace: PatcherMagicNumber.toString(),\n },\n ],\n }))\n )\n\n contractCallsResult.contractCalls.forEach((call, index) => {\n call.toContractAddress = patchedContractCalls[index].target\n call.toContractCallData = patchedContractCalls[index].callData\n })\n }\n\n /**\n * Limitations of the retry logic for contract calls:\n * - denyBridges and denyExchanges are not supported\n * - allowBridges and allowExchanges are not supported\n * - fee is not supported\n * - toAmount is not supported\n */\n const contractCallQuote = await getContractCallsQuote(client, {\n fromAddress: step.action.fromAddress!,\n fromChain: step.action.fromChainId,\n fromToken: step.action.fromToken.address,\n fromAmount: step.action.fromAmount,\n toChain: step.action.toChainId,\n toToken: step.action.toToken.address,\n contractCalls: contractCallsResult.contractCalls,\n toFallbackAddress: step.action.toAddress,\n slippage: step.action.slippage,\n })\n\n contractCallQuote.action.toToken = step.action.toToken\n\n const customStep = contractCallQuote.includedSteps?.find(\n (s) => s.type === 'custom'\n )\n if (customStep && contractCallsResult?.contractTool) {\n const toolDetails = {\n key: contractCallsResult.contractTool.name,\n name: contractCallsResult.contractTool.name,\n logoURI: contractCallsResult.contractTool.logoURI,\n }\n customStep.toolDetails = toolDetails\n contractCallQuote.toolDetails = toolDetails\n }\n\n const route = convertQuoteToRoute(contractCallQuote, {\n adjustZeroOutputFromPreviousStep:\n executionOptions?.adjustZeroOutputFromPreviousStep,\n })\n\n return {\n ...route.steps[0],\n id: step.id,\n }\n}\n\nconst getRelayerUpdatedStep = async (\n client: SDKClient,\n step: LiFiStepExtended\n): Promise<LiFiStepExtended> => {\n const updatedRelayedStep = await getRelayerQuote(client, {\n fromChain: step.action.fromChainId,\n fromToken: step.action.fromToken.address,\n fromAddress: step.action.fromAddress!,\n fromAmount: step.action.fromAmount,\n toChain: step.action.toChainId,\n toToken: step.action.toToken.address,\n slippage: step.action.slippage,\n toAddress: step.action.toAddress,\n allowBridges: [step.tool],\n })\n return {\n ...updatedRelayedStep,\n id: step.id,\n }\n}\n\nconst getStandardUpdatedStep = async (\n client: SDKClient,\n step: LiFiStepExtended,\n signedTypedData?: SignedTypedData[]\n): Promise<LiFiStepExtended> => {\n const filteredSignedTypedData = signedTypedData?.filter(\n (item) => item.signature\n )\n const { typedData: _, ...restStep } = step\n const params = filteredSignedTypedData?.length\n ? { ...restStep, typedData: filteredSignedTypedData }\n : restStep\n return getStepTransaction(client, params)\n}\n"],"mappings":";;;;;;;AAmBA,MAAa,iBAAiB,OAC5B,QACA,MACA,WACA,kBACA,oBAC8B;CAC9B,IAAIA,iCAAAA,mBAAmB,IAAI,GACzB,OAAO,2BAA2B,QAAQ,MAAM,gBAAgB;CAKlE,IAAIC,4BAAAA,cAAc,MAAM,SAAS,GAC/B,OAAO,sBAAsB,QAAQ,IAAI;CAE3C,OAAO,uBAAuB,QAAQ,MAAM,eAAe;AAC7D;AAEA,MAAM,6BAA6B,OACjC,QACA,MACA,qBAC8B;CAC9B,MAAM,sBAAsB,MAAM,kBAAkB,mBAAmB;EACrE,aAAa,KAAK,OAAO;EACzB,YAAY,OAAO,KAAK,OAAO,UAAU;EACzC,aAAa,KAAK,OAAO;EACzB,kBAAkB,KAAK,OAAO,UAAU;EACxC,UAAU,KAAK,OAAO;EACtB,WAAW,KAAK,OAAO;EACvB,UAAU,OAAO,KAAK,SAAS,QAAQ;EACvC,WAAW,KAAK,OAAO;EACvB,gBAAgB,KAAK,OAAO,QAAQ;CACtC,CAAC;CAED,IAAI,CAAC,qBAAqB,eAAe,QACvC,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,8DACF;CAGF,IAAI,oBAAoB,SAAS;EAC/B,MAAM,uBAAuB,OAAA,GAAMC,UAAAA,mBAAAA,CACjC,QACA,oBAAoB,cAAc,KAAK,UAAU;GAC/C,SAAS,KAAK,OAAO;GACrB,kBAAkB,KAAK;GACvB,uBAAuB,KAAK;GAC5B,iBAAiB,KAAK;GACtB,cAAc;GACd,SAAS,CACP,EACE,iBAAiBC,0BAAAA,mBAAmB,SAAS,EAC/C,CACF;EACF,EAAE,CACJ;EAEA,oBAAoB,cAAc,SAAS,MAAM,UAAU;GACzD,KAAK,oBAAoB,qBAAqB,MAAM,CAAC;GACrD,KAAK,qBAAqB,qBAAqB,MAAM,CAAC;EACxD,CAAC;CACH;;;;;;;;CASA,MAAM,oBAAoB,OAAA,GAAMC,UAAAA,sBAAAA,CAAsB,QAAQ;EAC5D,aAAa,KAAK,OAAO;EACzB,WAAW,KAAK,OAAO;EACvB,WAAW,KAAK,OAAO,UAAU;EACjC,YAAY,KAAK,OAAO;EACxB,SAAS,KAAK,OAAO;EACrB,SAAS,KAAK,OAAO,QAAQ;EAC7B,eAAe,oBAAoB;EACnC,mBAAmB,KAAK,OAAO;EAC/B,UAAU,KAAK,OAAO;CACxB,CAAC;CAED,kBAAkB,OAAO,UAAU,KAAK,OAAO;CAE/C,MAAM,aAAa,kBAAkB,eAAe,MACjD,MAAM,EAAE,SAAS,QACpB;CACA,IAAI,cAAc,qBAAqB,cAAc;EACnD,MAAM,cAAc;GAClB,KAAK,oBAAoB,aAAa;GACtC,MAAM,oBAAoB,aAAa;GACvC,SAAS,oBAAoB,aAAa;EAC5C;EACA,WAAW,cAAc;EACzB,kBAAkB,cAAc;CAClC;CAOA,OAAO;EACL,IAAA,GANYC,UAAAA,oBAAAA,CAAoB,mBAAmB,EACnD,kCACE,kBAAkB,iCACtB,CAGS,CAAC,CAAC,MAAM;EACf,IAAI,KAAK;CACX;AACF;AAEA,MAAM,wBAAwB,OAC5B,QACA,SAC8B;CAY9B,OAAO;EACL,GAAG,OAAA,GAZ4BC,UAAAA,gBAAAA,CAAgB,QAAQ;GACvD,WAAW,KAAK,OAAO;GACvB,WAAW,KAAK,OAAO,UAAU;GACjC,aAAa,KAAK,OAAO;GACzB,YAAY,KAAK,OAAO;GACxB,SAAS,KAAK,OAAO;GACrB,SAAS,KAAK,OAAO,QAAQ;GAC7B,UAAU,KAAK,OAAO;GACtB,WAAW,KAAK,OAAO;GACvB,cAAc,CAAC,KAAK,IAAI;EAC1B,CAAC;EAGC,IAAI,KAAK;CACX;AACF;AAEA,MAAM,yBAAyB,OAC7B,QACA,MACA,oBAC8B;CAC9B,MAAM,0BAA0B,iBAAiB,QAC9C,SAAS,KAAK,SACjB;CACA,MAAM,EAAE,WAAW,GAAG,GAAG,aAAa;CACtC,MAAM,SAAS,yBAAyB,SACpC;EAAE,GAAG;EAAU,WAAW;CAAwB,IAClD;CACJ,QAAA,GAAOC,UAAAA,mBAAAA,CAAmB,QAAQ,MAAM;AAC1C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EthereumStepExecutorContext } from "../../../types.js";
|
|
2
|
+
//#region src/core/tasks/helpers/hasPermit2AllowanceInFlight.d.ts
|
|
3
|
+
/** Whether this execution carries a caller-supplied Permit2 allowance, declared or signed. */
|
|
4
|
+
export declare function hasPermit2AllowanceInFlight(context: EthereumStepExecutorContext): boolean;
|
|
5
|
+
/** `isPermit2AllowanceLane`, for gates that run after prepare may have replaced `step.typedData`. */
|
|
6
|
+
export declare function isPermit2AllowanceLaneInFlight(context: EthereumStepExecutorContext): boolean;
|
|
7
|
+
//#endregion
|
|
8
|
+
//# sourceMappingURL=hasPermit2AllowanceInFlight.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_getTypedDataLane = require("../../../utils/getTypedDataLane.js");
|
|
3
|
+
//#region src/core/tasks/helpers/hasPermit2AllowanceInFlight.ts
|
|
4
|
+
/** Whether this execution carries a caller-supplied Permit2 allowance, declared or signed. */
|
|
5
|
+
function hasPermit2AllowanceInFlight(context) {
|
|
6
|
+
const { step, fromChain, signedTypedData } = context;
|
|
7
|
+
return require_utils_getTypedDataLane.hasPermit2Allowance(step, fromChain) || signedTypedData.some((typedData) => require_utils_getTypedDataLane.getTypedDataLane(typedData, fromChain) === "permit2-allowance");
|
|
8
|
+
}
|
|
9
|
+
/** `isPermit2AllowanceLane`, for gates that run after prepare may have replaced `step.typedData`. */
|
|
10
|
+
function isPermit2AllowanceLaneInFlight(context) {
|
|
11
|
+
return hasPermit2AllowanceInFlight(context) && !require_utils_getTypedDataLane.hasRelayerMessage(context.step, context.fromChain);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.hasPermit2AllowanceInFlight = hasPermit2AllowanceInFlight;
|
|
15
|
+
exports.isPermit2AllowanceLaneInFlight = isPermit2AllowanceLaneInFlight;
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=hasPermit2AllowanceInFlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasPermit2AllowanceInFlight.js","names":["hasPermit2Allowance","getTypedDataLane","hasRelayerMessage"],"sources":["../../../../../src/core/tasks/helpers/hasPermit2AllowanceInFlight.ts"],"sourcesContent":["import type { EthereumStepExecutorContext } from '../../../types.js'\nimport {\n getTypedDataLane,\n hasPermit2Allowance,\n hasRelayerMessage,\n} from '../../../utils/getTypedDataLane.js'\n\n/** Whether this execution carries a caller-supplied Permit2 allowance, declared or signed. */\nexport function hasPermit2AllowanceInFlight(\n context: EthereumStepExecutorContext\n): boolean {\n const { step, fromChain, signedTypedData } = context\n\n return (\n hasPermit2Allowance(step, fromChain) ||\n signedTypedData.some(\n (typedData) =>\n getTypedDataLane(typedData, fromChain) === 'permit2-allowance'\n )\n )\n}\n\n/** `isPermit2AllowanceLane`, for gates that run after prepare may have replaced `step.typedData`. */\nexport function isPermit2AllowanceLaneInFlight(\n context: EthereumStepExecutorContext\n): boolean {\n return (\n hasPermit2AllowanceInFlight(context) &&\n !hasRelayerMessage(context.step, context.fromChain)\n )\n}\n"],"mappings":";;;;AAQA,SAAgB,4BACd,SACS;CACT,MAAM,EAAE,MAAM,WAAW,oBAAoB;CAE7C,OACEA,+BAAAA,oBAAoB,MAAM,SAAS,KACnC,gBAAgB,MACb,cACCC,+BAAAA,iBAAiB,WAAW,SAAS,MAAM,mBAC/C;AAEJ;;AAGA,SAAgB,+BACd,SACS;CACT,OACE,4BAA4B,OAAO,KACnC,CAACC,+BAAAA,kBAAkB,QAAQ,MAAM,QAAQ,SAAS;AAEtD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SignedTypedData, TypedData } from "@lifi/sdk";
|
|
2
|
+
//#region src/core/tasks/helpers/isTypedDataAlreadySigned.d.ts
|
|
3
|
+
/** Whether `signedTypedData` already holds a signature for this exact entry. */
|
|
4
|
+
export declare function isTypedDataAlreadySigned(signedTypedData: SignedTypedData[], typedData: TypedData): boolean;
|
|
5
|
+
//#endregion
|
|
6
|
+
//# sourceMappingURL=isTypedDataAlreadySigned.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_isValidSignature = require("../../../utils/isValidSignature.js");
|
|
3
|
+
//#region src/core/tasks/helpers/isTypedDataAlreadySigned.ts
|
|
4
|
+
/** Whether `signedTypedData` already holds a signature for this exact entry. */
|
|
5
|
+
function isTypedDataAlreadySigned(signedTypedData, typedData) {
|
|
6
|
+
if (typedData.primaryType === "Permit") return false;
|
|
7
|
+
return signedTypedData.some((signed) => signed.primaryType === typedData.primaryType && require_utils_isValidSignature.isValidSignature(signed.signature) && isSameValue(signed.domain, typedData.domain) && isSameValue(signed.message, typedData.message));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* `domain` and `message` are decoded JSON, so compare them structurally: a
|
|
11
|
+
* round trip through the API rebuilds the objects, and `JSON.stringify` both
|
|
12
|
+
* depends on key order and throws on a `bigint`. Scalars compare by string
|
|
13
|
+
* form, because `1`, `1n` and `'1'` are one EIP-712 value.
|
|
14
|
+
*/
|
|
15
|
+
function isSameValue(a, b) {
|
|
16
|
+
if (a === b) return true;
|
|
17
|
+
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, index) => isSameValue(item, b[index]));
|
|
18
|
+
if (isRecord(a) && isRecord(b)) {
|
|
19
|
+
const keys = Object.keys(a);
|
|
20
|
+
return keys.length === Object.keys(b).length && keys.every((key) => key in b && isSameValue(a[key], b[key]));
|
|
21
|
+
}
|
|
22
|
+
if (a == null || b == null) return false;
|
|
23
|
+
return String(a) === String(b);
|
|
24
|
+
}
|
|
25
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.isTypedDataAlreadySigned = isTypedDataAlreadySigned;
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=isTypedDataAlreadySigned.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isTypedDataAlreadySigned.js","names":["isValidSignature"],"sources":["../../../../../src/core/tasks/helpers/isTypedDataAlreadySigned.ts"],"sourcesContent":["import type { SignedTypedData, TypedData } from '@lifi/sdk'\nimport { isValidSignature } from '../../../utils/isValidSignature.js'\n\n/** Whether `signedTypedData` already holds a signature for this exact entry. */\nexport function isTypedDataAlreadySigned(\n signedTypedData: SignedTypedData[],\n typedData: TypedData\n): boolean {\n // `Permit` stays with `isNativePermitValid`, which also checks the deadline,\n // the amount and the salt. Equality alone would drop those checks.\n if (typedData.primaryType === 'Permit') {\n return false\n }\n\n return signedTypedData.some(\n (signed) =>\n signed.primaryType === typedData.primaryType &&\n isValidSignature(signed.signature) &&\n isSameValue(signed.domain, typedData.domain) &&\n isSameValue(signed.message, typedData.message)\n )\n}\n\n/**\n * `domain` and `message` are decoded JSON, so compare them structurally: a\n * round trip through the API rebuilds the objects, and `JSON.stringify` both\n * depends on key order and throws on a `bigint`. Scalars compare by string\n * form, because `1`, `1n` and `'1'` are one EIP-712 value.\n */\nfunction isSameValue(a: unknown, b: unknown): boolean {\n if (a === b) {\n return true\n }\n if (Array.isArray(a) || Array.isArray(b)) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((item, index) => isSameValue(item, b[index]))\n )\n }\n if (isRecord(a) && isRecord(b)) {\n const keys = Object.keys(a)\n return (\n keys.length === Object.keys(b).length &&\n keys.every((key) => key in b && isSameValue(a[key], b[key]))\n )\n }\n if (a == null || b == null) {\n return false\n }\n return String(a) === String(b)\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null\n"],"mappings":";;;;AAIA,SAAgB,yBACd,iBACA,WACS;CAGT,IAAI,UAAU,gBAAgB,UAC5B,OAAO;CAGT,OAAO,gBAAgB,MACpB,WACC,OAAO,gBAAgB,UAAU,eACjCA,+BAAAA,iBAAiB,OAAO,SAAS,KACjC,YAAY,OAAO,QAAQ,UAAU,MAAM,KAC3C,YAAY,OAAO,SAAS,UAAU,OAAO,CACjD;AACF;;;;;;;AAQA,SAAS,YAAY,GAAY,GAAqB;CACpD,IAAI,MAAM,GACR,OAAO;CAET,IAAI,MAAM,QAAQ,CAAC,KAAK,MAAM,QAAQ,CAAC,GACrC,OACE,MAAM,QAAQ,CAAC,KACf,MAAM,QAAQ,CAAC,KACf,EAAE,WAAW,EAAE,UACf,EAAE,OAAO,MAAM,UAAU,YAAY,MAAM,EAAE,MAAM,CAAC;CAGxD,IAAI,SAAS,CAAC,KAAK,SAAS,CAAC,GAAG;EAC9B,MAAM,OAAO,OAAO,KAAK,CAAC;EAC1B,OACE,KAAK,WAAW,OAAO,KAAK,CAAC,CAAC,CAAC,UAC/B,KAAK,OAAO,QAAQ,OAAO,KAAK,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC;CAE/D;CACA,IAAI,KAAK,QAAQ,KAAK,MACpB,OAAO;CAET,OAAO,OAAO,CAAC,MAAM,OAAO,CAAC;AAC/B;AAEA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExtendedChain, LiFiStep, LiFiStepExtended, TypedData } from "@lifi/sdk";
|
|
2
|
+
//#region src/core/tasks/helpers/preservePermit2Allowances.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* `??` keeps the Permit2 allowance only when the answer omits `typedData`. An
|
|
5
|
+
* answer that carries entries of its own — native permits, or `[]` from a
|
|
6
|
+
* third-party backend — would drop it, and `signedTypedData` resets per
|
|
7
|
+
* `executeStep`, so a retry would let the Permit2 proxy hijack the calldata.
|
|
8
|
+
*/
|
|
9
|
+
export declare function preservePermit2Allowances(step: LiFiStepExtended | LiFiStep, updatedTypedData: TypedData[] | undefined, chain: ExtendedChain): TypedData[] | undefined;
|
|
10
|
+
//#endregion
|
|
11
|
+
//# sourceMappingURL=preservePermit2Allowances.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_getTypedDataLane = require("../../../utils/getTypedDataLane.js");
|
|
3
|
+
//#region src/core/tasks/helpers/preservePermit2Allowances.ts
|
|
4
|
+
/**
|
|
5
|
+
* `??` keeps the Permit2 allowance only when the answer omits `typedData`. An
|
|
6
|
+
* answer that carries entries of its own — native permits, or `[]` from a
|
|
7
|
+
* third-party backend — would drop it, and `signedTypedData` resets per
|
|
8
|
+
* `executeStep`, so a retry would let the Permit2 proxy hijack the calldata.
|
|
9
|
+
*/
|
|
10
|
+
function preservePermit2Allowances(step, updatedTypedData, chain) {
|
|
11
|
+
if (!updatedTypedData) return step.typedData;
|
|
12
|
+
if (!require_utils_getTypedDataLane.isPermit2AllowanceLane(step, chain)) return updatedTypedData;
|
|
13
|
+
if (updatedTypedData.some((typedData) => {
|
|
14
|
+
const lane = require_utils_getTypedDataLane.getTypedDataLane(typedData, chain);
|
|
15
|
+
return lane === "permit2-allowance" || lane === "relayer-message";
|
|
16
|
+
})) return updatedTypedData;
|
|
17
|
+
return [...updatedTypedData, ...require_utils_getTypedDataLane.getTypedDataInLane(step, "permit2-allowance", chain)];
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.preservePermit2Allowances = preservePermit2Allowances;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=preservePermit2Allowances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preservePermit2Allowances.js","names":["isPermit2AllowanceLane","getTypedDataLane","getTypedDataInLane"],"sources":["../../../../../src/core/tasks/helpers/preservePermit2Allowances.ts"],"sourcesContent":["import type {\n ExtendedChain,\n LiFiStep,\n LiFiStepExtended,\n TypedData,\n} from '@lifi/sdk'\nimport {\n getTypedDataInLane,\n getTypedDataLane,\n isPermit2AllowanceLane,\n} from '../../../utils/getTypedDataLane.js'\n\n/**\n * `??` keeps the Permit2 allowance only when the answer omits `typedData`. An\n * answer that carries entries of its own — native permits, or `[]` from a\n * third-party backend — would drop it, and `signedTypedData` resets per\n * `executeStep`, so a retry would let the Permit2 proxy hijack the calldata.\n */\nexport function preservePermit2Allowances(\n step: LiFiStepExtended | LiFiStep,\n updatedTypedData: TypedData[] | undefined,\n chain: ExtendedChain\n): TypedData[] | undefined {\n if (!updatedTypedData) {\n return step.typedData\n }\n\n if (!isPermit2AllowanceLane(step, chain)) {\n return updatedTypedData\n }\n\n const answerDeclaresLane = updatedTypedData.some((typedData) => {\n const lane = getTypedDataLane(typedData, chain)\n return lane === 'permit2-allowance' || lane === 'relayer-message'\n })\n if (answerDeclaresLane) {\n return updatedTypedData\n }\n\n return [\n ...updatedTypedData,\n ...getTypedDataInLane(step, 'permit2-allowance', chain),\n ]\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAgB,0BACd,MACA,kBACA,OACyB;CACzB,IAAI,CAAC,kBACH,OAAO,KAAK;CAGd,IAAI,CAACA,+BAAAA,uBAAuB,MAAM,KAAK,GACrC,OAAO;CAOT,IAJ2B,iBAAiB,MAAM,cAAc;EAC9D,MAAM,OAAOC,+BAAAA,iBAAiB,WAAW,KAAK;EAC9C,OAAO,SAAS,uBAAuB,SAAS;CAClD,CACqB,GACnB,OAAO;CAGT,OAAO,CACL,GAAG,kBACH,GAAGC,+BAAAA,mBAAmB,MAAM,qBAAqB,KAAK,CACxD;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_permits_canAccountUsePermit2 = require("../../../permits/canAccountUsePermit2.js");
|
|
3
|
+
const require_core_tasks_helpers_hasPermit2AllowanceInFlight = require("./hasPermit2AllowanceInFlight.js");
|
|
3
4
|
//#region src/core/tasks/helpers/resolvePermit2Support.ts
|
|
4
5
|
/**
|
|
5
6
|
* Cheap, synchronous part of the gate: does the step/chain combination allow
|
|
@@ -7,7 +8,7 @@ const require_permits_canAccountUsePermit2 = require("../../../permits/canAccoun
|
|
|
7
8
|
*/
|
|
8
9
|
const isPermit2SupportedForStep = (context, strategy) => {
|
|
9
10
|
const { step, fromChain, isFromNativeToken, disableMessageSigning } = context;
|
|
10
|
-
return !!fromChain.permit2 && !!fromChain.permit2Proxy && !isFromNativeToken && !disableMessageSigning && strategy !== "batched" && !!step.estimate.approvalAddress && !step.estimate.skipApproval && !step.estimate.skipPermit;
|
|
11
|
+
return !!fromChain.permit2 && !!fromChain.permit2Proxy && !isFromNativeToken && !disableMessageSigning && strategy !== "batched" && !!step.estimate.approvalAddress && !step.estimate.skipApproval && !step.estimate.skipPermit && !require_core_tasks_helpers_hasPermit2AllowanceInFlight.isPermit2AllowanceLaneInFlight(context);
|
|
11
12
|
};
|
|
12
13
|
/**
|
|
13
14
|
* Whether this step should use the Permit2 signature flow.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePermit2Support.js","names":["canAccountUsePermit2"],"sources":["../../../../../src/core/tasks/helpers/resolvePermit2Support.ts"],"sourcesContent":["import type { TransactionMethodType } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { canAccountUsePermit2 } from '../../../permits/canAccountUsePermit2.js'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\n\n/**\n * Cheap, synchronous part of the gate: does the step/chain combination allow\n * the Permit2 flow at all? Permit2 should not be available for atomic batch.\n */\nconst isPermit2SupportedForStep = (\n context: EthereumStepExecutorContext,\n strategy: TransactionMethodType\n): boolean => {\n const { step, fromChain, isFromNativeToken, disableMessageSigning } = context\n\n return (\n !!fromChain.permit2 &&\n !!fromChain.permit2Proxy &&\n !isFromNativeToken &&\n !disableMessageSigning &&\n strategy !== 'batched' &&\n // Approval address is not required for Permit2 per se, but we use it to skip allowance checks for direct transfers\n !!step.estimate.approvalAddress &&\n !step.estimate.skipApproval &&\n !step.estimate.skipPermit\n )\n}\n\n/**\n * Whether this step should use the Permit2 signature flow.\n *\n * Beyond the step/chain checks, the `standard` strategy also probes the\n * *signer*: code-bearing accounts send Permit2 down its EIP-1271 path, where\n * acceptance is implementation-specific — see {@link canAccountUsePermit2}.\n * Accounts that fail it fall back to approve + execute.\n *\n * Only `standard` consults the probe. `signPermit2Message` has one call site,\n * `EthereumStandardSignAndExecuteTask`, so that is the only flow where the SDK\n * produces the Permit2 signature itself. A relayed step has no approve +\n * execute fallback, so a verdict cannot rescue a failing account and would\n * break a working one — it must never move the spender off `fromChain.permit2`.\n *\n * The verdict is memoized on `context.permit2SignerSupported`, and a `false`\n * stays sticky, a failed lookup included. `TaskPipeline` threads one context\n * through every task, so a mid-run flip would let the allowance tasks approve\n * one spender while the sign task routes to the other — turning a needless\n * approval into a revert.\n */\nexport const resolvePermit2Support = async (\n context: EthereumStepExecutorContext,\n strategy: TransactionMethodType\n): Promise<boolean> => {\n if (!isPermit2SupportedForStep(context, strategy)) {\n return false\n }\n\n // Only `standard` consults the probe; `batched` is excluded above.\n if (strategy !== 'standard') {\n return true\n }\n\n const { client, step, fromChain, ethereumClient } = context\n const address = (step.action.fromAddress ??\n ethereumClient.account?.address) as Address | undefined\n if (!address) {\n return false\n }\n\n // Caching the promise is safe: `canAccountUsePermit2` never rejects.\n context.permit2SignerSupported ??= canAccountUsePermit2(client, {\n chainId: fromChain.id,\n address,\n })\n\n return context.permit2SignerSupported\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolvePermit2Support.js","names":["isPermit2AllowanceLaneInFlight","canAccountUsePermit2"],"sources":["../../../../../src/core/tasks/helpers/resolvePermit2Support.ts"],"sourcesContent":["import type { TransactionMethodType } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { canAccountUsePermit2 } from '../../../permits/canAccountUsePermit2.js'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { isPermit2AllowanceLaneInFlight } from './hasPermit2AllowanceInFlight.js'\n\n/**\n * Cheap, synchronous part of the gate: does the step/chain combination allow\n * the Permit2 flow at all? Permit2 should not be available for atomic batch.\n */\nconst isPermit2SupportedForStep = (\n context: EthereumStepExecutorContext,\n strategy: TransactionMethodType\n): boolean => {\n const { step, fromChain, isFromNativeToken, disableMessageSigning } = context\n\n return (\n !!fromChain.permit2 &&\n !!fromChain.permit2Proxy &&\n !isFromNativeToken &&\n !disableMessageSigning &&\n strategy !== 'batched' &&\n // Approval address is not required for Permit2 per se, but we use it to skip allowance checks for direct transfers\n !!step.estimate.approvalAddress &&\n !step.estimate.skipApproval &&\n !step.estimate.skipPermit &&\n !isPermit2AllowanceLaneInFlight(context)\n )\n}\n\n/**\n * Whether this step should use the Permit2 signature flow.\n *\n * Beyond the step/chain checks, the `standard` strategy also probes the\n * *signer*: code-bearing accounts send Permit2 down its EIP-1271 path, where\n * acceptance is implementation-specific — see {@link canAccountUsePermit2}.\n * Accounts that fail it fall back to approve + execute.\n *\n * Only `standard` consults the probe. `signPermit2Message` has one call site,\n * `EthereumStandardSignAndExecuteTask`, so that is the only flow where the SDK\n * produces the Permit2 signature itself. A relayed step has no approve +\n * execute fallback, so a verdict cannot rescue a failing account and would\n * break a working one — it must never move the spender off `fromChain.permit2`.\n *\n * The verdict is memoized on `context.permit2SignerSupported`, and a `false`\n * stays sticky, a failed lookup included. `TaskPipeline` threads one context\n * through every task, so a mid-run flip would let the allowance tasks approve\n * one spender while the sign task routes to the other — turning a needless\n * approval into a revert.\n */\nexport const resolvePermit2Support = async (\n context: EthereumStepExecutorContext,\n strategy: TransactionMethodType\n): Promise<boolean> => {\n if (!isPermit2SupportedForStep(context, strategy)) {\n return false\n }\n\n // Only `standard` consults the probe; `batched` is excluded above.\n if (strategy !== 'standard') {\n return true\n }\n\n const { client, step, fromChain, ethereumClient } = context\n const address = (step.action.fromAddress ??\n ethereumClient.account?.address) as Address | undefined\n if (!address) {\n return false\n }\n\n // Caching the promise is safe: `canAccountUsePermit2` never rejects.\n context.permit2SignerSupported ??= canAccountUsePermit2(client, {\n chainId: fromChain.id,\n address,\n })\n\n return context.permit2SignerSupported\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,6BACJ,SACA,aACY;CACZ,MAAM,EAAE,MAAM,WAAW,mBAAmB,0BAA0B;CAEtE,OACE,CAAC,CAAC,UAAU,WACZ,CAAC,CAAC,UAAU,gBACZ,CAAC,qBACD,CAAC,yBACD,aAAa,aAEb,CAAC,CAAC,KAAK,SAAS,mBAChB,CAAC,KAAK,SAAS,gBACf,CAAC,KAAK,SAAS,cACf,CAACA,uDAAAA,+BAA+B,OAAO;AAE3C;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,wBAAwB,OACnC,SACA,aACqB;CACrB,IAAI,CAAC,0BAA0B,SAAS,QAAQ,GAC9C,OAAO;CAIT,IAAI,aAAa,YACf,OAAO;CAGT,MAAM,EAAE,QAAQ,MAAM,WAAW,mBAAmB;CACpD,MAAM,UAAW,KAAK,OAAO,eAC3B,eAAe,SAAS;CAC1B,IAAI,CAAC,SACH,OAAO;CAIT,QAAQ,2BAA2BC,qCAAAA,qBAAqB,QAAQ;EAC9D,SAAS,UAAU;EACnB;CACF,CAAC;CAED,OAAO,QAAQ;AACjB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EthereumStepExecutorContext } from "../../../types.js";
|
|
2
2
|
import { SignedTypedData, TypedData } from "@lifi/sdk";
|
|
3
3
|
//#region src/core/tasks/helpers/signHyperliquidTypedData.d.ts
|
|
4
|
-
export declare const signHyperliquidTypedData: (context: EthereumStepExecutorContext,
|
|
4
|
+
export declare const signHyperliquidTypedData: (context: EthereumStepExecutorContext, allowanceTypedData: TypedData[]) => Promise<SignedTypedData[] | undefined>;
|
|
5
5
|
//#endregion
|
|
6
6
|
//# sourceMappingURL=signHyperliquidTypedData.d.ts.map
|
|
@@ -6,15 +6,15 @@ const require_hyperliquid_agentWallet = require("../../../hyperliquid/agentWalle
|
|
|
6
6
|
let viem_actions = require("viem/actions");
|
|
7
7
|
let viem_utils = require("viem/utils");
|
|
8
8
|
//#region src/core/tasks/helpers/signHyperliquidTypedData.ts
|
|
9
|
-
const signHyperliquidTypedData = async (context,
|
|
9
|
+
const signHyperliquidTypedData = async (context, allowanceTypedData) => {
|
|
10
10
|
const { step, fromChain, client, allowUserInteraction, checkClient, ethereumClient, getStorage } = context;
|
|
11
11
|
if (!allowUserInteraction) return;
|
|
12
12
|
const signedResults = [];
|
|
13
13
|
const ownerAddress = ethereumClient.account.address;
|
|
14
14
|
const storage = getStorage(client);
|
|
15
|
-
const existingAgentAddress =
|
|
15
|
+
const existingAgentAddress = allowanceTypedData.find(require_hyperliquid_isHyperliquidAgentStep.isApproveAgentMessage)?.message.agentAddress;
|
|
16
16
|
const { account: agentAccount, needsApproval, expiresAt } = await require_hyperliquid_agentWallet.getOrCreateAgentWallet(storage, ownerAddress, existingAgentAddress);
|
|
17
|
-
for (const typedData of
|
|
17
|
+
for (const typedData of allowanceTypedData) if (require_hyperliquid_isHyperliquidAgentStep.isApproveAgentMessage(typedData)) {
|
|
18
18
|
if (!needsApproval) continue;
|
|
19
19
|
const message = {
|
|
20
20
|
...typedData.message,
|