Closed MbBrainz closed 2 months ago
Is this ticket meant to go to https://github.com/CosmWasm/cw-nfts where cw721 is maintained? I can transfer if you agree
@webmaster128 this ticket is about the malfunctioning of Cosmwasm_schema when it comes to extensions. These extensions are a present in the cw721 code, but are not unique to it.
Hi! I'm the creator of the relevant macros in cosmwasm-schema
.
What you're asking for, as I understand it, is possible in cosmwasm-schema
as long as you use the nested
syntax as found in the docs. To the best of my knowledge, this does work with generics too.
After a brief look at the codebase here, it looks like QueryMsg
follows a different pattern, and then handwaves schema generation. This should be fixable right here, in this repo.
BTW, the doc comments state the extension
query is a dummy. Is that meant to be queried? I don't understand this codebase.
After looking at this more, I don't think the snippets you provided are how "metadata extensions" are meant to be used. See here and here.
I suspect what you might want to do instead in your project to provide both Cw721 and custom queries is something like:
#[cw_serde]
#[derive(QueryResponses)]
#[serde(untagged)]
#[query_responses(nested)]
pub enum QueryMsg {
Cw721(cw721_base::QueryMsg<Something>),
MyOtherQueries(MagotchiQueryExtension),
}
#[cw_serde]
#[derive(QueryResponses, QueryFns)]
pub enum MagotchiQueryExtension {
/// Returns the health of the magotchi
#[returns(HealthResponse)]
Health { token_id: String },
// ...
}
I'm closing this, but if there's something I missed, feel free to reopen!
Both query and execute extensions on cw721 are not properly serialized. You can see what happens when you add the schema to this contract and to query the contract for the extension (try for
token-2
). The returned data is correct(as shown in the json output), but its not properly parsed using the schema and therefore it shows asNull
in theReturn Output -> Your Schema
tab. link to the contract on celat.oneFor the messages below i get the attached schema:
cw721-gotchi.json