diff --git a/aptos-move/framework/aptos-framework/doc/coin.md b/aptos-move/framework/aptos-framework/doc/coin.md index 98f56f007e8b3d..0b5b91cec523cd 100644 --- a/aptos-move/framework/aptos-framework/doc/coin.md +++ b/aptos-move/framework/aptos-framework/doc/coin.md @@ -2054,13 +2054,21 @@ or disallow upgradability of total supply. deleted_withdraw_event_handle_creation_number: guid::creation_num(event::guid(&withdraw_events)) } ); - event::destroy_handle(deposit_events); - event::destroy_handle(withdraw_events); if (coin.value == 0) { destroy_zero(coin); } else { - fungible_asset::deposit(store, coin_to_fungible_asset(coin)); + if (std::features::module_event_migration_enabled()) { + event::emit(CoinWithdraw { coin_type: type_name<CoinType>(), account, amount: coin.value }); + } else { + event::emit_event<WithdrawEvent>( + &mut withdraw_events, + WithdrawEvent { amount: coin.value }, + ); + }; + fungible_asset::deposit_internal(object_address(&store), coin_to_fungible_asset(coin)); }; + event::destroy_handle(deposit_events); + event::destroy_handle(withdraw_events); // Note: // It is possible the primary fungible store may already exist before this function call. // In this case, if the account owns a frozen CoinStore and an unfrozen primary fungible store, this diff --git a/aptos-move/framework/aptos-framework/sources/coin.move b/aptos-move/framework/aptos-framework/sources/coin.move index 2ea6aca5762ec0..3887fe31c8f768 100644 --- a/aptos-move/framework/aptos-framework/sources/coin.move +++ b/aptos-move/framework/aptos-framework/sources/coin.move @@ -581,13 +581,21 @@ module aptos_framework::coin { deleted_withdraw_event_handle_creation_number: guid::creation_num(event::guid(&withdraw_events)) } ); - event::destroy_handle(deposit_events); - event::destroy_handle(withdraw_events); if (coin.value == 0) { destroy_zero(coin); } else { - fungible_asset::deposit(store, coin_to_fungible_asset(coin)); + if (std::features::module_event_migration_enabled()) { + event::emit(CoinWithdraw { coin_type: type_name(), account, amount: coin.value }); + } else { + event::emit_event( + &mut withdraw_events, + WithdrawEvent { amount: coin.value }, + ); + }; + fungible_asset::deposit_internal(object_address(&store), coin_to_fungible_asset(coin)); }; + event::destroy_handle(deposit_events); + event::destroy_handle(withdraw_events); // Note: // It is possible the primary fungible store may already exist before this function call. // In this case, if the account owns a frozen CoinStore and an unfrozen primary fungible store, this