odra_types/
lib.rs

1//! Blockchain-agnostic types used by Odra Framework.
2
3#![no_std]
4
5extern crate alloc;
6
7mod address;
8pub mod arithmetic;
9#[cfg(not(target_arch = "wasm32"))]
10pub mod contract_def;
11mod error;
12pub mod event;
13mod item;
14pub mod uints;
15
16use alloc::vec::Vec;
17use casper_types::{bytesrepr::FromBytes, CLValue, RuntimeArgs};
18
19pub type BlockTime = u64;
20pub type EventData = Vec<u8>;
21
22pub use address::{Address, OdraAddress};
23pub use casper_types;
24pub use casper_types::{CLType, CLTyped, PublicKey, U128, U256, U512};
25pub use error::{AddressError, CollectionError, ExecutionError, OdraError, VmError};
26pub use item::OdraItem;
27
28pub trait UncheckedGetter {
29    fn get<T: FromBytes + CLTyped>(&self, key: &str) -> T;
30}
31
32impl UncheckedGetter for RuntimeArgs {
33    fn get<T: FromBytes + CLTyped>(&self, key: &str) -> T {
34        self.get(key)
35            .map(Clone::clone)
36            .map(CLValue::into_t)
37            .unwrap()
38            .unwrap()
39    }
40}