|
| 1 | +use std::time::Duration; |
| 2 | + |
| 3 | +use candid::{CandidType, Nat, Principal}; |
| 4 | +use ic_log::LogSettings; |
| 5 | +use serde::Deserialize; |
| 6 | + |
| 7 | +use crate::{H160, U256}; |
| 8 | + |
| 9 | +pub type GenesisAccount = (H160, Option<U256>); |
| 10 | + |
| 11 | +/// These are the arguments which are taken by the evm canister init fn |
| 12 | +#[derive(Debug, Clone, CandidType, Deserialize)] |
| 13 | +pub struct EvmCanisterInitData { |
| 14 | + pub signature_verification_principal: Principal, |
| 15 | + pub min_gas_price: Nat, |
| 16 | + pub chain_id: u64, |
| 17 | + #[serde(default)] |
| 18 | + pub log_settings: Option<LogSettings>, |
| 19 | + #[serde(default)] |
| 20 | + pub permissions: Option<Vec<(Principal, Vec<Permission>)>>, |
| 21 | + #[serde(default)] |
| 22 | + pub transaction_processing_interval: Option<Duration>, |
| 23 | + /// Owner of the EVM Canister |
| 24 | + pub owner: Principal, |
| 25 | + /// Genesis accounts |
| 26 | + pub genesis_accounts: Vec<GenesisAccount>, |
| 27 | + /// Coinbase address |
| 28 | + pub coinbase: H160, |
| 29 | +} |
| 30 | + |
| 31 | +impl Default for EvmCanisterInitData { |
| 32 | + fn default() -> Self { |
| 33 | + Self { |
| 34 | + signature_verification_principal: Principal::anonymous(), |
| 35 | + min_gas_price: Default::default(), |
| 36 | + chain_id: Default::default(), |
| 37 | + log_settings: Default::default(), |
| 38 | + permissions: Default::default(), |
| 39 | + transaction_processing_interval: Default::default(), |
| 40 | + owner: Principal::management_canister(), |
| 41 | + genesis_accounts: vec![], |
| 42 | + coinbase: Default::default(), |
| 43 | + } |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +/// Principal specific permission |
| 48 | +#[derive( |
| 49 | + Debug, Clone, CandidType, Deserialize, Hash, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, |
| 50 | +)] |
| 51 | +pub enum Permission { |
| 52 | + /// Gives administrator permissions |
| 53 | + Admin, |
| 54 | + /// Allows calling the endpoints to read the logs and get runtime statistics |
| 55 | + ReadLogs, |
| 56 | + /// Allows calling the endpoints to set the logs configuration |
| 57 | + UpdateLogsConfiguration, |
| 58 | + /// Allows caller to update blockchain history |
| 59 | + UpdateBlockchain, |
| 60 | +} |
0 commit comments