Skip to content

Commit e639808

Browse files
committed
update syntax
1 parent 095b7b1 commit e639808

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

packages/contracts/noir/common/Nargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ compiler_version = ">=0.39.0"
66

77
[dependencies]
88
protocol_types = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "aztec-packages-v0.72.1", directory = "noir-projects/noir-protocol-circuits/crates/types" }
9-
bignum = { tag = "v0.4.2", git = "https://github.com/noir-lang/noir-bignum/" }
10-
nodash = { tag = "v0.39.4", git = "https://github.com/olehmisar/nodash/" }
9+
bignum = { tag = "v0.6.0", git = "https://github.com/noir-lang/noir-bignum/" }
10+
nodash = { tag = "v0.40.0", git = "https://github.com/olehmisar/nodash/" }

packages/contracts/noir/common/src/erc20_note.nr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// fails to compile if this file is moved to erc20 crate
22

3+
use super::note::Note;
4+
use nodash::ArrayExtensions;
5+
use protocol_types::traits::Serialize;
6+
37
pub struct Erc20Note {
48
pub owner: crate::WaAddress,
59
pub amount: crate::TokenAmount,
@@ -36,7 +40,7 @@ impl crate::Serialize<6> for Erc20Note {
3640
.owner
3741
.serialize()
3842
.concat(self.amount.token.serialize())
39-
.concat(self.amount.amount.limbs)
43+
.concat(self.amount.amount.limbs.map(|x| x.into()))
4044
.concat([self.randomness])
4145
}
4246
}

packages/contracts/noir/common/src/lib.nr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use bignum::{BigNum, fields::U256::U256Params};
1+
use bignum::BigNumTrait;
22
use protocol_types::hash::poseidon2_hash_with_separator;
33

44
mod context;
55
mod erc20_note;
6-
mod note;
6+
pub(crate) mod note;
77
mod owned_note;
88

99
pub use context::{Context, Result};
@@ -46,7 +46,7 @@ pub global GENERATOR_INDEX__NOTE_HASH: Field = 3;
4646
// Note: keep in sync with other languages
4747
pub global U256_LIMBS: u32 = 3;
4848

49-
pub type U256 = BigNum<U256_LIMBS, 257, U256Params>;
49+
pub type U256 = bignum::U256;
5050

5151
/// User address within the rollup
5252
#[derive(Eq, Serialize)]
@@ -74,7 +74,7 @@ pub struct TokenAmount {
7474

7575
impl TokenAmount {
7676
pub fn zero(token: crate::EthAddress) -> Self {
77-
Self { token, amount: U256::new() }
77+
Self { token, amount: U256::zero() }
7878
}
7979

8080
fn _check(self, other: Self) {

packages/contracts/noir/common/src/note.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use protocol_types::hash::poseidon2_hash_with_separator;
33
/// A marker trait to mark structs as notes
44
pub trait Note: crate::Serialize<_> {
55

6-
pub fn emit(self, context: &mut crate::Context) {
6+
fn emit(self, context: &mut crate::Context) {
77
context.push_note_hash(crate::compute_note_hash(self));
88
}
99
}

packages/contracts/noir/erc20/src/lib.nr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
pub use common::erc20_note::{Erc20Note, Erc20NoteConsumptionInputs};
22

33
pub mod Token {
4+
use common::Note;
5+
46
pub fn mint(
57
context: &mut common::Context,
68
to: common::WaAddress,

0 commit comments

Comments
 (0)