use std::sync::Arc;
use chrono::{DateTime, Utc};
use tlb::{ser::CellSerialize, Cell};
use tlb_ton::{action::SendMsgAction, state_init::StateInit};
use super::PUBLIC_KEY_LENGTH;
pub trait WalletVersion {
type Data: CellSerialize;
type SignBody: CellSerialize;
type ExternalMsgBody: CellSerialize;
fn code() -> Arc<Cell>;
fn init_data(wallet_id: u32, pubkey: [u8; PUBLIC_KEY_LENGTH]) -> Self::Data;
fn create_sign_body(
wallet_id: u32,
expire_at: DateTime<Utc>,
seqno: u32,
msgs: impl IntoIterator<Item = SendMsgAction>,
) -> Self::SignBody;
fn wrap_signed_external(body: Self::SignBody, signature: [u8; 64]) -> Self::ExternalMsgBody;
#[inline]
fn state_init(
wallet_id: u32,
pubkey: [u8; PUBLIC_KEY_LENGTH],
) -> StateInit<Arc<Cell>, Self::Data> {
StateInit {
code: Some(Self::code()),
data: Some(Self::init_data(wallet_id, pubkey)),
..Default::default()
}
}
}