darkfi_deployooor_contract/
lib.rs

1/* This file is part of DarkFi (https://dark.fi)
2 *
3 * Copyright (C) 2020-2026 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)]
25#[derive(Debug)]
26pub enum DeployFunction {
27    DeployV1 = 0x00,
28    LockV1 = 0x01,
29}
30
31impl TryFrom<u8> for DeployFunction {
32    type Error = ContractError;
33
34    fn try_from(b: u8) -> core::result::Result<Self, Self::Error> {
35        match b {
36            0x00 => Ok(Self::DeployV1),
37            0x01 => Ok(Self::LockV1),
38            _ => Err(ContractError::InvalidFunction),
39        }
40    }
41}
42
43#[cfg(not(feature = "no-entrypoint"))]
44/// WASM entrypoint functions
45pub mod entrypoint;
46
47/// Call parameters definitions
48pub mod model;
49
50/// Contract errors
51pub mod error;
52
53#[cfg(feature = "client")]
54/// Client API for interaction with this smart contract
55pub mod client;
56
57// These are the different sled trees that will be created
58pub const DEPLOY_CONTRACT_INFO_TREE: &str = "info";
59pub const DEPLOY_CONTRACT_LOCK_TREE: &str = "lock";
60
61// These are keys inside the info tree
62pub const DEPLOY_CONTRACT_DB_VERSION: &[u8] = b"db_version";