-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bad contract txs publishing contract data
- Loading branch information
Showing
8 changed files
with
332 additions
and
9 deletions.
There are no files selected for viewing
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
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
yarn-project/noir-contracts/src/contracts/test_assert_contract/Nargo.toml
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 @@ | ||
[package] | ||
name = "test_assert_contract" | ||
authors = [""] | ||
compiler_version = "0.1" | ||
type = "contract" | ||
|
||
[dependencies] | ||
aztec = { path = "../../../../aztec-nr/aztec" } |
276 changes: 276 additions & 0 deletions
276
yarn-project/noir-contracts/src/contracts/test_assert_contract/src/interface.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,276 @@ | ||
/* Autogenerated file, do not edit! */ | ||
|
||
use dep::std; | ||
use dep::aztec::context::{ PrivateContext, PublicContext }; | ||
use dep::aztec::constants_gen::RETURN_VALUES_LENGTH; | ||
|
||
struct AStructTestCodeGenStruct { | ||
amount: Field, | ||
secretHash: Field, | ||
} | ||
|
||
struct ADeepStructTestCodeGenStruct { | ||
aField: Field, | ||
aBool: bool, | ||
aNote: ANoteADeepStructTestCodeGenStruct, | ||
manyNotes: [ManyNotesADeepStructTestCodeGenStruct;3], | ||
} | ||
|
||
struct ANoteADeepStructTestCodeGenStruct { | ||
amount: Field, | ||
secretHash: Field, | ||
} | ||
|
||
struct ManyNotesADeepStructTestCodeGenStruct { | ||
amount: Field, | ||
secretHash: Field, | ||
} | ||
|
||
|
||
// Interface for calling Test functions from a private context | ||
struct TestPrivateContextInterface { | ||
address: Field, | ||
} | ||
|
||
impl TestPrivateContextInterface { | ||
fn at(address: Field) -> Self { | ||
Self { | ||
address, | ||
} | ||
} | ||
|
||
fn assert_is_zero( | ||
self, | ||
context: &mut PrivateContext, | ||
value: Field | ||
) { | ||
let mut serialized_args = [0; 1]; | ||
serialized_args[0] = value; | ||
|
||
context.call_public_function(self.address, 0x5438565f, serialized_args) | ||
} | ||
|
||
|
||
fn createL2ToL1MessagePublic( | ||
self, | ||
context: &mut PrivateContext, | ||
amount: Field, | ||
secretHash: Field | ||
) { | ||
let mut serialized_args = [0; 2]; | ||
serialized_args[0] = amount; | ||
serialized_args[1] = secretHash; | ||
|
||
context.call_public_function(self.address, 0xbac98727, serialized_args) | ||
} | ||
|
||
|
||
fn createNullifierPublic( | ||
self, | ||
context: &mut PrivateContext, | ||
amount: Field, | ||
secretHash: Field | ||
) { | ||
let mut serialized_args = [0; 2]; | ||
serialized_args[0] = amount; | ||
serialized_args[1] = secretHash; | ||
|
||
context.call_public_function(self.address, 0x42040a24, serialized_args) | ||
} | ||
|
||
|
||
fn emit_nullifier( | ||
self, | ||
context: &mut PrivateContext, | ||
nullifier: Field | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 1]; | ||
serialized_args[0] = nullifier; | ||
|
||
context.call_private_function(self.address, 0x82a8b183, serialized_args) | ||
} | ||
|
||
|
||
fn emit_unencrypted( | ||
self, | ||
context: &mut PrivateContext, | ||
value: Field | ||
) { | ||
let mut serialized_args = [0; 1]; | ||
serialized_args[0] = value; | ||
|
||
context.call_public_function(self.address, 0x817a64cb, serialized_args) | ||
} | ||
|
||
|
||
fn getPortalContractAddress( | ||
self, | ||
context: &mut PrivateContext, | ||
aztec_address: Field | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 1]; | ||
serialized_args[0] = aztec_address; | ||
|
||
context.call_private_function(self.address, 0xaf15a45f, serialized_args) | ||
} | ||
|
||
|
||
fn getPublicKey( | ||
self, | ||
context: &mut PrivateContext, | ||
address: Field | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 1]; | ||
serialized_args[0] = address; | ||
|
||
context.call_private_function(self.address, 0x88f0753b, serialized_args) | ||
} | ||
|
||
|
||
fn getThisAddress( | ||
self, | ||
context: &mut PrivateContext | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 0]; | ||
|
||
context.call_private_function(self.address, 0xd3953822, serialized_args) | ||
} | ||
|
||
|
||
fn getThisPortalAddress( | ||
self, | ||
context: &mut PrivateContext | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 0]; | ||
|
||
context.call_private_function(self.address, 0x82cc9431, serialized_args) | ||
} | ||
|
||
|
||
fn isTimeEqual( | ||
self, | ||
context: &mut PrivateContext, | ||
time: Field | ||
) { | ||
let mut serialized_args = [0; 1]; | ||
serialized_args[0] = time; | ||
|
||
context.call_public_function(self.address, 0xfff6026c, serialized_args) | ||
} | ||
|
||
|
||
fn testCodeGen( | ||
self, | ||
context: &mut PrivateContext, | ||
aField: Field, | ||
aBool: bool, | ||
aNumber: u32, | ||
anArray: [Field;2], | ||
aStruct: AStructTestCodeGenStruct, | ||
aDeepStruct: ADeepStructTestCodeGenStruct | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 17]; | ||
serialized_args[0] = aField; | ||
serialized_args[1] = aBool as Field; | ||
serialized_args[2] = aNumber as Field; | ||
serialized_args[3] = anArray[0]; | ||
serialized_args[4] = anArray[1]; | ||
serialized_args[5] = aStruct.amount; | ||
serialized_args[6] = aStruct.secretHash; | ||
serialized_args[7] = aDeepStruct.aField; | ||
serialized_args[8] = aDeepStruct.aBool as Field; | ||
serialized_args[9] = aDeepStruct.aNote.amount; | ||
serialized_args[10] = aDeepStruct.aNote.secretHash; | ||
serialized_args[11] = aDeepStruct.manyNotes[0].amount; | ||
serialized_args[12] = aDeepStruct.manyNotes[0].secretHash; | ||
serialized_args[13] = aDeepStruct.manyNotes[1].amount; | ||
serialized_args[14] = aDeepStruct.manyNotes[1].secretHash; | ||
serialized_args[15] = aDeepStruct.manyNotes[2].amount; | ||
serialized_args[16] = aDeepStruct.manyNotes[2].secretHash; | ||
|
||
context.call_private_function(self.address, 0x81d7c118, serialized_args) | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
// Interface for calling Test functions from a public context | ||
struct TestPublicContextInterface { | ||
address: Field, | ||
} | ||
|
||
impl TestPublicContextInterface { | ||
fn at(address: Field) -> Self { | ||
Self { | ||
address, | ||
} | ||
} | ||
|
||
fn assert_is_zero( | ||
self, | ||
context: PublicContext, | ||
value: Field | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 1]; | ||
serialized_args[0] = value; | ||
|
||
context.call_public_function(self.address, 0x5438565f, serialized_args) | ||
} | ||
|
||
|
||
fn createL2ToL1MessagePublic( | ||
self, | ||
context: PublicContext, | ||
amount: Field, | ||
secretHash: Field | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 2]; | ||
serialized_args[0] = amount; | ||
serialized_args[1] = secretHash; | ||
|
||
context.call_public_function(self.address, 0xbac98727, serialized_args) | ||
} | ||
|
||
|
||
fn createNullifierPublic( | ||
self, | ||
context: PublicContext, | ||
amount: Field, | ||
secretHash: Field | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 2]; | ||
serialized_args[0] = amount; | ||
serialized_args[1] = secretHash; | ||
|
||
context.call_public_function(self.address, 0x42040a24, serialized_args) | ||
} | ||
|
||
|
||
fn emit_unencrypted( | ||
self, | ||
context: PublicContext, | ||
value: Field | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 1]; | ||
serialized_args[0] = value; | ||
|
||
context.call_public_function(self.address, 0x817a64cb, serialized_args) | ||
} | ||
|
||
|
||
fn isTimeEqual( | ||
self, | ||
context: PublicContext, | ||
time: Field | ||
) -> [Field; RETURN_VALUES_LENGTH] { | ||
let mut serialized_args = [0; 1]; | ||
serialized_args[0] = time; | ||
|
||
context.call_public_function(self.address, 0xfff6026c, serialized_args) | ||
} | ||
|
||
} | ||
|
||
|
17 changes: 17 additions & 0 deletions
17
yarn-project/noir-contracts/src/contracts/test_assert_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// A contract used in end to end tests | ||
contract TestAssert { | ||
use dep::aztec::{ | ||
oracle::compute_selector::compute_selector, | ||
}; | ||
|
||
#[aztec(private)] | ||
fn constructor(value: Field) { | ||
let selector = compute_selector("assert_is_zero(Field)"); | ||
context.call_public_function(context.this_address(), selector, [value]); | ||
} | ||
|
||
#[aztec(public)] | ||
fn assert_is_zero(value: Field) { | ||
assert(0 == value); | ||
} | ||
} |
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
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
Oops, something went wrong.