-
Notifications
You must be signed in to change notification settings - Fork 0
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
20240207 invite as org #87
Changes from 3 commits
5b8f8ab
e7385c6
5fdb8f3
fef78fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,13 @@ contract Hub is Circles { | |
*/ | ||
uint256 public constant WELCOME_BONUS = 3 * 24 * 10 ** 18; | ||
|
||
/** | ||
* @dev The minimum donation amount for registering a human as an organization, | ||
* paid in xDai, set to 0.1 xDai. The donation benefiary is arbitrary, and purely | ||
* reputational for the organization inviting people to Circles. | ||
*/ | ||
uint256 public constant MINIMUM_DONATION = 10 ** 17; | ||
|
||
/** | ||
* @dev The address used as the first element of the linked list of avatars. | ||
*/ | ||
|
@@ -262,6 +269,41 @@ contract Hub is Circles { | |
emit InviteHuman(msg.sender, _human); | ||
} | ||
|
||
/** | ||
* Invite human as organization allows to register a human avatar as an organization. | ||
* @param _human address of the human to invite | ||
* @param _donationReceiver address of where to send the donation to with 2300 gas (using transfer) | ||
*/ | ||
function inviteHumanAsOrganization(address _human, address payable _donationReceiver) external payable { | ||
require(msg.value > MINIMUM_DONATION, "Donation must be at least 0.1 xDai."); | ||
require(isOrganization(msg.sender), "Only organizations can invite."); | ||
|
||
// insert avatar into linked list; reverts if it already exists | ||
_insertAvatar(_human); | ||
|
||
// set the last mint time to the current timestamp for invited human | ||
// and register the v1 Circles contract status | ||
address v1CirclesStatus = _avatarV1CirclesStatus(_human); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's refactor the common parts of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I wanted to, but then thought I was overthinking it. Ill quickly do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. turned out it was well worth the refactoring! |
||
MintTime storage mintTime = mintTimes[_human]; | ||
mintTime.mintV1Status = v1CirclesStatus; | ||
mintTime.lastMintTime = uint96(block.timestamp); | ||
|
||
// invited receives the welcome bonus in their personal Circles | ||
_mint(_human, _toTokenId(_human), WELCOME_BONUS, ""); | ||
|
||
// set trust for a year, but organization can edit this later | ||
_trust(msg.sender, _human, uint96(block.timestamp + 365 days)); | ||
|
||
// set the trust for the invited to self to indefinite future; not editable later | ||
_trust(_human, _human, INDEFINITELY); | ||
|
||
// send the donation to the donation receiver but with minimal gas | ||
// to avoid reentrancy attacks | ||
_donationReceiver.transfer(msg.value); | ||
|
||
emit InviteHuman(msg.sender, _human); | ||
} | ||
|
||
/** | ||
* @notice Register group allows to register a group avatar. | ||
* @param _mint mint address will be called before minting group circles | ||
|
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.
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.
Makes it at least a little bit more expensive to perpetually invite people with the same funds.
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.
well, I agree, but you can always send to yourself over one-hop, so I don't know if we should block it. we already know that the donation is a reputation requirement for it to have meaning
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.
I added the requirement with comment