1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
use ic_cdk::export::candid::{CandidType, Deserialize, Principal}; use ic_cdk::{caller, print}; use ic_event_hub_macros::Event; use std::time::{SystemTime, UNIX_EPOCH}; #[derive(Event, CandidType, Deserialize)] pub struct VotingPowerUpdateEvent { #[topic] pub voter: Principal, pub new_voting_power: u64, } #[derive(Event, CandidType, Deserialize)] pub struct TotalVotingPowerUpdateEvent { pub new_total_voting_power: u64, } #[derive(Clone, PartialEq, Eq, Hash, CandidType, Deserialize)] pub struct RemoteCallEndpoint { pub canister_id: Principal, pub method_name: String, } #[derive(Clone, CandidType, Deserialize)] pub struct RemoteCallPayload { pub endpoint: RemoteCallEndpoint, pub args_raw: Vec<u8>, pub cycles: u64, } #[inline(always)] pub fn log(msg: &str) { print(format!("[caller: {}]: {}", caller(), msg)) } #[inline(always)] pub fn random_principal_test() -> Principal { Principal::from_slice( &SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_nanos() .to_be_bytes(), ) }