diff --git a/python/processors/nft_orderbooks/parsers/okx_parser.py b/python/processors/nft_orderbooks/parsers/okx_parser.py index bb26d4553..5f9c3154b 100644 --- a/python/processors/nft_orderbooks/parsers/okx_parser.py +++ b/python/processors/nft_orderbooks/parsers/okx_parser.py @@ -19,6 +19,8 @@ "okx_listing_utils::CancelListingEvent", ] ) +DEPOSIT_EVENT_V1 = "0x3::token::DepositEvent" +DEPOSIT_EVENT_V2 = "0x3::token::Deposit" def parse_marketplace_events( @@ -141,8 +143,16 @@ def parse_marketplace_events( def get_token_data_from_deposit_events(user_transaction) -> Dict[str, TokenDataIdType]: # Extract deposit events, which contain token metadata deposit_events: Dict[str, TokenDataIdType] = {} - for event in user_transaction.events: - if event.type_str != "0x3::token::DepositEvent": + for idx, event in enumerate(user_transaction.events): + if event.type_str != DEPOSIT_EVENT_V1 and event.type_str != DEPOSIT_EVENT_V2: + continue + # Current event is either DEPOSIT_EVENT_V1 or DEPOSIT_EVENT_V2. + if ( + idx > 0 + # skip if prior event is V2 deposit event. + and user_transaction.events[idx - 1].type_str == DEPOSIT_EVENT_V2 + and event.type_str == DEPOSIT_EVENT_V1 + ): continue account_address = standardize_address(event_utils.get_account_address(event)) data = json.loads(event.data) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index fc4b403c3..a3840cabf 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -198,9 +198,9 @@ dependencies = [ [[package]] name = "aptos-indexer-test-transactions" version = "1.0.0" -source = "git+https://github.com/aptos-labs/aptos-core.git?rev=f60f1f0ca1dd935330152e481e680f1beb5b44ec#f60f1f0ca1dd935330152e481e680f1beb5b44ec" +source = "git+https://github.com/aptos-labs/aptos-core.git?rev=60ee0c686c15480b2cbba224c205e03f479bcdbd#60ee0c686c15480b2cbba224c205e03f479bcdbd" dependencies = [ - "aptos-protos 1.3.1 (git+https://github.com/aptos-labs/aptos-core.git?rev=f60f1f0ca1dd935330152e481e680f1beb5b44ec)", + "aptos-protos 1.3.1 (git+https://github.com/aptos-labs/aptos-core.git?rev=60ee0c686c15480b2cbba224c205e03f479bcdbd)", "serde_json", ] @@ -309,7 +309,7 @@ dependencies = [ [[package]] name = "aptos-protos" version = "1.3.1" -source = "git+https://github.com/aptos-labs/aptos-core.git?rev=f60f1f0ca1dd935330152e481e680f1beb5b44ec#f60f1f0ca1dd935330152e481e680f1beb5b44ec" +source = "git+https://github.com/aptos-labs/aptos-core.git?rev=60ee0c686c15480b2cbba224c205e03f479bcdbd#60ee0c686c15480b2cbba224c205e03f479bcdbd" dependencies = [ "futures-core", "pbjson", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 011ea22f1..763af2006 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -34,7 +34,7 @@ aptos-indexer-processor-sdk = { git = "https://github.com/aptos-labs/aptos-index aptos-indexer-processor-sdk-server-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "e6867c50a2c30ef16ad6f82e02313b2ba5ce361a" } aptos-protos = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "5c48aee129b5a141be2792ffa3d9bd0a1a61c9cb" } aptos-system-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "202bdccff2b2d333a385ae86a4fcf23e89da9f62" } -aptos-indexer-test-transactions = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "f60f1f0ca1dd935330152e481e680f1beb5b44ec" } +aptos-indexer-test-transactions = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "60ee0c686c15480b2cbba224c205e03f479bcdbd" } aptos-indexer-testing-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "e6867c50a2c30ef16ad6f82e02313b2ba5ce361a" } async-trait = "0.1.53" backtrace = "0.3.58" @@ -78,7 +78,6 @@ google-cloud-googleapis = "0.10.0" google-cloud-pubsub = "0.18.0" hex = "0.4.3" itertools = "0.12.1" -lazy_static = "1.4.0" jemallocator = { version = "0.5.0", features = [ "profiling", "unprefixed_malloc_on_supported_platforms", @@ -86,6 +85,7 @@ jemallocator = { version = "0.5.0", features = [ json-structural-diff = "0.1.0" assert-json-diff = "2.0.2" kanal = { version = "0.1.0-pre8", features = ["async"] } +lazy_static = "1.4.0" once_cell = "1.10.0" num_cpus = "1.16.0" pbjson = "0.5.1" diff --git a/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/coin_supply.json b/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/coin_supply.json new file mode 100644 index 000000000..4a8fc99a6 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/coin_supply.json @@ -0,0 +1,10 @@ +[ + { + "transaction_version": 78753811, + "coin_type_hash": "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6", + "coin_type": "0x1::aptos_coin::AptosCoin", + "supply": "18447249875628517278", + "transaction_timestamp": "2024-12-02T19:50:23", + "transaction_epoch": 63 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/current_fungible_asset_balances.json b/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/current_fungible_asset_balances.json new file mode 100644 index 000000000..818b63528 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/current_fungible_asset_balances.json @@ -0,0 +1,24 @@ +[ + { + "storage_id": "0x9249cee32378643feb7674c405057e6287050c151e74d7fee4857e1e82b608d1", + "owner_address": "0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c", + "asset_type": "0x1::aptos_coin::AptosCoin", + "is_primary": true, + "is_frozen": false, + "amount": "34464975541459", + "last_transaction_timestamp": "2024-12-02T19:50:23", + "last_transaction_version": 78753811, + "token_standard": "v1" + }, + { + "storage_id": "0xcec6acee464c2f2689dddf50ad4e9c78bb91b2d0a345cda799ab2a1dcdd4077c", + "owner_address": "0x74512d8383e6857a9a587012c44ad98420cbc713301714402611d7f87a7f4fe0", + "asset_type": "0x1::aptos_coin::AptosCoin", + "is_primary": true, + "is_frozen": false, + "amount": "2", + "last_transaction_timestamp": "2024-12-02T19:50:23", + "last_transaction_version": 78753811, + "token_standard": "v1" + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/fungible_asset_activities.json b/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/fungible_asset_activities.json new file mode 100644 index 000000000..f73ee528f --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/fungible_asset_activities.json @@ -0,0 +1,56 @@ +[ + { + "transaction_version": 78753811, + "event_index": -1, + "owner_address": "0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c", + "storage_id": "0x9249cee32378643feb7674c405057e6287050c151e74d7fee4857e1e82b608d1", + "asset_type": "0x1::aptos_coin::AptosCoin", + "is_frozen": null, + "amount": "700", + "type_": "0x1::aptos_coin::GasFeeEvent", + "is_gas_fee": true, + "gas_fee_payer_address": null, + "is_transaction_success": true, + "entry_function_id_str": "0x1::coin::transfer", + "block_height": 10811317, + "token_standard": "v1", + "transaction_timestamp": "2024-12-02T19:50:23", + "storage_refund_amount": "0" + }, + { + "transaction_version": 78753811, + "event_index": 0, + "owner_address": "0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c", + "storage_id": "0x9249cee32378643feb7674c405057e6287050c151e74d7fee4857e1e82b608d1", + "asset_type": "0x1::aptos_coin::AptosCoin", + "is_frozen": null, + "amount": "1", + "type_": "0x1::coin::CoinWithdraw", + "is_gas_fee": false, + "gas_fee_payer_address": null, + "is_transaction_success": true, + "entry_function_id_str": "0x1::coin::transfer", + "block_height": 10811317, + "token_standard": "v1", + "transaction_timestamp": "2024-12-02T19:50:23", + "storage_refund_amount": "0" + }, + { + "transaction_version": 78753811, + "event_index": 1, + "owner_address": "0x74512d8383e6857a9a587012c44ad98420cbc713301714402611d7f87a7f4fe0", + "storage_id": "0xcec6acee464c2f2689dddf50ad4e9c78bb91b2d0a345cda799ab2a1dcdd4077c", + "asset_type": "0x1::aptos_coin::AptosCoin", + "is_frozen": null, + "amount": "1", + "type_": "0x1::coin::CoinDeposit", + "is_gas_fee": false, + "gas_fee_payer_address": null, + "is_transaction_success": true, + "entry_function_id_str": "0x1::coin::transfer", + "block_height": 10811317, + "token_standard": "v1", + "transaction_timestamp": "2024-12-02T19:50:23", + "storage_refund_amount": "0" + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/fungible_asset_balances.json b/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/fungible_asset_balances.json new file mode 100644 index 000000000..23b20920c --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/fungible_asset_balances.json @@ -0,0 +1,26 @@ +[ + { + "transaction_version": 78753811, + "write_set_change_index": 0, + "storage_id": "0xcec6acee464c2f2689dddf50ad4e9c78bb91b2d0a345cda799ab2a1dcdd4077c", + "owner_address": "0x74512d8383e6857a9a587012c44ad98420cbc713301714402611d7f87a7f4fe0", + "asset_type": "0x1::aptos_coin::AptosCoin", + "is_primary": true, + "is_frozen": false, + "amount": "2", + "transaction_timestamp": "2024-12-02T19:50:23", + "token_standard": "v1" + }, + { + "transaction_version": 78753811, + "write_set_change_index": 1, + "storage_id": "0x9249cee32378643feb7674c405057e6287050c151e74d7fee4857e1e82b608d1", + "owner_address": "0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c", + "asset_type": "0x1::aptos_coin::AptosCoin", + "is_primary": true, + "is_frozen": false, + "amount": "34464975541459", + "transaction_timestamp": "2024-12-02T19:50:23", + "token_standard": "v1" + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/fungible_asset_metadata.json b/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/fungible_asset_metadata.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/fungible_asset_processor/coin_v2_events/fungible_asset_metadata.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/imported_devnet_txns/events_processor/coin_event_v2/events.json b/rust/integration-tests/sdk_expected_db_output_files/imported_devnet_txns/events_processor/coin_event_v2/events.json new file mode 100644 index 000000000..eeb65be06 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/imported_devnet_txns/events_processor/coin_event_v2/events.json @@ -0,0 +1,49 @@ +[ + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753811, + "transaction_block_height": 10811317, + "type_": "0x1::coin::CoinWithdraw", + "data": { + "amount": "1", + "account": "0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c", + "coin_type": "0x1::aptos_coin::AptosCoin" + }, + "indexed_type": "0x1::coin::CoinWithdraw", + "event_index": 0 + }, + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753811, + "transaction_block_height": 10811317, + "type_": "0x1::coin::CoinDeposit", + "data": { + "amount": "1", + "account": "0x74512d8383e6857a9a587012c44ad98420cbc713301714402611d7f87a7f4fe0", + "coin_type": "0x1::aptos_coin::AptosCoin" + }, + "indexed_type": "0x1::coin::CoinDeposit", + "event_index": 1 + }, + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753811, + "transaction_block_height": 10811317, + "type_": "0x1::transaction_fee::FeeStatement", + "data": { + "io_gas_units": "4", + "storage_fee_octas": "0", + "execution_gas_units": "4", + "total_charge_gas_units": "7", + "storage_fee_refund_octas": "0" + }, + "indexed_type": "0x1::transaction_fee::FeeStatement", + "event_index": 2 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/imported_devnet_txns/events_processor/token_v1_event_v2/events.json b/rust/integration-tests/sdk_expected_db_output_files/imported_devnet_txns/events_processor/token_v1_event_v2/events.json new file mode 100644 index 000000000..5ff634fde --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/imported_devnet_txns/events_processor/token_v1_event_v2/events.json @@ -0,0 +1,139 @@ +[ + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753831, + "transaction_block_height": 10811321, + "type_": "0x3::token::TokenDataCreation", + "data": { + "id": { + "name": "NFT Collectible #13360", + "creator": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a", + "collection": "An NFT Collection Name" + }, + "uri": "https://aptos.dev", + "name": "NFT Collectible #13360", + "creator": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a", + "maximum": "1", + "description": "", + "property_keys": [], + "property_types": [], + "property_values": [], + "mutability_config": { + "uri": true, + "maximum": true, + "royalty": true, + "properties": true, + "description": true + }, + "royalty_payee_address": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a", + "royalty_points_numerator": "0", + "royalty_points_denominator": "100" + }, + "indexed_type": "0x3::token::TokenDataCreation", + "event_index": 0 + }, + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753831, + "transaction_block_height": 10811321, + "type_": "0x3::token::Mint", + "data": { + "id": { + "name": "NFT Collectible #13360", + "creator": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a", + "collection": "An NFT Collection Name" + }, + "amount": "1", + "creator": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a" + }, + "indexed_type": "0x3::token::Mint", + "event_index": 1 + }, + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753831, + "transaction_block_height": 10811321, + "type_": "0x3::token::TokenDeposit", + "data": { + "id": { + "token_data_id": { + "name": "NFT Collectible #13360", + "creator": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a", + "collection": "An NFT Collection Name" + }, + "property_version": "0" + }, + "amount": "1", + "account": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a" + }, + "indexed_type": "0x3::token::TokenDeposit", + "event_index": 2 + }, + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753831, + "transaction_block_height": 10811321, + "type_": "0x3::token::TokenWithdraw", + "data": { + "id": { + "token_data_id": { + "name": "NFT Collectible #13360", + "creator": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a", + "collection": "An NFT Collection Name" + }, + "property_version": "0" + }, + "amount": "1", + "account": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a" + }, + "indexed_type": "0x3::token::TokenWithdraw", + "event_index": 3 + }, + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753831, + "transaction_block_height": 10811321, + "type_": "0x3::token::TokenDeposit", + "data": { + "id": { + "token_data_id": { + "name": "NFT Collectible #13360", + "creator": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a", + "collection": "An NFT Collection Name" + }, + "property_version": "0" + }, + "amount": "1", + "account": "0x348cd99611633b0eb8ee803016bcd26bae4ce9d2954da8ab060cd90ecea39118" + }, + "indexed_type": "0x3::token::TokenDeposit", + "event_index": 4 + }, + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753831, + "transaction_block_height": 10811321, + "type_": "0x1::transaction_fee::FeeStatement", + "data": { + "io_gas_units": "6", + "storage_fee_octas": "97720", + "execution_gas_units": "8", + "total_charge_gas_units": "991", + "storage_fee_refund_octas": "0" + }, + "indexed_type": "0x1::transaction_fee::FeeStatement", + "event_index": 5 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/imported_devnet_txns/events_processor/token_v2_event_v2/events.json b/rust/integration-tests/sdk_expected_db_output_files/imported_devnet_txns/events_processor/token_v2_event_v2/events.json new file mode 100644 index 000000000..455e5f45d --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/imported_devnet_txns/events_processor/token_v2_event_v2/events.json @@ -0,0 +1,51 @@ +[ + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753832, + "transaction_block_height": 10811321, + "type_": "0x4::collection::Mint", + "data": { + "index": { + "value": "133740" + }, + "token": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "collection": "0x58677eec16fc1a3d37dcfe5fa3ab62081d0838a694612a34e757caa7f7f2adb0" + }, + "indexed_type": "0x4::collection::Mint", + "event_index": 0 + }, + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753832, + "transaction_block_height": 10811321, + "type_": "0x1::object::Transfer", + "data": { + "to": "0x28adfb8a46395e7ccd83038860764193eea3f834ae6894e75cd80a3e1ff23b0b", + "from": "0xc8185b4484917ffda406f31fb71ab9a2b9ac7387041235b21dd7e4e5bdccb838", + "object": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b" + }, + "indexed_type": "0x1::object::Transfer", + "event_index": 1 + }, + { + "sequence_number": 0, + "creation_number": 0, + "account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "transaction_version": 78753832, + "transaction_block_height": 10811321, + "type_": "0x1::transaction_fee::FeeStatement", + "data": { + "io_gas_units": "6", + "storage_fee_octas": "78920", + "execution_gas_units": "6", + "total_charge_gas_units": "801", + "storage_fee_refund_octas": "0" + }, + "indexed_type": "0x1::transaction_fee::FeeStatement", + "event_index": 2 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/collections_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/collections_v2.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/collections_v2.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_collections_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_collections_v2.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_collections_v2.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_datas_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_datas_v2.json new file mode 100644 index 000000000..ac09f6305 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_datas_v2.json @@ -0,0 +1,19 @@ +[ + { + "token_data_id": "0xa91e026e2572b12e1d115ee7459326a87f709be38a85e1ebddb4de50c1b3696d", + "collection_id": "0x5f7245e54ce188cae66bd5fe4f06bd70a90391024adc65786cad9f3cc2321ca1", + "token_name": "NFT Collectible #13360", + "maximum": "1", + "supply": "1", + "largest_property_version_v1": "0", + "token_uri": "https://aptos.dev", + "description": "", + "token_properties": {}, + "token_standard": "v1", + "is_fungible_v2": null, + "last_transaction_version": 78753831, + "last_transaction_timestamp": "2024-12-02T19:50:23.770129", + "is_deleted_v2": null, + "decimals": 0 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_ownerships_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_ownerships_v2.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_ownerships_v2.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_pending_claims.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_pending_claims.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_pending_claims.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_v2_metadata.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_v2_metadata.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/current_token_v2_metadata.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/token_activities_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/token_activities_v2.json new file mode 100644 index 000000000..04dd2e9c4 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/token_activities_v2.json @@ -0,0 +1,70 @@ +[ + { + "transaction_version": 78753831, + "event_index": 1, + "event_account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "token_data_id": "0xa91e026e2572b12e1d115ee7459326a87f709be38a85e1ebddb4de50c1b3696d", + "property_version_v1": "0", + "type_": "0x3::token::Mint", + "from_address": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a", + "to_address": null, + "token_amount": "1", + "before_value": null, + "after_value": null, + "entry_function_id_str": "0xa1a48478a4f217b97198b9d828bd00abd8d96120bb97aca904e6203448f6babc::token_v1::token_v1_mint_and_transfer_nft_sequential", + "token_standard": "v1", + "is_fungible_v2": null, + "transaction_timestamp": "2024-12-02T19:50:23.770129" + }, + { + "transaction_version": 78753831, + "event_index": 2, + "event_account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "token_data_id": "0xa91e026e2572b12e1d115ee7459326a87f709be38a85e1ebddb4de50c1b3696d", + "property_version_v1": "0", + "type_": "0x3::token::TokenDeposit", + "from_address": null, + "to_address": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a", + "token_amount": "1", + "before_value": null, + "after_value": null, + "entry_function_id_str": "0xa1a48478a4f217b97198b9d828bd00abd8d96120bb97aca904e6203448f6babc::token_v1::token_v1_mint_and_transfer_nft_sequential", + "token_standard": "v1", + "is_fungible_v2": null, + "transaction_timestamp": "2024-12-02T19:50:23.770129" + }, + { + "transaction_version": 78753831, + "event_index": 3, + "event_account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "token_data_id": "0xa91e026e2572b12e1d115ee7459326a87f709be38a85e1ebddb4de50c1b3696d", + "property_version_v1": "0", + "type_": "0x3::token::TokenWithdraw", + "from_address": "0xcdc14b3f3edbbb739a0a7168661ae562449dd88ede045f4a310a4cf41489001a", + "to_address": null, + "token_amount": "1", + "before_value": null, + "after_value": null, + "entry_function_id_str": "0xa1a48478a4f217b97198b9d828bd00abd8d96120bb97aca904e6203448f6babc::token_v1::token_v1_mint_and_transfer_nft_sequential", + "token_standard": "v1", + "is_fungible_v2": null, + "transaction_timestamp": "2024-12-02T19:50:23.770129" + }, + { + "transaction_version": 78753831, + "event_index": 4, + "event_account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "token_data_id": "0xa91e026e2572b12e1d115ee7459326a87f709be38a85e1ebddb4de50c1b3696d", + "property_version_v1": "0", + "type_": "0x3::token::TokenDeposit", + "from_address": null, + "to_address": "0x348cd99611633b0eb8ee803016bcd26bae4ce9d2954da8ab060cd90ecea39118", + "token_amount": "1", + "before_value": null, + "after_value": null, + "entry_function_id_str": "0xa1a48478a4f217b97198b9d828bd00abd8d96120bb97aca904e6203448f6babc::token_v1::token_v1_mint_and_transfer_nft_sequential", + "token_standard": "v1", + "is_fungible_v2": null, + "transaction_timestamp": "2024-12-02T19:50:23.770129" + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/token_datas_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/token_datas_v2.json new file mode 100644 index 000000000..98f705e5e --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/token_datas_v2.json @@ -0,0 +1,20 @@ +[ + { + "transaction_version": 78753831, + "write_set_change_index": 4, + "token_data_id": "0xa91e026e2572b12e1d115ee7459326a87f709be38a85e1ebddb4de50c1b3696d", + "collection_id": "0x5f7245e54ce188cae66bd5fe4f06bd70a90391024adc65786cad9f3cc2321ca1", + "token_name": "NFT Collectible #13360", + "maximum": "1", + "supply": "1", + "largest_property_version_v1": "0", + "token_uri": "https://aptos.dev", + "token_properties": {}, + "description": "", + "token_standard": "v1", + "is_fungible_v2": null, + "transaction_timestamp": "2024-12-02T19:50:23.770129", + "is_deleted_v2": null, + "decimals": 0 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/token_ownerships_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/token_ownerships_v2.json new file mode 100644 index 000000000..c8ddb39b8 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v1_with_module_events/token_ownerships_v2.json @@ -0,0 +1,18 @@ +[ + { + "transaction_version": 78753831, + "write_set_change_index": 3, + "token_data_id": "0xa91e026e2572b12e1d115ee7459326a87f709be38a85e1ebddb4de50c1b3696d", + "property_version_v1": "0", + "owner_address": null, + "storage_id": "0x5b2921d6a8a8a6565432e265672fd6b9a06e243c31a7634f207eefc88fb2e7cf", + "amount": "1", + "table_type_v1": null, + "token_properties_mutated_v1": {}, + "is_soulbound_v2": null, + "token_standard": "v1", + "is_fungible_v2": null, + "transaction_timestamp": "2024-12-02T19:50:23.770129", + "non_transferrable_by_owner": null + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/collections_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/collections_v2.json new file mode 100644 index 000000000..de6274f96 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/collections_v2.json @@ -0,0 +1,20 @@ +[ + { + "transaction_version": 78753832, + "write_set_change_index": 3, + "collection_id": "0x58677eec16fc1a3d37dcfe5fa3ab62081d0838a694612a34e757caa7f7f2adb0", + "creator_address": "0xc8185b4484917ffda406f31fb71ab9a2b9ac7387041235b21dd7e4e5bdccb838", + "collection_name": "Ambassador Collection Name", + "description": "Ambassador Collection Description", + "uri": "Ambassador Collection URI", + "current_supply": "133740", + "max_supply": null, + "total_minted_v2": "133740", + "mutable_description": null, + "mutable_uri": null, + "table_handle_v1": null, + "token_standard": "v2", + "transaction_timestamp": "2024-12-02T19:50:23.770129", + "collection_properties": null + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_collections_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_collections_v2.json new file mode 100644 index 000000000..5a24e3482 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_collections_v2.json @@ -0,0 +1,19 @@ +[ + { + "collection_id": "0x58677eec16fc1a3d37dcfe5fa3ab62081d0838a694612a34e757caa7f7f2adb0", + "creator_address": "0xc8185b4484917ffda406f31fb71ab9a2b9ac7387041235b21dd7e4e5bdccb838", + "collection_name": "Ambassador Collection Name", + "description": "Ambassador Collection Description", + "uri": "Ambassador Collection URI", + "current_supply": "133740", + "max_supply": null, + "total_minted_v2": "133740", + "mutable_description": null, + "mutable_uri": null, + "table_handle_v1": null, + "token_standard": "v2", + "last_transaction_version": 78753832, + "last_transaction_timestamp": "2024-12-02T19:50:23.770129", + "collection_properties": null + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_datas_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_datas_v2.json new file mode 100644 index 000000000..c927ba378 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_datas_v2.json @@ -0,0 +1,21 @@ +[ + { + "token_data_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "collection_id": "0x58677eec16fc1a3d37dcfe5fa3ab62081d0838a694612a34e757caa7f7f2adb0", + "token_name": "superstar #133740", + "maximum": null, + "supply": null, + "largest_property_version_v1": null, + "token_uri": "fEL4YUz13hHhi573dzmC0yulbUh7RGcHxWjDteeRIuPE0dfBVBBronze", + "description": "pd9eIPNuxydkn3JJsYvGKVGMomZXCvuc1EQ92PzpIW512zEeCJEKGXR21707nHmzRLokNVfJ5ufd5jzk3GINOLAZ2CjGlsM2SJWb", + "token_properties": { + "Rank": "Bronze" + }, + "token_standard": "v2", + "is_fungible_v2": false, + "last_transaction_version": 78753832, + "last_transaction_timestamp": "2024-12-02T19:50:23.770129", + "is_deleted_v2": false, + "decimals": 0 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_ownerships_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_ownerships_v2.json new file mode 100644 index 000000000..337ff9ce9 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_ownerships_v2.json @@ -0,0 +1,32 @@ +[ + { + "token_data_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "property_version_v1": "0", + "owner_address": "0x28adfb8a46395e7ccd83038860764193eea3f834ae6894e75cd80a3e1ff23b0b", + "storage_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "amount": "1", + "table_type_v1": null, + "token_properties_mutated_v1": null, + "is_soulbound_v2": true, + "token_standard": "v2", + "is_fungible_v2": null, + "last_transaction_version": 78753832, + "last_transaction_timestamp": "2024-12-02T19:50:23.770129", + "non_transferrable_by_owner": true + }, + { + "token_data_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "property_version_v1": "0", + "owner_address": "0xc8185b4484917ffda406f31fb71ab9a2b9ac7387041235b21dd7e4e5bdccb838", + "storage_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "amount": "0", + "table_type_v1": null, + "token_properties_mutated_v1": null, + "is_soulbound_v2": true, + "token_standard": "v2", + "is_fungible_v2": null, + "last_transaction_version": 78753832, + "last_transaction_timestamp": "2024-12-02T19:50:23.770129", + "non_transferrable_by_owner": true + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_pending_claims.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_pending_claims.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_pending_claims.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_v2_metadata.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_v2_metadata.json new file mode 100644 index 000000000..6f6c8852d --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/current_token_v2_metadata.json @@ -0,0 +1,38 @@ +[ + { + "object_address": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "resource_type": "0xc8185b4484917ffda406f31fb71ab9a2b9ac7387041235b21dd7e4e5bdccb838::ambassador::AmbassadorLevel", + "data": { + "ambassador_level": "0" + }, + "state_key_hash": "0x9a91bb43853f0c9f30d912d370fe4d7d2afde0b34a81c00233d963c48c04ef6d", + "last_transaction_version": 78753832 + }, + { + "object_address": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "resource_type": "0xc8185b4484917ffda406f31fb71ab9a2b9ac7387041235b21dd7e4e5bdccb838::ambassador::AmbassadorToken", + "data": { + "base_uri": "fEL4YUz13hHhi573dzmC0yulbUh7RGcHxWjDteeRIuPE0dfBVB", + "burn_ref": { + "self": { + "vec": [] + }, + "inner": { + "vec": [ + { + "self": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b" + } + ] + } + }, + "mutator_ref": { + "self": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b" + }, + "property_mutator_ref": { + "self": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b" + } + }, + "state_key_hash": "0x9a91bb43853f0c9f30d912d370fe4d7d2afde0b34a81c00233d963c48c04ef6d", + "last_transaction_version": 78753832 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/token_activities_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/token_activities_v2.json new file mode 100644 index 000000000..d59893364 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/token_activities_v2.json @@ -0,0 +1,36 @@ +[ + { + "transaction_version": 78753832, + "event_index": 0, + "event_account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "token_data_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "property_version_v1": "0", + "type_": "0x4::collection::MintEvent", + "from_address": "0x28adfb8a46395e7ccd83038860764193eea3f834ae6894e75cd80a3e1ff23b0b", + "to_address": null, + "token_amount": "1", + "before_value": null, + "after_value": null, + "entry_function_id_str": "0xc8185b4484917ffda406f31fb71ab9a2b9ac7387041235b21dd7e4e5bdccb838::ambassador::mint_numbered_ambassador_token_by_user", + "token_standard": "v2", + "is_fungible_v2": null, + "transaction_timestamp": "2024-12-02T19:50:23.770129" + }, + { + "transaction_version": 78753832, + "event_index": 1, + "event_account_address": "0x0000000000000000000000000000000000000000000000000000000000000000", + "token_data_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "property_version_v1": "0", + "type_": "0x1::object::Transfer", + "from_address": "0xc8185b4484917ffda406f31fb71ab9a2b9ac7387041235b21dd7e4e5bdccb838", + "to_address": "0x28adfb8a46395e7ccd83038860764193eea3f834ae6894e75cd80a3e1ff23b0b", + "token_amount": "1", + "before_value": null, + "after_value": null, + "entry_function_id_str": "0xc8185b4484917ffda406f31fb71ab9a2b9ac7387041235b21dd7e4e5bdccb838::ambassador::mint_numbered_ambassador_token_by_user", + "token_standard": "v2", + "is_fungible_v2": null, + "transaction_timestamp": "2024-12-02T19:50:23.770129" + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/token_datas_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/token_datas_v2.json new file mode 100644 index 000000000..f152949eb --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/token_datas_v2.json @@ -0,0 +1,22 @@ +[ + { + "transaction_version": 78753832, + "write_set_change_index": 7, + "token_data_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "collection_id": "0x58677eec16fc1a3d37dcfe5fa3ab62081d0838a694612a34e757caa7f7f2adb0", + "token_name": "superstar #133740", + "maximum": null, + "supply": null, + "largest_property_version_v1": null, + "token_uri": "fEL4YUz13hHhi573dzmC0yulbUh7RGcHxWjDteeRIuPE0dfBVBBronze", + "token_properties": { + "Rank": "Bronze" + }, + "description": "pd9eIPNuxydkn3JJsYvGKVGMomZXCvuc1EQ92PzpIW512zEeCJEKGXR21707nHmzRLokNVfJ5ufd5jzk3GINOLAZ2CjGlsM2SJWb", + "token_standard": "v2", + "is_fungible_v2": false, + "transaction_timestamp": "2024-12-02T19:50:23.770129", + "is_deleted_v2": null, + "decimals": 0 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/token_ownerships_v2.json b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/token_ownerships_v2.json new file mode 100644 index 000000000..debce3f3c --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/token_v2_processor/test_token_v2_with_module_events/token_ownerships_v2.json @@ -0,0 +1,34 @@ +[ + { + "transaction_version": 78753832, + "write_set_change_index": -1, + "token_data_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "property_version_v1": "0", + "owner_address": "0xc8185b4484917ffda406f31fb71ab9a2b9ac7387041235b21dd7e4e5bdccb838", + "storage_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "amount": "0", + "table_type_v1": null, + "token_properties_mutated_v1": null, + "is_soulbound_v2": true, + "token_standard": "v2", + "is_fungible_v2": null, + "transaction_timestamp": "2024-12-02T19:50:23.770129", + "non_transferrable_by_owner": true + }, + { + "transaction_version": 78753832, + "write_set_change_index": 7, + "token_data_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "property_version_v1": "0", + "owner_address": "0x28adfb8a46395e7ccd83038860764193eea3f834ae6894e75cd80a3e1ff23b0b", + "storage_id": "0xb63f1fe89e713c0bbd093ea2f5d7af58fa69e90af27035f0b2e202e66d432d6b", + "amount": "1", + "table_type_v1": null, + "token_properties_mutated_v1": null, + "is_soulbound_v2": true, + "token_standard": "v2", + "is_fungible_v2": null, + "transaction_timestamp": "2024-12-02T19:50:23.770129", + "non_transferrable_by_owner": true + } +] \ No newline at end of file diff --git a/rust/integration-tests/src/sdk_tests/events_processor_tests.rs b/rust/integration-tests/src/sdk_tests/events_processor_tests.rs index d5f6086a8..08b292564 100644 --- a/rust/integration-tests/src/sdk_tests/events_processor_tests.rs +++ b/rust/integration-tests/src/sdk_tests/events_processor_tests.rs @@ -49,6 +49,9 @@ mod tests { }; use aptos_indexer_processor_sdk::traits::processor_trait::ProcessorTrait; use aptos_indexer_test_transactions::{ + IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS, + IMPORTED_DEVNET_TXNS_78753831_TOKEN_V1_MINT_TRANSFER_WITH_V2_EVENTS, + IMPORTED_DEVNET_TXNS_78753832_TOKEN_V2_MINT_TRANSFER_WITH_V2_EVENTS, IMPORTED_TESTNET_TXNS_1255836496_V2_FA_METADATA_, IMPORTED_TESTNET_TXNS_1_GENESIS, IMPORTED_TESTNET_TXNS_278556781_V1_COIN_REGISTER_FA_METADATA, IMPORTED_TESTNET_TXNS_2_NEW_BLOCK_EVENT, IMPORTED_TESTNET_TXNS_3_EMPTY_TXN, @@ -121,6 +124,33 @@ mod tests { .await; } + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn devnet_events_processor_coin_module_events() { + process_single_devnet_event_txn( + IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS, + Some("coin_event_v2".to_string()), + ) + .await; + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn devnet_events_processor_token_v1_module_events() { + process_single_devnet_event_txn( + IMPORTED_DEVNET_TXNS_78753831_TOKEN_V1_MINT_TRANSFER_WITH_V2_EVENTS, + Some("token_v1_event_v2".to_string()), + ) + .await; + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn devnet_events_processor_token_v2_module_events() { + process_single_devnet_event_txn( + IMPORTED_DEVNET_TXNS_78753832_TOKEN_V2_MINT_TRANSFER_WITH_V2_EVENTS, + Some("token_v2_event_v2".to_string()), + ) + .await; + } + // Example 2: Test for multiple transactions handling #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn testnet_events_processor_db_output_scenario_testing() { @@ -180,11 +210,23 @@ mod tests { } } - // Helper function to abstract out the single transaction processing + async fn process_single_devnet_event_txn(txn: &[u8], test_case_name: Option) { + process_single_event_txn(txn, test_case_name, "imported_devnet_txns").await + } + async fn process_single_testnet_event_txn(txn: &[u8], test_case_name: Option) { + process_single_event_txn(txn, test_case_name, "imported_testnet_txns").await + } + + // Helper function to abstract out the single transaction processing + async fn process_single_event_txn( + txn: &[u8], + test_case_name: Option, + folder_name: &str, + ) { let (diff_flag, custom_output_path) = get_test_config(); let output_path = custom_output_path - .unwrap_or_else(|| format!("{}/imported_testnet_txns", DEFAULT_OUTPUT_FOLDER)); + .unwrap_or_else(|| format!("{}/{}", DEFAULT_OUTPUT_FOLDER, folder_name)); let (db, mut test_context) = setup_test_environment(&[txn]).await; diff --git a/rust/integration-tests/src/sdk_tests/fungible_asset_processor_tests.rs b/rust/integration-tests/src/sdk_tests/fungible_asset_processor_tests.rs index 2c9105b85..f7df83060 100644 --- a/rust/integration-tests/src/sdk_tests/fungible_asset_processor_tests.rs +++ b/rust/integration-tests/src/sdk_tests/fungible_asset_processor_tests.rs @@ -49,6 +49,7 @@ mod sdk_fungible_asset_processor_tests { }, }; use aptos_indexer_test_transactions::{ + IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS, IMPORTED_MAINNET_TXNS_508365567_FA_V1_EVENTS, IMPORTED_MAINNET_TXNS_999929475_COIN_AND_FA_TRANSFERS, IMPORTED_TESTNET_TXNS_1200394037_FA_V2_FROZEN_EVENT, @@ -156,6 +157,15 @@ mod sdk_fungible_asset_processor_tests { .await; } + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_fungible_asset_processor_coin_v2_events() { + process_single_testnet_fa_txns( + IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS, + Some("coin_v2_events".to_string()), + ) + .await; + } + // Helper function to abstract out the transaction processing async fn process_single_testnet_fa_txns(txn: &[u8], test_case_name: Option) { let (diff_flag, custom_output_path) = get_test_config(); diff --git a/rust/integration-tests/src/sdk_tests/token_v2_processor_tests.rs b/rust/integration-tests/src/sdk_tests/token_v2_processor_tests.rs index 7443db1dc..3bbc2ba18 100644 --- a/rust/integration-tests/src/sdk_tests/token_v2_processor_tests.rs +++ b/rust/integration-tests/src/sdk_tests/token_v2_processor_tests.rs @@ -58,6 +58,8 @@ mod sdk_token_v2_processor_tests { }, }; use aptos_indexer_test_transactions::{ + IMPORTED_DEVNET_TXNS_78753831_TOKEN_V1_MINT_TRANSFER_WITH_V2_EVENTS, + IMPORTED_DEVNET_TXNS_78753832_TOKEN_V2_MINT_TRANSFER_WITH_V2_EVENTS, IMPORTED_MAINNET_TXNS_1058723093_TOKEN_V1_MINT_WITHDRAW_DEPOSIT_EVENTS, IMPORTED_MAINNET_TXNS_1080786089_TOKEN_V2_BURN_EVENT_V1, IMPORTED_MAINNET_TXNS_11648867_TOKEN_V1_BURN_EVENT, @@ -331,6 +333,23 @@ mod sdk_token_v2_processor_tests { .await; } + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_token_v1_with_module_events() { + process_single_transaction( + IMPORTED_DEVNET_TXNS_78753831_TOKEN_V1_MINT_TRANSFER_WITH_V2_EVENTS, + Some("test_token_v1_with_module_events".to_string()), + ) + .await; + } + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_token_v2_with_module_events() { + process_single_transaction( + IMPORTED_DEVNET_TXNS_78753832_TOKEN_V2_MINT_TRANSFER_WITH_V2_EVENTS, + Some("test_token_v2_with_module_events".to_string()), + ) + .await; + } + // Helper function to abstract out the transaction processing async fn process_single_transaction(txn: &[u8], test_case_name: Option) { let (diff_flag, custom_output_path) = get_test_config(); diff --git a/rust/processor/src/db/postgres/models/coin_models/coin_activities.rs b/rust/processor/src/db/postgres/models/coin_models/coin_activities.rs index 14e30c294..e54362a21 100644 --- a/rust/processor/src/db/postgres/models/coin_models/coin_activities.rs +++ b/rust/processor/src/db/postgres/models/coin_models/coin_activities.rs @@ -228,23 +228,44 @@ impl CoinActivity { transaction_timestamp: chrono::NaiveDateTime, event_index: i64, ) -> Self { - let amount = match coin_event { - CoinEvent::WithdrawCoinEvent(inner) => inner.amount.clone(), - CoinEvent::DepositCoinEvent(inner) => inner.amount.clone(), - }; - let event_move_guid = EventGuidResource { - addr: standardize_address(event.key.as_ref().unwrap().account_address.as_str()), - creation_num: event.key.as_ref().unwrap().creation_number as i64, + let (owner_address, amount, coin_type_option) = match coin_event { + CoinEvent::WithdrawCoinEvent(inner) => ( + standardize_address(&event.key.as_ref().unwrap().account_address), + inner.amount.clone(), + None, + ), + CoinEvent::DepositCoinEvent(inner) => ( + standardize_address(&event.key.as_ref().unwrap().account_address), + inner.amount.clone(), + None, + ), + CoinEvent::WithdrawCoinEventV2(inner) => ( + standardize_address(&inner.account), + inner.amount.clone(), + Some(inner.coin_type.clone()), + ), + CoinEvent::DepositCoinEventV2(inner) => ( + standardize_address(&inner.account), + inner.amount.clone(), + Some(inner.coin_type.clone()), + ), }; - let coin_type = + let coin_type = if let Some(coin_type) = coin_type_option { + coin_type + } else { + let event_move_guid = EventGuidResource { + addr: standardize_address(event.key.as_ref().unwrap().account_address.as_str()), + creation_num: event.key.as_ref().unwrap().creation_number as i64, + }; event_to_coin_type - .get(&event_move_guid) - .unwrap_or_else(|| { - panic!( - "Could not find event in resources (CoinStore), version: {}, event guid: {:?}, mapping: {:?}", - txn_version, event_move_guid, event_to_coin_type - ) - }).clone(); + .get(&event_move_guid) + .unwrap_or_else(|| { + panic!( + "Could not find event in resources (CoinStore), version: {}, event guid: {:?}, mapping: {:?}", + txn_version, event_move_guid, event_to_coin_type + ) + }).clone() + }; Self { transaction_version: txn_version, @@ -253,7 +274,7 @@ impl CoinActivity { ), event_creation_number: event.key.as_ref().unwrap().creation_number as i64, event_sequence_number: event.sequence_number as i64, - owner_address: standardize_address(&event.key.as_ref().unwrap().account_address), + owner_address, coin_type, amount, activity_type: event_type.to_string(), diff --git a/rust/processor/src/db/postgres/models/coin_models/coin_utils.rs b/rust/processor/src/db/postgres/models/coin_models/coin_utils.rs index 1c1b599dc..365868a3b 100644 --- a/rust/processor/src/db/postgres/models/coin_models/coin_utils.rs +++ b/rust/processor/src/db/postgres/models/coin_models/coin_utils.rs @@ -150,6 +150,22 @@ pub struct DepositCoinEvent { pub amount: BigDecimal, } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct WithdrawCoinEventV2 { + pub coin_type: String, + pub account: String, + #[serde(deserialize_with = "deserialize_from_string")] + pub amount: BigDecimal, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct DepositCoinEventV2 { + pub coin_type: String, + pub account: String, + #[serde(deserialize_with = "deserialize_from_string")] + pub amount: BigDecimal, +} + pub struct CoinInfoType { coin_type: String, creator_address: String, @@ -318,6 +334,8 @@ impl CoinResource { pub enum CoinEvent { WithdrawCoinEvent(WithdrawCoinEvent), DepositCoinEvent(DepositCoinEvent), + WithdrawCoinEventV2(WithdrawCoinEventV2), + DepositCoinEventV2(DepositCoinEventV2), } impl CoinEvent { @@ -329,6 +347,12 @@ impl CoinEvent { "0x1::coin::DepositEvent" => { serde_json::from_str(data).map(|inner| Some(CoinEvent::DepositCoinEvent(inner))) }, + "0x1::coin::CoinWithdraw" => { + serde_json::from_str(data).map(|inner| Some(CoinEvent::WithdrawCoinEventV2(inner))) + }, + "0x1::coin::CoinDeposit" => { + serde_json::from_str(data).map(|inner| Some(CoinEvent::DepositCoinEventV2(inner))) + }, _ => Ok(None), } .context(format!( diff --git a/rust/processor/src/db/postgres/models/fungible_asset_models/parquet_v2_fungible_asset_activities.rs b/rust/processor/src/db/postgres/models/fungible_asset_models/parquet_v2_fungible_asset_activities.rs index d902b34bb..d720f500e 100644 --- a/rust/processor/src/db/postgres/models/fungible_asset_models/parquet_v2_fungible_asset_activities.rs +++ b/rust/processor/src/db/postgres/models/fungible_asset_models/parquet_v2_fungible_asset_activities.rs @@ -180,6 +180,16 @@ impl FungibleAssetActivity { inner.amount.to_string(), None, ), + CoinEvent::WithdrawCoinEventV2(inner) => ( + standardize_address(&inner.account), + inner.amount.to_string(), + Some(inner.coin_type.clone()), + ), + CoinEvent::DepositCoinEventV2(inner) => ( + standardize_address(&inner.account), + inner.amount.to_string(), + Some(inner.coin_type.clone()), + ), }; let coin_type = if let Some(coin_type) = coin_type_option { coin_type diff --git a/rust/processor/src/db/postgres/models/fungible_asset_models/v2_fungible_asset_activities.rs b/rust/processor/src/db/postgres/models/fungible_asset_models/v2_fungible_asset_activities.rs index 75f3dbd58..afb6eca33 100644 --- a/rust/processor/src/db/postgres/models/fungible_asset_models/v2_fungible_asset_activities.rs +++ b/rust/processor/src/db/postgres/models/fungible_asset_models/v2_fungible_asset_activities.rs @@ -162,6 +162,16 @@ impl FungibleAssetActivity { inner.amount.clone(), None, ), + CoinEvent::WithdrawCoinEventV2(inner) => ( + standardize_address(&inner.account), + inner.amount.clone(), + Some(inner.coin_type.clone()), + ), + CoinEvent::DepositCoinEventV2(inner) => ( + standardize_address(&inner.account), + inner.amount.clone(), + Some(inner.coin_type.clone()), + ), }; let coin_type = if let Some(coin_type) = coin_type_option { coin_type diff --git a/rust/processor/src/db/postgres/models/stake_models/proposal_votes.rs b/rust/processor/src/db/postgres/models/stake_models/proposal_votes.rs index ebe473e0c..0540afb5e 100644 --- a/rust/processor/src/db/postgres/models/stake_models/proposal_votes.rs +++ b/rust/processor/src/db/postgres/models/stake_models/proposal_votes.rs @@ -49,7 +49,7 @@ impl ProposalVote { let txn_version = transaction.version as i64; if let TxnData::User(user_txn) = txn_data { - for event in &user_txn.events { + for event in user_txn.events.iter() { if let Some(StakeEvent::GovernanceVoteEvent(ev)) = StakeEvent::from_event(event.type_str.as_str(), &event.data, txn_version)? { diff --git a/rust/processor/src/db/postgres/models/stake_models/stake_utils.rs b/rust/processor/src/db/postgres/models/stake_models/stake_utils.rs index b3abae54d..b988a58c3 100644 --- a/rust/processor/src/db/postgres/models/stake_models/stake_utils.rs +++ b/rust/processor/src/db/postgres/models/stake_models/stake_utils.rs @@ -200,21 +200,24 @@ pub enum StakeEvent { impl StakeEvent { pub fn from_event(data_type: &str, data: &str, txn_version: i64) -> Result> { match data_type { - "0x1::aptos_governance::VoteEvent" => { + "0x1::aptos_governance::VoteEvent" | "0x1::aptos_governance::Vote" => { serde_json::from_str(data).map(|inner| Some(StakeEvent::GovernanceVoteEvent(inner))) }, - "0x1::stake::DistributeRewardsEvent" => serde_json::from_str(data) - .map(|inner| Some(StakeEvent::DistributeRewardsEvent(inner))), - "0x1::delegation_pool::AddStakeEvent" => { + "0x1::stake::DistributeRewardsEvent" | "0x1::stake::DistributeRewards" => { + serde_json::from_str(data) + .map(|inner| Some(StakeEvent::DistributeRewardsEvent(inner))) + }, + "0x1::delegation_pool::AddStakeEvent" | "0x1::delegation_pool::AddStake" => { serde_json::from_str(data).map(|inner| Some(StakeEvent::AddStakeEvent(inner))) }, - "0x1::delegation_pool::UnlockStakeEvent" => { + "0x1::delegation_pool::UnlockStakeEvent" | "0x1::delegation_pool::UnlockStake" => { serde_json::from_str(data).map(|inner| Some(StakeEvent::UnlockStakeEvent(inner))) }, - "0x1::delegation_pool::WithdrawStakeEvent" => { + "0x1::delegation_pool::WithdrawStakeEvent" | "0x1::delegation_pool::WithdrawStake" => { serde_json::from_str(data).map(|inner| Some(StakeEvent::WithdrawStakeEvent(inner))) }, - "0x1::delegation_pool::ReactivateStakeEvent" => serde_json::from_str(data) + "0x1::delegation_pool::ReactivateStakeEvent" + | "0x1::delegation_pool::ReactivateStake" => serde_json::from_str(data) .map(|inner| Some(StakeEvent::ReactivateStakeEvent(inner))), _ => Ok(None), } diff --git a/rust/processor/src/db/postgres/models/token_models/token_activities.rs b/rust/processor/src/db/postgres/models/token_models/token_activities.rs index 638738f14..cf2da00ac 100644 --- a/rust/processor/src/db/postgres/models/token_models/token_activities.rs +++ b/rust/processor/src/db/postgres/models/token_models/token_activities.rs @@ -120,6 +120,15 @@ impl TokenActivity { coin_type: None, coin_amount: None, }, + TokenEvent::Mint(inner) => TokenActivityHelper { + token_data_id: &inner.id, + property_version: BigDecimal::zero(), + from_address: Some(inner.get_account()), + to_address: None, + token_amount: inner.amount.clone(), + coin_type: None, + coin_amount: None, + }, TokenEvent::BurnTokenEvent(inner) => TokenActivityHelper { token_data_id: &inner.id.token_data_id, property_version: inner.id.property_version.clone(), @@ -129,6 +138,15 @@ impl TokenActivity { coin_type: None, coin_amount: None, }, + TokenEvent::Burn(inner) => TokenActivityHelper { + token_data_id: &inner.id.token_data_id, + property_version: inner.id.property_version.clone(), + from_address: Some(inner.get_account()), + to_address: None, + token_amount: inner.amount.clone(), + coin_type: None, + coin_amount: None, + }, TokenEvent::MutateTokenPropertyMapEvent(inner) => TokenActivityHelper { token_data_id: &inner.new_id.token_data_id, property_version: inner.new_id.property_version.clone(), @@ -138,6 +156,15 @@ impl TokenActivity { coin_type: None, coin_amount: None, }, + TokenEvent::MutatePropertyMap(inner) => TokenActivityHelper { + token_data_id: &inner.new_id.token_data_id, + property_version: inner.new_id.property_version.clone(), + from_address: Some(inner.get_account()), + to_address: None, + token_amount: BigDecimal::zero(), + coin_type: None, + coin_amount: None, + }, TokenEvent::WithdrawTokenEvent(inner) => TokenActivityHelper { token_data_id: &inner.id.token_data_id, property_version: inner.id.property_version.clone(), @@ -147,6 +174,15 @@ impl TokenActivity { coin_type: None, coin_amount: None, }, + TokenEvent::TokenWithdraw(inner) => TokenActivityHelper { + token_data_id: &inner.id.token_data_id, + property_version: inner.id.property_version.clone(), + from_address: Some(inner.get_account()), + to_address: None, + token_amount: inner.amount.clone(), + coin_type: None, + coin_amount: None, + }, TokenEvent::DepositTokenEvent(inner) => TokenActivityHelper { token_data_id: &inner.id.token_data_id, property_version: inner.id.property_version.clone(), @@ -156,6 +192,15 @@ impl TokenActivity { coin_type: None, coin_amount: None, }, + TokenEvent::TokenDeposit(inner) => TokenActivityHelper { + token_data_id: &inner.id.token_data_id, + property_version: inner.id.property_version.clone(), + from_address: None, + to_address: Some(inner.get_account()), + token_amount: inner.amount.clone(), + coin_type: None, + coin_amount: None, + }, TokenEvent::OfferTokenEvent(inner) => TokenActivityHelper { token_data_id: &inner.token_id.token_data_id, property_version: inner.token_id.property_version.clone(), @@ -183,6 +228,33 @@ impl TokenActivity { coin_type: None, coin_amount: None, }, + TokenEvent::Offer(inner) => TokenActivityHelper { + token_data_id: &inner.token_id.token_data_id, + property_version: inner.token_id.property_version.clone(), + from_address: Some(inner.get_from_address()), + to_address: Some(inner.get_to_address()), + token_amount: inner.amount.clone(), + coin_type: None, + coin_amount: None, + }, + TokenEvent::CancelOffer(inner) => TokenActivityHelper { + token_data_id: &inner.token_id.token_data_id, + property_version: inner.token_id.property_version.clone(), + from_address: Some(inner.get_from_address()), + to_address: Some(inner.get_to_address()), + token_amount: inner.amount.clone(), + coin_type: None, + coin_amount: None, + }, + TokenEvent::Claim(inner) => TokenActivityHelper { + token_data_id: &inner.token_id.token_data_id, + property_version: inner.token_id.property_version.clone(), + from_address: Some(inner.get_from_address()), + to_address: Some(inner.get_to_address()), + token_amount: inner.amount.clone(), + coin_type: None, + coin_amount: None, + }, }; let token_data_id = token_activity_helper.token_data_id; Self { diff --git a/rust/processor/src/db/postgres/models/token_models/token_utils.rs b/rust/processor/src/db/postgres/models/token_models/token_utils.rs index 49f967ffb..eef444ac0 100644 --- a/rust/processor/src/db/postgres/models/token_models/token_utils.rs +++ b/rust/processor/src/db/postgres/models/token_models/token_utils.rs @@ -250,6 +250,19 @@ pub struct WithdrawTokenEventType { pub id: TokenIdType, } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct WithdrawTokenEventTypeV2 { + account: String, + #[serde(deserialize_with = "deserialize_from_string")] + pub amount: BigDecimal, + pub id: TokenIdType, +} +impl WithdrawTokenEventTypeV2 { + pub fn get_account(&self) -> String { + standardize_address(&self.account) + } +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct DepositTokenEventType { #[serde(deserialize_with = "deserialize_from_string")] @@ -257,6 +270,20 @@ pub struct DepositTokenEventType { pub id: TokenIdType, } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct DepositTokenEventTypeV2 { + account: String, + #[serde(deserialize_with = "deserialize_from_string")] + pub amount: BigDecimal, + pub id: TokenIdType, +} + +impl DepositTokenEventTypeV2 { + pub fn get_account(&self) -> String { + standardize_address(&self.account) + } +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct MintTokenEventType { #[serde(deserialize_with = "deserialize_from_string")] @@ -264,6 +291,20 @@ pub struct MintTokenEventType { pub id: TokenDataIdType, } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct MintTokenEventTypeV2 { + creator: String, + #[serde(deserialize_with = "deserialize_from_string")] + pub amount: BigDecimal, + pub id: TokenDataIdType, +} + +impl MintTokenEventTypeV2 { + pub fn get_account(&self) -> String { + standardize_address(&self.creator) + } +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct BurnTokenEventType { #[serde(deserialize_with = "deserialize_from_string")] @@ -271,12 +312,39 @@ pub struct BurnTokenEventType { pub id: TokenIdType, } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct BurnTokenEventTypeV2 { + account: String, + #[serde(deserialize_with = "deserialize_from_string")] + pub amount: BigDecimal, + pub id: TokenIdType, +} + +impl BurnTokenEventTypeV2 { + pub fn get_account(&self) -> String { + standardize_address(&self.account) + } +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct MutateTokenPropertyMapEventType { pub old_id: TokenIdType, pub new_id: TokenIdType, } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct MutateTokenPropertyMapEventTypeV2 { + account: String, + pub old_id: TokenIdType, + pub new_id: TokenIdType, +} + +impl MutateTokenPropertyMapEventTypeV2 { + pub fn get_account(&self) -> String { + standardize_address(&self.account) + } +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct OfferTokenEventType { #[serde(deserialize_with = "deserialize_from_string")] @@ -291,6 +359,25 @@ impl OfferTokenEventType { } } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct OfferTokenEventTypeV2 { + #[serde(deserialize_with = "deserialize_from_string")] + pub amount: BigDecimal, + account: String, + to_address: String, + pub token_id: TokenIdType, +} + +impl OfferTokenEventTypeV2 { + pub fn get_to_address(&self) -> String { + standardize_address(&self.to_address) + } + + pub fn get_from_address(&self) -> String { + standardize_address(&self.account) + } +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct CancelTokenOfferEventType { #[serde(deserialize_with = "deserialize_from_string")] @@ -305,6 +392,25 @@ impl CancelTokenOfferEventType { } } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct CancelTokenOfferEventTypeV2 { + #[serde(deserialize_with = "deserialize_from_string")] + pub amount: BigDecimal, + account: String, + to_address: String, + pub token_id: TokenIdType, +} + +impl CancelTokenOfferEventTypeV2 { + pub fn get_from_address(&self) -> String { + standardize_address(&self.account) + } + + pub fn get_to_address(&self) -> String { + standardize_address(&self.to_address) + } +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ClaimTokenEventType { #[serde(deserialize_with = "deserialize_from_string")] @@ -319,6 +425,25 @@ impl ClaimTokenEventType { } } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct ClaimTokenEventTypeV2 { + #[serde(deserialize_with = "deserialize_from_string")] + pub amount: BigDecimal, + account: String, + to_address: String, + pub token_id: TokenIdType, +} + +impl ClaimTokenEventTypeV2 { + pub fn get_from_address(&self) -> String { + standardize_address(&self.account) + } + + pub fn get_to_address(&self) -> String { + standardize_address(&self.to_address) + } +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct TypeInfo { pub account_address: String, @@ -385,13 +510,21 @@ impl TokenWriteSet { #[derive(Serialize, Deserialize, Debug, Clone)] pub enum TokenEvent { MintTokenEvent(MintTokenEventType), + Mint(MintTokenEventTypeV2), BurnTokenEvent(BurnTokenEventType), + Burn(BurnTokenEventTypeV2), MutateTokenPropertyMapEvent(MutateTokenPropertyMapEventType), + MutatePropertyMap(MutateTokenPropertyMapEventTypeV2), WithdrawTokenEvent(WithdrawTokenEventType), + TokenWithdraw(WithdrawTokenEventTypeV2), DepositTokenEvent(DepositTokenEventType), + TokenDeposit(DepositTokenEventTypeV2), OfferTokenEvent(OfferTokenEventType), + Offer(OfferTokenEventTypeV2), CancelTokenOfferEvent(CancelTokenOfferEventType), + CancelOffer(CancelTokenOfferEventTypeV2), ClaimTokenEvent(ClaimTokenEventType), + Claim(ClaimTokenEventTypeV2), } impl TokenEvent { @@ -400,25 +533,49 @@ impl TokenEvent { "0x3::token::MintTokenEvent" => { serde_json::from_str(data).map(|inner| Some(TokenEvent::MintTokenEvent(inner))) }, + "0x3::token::Mint" => { + serde_json::from_str(data).map(|inner| Some(TokenEvent::Mint(inner))) + }, "0x3::token::BurnTokenEvent" => { serde_json::from_str(data).map(|inner| Some(TokenEvent::BurnTokenEvent(inner))) }, + "0x3::token::Burn" => { + serde_json::from_str(data).map(|inner| Some(TokenEvent::Burn(inner))) + }, "0x3::token::MutateTokenPropertyMapEvent" => serde_json::from_str(data) .map(|inner| Some(TokenEvent::MutateTokenPropertyMapEvent(inner))), + "0x3::token::MutatePropertyMap" => { + serde_json::from_str(data).map(|inner| Some(TokenEvent::MutatePropertyMap(inner))) + }, "0x3::token::WithdrawEvent" => { serde_json::from_str(data).map(|inner| Some(TokenEvent::WithdrawTokenEvent(inner))) }, + "0x3::token::TokenWithdraw" => { + serde_json::from_str(data).map(|inner| Some(TokenEvent::TokenWithdraw(inner))) + }, "0x3::token::DepositEvent" => { serde_json::from_str(data).map(|inner| Some(TokenEvent::DepositTokenEvent(inner))) }, + "0x3::token::TokenDeposit" => { + serde_json::from_str(data).map(|inner| Some(TokenEvent::TokenDeposit(inner))) + }, "0x3::token_transfers::TokenOfferEvent" => { serde_json::from_str(data).map(|inner| Some(TokenEvent::OfferTokenEvent(inner))) }, + "0x3::token_transfers::Offer" => { + serde_json::from_str(data).map(|inner| Some(TokenEvent::Offer(inner))) + }, "0x3::token_transfers::TokenCancelOfferEvent" => serde_json::from_str(data) .map(|inner| Some(TokenEvent::CancelTokenOfferEvent(inner))), + "0x3::token_transfers::CancelOffer" => { + serde_json::from_str(data).map(|inner| Some(TokenEvent::CancelOffer(inner))) + }, "0x3::token_transfers::TokenClaimEvent" => { serde_json::from_str(data).map(|inner| Some(TokenEvent::ClaimTokenEvent(inner))) }, + "0x3::token_transfers::Claim" => { + serde_json::from_str(data).map(|inner| Some(TokenEvent::Claim(inner))) + }, _ => Ok(None), } .context(format!( diff --git a/rust/processor/src/db/postgres/models/token_v2_models/v2_token_activities.rs b/rust/processor/src/db/postgres/models/token_v2_models/v2_token_activities.rs index b76da7d5c..6121baf07 100644 --- a/rust/processor/src/db/postgres/models/token_v2_models/v2_token_activities.rs +++ b/rust/processor/src/db/postgres/models/token_v2_models/v2_token_activities.rs @@ -111,6 +111,14 @@ impl TokenActivityV2 { after_value: Some(inner.new_value.clone()), event_type: event_type.clone(), }, + V2TokenEvent::TokenMutation(inner) => TokenActivityHelperV2 { + from_address: Some(inner.token_address.clone()), + to_address: None, + token_amount: BigDecimal::zero(), + before_value: Some(inner.old_value.clone()), + after_value: Some(inner.new_value.clone()), + event_type: "0x4::collection::MutationEvent".to_string(), + }, V2TokenEvent::BurnEvent(_) => TokenActivityHelperV2 { from_address: Some(object_core.get_owner_address()), to_address: None, @@ -205,6 +213,13 @@ impl TokenActivityV2 { to_address: None, token_amount: inner.amount.clone(), }, + TokenEvent::Mint(inner) => TokenActivityHelperV1 { + token_data_id_struct: inner.id.clone(), + property_version: BigDecimal::zero(), + from_address: Some(inner.get_account()), + to_address: None, + token_amount: inner.amount.clone(), + }, TokenEvent::BurnTokenEvent(inner) => TokenActivityHelperV1 { token_data_id_struct: inner.id.token_data_id.clone(), property_version: inner.id.property_version.clone(), @@ -212,6 +227,13 @@ impl TokenActivityV2 { to_address: None, token_amount: inner.amount.clone(), }, + TokenEvent::Burn(inner) => TokenActivityHelperV1 { + token_data_id_struct: inner.id.token_data_id.clone(), + property_version: inner.id.property_version.clone(), + from_address: Some(inner.get_account()), + to_address: None, + token_amount: inner.amount.clone(), + }, TokenEvent::MutateTokenPropertyMapEvent(inner) => TokenActivityHelperV1 { token_data_id_struct: inner.new_id.token_data_id.clone(), property_version: inner.new_id.property_version.clone(), @@ -219,6 +241,13 @@ impl TokenActivityV2 { to_address: None, token_amount: BigDecimal::zero(), }, + TokenEvent::MutatePropertyMap(inner) => TokenActivityHelperV1 { + token_data_id_struct: inner.new_id.token_data_id.clone(), + property_version: inner.new_id.property_version.clone(), + from_address: Some(inner.get_account()), + to_address: None, + token_amount: BigDecimal::zero(), + }, TokenEvent::WithdrawTokenEvent(inner) => TokenActivityHelperV1 { token_data_id_struct: inner.id.token_data_id.clone(), property_version: inner.id.property_version.clone(), @@ -226,6 +255,13 @@ impl TokenActivityV2 { to_address: None, token_amount: inner.amount.clone(), }, + TokenEvent::TokenWithdraw(inner) => TokenActivityHelperV1 { + token_data_id_struct: inner.id.token_data_id.clone(), + property_version: inner.id.property_version.clone(), + from_address: Some(inner.get_account()), + to_address: None, + token_amount: inner.amount.clone(), + }, TokenEvent::DepositTokenEvent(inner) => TokenActivityHelperV1 { token_data_id_struct: inner.id.token_data_id.clone(), property_version: inner.id.property_version.clone(), @@ -233,6 +269,13 @@ impl TokenActivityV2 { to_address: Some(standardize_address(&event_account_address)), token_amount: inner.amount.clone(), }, + TokenEvent::TokenDeposit(inner) => TokenActivityHelperV1 { + token_data_id_struct: inner.id.token_data_id.clone(), + property_version: inner.id.property_version.clone(), + from_address: None, + to_address: Some(inner.get_account()), + token_amount: inner.amount.clone(), + }, TokenEvent::OfferTokenEvent(inner) => TokenActivityHelperV1 { token_data_id_struct: inner.token_id.token_data_id.clone(), property_version: inner.token_id.property_version.clone(), @@ -254,6 +297,27 @@ impl TokenActivityV2 { to_address: Some(inner.get_to_address()), token_amount: inner.amount.clone(), }, + TokenEvent::Offer(inner) => TokenActivityHelperV1 { + token_data_id_struct: inner.token_id.token_data_id.clone(), + property_version: inner.token_id.property_version.clone(), + from_address: Some(inner.get_from_address()), + to_address: Some(inner.get_to_address()), + token_amount: inner.amount.clone(), + }, + TokenEvent::CancelOffer(inner) => TokenActivityHelperV1 { + token_data_id_struct: inner.token_id.token_data_id.clone(), + property_version: inner.token_id.property_version.clone(), + from_address: Some(inner.get_from_address()), + to_address: Some(inner.get_to_address()), + token_amount: inner.amount.clone(), + }, + TokenEvent::Claim(inner) => TokenActivityHelperV1 { + token_data_id_struct: inner.token_id.token_data_id.clone(), + property_version: inner.token_id.property_version.clone(), + from_address: Some(inner.get_from_address()), + to_address: Some(inner.get_to_address()), + token_amount: inner.amount.clone(), + }, }; let token_data_id_struct = token_activity_helper.token_data_id_struct; return Ok(Some(Self { diff --git a/rust/processor/src/db/postgres/models/token_v2_models/v2_token_utils.rs b/rust/processor/src/db/postgres/models/token_v2_models/v2_token_utils.rs index 5fac55943..b6bab62bf 100644 --- a/rust/processor/src/db/postgres/models/token_v2_models/v2_token_utils.rs +++ b/rust/processor/src/db/postgres/models/token_v2_models/v2_token_utils.rs @@ -219,6 +219,16 @@ pub struct Mint { } impl Mint { + pub fn from_event(event: &Event, txn_version: i64) -> anyhow::Result> { + if let Some(V2TokenEvent::Mint(inner)) = + V2TokenEvent::from_event(event.type_str.as_str(), &event.data, txn_version).unwrap() + { + Ok(Some(inner)) + } else { + Ok(None) + } + } + pub fn get_token_address(&self) -> String { standardize_address(&self.token) } @@ -231,6 +241,14 @@ pub struct TokenMutationEvent { pub new_value: String, } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct TokenMutationEventV2 { + pub token_address: String, + pub mutated_field_name: String, + pub old_value: String, + pub new_value: String, +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct BurnEvent { #[serde(deserialize_with = "deserialize_from_string")] @@ -257,14 +275,22 @@ impl BurnEvent { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Burn { collection: String, + #[serde(deserialize_with = "deserialize_from_string")] + pub index: BigDecimal, token: String, previous_owner: String, } impl Burn { - pub fn new(collection: String, token: String, previous_owner: String) -> Self { + pub fn new( + collection: String, + index: BigDecimal, + token: String, + previous_owner: String, + ) -> Self { Burn { collection, + index, token, previous_owner, } @@ -367,6 +393,7 @@ pub enum V2TokenEvent { Mint(Mint), MintEvent(MintEvent), TokenMutationEvent(TokenMutationEvent), + TokenMutation(TokenMutationEventV2), Burn(Burn), BurnEvent(BurnEvent), TransferEvent(TransferEvent), @@ -384,13 +411,16 @@ impl V2TokenEvent { "0x4::token::MutationEvent" => { serde_json::from_str(data).map(|inner| Some(Self::TokenMutationEvent(inner))) }, + "0x4::token::Mutation" => { + serde_json::from_str(data).map(|inner| Some(Self::TokenMutation(inner))) + }, "0x4::collection::Burn" => { serde_json::from_str(data).map(|inner| Some(Self::Burn(inner))) }, "0x4::collection::BurnEvent" => { serde_json::from_str(data).map(|inner| Some(Self::BurnEvent(inner))) }, - "0x1::object::TransferEvent" => { + "0x1::object::TransferEvent" | "0x1::object::Transfer" => { serde_json::from_str(data).map(|inner| Some(Self::TransferEvent(inner))) }, _ => Ok(None), diff --git a/rust/processor/src/processors/parquet_processors/parquet_token_v2_processor.rs b/rust/processor/src/processors/parquet_processors/parquet_token_v2_processor.rs index 0cf6b34a0..9d544e713 100644 --- a/rust/processor/src/processors/parquet_processors/parquet_token_v2_processor.rs +++ b/rust/processor/src/processors/parquet_processors/parquet_token_v2_processor.rs @@ -1,4 +1,5 @@ // Copyright © Aptos Foundation + // SPDX-License-Identifier: Apache-2.0 use crate::{ @@ -279,6 +280,7 @@ async fn parse_v2_token( if let Some(old_burn_event) = BurnEvent::from_event(event, txn_version).unwrap() { let burn_event = Burn::new( standardize_address(event.key.as_ref().unwrap().account_address.as_str()), + old_burn_event.index.clone(), old_burn_event.get_token_address(), "".to_string(), ); diff --git a/rust/processor/src/processors/token_v2_processor.rs b/rust/processor/src/processors/token_v2_processor.rs index fac3cdbd7..591ed2bae 100644 --- a/rust/processor/src/processors/token_v2_processor.rs +++ b/rust/processor/src/processors/token_v2_processor.rs @@ -24,7 +24,7 @@ use crate::{ TokenOwnershipV2, }, v2_token_utils::{ - Burn, BurnEvent, MintEvent, TokenV2Burned, TokenV2Minted, TransferEvent, + Burn, BurnEvent, Mint, MintEvent, TokenV2Burned, TokenV2Minted, TransferEvent, }, }, }, @@ -849,20 +849,23 @@ pub async fn parse_v2_token( // and burn / transfer events need to come before the next loop for (index, event) in user_txn.events.iter().enumerate() { if let Some(burn_event) = Burn::from_event(event, txn_version).unwrap() { - tokens_burned.insert(burn_event.get_token_address(), burn_event); - } - if let Some(old_burn_event) = BurnEvent::from_event(event, txn_version).unwrap() { + tokens_burned.insert(burn_event.get_token_address(), burn_event.clone()); + } else if let Some(mint_event) = Mint::from_event(event, txn_version).unwrap() { + tokens_minted.insert(mint_event.get_token_address()); + } else if let Some(old_burn_event) = + BurnEvent::from_event(event, txn_version).unwrap() + { let burn_event = Burn::new( standardize_address(event.key.as_ref().unwrap().account_address.as_str()), + old_burn_event.index.clone(), old_burn_event.get_token_address(), "".to_string(), ); tokens_burned.insert(burn_event.get_token_address(), burn_event); - } - if let Some(mint_event) = MintEvent::from_event(event, txn_version).unwrap() { + } else if let Some(mint_event) = MintEvent::from_event(event, txn_version).unwrap() + { tokens_minted.insert(mint_event.get_token_address()); - } - if let Some(transfer_events) = + } else if let Some(transfer_events) = TransferEvent::from_event(event, txn_version).unwrap() { if let Some(aggregated_data) = diff --git a/rust/testing-transactions/build.rs b/rust/testing-transactions/build.rs index 500774ba4..7c861ca9f 100644 --- a/rust/testing-transactions/build.rs +++ b/rust/testing-transactions/build.rs @@ -12,6 +12,7 @@ fn main() { // Create necessary directories if missing create_directory_if_missing("json_transactions/imported_mainnet_txns"); create_directory_if_missing("json_transactions/imported_testnet_txns"); + create_directory_if_missing("json_transactions/imported_devnet_txns"); create_directory_if_missing("json_transactions/scripted_transactions"); // Process different directories and collect name mappings @@ -27,6 +28,12 @@ fn main() { false, &mut name_function_code, )); + all_transactions_code.push_str(&process_directory( + "imported_devnet_txns", + "IMPORTED_DEVNET_TXNS", + false, + &mut name_function_code, + )); all_transactions_code.push_str(&process_directory( "scripted_transactions", "SCRIPTED_TRANSACTIONS",