Skip to content

fix: nonfungible api mismatched balance type #526

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

Merged
merged 4 commits into from
Apr 28, 2025

Conversation

chungquantin
Copy link
Collaborator

There is an issue in the nonfungible API that when user calls api::nonfungibles::create, it throws Contract Decode Failed. Reason to that is the mismatched type in the price field of MintSettings in the runtime and in the API crate.

  • Remove the balance u32 type in the nonfungibles api crate. Use the primitives::Balance type instead.
  • Update all tests in the nonfungible integration tests to test with the min / max value of the data types instead of None.

@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.43%. Comparing base (27f09da) to head (f0884ff).

@@           Coverage Diff           @@
##             main     #526   +/-   ##
=======================================
  Coverage   64.43%   64.43%           
=======================================
  Files         124      124           
  Lines       23325    23325           
  Branches    23325    23325           
=======================================
  Hits        15029    15029           
  Misses       7637     7637           
  Partials      659      659           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chungquantin chungquantin requested a review from a team April 24, 2025 11:07
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

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

LGTM, lets get this on testnet next!

@chungquantin chungquantin requested review from evilrobot-01 and a team April 25, 2025 05:35
Copy link
Collaborator

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

LGTM. Made a few improvement suggestions.

Not approving yet as when I try to create a collection by deploying the non-fungibles integration tests contract to local devnet, and calling create, it errors with 'contract reverted'

@evilrobot-01
Copy link
Collaborator

The reason for the failure when testing manually was due to the contract not having sufficient balance for the collection deposit. Whilst the goal of these tests is ensuring the non-fungibles pallet works, they perhaps set a bad example, especially as there is no explicit non-fungibles example. I found https://github.com/r0gue-io/pop-api-examples so perhaps that could be migrated across and improved?

Ideally such functions should be payable and should consider a proper flow rather than

let addr = instantiate(CONTRACT, INIT_VALUE, vec![1]);
.

I'm not suggesting a change here now, just that some proper example is made available which uses a more realistic flow.

@evilrobot-01
Copy link
Collaborator

I see we have:

We really just need a simple starter example at https://github.com/r0gue-io/pop-node/tree/main/pop-api/examples.

@chungquantin chungquantin force-pushed the chungquantin/fix-nonfungible_balance_type branch from 7285348 to c835858 Compare April 28, 2025 06:21
@chungquantin chungquantin force-pushed the chungquantin/fix-nonfungible_balance_type branch from c835858 to 7d236b9 Compare April 28, 2025 07:27
@chungquantin
Copy link
Collaborator Author

I'll add the example contract for nonfungible in #386 after this PR. Would love to have this PR merged first to resolve the issue on testnet!

@evilrobot-01
Copy link
Collaborator

Would love to have this PR merged first to resolve the issue on testnet!

The problem isnt specific to testnet, its v0 of the pop-api crate which would affect any runtime.

Copy link
Collaborator

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for addressing the feedback so promptly.

Will merge once CI is green.

@evilrobot-01 evilrobot-01 merged commit 2739989 into main Apr 28, 2025
15 checks passed
@evilrobot-01 evilrobot-01 deleted the chungquantin/fix-nonfungible_balance_type branch April 28, 2025 09:59
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.

4 participants