darkfi_money_contract/
lib.rs1use darkfi_sdk::error::ContractError;
25
26#[repr(u8)]
28pub enum MoneyFunction {
30 FeeV1 = 0x00,
31 GenesisMintV1 = 0x01,
32 PoWRewardV1 = 0x02,
33 TransferV1 = 0x03,
34 OtcSwapV1 = 0x04,
35 AuthTokenMintV1 = 0x05,
36 AuthTokenFreezeV1 = 0x06,
37 TokenMintV1 = 0x07,
38}
39impl TryFrom<u8> for MoneyFunction {
42 type Error = ContractError;
43
44 fn try_from(b: u8) -> core::result::Result<Self, Self::Error> {
45 match b {
46 0x00 => Ok(Self::FeeV1),
47 0x01 => Ok(Self::GenesisMintV1),
48 0x02 => Ok(Self::PoWRewardV1),
49 0x03 => Ok(Self::TransferV1),
50 0x04 => Ok(Self::OtcSwapV1),
51 0x05 => Ok(Self::AuthTokenMintV1),
52 0x06 => Ok(Self::AuthTokenFreezeV1),
53 0x07 => Ok(Self::TokenMintV1),
54 _ => Err(ContractError::InvalidFunction),
55 }
56 }
57}
58
59pub mod error;
61
62pub mod model;
64
65#[cfg(not(feature = "no-entrypoint"))]
66pub mod entrypoint;
68
69#[cfg(feature = "client")]
70pub mod client;
72
73pub const MONEY_CONTRACT_INFO_TREE: &str = "info";
75pub const MONEY_CONTRACT_COINS_TREE: &str = "coins";
76pub const MONEY_CONTRACT_COIN_ROOTS_TREE: &str = "coin_roots";
77pub const MONEY_CONTRACT_NULLIFIERS_TREE: &str = "nullifiers";
78pub const MONEY_CONTRACT_NULLIFIER_ROOTS_TREE: &str = "nullifier_roots";
79pub const MONEY_CONTRACT_TOKEN_FREEZE_TREE: &str = "token_freezes";
80pub const MONEY_CONTRACT_FEES_TREE: &str = "fees";
81
82pub const MONEY_CONTRACT_DB_VERSION: &[u8] = b"db_version";
84pub const MONEY_CONTRACT_COIN_MERKLE_TREE: &[u8] = b"coins_tree";
85pub const MONEY_CONTRACT_LATEST_COIN_ROOT: &[u8] = b"last_coins_root";
86pub const MONEY_CONTRACT_LATEST_NULLIFIER_ROOT: &[u8] = b"last_nullifiers_root";
87
88pub const EMPTY_COINS_TREE_ROOT: [u8; 32] = [
91 0xb8, 0xc1, 0x07, 0x5a, 0x80, 0xa8, 0x09, 0x65, 0xc2, 0x39, 0x8f, 0x71, 0x1f, 0xe7, 0x3e, 0x05,
92 0xb4, 0xed, 0xae, 0xde, 0xf1, 0x62, 0xf2, 0x61, 0xd4, 0xee, 0xd7, 0xcd, 0x72, 0x74, 0x8d, 0x17,
93];
94
95pub const MONEY_CONTRACT_ZKAS_FEE_NS_V1: &str = "Fee_V1";
97pub const MONEY_CONTRACT_ZKAS_MINT_NS_V1: &str = "Mint_V1";
99pub const MONEY_CONTRACT_ZKAS_BURN_NS_V1: &str = "Burn_V1";
101pub const MONEY_CONTRACT_ZKAS_AUTH_TOKEN_MINT_NS_V1: &str = "AuthTokenMint_V1";
103pub const MONEY_CONTRACT_ZKAS_TOKEN_MINT_NS_V1: &str = "TokenMint_V1";