Skip to content
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

Json schema for Coin and some parts of Transfer #772

Merged
merged 14 commits into from
Jul 31, 2023

Conversation

dzmitry-lahoda
Copy link
Contributor

@dzmitry-lahoda dzmitry-lahoda commented Jul 17, 2023

Closes: #772

Description

We do coin router kind of thing in CosmWasm. It needs some IBC things, and it requests JsonSchema on types.
So I did it.

Also, I made serde of Amount consistently decimal(decimal string). It was from str decimal, and in coin it was decimal, but on its own if was hex string. So made on its own also decimal. For some it can be breaking change. But other way schema (and CosmWasm messages) would be bad/inconsistent.


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests.
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR. may be i guess @Farhad-Shabani

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@dzmitry-lahoda dzmitry-lahoda marked this pull request as draft July 17, 2023 23:48
@codecov
Copy link

codecov bot commented Jul 17, 2023

Codecov Report

Patch coverage: 50.00% and no project coverage change.

Comparison is base (01e3ab8) 71.32% compared to head (02197f9) 71.33%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #772   +/-   ##
=======================================
  Coverage   71.32%   71.33%           
=======================================
  Files         124      124           
  Lines       14796    14828   +32     
=======================================
+ Hits        10553    10577   +24     
- Misses       4243     4251    +8     
Files Changed Coverage Δ
crates/ibc/src/applications/transfer/coin.rs 81.08% <0.00%> (-1.12%) ⬇️
crates/ibc/src/applications/transfer/denom.rs 75.48% <0.00%> (-1.81%) ⬇️
crates/ibc/src/applications/transfer/memo.rs 33.33% <0.00%> (-1.67%) ⬇️
crates/ibc/src/applications/transfer/packet.rs 96.42% <0.00%> (-1.76%) ⬇️
crates/ibc/src/core/ics02_client/height.rs 90.62% <0.00%> (-0.57%) ⬇️
crates/ibc/src/core/ics04_channel/timeout.rs 39.82% <0.00%> (-0.36%) ⬇️
crates/ibc/src/core/ics24_host/identifier.rs 66.52% <0.00%> (-0.87%) ⬇️
crates/ibc/src/signer.rs 26.66% <0.00%> (-1.91%) ⬇️
crates/ibc/src/applications/transfer/amount.rs 60.97% <94.11%> (+27.64%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dzmitry-lahoda dzmitry-lahoda changed the title #draft #wip support for optional json schema Support for optional json schema Jul 19, 2023
@dzmitry-lahoda dzmitry-lahoda changed the title Support for optional json schema Json schema for Coin and some parts of Transfer Jul 19, 2023
@dzmitry-lahoda dzmitry-lahoda marked this pull request as ready for review July 19, 2023 16:36
Copy link
Member

@Farhad-Shabani Farhad-Shabani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do coin router kind of thing in CosmWasm. It needs some IBC things, and it requests JsonSchema on types.

Great seeing you're using ibc-rs! Thanks for featuring this :)

Also, I made serde of Amount consistently decimal(decimal string). It was from str decimal, and in coin it was decimal, but on its own if was hex string. So made on its own also decimal. For some it can be breaking change. But other way schema (and CosmWasm messages) would be bad/inconsistent.

Just got a deserialization issue when tested locally. Otherwise, we are good.

  • Before, serialization roundtrip (ser > deser) on both Coin and Amount was ending up with a genuine value. Now, on deserialization, it fails. I think we should add a tailored deserialize for U256 instead of using this.
  • Also, It would be great if you include a test for it.

crates/ibc/src/signer.rs Outdated Show resolved Hide resolved
Copy link
Member

@Farhad-Shabani Farhad-Shabani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

A quick nit and then done!

crates/ibc/src/applications/transfer/amount.rs Outdated Show resolved Hide resolved
crates/ibc/src/applications/transfer/amount.rs Outdated Show resolved Hide resolved
Copy link
Member

@Farhad-Shabani Farhad-Shabani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

@Farhad-Shabani Farhad-Shabani merged commit 17c42c3 into informalsystems:main Jul 31, 2023
@Farhad-Shabani Farhad-Shabani added this to the v0.43.1 milestone Jul 31, 2023
dzmitry-lahoda added a commit to dzmitry-lahoda-forks/ibc-rs that referenced this pull request Aug 1, 2023
* support for optional json schema

* some comment about using json schema

* more schema

* prefixed denom schema and amount fixes

* final transfer things

* release note

* connection is needed too

* std is for schema

* fixed de of u256

* tests behind flag

* clean up
Farhad-Shabani pushed a commit that referenced this pull request Sep 9, 2024
* support for optional json schema

* some comment about using json schema

* more schema

* prefixed denom schema and amount fixes

* final transfer things

* release note

* connection is needed too

* std is for schema

* fixed de of u256

* tests behind flag

* clean up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants