Skip to content

Commit

Permalink
Contract self calls
Browse files Browse the repository at this point in the history
  • Loading branch information
MissingNO57 committed Nov 18, 2024
1 parent 5b8fa45 commit af41c54
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/permissions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
mod private;
mod superadmin;

pub use crate::permissions::superadmin::{
ensure_super_admin, is_super_admin, not_super_admin_error,
};

pub use crate::permissions::private::{ensure_private, not_self_contract_error};
16 changes: 16 additions & 0 deletions src/permissions/private.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use cosmwasm_std::{Addr, Env};
use cosmwasm_std::{StdError, StdResult};

const ERR_NOT_SELF_CONTRACT: &str = "[FET_ERR_NOT_SELF] Sender is not a self contract.";

pub fn ensure_private(env: &Env, address: &Addr) -> StdResult<()> {
if env.contract.address != address {
return Err(not_self_contract_error());
}

Ok(())
}

pub fn not_self_contract_error() -> StdError {
StdError::generic_err(ERR_NOT_SELF_CONTRACT)
}
2 changes: 1 addition & 1 deletion src/permissions/superadmin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cosmwasm_std::{StdError, StdResult};

const ERR_NOT_SUPER_ADMIN: &str = "[FET_ERR_NOT_SUPER_ADMIN] Sender is not a super-admin.";

// Check if the address is admin of the contract, everyone cannot be admin of the contract
// Check if the address is admin of the contract
pub fn is_super_admin(deps: &Deps, env: &Env, address: &Addr) -> StdResult<bool> {
// Check if the address is specified (opposite of the Everyone case)
if let Some(admin_address) = deps
Expand Down

0 comments on commit af41c54

Please sign in to comment.