diff --git a/account-integrations/safe/src/SafeBlsPlugin.sol b/account-integrations/safe/src/SafeBlsPlugin.sol index ade52f8a..ce03447d 100644 --- a/account-integrations/safe/src/SafeBlsPlugin.sol +++ b/account-integrations/safe/src/SafeBlsPlugin.sol @@ -17,6 +17,8 @@ interface ISafe { ) external returns (bool success); } +error IncorrectSignatureLength(uint256 length); + contract SafeBlsPlugin is BaseAccount { // TODO: Use EIP 712 for domain separation bytes32 public constant BLS_DOMAIN = keccak256("eip4337.bls.domain"); @@ -73,7 +75,9 @@ contract SafeBlsPlugin is BaseAccount { UserOperation calldata userOp, bytes32 userOpHash ) internal view override returns (uint256 validationData) { - require(userOp.signature.length == 64, "VG: Sig bytes length must be 64"); + if (userOp.signature.length != 64) { + revert IncorrectSignatureLength(userOp.signature.length); + } uint256[2] memory decodedSignature = abi.decode(userOp.signature, (uint256[2])); diff --git a/account-integrations/safe/src/utils/SafeTypechainTypesHelper.sol b/account-integrations/safe/src/utils/TypechainTypesHelper.sol similarity index 100% rename from account-integrations/safe/src/utils/SafeTypechainTypesHelper.sol rename to account-integrations/safe/src/utils/TypechainTypesHelper.sol diff --git a/account-integrations/safe/test/hardhat/SafeBlsPlugin.test.ts b/account-integrations/safe/test/hardhat/SafeBlsPlugin.test.ts index 5c8f3772..cd0919fb 100644 --- a/account-integrations/safe/test/hardhat/SafeBlsPlugin.test.ts +++ b/account-integrations/safe/test/hardhat/SafeBlsPlugin.test.ts @@ -1,7 +1,7 @@ import { ethers } from "hardhat"; import { expect } from "chai"; import { AddressZero } from "@ethersproject/constants"; -import { utils } from "ethers-v5"; +import { getBytes, keccak256, solidityPacked } from "ethers"; import { UserOperationStruct } from "@account-abstraction/contracts"; import { calculateProxyAddress } from "./utils/calculateProxyAddress"; import { signer as hubbleBlsSigner } from "@thehubbleproject/bls"; @@ -33,9 +33,6 @@ describe("SafeBlsPlugin", () => { return { provider, userWallet, - entryPoint, - safe, - safeProxyFactory, }; }; @@ -47,11 +44,11 @@ describe("SafeBlsPlugin", () => { * 2. Executing a transaction is possible */ it("should pass the ERC4337 validation", async () => { - const { provider, userWallet, entryPoint, safe, safeProxyFactory } = + const { provider, userWallet } = await setupTests(); - const domain = utils.arrayify( - utils.keccak256(Buffer.from("eip4337.bls.domain")) + const domain = getBytes( + keccak256(Buffer.from("eip4337.bls.domain")) ); const signerFactory = await hubbleBlsSigner.BlsSignerFactory.new(); const blsSigner = signerFactory.getSigner(domain, BLS_PRIVATE_KEY); @@ -82,6 +79,7 @@ describe("SafeBlsPlugin", () => { const factoryAddress = await safeProxyFactory.getAddress(); const moduleInitializer = safeBlsPlugin.interface.encodeFunctionData( + // @ts-ignore Typescript linting isn't recognizing this function for some reason (Build still works fine) "enableMyself", [] ); @@ -158,7 +156,7 @@ describe("SafeBlsPlugin", () => { const userOperation = { ...unsignedUserOperation, - signature: utils.solidityPack(["uint256", "uint256"], userOpSignature), + signature: solidityPacked(["uint256", "uint256"], userOpSignature), }; // Uncomment to get a detailed debug message @@ -175,6 +173,7 @@ describe("SafeBlsPlugin", () => { try { const rcpt = await entryPoint.handleOps( + // @ts-ignore Typescript linting is showing an error for some reason (Build still works fine) [userOperation], ENTRYPOINT_ADDRESS );