signer-daemon 0.2.5

Signer daemon package.
Documentation
use poem_openapi::Object;
use serde::{Deserialize, Serialize};
use signer_core::OApiSignerSigned;

use crate::{
  model::viewobject::{
    Envelope as CoreEnvelope, EnvelopeInner as CoreEnvelopeInner,
  },
  poem_openapi::model::viewobject::OApiMessageVO,
};

#[derive(Debug, Clone, Serialize, Deserialize, Object)]
pub struct OApiEnvelope {
  pub data: OApiSignerSigned<OApiEnvelopeInner>,
}

impl From<CoreEnvelope> for OApiEnvelope {
  fn from(value: CoreEnvelope) -> Self {
    Self {
      data: OApiSignerSigned {
        sig: value.data.sig,
        msg: value.data.msg,
        pubkey: value.data.pubkey,
        _marker: std::marker::PhantomData,
      },
    }
  }
}

impl Into<CoreEnvelope> for OApiEnvelope {
  fn into(self) -> CoreEnvelope {
    CoreEnvelope {
      data: signer_core::SignerSigned {
        sig: self.data.sig,
        msg: self.data.msg,
        pubkey: self.data.pubkey,
        _marker: std::marker::PhantomData,
      },
    }
  }
}

#[derive(Debug, Clone, Serialize, Deserialize, Object)]
pub struct OApiEnvelopeInner {
  pub destinations: Vec<String>,
  pub message: OApiMessageVO,
}

impl From<CoreEnvelopeInner> for OApiEnvelopeInner {
  fn from(value: CoreEnvelopeInner) -> Self {
    Self {
      destinations: value.destinations,
      message: value.message.into(),
    }
  }
}

impl Into<CoreEnvelopeInner> for OApiEnvelopeInner {
  fn into(self) -> CoreEnvelopeInner {
    CoreEnvelopeInner {
      destinations: self.destinations,
      message: self.message.into(),
    }
  }
}