use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct SuiSealRef {
pub object_id: [u8; 32],
pub version: u64,
pub nonce: u64,
}
impl SuiSealRef {
pub fn new(object_id: [u8; 32], version: u64, nonce: u64) -> Self {
Self {
object_id,
version,
nonce,
}
}
pub fn to_vec(&self) -> Vec<u8> {
let mut out = Vec::with_capacity(32 + 8 + 8);
out.extend_from_slice(&self.object_id);
out.extend_from_slice(&self.version.to_le_bytes());
out.extend_from_slice(&self.nonce.to_le_bytes());
out
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct SuiAnchorRef {
pub object_id: [u8; 32],
pub tx_digest: [u8; 32],
pub checkpoint: u64,
}
impl SuiAnchorRef {
pub fn new(object_id: [u8; 32], tx_digest: [u8; 32], checkpoint: u64) -> Self {
Self {
object_id,
tx_digest,
checkpoint,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct SuiInclusionProof {
pub object_proof: Vec<u8>,
pub checkpoint_hash: [u8; 32],
pub checkpoint_number: u64,
}
impl SuiInclusionProof {
pub fn new(object_proof: Vec<u8>, checkpoint_hash: [u8; 32], checkpoint_number: u64) -> Self {
Self {
object_proof,
checkpoint_hash,
checkpoint_number,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct SuiFinalityProof {
pub checkpoint: u64,
pub is_certified: bool,
}
impl SuiFinalityProof {
pub fn new(checkpoint: u64, is_certified: bool) -> Self {
Self {
checkpoint,
is_certified,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_seal_ref_creation() {
let seal = SuiSealRef::new([1u8; 32], 1, 42);
assert_eq!(seal.version, 1);
}
#[test]
fn test_anchor_ref_creation() {
let anchor = SuiAnchorRef::new([2u8; 32], [3u8; 32], 100);
assert_eq!(anchor.checkpoint, 100);
}
}