From eef235e61982f5427a2c974cc9f8abb89d6bbd7f Mon Sep 17 00:00:00 2001 From: superstar0402 Date: Thu, 7 Mar 2024 13:00:17 +0100 Subject: [PATCH] feat: crowdfunding contract (#4917) Crowdfunding contract implemented during offsite. --- aztec/src/note/note_header.nr | 8 +++++++- value-note/src/value_note.nr | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/aztec/src/note/note_header.nr b/aztec/src/note/note_header.nr index b807dee..27f8194 100644 --- a/aztec/src/note/note_header.nr +++ b/aztec/src/note/note_header.nr @@ -1,5 +1,5 @@ use dep::protocol_types::address::AztecAddress; -use dep::protocol_types::traits::Empty; +use dep::protocol_types::traits::{Empty, Serialize}; struct NoteHeader { contract_address: AztecAddress, @@ -21,3 +21,9 @@ impl NoteHeader { NoteHeader { contract_address, nonce, storage_slot, is_transient: false } } } + +impl Serialize<4> for NoteHeader { + fn serialize(self) -> [Field; 4] { + [self.contract_address.to_field(), self.nonce, self.storage_slot, self.is_transient as Field] + } +} diff --git a/value-note/src/value_note.nr b/value-note/src/value_note.nr index f29769e..f0d59d3 100644 --- a/value-note/src/value_note.nr +++ b/value-note/src/value_note.nr @@ -96,3 +96,11 @@ impl ValueNote { ValueNote { value, owner, randomness, header } } } + +impl Serialize<7> for ValueNote { + fn serialize(self) -> [Field; 7] { + let header = self.header.serialize(); + + [self.value, self.owner.to_field(), self.randomness, header[0], header[1], header[2], header[3]] + } +}