Commit 8e63cd2f authored by James Kim's avatar James Kim

create OptimistConstants library

parent b68f64af
...@@ -9,6 +9,7 @@ import { Optimist } from "../universal/op-nft/Optimist.sol"; ...@@ -9,6 +9,7 @@ import { Optimist } from "../universal/op-nft/Optimist.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { TestERC1271Wallet } from "../testing/helpers/TestERC1271Wallet.sol"; import { TestERC1271Wallet } from "../testing/helpers/TestERC1271Wallet.sol";
import { OptimistInviterHelper } from "../testing/helpers/OptimistInviterHelper.sol"; import { OptimistInviterHelper } from "../testing/helpers/OptimistInviterHelper.sol";
import { OptimistConstants } from "../universal/op-nft/libraries/OptimistConstants.sol";
contract OptimistInviter_Initializer is Test { contract OptimistInviter_Initializer is Test {
event InviteClaimed(address indexed issuer, address indexed claimer); event InviteClaimed(address indexed issuer, address indexed claimer);
...@@ -101,7 +102,7 @@ contract OptimistInviter_Initializer is Test { ...@@ -101,7 +102,7 @@ contract OptimistInviter_Initializer is Test {
bytes memory attestation = attestationStation.attestations( bytes memory attestation = attestationStation.attestations(
address(optimistInviter), address(optimistInviter),
_claimer, _claimer,
optimistInviter.CAN_MINT_FROM_INVITE_ATTESTATION_KEY() OptimistConstants.OPTIMIST_CAN_MINT_FROM_INVITE_ATTESTATION_KEY
); );
return attestation.length > 0; return attestation.length > 0;
} }
...@@ -212,7 +213,7 @@ contract OptimistInviter_Initializer is Test { ...@@ -212,7 +213,7 @@ contract OptimistInviter_Initializer is Test {
emit AttestationCreated( emit AttestationCreated(
address(optimistInviter), address(optimistInviter),
_claimer, _claimer,
optimistInviter.CAN_MINT_FROM_INVITE_ATTESTATION_KEY(), OptimistConstants.OPTIMIST_CAN_MINT_FROM_INVITE_ATTESTATION_KEY,
abi.encode(issuer) abi.encode(issuer)
); );
...@@ -394,7 +395,7 @@ contract OptimistInviterTest is OptimistInviter_Initializer { ...@@ -394,7 +395,7 @@ contract OptimistInviterTest is OptimistInviter_Initializer {
emit AttestationCreated( emit AttestationCreated(
address(optimistInviter), address(optimistInviter),
sally, sally,
optimistInviter.CAN_MINT_FROM_INVITE_ATTESTATION_KEY(), OptimistConstants.OPTIMIST_CAN_MINT_FROM_INVITE_ATTESTATION_KEY,
abi.encode(bob) abi.encode(bob)
); );
...@@ -550,7 +551,7 @@ contract OptimistInviterTest is OptimistInviter_Initializer { ...@@ -550,7 +551,7 @@ contract OptimistInviterTest is OptimistInviter_Initializer {
emit AttestationCreated( emit AttestationCreated(
address(optimistInviter), address(optimistInviter),
sally, sally,
optimistInviter.CAN_MINT_FROM_INVITE_ATTESTATION_KEY(), OptimistConstants.OPTIMIST_CAN_MINT_FROM_INVITE_ATTESTATION_KEY,
abi.encode(address(carolERC1271Wallet)) abi.encode(address(carolERC1271Wallet))
); );
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
import { OptimistConstants } from "./libraries/OptimistConstants.sol";
import { Semver } from "@eth-optimism/contracts-bedrock/contracts/universal/Semver.sol"; import { Semver } from "@eth-optimism/contracts-bedrock/contracts/universal/Semver.sol";
import { AttestationStation } from "./AttestationStation.sol"; import { AttestationStation } from "./AttestationStation.sol";
import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
...@@ -63,12 +64,6 @@ contract OptimistInviter is Semver, EIP712Upgradeable { ...@@ -63,12 +64,6 @@ contract OptimistInviter is Semver, EIP712Upgradeable {
*/ */
bytes32 public constant CAN_INVITE_ATTESTATION_KEY = bytes32("optimist.can-invite"); bytes32 public constant CAN_INVITE_ATTESTATION_KEY = bytes32("optimist.can-invite");
/**
* @notice Attestation key allowing the attested account to mint.
*/
bytes32 public constant CAN_MINT_FROM_INVITE_ATTESTATION_KEY =
bytes32("optimist.can-mint-from-invite");
/** /**
* @notice Granter who can set accounts' invite counts. * @notice Granter who can set accounts' invite counts.
*/ */
...@@ -297,7 +292,7 @@ contract OptimistInviter is Semver, EIP712Upgradeable { ...@@ -297,7 +292,7 @@ contract OptimistInviter is Semver, EIP712Upgradeable {
// The invite issuer is included in the data of the attestation. // The invite issuer is included in the data of the attestation.
ATTESTATION_STATION.attest( ATTESTATION_STATION.attest(
_claimer, _claimer,
CAN_MINT_FROM_INVITE_ATTESTATION_KEY, OptimistConstants.OPTIMIST_CAN_MINT_FROM_INVITE_ATTESTATION_KEY,
abi.encode(_claimableInvite.issuer) abi.encode(_claimableInvite.issuer)
); );
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
/**
* @title OptimistConstants
* @notice Library for storing constants related to the Optimist NFT shared in multiple contracts.
*/
library OptimistConstants {
/**
* @notice Attestation key issued by OptimistInviter allowing the attested account to mint.
*/
bytes32 internal constant OPTIMIST_CAN_MINT_FROM_INVITE_ATTESTATION_KEY =
bytes32("optimist.can-mint-from-invite");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment