@@ -50,6 +50,7 @@ pub async fn call_function(
50
50
mut output,
51
51
external_contracts,
52
52
contract_abis,
53
+ variable_output,
53
54
..
54
55
} = cmd;
55
56
@@ -88,7 +89,9 @@ pub async fn call_function(
88
89
} ;
89
90
90
91
// Setup variable output policy and log decoder
91
- let variable_output_policy = VariableOutputPolicy :: Exactly ( call_parameters. amount as usize ) ;
92
+ let variable_output_policy = variable_output
93
+ . map ( VariableOutputPolicy :: Exactly )
94
+ . unwrap_or ( VariableOutputPolicy :: EstimateMinimum ) ;
92
95
let error_codes = abi
93
96
. unified
94
97
. error_codes
@@ -275,8 +278,6 @@ pub async fn call_function(
275
278
let fuel_tx:: Transaction :: Script ( script) = & tx else {
276
279
bail ! ( "Transaction is not a script" ) ;
277
280
} ;
278
- let script_json = serde_json:: to_value ( script)
279
- . map_err ( |e| anyhow ! ( "Failed to convert script to JSON: {e}" ) ) ?;
280
281
281
282
// Parse the result based on output format
282
283
let mut receipt_parser =
@@ -330,7 +331,7 @@ pub async fn call_function(
330
331
331
332
super :: display_detailed_call_info (
332
333
& tx_execution,
333
- & script_json ,
334
+ script ,
334
335
& abi_map,
335
336
cmd. verbosity ,
336
337
& mut output,
@@ -357,7 +358,7 @@ pub async fn call_function(
357
358
result : Some ( result) ,
358
359
total_gas : * tx_execution. result . total_gas ( ) ,
359
360
receipts : tx_execution. result . receipts ( ) . to_vec ( ) ,
360
- script_json : Some ( script_json ) ,
361
+ script : Some ( script . to_owned ( ) ) ,
361
362
trace_events,
362
363
} )
363
364
}
@@ -466,6 +467,7 @@ pub mod tests {
466
467
cmd,
467
468
op:: call:: { call, get_wallet, PrivateKeySigner } ,
468
469
} ;
470
+ use fuel_tx:: field:: Outputs ;
469
471
use fuels:: { crypto:: SecretKey , prelude:: * } ;
470
472
use std:: path:: PathBuf ;
471
473
@@ -493,6 +495,7 @@ pub mod tests {
493
495
label : None ,
494
496
output : cmd:: call:: OutputFormat :: Raw ,
495
497
list_functions : false ,
498
+ variable_output : None ,
496
499
verbosity : 0 ,
497
500
debug : false ,
498
501
}
@@ -948,15 +951,9 @@ pub mod tests {
948
951
gas_forwarded : None ,
949
952
} ;
950
953
// validate balance is unchanged (dry-run)
951
- assert_eq ! (
952
- call( operation. clone( ) , cmd. clone( ) )
953
- . await
954
- . unwrap( )
955
- . result
956
- . unwrap( ) ,
957
- "()"
958
- ) ;
959
- assert_eq ! ( get_contract_balance( id_2, provider. clone( ) ) . await , 0 ) ;
954
+ let call_response = call ( operation. clone ( ) , cmd. clone ( ) ) . await . unwrap ( ) ;
955
+ assert_eq ! ( call_response. result. unwrap( ) , "()" ) ;
956
+ assert_eq ! ( call_response. script. unwrap( ) . outputs( ) . len( ) , 2 ) ;
960
957
cmd. mode = cmd:: call:: ExecutionMode :: Live ;
961
958
assert_eq ! ( call( operation, cmd) . await . unwrap( ) . result. unwrap( ) , "()" ) ;
962
959
assert_eq ! ( get_contract_balance( id_2, provider. clone( ) ) . await , 1 ) ;
@@ -983,7 +980,9 @@ pub mod tests {
983
980
} ;
984
981
cmd. mode = cmd:: call:: ExecutionMode :: Live ;
985
982
let operation = cmd. validate_and_get_operation ( ) . unwrap ( ) ;
986
- assert_eq ! ( call( operation, cmd) . await . unwrap( ) . result. unwrap( ) , "()" ) ;
983
+ let call_response = call ( operation, cmd) . await . unwrap ( ) ;
984
+ assert_eq ! ( call_response. result. unwrap( ) , "()" ) ;
985
+ assert_eq ! ( call_response. script. unwrap( ) . outputs( ) . len( ) , 3 ) ;
987
986
assert_eq ! (
988
987
get_recipient_balance( random_wallet. address( ) , provider. clone( ) ) . await ,
989
988
2
@@ -1041,7 +1040,9 @@ pub mod tests {
1041
1040
} ;
1042
1041
cmd. mode = cmd:: call:: ExecutionMode :: Live ;
1043
1042
let operation = cmd. validate_and_get_operation ( ) . unwrap ( ) ;
1044
- assert_eq ! ( call( operation, cmd) . await . unwrap( ) . result. unwrap( ) , "()" ) ;
1043
+ let call_response = call ( operation, cmd) . await . unwrap ( ) ;
1044
+ assert_eq ! ( call_response. result. unwrap( ) , "()" ) ;
1045
+ assert_eq ! ( call_response. script. unwrap( ) . outputs( ) . len( ) , 3 ) ;
1045
1046
assert_eq ! (
1046
1047
get_recipient_balance( random_wallet. address( ) , provider. clone( ) ) . await ,
1047
1048
3
0 commit comments