-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
13 additions
and
59 deletions.
There are no files selected for viewing
35 changes: 3 additions & 32 deletions
35
noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
noir-projects/noir-contracts/contracts/avm_test_contract/src/note.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use dep::aztec::protocol_types::traits::{Deserialize, Packable, Serialize}; | ||
use std::meta::derive; | ||
|
||
#[derive(Deserialize, Packable, Serialize)] | ||
pub struct Note { | ||
a: Field, | ||
b: Field, | ||
} |
29 changes: 2 additions & 27 deletions
29
noir-projects/noir-contracts/contracts/fpc_contract/src/config.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,8 @@ | ||
use dep::aztec::protocol_types::{address::AztecAddress, traits::{Deserialize, Packable, Serialize}}; | ||
use std::meta::derive; | ||
|
||
global CONFIG_LENGTH: u32 = 2; | ||
|
||
#[derive(Deserialize, Packable, Serialize)] | ||
pub struct Config { | ||
pub accepted_asset: AztecAddress, // Asset the FPC accepts (denoted as AA below) | ||
pub admin: AztecAddress, // Address to which AA is sent during the private fee payment flow | ||
} | ||
|
||
impl Serialize<CONFIG_LENGTH> for Config { | ||
fn serialize(self: Self) -> [Field; CONFIG_LENGTH] { | ||
[self.accepted_asset.to_field(), self.admin.to_field()] | ||
} | ||
} | ||
|
||
impl Deserialize<CONFIG_LENGTH> for Config { | ||
fn deserialize(fields: [Field; CONFIG_LENGTH]) -> Self { | ||
Config { | ||
accepted_asset: AztecAddress::from_field(fields[0]), | ||
admin: AztecAddress::from_field(fields[1]), | ||
} | ||
} | ||
} | ||
|
||
impl Packable<CONFIG_LENGTH> for Config { | ||
fn pack(self) -> [Field; CONFIG_LENGTH] { | ||
self.serialize() | ||
} | ||
|
||
fn unpack(fields: [Field; CONFIG_LENGTH]) -> Self { | ||
Self::deserialize(fields) | ||
} | ||
} |