use address::Address;
use cid::Cid;
use clock::ChainEpoch;
use encoding::tuple::*;
use encoding::Cbor;
use num_bigint::{bigint_ser, BigInt};
use vm::TokenAmount;
#[derive(Debug, Serialize_tuple, Deserialize_tuple)]
pub struct State {
pub from: Address,
pub to: Address,
#[serde(with = "bigint_ser")]
pub to_send: TokenAmount,
pub settling_at: ChainEpoch,
pub min_settle_height: ChainEpoch,
pub lane_states: Cid, }
impl State {
pub fn new(from: Address, to: Address, empty_arr_cid: Cid) -> Self {
Self {
from,
to,
to_send: Default::default(),
settling_at: 0,
min_settle_height: 0,
lane_states: empty_arr_cid,
}
}
}
#[derive(Default, Clone, PartialEq, Debug, Serialize_tuple, Deserialize_tuple)]
pub struct LaneState {
#[serde(with = "bigint_ser")]
pub redeemed: BigInt,
pub nonce: u64,
}
#[derive(Default, Clone, Copy, Debug, PartialEq, Serialize_tuple, Deserialize_tuple)]
pub struct Merge {
pub lane: usize,
pub nonce: u64,
}
impl Cbor for State {}
impl Cbor for LaneState {}
impl Cbor for Merge {}