@@ -16,7 +16,12 @@ use crate::note::{
16
16
use crate::oracle ;
17
17
use crate::types::vec::BoundedVec ;
18
18
19
- fn check_note_header <Note , N >(context : PrivateContext , storage_slot : Field , note_interface : NoteInterface <Note , N >, note : Note ) {
19
+ fn check_note_header <Note , N >(
20
+ context : PrivateContext ,
21
+ storage_slot : Field ,
22
+ note_interface : NoteInterface <Note , N >,
23
+ note : Note
24
+ ) {
20
25
let get_header = note_interface .get_header ;
21
26
let header = get_header (note );
22
27
let contract_address = context .this_address ();
@@ -31,7 +36,11 @@ fn check_note_fields<N>(fields: [Field; N], selects: BoundedVec<Option<Select>,
31
36
}
32
37
}
33
38
34
- fn check_notes_order <N >(fields_0 : [Field ; N ], fields_1 : [Field ; N ], sorts : BoundedVec <Option <Sort >, N >) {
39
+ fn check_notes_order <N >(
40
+ fields_0 : [Field ; N ],
41
+ fields_1 : [Field ; N ],
42
+ sorts : BoundedVec <Option <Sort >, N >
43
+ ) {
35
44
for i in 0 ..sorts .len {
36
45
let sort = sorts .get_unchecked (i ).unwrap_unchecked ();
37
46
let eq = fields_0 [sort .field_index ] == fields_1 [sort .field_index ];
@@ -44,7 +53,11 @@ fn check_notes_order<N>(fields_0: [Field; N], fields_1: [Field; N], sorts: Bound
44
53
}
45
54
}
46
55
47
- pub fn get_note <Note , N >(context : &mut PrivateContext , storage_slot : Field , note_interface : NoteInterface <Note , N >) -> Note {
56
+ pub fn get_note <Note , N >(
57
+ context : &mut PrivateContext ,
58
+ storage_slot : Field ,
59
+ note_interface : NoteInterface <Note , N >
60
+ ) -> Note {
48
61
let note = get_note_internal (storage_slot , note_interface );
49
62
50
63
check_note_header (*context , storage_slot , note_interface , note );
@@ -94,7 +107,8 @@ pub fn get_notes<Note, N, FILTER_ARGS>(
94
107
unconstrained fn get_note_internal <Note , N >(storage_slot : Field , note_interface : NoteInterface <Note , N >) -> Note {
95
108
let placeholder_note = [Option ::none ()];
96
109
let placeholder_fields = [0 ; GET_NOTE_ORACLE_RETURN_LENGTH ];
97
- oracle::notes:: get_notes (storage_slot ,
110
+ oracle::notes:: get_notes (
111
+ storage_slot ,
98
112
note_interface ,
99
113
0 ,
100
114
[],
@@ -104,7 +118,8 @@ unconstrained fn get_note_internal<Note, N>(storage_slot: Field, note_interface:
104
118
1 , // limit
105
119
0 , // offset
106
120
placeholder_note ,
107
- placeholder_fields )[0 ].unwrap () // Notice: we don't allow dummies to be returned from get_note (singular).
121
+ placeholder_fields
122
+ )[0 ].unwrap () // Notice: we don't allow dummies to be returned from get_note (singular).
108
123
}
109
124
110
125
unconstrained fn get_notes_internal <Note , N , FILTER_ARGS >(
@@ -115,7 +130,8 @@ unconstrained fn get_notes_internal<Note, N, FILTER_ARGS>(
115
130
let (num_selects , select_by , select_values , sort_by , sort_order ) = flatten_options (options .selects , options .sorts );
116
131
let placeholder_opt_notes = [Option ::none (); MAX_READ_REQUESTS_PER_CALL ];
117
132
let placeholder_fields = [0 ; GET_NOTES_ORACLE_RETURN_LENGTH ];
118
- let opt_notes = oracle::notes:: get_notes (storage_slot ,
133
+ let opt_notes = oracle::notes:: get_notes (
134
+ storage_slot ,
119
135
note_interface ,
120
136
num_selects ,
121
137
select_by ,
@@ -125,18 +141,24 @@ unconstrained fn get_notes_internal<Note, N, FILTER_ARGS>(
125
141
options .limit ,
126
142
options .offset ,
127
143
placeholder_opt_notes ,
128
- placeholder_fields );
144
+ placeholder_fields
145
+ );
129
146
130
147
let filter = options .filter ;
131
148
let filter_args = options .filter_args ;
132
149
filter (opt_notes , filter_args )
133
150
}
134
151
135
- unconstrained pub fn view_notes <Note , N >(storage_slot : Field , note_interface : NoteInterface <Note , N >, options : NoteViewerOptions <Note , N >) -> [Option <Note >; MAX_NOTES_PER_PAGE ] {
152
+ unconstrained pub fn view_notes <Note , N >(
153
+ storage_slot : Field ,
154
+ note_interface : NoteInterface <Note , N >,
155
+ options : NoteViewerOptions <Note , N >
156
+ ) -> [Option <Note >; MAX_NOTES_PER_PAGE ] {
136
157
let (num_selects , select_by , select_values , sort_by , sort_order ) = flatten_options (options .selects , options .sorts );
137
158
let placeholder_opt_notes = [Option ::none (); MAX_NOTES_PER_PAGE ];
138
159
let placeholder_fields = [0 ; VIEW_NOTE_ORACLE_RETURN_LENGTH ];
139
- oracle::notes:: get_notes (storage_slot ,
160
+ oracle::notes:: get_notes (
161
+ storage_slot ,
140
162
note_interface ,
141
163
num_selects ,
142
164
select_by ,
@@ -146,10 +168,14 @@ unconstrained pub fn view_notes<Note, N>(storage_slot: Field, note_interface: No
146
168
options .limit ,
147
169
options .offset ,
148
170
placeholder_opt_notes ,
149
- placeholder_fields )
171
+ placeholder_fields
172
+ )
150
173
}
151
174
152
- unconstrained fn flatten_options <Note , N >(selects : BoundedVec <Option <Select >, N >, sorts : BoundedVec <Option <Sort >, N >) -> (u8 , [u8 ; N ], [Field ; N ], [u8 ; N ], [u2 ; N ]) {
175
+ unconstrained fn flatten_options <Note , N >(
176
+ selects : BoundedVec <Option <Select >, N >,
177
+ sorts : BoundedVec <Option <Sort >, N >
178
+ ) -> (u8 , [u8 ; N ], [Field ; N ], [u8 ; N ], [u2 ; N ]) {
153
179
let mut num_selects = 0 ;
154
180
let mut select_by = [0 ; N ];
155
181
let mut select_values = [0 ; N ];
0 commit comments