Skip to content

Commit bb3ae7e

Browse files
authored
Merge pull request #84 from bitfinity-network/share_evm_types
[EPROD-624] Add EVM canister init data to did package
2 parents c423db3 + ba1eae9 commit bb3ae7e

3 files changed

Lines changed: 62 additions & 0 deletions

File tree

src/did/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ serde_json = { workspace = true }
3434
sha2 = { workspace = true }
3535
sha3 = { workspace = true }
3636
thiserror = { workspace = true }
37+
ic-log = { workspace = true }
3738

3839
[dev-dependencies]
3940
eth-signer = { path = "../eth-signer" }

src/did/src/init.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
}

src/did/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub mod error;
1111
pub mod gas;
1212
pub mod hash;
1313
pub mod ic;
14+
pub mod init;
1415
pub mod integer;
1516
pub mod keccak;
1617
pub mod mint_order_exemption;

0 commit comments

Comments
 (0)