Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

PR comment clean up #82

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion account-integrations/safe/src/SafeBlsPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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]));

Expand Down
15 changes: 7 additions & 8 deletions account-integrations/safe/test/hardhat/SafeBlsPlugin.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -33,9 +33,6 @@ describe("SafeBlsPlugin", () => {
return {
provider,
userWallet,
entryPoint,
safe,
safeProxyFactory,
};
};

Expand All @@ -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);
Expand Down Expand Up @@ -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",
[]
);
Expand Down Expand Up @@ -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
Expand All @@ -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
);
Expand Down