diff --git a/src/ProxyFactory.sol b/src/ProxyFactory.sol index c925f64..c40a144 100644 --- a/src/ProxyFactory.sol +++ b/src/ProxyFactory.sol @@ -67,6 +67,8 @@ contract ProxyFactory is Ownable, EIP712 { /////// State Variables //////// //////////////////////////////// // contest distribution expiration + bytes32 internal constant _DEPLOY_AND_DISTRIBUTE_TYPEHASH = + keccak256("DeployAndDistribute(bytes32 contestId,address implementation,bytes data)"); uint256 public constant EXPIRATION_TIME = 7 days; uint256 public constant MAX_CONTEST_PERIOD = 28 days; @@ -163,7 +165,8 @@ contract ProxyFactory is Ownable, EIP712 { bytes calldata signature, bytes calldata data ) public returns (address) { - bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(contestId, implementation, data))); + bytes32 digest = + _hashTypedDataV4(keccak256(abi.encode(_DEPLOY_AND_DISTRIBUTE_TYPEHASH, contestId, implementation, data))); if (!organizer.isValidSignatureNow(digest, signature)) revert ProxyFactory__InvalidSignature(); bytes32 salt = _calculateSalt(organizer, contestId, implementation); if (saltToCloseTime[salt] == 0) revert ProxyFactory__ContestIsNotRegistered(); @@ -257,7 +260,7 @@ contract ProxyFactory is Ownable, EIP712 { /// @param proxy The proxy address /// @param data The prize distribution data function _distribute(address proxy, bytes calldata data) internal { - if (proxy.code.length == 0) revert ProxyFactory__ProxyIsNotAContract(); + if (proxy.code.length == 0) revert ProxyFactory__ProxyIsNotAContract(); (bool success,) = proxy.call(data); if (!success) revert ProxyFactory__DelegateCallFailed(); emit Distributed(proxy, data); diff --git a/test/integration/HelperContract.t.sol b/test/integration/HelperContract.t.sol index 09ee984..79bf77a 100644 --- a/test/integration/HelperContract.t.sol +++ b/test/integration/HelperContract.t.sol @@ -51,6 +51,10 @@ abstract contract HelperContract is Test { // test signer's key pair when testing meta tx // **these are all for test. should never use these in production** + // bytes32 internal constant _DEPLOY_AND_DISTRIBUTE_TYPEHASH = + // keccak256("DeployAndDistribute(bytes32 contestId,bytes data)"); + bytes32 internal constant _DEPLOY_AND_DISTRIBUTE_TYPEHASH = + keccak256("DeployAndDistribute(bytes32 contestId,address implementation,bytes data)"); uint256 public constant TEST_SIGNER_KEY = 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d; address public constant TEST_SIGNER = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; uint256 public constant TEST_SIGNER_KEY2 = 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a; diff --git a/test/integration/ProxyFactoryTest.t.sol b/test/integration/ProxyFactoryTest.t.sol index 27c24a5..b319892 100644 --- a/test/integration/ProxyFactoryTest.t.sol +++ b/test/integration/ProxyFactoryTest.t.sol @@ -777,7 +777,7 @@ contract ProxyFactoryTest is StdCheats, HelperContract { ); bytes32 randomId_ = keccak256(abi.encode("Jason", "001")); bytes memory sendingData = createData(); - bytes32 data = keccak256(abi.encode(randomId_, address(distributor), sendingData)); + bytes32 data = keccak256(abi.encode(_DEPLOY_AND_DISTRIBUTE_TYPEHASH, randomId_,address(distributor), sendingData)); bytes32 digest = ECDSA.toTypedDataHash(domainSeparatorV4, data); (uint8 v, bytes32 r, bytes32 s) = vm.sign(privateK, digest); bytes memory signature = abi.encodePacked(r, s, v);