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

MET-129: Restrict token standard on bubblegum #87

Merged
merged 4 commits into from
Feb 27, 2024

Conversation

kstepanovdev
Copy link
Contributor

No description provided.

@kstepanovdev kstepanovdev added the bug Something isn't working label Feb 14, 2024
@kstepanovdev kstepanovdev self-assigned this Feb 14, 2024
@blockiosaurus
Copy link
Contributor

You should be able to run cargo fmt in the programs/bubblegum and pnpm format:fix in clients/js to fix those failed checks.

@kstepanovdev kstepanovdev force-pushed the restrict-token-standard-on-bubblegum branch 3 times, most recently from dca5db8 to 613102a Compare February 15, 2024 17:31
use crate::{error::BubblegumError, state::metaplex_adapter::MetadataArgs, utils::cmp_pubkeys};
use crate::{
error::BubblegumError,
state::metaplex_adapter::{MetadataArgs, TokenStandard as MetadataTokenStandard},
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think its clearer to just call it TokenStandard since that is the type and that's how its been used here and in other places.

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 had to rename it because assert.rs already contains TokenStandard from mpl_token_metadata::types. These types are different.

@@ -84,6 +84,8 @@ pub enum BubblegumError {
PrimarySaleCanOnlyBeFlippedToTrue,
#[msg("Creator did not unverify the metadata")]
CreatorDidNotUnverify,
#[msg("Minting Bubblegum is allowed only for NonFungible Standard")]
Copy link
Contributor

Choose a reason for hiding this comment

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

wdyt about "Only NonFungible standard is supported" ?

@@ -117,4 +117,94 @@ mod mint {

tree_manager.assert_root(&mut context).await;
}

#[tokio::test]
async fn mint_empty_token_standard() {
Copy link
Contributor

Choose a reason for hiding this comment

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

wdyt about "cannot_mint_empty_token_standard"?

}

#[tokio::test]
async fn mint_wrong_token_standard() {
Copy link
Contributor

Choose a reason for hiding this comment

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

wdyt about "cannot_mint_wrong_token_standard"?

Comment on lines 162 to 163
// Minting must fail because the token standard hasn't been provided.
assert!(minting_result.is_err());
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also do assert_eq!(minting_result.unwrap_err(), BubblegumError::InvalidTokenStandard) to make sure it fails for the exact expected reason?

although you already covered this in the JS test so its ok without it, but might as well.

Copy link
Contributor Author

@kstepanovdev kstepanovdev Feb 16, 2024

Choose a reason for hiding this comment

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

Yeah, I agree.
However, TreeManager is a wrapper and has Result<_, BanksClientError> signature. I suppose it's better to remove these tests then.

Comment on lines 207 to 208
// Minting must fail because the provided token standard is Fungible.
assert!(minting_result.is_err());
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also do assert_eq!(minting_result.unwrap_err(), BubblegumError::InvalidTokenStandard) to make sure it fails for the exact expected reason?

although you already covered this in the JS test so its ok without it, but might as well.

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 doubt they could've been compared in a such way because they're not implementing PartialEq, could have they? asset_matches should've been used instead.

@kstepanovdev kstepanovdev force-pushed the restrict-token-standard-on-bubblegum branch from bb61573 to 45b426d Compare February 16, 2024 10:40
@kstepanovdev kstepanovdev force-pushed the restrict-token-standard-on-bubblegum branch from 45b426d to eba7643 Compare February 16, 2024 10:53
@kstepanovdev kstepanovdev requested a review from danenbm February 16, 2024 11:01
@kstepanovdev kstepanovdev merged commit 5b3cdfc into main Feb 27, 2024
9 checks passed
@danenbm danenbm deleted the restrict-token-standard-on-bubblegum branch March 19, 2024 15:45
nicholasoxford pushed a commit to Primitives-xyz/primitives-protocol that referenced this pull request Jan 16, 2025
* Prevent non NonFungible from minting

* update clients

* updated tests

* update program's test accordingly to the latest changes regarding TokenStandard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants