-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authz Code ID Proxy Contract Example #35
base: main
Are you sure you want to change the base?
Conversation
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), | ||
])), | ||
) | ||
} |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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.
No description provided.