verity_ic/remittance/external_router/
permissions.rs1use candid::Principal;
2use ic_cdk::caller;
3use std::{cell::RefCell, collections::HashMap};
4
5thread_local! {
6 pub static WHITELISTED_PUBLISHERS: RefCell<HashMap<Principal, bool>> = RefCell::default();
7}
8
9pub fn add_publisher(principal: Principal) {
10 WHITELISTED_PUBLISHERS.with(|rc| rc.borrow_mut().insert(principal, true));
11}
12
13pub fn remove_publisher(principal: Principal) {
14 WHITELISTED_PUBLISHERS.with(|rc| rc.borrow_mut().remove(&principal));
15}
16
17pub fn only_whitelisted_publishers() {
18 let caller_principal_id = caller();
19 let whitelisted = WHITELISTED_PUBLISHERS.with(|rc| rc.borrow().clone());
20
21 if !whitelisted.contains_key(&caller_principal_id) {
22 panic!("PRINCPAL NOT WHITELISTED")
23 }
24}