-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Coupon mintlist system #101
Open
JamesEarle
wants to merge
15
commits into
development
Choose a base branch
from
fix/coupon-mintlist
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
62d1c67
WIP but finally got correct hashing through EIP712 and recovery of th…
JamesEarle f0cbd59
WIP but working correctly, snapshot here to have if need to rollback
JamesEarle b8f6f5d
more WIP as change to strings might complicate the hashing
JamesEarle fe103e9
improved working system, need to adjust remainder of tests and helpers
JamesEarle 773fdb3
all subregistrar tests passing
JamesEarle 85c5eb6
all tests passing
JamesEarle c66ab45
lint, clean comments a bit, ready for first pass at PR
JamesEarle 94586b2
update deploy config to have new eip712 helper
JamesEarle 6d7f6c3
updates for failing CI pipeline, custom config creation in test
JamesEarle 8475426
more test fixes for coupon creation in dc tests
JamesEarle 01405bd
lint fix
JamesEarle 67c0796
lint fix
JamesEarle cc83007
add helper to test mission list for appropriate failures
JamesEarle 8e6048c
fix hardcoded counts in deploy test to match number of contracts
JamesEarle 1132ff9
Merge branch 'development' into fix/coupon-mintlist
JamesEarle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.18; | ||
|
||
import { IEIP712Helper } from "./IEIP712Helper.sol"; | ||
import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; | ||
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; | ||
|
||
|
||
contract EIP712Helper is EIP712, IEIP712Helper { | ||
using ECDSA for bytes32; | ||
|
||
// TODO make this real, not the HH rootOwner | ||
// idea around creating signer in `hashCoupon` or similar | ||
// then storing that data, and in recreation we have to get the address that signed? | ||
// how do we bulk sign? | ||
address private constant COUPON_SIGNER = 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65; | ||
|
||
bytes32 private constant COUPON_TYPEHASH = keccak256( | ||
"Coupon(bytes32 parentHash,address registrantAddress,string domainLabel)" | ||
); | ||
|
||
constructor( | ||
string memory name, | ||
string memory version | ||
) EIP712(name, version) {} | ||
|
||
function hashCoupon(Coupon memory coupon) public view override returns (bytes32) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this be a pure function? |
||
return | ||
_hashTypedDataV4( | ||
keccak256( | ||
abi.encode( | ||
COUPON_TYPEHASH, | ||
coupon.parentHash, | ||
coupon.registrantAddress, | ||
keccak256(bytes(coupon.domainLabel)) | ||
) | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* @notice Recovers the account that signed a message using openzeppelin's ECDSA library. | ||
* @param coupon The unsigned coupon data | ||
* @param signature The signed message | ||
*/ | ||
function recoverSigner(Coupon memory coupon, bytes memory signature) public view override returns (address) { | ||
return _recoverSigner(coupon, signature); | ||
} | ||
|
||
function isCouponSigner(Coupon memory coupon, bytes memory signature) public view override returns (bool) { | ||
address signer = _recoverSigner(coupon, signature); | ||
return signer == COUPON_SIGNER; | ||
} | ||
|
||
function _recoverSigner(Coupon memory coupon, bytes memory signature) internal view returns (address) { | ||
bytes32 hash = hashCoupon(coupon); | ||
return hash.recover(signature); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.18; | ||
|
||
|
||
interface IEIP712Helper { | ||
struct Coupon { | ||
bytes32 parentHash; | ||
address registrantAddress; | ||
string domainLabel; | ||
} | ||
|
||
function hashCoupon( | ||
Coupon memory coupon | ||
) external view returns (bytes32); | ||
|
||
function recoverSigner( | ||
Coupon memory coupon, | ||
bytes memory signature | ||
) external view returns (address); | ||
|
||
function isCouponSigner( | ||
Coupon memory coupon, | ||
bytes memory signature | ||
) external view returns (bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, this should be a state var.