Skip to content

Commit e93c1b1

Browse files
committed
chore(client): remove serde_json unwraps in favor of Error::SerdeJson
1 parent 3c9be91 commit e93c1b1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/async.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ impl<S: Sleeper> AsyncClient<S> {
394394
maxfeerate: Option<f64>,
395395
maxburnamount: Option<f64>,
396396
) -> Result<SubmitPackageResult, Error> {
397+
let serialized_txs = transactions
398+
.iter()
399+
.map(|tx| serialize_hex(&tx))
400+
.collect::<Vec<_>>();
401+
397402
let mut queryparams = HashSet::<(&str, String)>::new();
398403
if let Some(maxfeerate) = maxfeerate {
399404
queryparams.insert(("maxfeerate", maxfeerate.to_string()));
@@ -402,15 +407,10 @@ impl<S: Sleeper> AsyncClient<S> {
402407
queryparams.insert(("maxburnamount", maxburnamount.to_string()));
403408
}
404409

405-
let serialized_txs = transactions
406-
.iter()
407-
.map(|tx| serialize_hex(&tx))
408-
.collect::<Vec<_>>();
409-
410410
let response = self
411411
.post_request_bytes(
412412
"/txs/package",
413-
serde_json::to_string(&serialized_txs).unwrap_or_default(),
413+
serde_json::to_string(&serialized_txs).map_err(Error::SerdeJson)?,
414414
Some(queryparams),
415415
)
416416
.await?;

src/blocking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl BlockingClient {
332332
let mut request = self.post_request(
333333
"/txs/package",
334334
serde_json::to_string(&serialized_txs)
335-
.unwrap_or_default()
335+
.map_err(Error::SerdeJson)?
336336
.into_bytes(),
337337
)?;
338338

0 commit comments

Comments
 (0)