Skip to main content

seedelf_core/
constants.rs

1use anyhow::{Result, bail};
2use hex_literal::hex;
3use serde::{Deserialize, Serialize};
4
5/// The current variant of Seedelf
6pub const VARIANT: u64 = 1;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct Contract {
10    pub wallet_contract_hash: [u8; 28],
11    pub seedelf_policy_id: String,
12    pub wallet_contract_size: u64,
13    pub seedelf_contract_size: u64,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct Reference {
18    pub wallet_reference_utxo: [u8; 32],
19    pub seedelf_reference_utxo: [u8; 32],
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct Config {
24    pub contract: Contract,
25    pub reference: Reference,
26}
27
28/// We can store all variants of the contracts inside this function then call it whenever we need it.
29///
30/// `preprod` is `true` for preprod and `false` for mainnet, as everywhere in
31/// the workspace. Variant 1 is the deployed contracts: its values are frozen,
32/// and a new build of the contracts is a new variant, never an edit to 1.
33pub fn get_config(variant: u64, preprod: bool) -> Result<Config> {
34    match variant {
35        1 => {
36            let reference: Reference = if preprod {
37                Reference {
38                    wallet_reference_utxo: hex!(
39                        "96fbddac63c55284fbbaa3c216ef1c0f460019e8643a889a189d5b5f7ddd71d6"
40                    ),
41                    seedelf_reference_utxo: hex!(
42                        "f620a4e949bfbefbf2892d39d0777439f3acfbf850eae9b007c6558ba8ef4db4"
43                    ),
44                }
45            } else {
46                Reference {
47                    wallet_reference_utxo: hex!(
48                        "51f12c1a5c2b0558a284628d81b06dee50b27693242fe35618c5f921730c0527"
49                    ),
50                    seedelf_reference_utxo: hex!(
51                        "f3955f42f660fae8b3e4dcf664011876cf769d87aa8450dc73171b4f6b5f520b"
52                    ),
53                }
54            };
55            let contract: Contract = Contract {
56                wallet_contract_hash: hex!(
57                    "94bca9c099e84ffd90d150316bb44c31a78702239076a0a80ea4a469"
58                ),
59                seedelf_policy_id: "84967d911e1a10d5b4a38441879f374a07f340945bcf9e7697485255"
60                    .to_string(),
61                wallet_contract_size: 629,
62                seedelf_contract_size: 519,
63            };
64            Ok(Config {
65                contract,
66                reference,
67            })
68        }
69        _ => bail!("unsupported contract variant {variant}; supported variants: 1"),
70    }
71}
72
73// support the [LOGIC] stakepool
74pub const PREPROD_STAKE_HASH: [u8; 28] =
75    hex!("86c769419aaa673c963da04e4b5bae448d490e2ceac902cb82e4da76");
76pub const MAINNET_STAKE_HASH: [u8; 28] =
77    hex!("fcfc7701b1df42061202efa9c96968a481bbd6a0676efb7afa87ebf1");
78
79// collateral info for giveme.my
80pub const COLLATERAL_HASH: [u8; 28] =
81    hex!("1108b97f2e199d58a0c0697d25412d0fb14d354dcd39654b9eb0dec8");
82pub const COLLATERAL_PUBLIC_KEY: [u8; 32] =
83    hex!("754c1db51aaee2e939b05b529ff5e210d8469afebcd2e487dae6f125fd500356");
84
85pub const PREPROD_COLLATERAL_UTXO: [u8; 32] =
86    hex!("ef18e00c412c06b74606c5e68901693c3974b2073dbec1dfd8b74f01af3102a1");
87pub const MAINNET_COLLATERAL_UTXO: [u8; 32] =
88    hex!("1c2fbce4e3974f721b27226645c7a35d648698c77f62bc337b40bc2cd294e9cd");
89
90// ADA Handle Policy Ids
91pub const ADA_HANDLE_POLICY_ID: &str = "f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a";
92
93// these maximums are estimated
94pub const MAXIMUM_WALLET_UTXOS: u64 = 20;
95pub const MAXIMUM_TOKENS_PER_UTXO: u64 = 20;
96
97// Spec-defined byte overhead used in the minUTxO formula. Network-independent.
98pub const OVERHEAD_COST: u64 = 160;