File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -53,15 +53,7 @@ pub async fn run(command: RunCommand) -> Result<(), CliError> {
53
53
_ => DEFAULT_NODE_URL ,
54
54
} ;
55
55
56
- let client = FuelClient :: new ( node_url) ?;
57
-
58
- match client. transact ( & tx) . await {
59
- Ok ( logs) => {
60
- println ! ( "{:?}" , logs) ;
61
- Ok ( ( ) )
62
- }
63
- Err ( e) => Err ( e. to_string ( ) . into ( ) ) ,
64
- }
56
+ send_tx ( node_url, & tx) . await
65
57
}
66
58
} else {
67
59
let parse_type = {
@@ -88,6 +80,22 @@ pub async fn run(command: RunCommand) -> Result<(), CliError> {
88
80
}
89
81
}
90
82
83
+ async fn send_tx ( node_url : & str , tx : & Transaction ) -> Result < ( ) , CliError > {
84
+ let client = FuelClient :: new ( node_url) ?;
85
+
86
+ if let Err ( _) = client. health ( ) . await {
87
+ return Err ( format ! ( "Node at given url `{}` is unreachable, please start the node by running `fuel-core` and try again" , node_url) . into ( ) ) ;
88
+ }
89
+
90
+ match client. transact ( & tx) . await {
91
+ Ok ( logs) => {
92
+ println ! ( "{:?}" , logs) ;
93
+ Ok ( ( ) )
94
+ }
95
+ Err ( e) => Err ( e. to_string ( ) . into ( ) ) ,
96
+ }
97
+ }
98
+
91
99
fn create_tx_with_script_and_data ( script : Vec < u8 > , script_data : Vec < u8 > ) -> Transaction {
92
100
let gas_price = 0 ;
93
101
let gas_limit = 10000000 ;
You can’t perform that action at this time.
0 commit comments