Skip to content

Commit

Permalink
Update mpl-core crate and indexing for AppData external plugin (met…
Browse files Browse the repository at this point in the history
…aplex-foundation#202)

* Update docker build

* Add initial AppData tests

* Update mpl-core version

* Add LinkedAppData and DataSection tests and results

* Transform DataAuthority and LinkedAppData parent key

* Update test results

* Update to mpl-core beta crate
  • Loading branch information
danenbm authored Aug 2, 2024
1 parent 20460a2 commit 6875b16
Show file tree
Hide file tree
Showing 25 changed files with 1,084 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.75-bullseye AS builder
FROM rust:1.76-bullseye AS builder
RUN apt-get update -y && \
apt-get install -y build-essential make git

Expand Down
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.1", features = ["serde"]}
mpl-core = {version = "0.8.0-beta.1", features = ["serde"]}
mpl-token-metadata = "4.1.1"
nft_ingester = {path = "nft_ingester"}
num-derive = "0.3.3"
Expand Down
2 changes: 1 addition & 1 deletion Migrator.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM das-api/builder AS files

FROM rust:1.75-bullseye
FROM rust:1.76-bullseye
COPY init.sql /init.sql
ENV INIT_FILE_PATH=/init.sql
COPY --from=files /das/migration /bins/migration
Expand Down
2 changes: 1 addition & 1 deletion Proxy.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.75-bullseye AS builder
FROM rust:1.76-bullseye AS builder
RUN cargo install wasm-pack

RUN mkdir /rust
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
265 changes: 265 additions & 0 deletions integration_tests/tests/integration_tests/mpl_core_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,268 @@ async fn test_mpl_core_verified_creators_plugin_with_signature() {
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_get_asset_with_app_data_with_binary_data_and_owner_is_data_authority() {
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(["6tqX4RuPCoD9dVKEJ51jykwBwjKh6runcHJSuSHpDPJU"]);

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

let request = r#"
{
"id": "6tqX4RuPCoD9dVKEJ51jykwBwjKh6runcHJSuSHpDPJU"
}
"#;

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_get_asset_with_app_data_with_json_data_and_update_authority_is_data_authority(
) {
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(["39XrhcVGuyq4HwTarxMCwDEMFtPBY5Nctxrvpvpdpe3g"]);

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

let request = r#"
{
"id": "39XrhcVGuyq4HwTarxMCwDEMFtPBY5Nctxrvpvpdpe3g"
}
"#;

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_get_asset_with_app_data_with_msg_pack_data_and_address_is_data_authority() {
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(["2pY3t29uxpBotbmKbCsQNjYfML5DBoBshDgB7hpHu3XA"]);

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

let request = r#"
{
"id": "2pY3t29uxpBotbmKbCsQNjYfML5DBoBshDgB7hpHu3XA"
}
"#;

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_get_collection_with_linked_app_data_with_binary_data_and_address_is_data_authority(
) {
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(["41thppJ4z9HnBNbFMLnztXS7seqBptYV1jG8UhxR4vK8"]);

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

let request = r#"
{
"id": "41thppJ4z9HnBNbFMLnztXS7seqBptYV1jG8UhxR4vK8"
}
"#;

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_get_asset_with_data_section_with_binary_data() {
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(["BVjK8uvqUuH5YU6ThX6A7gznx2xi8BxshawbuFe1Y5Vr"]);

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

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

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_get_collection_with_linked_app_data_with_json_data_and_owner_is_data_authority(
) {
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(["2aUn89GKuSjfYTeCH6GL1Y6CiUYqjvcgZehFGDJbhNeW"]);

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

let request = r#"
{
"id": "2aUn89GKuSjfYTeCH6GL1Y6CiUYqjvcgZehFGDJbhNeW"
}
"#;

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_get_asset_with_data_section_with_json_data() {
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(["9vqNxe6M6t7PYo1gXrY18hVgDvCpouHSZ6vdDEFbybeA"]);

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

let request = r#"
{
"id": "9vqNxe6M6t7PYo1gXrY18hVgDvCpouHSZ6vdDEFbybeA"
}
"#;

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_get_collection_with_linked_app_data_with_msg_pack_data_and_update_authority_is_data_authority(
) {
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(["53q1PCBy5KgzZfoHu6bnLWQFVmJtKyceP8DqNMhXWUaA"]);

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

let request = r#"
{
"id": "53q1PCBy5KgzZfoHu6bnLWQFVmJtKyceP8DqNMhXWUaA"
}
"#;

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_get_asset_with_data_section_with_msg_pack_data() {
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(["EuXEcqHhF9jPxV9CKB5hjHC2TRo3xprdgk5vJTc9qRaY"]);

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

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

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,82 @@
---
source: integration_tests/tests/integration_tests/mpl_core_tests.rs
assertion_line: 603
expression: response
---
{
"interface": "MplCoreAsset",
"id": "6tqX4RuPCoD9dVKEJ51jykwBwjKh6runcHJSuSHpDPJU",
"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": "HKwwF4sPVYFPgqEgxth4GZRZjJ9o4E3wA8eu2QM5Vt3H"
},
"supply": null,
"mutable": true,
"burnt": false,
"plugins": {},
"mpl_core_info": {
"plugins_json_version": 1
},
"external_plugins": [
{
"data": "SGVsbG8sIHdvcmxkIQ==",
"type": "AppData",
"index": 0,
"offset": 119,
"data_len": 13,
"authority": {
"type": "UpdateAuthority",
"address": null
},
"data_offset": 122,
"adapter_config": {
"schema": "Binary",
"data_authority": {
"type": "Owner",
"address": null
}
}
}
]
}
Loading

0 comments on commit 6875b16

Please sign in to comment.