1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use candid::{Nat, Principal};
use num_bigint::BigUint;
use serde_bytes::ByteBuf;

pub use version::Version;

pub mod asset;
pub mod block;
pub mod package;
pub mod secret;
pub mod transaction;
pub mod vault;
mod version;

pub type PublicKey = ByteBuf;
pub type WalletRegisterId = BigUint;
pub type MarketId = BigUint;
pub type OrderId = BigUint;
pub type AssetId = BigUint;
pub type PackageId = BigUint;
pub type AssetAmount = BigUint;
pub type Nonce = BigUint;
pub type CanisterId = Principal;
pub type NodeProvider = Principal;
pub type BlockHeight = BigUint;
pub type MerkleRoot = [u8; 32];
pub type MerkleNode = [u8; 32];
pub type BlockHash = [u8; 32];
pub type TransactionHash = [u8; 32];
pub type VaultSeqId = u64;

pub type CandidWalletRegisterId = Nat;
pub type CandidMarketId = Nat;
pub type CandidOrderId = Nat;
pub type CandidPackageId = Nat;
pub type CandidAssetId = Nat;
pub type CandidAssetAmount = Nat;
pub type CandidNonce = Nat;
pub type CandidBlockHeight = Nat;

#[macro_export(local_inner_macros)]
macro_rules! impl_from_uint_for_enum {
    ($enum_type:ty, $($t:ty),*) => {
        $(
            impl From<$t> for $enum_type {
                fn from(value: $t) -> Self {
                    <$enum_type>::from(BigUint::from(value))
                }
            }
        )*
    };
}