diff --git a/Cargo.toml b/Cargo.toml index a62a1d5ef..5e440d577 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,7 +77,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" diff --git a/integration_tests/tests/data/accounts/mpl_core_autograph_plugin/Hz4MSHgevYkpwF3cerDLuPJLQE3GZ5yDWu7vqmQGpRMU b/integration_tests/tests/data/accounts/mpl_core_autograph_plugin/Hz4MSHgevYkpwF3cerDLuPJLQE3GZ5yDWu7vqmQGpRMU new file mode 100644 index 000000000..7560f1d6e Binary files /dev/null and b/integration_tests/tests/data/accounts/mpl_core_autograph_plugin/Hz4MSHgevYkpwF3cerDLuPJLQE3GZ5yDWu7vqmQGpRMU differ diff --git a/integration_tests/tests/data/accounts/mpl_core_autograph_plugin_with_signature/4MCuZ5WNCgFnb7YJ2exj34qsLscmwd23WcoLBXBkaB7d b/integration_tests/tests/data/accounts/mpl_core_autograph_plugin_with_signature/4MCuZ5WNCgFnb7YJ2exj34qsLscmwd23WcoLBXBkaB7d new file mode 100644 index 000000000..b1667b268 Binary files /dev/null and b/integration_tests/tests/data/accounts/mpl_core_autograph_plugin_with_signature/4MCuZ5WNCgFnb7YJ2exj34qsLscmwd23WcoLBXBkaB7d differ diff --git a/integration_tests/tests/data/accounts/mpl_core_verified_creators_plugin/AGyjcG9mBfYJFMZiJVkXr4iX7re6vkQ1Fw5grukA6Hiu b/integration_tests/tests/data/accounts/mpl_core_verified_creators_plugin/AGyjcG9mBfYJFMZiJVkXr4iX7re6vkQ1Fw5grukA6Hiu new file mode 100644 index 000000000..62af76d3e Binary files /dev/null and b/integration_tests/tests/data/accounts/mpl_core_verified_creators_plugin/AGyjcG9mBfYJFMZiJVkXr4iX7re6vkQ1Fw5grukA6Hiu differ diff --git a/integration_tests/tests/data/accounts/mpl_core_verified_creators_plugin_with_signature/4iVX1oZj6nLAMerjXFw3UeGD4QU7BEaCscsWqD3zEH37 b/integration_tests/tests/data/accounts/mpl_core_verified_creators_plugin_with_signature/4iVX1oZj6nLAMerjXFw3UeGD4QU7BEaCscsWqD3zEH37 new file mode 100644 index 000000000..afea04796 Binary files /dev/null and b/integration_tests/tests/data/accounts/mpl_core_verified_creators_plugin_with_signature/4iVX1oZj6nLAMerjXFw3UeGD4QU7BEaCscsWqD3zEH37 differ diff --git a/integration_tests/tests/integration_tests/common.rs b/integration_tests/tests/integration_tests/common.rs index e190b39fa..4d4b6a1d0 100644 --- a/integration_tests/tests/integration_tests/common.rs +++ b/integration_tests/tests/integration_tests/common.rs @@ -162,7 +162,7 @@ pub async fn apply_migrations_and_delete_data(db: Arc) { } async fn load_ingest_program_transformer(pool: sqlx::Pool) -> ProgramTransformer { - ProgramTransformer::new(pool, Box::new(|_info| ready(Ok(())).boxed()), false) + ProgramTransformer::new(pool, Box::new(|_info| ready(Ok(())).boxed())) } pub async fn get_transaction( diff --git a/integration_tests/tests/integration_tests/mpl_core_tests.rs b/integration_tests/tests/integration_tests/mpl_core_tests.rs index a8630e84c..5affe048a 100644 --- a/integration_tests/tests/integration_tests/mpl_core_tests.rs +++ b/integration_tests/tests/integration_tests/mpl_core_tests.rs @@ -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 = 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 = 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 = 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 = 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); +} diff --git a/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_autograph_plugin.snap b/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_autograph_plugin.snap new file mode 100644 index 000000000..1a8cfd344 --- /dev/null +++ b/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_autograph_plugin.snap @@ -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": [] +} diff --git a/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_autograph_plugin_with_signature.snap b/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_autograph_plugin_with_signature.snap new file mode 100644 index 000000000..4277369f1 --- /dev/null +++ b/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_autograph_plugin_with_signature.snap @@ -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": [] +} diff --git a/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_verified_creators_plugin.snap b/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_verified_creators_plugin.snap new file mode 100644 index 000000000..6387d404c --- /dev/null +++ b/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_verified_creators_plugin.snap @@ -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": [] +} diff --git a/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_verified_creators_plugin_with_signature.snap b/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_verified_creators_plugin_with_signature.snap new file mode 100644 index 000000000..96428d6a1 --- /dev/null +++ b/integration_tests/tests/integration_tests/snapshots/integration_tests__mpl_core_tests__mpl_core_verified_creators_plugin_with_signature.snap @@ -0,0 +1,79 @@ +--- +source: integration_tests/tests/integration_tests/mpl_core_tests.rs +assertion_line: 574 +expression: response +--- +{ + "interface": "MplCoreAsset", + "id": "4iVX1oZj6nLAMerjXFw3UeGD4QU7BEaCscsWqD3zEH37", + "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": "D9SSaw4tz5AGpfWynYJ66jDCVNTsbLBkqT8rxQFenqj4" + }, + "supply": null, + "mutable": true, + "burnt": false, + "plugins": { + "verified_creators": { + "data": { + "signatures": [ + { + "address": "APrZTeVysBJqAznfLXS71NAzjr2fCVTSF1A66MeErzM7", + "verified": true + } + ] + }, + "index": 0, + "offset": 119, + "authority": { + "type": "UpdateAuthority", + "address": null + } + } + }, + "mpl_core_info": { + "plugins_json_version": 1 + }, + "external_plugins": [] +} diff --git a/nft_ingester/src/account_updates.rs b/nft_ingester/src/account_updates.rs index 6d5372555..6808e8dd2 100644 --- a/nft_ingester/src/account_updates.rs +++ b/nft_ingester/src/account_updates.rs @@ -34,7 +34,6 @@ pub fn account_worker( let manager = Arc::new(ProgramTransformer::new( pool, create_download_metadata_notifier(bg_task_sender), - false, )); loop { let e = msg.recv(stream_key, consumption_type.clone()).await; diff --git a/nft_ingester/src/main.rs b/nft_ingester/src/main.rs index 61cab04e9..85b996cc1 100644 --- a/nft_ingester/src/main.rs +++ b/nft_ingester/src/main.rs @@ -147,7 +147,6 @@ pub async fn main() -> Result<(), IngesterError> { } else { ConsumptionType::New }, - config.cl_audits.unwrap_or(false), stream_name, ); } diff --git a/nft_ingester/src/transaction_notifications.rs b/nft_ingester/src/transaction_notifications.rs index df005bc56..1eb41ce38 100644 --- a/nft_ingester/src/transaction_notifications.rs +++ b/nft_ingester/src/transaction_notifications.rs @@ -26,7 +26,6 @@ pub fn transaction_worker( bg_task_sender: UnboundedSender, ack_channel: UnboundedSender<(&'static str, String)>, consumption_type: ConsumptionType, - cl_audits: bool, stream_key: &'static str, ) -> JoinHandle<()> { tokio::spawn(async move { @@ -35,7 +34,6 @@ pub fn transaction_worker( let manager = Arc::new(ProgramTransformer::new( pool, create_download_metadata_notifier(bg_task_sender), - cl_audits, )); loop { let e = msg.recv(stream_key, consumption_type.clone()).await; diff --git a/program_transformers/src/bubblegum/burn.rs b/program_transformers/src/bubblegum/burn.rs index d0d45cca4..6a18ae5f6 100644 --- a/program_transformers/src/bubblegum/burn.rs +++ b/program_transformers/src/bubblegum/burn.rs @@ -23,14 +23,12 @@ pub async fn burn<'c, T>( bundle: &InstructionBundle<'c>, txn: &'c T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult<()> where T: ConnectionTrait + TransactionTrait, { if let Some(cl) = &parsing_result.tree_update { - let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction, cl_audits) - .await?; + let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction).await?; let leaf_index = cl.index; let (asset_id, _) = Pubkey::find_program_address( &[ diff --git a/program_transformers/src/bubblegum/cancel_redeem.rs b/program_transformers/src/bubblegum/cancel_redeem.rs index 450bde198..28ea1695c 100644 --- a/program_transformers/src/bubblegum/cancel_redeem.rs +++ b/program_transformers/src/bubblegum/cancel_redeem.rs @@ -18,14 +18,12 @@ pub async fn cancel_redeem<'c, T>( bundle: &InstructionBundle<'c>, txn: &'c T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult<()> where T: ConnectionTrait + TransactionTrait, { if let (Some(le), Some(cl)) = (&parsing_result.leaf_update, &parsing_result.tree_update) { - let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction, cl_audits) - .await?; + let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction).await?; match le.schema { LeafSchema::V1 { id, diff --git a/program_transformers/src/bubblegum/collection_verification.rs b/program_transformers/src/bubblegum/collection_verification.rs index 39284ffe3..27a3ed4d4 100644 --- a/program_transformers/src/bubblegum/collection_verification.rs +++ b/program_transformers/src/bubblegum/collection_verification.rs @@ -20,7 +20,6 @@ pub async fn process<'c, T>( bundle: &InstructionBundle<'c>, txn: &'c T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult<()> where T: ConnectionTrait + TransactionTrait, @@ -44,8 +43,7 @@ where "Handling collection verification event for {} (verify: {}): {}", collection, verify, bundle.txn_id ); - let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction, cl_audits) - .await?; + let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction).await?; let id_bytes = match le.schema { LeafSchema::V1 { id, .. } => id.to_bytes().to_vec(), }; diff --git a/program_transformers/src/bubblegum/creator_verification.rs b/program_transformers/src/bubblegum/creator_verification.rs index 22646ec60..8281e7179 100644 --- a/program_transformers/src/bubblegum/creator_verification.rs +++ b/program_transformers/src/bubblegum/creator_verification.rs @@ -20,7 +20,6 @@ pub async fn process<'c, T>( bundle: &InstructionBundle<'c>, txn: &'c T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult<()> where T: ConnectionTrait + TransactionTrait, @@ -60,8 +59,7 @@ where "Handling creator verification event for creator {} (verify: {}): {}", creator, verify, bundle.txn_id ); - let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction, cl_audits) - .await?; + let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction).await?; match le.schema { LeafSchema::V1 { diff --git a/program_transformers/src/bubblegum/db.rs b/program_transformers/src/bubblegum/db.rs index 35191a6af..7f5512b52 100644 --- a/program_transformers/src/bubblegum/db.rs +++ b/program_transformers/src/bubblegum/db.rs @@ -24,12 +24,11 @@ pub async fn save_changelog_event<'c, T>( txn_id: &str, txn: &T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult where T: ConnectionTrait + TransactionTrait, { - insert_change_log(change_log_event, slot, txn_id, txn, instruction, cl_audits).await?; + insert_change_log(change_log_event, slot, txn_id, txn, instruction).await?; Ok(change_log_event.seq) } @@ -43,7 +42,6 @@ pub async fn insert_change_log<'c, T>( txn_id: &str, txn: &T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult<()> where T: ConnectionTrait + TransactionTrait, @@ -95,39 +93,37 @@ where .map_err(|db_err| ProgramTransformerError::StorageWriteError(db_err.to_string()))?; } - // Insert the audit item after the insert into cl_items have been completed - if cl_audits { - let tx_id_bytes = bs58::decode(txn_id) - .into_vec() - .map_err(|_e| ProgramTransformerError::ChangeLogEventMalformed)?; - let ix = Instruction::from(instruction); - if ix == Instruction::Unknown { - error!("Unknown instruction: {}", instruction); - } - let audit_item_v2 = cl_audits_v2::ActiveModel { - tree: ActiveValue::Set(tree_id.to_vec()), - leaf_idx: ActiveValue::Set(change_log_event.index as i64), - seq: ActiveValue::Set(change_log_event.seq as i64), - tx: ActiveValue::Set(tx_id_bytes), - instruction: ActiveValue::Set(ix), - ..Default::default() - }; - let query = cl_audits_v2::Entity::insert(audit_item_v2) - .on_conflict( - OnConflict::columns([ - cl_audits_v2::Column::Tree, - cl_audits_v2::Column::LeafIdx, - cl_audits_v2::Column::Seq, - ]) - .do_nothing() - .to_owned(), - ) - .build(DbBackend::Postgres); - match txn.execute(query).await { - Ok(_) => {} - Err(e) => { - error!("Error while inserting into cl_audits_v2: {:?}", e); - } + let tx_id_bytes = bs58::decode(txn_id) + .into_vec() + .map_err(|_e| ProgramTransformerError::ChangeLogEventMalformed)?; + let ix = Instruction::from(instruction); + if ix == Instruction::Unknown { + error!("Unknown instruction: {}", instruction); + } + let audit_item_v2 = cl_audits_v2::ActiveModel { + tree: ActiveValue::Set(tree_id.to_vec()), + leaf_idx: ActiveValue::Set(change_log_event.index as i64), + seq: ActiveValue::Set(change_log_event.seq as i64), + tx: ActiveValue::Set(tx_id_bytes), + instruction: ActiveValue::Set(ix), + ..Default::default() + }; + + let query = cl_audits_v2::Entity::insert(audit_item_v2) + .on_conflict( + OnConflict::columns([ + cl_audits_v2::Column::Tree, + cl_audits_v2::Column::LeafIdx, + cl_audits_v2::Column::Seq, + ]) + .do_nothing() + .to_owned(), + ) + .build(DbBackend::Postgres); + match txn.execute(query).await { + Ok(_) => {} + Err(e) => { + error!("Error while inserting into cl_audits_v2: {:?}", e); } } diff --git a/program_transformers/src/bubblegum/delegate.rs b/program_transformers/src/bubblegum/delegate.rs index b491ab5b4..15b50a69a 100644 --- a/program_transformers/src/bubblegum/delegate.rs +++ b/program_transformers/src/bubblegum/delegate.rs @@ -18,14 +18,12 @@ pub async fn delegate<'c, T>( bundle: &InstructionBundle<'c>, txn: &'c T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult<()> where T: ConnectionTrait + TransactionTrait, { if let (Some(le), Some(cl)) = (&parsing_result.leaf_update, &parsing_result.tree_update) { - let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction, cl_audits) - .await?; + let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction).await?; match le.schema { LeafSchema::V1 { id, diff --git a/program_transformers/src/bubblegum/mint_v1.rs b/program_transformers/src/bubblegum/mint_v1.rs index 641156cb9..fb179727a 100644 --- a/program_transformers/src/bubblegum/mint_v1.rs +++ b/program_transformers/src/bubblegum/mint_v1.rs @@ -33,7 +33,6 @@ pub async fn mint_v1<'c, T>( bundle: &InstructionBundle<'c>, txn: &'c T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult> where T: ConnectionTrait + TransactionTrait, @@ -51,8 +50,7 @@ where &parsing_result.tree_update, &parsing_result.payload, ) { - let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction, cl_audits) - .await?; + let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction).await?; let metadata = args; #[allow(unreachable_patterns)] return match le.schema { diff --git a/program_transformers/src/bubblegum/mod.rs b/program_transformers/src/bubblegum/mod.rs index c318d57aa..03a800858 100644 --- a/program_transformers/src/bubblegum/mod.rs +++ b/program_transformers/src/bubblegum/mod.rs @@ -30,7 +30,6 @@ pub async fn handle_bubblegum_instruction<'c, T>( bundle: &'c InstructionBundle<'c>, txn: &T, download_metadata_notifier: &DownloadMetadataNotifier, - cl_audits: bool, ) -> ProgramTransformerResult<()> where T: ConnectionTrait + TransactionTrait, @@ -63,46 +62,42 @@ where match ix_type { InstructionName::Transfer => { - transfer::transfer(parsing_result, bundle, txn, ix_str, cl_audits).await?; + transfer::transfer(parsing_result, bundle, txn, ix_str).await?; } InstructionName::Burn => { - burn::burn(parsing_result, bundle, txn, ix_str, cl_audits).await?; + burn::burn(parsing_result, bundle, txn, ix_str).await?; } InstructionName::Delegate => { - delegate::delegate(parsing_result, bundle, txn, ix_str, cl_audits).await?; + delegate::delegate(parsing_result, bundle, txn, ix_str).await?; } InstructionName::MintV1 | InstructionName::MintToCollectionV1 => { - if let Some(info) = - mint_v1::mint_v1(parsing_result, bundle, txn, ix_str, cl_audits).await? - { + if let Some(info) = mint_v1::mint_v1(parsing_result, bundle, txn, ix_str).await? { download_metadata_notifier(info) .await .map_err(ProgramTransformerError::DownloadMetadataNotify)?; } } InstructionName::Redeem => { - redeem::redeem(parsing_result, bundle, txn, ix_str, cl_audits).await?; + redeem::redeem(parsing_result, bundle, txn, ix_str).await?; } InstructionName::CancelRedeem => { - cancel_redeem::cancel_redeem(parsing_result, bundle, txn, ix_str, cl_audits).await?; + cancel_redeem::cancel_redeem(parsing_result, bundle, txn, ix_str).await?; } InstructionName::DecompressV1 => { debug!("No action necessary for decompression") } InstructionName::VerifyCreator | InstructionName::UnverifyCreator => { - creator_verification::process(parsing_result, bundle, txn, ix_str, cl_audits).await?; + creator_verification::process(parsing_result, bundle, txn, ix_str).await?; } InstructionName::VerifyCollection | InstructionName::UnverifyCollection | InstructionName::SetAndVerifyCollection => { - collection_verification::process(parsing_result, bundle, txn, ix_str, cl_audits) - .await?; + collection_verification::process(parsing_result, bundle, txn, ix_str).await?; } InstructionName::SetDecompressibleState => (), // Nothing to index. InstructionName::UpdateMetadata => { if let Some(info) = - update_metadata::update_metadata(parsing_result, bundle, txn, ix_str, cl_audits) - .await? + update_metadata::update_metadata(parsing_result, bundle, txn, ix_str).await? { download_metadata_notifier(info) .await diff --git a/program_transformers/src/bubblegum/redeem.rs b/program_transformers/src/bubblegum/redeem.rs index e6a6080a3..22caaf3dd 100644 --- a/program_transformers/src/bubblegum/redeem.rs +++ b/program_transformers/src/bubblegum/redeem.rs @@ -17,14 +17,12 @@ pub async fn redeem<'c, T>( bundle: &InstructionBundle<'c>, txn: &'c T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult<()> where T: ConnectionTrait + TransactionTrait, { if let Some(cl) = &parsing_result.tree_update { - let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction, cl_audits) - .await?; + let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction).await?; let leaf_index = cl.index; let (asset_id, _) = Pubkey::find_program_address( &[ diff --git a/program_transformers/src/bubblegum/transfer.rs b/program_transformers/src/bubblegum/transfer.rs index 9aa6a3311..9c551beea 100644 --- a/program_transformers/src/bubblegum/transfer.rs +++ b/program_transformers/src/bubblegum/transfer.rs @@ -18,14 +18,12 @@ pub async fn transfer<'c, T>( bundle: &InstructionBundle<'c>, txn: &'c T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult<()> where T: ConnectionTrait + TransactionTrait, { if let (Some(le), Some(cl)) = (&parsing_result.leaf_update, &parsing_result.tree_update) { - let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction, cl_audits) - .await?; + let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction).await?; match le.schema { LeafSchema::V1 { id, diff --git a/program_transformers/src/bubblegum/update_metadata.rs b/program_transformers/src/bubblegum/update_metadata.rs index fd01a930e..702aa552c 100644 --- a/program_transformers/src/bubblegum/update_metadata.rs +++ b/program_transformers/src/bubblegum/update_metadata.rs @@ -31,7 +31,6 @@ pub async fn update_metadata<'c, T>( bundle: &InstructionBundle<'c>, txn: &'c T, instruction: &str, - cl_audits: bool, ) -> ProgramTransformerResult> where T: ConnectionTrait + TransactionTrait, @@ -49,8 +48,7 @@ where &parsing_result.tree_update, &parsing_result.payload, ) { - let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction, cl_audits) - .await?; + let seq = save_changelog_event(cl, bundle.slot, bundle.txn_id, txn, instruction).await?; #[allow(unreachable_patterns)] return match le.schema { diff --git a/program_transformers/src/lib.rs b/program_transformers/src/lib.rs index 79c407bd4..5d6bf5244 100644 --- a/program_transformers/src/lib.rs +++ b/program_transformers/src/lib.rs @@ -85,15 +85,10 @@ pub struct ProgramTransformer { download_metadata_notifier: DownloadMetadataNotifier, parsers: HashMap>, key_set: HashSet, - cl_audits: bool, } impl ProgramTransformer { - pub fn new( - pool: PgPool, - download_metadata_notifier: DownloadMetadataNotifier, - cl_audits: bool, - ) -> Self { + pub fn new(pool: PgPool, download_metadata_notifier: DownloadMetadataNotifier) -> Self { let mut parsers: HashMap> = HashMap::with_capacity(3); let bgum = BubblegumParser {}; let token_metadata = TokenMetadataParser {}; @@ -113,7 +108,6 @@ impl ProgramTransformer { download_metadata_notifier, parsers, key_set: hs, - cl_audits, } } @@ -187,7 +181,6 @@ impl ProgramTransformer { &ix, &self.storage, &self.download_metadata_notifier, - self.cl_audits, ) .await .map_err(|err| { @@ -206,7 +199,10 @@ impl ProgramTransformer { } if not_impl == ixlen { - debug!("Not imple"); + debug!( + "Not implemented for transaction signature: {:?}", + tx_info.signature + ); return Err(ProgramTransformerError::NotImplemented); } Ok(())