-
Notifications
You must be signed in to change notification settings - Fork 36
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
Added new package hyperverse-evm-mintpass #84
base: feat/builderkit
Are you sure you want to change the base?
Conversation
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.
are you able to switch all the requires to use the new Solidity custom errors? Thank you!
Here are some references:
https://blog.soliditylang.org/2021/04/21/custom-errors/
error Unathorized(); |
revert Unathorized(); |
contractOwner = msg.sender; | ||
|
||
metadata = ModuleMetadata( | ||
'Token', |
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.
needs to be changed to MintPass
'Token', | |
'MintPass', |
*/ | ||
|
||
contract MintPassFactory is CloneFactory { | ||
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ S T A T E @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ |
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.
lets add a tenant counter to keep track of how many tenants we have
Counters.Counter public tenantCounter; |
_; | ||
} | ||
|
||
modifier isAllowedToCreateInstance(address _tenant) { |
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.
let's rename this to isAuthorized
modifier isAllowedToCreateInstance(address _tenant) { | |
modifier isAuthorized(address _tenant) { |
address private hyperverseAdmin = 0xD847C7408c48b6b6720CCa75eB30a93acbF5163D; | ||
|
||
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ M O D I F I E R S @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ | ||
modifier isOwner(address _tenant) { |
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.
we don't need this modifier here, but let's add a hasAnInstance modifier and use it in createInstance
modifier hasAnInstance(address _tenant) { |
} | ||
|
||
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ E V E N T S @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ | ||
|
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.
lets add a TenantCreated Event
event TenantCreated(address _tenant, address _proxy); |
and emit it on createInstance
|
||
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ F U N C T I O N S @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ | ||
|
||
function createInstance(string memory name, string memory symbol) external { |
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.
function createInstance(string memory name, string memory symbol) external { | |
function createInstance(address _tenant, string memory _name, string memory _symbol) external { |
lets keep the convention of using _ for function params
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ F U N C T I O N S @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ | ||
|
||
function createInstance(string memory name, string memory symbol) external { | ||
address tenant = msg.sender; |
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.
we shouldn't set tenant as the msg.sender since we are allowing a hyperverseAdmin to createInstance for others
string public _symbol; | ||
|
||
uint256 public tokenCounter; | ||
bool public initialized; |
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.
we can get rid of this initialized variable if we just use a modifier to check
reference:
modifier canInitialize(address _tenant) { |
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
contract MintPass is ERC1155, Ownable, IHyperverseModule { | ||
string public _name; |
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.
since _name and _symbol are public state variables let's remove the _
return tokenURI[_id]; | ||
} | ||
|
||
function name() public view returns (string memory) { |
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.
we can get rid of the name and symbol getters again since name and symbol are public state vars since Solidity creates those getter for us
Added new package hyperverse-evm-mintpass. This package includes MintPass, MintPassFactory, CloneFactory contracts, hardhat test scripts, etc.
related #83