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
add setUsername functionality #63
Conversation
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.
The core logic is correct, just need to remove some of the stuff around it. This pr also needs tests for this function. Just testing to make sure a username can't be double registered and that the old username is freed.
I'm going to publish a new version of the unirep stuff to npm today so it should be easier to build/test.
I get this error for
I saw this ethereum/solidity#13159, but I assumed it's not ok to add |
This is a really generic error that occurs anytime the transaction might revert. In this case you need to send the transaction from the Try something like this:
You also don't need the explicit assertions for tx success. You can replace
With
The |
Ah I totally forgot something for this PR. We need to actually attest to the epoch key to give the key the username! This functionality is blocked by #30 because you need the attestation function. You'll use the You can rebase this branch on top of |
I added |
949e9d9
to
3bf5dd1
Compare
packages/core/.node-version
Outdated
@@ -0,0 +1 @@ | |||
14.16.0 |
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.
This file still needs to be removed
@yuriko627 the files just need to be linted then this lgtm |
@@ -180,17 +180,36 @@ describe('Signup', function () { | |||
const newUsername4 = genRandomSalt().valueOf() | |||
const accounts = await ethers.getSigners() | |||
|
|||
const tx = await unirepSocialContract | |||
const tx1 = await unirepSocialContract |
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.
This is just a note, instead of using like tx1/tx2
variables you can put this logic inside a block like this:
...
const newUsername4 = genRandomSalt().valueOf()
const accounts = await ethers.getSigners()
{
const tx = await unirepSocialContract....
const receipt = await tx.wait()
expect(receipt.status)...
}
{
const tx = await unirepSocialContract....
const receipt = await tx.wait()
expect(receipt.status)...
}
This bracket blocks can exist anywhere in the code, not just around if
or for
or functions or other flow control structures. Then the variables are scoped to that block and gone after.
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 think epochKey
verification should be either in the backend or in the contract.
But it can be in another PR.
This PR LGTM.
* @param newUsername requested new user name | ||
*/ | ||
function setUsername( | ||
uint256 epochKey, |
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 am not sure whether epochKey
should be verified on-chain so that it will not be easily changed by other users (if we don't want an admin
to control)
Pull request checklist
Please check if your PR fulfills the following requirements:
yarn build
) was run locally and any changes were pushedyarn lint --check
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Closes #39
What is the new behavior?
Does this introduce a breaking change?
Other information