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

refactor: remove class&nft id validation #13836

Merged
merged 7 commits into from
Nov 15, 2022

Conversation

dreamer-zq
Copy link
Collaborator

@dreamer-zq dreamer-zq commented Nov 11, 2022

Description

Closes: #13819


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...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

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...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@dreamer-zq dreamer-zq requested a review from a team as a code owner November 11, 2022 06:35
@dreamer-zq dreamer-zq changed the title Remove class&nft id validation refactor: remove class&nft id validation Nov 11, 2022
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

makes sense to me, could we get a changelog entry and update to the spec with this change so applications know they must handle validation

@codecov
Copy link

codecov bot commented Nov 11, 2022

Codecov Report

Merging #13836 (7150dab) into main (ec27c53) will increase coverage by 0.22%.
The diff coverage is 33.33%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13836      +/-   ##
==========================================
+ Coverage   56.46%   56.68%   +0.22%     
==========================================
  Files         648      642       -6     
  Lines       56221    55136    -1085     
==========================================
- Hits        31747    31256     -491     
+ Misses      21909    21350     -559     
+ Partials     2565     2530      -35     
Impacted Files Coverage Δ
x/auth/tx/service.go 0.00% <0.00%> (ø)
x/nft/client/cli/query.go 62.43% <ø> (+0.71%) ⬆️
x/nft/keeper/grpc_query.go 70.83% <100.00%> (+1.44%) ⬆️
crypto/keys/internal/ecdsa/privkey.go 81.13% <0.00%> (-1.89%) ⬇️
x/group/keeper/keeper.go 56.25% <0.00%> (-0.40%) ⬇️
simapp/app.go
simapp/upgrades.go
simapp/state.go
simapp/simd/cmd/root.go
simapp/genesis.go
... and 10 more

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

Can we instead update the validation rule to only check if not empty?
This way this avoids duplicating the error messages, and we are sure we validate the same way everywhere.
+1 for the changelog too.

EDIT: Actually, we could as well just set these errors (errors.Wrap(ErrInvalidID, "empty class id") and errors.Wrap(ErrInvalidID, "empty nft id")) as variable somewhere and use them.

@julienrbrt julienrbrt added the backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release label Nov 11, 2022
@julienrbrt julienrbrt dismissed their stale review November 14, 2022 09:08

Feedback implemented.

x/nft/errors.go Outdated Show resolved Hide resolved
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm! Thank you!

Maybe in addition of the ADR changes, we could mention in the specs (https://github.com/cosmos/cosmos-sdk/blob/main/x/nft/README.md) that the app dev is supposed to handle the validation and in the UPGRADING.md.

I can do that in a follow-up too.

Comment on lines -352 to -363
{
name: "class id does not exist",
args: struct {
ClassID string
ID string
}{
ClassID: "class",
ID: ExpNFT.Id,
},
expectErr: true,
errorMsg: "not found nft",
},
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think this one can be put back

Copy link
Member

Choose a reason for hiding this comment

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

Just tested locally and it can be put back, but we can do a follow-up PR :)

Copy link
Member

Choose a reason for hiding this comment

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

Merging then, I'll update the docs in a quick follow-up and re-add this test.

Copy link
Member

@facundomedica facundomedica left a comment

Choose a reason for hiding this comment

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

Left a small nit, otherwise, LGTM 🚀

@julienrbrt julienrbrt merged commit 5f4350d into cosmos:main Nov 15, 2022
mergify bot pushed a commit that referenced this pull request Nov 15, 2022
tac0turtle pushed a commit that referenced this pull request Nov 15, 2022
(cherry picked from commit 5f4350d)

Co-authored-by: Dreamer <745124335@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release C:CLI C:x/nft Type: ADR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the relevant validation for classID and nftID from x/nft
4 participants