desmos-labs / desmos

Improving the well-being of users on social networks through the blockchain technology.
https://desmos.network
Apache License 2.0
104 stars 46 forks source link

feat: build wasm interface registry with custom resolver #1193

Closed dadamu closed 1 year ago

dadamu commented 1 year ago

Description

After discussing with wasmd team, the best way to have custom wasm any for desmos-bindings is injecting a custom any resolver to the codec. https://github.com/CosmWasm/wasmd/issues/1454#issuecomment-1614355169

This PR creates a custom InterfaceRegistry with a custom any resolver function Resolve in order to have a custom any JSON encoding in base64 for our contract SDK. As a result, we can use wasmd directly without forking it.

In the other word, it moves the logic of this commit into Desmos.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.

I have...

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.

I have...

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 70.58% and project coverage change: -0.02 :warning:

Comparison is base (ae245f3) 80.92% compared to head (19ea490) 80.90%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1193 +/- ## ========================================== - Coverage 80.92% 80.90% -0.02% ========================================== Files 213 215 +2 Lines 17972 17988 +16 ========================================== + Hits 14543 14554 +11 - Misses 2821 2825 +4 - Partials 608 609 +1 ``` | [Impacted Files](https://app.codecov.io/gh/desmos-labs/desmos/pull/1193?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=desmos-labs) | Coverage Δ | | |---|---|---| | [app/wasm\_config.go](https://app.codecov.io/gh/desmos-labs/desmos/pull/1193?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=desmos-labs#diff-YXBwL3dhc21fY29uZmlnLmdv) | `97.91% <60.00%> (-2.09%)` | :arrow_down: | | [x/wasm/types/any.go](https://app.codecov.io/gh/desmos-labs/desmos/pull/1193?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=desmos-labs#diff-eC93YXNtL3R5cGVzL2FueS5nbw==) | `62.50% <62.50%> (ø)` | | | [x/wasm/types/interface\_registry.go](https://app.codecov.io/gh/desmos-labs/desmos/pull/1193?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=desmos-labs#diff-eC93YXNtL3R5cGVzL2ludGVyZmFjZV9yZWdpc3RyeS5nbw==) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

dadamu commented 1 year ago

@RiccardoM I tested it by the ci process inside desmos-bindings: https://github.com/desmos-labs/desmos-bindings/blob/main/.github/workflows/chain-interaction.yml

Do you think we should have a similar ci test inside Desmos as well?

RiccardoM commented 1 year ago

@dadamu Yes I think it would be better. Since it's something we are going to implement inside the Desmos Core, it would be better to have a test here. Can you add it to this PR please? It would just need to create a contract and perform some operations and queries to make sure the Any type is serialized as we expect

dadamu commented 1 year ago

@RiccardoM Added the test by referring the wasmd e2e tests leveraging the ibctesting.TestChain structure.