Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
330e2859
Commit
330e2859
authored
Mar 28, 2023
by
James Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor EIP712 creator
parent
d5007be5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
58 deletions
+21
-58
OptimistInviter.t.sol
...s-periphery/contracts/foundry-tests/OptimistInviter.t.sol
+20
-57
ClaimableInviteEIP712TypedData.sol
...tracts/testing/helpers/ClaimableInviteEIP712TypedData.sol
+1
-1
No files found.
packages/contracts-periphery/contracts/foundry-tests/OptimistInviter.t.sol
View file @
330e2859
...
...
@@ -25,8 +25,6 @@ contract OptimistInviter_Initializer is Test {
bytes32 EIP712_DOMAIN_TYPEHASH;
ClaimableInviteEIP712TypedData claimableInviteEIP712TypedData;
address internal alice_inviteGranter;
address internal sally;
address internal ted;
...
...
@@ -85,11 +83,6 @@ contract OptimistInviter_Initializer is Test {
vm.expectEmit(true, true, true, true, address(optimistInviter));
emit Initialized(1);
optimistInviter.initialize("OptimistInviter");
claimableInviteEIP712TypedData = new ClaimableInviteEIP712TypedData(
"OptimistInviter",
optimistInviter.version()
);
}
/**
...
...
@@ -180,7 +173,7 @@ contract OptimistInviter_Initializer is Test {
claimableInvite,
_getSignature(
_issuerPrivateKey,
claimableInviteEIP712TypedData.getDigestWithDomain
(
ClaimableInviteEIP712TypedData.getDigest
(
claimableInvite,
_eip712Name,
_eip712Version,
...
...
@@ -283,48 +276,24 @@ contract OptimistInviter_Initializer is Test {
assertEq(_getInviteCount(_to), 3);
}
// /**
// * @notice Gets the hashed typed object for a EIP712 signature.
// */
// function _getStructHash(OptimistInviter.ClaimableInvite memory _claimableInvite)
// internal
// view
// returns (bytes32)
// {
// return
// keccak256(
// abi.encode(
// optimistInviter.CLAIMABLE_INVITE_TYPEHASH(),
// _claimableInvite.issuer,
// _claimableInvite.nonce
// )
// );
// }
// /**
// * @notice Gets the signable digest for a EIP712 signature.
// */
// function _getEIP712Digest(
// OptimistInviter.ClaimableInvite memory _claimableInvite,
// bytes memory _name,
// bytes memory _version,
// uint256 _chainid,
// address _verifyingContract
// ) internal view returns (bytes32) {
// bytes32 domainSeparator = keccak256(
// abi.encode(
// EIP712_DOMAIN_TYPEHASH,
// keccak256(_name),
// keccak256(_version),
// _chainid,
// _verifyingContract
// )
// );
// return
// keccak256(
// abi.encodePacked("\x19\x01", domainSeparator, _getStructHash(_claimableInvite))
// );
// }
/**
* @notice Issues 3 invites to the given address. Checks that all expected events are emitted
* and that state is updated correctly.
*/
function _getEIP712Digest(OptimistInviter.ClaimableInvite memory _claimableInvite)
internal
view
returns (bytes32)
{
return
ClaimableInviteEIP712TypedData.getDigest(
_claimableInvite,
bytes("OptimistInviter"),
bytes(optimistInviter.version()),
block.chainid,
address(optimistInviter)
);
}
}
contract OptimistInviterTest is OptimistInviter_Initializer {
...
...
@@ -578,13 +547,7 @@ contract OptimistInviterTest is OptimistInviter_Initializer {
nonce
);
bytes memory signature = _getSignature(
carolPrivateKey,
claimableInviteEIP712TypedData.getDigest(
claimableInvite,
)
);
bytes memory signature = _getSignature(carolPrivateKey, _getEIP712Digest(claimableInvite));
// Sally tries to claim the invite
_commitInviteAs(sally, signature);
...
...
packages/contracts-periphery/contracts/testing/helpers/ClaimableInviteEIP712TypedData.sol
View file @
330e2859
...
...
@@ -5,7 +5,7 @@ import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { OptimistInviter } from "../../universal/op-nft/OptimistInviter.sol";
/**
* Helper
contract
that generates the EIP712 digest for a ClaimableInvite.
* Helper
library
that generates the EIP712 digest for a ClaimableInvite.
*/
library ClaimableInviteEIP712TypedData {
bytes32 public constant CLAIMABLE_INVITE_TYPEHASH =
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment