Skip to content

Commit

Permalink
try to serialize tx, avoid unwrapping (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman authored Nov 21, 2024
1 parent b29020a commit c2af75a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions shared/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ pub enum TransactionKind {
}

impl TransactionKind {
pub fn to_json(&self) -> String {
serde_json::to_string(&self).expect("Cannot serialize TransactionKind")
pub fn to_json(&self) -> Option<String> {
serde_json::to_string(&self).ok()
}

pub fn from(tx_kind_name: &str, data: &[u8]) -> Self {
Expand Down Expand Up @@ -340,7 +340,7 @@ impl Transaction {
};

let encoded_tx_data = if !tx_data.is_empty() {
Some(tx_kind.to_json())
tx_kind.to_json()
} else {
None
};
Expand Down

0 comments on commit c2af75a

Please sign in to comment.