Skip to content
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

Submit ballot hashcode mismatch #6

Open
cauetomaz opened this issue Jan 12, 2024 · 7 comments
Open

Submit ballot hashcode mismatch #6

cauetomaz opened this issue Jan 12, 2024 · 7 comments

Comments

@cauetomaz
Copy link

I found the tool practical and functional! I just had one problem when trying to submit my basket, the signature in the metamask didn't arrive, then when I tried again there was a conflict in the submission hash code, so I just changed the allocated value of one of the projects and everything worked. Thank you for everyone's time and energy.

@owocki
Copy link
Contributor

owocki commented Jan 12, 2024

@carlbarrdahl perhaps we can help here?

@carlbarrdahl
Copy link
Contributor

Thanks for taking the time to report this @cauetomaz! Will look into it.

@carlbarrdahl carlbarrdahl changed the title Feedback Submit ballot hashcode mismatch Jan 19, 2024
@carlbarrdahl
Copy link
Contributor

I found the tool practical and functional! I just had one problem when trying to submit my basket, the signature in the metamask didn't arrive, then when I tried again there was a conflict in the submission hash code, so I just changed the allocated value of one of the projects and everything worked. Thank you for everyone's time and energy.

I haven't been able to reproduce this @cauetomaz. What wallet did you connect and sign with?

@cauetomaz
Copy link
Author

Hey carl! I signed with this adress 0xAcD59e854adf632d2322404198624F757C868C97, i dont know why this happened, i hope you find.

@carlbarrdahl
Copy link
Contributor

Hey carl! I signed with this adress 0xAcD59e854adf632d2322404198624F757C868C97, i dont know why this happened, i hope you find.

With Metamask or any other wallet?

@cauetomaz
Copy link
Author

Hey carl! I signed with this adress 0xAcD59e854adf632d2322404198624F757C868C97, i dont know why this happened, i hope you find.

With Metamask or any other wallet?

I used a metamask wallet on my android.

@carlbarrdahl
Copy link
Contributor

This was potentially caused by the updated ballot wasn't used (slow network connection could cause an older instance of the ballot to be used)

We now fetch the latest ballot (using refetch) before creating the message and signing it.

const { refetch } = useBallot();
const { mutateAsync, isLoading } = api.ballot.publish.useMutation({
onSuccess,
});
useBeforeUnload(isLoading, "You have unsaved changes, are you sure?");
const { signTypedDataAsync } = useSignTypedData();
return useMutation(async () => {
if (chain) {
const { data: ballot } = await refetch();
const message = {
total_votes: BigInt(sumBallot(ballot?.votes)),
project_count: BigInt(ballot?.votes?.length ?? 0),
hashed_votes: keccak256(Buffer.from(JSON.stringify(ballot?.votes))),
};
const signature = await signTypedDataAsync({
...ballotTypedData(chain?.id),
message,
});
return mutateAsync({ signature, message, chainId: chain?.id });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants