Skip to content

Commit

Permalink
create separate lib for token portal content hash
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-kothari committed Oct 11, 2023
1 parent 06bd42f commit e122e23
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 57 deletions.
3 changes: 2 additions & 1 deletion docs/docs/dev_docs/contracts/portals/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ Computing the `content` must be done manually in its current form, as we are sti
:::info
The `content_hash` is a sha256 truncated to a field element (~ 254 bits). In Aztec-nr, you can use our `sha256_to_field()` to do a sha256 hash which fits in one field element:

#include_code mint_public_content_hash_nr /yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/util.nr rust
#include_code mint_public_content_hash_nr /yarn-project/noir-contracts/src/contracts/token_portal_content_hash_lib/src/lib.nr rust


In solidity, you can use our `Hash.sha256ToField()` method:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ type = "contract"

[dependencies]
aztec = { path = "../../../../aztec-nr/aztec" }
token_portal_content_hash_lib = { path = "../token_portal_content_hash_lib" }
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mod utils;

// A contract used for testing a random hodgepodge of small features from simulator and end-to-end tests.
contract Test {
use dep::aztec::{
Expand All @@ -15,7 +13,7 @@ contract Test {
types::vec::BoundedVec,
constants_gen::EMPTY_NULLIFIED_COMMITMENT,
};
use crate::utils::{get_mint_private_content_hash, get_mint_public_content_hash};
use dep::token_portal_content_hash_lib::{get_mint_private_content_hash, get_mint_public_content_hash};

#[event]
struct ExampleEvent {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ compiler_version = "0.1"
type = "contract"

[dependencies]
aztec = { path = "../../../../aztec-nr/aztec" }
aztec = { path = "../../../../aztec-nr/aztec" }
token_portal_content_hash_lib = { path = "../token_portal_content_hash_lib" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod util;
mod token_interface;

// Minimal implementation of the token bridge that can move funds between L1 <> L2.
Expand All @@ -17,9 +16,9 @@ contract TokenBridge {
types::address::{AztecAddress, EthereumAddress},
selector::compute_selector,
};
use dep::token_portal_content_hash_lib::{get_mint_public_content_hash, get_mint_private_content_hash, get_withdraw_content_hash};

use crate::token_interface::Token;
use crate::util::{get_mint_public_content_hash, get_mint_private_content_hash, get_withdraw_content_hash};

// Storage structure, containing all storage, and specifying what slots they use.
struct Storage {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "token_portal_content_hash_lib"
authors = ["aztec-labs"]
compiler_version = "0.1"
type = "lib"

[dependencies]
aztec = { path = "../../../../aztec-nr/aztec" }

0 comments on commit e122e23

Please sign in to comment.