Skip to content

Commit

Permalink
rename CW721_ADMIN > ADMIN_USED_FOR_CW721
Browse files Browse the repository at this point in the history
  • Loading branch information
taitruong committed Jan 22, 2024
1 parent 5016c3a commit b5c4acb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
14 changes: 8 additions & 6 deletions packages/ics721/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use crate::{
},
msg::{CallbackMsg, ExecuteMsg, InstantiateMsg, MigrateMsg},
state::{
CollectionData, UniversalAllNftInfoResponse, CLASS_ID_TO_CLASS, CLASS_ID_TO_NFT_CONTRACT,
CW721_ADMIN, CW721_CODE_ID, INCOMING_PROXY, NFT_CONTRACT_TO_CLASS_ID,
CollectionData, UniversalAllNftInfoResponse, ADMIN_USED_FOR_CW721, CLASS_ID_TO_CLASS,
CLASS_ID_TO_NFT_CONTRACT, CW721_CODE_ID, INCOMING_PROXY, NFT_CONTRACT_TO_CLASS_ID,
OUTGOING_CLASS_TOKEN_TO_CHANNEL, OUTGOING_PROXY, PO, TOKEN_METADATA,
},
token_types::{VoucherCreation, VoucherRedemption},
Expand Down Expand Up @@ -62,7 +62,7 @@ where
));
}

CW721_ADMIN.save(
ADMIN_USED_FOR_CW721.save(
deps.storage,
&msg.cw721_admin
.as_ref()
Expand Down Expand Up @@ -336,7 +336,9 @@ where
CLASS_ID_TO_NFT_CONTRACT.save(deps.storage, class_id.clone(), &cw721_addr)?;
NFT_CONTRACT_TO_CLASS_ID.save(deps.storage, cw721_addr, &class_id)?;

let admin = CW721_ADMIN.load(deps.storage)?.map(|a| a.to_string());
let admin = ADMIN_USED_FOR_CW721
.load(deps.storage)?
.map(|a| a.to_string());
let message = SubMsg::<T>::reply_on_success(
WasmMsg::Instantiate2 {
admin,
Expand Down Expand Up @@ -509,9 +511,9 @@ where
}
if let Some(cw721_admin) = cw721_admin.clone() {
if cw721_admin.is_empty() {
CW721_ADMIN.save(deps.storage, &None)?;
ADMIN_USED_FOR_CW721.save(deps.storage, &None)?;
} else {
CW721_ADMIN
ADMIN_USED_FOR_CW721
.save(deps.storage, &Some(deps.api.addr_validate(&cw721_admin)?))?;
}
}
Expand Down
9 changes: 5 additions & 4 deletions packages/ics721/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use cw_storage_plus::Map;
use crate::{
msg::QueryMsg,
state::{
UniversalAllNftInfoResponse, CLASS_ID_TO_CLASS, CLASS_ID_TO_NFT_CONTRACT, CW721_ADMIN,
CW721_CODE_ID, INCOMING_CLASS_TOKEN_TO_CHANNEL, INCOMING_PROXY, NFT_CONTRACT_TO_CLASS_ID,
OUTGOING_CLASS_TOKEN_TO_CHANNEL, OUTGOING_PROXY, PO, TOKEN_METADATA,
UniversalAllNftInfoResponse, ADMIN_USED_FOR_CW721, CLASS_ID_TO_CLASS,
CLASS_ID_TO_NFT_CONTRACT, CW721_CODE_ID, INCOMING_CLASS_TOKEN_TO_CHANNEL, INCOMING_PROXY,
NFT_CONTRACT_TO_CLASS_ID, OUTGOING_CLASS_TOKEN_TO_CHANNEL, OUTGOING_PROXY, PO,
TOKEN_METADATA,
},
};
use ics721_types::token_types::{Class, ClassId, ClassToken, Token, TokenId};
Expand Down Expand Up @@ -34,7 +35,7 @@ pub trait Ics721Query {
QueryMsg::OutgoingProxy {} => to_json_binary(&OUTGOING_PROXY.load(deps.storage)?),
QueryMsg::IncomingProxy {} => to_json_binary(&INCOMING_PROXY.load(deps.storage)?),
QueryMsg::Cw721CodeId {} => to_json_binary(&self.query_cw721_code_id(deps)?),
QueryMsg::Cw721Admin {} => to_json_binary(&CW721_ADMIN.load(deps.storage)?),
QueryMsg::Cw721Admin {} => to_json_binary(&ADMIN_USED_FOR_CW721.load(deps.storage)?),
QueryMsg::NftContracts { start_after, limit } => {
to_json_binary(&self.query_nft_contracts(deps, start_after, limit)?)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ics721/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub const INCOMING_CLASS_TOKEN_TO_CHANNEL: Map<(ClassId, TokenId), String> = Map
/// it's source chain, the metadata is removed from the map.
pub const TOKEN_METADATA: Map<(ClassId, TokenId), Option<Binary>> = Map::new("j");
/// The admin address for instantiating new cw721 contracts. In case of None, contract is immutable.
pub const CW721_ADMIN: Item<Option<Addr>> = Item::new("l");
pub const ADMIN_USED_FOR_CW721: Item<Option<Addr>> = Item::new("l");

#[derive(Deserialize)]
pub struct UniversalAllNftInfoResponse {
Expand Down
4 changes: 2 additions & 2 deletions packages/ics721/src/testing/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
msg::InstantiateMsg,
query::Ics721Query,
state::{
CollectionData, CLASS_ID_TO_CLASS, CW721_ADMIN, CW721_CODE_ID, INCOMING_PROXY,
CollectionData, ADMIN_USED_FOR_CW721, CLASS_ID_TO_CLASS, CW721_CODE_ID, INCOMING_PROXY,
OUTGOING_CLASS_TOKEN_TO_CHANNEL, OUTGOING_PROXY, PO,
},
utils::get_collection_data,
Expand Down Expand Up @@ -545,7 +545,7 @@ fn test_instantiate() {
);
assert!(!PO.paused.load(&deps.storage).unwrap());
assert_eq!(
CW721_ADMIN.load(&deps.storage).unwrap(),
ADMIN_USED_FOR_CW721.load(&deps.storage).unwrap(),
Some(Addr::unchecked(ADMIN_ADDR.to_string()))
);
}

0 comments on commit b5c4acb

Please sign in to comment.