Skip to content

Commit

Permalink
Update Hub.sol
Browse files Browse the repository at this point in the history
Make it compile
  • Loading branch information
koeppelmann authored Jan 31, 2024
1 parent 7975a45 commit a9bbf87
Showing 1 changed file with 42 additions and 30 deletions.
72 changes: 42 additions & 30 deletions src/multitoken-graph/Hub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract Graph is ERC1155 {
// Constants
// TODO find hub deployment time
uint256 public constant hubV1START = 1604136263;

// People registering can mint up to one Circle per hour.
// todo: should this be implemented without branching, ie. all be contracts
Expand Down Expand Up @@ -77,9 +79,10 @@ contract Graph is ERC1155 {
// External functions

function registerHuman() external {
require(trusts(_inviter, msg.sender), "");

//require(trusts(_inviter, msg.sender), "");
// todo: v1 stopped & enable migration
require(...);
//require(...);
insertAvatar(msg.sender);
// mintPolicies[msg.sender] = PERSONAL_MINT;
lastMintTimes[msg.sender] = block.timestamp;
Expand All @@ -88,19 +91,24 @@ contract Graph is ERC1155 {
// todo: let's welcome mint re-introduced; 3 days not demurraged
}

function registerGroup(address _treasury, string _name, string _symbol) {
_registerGroup(msg.sender, standardGroupMint, _treasury);
function insertAvatar(address avatar) internal {
avatars[SENTINEL] = avatar;
avatars[avatar] = SENTINEL;
}

function registerGroup (address _treasury, string calldata _name, string calldata _symbol) external{
_registerGroup(msg.sender, standardGroupMint, _treasury, _name, _symbol);
}

function registerCustomGroup(address _mint, address _treasury) external {
function registerCustomGroup (address _mint, address _treasury, string calldata _name, string calldata _symbol) external{
// msg.sender controls membership
// minting: policy only
// redemption: treasury contract (ideally generated from a factory - outside protocol)
require(...);
_registerGroup(msg.sender, _mint, _treasury);
require(avatars[msg.sender] == address(0));
_registerGroup(msg.sender, _mint, _treasury, _name, _symbol);
}

function registerOrganization(string _name) {
function registerOrganization (string calldata _name) external{
insertAvatar(msg.sender);
lastMintTimes[msg.sender] = 0;
}
Expand All @@ -122,24 +130,27 @@ contract Graph is ERC1155 {

// msg.sender holds collateral, and MUST be accepted by group
// maybe less
function groupMint(address _group, address[] calldata _collateral, uint256[] calldata _amounts) {
function groupMint(address _group, uint256[] calldata _collateral, uint256[] calldata _amounts) external{
// check group and collateral exist
// de-demurrage amounts
// loop over collateral

require(
mintPolicies[_group].beforeMintPolicy(msg.sender, _group, _collateral, _amounts), "");
//require(
//mintPolicies[_group].beforeMintPolicy(msg.sender, _group, _collateral, _amounts), "");

sendBatchTransfer(to: _group.treasury) // treasury.on1155Received should only implement but nothing protocol related

_mint(msg.sender, _group, sumAmounts);
safeBatchTransferFrom(msg.sender, treasuries[_group], _collateral, _amounts, ""); // treasury.on1155Received should only implement but nothing protocol related

uint256 sumAmounts;
// TODO sum up amounts
sumAmounts = _amounts[0];
_mint(msg.sender, uint256(uint160(_group)), sumAmounts, "");
}

// check if path transfer can be fully ERC1155 compatible
// note: matrix math needs to consider mints, otherwise it won't add up

function singleSourcePathTransfer() {
require(msg.sender == _source)
function singleSourcePathTransfer() external{
//require(msg.sender == _source);
// todo: sender does not have to be registered; can be anyone
// can have multiple receivers
// can allow zero-nett amounts, ie. closed paths are ok
Expand All @@ -149,20 +160,20 @@ contract Graph is ERC1155 {
// emit Transfer intent events
}

function operatorPathTransfer() {
function operatorPathTransfer() external{
// msg.sender = oeprator
require("nett sources have approved operator");
//require("nett sources have approved operator");
}

function wrapInflationaryERC20() {
function wrapInflationaryERC20() external {
// pass on name() but not modified
}

function unwrapInflationaryERC20() {
function unwrapInflationaryERC20() external {

}

function wrapDemurrageERC20() {
function wrapDemurrageERC20() external {
// call on Hub for demurrage calculation in ERC20 contract

// dont do a global allowance; but do do an ERC20Permit
Expand All @@ -174,37 +185,38 @@ contract Graph is ERC1155 {
// do some unique name hash finding for personal circles
// register with a salt for avoiding malicious blockage

function uri(uint256 _id) external view override returns (string memory uri_) {

function uri(uint256 _id) public view override returns (string memory uri_) {
if (avatarIpfsUris[_id] != bytes32(0)) {
return uri_ = string(abi.encodedPacked("ipfs://f0", bytes32ToHex(avatarIpfsUris[_id]);
//return uri_ = string(abi.encodedPacked("ipfs://f0", bytes32ToHex(avatarIpfsUris[_id])));
} else {
return super.
return super.uri(_id);
}
}

function setUri(bytes32 _ipfsCid) external {
// msg.sender -> tokenId
avatarIpfsUris[uint256(msg.sender)] = _ipfsCid;
avatarIpfsUris[uint256(uint160(msg.sender))] = _ipfsCid;
}


// Internal functions

function toDemurrageAmount(uint256 _amount, uint256 _timestamp) {
function toDemurrageAmount(uint256 _amount, uint256 _timestamp) external {
// timestamp should be "stepfunction" the timestamp
// todo: ask where the best time step is

if (_time<hubV1start) {_time = block.timestamp}
if (_timestamp<hubV1START) {_timestamp = block.timestamp;}

// uint256 durationSinceStart = _time - hubV1start;
// do conversion
}

function ToInflationAmount(uint256 _amount, uint256 _timestamp) {
function ToInflationAmount(uint256 _amount, uint256 _timestamp) external {

}

function _registerGroup(address _avatar, address _mint, address _treasury, string _name, string _symbol) internal {
function _registerGroup(address _avatar, address _mint, address _treasury, string calldata _name, string calldata _symbol) internal {
// do
}
}
}

0 comments on commit a9bbf87

Please sign in to comment.