@@ -53,7 +53,10 @@ pub struct PrivateCallInterface<let N: u32, T, Env> {
5353
5454impl <let N : u32 , T , Env > PrivateCallInterface <N , T , Env > {
5555 pub fn call <let M : u32 >(self , context : &mut PrivateContext ) -> T where T : Deserialize <M > {
56- assert (self .args_hash == pack_arguments (self .args ));
56+ let packed_args_hash = unsafe {
57+ pack_arguments (self .args )
58+ };
59+ assert (self .args_hash == packed_args_hash );
5760 let returns = context .call_private_function_with_packed_args (
5861 self .target_contract ,
5962 self .selector ,
@@ -66,13 +69,19 @@ impl<let N: u32, T, Env> PrivateCallInterface<N, T, Env> {
6669 }
6770
6871 pub fn view <let M : u32 >(self , context : &mut PrivateContext ) -> T where T : Deserialize <M > {
69- assert (self .args_hash == pack_arguments (self .args ));
72+ let packed_args_hash = unsafe {
73+ pack_arguments (self .args )
74+ };
75+ assert (self .args_hash == packed_args_hash );
7076 let returns = context .call_private_function_with_packed_args (self .target_contract , self .selector , self .args_hash , true , false );
7177 returns .unpack_into ()
7278 }
7379
7480 pub fn delegate_call <let M : u32 >(self , context : &mut PrivateContext ) -> T where T : Deserialize <M > {
75- assert (self .args_hash == pack_arguments (self .args ));
81+ let packed_args_hash = unsafe {
82+ pack_arguments (self .args )
83+ };
84+ assert (self .args_hash == packed_args_hash );
7685 let returns = context .call_private_function_with_packed_args (self .target_contract , self .selector , self .args_hash , false , true );
7786 returns .unpack_into ()
7887 }
@@ -96,7 +105,10 @@ pub struct PrivateVoidCallInterface<let N: u32, Env> {
96105
97106impl <let N : u32 , Env > PrivateVoidCallInterface <N , Env > {
98107 pub fn call (self , context : &mut PrivateContext ) {
99- assert (self .args_hash == pack_arguments (self .args ));
108+ let packed_args_hash = unsafe {
109+ pack_arguments (self .args )
110+ };
111+ assert (self .args_hash == packed_args_hash );
100112 context .call_private_function_with_packed_args (
101113 self .target_contract ,
102114 self .selector ,
@@ -107,12 +119,18 @@ impl<let N: u32, Env> PrivateVoidCallInterface<N, Env> {
107119 }
108120
109121 pub fn view (self , context : &mut PrivateContext ) {
110- assert (self .args_hash == pack_arguments (self .args ));
122+ let packed_args_hash = unsafe {
123+ pack_arguments (self .args )
124+ };
125+ assert (self .args_hash == packed_args_hash );
111126 context .call_private_function_with_packed_args (self .target_contract , self .selector , self .args_hash , true , false ).assert_empty ();
112127 }
113128
114129 pub fn delegate_call (self , context : &mut PrivateContext ) {
115- assert (self .args_hash == pack_arguments (self .args ));
130+ let packed_args_hash = unsafe {
131+ pack_arguments (self .args )
132+ };
133+ assert (self .args_hash == packed_args_hash );
116134 context .call_private_function_with_packed_args (self .target_contract , self .selector , self .args_hash , false , true ).assert_empty ();
117135 }
118136}
@@ -135,7 +153,10 @@ pub struct PrivateStaticCallInterface<let N: u32, T, Env> {
135153
136154impl <let N : u32 , T , Env > PrivateStaticCallInterface <N , T , Env > {
137155 pub fn view <let M : u32 >(self , context : &mut PrivateContext ) -> T where T : Deserialize <M > {
138- assert (self .args_hash == pack_arguments (self .args ));
156+ let packed_args_hash = unsafe {
157+ pack_arguments (self .args )
158+ };
159+ assert (self .args_hash == packed_args_hash );
139160 let returns = context .call_private_function_with_packed_args (self .target_contract , self .selector , self .args_hash , true , false );
140161 returns .unpack_into ()
141162 }
@@ -159,7 +180,10 @@ pub struct PrivateStaticVoidCallInterface<let N: u32, Env> {
159180
160181impl <let N : u32 , Env > PrivateStaticVoidCallInterface <N , Env > {
161182 pub fn view (self , context : &mut PrivateContext ) {
162- assert (self .args_hash == pack_arguments (self .args ));
183+ let packed_args_hash = unsafe {
184+ pack_arguments (self .args )
185+ };
186+ assert (self .args_hash == packed_args_hash );
163187 context .call_private_function_with_packed_args (self .target_contract , self .selector , self .args_hash , true , false ).assert_empty ();
164188 }
165189}
@@ -203,7 +227,10 @@ impl<let N: u32, T, Env> PublicCallInterface<N, T, Env> {
203227
204228 pub fn enqueue (self , context : &mut PrivateContext ) {
205229 let args_hash = hash_args (self .args );
206- assert (args_hash == pack_arguments (self .args ));
230+ let packed_args_hash = unsafe {
231+ pack_arguments (self .args )
232+ };
233+ assert (args_hash == packed_args_hash );
207234 context .call_public_function_with_packed_args (
208235 self .target_contract ,
209236 self .selector ,
@@ -215,7 +242,10 @@ impl<let N: u32, T, Env> PublicCallInterface<N, T, Env> {
215242
216243 pub fn enqueue_view (self , context : &mut PrivateContext ) {
217244 let args_hash = hash_args (self .args );
218- assert (args_hash == pack_arguments (self .args ));
245+ let packed_args_hash = unsafe {
246+ pack_arguments (self .args )
247+ };
248+ assert (args_hash == packed_args_hash );
219249 context .call_public_function_with_packed_args (
220250 self .target_contract ,
221251 self .selector ,
@@ -227,7 +257,10 @@ impl<let N: u32, T, Env> PublicCallInterface<N, T, Env> {
227257
228258 pub fn delegate_enqueue (self , context : &mut PrivateContext ) {
229259 let args_hash = hash_args (self .args );
230- assert (args_hash == pack_arguments (self .args ));
260+ let packed_args_hash = unsafe {
261+ pack_arguments (self .args )
262+ };
263+ assert (args_hash == packed_args_hash );
231264 context .call_public_function_with_packed_args (
232265 self .target_contract ,
233266 self .selector ,
@@ -277,7 +310,10 @@ impl<let N: u32, Env> PublicVoidCallInterface<N, Env> {
277310
278311 pub fn enqueue (self , context : &mut PrivateContext ) {
279312 let args_hash = hash_args (self .args );
280- assert (args_hash == pack_arguments (self .args ));
313+ let packed_args_hash = unsafe {
314+ pack_arguments (self .args )
315+ };
316+ assert (args_hash == packed_args_hash );
281317 context .call_public_function_with_packed_args (
282318 self .target_contract ,
283319 self .selector ,
@@ -289,7 +325,10 @@ impl<let N: u32, Env> PublicVoidCallInterface<N, Env> {
289325
290326 pub fn enqueue_view (self , context : &mut PrivateContext ) {
291327 let args_hash = hash_args (self .args );
292- assert (args_hash == pack_arguments (self .args ));
328+ let packed_args_hash = unsafe {
329+ pack_arguments (self .args )
330+ };
331+ assert (args_hash == packed_args_hash );
293332 context .call_public_function_with_packed_args (
294333 self .target_contract ,
295334 self .selector ,
@@ -301,7 +340,10 @@ impl<let N: u32, Env> PublicVoidCallInterface<N, Env> {
301340
302341 pub fn delegate_enqueue (self , context : &mut PrivateContext ) {
303342 let args_hash = hash_args (self .args );
304- assert (args_hash == pack_arguments (self .args ));
343+ let packed_args_hash = unsafe {
344+ pack_arguments (self .args )
345+ };
346+ assert (args_hash == packed_args_hash );
305347 context .call_public_function_with_packed_args (
306348 self .target_contract ,
307349 self .selector ,
@@ -342,7 +384,10 @@ impl<let N: u32, T, Env> PublicStaticCallInterface<N, T, Env> {
342384
343385 pub fn enqueue_view (self , context : &mut PrivateContext ) {
344386 let args_hash = hash_args (self .args );
345- assert (args_hash == pack_arguments (self .args ));
387+ let packed_args_hash = unsafe {
388+ pack_arguments (self .args )
389+ };
390+ assert (args_hash == packed_args_hash );
346391 context .call_public_function_with_packed_args (
347392 self .target_contract ,
348393 self .selector ,
@@ -382,7 +427,10 @@ impl<let N: u32, Env> PublicStaticVoidCallInterface<N, Env> {
382427
383428 pub fn enqueue_view (self , context : &mut PrivateContext ) {
384429 let args_hash = hash_args (self .args );
385- assert (args_hash == pack_arguments (self .args ));
430+ let packed_args_hash = unsafe {
431+ pack_arguments (self .args )
432+ };
433+ assert (args_hash == packed_args_hash );
386434 context .call_public_function_with_packed_args (
387435 self .target_contract ,
388436 self .selector ,
0 commit comments