Skip to content

Commit

Permalink
🐛 to be aligned with EIP712 standard using keccak256 (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
thurendous authored Oct 3, 2023
1 parent c6c030e commit 1d0f572
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/ProxyFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ contract ProxyFactory is Ownable, EIP712 {
bytes calldata signature,
bytes calldata data
) public returns (address) {
bytes32 digest =
_hashTypedDataV4(keccak256(abi.encode(_DEPLOY_AND_DISTRIBUTE_TYPEHASH, contestId, implementation, data)));
bytes32 digest = _hashTypedDataV4(
keccak256(abi.encode(_DEPLOY_AND_DISTRIBUTE_TYPEHASH, contestId, implementation, keccak256(data)))
);
if (!organizer.isValidSignatureNow(digest, signature)) revert ProxyFactory__InvalidSignature();
bytes32 salt = _calculateSalt(organizer, contestId, implementation);
if (saltToCloseTime[salt] == 0) revert ProxyFactory__ContestIsNotRegistered();
Expand Down
6 changes: 3 additions & 3 deletions test/integration/ProxyFactoryTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ contract ProxyFactoryTest is StdCheats, HelperContract {
bytes32 randomId_ = keccak256(abi.encode("Jason", "001"));
bytes memory sendingData = createData();
bytes32 data =
keccak256(abi.encode(_DEPLOY_AND_DISTRIBUTE_TYPEHASH, randomId_, address(distributor), sendingData));
keccak256(abi.encode(_DEPLOY_AND_DISTRIBUTE_TYPEHASH, randomId_, address(distributor), keccak256(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);
Expand Down Expand Up @@ -1355,7 +1355,7 @@ contract ProxyFactoryTest is StdCheats, HelperContract {
bytes32 randomId_ = keccak256(abi.encode("Jason", "001"));
bytes memory sendingData = createDataIncludesZeroAddress();
bytes32 data =
keccak256(abi.encode(_DEPLOY_AND_DISTRIBUTE_TYPEHASH, randomId_, address(distributor), sendingData));
keccak256(abi.encode(_DEPLOY_AND_DISTRIBUTE_TYPEHASH, randomId_, address(distributor), keccak256(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);
Expand All @@ -1378,7 +1378,7 @@ contract ProxyFactoryTest is StdCheats, HelperContract {

bytes32 randomId = keccak256(abi.encode("Jason", "001"));
vm.warp(8.01 days);
// it won't succeeds
// it won't succeed
vm.expectRevert(ProxyFactory.ProxyFactory__DelegateCallFailed.selector);
proxyFactory.deployProxyAndDistributeBySignature(
TEST_SIGNER, randomId, address(distributor), signature, sendingData
Expand Down

0 comments on commit 1d0f572

Please sign in to comment.