darkfi_deployooor_contract/
lib.rs

1/* This file is part of DarkFi (https://dark.fi)
2 *
3 * Copyright (C) 2020-2025 Dyne.org foundation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 */
18
19//! Smart contract implementing non-native smart contract deployment.
20
21use darkfi_sdk::error::ContractError;
22
23/// Functions available in the contract
24#[repr(u8)]
25pub enum DeployFunction {
26    DeployV1 = 0x00,
27    LockV1 = 0x01,
28}
29
30impl TryFrom<u8> for DeployFunction {
31    type Error = ContractError;
32
33    fn try_from(b: u8) -> core::result::Result<Self, Self::Error> {
34        match b {
35            0x00 => Ok(Self::DeployV1),
36            0x01 => Ok(Self::LockV1),
37            _ => Err(ContractError::InvalidFunction),
38        }
39    }
40}
41
42#[cfg(not(feature = "no-entrypoint"))]
43/// WASM entrypoint functions
44pub mod entrypoint;
45
46/// Call parameters definitions
47pub mod model;
48
49/// Contract errors
50pub mod error;
51
52#[cfg(feature = "client")]
53/// Client API for interaction with this smart contract
54pub mod client;
55
56// These are the different sled trees that will be created
57pub const DEPLOY_CONTRACT_INFO_TREE: &str = "info";
58pub const DEPLOY_CONTRACT_LOCK_TREE: &str = "lock";
59
60// These are keys inside the info tree
61pub const DEPLOY_CONTRACT_DB_VERSION: &[u8] = b"db_version";