Skip to content

FR: Refactor CosmWasm messages to use distinct response types for each query #1277

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
srdtrk opened this issue Jul 15, 2024 · 3 comments · Fixed by #1281
Closed

FR: Refactor CosmWasm messages to use distinct response types for each query #1277

srdtrk opened this issue Jul 15, 2024 · 3 comments · Fixed by #1281
Labels
O: maintainability Objective: cause to ease modification, fault corrections and improve code understanding

Comments

@srdtrk
Copy link
Contributor

srdtrk commented Jul 15, 2024

Feature Summary

Currently, the contract API messages defined in the CosmWasm context return the same response type for each query type. This necessitates an aggregate struct with all fields optional. This approach is not ideal. Instead, the response types should be distinct and specific to each query type, similar to how they are defined in the 08-wasm module.

Proposal

I have created a wrapper contract around the ics07-tendermint context that implements this improved approach. Here are the types I used in that contract: response definitions and query definitions. Note that I am using this contract for other purposes (not in 08-wasm). (This repository successfully implements all of IBC-lite in CosmWasm, allowing for end-to-end packet passing with an ibc-go counterparty without any dependency on ibc-go.)

By adopting distinct response types for each query, we can enhance clarity, maintainability, and adherence to best practices in the contract API.

@github-project-automation github-project-automation bot moved this to 📥 To Do in ibc-rs Jul 15, 2024
@Farhad-Shabani Farhad-Shabani added the O: maintainability Objective: cause to ease modification, fault corrections and improve code understanding label Jul 15, 2024
@Farhad-Shabani
Copy link
Member

Much appreciate the details @srdtrk. Makes a lot of sense.

I have created a wrapper contract around the ics07-tendermint context that implements this improved approach. Here are the types I used in that contract

Do you feel up for opening a PR and upstream your changes to ibc-rs?

This repository successfully implements all of IBC-lite in CosmWasm, allowing for end-to-end packet passing with an ibc-go counterparty without any dependency on ibc-go.

Awesome news! It's great to hear that ibc-rs could assist with the ibc-lite PoC 🚀.

@srdtrk
Copy link
Contributor Author

srdtrk commented Jul 15, 2024

Ok, I'll open a PR

@srdtrk
Copy link
Contributor Author

srdtrk commented Jul 15, 2024

In this PR, I've also removed ExportGenesis. This is because it is no longer in the 08-wasm contract api. The reason for this is that in 02-client, the genesis metadata of all the light clients are exported anyway. Which always includes the light client's genesis metadata. And similarly, if this light client is used in cosmwasm directly, then x/wasm would export the metadata of all contracts.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
O: maintainability Objective: cause to ease modification, fault corrections and improve code understanding
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants