Skip to content

Commit

Permalink
handle extra fields in collection info response
Browse files Browse the repository at this point in the history
  • Loading branch information
jhernandezb committed Apr 16, 2024
1 parent ad8f7b4 commit 24d6346
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/ics721/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, DepsMut, Empty, Env, StdResult};
use cw721::{ContractInfoResponse, NumTokensResponse};
use cw721::NumTokensResponse;
use cw_ownable::Ownership;

use crate::state::CollectionData;

#[cw_serde]
pub struct ContractInfoResponse {
pub name: String,
pub symbol: String,
pub minter: Option<String>,
pub royalty_bps: Option<Vec<u64>>,
pub royalty_addrs: Option<Vec<String>>,
}

pub fn get_collection_data(deps: &DepsMut, collection: &Addr) -> StdResult<CollectionData> {
// cw721 v0.17 and higher holds ownership in the contract
let ownership: StdResult<Ownership<Addr>> = deps
Expand All @@ -21,7 +31,13 @@ pub fn get_collection_data(deps: &DepsMut, collection: &Addr) -> StdResult<Colle
}
};
let contract_info = deps.querier.query_wasm_contract_info(collection)?;
let ContractInfoResponse { name, symbol } = deps.querier.query_wasm_smart(
let ContractInfoResponse {
name,
symbol,
minter: _,
royalty_bps: _,
royalty_addrs: _,
} = deps.querier.query_wasm_smart(
collection,
&cw721_base::msg::QueryMsg::<Empty>::ContractInfo {},
)?;
Expand Down

0 comments on commit 24d6346

Please sign in to comment.