diff --git a/packages/bundler/src/BundlerServer.ts b/packages/bundler/src/BundlerServer.ts index 492904d8..372f1d84 100644 --- a/packages/bundler/src/BundlerServer.ts +++ b/packages/bundler/src/BundlerServer.ts @@ -95,8 +95,7 @@ export class BundlerServer { callGasLimit: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0, - signature: '0x', - authorizationList: [] + signature: '0x' } // await EntryPoint__factory.connect(this.config.entryPoint,this.provider).callStatic.addStake(0) try { diff --git a/packages/bundler/src/MethodHandlerERC4337.ts b/packages/bundler/src/MethodHandlerERC4337.ts index 751f80f6..2da5e847 100644 --- a/packages/bundler/src/MethodHandlerERC4337.ts +++ b/packages/bundler/src/MethodHandlerERC4337.ts @@ -124,7 +124,7 @@ export class MethodHandlerERC4337 { entryPointInput: string, stateOverride?: StateOverride ): Promise { - if (!this.config.eip7702Support && userOp1.authorizationList != null && userOp1.authorizationList.length !== 0) { + if (!this.config.eip7702Support && userOp1.eip7712auth != null) { throw new Error('EIP-7702 tuples are not supported') } const userOp: UserOperation = { @@ -192,12 +192,12 @@ export class MethodHandlerERC4337 { } async sendUserOperation (userOp: UserOperation, entryPointInput: string): Promise { - if (!this.config.eip7702Support && userOp.authorizationList != null && userOp.authorizationList.length !== 0) { + if (!this.config.eip7702Support && userOp.eip7712auth != null) { throw new Error('EIP-7702 tuples are not supported') } await this._validateParameters(userOp, entryPointInput) - debug(`UserOperation: Sender=${userOp.sender} Nonce=${tostr(userOp.nonce)} EntryPoint=${entryPointInput} Paymaster=${userOp.paymaster ?? ''} EIP-7702TuplesSize=${userOp.authorizationList?.length}`) + debug(`UserOperation: Sender=${userOp.sender} Nonce=${tostr(userOp.nonce)} EntryPoint=${entryPointInput} Paymaster=${userOp.paymaster ?? ''} ${userOp.eip7712auth != null ? 'eip-7702 auth' : ''}`) await this.execManager.sendUserOperation(userOp, entryPointInput, false) return await this.entryPoint.getUserOpHash(packUserOp(userOp)) } diff --git a/packages/bundler/src/modules/BundleManager.ts b/packages/bundler/src/modules/BundleManager.ts index 3974c4f2..a753a16e 100644 --- a/packages/bundler/src/modules/BundleManager.ts +++ b/packages/bundler/src/modules/BundleManager.ts @@ -23,7 +23,7 @@ import { getEip7702AuthorizationSigner, mergeStorageMap, packUserOp, - getUserOpHash + getUserOpHash, getAuthorizationList } from '@account-abstraction/utils' import { EventsManager } from './EventsManager' @@ -410,7 +410,8 @@ export class BundleManager implements IBundleManager { } mergeStorageMap(storageMap, validationResult.storageMap) - for (const eip7702Authorization of entry.userOp.authorizationList ?? []) { + const authorizationList = getAuthorizationList(entry.userOp) + for (const eip7702Authorization of authorizationList) { const existingAuthorization = sharedAuthorizationList .find(it => { return getEip7702AuthorizationSigner(it) === getEip7702AuthorizationSigner(eip7702Authorization) @@ -420,8 +421,8 @@ export class BundleManager implements IBundleManager { // eslint-disable-next-line no-labels continue mainLoop } - if (existingAuthorization == null && entry.userOp.authorizationList != null) { - sharedAuthorizationList.push(...entry.userOp.authorizationList) + if (existingAuthorization == null && authorizationList.length > 0) { + sharedAuthorizationList.push(...authorizationList) } } diff --git a/packages/bundler/test/BundlerManager.test.ts b/packages/bundler/test/BundlerManager.test.ts index 44d46298..a855f33c 100644 --- a/packages/bundler/test/BundlerManager.test.ts +++ b/packages/bundler/test/BundlerManager.test.ts @@ -78,8 +78,7 @@ describe('#BundlerManager', () => { verificationGasLimit: 7, maxFeePerGas: 8, maxPriorityFeePerGas: 9, - preVerificationGas: 10, - authorizationList: [] + preVerificationGas: 10 } const hash = await entryPoint.getUserOpHash(packUserOp(userOp)) @@ -161,8 +160,7 @@ describe('#BundlerManager', () => { verificationGasLimit: '0x50000', maxFeePerGas: '0x0', maxPriorityFeePerGas: '0x0', - preVerificationGas: '0x50000', - authorizationList: [] + preVerificationGas: '0x50000' } const userOp1: UserOperation = { ...cEmptyUserOp, diff --git a/packages/bundler/test/UserOpMethodHandler.test.ts b/packages/bundler/test/UserOpMethodHandler.test.ts index ec319d68..84d44af8 100644 --- a/packages/bundler/test/UserOpMethodHandler.test.ts +++ b/packages/bundler/test/UserOpMethodHandler.test.ts @@ -345,8 +345,7 @@ describe('UserOpMethodHandler', function () { preVerificationGas: 50000, maxFeePerGas: 1e6, maxPriorityFeePerGas: 1e6, - signature: Buffer.from('emit-msg'), - authorizationList: [] + signature: Buffer.from('emit-msg') } await entryPoint.depositTo(acc.address, { value: parseEther('1') }) // await signer.sendTransaction({to:acc.address, value: parseEther('1')}) diff --git a/packages/bundler/test/ValidateManager.test.ts b/packages/bundler/test/ValidateManager.test.ts index 4d7bc48f..129869bf 100644 --- a/packages/bundler/test/ValidateManager.test.ts +++ b/packages/bundler/test/ValidateManager.test.ts @@ -45,8 +45,7 @@ const cEmptyUserOp: UserOperation = { verificationGasLimit: 50000, maxFeePerGas: 0, maxPriorityFeePerGas: 0, - preVerificationGas: 0, - authorizationList: [] + preVerificationGas: 0 } describe('#ValidationManager', () => { diff --git a/packages/sdk/test/0-utils.test.ts b/packages/sdk/test/0-utils.test.ts index c687b50f..68c4be02 100644 --- a/packages/sdk/test/0-utils.test.ts +++ b/packages/sdk/test/0-utils.test.ts @@ -63,8 +63,7 @@ describe('utils', () => { callData: '333', maxFeePerGas: 5, maxPriorityFeePerGas: 6, - signature: '777', - authorizationList: [] + signature: '777' })).to.eql({ sender: 'a', nonce: '0x01', @@ -95,8 +94,7 @@ describe('utils', () => { paymaster, paymasterVerificationGasLimit: 8, paymasterPostOpGasLimit: 9, - paymasterData: '0xcafebabe', - authorizationList: [] + paymasterData: '0xcafebabe' })).to.eql({ sender: 'a', nonce: '0x01', diff --git a/packages/sdk/test/1-SimpleAccountAPI.test.ts b/packages/sdk/test/1-SimpleAccountAPI.test.ts index 03eadf3c..ed6a052d 100644 --- a/packages/sdk/test/1-SimpleAccountAPI.test.ts +++ b/packages/sdk/test/1-SimpleAccountAPI.test.ts @@ -53,8 +53,7 @@ describe('SimpleAccountAPI', () => { preVerificationGas: 7, maxFeePerGas: 8, maxPriorityFeePerGas: 9, - signature: '0xbbbb', - authorizationList: [] + signature: '0xbbbb' } const hash = await api.getUserOpHash(userOp) const epHash = await entryPoint.getUserOpHash(packUserOp(userOp)) diff --git a/packages/utils/src/ERC4337Utils.ts b/packages/utils/src/ERC4337Utils.ts index b1b9e0d1..13f2815d 100644 --- a/packages/utils/src/ERC4337Utils.ts +++ b/packages/utils/src/ERC4337Utils.ts @@ -174,8 +174,7 @@ export function unpackUserOp (packed: PackedUserOperation): UserOperation { callGasLimit, maxFeePerGas, maxPriorityFeePerGas, - signature: packed.signature, - authorizationList: [] + signature: packed.signature } if (packed.initCode != null && packed.initCode.length > 2) { const factory = hexDataSlice(packed.initCode, 0, 20) diff --git a/packages/utils/src/Utils.ts b/packages/utils/src/Utils.ts index 1bde3b0b..09302a24 100644 --- a/packages/utils/src/Utils.ts +++ b/packages/utils/src/Utils.ts @@ -10,6 +10,7 @@ import { PackedUserOperationStruct } from './soltypes' import { UserOperation } from './interfaces/UserOperation' import { OperationBase } from './interfaces/OperationBase' import { OperationRIP7560 } from './interfaces/OperationRIP7560' +import { EIP7702Authorization } from './interfaces/EIP7702Authorization' export interface SlotMap { [slot: string]: string @@ -236,3 +237,12 @@ export function getPackedNonce (userOp: OperationBase): BigNumber { const bigNumberNonce = BigNumber.from(packed) return bigNumberNonce } + +export function getAuthorizationList (op: OperationBase): EIP7702Authorization[] { + const userOp = op as UserOperation + if (userOp.eip7712auth != null) { + return [userOp.eip7712auth] + } else { + return (op as OperationRIP7560).authorizationList ?? [] + } +} diff --git a/packages/utils/src/interfaces/OperationBase.ts b/packages/utils/src/interfaces/OperationBase.ts index ec540598..cddf756f 100644 --- a/packages/utils/src/interfaces/OperationBase.ts +++ b/packages/utils/src/interfaces/OperationBase.ts @@ -1,7 +1,5 @@ import { BigNumberish, BytesLike } from 'ethers' -import { EIP7702Authorization } from './EIP7702Authorization' - /** * The operation interface that is shared by ERC-4337 and RIP-7560 types. */ @@ -22,5 +20,4 @@ export interface OperationBase { verificationGasLimit: BigNumberish paymasterVerificationGasLimit?: BigNumberish paymasterPostOpGasLimit?: BigNumberish - authorizationList?: EIP7702Authorization[] } diff --git a/packages/utils/src/interfaces/OperationRIP7560.ts b/packages/utils/src/interfaces/OperationRIP7560.ts index c05161de..4bd7dd9c 100644 --- a/packages/utils/src/interfaces/OperationRIP7560.ts +++ b/packages/utils/src/interfaces/OperationRIP7560.ts @@ -1,5 +1,6 @@ import { OperationBase } from './OperationBase' import { BigNumberish, BytesLike } from 'ethers' +import { EIP7702Authorization } from './EIP7702Authorization' export interface OperationRIP7560 extends OperationBase { chainId: BigNumberish @@ -12,4 +13,6 @@ export interface OperationRIP7560 extends OperationBase { // todo: we discussed using 'nonceKey' in the JSON schema for ERC-4337 as well but we did not finalize this decision nonceKey: BigNumberish + + authorizationList?: EIP7702Authorization[] } diff --git a/packages/utils/src/interfaces/UserOperation.ts b/packages/utils/src/interfaces/UserOperation.ts index f7bc0fff..61a16e77 100644 --- a/packages/utils/src/interfaces/UserOperation.ts +++ b/packages/utils/src/interfaces/UserOperation.ts @@ -1,5 +1,6 @@ import { BigNumberish, BytesLike } from 'ethers' import { OperationBase } from './OperationBase' +import { EIP7702Authorization } from './EIP7702Authorization' export interface UserOperation extends OperationBase { // these fields have same meaning but different names between ERC-4337 and RIP-7560/RIP-7712 @@ -8,4 +9,5 @@ export interface UserOperation extends OperationBase { nonce: BigNumberish preVerificationGas: BigNumberish + eip7712auth?: EIP7702Authorization } diff --git a/packages/validation-manager/src/ValidationManager.ts b/packages/validation-manager/src/ValidationManager.ts index 6a69a8e3..cd56b406 100644 --- a/packages/validation-manager/src/ValidationManager.ts +++ b/packages/validation-manager/src/ValidationManager.ts @@ -28,7 +28,7 @@ import { packUserOp, requireAddressAndFields, requireCond, - runContractScript + runContractScript, getAuthorizationList } from '@account-abstraction/utils' import { tracerResultParser } from './TracerResultParser' @@ -222,7 +222,7 @@ export class ValidationManager implements IValidationManager { addresses: [], hash: '' } - const stateOverrideForEip7702 = await this.getAuthorizationsStateOverride(userOp.authorizationList ?? []) + const stateOverrideForEip7702 = await this.getAuthorizationsStateOverride(getAuthorizationList(userOp)) let storageMap: StorageMap = {} if (!this.unsafe) { let tracerResult: BundlerTracerResult