Skip to content

Commit

Permalink
feat(avm): implement avm state getter opcodes within noir contracts (…
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 authored and AztecBot committed Feb 6, 2024
1 parent 3b6cc2d commit 0ffd0c9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions aztec/src/avm.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod context;
50 changes: 50 additions & 0 deletions aztec/src/avm/context.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use dep::protocol_types::address::{
AztecAddress,
EthAddress,
};

// Getters that will be converted by the transpiler into their
// own opcodes
struct AvmContext {}

// No new function as this struct is entirely static getters
impl AvmContext {
#[oracle(address)]
pub fn address() -> AztecAddress {}

#[oracle(storageAddress)]
pub fn storage_address() -> AztecAddress {}

#[oracle(origin)]
pub fn origin() -> AztecAddress {}

#[oracle(sender)]
pub fn sender() -> AztecAddress {}

#[oracle(portal)]
pub fn portal() -> EthAddress {}

#[oracle(feePerL1Gas)]
pub fn fee_per_l1_gas() -> Field {}

#[oracle(feePerL2Gas)]
pub fn fee_per_l2_gas() -> Field {}

#[oracle(feePerDaGas)]
pub fn fee_per_da_gas() -> Field {}

#[oracle(chainId)]
pub fn chain_id() -> Field {}

#[oracle(version)]
pub fn version() -> Field {}

#[oracle(blockNumber)]
pub fn block_number() -> Field {}

#[oracle(timestamp)]
pub fn timestamp() -> Field {}

// #[oracle(contractCallDepth)]
// pub fn contract_call_depth() -> Field {}
}
1 change: 1 addition & 0 deletions aztec/src/lib.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod abi;
mod avm;
mod context;
mod hash;
mod history;
Expand Down

0 comments on commit 0ffd0c9

Please sign in to comment.