Skip to content

Commit c2abd2c

Browse files
authored
Refactor: use strip_0x in Cast::publish and drop unnecessary mut (#12376)
* Update lib.rs * Update lib.rs
1 parent 63794a4 commit c2abd2c

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

crates/cast/src/lib.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,8 @@ impl<P: Provider<AnyNetwork>> Cast<P> {
323323
/// # Ok(())
324324
/// # }
325325
/// ```
326-
pub async fn publish(
327-
&self,
328-
mut raw_tx: String,
329-
) -> Result<PendingTransactionBuilder<AnyNetwork>> {
330-
raw_tx = match raw_tx.strip_prefix("0x") {
331-
Some(s) => s.to_string(),
332-
None => raw_tx,
333-
};
334-
let tx = hex::decode(raw_tx)?;
326+
pub async fn publish(&self, raw_tx: String) -> Result<PendingTransactionBuilder<AnyNetwork>> {
327+
let tx = hex::decode(strip_0x(&raw_tx))?;
335328
let res = self.provider.send_raw_transaction(&tx).await?;
336329

337330
Ok(res)

0 commit comments

Comments
 (0)