1#![no_std]
2
3extern crate alloc;
4
5mod args;
6mod casper_address;
7mod ty;
8mod uints;
9use alloc::vec::Vec;
10pub use args::CallArgs;
11pub use casper_types;
12pub use casper_types::bytesrepr::Bytes;
13pub use ty::Typed;
14pub use uints::{U128, U256, U512};
15
16pub use casper_address::CasperAddress as Address;
17pub use casper_types::PublicKey;
18pub type Balance = U512;
20pub type BlockTime = u64;
22use casper_types::{
23 bytesrepr::{FromBytes, ToBytes},
24 CLTyped
25};
26
27pub trait OdraType: CLTyped + ToBytes + FromBytes {
29 fn serialize(&self) -> Option<Vec<u8>> {
30 self.to_bytes().ok()
31 }
32
33 fn deserialize(bytes: &[u8]) -> Option<Self> {
34 match Self::from_bytes(bytes) {
35 Ok((result, leftover)) => {
36 if leftover.is_empty() {
37 Some(result)
38 } else {
39 None
40 }
41 }
42 Err(_) => None
43 }
44 }
45}
46
47impl<T: CLTyped + ToBytes + FromBytes> OdraType for T {}