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

[CNft] CNft Collection Offer #107

Merged
merged 36 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6da4bae
set up test skeleton
JeremyLi28 Oct 23, 2024
0990f00
import mpl bubblegum
JeremyLi28 Oct 23, 2024
79df2f4
basic cnft test set up
JeremyLi28 Oct 23, 2024
0dff0f1
imported bubblegum crate
JeremyLi28 Oct 23, 2024
d1c1f96
fulfill buy contract skeleton
JeremyLi28 Oct 23, 2024
d3623c0
add cnft transfer to fulfill buy
JeremyLi28 Oct 24, 2024
4aad3a2
add collection offer creation in test
JeremyLi28 Oct 24, 2024
d69ce2d
Add basic fulfill buy operation
JeremyLi28 Oct 26, 2024
06d7ec9
successful cnft transfer
JeremyLi28 Oct 28, 2024
c18508a
remove metadata rehash
JeremyLi28 Nov 1, 2024
dfb8b28
fix CreatorRoyaltyConfig
JeremyLi28 Nov 1, 2024
0108385
add using canopyDepth and handling truncated proofs. test passes
swimricky Nov 1, 2024
d436b60
Merge pull request #1 from JeremyLi28/ricky/fulfill-cnft-buy-fix-test
JeremyLi28 Nov 5, 2024
ad2f360
pass metadata args in
JeremyLi28 Nov 7, 2024
6e06918
fix passing metadata args
JeremyLi28 Nov 7, 2024
c58fdc8
add collection metadata verification
JeremyLi28 Nov 7, 2024
c9dc16c
add fee cacluation, shared escrow support, reinvest buy support
JeremyLi28 Nov 7, 2024
558bb62
add creator verification and pay
JeremyLi28 Nov 8, 2024
da09c32
fix full logic
JeremyLi28 Nov 8, 2024
a31d1be
pass basic test
JeremyLi28 Nov 9, 2024
f4b528c
clean up redudent args and log
JeremyLi28 Nov 9, 2024
d176b46
use pub! macro
JeremyLi28 Nov 12, 2024
4afc5ef
remove test skips
JeremyLi28 Nov 12, 2024
dfeb37b
add allowlist verification
JeremyLi28 Nov 12, 2024
460929e
propgate error
JeremyLi28 Nov 12, 2024
bfca62f
fix collection verification for mcc
JeremyLi28 Nov 13, 2024
affe611
fix allowlist check test
JeremyLi28 Nov 13, 2024
d7955f1
add incorrect royalty test
JeremyLi28 Nov 13, 2024
b08a8f1
clean up tests log
JeremyLi28 Nov 13, 2024
1f7ca41
add comment
JeremyLi28 Nov 13, 2024
42864c2
clean up unused parameters
JeremyLi28 Nov 20, 2024
573d61b
use asset id as seed of sell state
JeremyLi28 Nov 20, 2024
609e72e
compute creator hash using metadata args
JeremyLi28 Nov 20, 2024
7112056
address comments
JeremyLi28 Nov 21, 2024
a1ede67
skip ocp test
JeremyLi28 Nov 22, 2024
6cbe701
fix format
JeremyLi28 Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ address = "CZ1rQoAHSqWBoAEfqGsiLhgbM59dDrCWk3rnG5FXaoRV" # libreplex royalty enf
[[test.validator.clone]]
address = "CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d" # metaplex core program

[[test.validator.clone]]
address = "BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY" # bubblegum

[[test.validator.clone]]
address = "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV" # Noop logger for bubblegum

[[test.validator.clone]]
address = "cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK" # compression program

[[test.validator.account]]
address = "9V5HWD1ap6mCDMhBoXU5SVcZZn9ihqJtoMQZsw5MTnoD" # example payment proxy
filename = './tests/deps/proxy.json'
Expand Down
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"dependencies": {
"@magiceden-oss/open_creator_protocol": "^0.3.2",
"@metaplex-foundation/js": "^0.19.4",
"@metaplex-foundation/mpl-bubblegum": "^4.2.1",
"@metaplex-foundation/mpl-core": "^0.4.7",
"@metaplex-foundation/mpl-token-auth-rules": "^2.0.0",
"@metaplex-foundation/mpl-token-metadata": "^3.1.2",
"@metaplex-foundation/umi": "^0.8.10",
"@metaplex-foundation/umi-bundle-tests": "^0.8.2",
"@metaplex-foundation/umi-web3js-adapters": "^0.8.2",
"@project-serum/anchor": "^0.26.0",
"@solana/spl-account-compression": "0.1.8",
"@solana/spl-token": "^0.4.1",
"@solana/spl-token-group": "^0.0.1",
"@solana/web3.js": "^1.65.0",
Expand All @@ -22,15 +24,16 @@
},
"devDependencies": {
"@magiceden-oss/mmm": "file:sdk",
"@metaplex-foundation/digital-asset-standard-api": "^1.0.4",
"@metaplex-foundation/mpl-migration-validator": "^0.4.1",
"@msgpack/msgpack": "^2.8.0",
"@types/jest": "29.0.0",
"chai": "^4.3.4",
"eslint-config-standard-with-typescript": "^21.0.1",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.3.2",
"typescript": "^4.4.2",
"jest": "29.0.0",
"ts-jest": "^29.0.0"
"prettier": "^2.3.2",
"ts-jest": "^29.0.0",
"typescript": "^4.4.2"
}
}
1 change: 1 addition & 0 deletions programs/mmm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ spl-associated-token-account = { version = "2.2.0", features = [
spl-token-2022 = {version = "1.0.0", features = ["no-entrypoint"] }
m2_interface = { path = "../m2_interface" }
mpl-core = "0.7.0"
mpl-bubblegum = "1.4.0"
4 changes: 4 additions & 0 deletions programs/mmm/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ pub enum MMMErrorCode {
InvalidTokenExtension, // 0x1791
#[msg("Unsupported asset plugin")]
UnsupportedAssetPlugin, // 0x1792
#[msg("Mismatched ceator data lengths")]
MismatchedCreatorDataLengths, // 0x1793
#[msg("Invalid creators")]
InvalidCreators, // 0x1794
}
63 changes: 63 additions & 0 deletions programs/mmm/src/instructions/cnft/metadata_args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use anchor_lang::{prelude::*, AnchorDeserialize, AnchorSerialize};

// Define the TokenStandard enum
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)]
pub enum TokenStandard {
NonFungible,
FungibleAsset,
Fungible,
NonFungibleEdition,
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Eq, PartialEq)]
pub struct Collection {
pub verified: bool,
pub key: Pubkey,
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)]
pub enum UseMethod {
Burn,
Multiple,
Single,
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Eq, PartialEq)]
pub struct Uses {
pub use_method: UseMethod,
pub remaining: u64,
pub total: u64,
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)]
pub enum TokenProgramVersion {
Original,
Token2022,
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Eq, PartialEq)]
pub struct Creator {
pub address: Pubkey,
pub verified: bool,
/// The percentage share.
///
/// The value is a percentage, not basis points.
pub share: u8,
}

// Define the MetadataArgs struct
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub struct MetadataArgs {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

look into if we can pass in serialized data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tried with serialize and deserialize, the deserilized data has some unknown issue that I couldn't figure out in short time (it fails allowlist check, means the deserialization had some issue). will keep the metadata args as it is for now to unblock this PR

pub name: String,
pub symbol: String, // Changed from Option<String> to String
pub uri: String,
pub seller_fee_basis_points: u16,
pub primary_sale_happened: bool, // Changed from Option<bool> to bool
pub is_mutable: bool, // Changed from Option<bool> to bool
pub edition_nonce: Option<u8>,
pub token_standard: Option<TokenStandard>, // Changed from Option<u8> to Option<TokenStandard>
pub collection: Option<Collection>,
pub uses: Option<Uses>,
pub token_program_version: TokenProgramVersion, // Assuming TokenProgramVersion is a simple u8
pub creators: Vec<Creator>,
}
5 changes: 5 additions & 0 deletions programs/mmm/src/instructions/cnft/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub mod sol_cnft_fulfill_buy;
pub mod metadata_args;

pub use sol_cnft_fulfill_buy::*;
pub use metadata_args::*;
Loading
Loading