diff --git a/contracts/ics721-base-tester/src/contract.rs b/contracts/ics721-base-tester/src/contract.rs index 8c9fecee..3fbc53a2 100644 --- a/contracts/ics721-base-tester/src/contract.rs +++ b/contracts/ics721-base-tester/src/contract.rs @@ -65,7 +65,8 @@ pub fn execute( mod receive_callbacks { use cosmwasm_std::{ensure_eq, from_json, DepsMut, Empty, MessageInfo, Response}; - use cw721::{DefaultOptionalCollectionExtension, DefaultOptionalNftExtension}; + use cw721::DefaultOptionalCollectionExtension; + use ics721::state::UniversalDefaultOptionalNftExtension; use ics721_types::{ ibc_types::NonFungibleTokenPacketData, types::{Ics721AckCallbackMsg, Ics721ReceiveCallbackMsg, Ics721Status}, @@ -135,7 +136,7 @@ mod receive_callbacks { .query_wasm_smart::( nft_contract, &cw721::msg::Cw721QueryMsg::< - DefaultOptionalNftExtension, + UniversalDefaultOptionalNftExtension, DefaultOptionalCollectionExtension, Empty, >::OwnerOf { @@ -182,7 +183,7 @@ mod receive_callbacks { .query_wasm_smart::( nft_contract, &cw721::msg::Cw721QueryMsg::< - DefaultOptionalNftExtension, + UniversalDefaultOptionalNftExtension, DefaultOptionalCollectionExtension, Empty, >::OwnerOf { diff --git a/packages/ics721/src/ibc_packet_receive.rs b/packages/ics721/src/ibc_packet_receive.rs index 7180dec6..77185c71 100644 --- a/packages/ics721/src/ibc_packet_receive.rs +++ b/packages/ics721/src/ibc_packet_receive.rs @@ -62,11 +62,8 @@ pub(crate) fn receive_ibc_packet( load_nft_contract_for_class_id(deps.storage, local_class_id.to_string()) .map_err(|_| ContractError::NoNftContractForClassId(local_class_id.to_string())) } else { - let nft_contract = - match query_nft_contract_for_class_id(deps.storage, local_class_id.clone()) { - Ok(nft_contract) => nft_contract, - Err(_) => None, // not found, occurs on initial transfer when we don't have the contract address - }; + let nft_contract = query_nft_contract_for_class_id(deps.storage, local_class_id.clone()) + .unwrap_or_default(); match nft_contract { Some(nft_contract) => Ok(nft_contract), None => { diff --git a/packages/ics721/src/state.rs b/packages/ics721/src/state.rs index 21cc0495..352c7dba 100644 --- a/packages/ics721/src/state.rs +++ b/packages/ics721/src/state.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::{cw_serde, schemars::JsonSchema}; use cosmwasm_std::{Addr, Binary, ContractInfoResponse, Empty, Timestamp}; -use cw721::{DefaultOptionalCollectionExtension, DefaultOptionalNftExtension}; +use cw721::{state::Trait, DefaultOptionalCollectionExtension}; use cw_pause_once::PauseOrchestrator; use cw_storage_plus::{Index, IndexList, IndexedMap, Item, Map, UniqueIndex}; use serde::{Deserialize, Serialize}; @@ -79,7 +79,22 @@ pub struct UniversalCollectionInfoResponse { pub struct UniversalNftInfoResponse { pub token_uri: Option, - pub extension: DefaultOptionalNftExtension, + pub extension: UniversalDefaultOptionalNftExtension, +} + +pub type UniversalDefaultOptionalNftExtension = Option; + +#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq)] +pub struct UniversalNftExtension { + pub image: Option, + pub image_data: Option, + pub external_url: Option, + pub description: Option, + pub name: Option, + pub attributes: Option>, + pub background_color: Option, + pub animation_url: Option, + pub youtube_url: Option, } /// Collection data send by ICS721 on source chain. It is an optional class data for interchain transfer to target chain. @@ -133,20 +148,21 @@ impl<'a> IndexList for ClassIdInfoIndexes<'a> { #[cfg(test)] mod tests { use cosmwasm_std::{from_json, to_json_binary}; - use cw721::{DefaultOptionalNftExtension, NftExtension}; + + use crate::state::{UniversalDefaultOptionalNftExtension, UniversalNftExtension}; use super::UniversalAllNftInfoResponse; #[test] fn test_universal_deserialize() { - let start = cw721::msg::AllNftInfoResponse:: { + let start = cw721::msg::AllNftInfoResponse:: { access: cw721::msg::OwnerOfResponse { owner: "foo".to_string(), approvals: vec![], }, info: cw721::msg::NftInfoResponse { token_uri: None, - extension: Some(NftExtension { + extension: Some(UniversalNftExtension { ..Default::default() }), }, @@ -158,7 +174,7 @@ mod tests { assert_eq!(end.info.token_uri, None); assert_eq!( end.info.extension, - Some(NftExtension { + Some(UniversalNftExtension { ..Default::default() }) )