Skip to content

Commit

Permalink
🚧 update contracts and interface
Browse files Browse the repository at this point in the history
  • Loading branch information
audsssy committed Oct 25, 2023
1 parent 44cc126 commit 2d871ac
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/KaliBerger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract KaliBerger is Storage {

function initialize(address dao, address daoFactory, address minter) external {
if (daoFactory != address(0)) {
init(dao, address(0));
init(dao);
this.setKaliDaoFactory(daoFactory);
this.setCertificateMinter(minter);
}
Expand Down Expand Up @@ -81,7 +81,7 @@ contract KaliBerger is Storage {
IERC721(token).safeTransferFrom(msg.sender, address(this), tokenId);

// Set creator
this.setCreator(token, tokenId, msg.sender);
setCreator(token, tokenId, msg.sender);
}

/// @notice Pull ERC721 NFT from escrow when it is idle.
Expand Down Expand Up @@ -148,7 +148,7 @@ contract KaliBerger is Storage {
function updateBalances(address token, uint256 tokenId, address impactDao, address patron) internal {
if (impactDao == address(0)) {
// Summon DAO with 50/50 ownership between creator and patron(s).
this.setImpactDao(token, tokenId, summonDao(token, tokenId, this.getCreator(token, tokenId), patron));
setImpactDao(token, tokenId, summonDao(token, tokenId, this.getCreator(token, tokenId), patron));
} else {
// Update DAO balance.
_balance(token, tokenId, impactDao);
Expand Down Expand Up @@ -198,7 +198,7 @@ contract KaliBerger is Storage {
);

// Store dao address for future.
this.setImpactDao(token, tokenId, impactDao);
setImpactDao(token, tokenId, impactDao);

// Increment number of impactDAOs.
incrementBergerCount();
Expand Down Expand Up @@ -336,7 +336,7 @@ contract KaliBerger is Storage {
this.setAddress(keccak256(abi.encodePacked("certificate.minter")), factory);
}

function setImpactDao(address token, uint256 tokenId, address impactDao) external payable onlyOperator {
function setImpactDao(address token, uint256 tokenId, address impactDao) internal {
this.setAddress(keccak256(abi.encode(token, tokenId, ".impactDao")), impactDao);
}

Expand All @@ -350,7 +350,7 @@ contract KaliBerger is Storage {
this.setUint(keccak256(abi.encode(token, tokenId, ".tax")), _tax);
}

function setCreator(address token, uint256 tokenId, address creator) external payable onlyOperator {
function setCreator(address token, uint256 tokenId, address creator) internal {
this.setAddress(keccak256(abi.encode(token, tokenId, ".creator")), creator);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Storage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ contract Storage {
/// Constructor
/// -----------------------------------------------------------------------

function init(address dao, address target) internal {
function init(address dao) internal {
_setDao(dao);
if (target != address(0)) booleanStorage[keccak256(abi.encodePacked("playground.", target))] = true;
}

/// -----------------------------------------------------------------------
Expand Down
53 changes: 50 additions & 3 deletions src/interface/IKaliBerger.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,55 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {KaliBerger} from "src/KaliBerger.sol";

interface IKaliBerger {
function getTax(address target, uint256 value) external view returns (uint256 _tax);
/// @notice ERC721 token logic.
function escrow(address token, uint256 tokenId) external payable;
function pull(address token, uint256 tokenId) external payable;
function setTokenDetail(address token, uint256 tokenId, string calldata detail) external payable;

/// @notice DAO logic.
function approve(address token, uint256 tokenId, bool sale, string calldata detail) external payable;
function balanceDao(address token, uint256 tokenId) external payable;
function setKaliDaoFactory(address factory) external payable;
function setCertificateMinter(address factory) external payable;
function setTax(address token, uint256 tokenId, uint256 _tax) external payable;

/// @notice Claim logic.
function claim() external payable;
function getUnclaimed(address user) external view returns (uint256);

/// @notice Buyer/Owner logic.
function buy(address token, uint256 tokenId, uint256 newPrice, uint256 currentPrice) external payable;
function setPrice(address token, uint256 tokenId, uint256 price) external payable;
function addDeposit(address token, uint256 tokenId, uint256 amount) external payable;
function exit(address token, uint256 tokenId, uint256 amount) external payable;

/// @notice DAO getter logic.
function getKaliDaoFactory() external view returns (address);
function getCertificateMinter() external view returns (address);
function getBergerCount() external view returns (uint256);
function getImpactDao(address token, uint256 tokenId) external view returns (address);
function getTokenPurchaseStatus(address token, uint256 tokenId) external view returns (bool);
function getTax(address token, uint256 tokenId) external view returns (uint256 _tax);

/// @notice ERC721 token getter logic.
function getPrice(address token, uint256 tokenId) external view returns (uint256);
function getCreator(address token, uint256 tokenId) external view returns (address);
function getTokenDetail(address token, uint256 tokenId) external view returns (string memory);
function getDeposit(address token, uint256 tokenId) external view returns (uint256);
function getTimeLastCollected(address token, uint256 tokenId) external view returns (uint256);
function getTimeAcquired(address token, uint256 tokenId) external view returns (uint256);
function getTimeHeld(address user) external view returns (uint256);
function getOwner(address token, uint256 tokenId) external view returns (address);

/// @notice Harberger Tax logic.
function getTotalCollected(address token, uint256 tokenId) external view returns (uint256);
function patronageToCollect(address token, uint256 tokenId) external view returns (uint256 amount);

/// @notice Patron logic.
function isPatron(address token, uint256 tokenId, address patron) external view returns (bool);
function getPatron(address token, uint256 tokenId, uint256 patronId) external view returns (address);
function getPatronId(address token, uint256 tokenId, address patron) external view returns (uint256);
function getPatronCount(address token, uint256 tokenId) external view returns (uint256);
function getPatronContribution(address token, uint256 tokenId, address patron) external view returns (uint256);
}

0 comments on commit 2d871ac

Please sign in to comment.