Skip to content

Commit 14c35c9

Browse files
committed
fixup! add coin_store_deletion_event info to event_to_coin_type map
1 parent df8aaf1 commit 14c35c9

File tree

11 files changed

+194
-76
lines changed

11 files changed

+194
-76
lines changed

rust/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ anyhow = "1.0.86"
3131
aptos-indexer-processor-sdk = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" }
3232
aptos-indexer-processor-sdk-server-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" }
3333
aptos-protos = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "1d8460a995503574ec4e9699d3442d0150d7f3b9" }
34-
aptos-indexer-test-transactions = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "80b98ce2c8cda854f3bccf0e8649d33606e624eb" }
34+
aptos-indexer-test-transactions = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "e80c1336de5f3a8b83dfe5539936a79ef9c1edb8" }
3535
aptos-indexer-testing-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" }
3636
async-trait = "0.1.53"
3737
backtrace = "0.3.58"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"transaction_version": 2448304257,
4+
"coin_type_hash": "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
5+
"coin_type": "0x1::aptos_coin::AptosCoin",
6+
"supply": "114337055298908041",
7+
"transaction_timestamp": "2025-03-07T22:32:23",
8+
"transaction_epoch": 10582
9+
}
10+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[
2+
{
3+
"storage_id": "0x35b5700571cbb1c340c5a2fa7e1ecc32fd8b4da273881c2728058bd4c2514895",
4+
"owner_address": "0x2dcbc03740a6fa2efee926b9df329184cce357d0573bdab09930f4d48e61a4c8",
5+
"asset_type_v2": null,
6+
"asset_type_v1": "0x1::aptos_coin::AptosCoin",
7+
"is_primary": true,
8+
"is_frozen": false,
9+
"amount_v1": "25361327420",
10+
"amount_v2": null,
11+
"amount": "25361327420",
12+
"last_transaction_version_v1": 2448304257,
13+
"last_transaction_version_v2": null,
14+
"last_transaction_version": 2448304257,
15+
"last_transaction_timestamp_v1": "2025-03-07T22:32:23",
16+
"last_transaction_timestamp_v2": null,
17+
"last_transaction_timestamp": "2025-03-07T22:32:23",
18+
"token_standard": "v1",
19+
"asset_type": "0x1::aptos_coin::AptosCoin"
20+
},
21+
{
22+
"storage_id": "0xd5263bada2f6b752de987f5e8eca800ffb07f34c489633fc7eb46acea7cd5c37",
23+
"owner_address": "0xf8e25f6c8ce40a15107fb4b4d288ca03dd434d057392f2ccb5fde505a300a0bf",
24+
"asset_type_v2": "0x000000000000000000000000000000000000000000000000000000000000000a",
25+
"asset_type_v1": "0x1::aptos_coin::AptosCoin",
26+
"is_primary": true,
27+
"is_frozen": false,
28+
"amount_v1": "0",
29+
"amount_v2": "49843000",
30+
"amount": "49843000",
31+
"last_transaction_version_v1": 2448304257,
32+
"last_transaction_version_v2": 2448304257,
33+
"last_transaction_version": 2448304257,
34+
"last_transaction_timestamp_v1": "2025-03-07T22:32:23",
35+
"last_transaction_timestamp_v2": "2025-03-07T22:32:23",
36+
"last_transaction_timestamp": "2025-03-07T22:32:23",
37+
"token_standard": "v1",
38+
"asset_type": "0x1::aptos_coin::AptosCoin"
39+
}
40+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[
2+
{
3+
"transaction_version": 2448304257,
4+
"event_index": -1,
5+
"owner_address": "0xf8e25f6c8ce40a15107fb4b4d288ca03dd434d057392f2ccb5fde505a300a0bf",
6+
"storage_id": "0xd5263bada2f6b752de987f5e8eca800ffb07f34c489633fc7eb46acea7cd5c37",
7+
"asset_type": "0x1::aptos_coin::AptosCoin",
8+
"is_frozen": null,
9+
"amount": "57000",
10+
"type_": "0x1::aptos_coin::GasFeeEvent",
11+
"is_gas_fee": true,
12+
"gas_fee_payer_address": null,
13+
"is_transaction_success": true,
14+
"entry_function_id_str": "0xa746e980ae21949a4f084db7403430f00bce3c9a1da4101ffcf0bf45ebd35e7e::test::transfer_and_migrate",
15+
"block_height": 300296983,
16+
"token_standard": "v1",
17+
"transaction_timestamp": "2025-03-07T22:32:23",
18+
"storage_refund_amount": "0"
19+
},
20+
{
21+
"transaction_version": 2448304257,
22+
"event_index": 0,
23+
"owner_address": "0xf8e25f6c8ce40a15107fb4b4d288ca03dd434d057392f2ccb5fde505a300a0bf",
24+
"storage_id": "0xd5263bada2f6b752de987f5e8eca800ffb07f34c489633fc7eb46acea7cd5c37",
25+
"asset_type": "0x1::aptos_coin::AptosCoin",
26+
"is_frozen": null,
27+
"amount": "100000",
28+
"type_": "0x1::coin::WithdrawEvent",
29+
"is_gas_fee": false,
30+
"gas_fee_payer_address": null,
31+
"is_transaction_success": true,
32+
"entry_function_id_str": "0xa746e980ae21949a4f084db7403430f00bce3c9a1da4101ffcf0bf45ebd35e7e::test::transfer_and_migrate",
33+
"block_height": 300296983,
34+
"token_standard": "v1",
35+
"transaction_timestamp": "2025-03-07T22:32:23",
36+
"storage_refund_amount": "0"
37+
},
38+
{
39+
"transaction_version": 2448304257,
40+
"event_index": 1,
41+
"owner_address": "0x2dcbc03740a6fa2efee926b9df329184cce357d0573bdab09930f4d48e61a4c8",
42+
"storage_id": "0x35b5700571cbb1c340c5a2fa7e1ecc32fd8b4da273881c2728058bd4c2514895",
43+
"asset_type": "0x1::aptos_coin::AptosCoin",
44+
"is_frozen": null,
45+
"amount": "100000",
46+
"type_": "0x1::coin::DepositEvent",
47+
"is_gas_fee": false,
48+
"gas_fee_payer_address": null,
49+
"is_transaction_success": true,
50+
"entry_function_id_str": "0xa746e980ae21949a4f084db7403430f00bce3c9a1da4101ffcf0bf45ebd35e7e::test::transfer_and_migrate",
51+
"block_height": 300296983,
52+
"token_standard": "v1",
53+
"transaction_timestamp": "2025-03-07T22:32:23",
54+
"storage_refund_amount": "0"
55+
}
56+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[
2+
{
3+
"asset_type": "0x000000000000000000000000000000000000000000000000000000000000000a",
4+
"creator_address": "0x0000000000000000000000000000000000000000000000000000000000000001",
5+
"name": "Aptos Coin",
6+
"symbol": "APT",
7+
"decimals": 8,
8+
"icon_uri": "",
9+
"project_uri": "",
10+
"last_transaction_version": 2448304257,
11+
"last_transaction_timestamp": "2025-03-07T22:32:23",
12+
"supply_aggregator_table_handle_v1": null,
13+
"supply_aggregator_table_key_v1": null,
14+
"token_standard": "v2",
15+
"maximum_v2": "340282366920938463463374607431768211455",
16+
"is_token_v2": null,
17+
"supply_v2": "118281485271096"
18+
}
19+
]

rust/integration-tests/src/sdk_tests/events_processor_tests.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ mod tests {
5757
};
5858
use aptos_indexer_processor_sdk::traits::processor_trait::ProcessorTrait;
5959
use aptos_indexer_test_transactions::json_transactions::generated_transactions::{
60-
IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS,
6160
IMPORTED_DEVNET_TXNS_78753831_TOKEN_V1_MINT_TRANSFER_WITH_V2_EVENTS,
6261
IMPORTED_DEVNET_TXNS_78753832_TOKEN_V2_MINT_TRANSFER_WITH_V2_EVENTS,
6362
IMPORTED_MAINNET_TXNS_554229017_EVENTS_WITH_NO_EVENT_SIZE_INFO,
@@ -133,15 +132,6 @@ mod tests {
133132
.await;
134133
}
135134

136-
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
137-
async fn devnet_events_processor_coin_module_events() {
138-
process_single_devnet_event_txn(
139-
IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS,
140-
Some("coin_event_v2".to_string()),
141-
)
142-
.await;
143-
}
144-
145135
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
146136
async fn devnet_events_processor_token_v1_module_events() {
147137
process_single_devnet_event_txn(

rust/integration-tests/src/sdk_tests/fungible_asset_processor_tests.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ mod sdk_fungible_asset_processor_tests {
5757
},
5858
};
5959
use aptos_indexer_test_transactions::json_transactions::generated_transactions::{
60-
IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS,
6160
IMPORTED_MAINNET_TXNS_1680592683_FA_MIGRATION_COIN_INFO,
6261
IMPORTED_MAINNET_TXNS_1737056775_COIN_TRANSFER_BURN_EVENT,
6362
IMPORTED_MAINNET_TXNS_1957950162_FA_MIGRATION_V2_STORE_ONLY,
6463
IMPORTED_MAINNET_TXNS_2186504987_COIN_STORE_DELETION_NO_EVENT,
6564
IMPORTED_MAINNET_TXNS_2308282694_ASSET_TYPE_V1_NULL,
6665
IMPORTED_MAINNET_TXNS_2308283617_ASSET_TYPE_V1_NULL_2,
66+
IMPORTED_MAINNET_TXNS_2448304257_COINSTORE_DELETION_EVENT,
6767
IMPORTED_MAINNET_TXNS_255894550_STORAGE_REFUND,
6868
IMPORTED_MAINNET_TXNS_508365567_FA_V1_EVENTS,
6969
IMPORTED_MAINNET_TXNS_550582915_MULTIPLE_TRANSFER_EVENT,
@@ -178,17 +178,6 @@ mod sdk_fungible_asset_processor_tests {
178178
.await;
179179
}
180180

181-
/// Tests processing of coin v2 events
182-
/// Validates the handling of updated coin event formats
183-
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
184-
async fn test_fungible_asset_processor_coin_v2_events() {
185-
process_single_batch_txns(
186-
&[IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS],
187-
Some("coin_v2_events".to_string()),
188-
)
189-
.await;
190-
}
191-
192181
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
193182
async fn test_fungible_asset_processor_coin_store_deletion_no_event() {
194183
process_single_batch_txns(
@@ -292,6 +281,15 @@ mod sdk_fungible_asset_processor_tests {
292281
.await;
293282
}
294283

284+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
285+
async fn test_fungible_asset_processor_fa_migration_with_coin_store_deletion() {
286+
process_single_batch_txns(
287+
&[IMPORTED_MAINNET_TXNS_2448304257_COINSTORE_DELETION_EVENT],
288+
Some("migration_with_coin_store_deletion_event".to_string()),
289+
)
290+
.await;
291+
}
292+
295293
/// Tests processing of two transactions sequentially
296294
/// Validates handling of multiple transactions with shared context
297295
async fn sequential_multi_transaction_helper_function(

rust/processor/src/processors/fungible_asset_processor.rs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -710,31 +710,33 @@ pub async fn parse_v2_coin(
710710

711711
// The CoinStoreDeletionEvent, only need for v1 with migration
712712
if user_request.is_some() {
713-
let coin_store_deletion_event = events.iter().find_map(|event| {
714-
let event_type = event.type_str.as_str();
715-
CoinStoreDeletionEvent::from_event(event_type, &event.data, txn_version)
716-
});
717-
if let Some(coin_store_deletion) = coin_store_deletion_event {
718-
let addr = standardize_address(
719-
coin_store_deletion.event_handle_creation_address.as_str(),
720-
);
721-
let deposit_event_guid = EventGuidResource {
722-
addr: addr.clone(),
723-
creation_num: coin_store_deletion
724-
.deleted_deposit_event_handle_creation_number
725-
as i64,
726-
};
727-
let withdraw_event_guid = EventGuidResource {
728-
addr,
729-
creation_num: coin_store_deletion
730-
.deleted_withdraw_event_handle_creation_number
731-
as i64,
732-
};
733-
event_to_v1_coin_type
734-
.insert(deposit_event_guid, coin_store_deletion.coin_type.clone());
735-
event_to_v1_coin_type
736-
.insert(withdraw_event_guid, coin_store_deletion.coin_type);
737-
};
713+
events
714+
.iter()
715+
.filter_map(|event| {
716+
let event_type = event.type_str.as_str();
717+
CoinStoreDeletionEvent::from_event(event_type, &event.data, txn_version)
718+
})
719+
.for_each(|coin_store_deletion| {
720+
let addr = standardize_address(
721+
coin_store_deletion.event_handle_creation_address.as_str(),
722+
);
723+
let deposit_event_guid = EventGuidResource {
724+
addr: addr.clone(),
725+
creation_num: coin_store_deletion
726+
.deleted_deposit_event_handle_creation_number
727+
as i64,
728+
};
729+
let withdraw_event_guid = EventGuidResource {
730+
addr,
731+
creation_num: coin_store_deletion
732+
.deleted_withdraw_event_handle_creation_number
733+
as i64,
734+
};
735+
event_to_v1_coin_type
736+
.insert(deposit_event_guid, coin_store_deletion.coin_type.clone());
737+
event_to_v1_coin_type
738+
.insert(withdraw_event_guid, coin_store_deletion.coin_type);
739+
});
738740
}
739741

740742
// Loop 3 to handle events and collect additional metadata from events for v2

0 commit comments

Comments
 (0)