Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
taitruong committed Aug 13, 2024
1 parent 3a6d97f commit cfe65dc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
14 changes: 6 additions & 8 deletions packages/ics721/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use crate::{
query_nft_contract_for_class_id, query_nft_contracts,
},
state::{
ClassIdInfo, CollectionData, UniversalAllNftInfoResponse, ADMIN_USED_FOR_CW721,
CLASS_ID_AND_NFT_CONTRACT_INFO, CLASS_ID_TO_CLASS, CONTRACT_ADDR_LENGTH, CW721_CODE_ID,
ClassIdInfo, CollectionData, UniversalAllNftInfoResponse, CLASS_ID_AND_NFT_CONTRACT_INFO,
CLASS_ID_TO_CLASS, CONTRACT_ADDR_LENGTH, CW721_ADMIN, CW721_CODE_ID,
INCOMING_CLASS_TOKEN_TO_CHANNEL, INCOMING_PROXY, OUTGOING_CLASS_TOKEN_TO_CHANNEL,
OUTGOING_PROXY, PO, TOKEN_METADATA,
},
Expand Down Expand Up @@ -69,7 +69,7 @@ where
));
}

ADMIN_USED_FOR_CW721.save(
CW721_ADMIN.save(
deps.storage,
&msg.cw721_admin
.as_ref()
Expand Down Expand Up @@ -580,9 +580,7 @@ where
};
CLASS_ID_AND_NFT_CONTRACT_INFO.save(deps.storage, &class.id, &class_id_info)?;

let cw721_admin = ADMIN_USED_FOR_CW721
.load(deps.storage)?
.map(|a| a.to_string());
let cw721_admin = CW721_ADMIN.load(deps.storage)?.map(|a| a.to_string());
let message = SubMsg::<T>::reply_on_success(
WasmMsg::Instantiate2 {
admin: cw721_admin.clone(),
Expand Down Expand Up @@ -795,9 +793,9 @@ where
}
if let Some(cw721_admin) = cw721_admin.clone() {
if cw721_admin.is_empty() {
ADMIN_USED_FOR_CW721.save(deps.storage, &None)?;
CW721_ADMIN.save(deps.storage, &None)?;
} else {
ADMIN_USED_FOR_CW721
CW721_ADMIN
.save(deps.storage, &Some(deps.api.addr_validate(&cw721_admin)?))?;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/ics721/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
helpers::get_instantiate2_address,
msg::QueryMsg,
state::{
UniversalAllNftInfoResponse, ADMIN_USED_FOR_CW721, CLASS_ID_AND_NFT_CONTRACT_INFO,
UniversalAllNftInfoResponse, CW721_ADMIN, CLASS_ID_AND_NFT_CONTRACT_INFO,
CLASS_ID_TO_CLASS, CONTRACT_ADDR_LENGTH, CW721_CODE_ID, INCOMING_CLASS_TOKEN_TO_CHANNEL,
INCOMING_PROXY, OUTGOING_CLASS_TOKEN_TO_CHANNEL, OUTGOING_PROXY, PO, TOKEN_METADATA,
},
Expand Down Expand Up @@ -47,7 +47,7 @@ pub trait Ics721Query {
QueryMsg::IncomingProxy {} => Ok(to_json_binary(&INCOMING_PROXY.load(deps.storage)?)?),
QueryMsg::Cw721CodeId {} => Ok(to_json_binary(&query_cw721_code_id(deps)?)?),
QueryMsg::Cw721Admin {} => {
Ok(to_json_binary(&ADMIN_USED_FOR_CW721.load(deps.storage)?)?)
Ok(to_json_binary(&CW721_ADMIN.load(deps.storage)?)?)
}
QueryMsg::ContractAddrLength {} => Ok(to_json_binary(
&CONTRACT_ADDR_LENGTH.may_load(deps.storage)?,
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 @@ -48,7 +48,7 @@ pub const INCOMING_CLASS_TOKEN_TO_CHANNEL: Map<(ClassId, TokenId), String> = 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 ADMIN_USED_FOR_CW721: Item<Option<Addr>> = Item::new("l");
pub const CW721_ADMIN: Item<Option<Addr>> = Item::new("l");

/// The optional contract address length being used for instantiate2. In case of None, default length is 32 (standard in cosmwasm).
/// So length must be shorter than 32. For example, Injective has 20 length address.
Expand Down
8 changes: 4 additions & 4 deletions packages/ics721/src/testing/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use crate::{
Ics721Query,
},
state::{
CollectionData, ADMIN_USED_FOR_CW721, CLASS_ID_TO_CLASS, CONTRACT_ADDR_LENGTH,
CW721_CODE_ID, INCOMING_PROXY, OUTGOING_CLASS_TOKEN_TO_CHANNEL, OUTGOING_PROXY, PO,
CollectionData, CLASS_ID_TO_CLASS, CONTRACT_ADDR_LENGTH, CW721_ADMIN, CW721_CODE_ID,
INCOMING_PROXY, OUTGOING_CLASS_TOKEN_TO_CHANNEL, OUTGOING_PROXY, PO,
},
utils::get_collection_data,
};
Expand Down Expand Up @@ -651,7 +651,7 @@ fn test_instantiate() {
);
assert!(!PO.paused.load(&deps.storage).unwrap());
assert_eq!(
ADMIN_USED_FOR_CW721.load(&deps.storage).unwrap(),
CW721_ADMIN.load(&deps.storage).unwrap(),
Some(Addr::unchecked(ADMIN_ADDR.to_string()))
);
assert_eq!(CONTRACT_ADDR_LENGTH.load(&deps.storage).unwrap(), 20);
Expand Down Expand Up @@ -726,7 +726,7 @@ fn test_migrate() {
);
assert_eq!(CW721_CODE_ID.load(&deps.storage).unwrap(), 1);
assert_eq!(
ADMIN_USED_FOR_CW721.load(&deps.storage).unwrap(),
CW721_ADMIN.load(&deps.storage).unwrap(),
Some(Addr::unchecked("some_other_admin"))
);
assert_eq!(CONTRACT_ADDR_LENGTH.load(&deps.storage).unwrap(), 20);
Expand Down

0 comments on commit cfe65dc

Please sign in to comment.