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

Generate JSON response sample #1971

Merged
merged 5 commits into from
May 16, 2022
Merged

Generate JSON response sample #1971

merged 5 commits into from
May 16, 2022

Conversation

patrickkuo
Copy link
Contributor

Generate JSON response sample when schema changes.

The sample files are located in sui/open_rpc/samples, they will be regenerated together with openrpc.json when we run cargo -q run --example generate-json-rpc-spec -- record, the files can be used for downstream testing.

Copy link
Contributor

@666lcz 666lcz left a comment

Choose a reason for hiding this comment

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

This is an amazing improvement on our regression detection! A great next step would be to add a mode for the sui/src/generate_json_rpc_spec.rs to act as a mock data server and then we can connect the Explorer with it.

@666lcz
Copy link
Contributor

666lcz commented May 16, 2022

Test Plan for TS-side changes

Manual Testing

I. Transactions

Landing
CleanShot 2022-05-16 at 02 12 31

MoveCall
CleanShot 2022-05-16 at 02 13 14

Publish
CleanShot 2022-05-16 at 02 13 04

TransferCoin
CleanShot 2022-05-16 at 02 12 49

II. AddressView

Aggregate Fungible Tokens section
CleanShot 2022-05-16 at 02 16 14

Expanded Fungible Tokens section
CleanShot 2022-05-16 at 02 16 24

III. Object View

Coin
CleanShot 2022-05-16 at 02 17 49

NFT with image
CleanShot 2022-05-16 at 02 22 06

NFT without image

CleanShot 2022-05-16 at 02 22 39

Package
CleanShot 2022-05-16 at 02 25 48

IV. Search

validate that searching for object id, transaction, address is working

Unit tests

Added TS tests to check the data schema against the mock data generated by sui/src/generate_json_rpc_spec.rs

@@ -33,23 +41,25 @@
"data": {
"dataType": "moveObject",
"type": "0x2::Coin::Coin<0x2::SUI::SUI>",
"fields": {
"coin": {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really not ideal as it is hard for clients to parse when some data has fields while others has coin and other names

"name": "Example NFT",
"url": "ipfs://bafkreibngqhl3gaa7daob4i2vccziay2jjlp435cf66vhono7nrvww53ty"
"url": {
"string": "ipfs://bafkreibngqhl3gaa7daob4i2vccziay2jjlp435cf66vhono7nrvww53ty"
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing I don't like about this is that sometimes the field name refers to a type (e.g., string) while in other places it's not (e.g., version).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed the tag in the parent branch, I have condensed the enum types instead of using tags to remove ambiguity.

@patrickkuo patrickkuo force-pushed the pat/generate_json_sample branch from 896e314 to 8158243 Compare May 16, 2022 20:51
@patrickkuo patrickkuo requested a review from 666lcz May 16, 2022 20:53
@patrickkuo patrickkuo force-pushed the pat/generate_json_sample branch from 8158243 to f7ef230 Compare May 16, 2022 21:12
@patrickkuo patrickkuo requested a review from Clay-Mysten as a May 16, 2022 21:12
@github-actions github-actions bot added the Type: Documentation Improvements or additions to documentation label May 16, 2022
@patrickkuo patrickkuo force-pushed the pat/move_object_parsing branch from 25119e2 to a639cdc Compare May 16, 2022 21:15
Base automatically changed from pat/move_object_parsing to main May 16, 2022 21:32
@patrickkuo patrickkuo force-pushed the pat/generate_json_sample branch from f7ef230 to f0317ff Compare May 16, 2022 21:38
@github-actions github-actions bot removed the Type: Documentation Improvements or additions to documentation label May 16, 2022
@patrickkuo patrickkuo merged commit 48f2840 into main May 16, 2022
@patrickkuo patrickkuo deleted the pat/generate_json_sample branch May 16, 2022 22:23
@Clay-Mysten
Copy link
Contributor

Hi team,

Thanks, Patrick! Great work, as always. Does this test plan represent a common workflow?

Let me know how we can make best use of this work. Should we link to the samples from our JSON RPC page? Perhaps reuse the screenshots for Sui Explorer docs? Would love to expand the flow presented here with details for each step.

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

Successfully merging this pull request may close these issues.

3 participants