diff --git a/contracts/src/PBH4337Module.sol b/contracts/src/PBH4337Module.sol index cd1428d5..3f2e509d 100644 --- a/contracts/src/PBH4337Module.sol +++ b/contracts/src/PBH4337Module.sol @@ -9,11 +9,17 @@ import {ISafe} from "@4337/interfaces/Safe.sol"; import {SafeModuleSignatures} from "./lib/SafeModuleSignatures.sol"; contract PBHSafe4337Module is Safe4337Module { + /////////////////////////////////////////////////////////////////////////////// + /// STATE VARIABLES /// + ////////////////////////////////////////////////////////////////////////////// + /// @notice The length of an ECDSA signature. uint256 internal constant ECDSA_SIGNATURE_LENGTH = 65; + /// @notice The length of the timestamp bytes. /// @dev 6 bytes each for validAfter and validUntil. uint256 internal constant TIMESTAMP_BYTES = 12; + /// @notice The length of the encoded proof data. uint256 internal constant ENCODED_PROOF_BYTES = 352; @@ -24,6 +30,10 @@ contract PBHSafe4337Module is Safe4337Module { /// @dev This key is used to identify a PBH user operation. uint192 public immutable PBH_NONCE_KEY; + /////////////////////////////////////////////////////////////////////////////// + /// ERRORS /// + ////////////////////////////////////////////////////////////////////////////// + /// @notice Thrown when the proof size is invalid. error InvalidProofSize(); @@ -33,6 +43,10 @@ contract PBHSafe4337Module is Safe4337Module { /// @notice Thrown when the PBH Nonce Key is not initialized. error UninitializedNonceKey(); + /////////////////////////////////////////////////////////////////////////////// + /// FUNCTIONS /// + /////////////////////////////////////////////////////////////////////////////// + constructor(address entryPoint, address _pbhSignatureAggregator, uint192 _pbhNonceKey) Safe4337Module(entryPoint) { require(_pbhSignatureAggregator != address(0), AddressZero()); require(entryPoint != address(0), AddressZero()); diff --git a/contracts/src/PBHEntryPointImplV1.sol b/contracts/src/PBHEntryPointImplV1.sol index 500ec8da..69ab3892 100644 --- a/contracts/src/PBHEntryPointImplV1.sol +++ b/contracts/src/PBHEntryPointImplV1.sol @@ -61,6 +61,28 @@ contract PBHEntryPointImplV1 is IPBHEntryPoint, WorldIDImpl, ReentrancyGuardTran uint256 pbhGasLimit ); + /// @notice Emitted once for each successful PBH verification. + /// + /// @param sender The sender of this particular transaction or UserOp. + /// @param signalHash Signal hash associated with the PBHPayload. + /// @param payload The zero-knowledge proof that demonstrates the claimer is registered with World ID. + event PBH(address indexed sender, uint256 indexed signalHash, PBHPayload payload); + + /// @notice Emitted when the World ID address is set. + /// + /// @param worldId The World ID instance that will be used for verifying proofs. + event WorldIdSet(address indexed worldId); + + /// @notice Emitted when the number of PBH transactions allowed per month is set. + /// + /// @param numPbhPerMonth The number of allowed PBH transactions per month. + event NumPbhPerMonthSet(uint8 indexed numPbhPerMonth); + + /// @notice Emitted when setting the PBH gas limit. + /// + /// @param pbhGasLimit The gas limit for a PBH multicall transaction. + event PBHGasLimitSet(uint256 indexed pbhGasLimit); + /////////////////////////////////////////////////////////////////////////////// /// ERRORS /// ////////////////////////////////////////////////////////////////////////////// @@ -86,28 +108,6 @@ contract PBHEntryPointImplV1 is IPBHEntryPoint, WorldIDImpl, ReentrancyGuardTran /// @notice Thrown when setting the gas limit for a PBH multicall to 0 error InvalidPBHGasLimit(uint256 gasLimit); - /// @notice Emitted once for each successful PBH verification. - /// - /// @param sender The sender of this particular transaction or UserOp. - /// @param signalHash Signal hash associated with the PBHPayload. - /// @param payload The zero-knowledge proof that demonstrates the claimer is registered with World ID. - event PBH(address indexed sender, uint256 indexed signalHash, PBHPayload payload); - - /// @notice Emitted when the World ID address is set. - /// - /// @param worldId The World ID instance that will be used for verifying proofs. - event WorldIdSet(address indexed worldId); - - /// @notice Emitted when the number of PBH transactions allowed per month is set. - /// - /// @param numPbhPerMonth The number of allowed PBH transactions per month. - event NumPbhPerMonthSet(uint8 indexed numPbhPerMonth); - - /// @notice Emitted when setting the PBH gas limit. - /// - /// @param pbhGasLimit The gas limit for a PBH multicall transaction. - event PBHGasLimitSet(uint256 indexed pbhGasLimit); - /////////////////////////////////////////////////////////////////////////////// /// FUNCTIONS /// /////////////////////////////////////////////////////////////////////////////// diff --git a/contracts/src/PBHSignatureAggregator.sol b/contracts/src/PBHSignatureAggregator.sol index 4b55d69a..701a48a4 100644 --- a/contracts/src/PBHSignatureAggregator.sol +++ b/contracts/src/PBHSignatureAggregator.sol @@ -18,6 +18,20 @@ import {SafeModuleSignatures} from "./lib/SafeModuleSignatures.sol"; contract PBHSignatureAggregator is IAggregator { using ByteHasher for bytes; + /////////////////////////////////////////////////////////////////////////////// + /// STATE VARIABLES /// + ////////////////////////////////////////////////////////////////////////////// + + /// @notice The PBHVerifier contract. + IPBHEntryPoint public immutable pbhEntryPoint; + + /// @notice The WorldID contract. + IWorldID public immutable worldID; + + /////////////////////////////////////////////////////////////////////////////// + /// ERRORS /// + ////////////////////////////////////////////////////////////////////////////// + /// @notice Thrown when the Hash of the UserOperations is not /// in transient storage of the `PBHVerifier`. error InvalidUserOperations(); @@ -28,11 +42,9 @@ contract PBHSignatureAggregator is IAggregator { /// @notice Thrown when a zero address is passed as the PBHEntryPoint. error AddressZero(); - /// @notice The PBHVerifier contract. - IPBHEntryPoint public immutable pbhEntryPoint; - - /// @notice The WorldID contract. - IWorldID public immutable worldID; + /////////////////////////////////////////////////////////////////////////////// + /// FUNCTIONS /// + /////////////////////////////////////////////////////////////////////////////// constructor(address _pbhEntryPoint, address _worldID) { require(_pbhEntryPoint != address(0), AddressZero());