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
a8798268
Commit
a8798268
authored
Apr 03, 2023
by
James Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor _hasValidAttestation
parent
1ded9c45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
36 deletions
+46
-36
OptimistAllowlist.sol
...eriphery/contracts/universal/op-nft/OptimistAllowlist.sol
+46
-36
No files found.
packages/contracts-periphery/contracts/universal/op-nft/OptimistAllowlist.sol
View file @
a8798268
...
@@ -65,6 +65,26 @@ contract OptimistAllowlist is Semver {
...
@@ -65,6 +65,26 @@ contract OptimistAllowlist is Semver {
OPTIMIST_INVITER = _optimistInviter;
OPTIMIST_INVITER = _optimistInviter;
}
}
/**
* @notice Checks whether a given address is allowed to mint the Optimist NFT yet. Since the
* Optimist NFT will also be used as part of the Citizens House, mints are currently
* restricted. Eventually anyone will be able to mint.
*
* Currently, address is allowed to mint if it satisfies any of the following:
* 1) Has a valid 'optimist.can-mint' attestation from the allowlist attestor.
* 2) Has a valid 'coinbase.quest-eligible' attestation from Coinbase Quest attestor
* 3) Has a valid 'optimist.can-mint-from-invite' attestation from the OptimistInviter
* contract.
*
* @return Whether or not the address is allowed to mint yet.
*/
function isAllowedToMint(address _claimer) public view returns (bool) {
return
_hasAttestationFromAllowlistAttestor(_claimer) ||
_hasAttestationFromCoinbaseQuestAttestor(_claimer) ||
_hasAttestationFromOptimistInviter(_claimer);
}
/**
/**
* @notice Checks whether an address has a valid 'optimist.can-mint' attestation from the
* @notice Checks whether an address has a valid 'optimist.can-mint' attestation from the
* allowlist attestor.
* allowlist attestor.
...
@@ -74,12 +94,9 @@ contract OptimistAllowlist is Semver {
...
@@ -74,12 +94,9 @@ contract OptimistAllowlist is Semver {
* @return Whether or not the address has a valid attestation.
* @return Whether or not the address has a valid attestation.
*/
*/
function _hasAttestationFromAllowlistAttestor(address _claimer) internal view returns (bool) {
function _hasAttestationFromAllowlistAttestor(address _claimer) internal view returns (bool) {
// Expected attestation value is bytes32("true"), but we consider any non-zero value
// Expected attestation value is bytes32("true")
// to be truthy.
return
return
ATTESTATION_STATION
_hasValidAttestation(ALLOWLIST_ATTESTOR, _claimer, OPTIMIST_CAN_MINT_ATTESTATION_KEY);
.attestations(ALLOWLIST_ATTESTOR, _claimer, OPTIMIST_CAN_MINT_ATTESTATION_KEY)
.length > 0;
}
}
/**
/**
...
@@ -94,16 +111,13 @@ contract OptimistAllowlist is Semver {
...
@@ -94,16 +111,13 @@ contract OptimistAllowlist is Semver {
view
view
returns (bool)
returns (bool)
{
{
// Expected attestation value is bytes32("true"), but we consider any non-zero value
// Expected attestation value is bytes32("true")
// to be truthy.
return
return
ATTESTATION_STATION
_hasValidAttestation(
.attestations(
COINBASE_QUEST_ATTESTOR,
COINBASE_QUEST_ATTESTOR,
_claimer,
_claimer,
COINBASE_QUEST_ELIGIBLE_ATTESTATION_KEY
COINBASE_QUEST_ELIGIBLE_ATTESTATION_KEY
);
)
.length > 0;
}
}
/**
/**
...
@@ -114,34 +128,30 @@ contract OptimistAllowlist is Semver {
...
@@ -114,34 +128,30 @@ contract OptimistAllowlist is Semver {
* @return Whether or not the address has a valid attestation.
* @return Whether or not the address has a valid attestation.
*/
*/
function _hasAttestationFromOptimistInviter(address _claimer) internal view returns (bool) {
function _hasAttestationFromOptimistInviter(address _claimer) internal view returns (bool) {
// Expected attestation value is the inviter's address
, but we just check that it's set.
// Expected attestation value is the inviter's address
return
return
ATTESTATION_STATION
_hasValidAttestation(
.attestations(
OPTIMIST_INVITER,
OPTIMIST_INVITER,
_claimer,
_claimer,
OptimistConstants.OPTIMIST_CAN_MINT_FROM_INVITE_ATTESTATION_KEY
OptimistConstants.OPTIMIST_CAN_MINT_FROM_INVITE_ATTESTATION_KEY
);
)
.length > 0;
}
}
/**
/**
* @notice Checks whether a given address is allowed to mint the Optimist NFT yet. Since the
* @notice Checks whether an address has a valid truthy attestation.
* Optimist NFT will also be used as part of the Citizens House, mints are currently
* Any attestation val other than bytes32("") is considered truthy.
* restricted. Eventually anyone will be able to mint.
*
*
* Currently, address is allowed to mint if it satisfies any of the following:
* @param _creator Address that made the attestation.
* 1) Has a valid 'optimist.can-mint' attestation from the allowlist attestor.
* @param _about Address attestation is about.
* 2) Has a valid 'coinbase.quest-eligible' attestation from Coinbase Quest attestor
* @param _key Key of the attestation.
* 3) Has a valid 'optimist.can-mint-from-invite' attestation from the OptimistInviter
* contract.
*
*
* @return Whether or not the address
is allowed to mint yet
.
* @return Whether or not the address
has a valid truthy attestation
.
*/
*/
function isAllowedToMint(address _claimer) public view returns (bool) {
function _hasValidAttestation(
return
address _creator,
_hasAttestationFromAllowlistAttestor(_claimer) ||
address _about,
_hasAttestationFromCoinbaseQuestAttestor(_claimer) ||
bytes32 _key
_hasAttestationFromOptimistInviter(_claimer);
) internal view returns (bool) {
return ATTESTATION_STATION.attestations(_creator, _about, _key).length > 0;
}
}
}
}
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