-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend cosmwasm-schema
to be able to annotate the resultant JsonSchema
s with Parameter
/ReturnType
/State
tags. (Or similar)
#1276
Comments
A few other things that can maybe be tied into this:
Example: Response::new()
.add_attribute("method", "instantiate")
.add_attribute("owner", info.sender)
.add_attribute("count", msg.count) would get translated into the valid version of {
"type": "object",
"properties": {
"method": "string",
"owner": "Address", // <--- maybe instead a json $ref to protocol://global-cosmwasm-typespace/Address
"count": "int32"
},
"required": [...],
...
} I guess according to this logic every type exposed to the user in cosmwasm needs a schema if it were to be |
In particular:
I think this can be done as a procedural macro. I.e. for a given cosmwasm contract method, say Again, motivation being: it seems like a lot of data that is integrations-relevant that is returned by a given contract are |
hey @rtviii by chance are you using https://github.com/pyramation/cosmwasm-typescript-gen — if so, I think what you may be looking for (as a temporary solution) is what we're doing here https://github.com/public-awesome/stargaze-contracts/blob/main/contracts/sg721/examples/schema.rs#L20-L39 |
@pyramation love your work with ast's & macros in that package and postgres(unrelated). been meaning to take a look at the |
I think so, although we're doing it quite differently from what OP suggested. From that wishlist, we don't (yet!) have a way of describing possible events a contract might emit, but it's going to happen. For reference:
I think we can close this and let @rtviii reopen if he doesn't feel we addressed his problem. |
Awesome work! |
amazing! 👏🏻👏🏻👏🏻 |
Hi, This both a proposal and a question.
The problem: i'm trying to generate typescript bindings for
cosmwasm
contracts to speed up the development with our js package. In the ideal world,query
andexecute
methods along with types would be transpiled directly from rust contract to typescript and that'd be the end of story.In the short term though it'd be really nice to have the clarity as to which generated
.json
type corresponds to a method's parameter and which -- to its return type.Currently
In terms of the
cw-template
and in the most basic case this would work as follows:yields the following schema
Desirable
With "param/return type method tags" or whatever this might instead look like the following:
yields the following schema
This is just one possible implementation, probably with lots of edge cases down the road -- i'd really love to hear what you guys think to this end. Perhaps this is better done as a custom
schemars
trait or a macro or aserde
injection...Implementation details aside, i think it'd be useful to have this additional reference/link between the schema files because the space of things that can be reconstructed (in typescript or other langs) from them right now is limited by its lack.
In general, i'd be very happy to contribute to any transpilation effort here.
Seeing as @webmaster128 wrote this bit -- would like to refer to your expertise on this. Please advise!
The text was updated successfully, but these errors were encountered: