Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmychu0807 committed Oct 29, 2024
1 parent 1be45b4 commit b6394a0
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 8 deletions.
10 changes: 5 additions & 5 deletions script/DeployModule.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ contract DeployModuleScript is Script, RegistryDeployer {
function run() public {
// Setup module bytecode, deploy params, and data
bytes memory bytecode = type(MultiOwnerValidator).creationCode;
bytes memory deployParams = "";
bytes memory data = "";
bytes memory resolverContext = "";
bytes memory metadata = "";

// Get private key for deployment
vm.startBroadcast(vm.envUint("PK"));

// Deploy module
address module = deployModule({
code: bytecode,
deployParams: deployParams,
initCode: bytecode,
resolverContext: resolverContext,
salt: bytes32(0),
data: data
metadata: metadata
});

// Stop broadcast and log module address
Expand Down
14 changes: 14 additions & 0 deletions src/MultiOwnerValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ contract MultiOwnerValidator is ERC7579ValidatorBase {
: EIP1271_FAILED;
}

function validateSignatureWithData(
bytes32,
bytes calldata,
bytes calldata
)
external
view
virtual
override
returns (bool validSig)
{
return true;
}

function addOwner(uint256 ownerId, address owner) external {
require(owners[ownerId][msg.sender] == address(0), "Owner already exists");
owners[ownerId][msg.sender] = owner;
Expand Down
19 changes: 16 additions & 3 deletions src/SemaphoreMemberValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract SemaphoreMemberValidator is ERC7579ValidatorBase {
bytes32 userOpHash
) external view override returns (ValidationData) {

return _packValidationData(0, type(uint48).max, 0);
return _packValidationData(true, type(uint48).max, 0);
}

function isValidSignatureWithSender(
Expand All @@ -82,8 +82,21 @@ contract SemaphoreMemberValidator is ERC7579ValidatorBase {
return EIP1271_SUCCESS;
}

function validateSignatureWithData(
bytes32,
bytes calldata,
bytes calldata
)
external
view
virtual
override
returns (bool validSig)
{
return true;
}

function addMembers(uint256 user, uint256 gId, address[] calldata members) external {
function addMembers(address user, uint256 gId, uint256[] calldata memberCommitments) external {
if (!inUse[msg.sender]) {
revert ModuleNotInstalled(msg.sender);
}
Expand All @@ -93,7 +106,7 @@ contract SemaphoreMemberValidator is ERC7579ValidatorBase {
revert UserNotAdmin(gId, user);
}

semaphore.addMembers(gId, members);
semaphore.addMembers(gId, memberCommitments);
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down
15 changes: 15 additions & 0 deletions src/ValidatorTemplate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ contract ValidatorTemplate is ERC7579ValidatorBase {
return EIP1271_FAILED;
}

function validateSignatureWithData(
bytes32,
bytes calldata,
bytes calldata
)
external
view
virtual
override
returns (bool validSig)
{
return false;
}


/*//////////////////////////////////////////////////////////////////////////
INTERNAL
//////////////////////////////////////////////////////////////////////////*/
Expand Down
52 changes: 52 additions & 0 deletions test/SemaphoreMemberValidator.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import { Test } from "forge-std/Test.sol";
import {
RhinestoneModuleKit,
ModuleKitHelpers,
ModuleKitUserOp,
AccountInstance,
UserOpData
} from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_VALIDATOR } from "modulekit/external/ERC7579.sol";

import { Semaphore } from "@semaphore-protocol/Semaphore.sol";
import { SemaphoreVerifier } from "@semaphore-protocol/base/SemaphoreVerifier.sol";
import { ISemaphoreVerifier } from "@semaphore-protocol/interfaces/ISemaphoreVerifier.sol";

import { SemaphoreMemberValidator } from "src/SemaphoreMemberValidator.sol";

contract SemaphoreMemberValidatorTest is RhinestoneModuleKit, Test {
using ModuleKitHelpers for *;
using ModuleKitUserOp for *;

AccountInstance internal smartAcct;

Semaphore internal semaphore;
SemaphoreVerifier internal semaphoreVerifier;
SemaphoreMemberValidator internal validator;

Account user1;
Account user2;
Account admin;

function setUp() public {
init();

// Deploy Semaphore
semaphoreVerifier = new SemaphoreVerifier();
ISemaphoreVerifier isv = ISemaphoreVerifier(address(semaphoreVerifier));
semaphore = new Semaphore(isv);

// Create the validator
validator = new SemaphoreMemberValidator(address(semaphore));
vm.label(address(validator), "SemaphoreMemberValidator");

// Create some users
}

function test() public {

}
}

0 comments on commit b6394a0

Please sign in to comment.