Skip to content

Add a reference note for each first issuance#124

Merged
ConstanceBeguier merged 12 commits intozsa1from
add_reference_notes
Dec 17, 2024
Merged

Add a reference note for each first issuance#124
ConstanceBeguier merged 12 commits intozsa1from
add_reference_notes

Conversation

@ConstanceBeguier
Copy link
Collaborator

When an asset is issue for the first time, we create a reference note which is a note with a value equal to zero and a recipient address equal to the reference recipient address.

@QED-it QED-it deleted a comment from what-the-diff bot Dec 9, 2024
Copy link
Collaborator

@PaulLaux PaulLaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added questions and comments.

Copy link
Collaborator

@PaulLaux PaulLaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added one last change

src/issuance.rs Outdated
Comment on lines +468 to +478
/// Validation for reference note
///
/// The following checks are performed:
/// - the note value of the reference note is equal to 0
/// - the asset of the reference note is equal to the provided asset
/// - the recipient of the reference note is equal to the reference recipient
pub fn verify_reference_note(note: &Note, asset: AssetBase) {
assert_eq!(note.value(), NoteValue::from_raw(0));
assert_eq!(note.asset(), asset);
assert_eq!(note.recipient(), ReferenceKeys::recipient());
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move it inside the test section. this code is not fit for real usage (no error handling)

Copy link
Collaborator Author

@ConstanceBeguier ConstanceBeguier Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use this function in tests/zsa.rs. Thus I cannot move it into test section.
Otherwise, I will have to duplicate it.

Copy link
Collaborator Author

@ConstanceBeguier ConstanceBeguier Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I duplicate the function in order to be able to move it into test section.
I have no access to ReferenceKeys::recipient() into tests/zsa.rs. Thus, I derived it from the zero SpendingKey.

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

Successfully merging this pull request may close these issues.

2 participants