-
Notifications
You must be signed in to change notification settings - Fork 599
Expand file tree
/
Copy pathmain.nr
More file actions
74 lines (64 loc) · 3.03 KB
/
main.nr
File metadata and controls
74 lines (64 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
mod test_contract_interface;
// Contract that uses the autogenerated interface of the Test contract for calling its functions.
// Used for testing calling into other contracts via autogenerated interfaces.
contract ImportTest {
use dep::aztec::prelude::AztecAddress;
use crate::test_contract_interface::{
TestPrivateContextInterface, TestPublicContextInterface, AStructTestCodeGenStruct,
ADeepStructTestCodeGenStruct, ANoteADeepStructTestCodeGenStruct,
ManyNotesADeepStructTestCodeGenStruct
};
// Calls the testCodeGen on the Test contract at the target address
// Used for testing calling a function with arguments of multiple types
// See yarn-project/simulator/src/client/private_execution.ts
// See yarn-project/end-to-end/src/e2e_nested_contract.test.ts
#[aztec(private)]
fn main(target: AztecAddress) -> Field {
let test_contract_instance = TestPrivateContextInterface::at(target);
let return_values = test_contract_instance.test_code_gen(
&mut context,
1,
true,
1 as u32,
[1, 2],
AStructTestCodeGenStruct { amount: 1, secret_hash: 2 },
ADeepStructTestCodeGenStruct {
a_field: 1,
a_bool: true,
a_note: ANoteADeepStructTestCodeGenStruct { amount: 1, secret_hash: 2 },
many_notes: [
ManyNotesADeepStructTestCodeGenStruct { amount: 1, secret_hash: 2 },
ManyNotesADeepStructTestCodeGenStruct { amount: 1, secret_hash: 2 },
ManyNotesADeepStructTestCodeGenStruct { amount: 1, secret_hash: 2 }
]
}
);
return_values[0]
}
// Calls the getThisAddress on the Test contract at the target address
// Used for testing calling a function with no arguments
// See yarn-project/end-to-end/src/e2e_nested_contract.test.ts
#[aztec(private)]
fn callNoArgs(target: AztecAddress) -> Field {
let test_contract_instance = TestPrivateContextInterface::at(target);
let return_values = test_contract_instance.get_this_address(&mut context);
return_values[0]
}
// Calls the createNullifierPublic on the Test contract at the target address
// Used for testing calling an open function
// See yarn-project/end-to-end/src/e2e_nested_contract.test.ts
#[aztec(private)]
fn callOpenFn(target: AztecAddress) {
let test_contract_instance = TestPrivateContextInterface::at(target);
test_contract_instance.create_nullifier_public(&mut context, 1, 2);
}
// Calls the createNullifierPublic on the Test contract at the target address
// Used for testing calling an open function from another open function
// See yarn-project/end-to-end/src/e2e_nested_contract.test.ts
#[aztec(public)]
fn pubCallOpenFn(target: AztecAddress) -> Field {
let test_contract_instance = TestPublicContextInterface::at(target);
let ret = test_contract_instance.create_nullifier_public(&mut context, 1, 2);
ret[0]
}
}