Skip to content

Conversation

ash-burnt
Copy link
Contributor

No description provided.

Comment on lines +89 to +123
pub fn is_admin(deps: Deps, address: Addr) -> ContractResult<()> {
let admin = ADMIN.load(deps.storage)?;
match admin {
None => Err(Unauthorized),
Some(a) => {
if a != address {
Err(Unauthorized)
} else {
Ok(())
}
}
}
}

pub fn update_admin(
deps: DepsMut,
info: MessageInfo,
new_admin: Option<Addr>,
) -> ContractResult<Response> {
is_admin(deps.as_ref(), info.sender.clone())?;

ADMIN.save(deps.storage, &new_admin)?;

let admin_str: String = match new_admin {
None => String::new(),
Some(a) => a.into_string(),
};

Ok(
Response::new().add_event(Event::new("updated_treasury_admin").add_attributes(vec![
("old admin", info.sender.into_string()),
("new admin", admin_str),
])),
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cw-ownable removes all this boilerplate: https://crates.io/crates/cw-ownable

use cw_storage_plus::{Item, Map};

pub const ADMIN: Item<Option<Addr>> = Item::new("admin");
pub const CODE_IDS: Map<u64, bool> = Map::new("code_ids");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,77 @@
use crate::msg::{get_inner, ExecuteMsg, InnerExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
Copy link
Contributor

@adairrr adairrr Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cw721-proxy acts as an cw721 adapter module within Abstract SDK: https://docs.abstract.money/3_framework/6_module_types.html#adapters

Happy to go over the different modules and how to build them, as it removes a ton of boilerplate, makes the contract more upgradeable, and the module code has already been audited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants