Skip to content

Commit

Permalink
Merge pull request #88 from CirclesUBI/20240201-register-avatars
Browse files Browse the repository at this point in the history
merging into develop
  • Loading branch information
benjaminbollen authored Feb 7, 2024
2 parents 9287ee6 + 3236900 commit 4628391
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions src/multitoken-graph/Hub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,17 @@ contract Hub is Circles {

// Events

event RegisterHuman(address indexed avatar, bytes32 cidV0Digest);
event RegisterHuman(address indexed avatar);
event InviteHuman(address indexed inviter, address indexed invited);
event RegisterOrganization(address indexed organization, string name, bytes32 cidV0Digest);
event RegisterOrganization(address indexed organization, string name);
event RegisterGroup(
address indexed group,
address indexed mint,
address indexed treasury,
string name,
string symbol,
bytes32 cidV0Digest
address indexed group, address indexed mint, address indexed treasury, string name, string symbol
);

event Trust(address indexed truster, address indexed trustee, uint256 expiryTime);

event CidV0(address indexed avatar, bytes32 cidV0Digest);

// Modifiers

/**
Expand Down Expand Up @@ -225,7 +222,9 @@ contract Hub is Circles {
// trust self indefinitely
_trust(msg.sender, msg.sender, INDEFINITELY);

emit RegisterHuman(msg.sender, _cidV0Digest);
emit RegisterHuman(msg.sender);

emit CidV0(msg.sender, _cidV0Digest);
}

/**
Expand Down Expand Up @@ -278,7 +277,9 @@ contract Hub is Circles {
// store the IPFS CIDv0 digest for the group metadata
tokenIdToCidV0Digest[_toTokenId(msg.sender)] = _cidV0Digest;

emit RegisterGroup(msg.sender, _mint, standardTreasury, _name, _symbol, _cidV0Digest);
emit RegisterGroup(msg.sender, _mint, standardTreasury, _name, _symbol);

emit CidV0(msg.sender, _cidV0Digest);
}

/**
Expand All @@ -301,7 +302,9 @@ contract Hub is Circles {
// store the IPFS CIDv0 digest for the group metadata
tokenIdToCidV0Digest[_toTokenId(msg.sender)] = _cidV0Digest;

emit RegisterGroup(msg.sender, _mint, _treasury, _name, _symbol, _cidV0Digest);
emit RegisterGroup(msg.sender, _mint, _treasury, _name, _symbol);

emit CidV0(msg.sender, _cidV0Digest);
}

function registerOrganization(string calldata _name, bytes32 _cidV0Digest) external {
Expand All @@ -314,7 +317,9 @@ contract Hub is Circles {
// store the IPFS CIDv0 digest for the organization metadata
tokenIdToCidV0Digest[_toTokenId(msg.sender)] = _cidV0Digest;

emit RegisterOrganization(msg.sender, _name, _cidV0Digest);
emit RegisterOrganization(msg.sender, _name);

emit CidV0(msg.sender, _cidV0Digest);
}

/**
Expand Down Expand Up @@ -425,24 +430,16 @@ contract Hub is Circles {
// and how?
}

// do some unique name hash finding for personal circles
// register with a salt for avoiding malicious blockage

/**
* uri returns the IPFS URI for the ERC1155 token.
* If the
* @param _id tokenId of the ERC1155 token
* set IPFS CIDv0 digest for the avatar metadata.
* @param _ipfsCid IPFS CIDv0 digest for the avatar metadata
*/
function uri(uint256 _id) public view override returns (string memory uri_) {
// todo: fallback should move into SDK rather than contract
// "https://fallback.aboutcircles.com/v1/profile/{id}.json"
return super.uri(_id);
}

function setIpfsCidV0(bytes32 _ipfsCid) external {
require(avatars[msg.sender] != address(0), "Avatar must be registered.");
// todo: we should charge in CRC, but better done later through a storage market
tokenIdToCidV0Digest[_toTokenId(msg.sender)] = _ipfsCid;

emit CidV0(msg.sender, _ipfsCid);
}

function toDemurrageAmount(uint256 _amount, uint256 _timestamp) external {
Expand Down Expand Up @@ -472,6 +469,18 @@ contract Hub is Circles {
&& mintTimes[_organization].lastMintTime == uint256(0);
}

/**
* uri returns the IPFS URI for the ERC1155 token.
* If the
* @param _id tokenId of the ERC1155 token
*/
function uri(uint256 _id) public view override returns (string memory uri_) {
// todo: should fallback move into SDK rather than contract ?
// todo: we don't need to override this function if we keep this pattern
// "https://fallback.aboutcircles.com/v1/profile/{id}.json"
return super.uri(_id);
}

// Internal functions

function _trust(address _truster, address _trustee, uint96 _expiry) internal {
Expand Down

0 comments on commit 4628391

Please sign in to comment.