Skip to content

Commit

Permalink
 attest to the epoch key to give the key the username
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriko627 committed Aug 30, 2022
1 parent b01c88a commit 949e9d9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/core/contracts/UnirepSocial.sol
Original file line number Diff line number Diff line change
Expand Up @@ -281,24 +281,27 @@ contract UnirepSocial {
uint256 oldUsername,
uint256 newUsername
) external {
(,,,,,,,uint attestingFee,,) = unirep.config();

// check if the new username is taken
require(usernames[newUsername] == false, "This user name is already taken");

// only admin can call this function
require(msg.sender == admin);

usernames[oldUsername] = false;
usernames[newUsername] = true;

// attest to the epoch key to give the key the username
Unirep.Attestation memory attestation;
attestation.attesterId = attesterId;
attestation.posRep = 0;
attestation.negRep = 0;
attestation.posRep = 1;
attestation.negRep = 1;
attestation.graffiti = newUsername;

unirep.submitAttestation{value: attestingFee}(
attestation,
epochKey
);

usernames[oldUsername] = false;
usernames[newUsername] = true;
}
}

0 comments on commit 949e9d9

Please sign in to comment.