From 9910e8567f59cce3c43d6c944e0cbdb29b69048a Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 11 Sep 2024 11:15:42 -0700 Subject: [PATCH] chore: finally put in right spot --- src/executor/executor.ts | 68 +++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/src/executor/executor.ts b/src/executor/executor.ts index e1440eda..7df212ba 100644 --- a/src/executor/executor.ts +++ b/src/executor/executor.ts @@ -655,35 +655,65 @@ export class Executor { let transactionHash: HexData32 try { - const isLegacyTransaction = this.legacyTransactions + const userOps = opsWithHashToBundle.map((owh) => + isUserOpVersion06 + ? owh.mempoolUserOperation + : toPackedUserOperation( + owh.mempoolUserOperation as UserOperationV07 + ) + ) as PackedUserOperation[] - const gasOptions = isLegacyTransaction - ? { gasPrice: gasPriceParameters.maxFeePerGas } - : { - maxFeePerGas: gasPriceParameters.maxFeePerGas, - maxPriorityFeePerGas: - gasPriceParameters.maxPriorityFeePerGas - } + let authorizationList: Authorization[] | undefined = undefined + for (const compressedOp of userOps) { + const key = `${compressedOp.sender}:${compressedOp.nonce}:${compressedOp.callData}` + const opAuthorizationList = userOperation7702.get(key) + // if ("authorizationList" in compressedOp.inflatedOp) { + // const opAuthorizationList = compressedOp.inflatedOp.authorizationList + if (opAuthorizationList) { + if (authorizationList !== undefined) { + authorizationList.push(...opAuthorizationList) + } else { + authorizationList = opAuthorizationList + } + } + // } + } + + if (authorizationList && this.legacyTransactions) { + throw new Error("AuthorizationList is not supported for legacy transactions") + } + const newGasOptions = { + maxFeePerGas: gasPriceParameters.maxFeePerGas, + maxPriorityFeePerGas: + gasPriceParameters.maxPriorityFeePerGas + } + const gasOptions = this.legacyTransactions + ? { + gasPrice: gasPriceParameters.maxFeePerGas + } + : newGasOptions const opts = { account: wallet, gas: gasLimit, - nonce: nonce, - ...gasOptions + nonce: nonce } - const userOps = opsWithHashToBundle.map((owh) => - isUserOpVersion06 - ? owh.mempoolUserOperation - : toPackedUserOperation( - owh.mempoolUserOperation as UserOperationV07 - ) - ) as PackedUserOperation[] + const sendTransactionParams = authorizationList + ? { + ...opts, + ...newGasOptions, + authorizationList + } + : { + ...opts, + ...gasOptions + } - console.log("DOexecute: userOps: " + JSON.stringify(userOps) + " opts: " + JSON.stringify(opts)) + console.log("DOexecute: userOps: " + JSON.stringify(userOps) + " opts: " + JSON.stringify(sendTransactionParams)) transactionHash = await ep.write.handleOps( [userOps, wallet.address], - opts + sendTransactionParams ) opsWithHashToBundle.map(({ userOperationHash }) => {