Skip to content

Commit

Permalink
Add conversion from soft confarmiton response to signed soft confirma…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
ercecan committed Dec 20, 2024
1 parent 74c765c commit 879a075
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};

use crate::da::SequencerCommitment;
use crate::soft_confirmation::SignedSoftConfirmation;
#[cfg(feature = "native")]
use crate::stf::EventKey;
use crate::zk::CumulativeStateDiff;
Expand Down Expand Up @@ -85,6 +86,31 @@ pub enum BatchIdentifier {
Number(u64),
}

impl TryFrom<SoftConfirmationResponse> for SignedSoftConfirmation {
type Error = borsh::io::Error;
fn try_from(val: SoftConfirmationResponse) -> Result<Self, Self::Error> {
let res = SignedSoftConfirmation::new(
val.l2_height,
val.hash,
val.prev_hash,
val.da_slot_height,
val.da_slot_hash,
val.da_slot_txs_commitment,
val.l1_fee_rate,
val.txs
.unwrap_or_default()
.into_iter()
.map(|tx| tx.tx)
.collect(),
val.deposit_data.into_iter().map(|tx| tx.tx).collect(),
val.soft_confirmation_signature,
val.pub_key,
val.timestamp,
);
Ok(res)
}
}

/// An identifier that specifies a single transaction.
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged, rename_all = "camelCase")]
Expand Down

0 comments on commit 879a075

Please sign in to comment.