@@ -62,7 +62,11 @@ pub fn run(
6262}
6363
6464/// Resolve the RPC URL: CLI flag > config override (exact chain_id) > config (namespace) > built-in default.
65- fn resolve_rpc_url ( chain_id : & str , chain_type : ChainType , flag : Option < & str > ) -> Result < String , CliError > {
65+ fn resolve_rpc_url (
66+ chain_id : & str ,
67+ chain_type : ChainType ,
68+ flag : Option < & str > ,
69+ ) -> Result < String , CliError > {
6670 if let Some ( url) = flag {
6771 return Ok ( url. to_string ( ) ) ;
6872 }
@@ -140,9 +144,12 @@ fn broadcast_bitcoin(rpc_url: &str, signed_bytes: &[u8]) -> Result<String, CliEr
140144 let output = Command :: new ( "curl" )
141145 . args ( [
142146 "-fsSL" ,
143- "-X" , "POST" ,
144- "-H" , "Content-Type: text/plain" ,
145- "-d" , & hex_tx,
147+ "-X" ,
148+ "POST" ,
149+ "-H" ,
150+ "Content-Type: text/plain" ,
151+ "-d" ,
152+ & hex_tx,
146153 & url,
147154 ] )
148155 . output ( )
@@ -155,18 +162,17 @@ fn broadcast_bitcoin(rpc_url: &str, signed_bytes: &[u8]) -> Result<String, CliEr
155162
156163 let tx_hash = String :: from_utf8_lossy ( & output. stdout ) . trim ( ) . to_string ( ) ;
157164 if tx_hash. is_empty ( ) {
158- return Err ( CliError :: InvalidArgs ( "empty response from broadcast" . into ( ) ) ) ;
165+ return Err ( CliError :: InvalidArgs (
166+ "empty response from broadcast" . into ( ) ,
167+ ) ) ;
159168 }
160169 Ok ( tx_hash)
161170}
162171
163172fn broadcast_cosmos ( rpc_url : & str , signed_bytes : & [ u8 ] ) -> Result < String , CliError > {
164173 use base64:: Engine ;
165174 let b64_tx = base64:: engine:: general_purpose:: STANDARD . encode ( signed_bytes) ;
166- let url = format ! (
167- "{}/cosmos/tx/v1beta1/txs" ,
168- rpc_url. trim_end_matches( '/' )
169- ) ;
175+ let url = format ! ( "{}/cosmos/tx/v1beta1/txs" , rpc_url. trim_end_matches( '/' ) ) ;
170176 let body = serde_json:: json!( {
171177 "tx_bytes" : b64_tx,
172178 "mode" : "BROADCAST_MODE_SYNC"
@@ -183,10 +189,7 @@ fn broadcast_cosmos(rpc_url: &str, signed_bytes: &[u8]) -> Result<String, CliErr
183189
184190fn broadcast_tron ( rpc_url : & str , signed_bytes : & [ u8 ] ) -> Result < String , CliError > {
185191 let hex_tx = hex:: encode ( signed_bytes) ;
186- let url = format ! (
187- "{}/wallet/broadcasthex" ,
188- rpc_url. trim_end_matches( '/' )
189- ) ;
192+ let url = format ! ( "{}/wallet/broadcasthex" , rpc_url. trim_end_matches( '/' ) ) ;
190193 let body = serde_json:: json!( { "transaction" : hex_tx } ) ;
191194 let resp = curl_post_json ( & url, & body. to_string ( ) ) ?;
192195 extract_json_field ( & resp, "txid" )
@@ -195,10 +198,7 @@ fn broadcast_tron(rpc_url: &str, signed_bytes: &[u8]) -> Result<String, CliError
195198fn broadcast_ton ( rpc_url : & str , signed_bytes : & [ u8 ] ) -> Result < String , CliError > {
196199 use base64:: Engine ;
197200 let b64_boc = base64:: engine:: general_purpose:: STANDARD . encode ( signed_bytes) ;
198- let url = format ! (
199- "{}/sendBoc" ,
200- rpc_url. trim_end_matches( '/' )
201- ) ;
201+ let url = format ! ( "{}/sendBoc" , rpc_url. trim_end_matches( '/' ) ) ;
202202 let body = serde_json:: json!( { "boc" : b64_boc } ) ;
203203 let resp = curl_post_json ( & url, & body. to_string ( ) ) ?;
204204 let parsed: serde_json:: Value = serde_json:: from_str ( & resp)
@@ -214,9 +214,12 @@ fn curl_post_json(url: &str, body: &str) -> Result<String, CliError> {
214214 let output = Command :: new ( "curl" )
215215 . args ( [
216216 "-fsSL" ,
217- "-X" , "POST" ,
218- "-H" , "Content-Type: application/json" ,
219- "-d" , body,
217+ "-X" ,
218+ "POST" ,
219+ "-H" ,
220+ "Content-Type: application/json" ,
221+ "-d" ,
222+ body,
220223 url,
221224 ] )
222225 . output ( )
@@ -241,7 +244,8 @@ fn extract_key_for_curve(
241244 lws_signer:: Curve :: Secp256k1 => "secp256k1" ,
242245 lws_signer:: Curve :: Ed25519 => "ed25519" ,
243246 } ;
244- let hex_key = obj[ field] . as_str ( )
247+ let hex_key = obj[ field]
248+ . as_str ( )
245249 . ok_or_else ( || CliError :: InvalidArgs ( format ! ( "missing {field} key in wallet" ) ) ) ?;
246250 let bytes = hex:: decode ( hex_key)
247251 . map_err ( |e| CliError :: InvalidArgs ( format ! ( "invalid {field} hex: {e}" ) ) ) ?;
0 commit comments