Skip to content

Commit

Permalink
feat(billboard): revise deployment & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed Nov 15, 2023
1 parent e7c3304 commit d282702
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 260 deletions.
36 changes: 23 additions & 13 deletions src/Billboard/Billboard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ contract Billboard is IBillboard {
address public admin;
mapping(address => bool) public whitelist;

constructor() {
constructor(address registry_, uint256 taxRate_, string memory name_, string memory symbol_) {
admin = msg.sender;
whitelist[msg.sender] = true;

// deploy operator only
if (registry_ != address(0)) {
registry = BillboardRegistry(registry_);
}
// deploy operator and registry
else {
registry = new BillboardRegistry(address(this), taxRate_, name_, symbol_);
}
}

//////////////////////////////
/// Modifiers
//////////////////////////////

modifier isValidAddress(address value_) {
if (value_ == address(0)) {
revert InvalidAddress();
}
_;
}

modifier isFromAdmin() {
if (msg.sender != admin) {
revert Unauthorized("admin");
Expand Down Expand Up @@ -63,10 +65,14 @@ contract Billboard is IBillboard {
//////////////////////////////

/// @inheritdoc IBillboard
function upgradeRegistry(address contract_) external isValidAddress(contract_) isFromAdmin {
registry = BillboardRegistry(contract_);
function setRegistryOperator(address operator_) external isFromAdmin {
registry.setOperator(operator_);
}

//////////////////////////////
/// Access control
//////////////////////////////

/// @inheritdoc IBillboard
function setIsOpened(bool value_) external isFromAdmin {
isOpened = value_;
Expand All @@ -87,9 +93,9 @@ contract Billboard is IBillboard {
//////////////////////////////

/// @inheritdoc IBillboard
function mintBoard(address to_) external isValidAddress(to_) isFromWhitelist {
if (!isOpened) {
revert MintClosed();
function mintBoard(address to_) external {
if (!isOpened && whitelist[msg.sender] != true) {
revert Unauthorized("whitelist");
}

registry.mintBoard(to_);
Expand Down Expand Up @@ -192,6 +198,10 @@ contract Billboard is IBillboard {
uint256 _nextAuctionId = registry.nextBoardAuctionId(tokenId_);
IBillboardRegistry.Auction memory _nextAuction = registry.getAuction(tokenId_, _nextAuctionId);

// TODO: check if current address already has bidded
// TODO: transfer ETH to registry
// TODO: set highestBidder

// create new auction and new bid if no next auction
if (_nextAuction.tokenId == 0) {
_newAuctionAndBid(tokenId_, amount_);
Expand Down
10 changes: 3 additions & 7 deletions src/Billboard/IBillboard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ interface IBillboard {
/// Error
//////////////////////////////

error InvalidAddress();

error Unauthorized(string type_);

error MintClosed();

error BoardNotFound();

error AuctionNotFound();
Expand All @@ -27,11 +23,11 @@ interface IBillboard {
//////////////////////////////

/**
* @notice Switch the registry logic contract to another one.
* @notice Set the address of operator to current registry contract.
*
* @param contract_ Address of new registry logic contract.
* @param operator_ Address of operator_.
*/
function upgradeRegistry(address contract_) external;
function setRegistryOperator(address operator_) external;

//////////////////////////////
/// Access control
Expand Down
Loading

0 comments on commit d282702

Please sign in to comment.