Skip to content

Commit

Permalink
MPL Core new plugins support (#196)
Browse files Browse the repository at this point in the history
* Update mpl-core version

* Add autograph tests

* Add verified creators tests
  • Loading branch information
danenbm committed Jun 14, 2024
1 parent e21e037 commit 22d9168
Show file tree
Hide file tree
Showing 11 changed files with 425 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ metrics = "0.20.1"
migration = {path = "migration"}
mime_guess = "2.0.4"
mpl-bubblegum = "1.2.0"
mpl-core = {version = "0.7.0", features = ["serde"]}
mpl-core = {version = "0.7.1", features = ["serde"]}
mpl-token-metadata = "4.1.1"
nft_ingester = {path = "nft_ingester"}
num-derive = "0.3.3"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
116 changes: 116 additions & 0 deletions integration_tests/tests/integration_tests/mpl_core_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,119 @@ async fn test_mpl_core_get_asset_with_multiple_internal_and_external_plugins() {
let response = setup.das_api.get_asset(request).await.unwrap();
insta::assert_json_snapshot!(name, response);
}

#[tokio::test]
#[serial]
#[named]
async fn test_mpl_core_autograph_plugin() {
let name = trim_test_name(function_name!());
let setup = TestSetup::new_with_options(
name.clone(),
TestSetupOptions {
network: Some(Network::Devnet),
},
)
.await;

let seeds: Vec<SeedEvent> = seed_accounts(["Hz4MSHgevYkpwF3cerDLuPJLQE3GZ5yDWu7vqmQGpRMU"]);

apply_migrations_and_delete_data(setup.db.clone()).await;
index_seed_events(&setup, seeds.iter().collect_vec()).await;

let request = r#"
{
"id": "Hz4MSHgevYkpwF3cerDLuPJLQE3GZ5yDWu7vqmQGpRMU"
}
"#;

let request: api::GetAsset = serde_json::from_str(request).unwrap();
let response = setup.das_api.get_asset(request).await.unwrap();
insta::assert_json_snapshot!(name, response);
}

#[tokio::test]
#[serial]
#[named]
async fn test_mpl_core_autograph_plugin_with_signature() {
let name = trim_test_name(function_name!());
let setup = TestSetup::new_with_options(
name.clone(),
TestSetupOptions {
network: Some(Network::Devnet),
},
)
.await;

let seeds: Vec<SeedEvent> = seed_accounts(["4MCuZ5WNCgFnb7YJ2exj34qsLscmwd23WcoLBXBkaB7d"]);

apply_migrations_and_delete_data(setup.db.clone()).await;
index_seed_events(&setup, seeds.iter().collect_vec()).await;

let request = r#"
{
"id": "4MCuZ5WNCgFnb7YJ2exj34qsLscmwd23WcoLBXBkaB7d"
}
"#;

let request: api::GetAsset = serde_json::from_str(request).unwrap();
let response = setup.das_api.get_asset(request).await.unwrap();
insta::assert_json_snapshot!(name, response);
}

#[tokio::test]
#[serial]
#[named]
async fn test_mpl_core_verified_creators_plugin() {
let name = trim_test_name(function_name!());
let setup = TestSetup::new_with_options(
name.clone(),
TestSetupOptions {
network: Some(Network::Devnet),
},
)
.await;

let seeds: Vec<SeedEvent> = seed_accounts(["AGyjcG9mBfYJFMZiJVkXr4iX7re6vkQ1Fw5grukA6Hiu"]);

apply_migrations_and_delete_data(setup.db.clone()).await;
index_seed_events(&setup, seeds.iter().collect_vec()).await;

let request = r#"
{
"id": "AGyjcG9mBfYJFMZiJVkXr4iX7re6vkQ1Fw5grukA6Hiu"
}
"#;

let request: api::GetAsset = serde_json::from_str(request).unwrap();
let response = setup.das_api.get_asset(request).await.unwrap();
insta::assert_json_snapshot!(name, response);
}

#[tokio::test]
#[serial]
#[named]
async fn test_mpl_core_verified_creators_plugin_with_signature() {
let name = trim_test_name(function_name!());
let setup = TestSetup::new_with_options(
name.clone(),
TestSetupOptions {
network: Some(Network::Devnet),
},
)
.await;

let seeds: Vec<SeedEvent> = seed_accounts(["4iVX1oZj6nLAMerjXFw3UeGD4QU7BEaCscsWqD3zEH37"]);

apply_migrations_and_delete_data(setup.db.clone()).await;
index_seed_events(&setup, seeds.iter().collect_vec()).await;

let request = r#"
{
"id": "4iVX1oZj6nLAMerjXFw3UeGD4QU7BEaCscsWqD3zEH37"
}
"#;

let request: api::GetAsset = serde_json::from_str(request).unwrap();
let response = setup.das_api.get_asset(request).await.unwrap();
insta::assert_json_snapshot!(name, response);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
source: integration_tests/tests/integration_tests/mpl_core_tests.rs
assertion_line: 487
expression: response
---
{
"interface": "MplCoreAsset",
"id": "Hz4MSHgevYkpwF3cerDLuPJLQE3GZ5yDWu7vqmQGpRMU",
"content": {
"$schema": "https://schema.metaplex.com/nft1.0.json",
"json_uri": "https://example.com/asset",
"files": [],
"metadata": {
"name": "Test Asset",
"symbol": ""
},
"links": {}
},
"authorities": [
{
"address": "APrZTeVysBJqAznfLXS71NAzjr2fCVTSF1A66MeErzM7",
"scopes": [
"full"
]
}
],
"compression": {
"eligible": false,
"compressed": false,
"data_hash": "",
"creator_hash": "",
"asset_hash": "",
"tree": "",
"seq": 0,
"leaf_id": 0
},
"grouping": [],
"royalty": {
"royalty_model": "creators",
"target": null,
"percent": 0.0,
"basis_points": 0,
"primary_sale_happened": false,
"locked": false
},
"creators": [],
"ownership": {
"frozen": false,
"delegated": false,
"delegate": null,
"ownership_model": "single",
"owner": "APrZTeVysBJqAznfLXS71NAzjr2fCVTSF1A66MeErzM7"
},
"supply": null,
"mutable": true,
"burnt": false,
"plugins": {
"autograph": {
"data": {
"signatures": []
},
"index": 0,
"offset": 119,
"authority": {
"type": "Owner",
"address": null
}
}
},
"mpl_core_info": {
"plugins_json_version": 1
},
"external_plugins": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
source: integration_tests/tests/integration_tests/mpl_core_tests.rs
assertion_line: 516
expression: response
---
{
"interface": "MplCoreAsset",
"id": "4MCuZ5WNCgFnb7YJ2exj34qsLscmwd23WcoLBXBkaB7d",
"content": {
"$schema": "https://schema.metaplex.com/nft1.0.json",
"json_uri": "https://example.com/asset",
"files": [],
"metadata": {
"name": "Test Asset",
"symbol": ""
},
"links": {}
},
"authorities": [
{
"address": "APrZTeVysBJqAznfLXS71NAzjr2fCVTSF1A66MeErzM7",
"scopes": [
"full"
]
}
],
"compression": {
"eligible": false,
"compressed": false,
"data_hash": "",
"creator_hash": "",
"asset_hash": "",
"tree": "",
"seq": 0,
"leaf_id": 0
},
"grouping": [],
"royalty": {
"royalty_model": "creators",
"target": null,
"percent": 0.0,
"basis_points": 0,
"primary_sale_happened": false,
"locked": false
},
"creators": [],
"ownership": {
"frozen": false,
"delegated": false,
"delegate": null,
"ownership_model": "single",
"owner": "ACxrDWeCPic6voU6a8vyadpL8nSW15Un5vT76LDpxD4N"
},
"supply": null,
"mutable": true,
"burnt": false,
"plugins": {
"autograph": {
"data": {
"signatures": [
{
"address": "APrZTeVysBJqAznfLXS71NAzjr2fCVTSF1A66MeErzM7",
"message": "hi"
}
]
},
"index": 0,
"offset": 119,
"authority": {
"type": "Owner",
"address": null
}
}
},
"mpl_core_info": {
"plugins_json_version": 1
},
"external_plugins": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
source: integration_tests/tests/integration_tests/mpl_core_tests.rs
assertion_line: 545
expression: response
---
{
"interface": "MplCoreAsset",
"id": "AGyjcG9mBfYJFMZiJVkXr4iX7re6vkQ1Fw5grukA6Hiu",
"content": {
"$schema": "https://schema.metaplex.com/nft1.0.json",
"json_uri": "https://example.com/asset",
"files": [],
"metadata": {
"name": "Test Asset",
"symbol": ""
},
"links": {}
},
"authorities": [
{
"address": "APrZTeVysBJqAznfLXS71NAzjr2fCVTSF1A66MeErzM7",
"scopes": [
"full"
]
}
],
"compression": {
"eligible": false,
"compressed": false,
"data_hash": "",
"creator_hash": "",
"asset_hash": "",
"tree": "",
"seq": 0,
"leaf_id": 0
},
"grouping": [],
"royalty": {
"royalty_model": "creators",
"target": null,
"percent": 0.0,
"basis_points": 0,
"primary_sale_happened": false,
"locked": false
},
"creators": [],
"ownership": {
"frozen": false,
"delegated": false,
"delegate": null,
"ownership_model": "single",
"owner": "APrZTeVysBJqAznfLXS71NAzjr2fCVTSF1A66MeErzM7"
},
"supply": null,
"mutable": true,
"burnt": false,
"plugins": {
"verified_creators": {
"data": {
"signatures": []
},
"index": 0,
"offset": 119,
"authority": {
"type": "UpdateAuthority",
"address": null
}
}
},
"mpl_core_info": {
"plugins_json_version": 1
},
"external_plugins": []
}
Loading

0 comments on commit 22d9168

Please sign in to comment.