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

Requester can cancel answered note #8

Open
spalladino opened this issue Oct 4, 2023 · 3 comments
Open

Requester can cancel answered note #8

spalladino opened this issue Oct 4, 2023 · 3 comments

Comments

@spalladino
Copy link

I may be missing something, but since answer is not emitting a nullifier, the user is allowed to cancel a note already answered, right?

// Requester cancels a question - no real utility here, will be usefull when request bound an amount, waiting for the answer
#[aztec(private)]
fn cancel_question(question: Field) {
let storage = Storage::init(Context::private(&mut context));
let caller = context.msg_sender();
// create the Answer_getter_option: SELECT by address and max number of requests
let question_getter_option = NoteGetterOptions::new().select(0, question).select(1, caller).set_limit(1);
let question_note = storage.questions.get_notes(question_getter_option)[0].unwrap_unchecked();
// Assert that the question exists and is owned by the caller
assert(question_note.request == question);
assert(question_note.requester_address == caller);
// nullify the note
storage.questions.remove(question_note);
}

@skeletor-spaceman
Copy link
Contributor

you are correct, but I think the main difference is that we only pay for canceled questions, answers cannot be cancelled.
does this make sense? feel free to close if so :)

@spalladino
Copy link
Author

I think this will be clear when fees are added, right? The issue would be if the user can get a refund for cancelling a question that was already answered.

@skeletor-spaceman
Copy link
Contributor

I see what you mean. And yes, this will be way clearer when we add fees.
Also, even when a question has previously been answered. The flow for creating a new "instance" of that same questions is the same. The divinity will still get a new Question Note liked into the same nullifier as the Users Question Note.
The only difference in the flow is when the Divinity answers, it will need to provide both that newly created Question note and the original Answer Note.
This makes it so that the Answers are always the same, and then it nullifies the User Question Note & creates a new Answer Note for that User.

On this flow, the User, after creating the Question Note, can still nullify it to get the funds back, and in turn it will nullify the Question Note that the Divinity should use to replicate the Answer.

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

2 participants