@@ -11,12 +11,16 @@ impl Trait for DefaultImpl {
1111 fn exec ( env : & Env ) -> String {
1212 String :: from_str ( env, "default" )
1313 }
14+ fn exec2 ( env : & Env ) {
15+ String :: from_str ( env, "default" )
16+ }
1417}
1518pub trait Trait {
1619 type Impl : Trait ;
1720 fn exec ( env : & Env ) -> String {
1821 Self :: Impl :: exec ( env)
1922 }
23+ fn exec2 ( ) ;
2024}
2125pub struct Contract ;
2226///ContractArgs is a type for building arg lists for functions defined in "Contract".
@@ -151,8 +155,8 @@ impl soroban_sdk::testutils::ContractFunctionSet for Contract {
151155}
152156impl Trait for Contract {
153157 type Impl = DefaultImpl ;
154- fn exec ( env : & Env ) -> String {
155- Self :: Impl :: exec ( env)
158+ fn exec2 ( env : & Env ) -> String {
159+ String :: from_str ( env, "impl" )
156160 }
157161}
158162#[ doc( hidden) ]
@@ -169,6 +173,20 @@ impl Contract {
169173 * b"\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \x04 exec\0 \0 \0 \0 \0 \0 \0 \x01 \0 \0 \0 \x10 "
170174 }
171175}
176+ #[ doc( hidden) ]
177+ #[ allow( non_snake_case) ]
178+ pub mod __Contract__exec2__spec {
179+ #[ doc( hidden) ]
180+ #[ allow( non_snake_case) ]
181+ #[ allow( non_upper_case_globals) ]
182+ pub static __SPEC_XDR_FN_EXEC2: [ u8 ; 32usize ] = super :: Contract :: spec_xdr_exec2 ( ) ;
183+ }
184+ impl Contract {
185+ #[ allow( non_snake_case) ]
186+ pub const fn spec_xdr_exec2 ( ) -> [ u8 ; 32usize ] {
187+ * b"\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \x05 exec2\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \x01 \0 \0 \0 \x10 "
188+ }
189+ }
172190impl < ' a > ContractClient < ' a > {
173191 pub fn exec ( & self ) -> String {
174192 use core:: ops:: Not ;
@@ -248,13 +266,96 @@ impl<'a> ContractClient<'a> {
248266 }
249267 res
250268 }
269+ pub fn exec2 ( & self ) -> String {
270+ use core:: ops:: Not ;
271+ let old_auth_manager = self
272+ . env
273+ . in_contract ( )
274+ . not ( )
275+ . then ( || self . env . host ( ) . snapshot_auth_manager ( ) . unwrap ( ) ) ;
276+ {
277+ if let Some ( set_auths) = self . set_auths {
278+ self . env . set_auths ( set_auths) ;
279+ }
280+ if let Some ( mock_auths) = self . mock_auths {
281+ self . env . mock_auths ( mock_auths) ;
282+ }
283+ if self . mock_all_auths {
284+ if self . allow_non_root_auth {
285+ self . env . mock_all_auths_allowing_non_root_auth ( ) ;
286+ } else {
287+ self . env . mock_all_auths ( ) ;
288+ }
289+ }
290+ }
291+ use soroban_sdk:: { FromVal , IntoVal } ;
292+ let res = self . env . invoke_contract (
293+ & self . address ,
294+ & {
295+ #[ allow( deprecated) ]
296+ const SYMBOL : soroban_sdk:: Symbol = soroban_sdk:: Symbol :: short ( "exec2" ) ;
297+ SYMBOL
298+ } ,
299+ :: soroban_sdk:: Vec :: new ( & self . env ) ,
300+ ) ;
301+ if let Some ( old_auth_manager) = old_auth_manager {
302+ self . env . host ( ) . set_auth_manager ( old_auth_manager) . unwrap ( ) ;
303+ }
304+ res
305+ }
306+ pub fn try_exec2 (
307+ & self ,
308+ ) -> Result <
309+ Result <
310+ String ,
311+ <String as soroban_sdk:: TryFromVal < soroban_sdk:: Env , soroban_sdk:: Val > >:: Error ,
312+ > ,
313+ Result < soroban_sdk:: Error , soroban_sdk:: InvokeError > ,
314+ > {
315+ use core:: ops:: Not ;
316+ let old_auth_manager = self
317+ . env
318+ . in_contract ( )
319+ . not ( )
320+ . then ( || self . env . host ( ) . snapshot_auth_manager ( ) . unwrap ( ) ) ;
321+ {
322+ if let Some ( set_auths) = self . set_auths {
323+ self . env . set_auths ( set_auths) ;
324+ }
325+ if let Some ( mock_auths) = self . mock_auths {
326+ self . env . mock_auths ( mock_auths) ;
327+ }
328+ if self . mock_all_auths {
329+ self . env . mock_all_auths ( ) ;
330+ }
331+ }
332+ use soroban_sdk:: { FromVal , IntoVal } ;
333+ let res = self . env . try_invoke_contract (
334+ & self . address ,
335+ & {
336+ #[ allow( deprecated) ]
337+ const SYMBOL : soroban_sdk:: Symbol = soroban_sdk:: Symbol :: short ( "exec2" ) ;
338+ SYMBOL
339+ } ,
340+ :: soroban_sdk:: Vec :: new ( & self . env ) ,
341+ ) ;
342+ if let Some ( old_auth_manager) = old_auth_manager {
343+ self . env . host ( ) . set_auth_manager ( old_auth_manager) . unwrap ( ) ;
344+ }
345+ res
346+ }
251347}
252348impl ContractArgs {
253349 #[ inline( always) ]
254350 #[ allow( clippy:: unused_unit) ]
255351 pub fn exec < ' i > ( ) -> ( ) {
256352 ( )
257353 }
354+ #[ inline( always) ]
355+ #[ allow( clippy:: unused_unit) ]
356+ pub fn exec2 < ' i > ( ) -> ( ) {
357+ ( )
358+ }
258359}
259360#[ doc( hidden) ]
260361#[ allow( non_snake_case) ]
@@ -292,8 +393,42 @@ pub mod __Contract__exec {
292393}
293394#[ doc( hidden) ]
294395#[ allow( non_snake_case) ]
396+ pub mod __Contract__exec2 {
397+ use super :: * ;
398+ #[ deprecated( note = "use `ContractClient::new(&env, &contract_id).exec2` instead" ) ]
399+ pub fn invoke_raw ( env : soroban_sdk:: Env ) -> soroban_sdk:: Val {
400+ use super :: Trait ;
401+ <_ as soroban_sdk:: IntoVal < soroban_sdk:: Env , soroban_sdk:: Val > >:: into_val (
402+ #[ allow( deprecated) ]
403+ & <super :: Contract >:: exec2 ( & env) ,
404+ & env,
405+ )
406+ }
407+ #[ deprecated( note = "use `ContractClient::new(&env, &contract_id).exec2` instead" ) ]
408+ pub fn invoke_raw_slice ( env : soroban_sdk:: Env , args : & [ soroban_sdk:: Val ] ) -> soroban_sdk:: Val {
409+ if args. len ( ) != 0usize {
410+ {
411+ :: core:: panicking:: panic_fmt ( format_args ! (
412+ "invalid number of input arguments: {0} expected, got {1}" ,
413+ 0usize ,
414+ args. len( ) ,
415+ ) ) ;
416+ } ;
417+ }
418+ #[ allow( deprecated) ]
419+ invoke_raw ( env)
420+ }
421+ #[ deprecated( note = "use `ContractClient::new(&env, &contract_id).exec2` instead" ) ]
422+ pub extern "C" fn invoke_raw_extern ( ) -> soroban_sdk:: Val {
423+ #[ allow( deprecated) ]
424+ invoke_raw ( soroban_sdk:: Env :: default ( ) )
425+ }
426+ use super :: * ;
427+ }
428+ #[ doc( hidden) ]
429+ #[ allow( non_snake_case) ]
295430#[ allow( unused) ]
296- fn __Contract_Trait_2706c619fe73f0cf112473c6ee02e66c04e1c01c110b0c37b88d8eb509630c9f_ctor ( ) {
431+ fn __Contract_Trait_63842da933ab3611b9860480a0bd8b7c0de39e8f6f301c9ed52dd54191e8c014_ctor ( ) {
297432 #[ allow( unsafe_code) ]
298433 {
299434 #[ link_section = ".init_array" ]
@@ -305,7 +440,7 @@ fn __Contract_Trait_2706c619fe73f0cf112473c6ee02e66c04e1c01c110b0c37b88d8eb50963
305440 #[ allow( non_snake_case) ]
306441 extern "C" fn f ( ) -> :: ctor:: __support:: CtorRetType {
307442 unsafe {
308- __Contract_Trait_2706c619fe73f0cf112473c6ee02e66c04e1c01c110b0c37b88d8eb509630c9f_ctor ( ) ;
443+ __Contract_Trait_63842da933ab3611b9860480a0bd8b7c0de39e8f6f301c9ed52dd54191e8c014_ctor ( ) ;
309444 } ;
310445 core:: default:: Default :: default ( )
311446 }
@@ -318,6 +453,11 @@ fn __Contract_Trait_2706c619fe73f0cf112473c6ee02e66c04e1c01c110b0c37b88d8eb50963
318453 #[ allow( deprecated) ]
319454 & __Contract__exec:: invoke_raw_slice,
320455 ) ;
456+ <Contract as soroban_sdk:: testutils:: ContractFunctionRegister >:: register (
457+ "exec2" ,
458+ #[ allow( deprecated) ]
459+ & __Contract__exec2:: invoke_raw_slice,
460+ ) ;
321461 }
322462}
323463mod test {
@@ -332,9 +472,9 @@ mod test {
332472 ignore : false ,
333473 ignore_message : :: core:: option:: Option :: None ,
334474 source_file : "tests/associated_type/src/lib.rs" ,
335- start_line : 42usize ,
475+ start_line : 51usize ,
336476 start_col : 8usize ,
337- end_line : 42usize ,
477+ end_line : 51usize ,
338478 end_col : 17usize ,
339479 compile_fail : false ,
340480 no_run : false ,
@@ -364,6 +504,20 @@ mod test {
364504 }
365505 }
366506 } ;
507+ let res = client. exec2 ( ) ;
508+ match ( & res, & String :: from_str ( & e, "impl" ) ) {
509+ ( left_val, right_val) => {
510+ if !( * left_val == * right_val) {
511+ let kind = :: core:: panicking:: AssertKind :: Eq ;
512+ :: core:: panicking:: assert_failed (
513+ kind,
514+ & * left_val,
515+ & * right_val,
516+ :: core:: option:: Option :: None ,
517+ ) ;
518+ }
519+ }
520+ } ;
367521 }
368522}
369523#[ rustc_main]
0 commit comments