From ff30778183732c8febcce19631ee3265c46eb00a Mon Sep 17 00:00:00 2001 From: Aaron Gao Date: Mon, 26 Aug 2024 23:40:27 -1000 Subject: [PATCH] [module events] update token events --- .../tests/aptos_test_harness/table.exp | 28 +- aptos-move/framework/aptos-token/doc/token.md | 357 +++++++++++++++++- .../aptos-token/doc/token_transfers.md | 217 +++++++++-- .../framework/aptos-token/sources/token.move | 85 ++++- .../aptos-token/sources/token_transfers.move | 43 ++- 5 files changed, 655 insertions(+), 75 deletions(-) diff --git a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/table.exp b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/table.exp index b0352e4c59288..295a2e527a323 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/table.exp +++ b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/table.exp @@ -21,8 +21,8 @@ return values: 0 task 2 'run'. lines 9-9: Events: { - type: 0x3::token::CreateTokenData - data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00640000000000000000f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6010000000000000000000000000000000a6765656b5f746f6b656e0000000000000000" + type: 0x3::token::TokenDataCreation + data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00640000000000000000f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6010000000000000000000000000000000a6765656b5f746f6b656e0000000000000000" } { key: 0500000000000000f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6 @@ -31,8 +31,8 @@ Events: data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00640000000000000000f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6010000000000000000000000000000000a6765656b5f746f6b656e0000000000000000" } { - type: 0x3::token::MintToken - data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e0a00000000000000" + type: 0x3::token::Mint + data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e0a00000000000000" } { key: 0600000000000000f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6 @@ -41,8 +41,8 @@ Events: data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e0a00000000000000" } { - type: 0x3::token::Deposit - data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000a00000000000000" + type: 0x3::token::TokenDeposit + data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000a00000000000000" } { key: 0700000000000000f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6 @@ -99,8 +99,8 @@ task 4 'view_table'. lines 13-15: task 5 'run'. lines 16-18: Events: { - type: 0x3::token::Withdraw - data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" + type: 0x3::token::TokenWithdraw + data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" } { key: 0800000000000000f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6 @@ -109,8 +109,8 @@ Events: data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" } { - type: 0x3::token_transfers::TokenOffer - data: "9c3b634ac05d0af393e0f93b9b19b61e7cac1c519f566276aa0c6fd15dac12aaf75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" + type: 0x3::token_transfers::Offer + data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb69c3b634ac05d0af393e0f93b9b19b61e7cac1c519f566276aa0c6fd15dac12aaf75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" } { key: 0b00000000000000f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6 @@ -127,8 +127,8 @@ return values: 0 task 6 'run'. lines 19-19: Events: { - type: 0x3::token::Deposit - data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" + type: 0x3::token::TokenDeposit + data: "9c3b634ac05d0af393e0f93b9b19b61e7cac1c519f566276aa0c6fd15dac12aaf75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" } { key: 04000000000000009c3b634ac05d0af393e0f93b9b19b61e7cac1c519f566276aa0c6fd15dac12aa @@ -137,8 +137,8 @@ Events: data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" } { - type: 0x3::token_transfers::TokenClaim - data: "9c3b634ac05d0af393e0f93b9b19b61e7cac1c519f566276aa0c6fd15dac12aaf75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" + type: 0x3::token_transfers::Claim + data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb69c3b634ac05d0af393e0f93b9b19b61e7cac1c519f566276aa0c6fd15dac12aaf75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" } { key: 0d00000000000000f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6 diff --git a/aptos-move/framework/aptos-token/doc/token.md b/aptos-move/framework/aptos-token/doc/token.md index af496bd937b73..dfb5a41511752 100644 --- a/aptos-move/framework/aptos-token/doc/token.md +++ b/aptos-move/framework/aptos-token/doc/token.md @@ -19,17 +19,23 @@ Checkout our developer doc on our token standard https://aptos.dev/standards - [Struct `CollectionData`](#0x3_token_CollectionData) - [Struct `WithdrawCapability`](#0x3_token_WithdrawCapability) - [Struct `DepositEvent`](#0x3_token_DepositEvent) +- [Struct `TokenDeposit`](#0x3_token_TokenDeposit) - [Struct `Deposit`](#0x3_token_Deposit) - [Struct `WithdrawEvent`](#0x3_token_WithdrawEvent) - [Struct `Withdraw`](#0x3_token_Withdraw) +- [Struct `TokenWithdraw`](#0x3_token_TokenWithdraw) - [Struct `CreateTokenDataEvent`](#0x3_token_CreateTokenDataEvent) - [Struct `CreateTokenData`](#0x3_token_CreateTokenData) +- [Struct `TokenDataCreation`](#0x3_token_TokenDataCreation) - [Struct `MintTokenEvent`](#0x3_token_MintTokenEvent) - [Struct `MintToken`](#0x3_token_MintToken) +- [Struct `Mint`](#0x3_token_Mint) - [Struct `BurnTokenEvent`](#0x3_token_BurnTokenEvent) - [Struct `BurnToken`](#0x3_token_BurnToken) +- [Struct `Burn`](#0x3_token_Burn) - [Struct `MutateTokenPropertyMapEvent`](#0x3_token_MutateTokenPropertyMapEvent) - [Struct `MutateTokenPropertyMap`](#0x3_token_MutateTokenPropertyMap) +- [Struct `MutatePropertyMap`](#0x3_token_MutatePropertyMap) - [Struct `CreateCollectionEvent`](#0x3_token_CreateCollectionEvent) - [Struct `CreateCollection`](#0x3_token_CreateCollection) - [Constants](#@Constants_0) @@ -768,6 +774,47 @@ Set of data sent to the event stream during a receive + + + + +## Struct `TokenDeposit` + +Set of data sent to the event stream during a receive + + +
#[event]
+struct TokenDeposit has drop, store
+
+ + + +
+Fields + + +
+
+account: address +
+
+ +
+
+id: token::TokenId +
+
+ +
+
+amount: u64 +
+
+ +
+
+ +
@@ -778,6 +825,7 @@ Set of data sent to the event stream during a receive
#[event]
+#[deprecated]
 struct Deposit has drop, store
 
@@ -847,6 +895,7 @@ Set of data sent to the event stream during a withdrawal
#[event]
+#[deprecated]
 struct Withdraw has drop, store
 
@@ -872,6 +921,47 @@ Set of data sent to the event stream during a withdrawal + + + + +## Struct `TokenWithdraw` + +Set of data sent to the event stream during a withdrawal + + +
#[event]
+struct TokenWithdraw has drop, store
+
+ + + +
+Fields + + +
+
+account: address +
+
+ +
+
+id: token::TokenId +
+
+ +
+
+amount: u64 +
+
+ +
+
+ +
@@ -975,6 +1065,7 @@ token creation event id of token created
#[event]
+#[deprecated]
 struct CreateTokenData has drop, store
 
@@ -1060,6 +1151,106 @@ token creation event id of token created + + + + +## Struct `TokenDataCreation` + + + +
#[event]
+struct TokenDataCreation has drop, store
+
+ + + +
+Fields + + +
+
+creator: address +
+
+ +
+
+id: token::TokenDataId +
+
+ +
+
+description: string::String +
+
+ +
+
+maximum: u64 +
+
+ +
+
+uri: string::String +
+
+ +
+
+royalty_payee_address: address +
+
+ +
+
+royalty_points_denominator: u64 +
+
+ +
+
+royalty_points_numerator: u64 +
+
+ +
+
+name: string::String +
+
+ +
+
+mutability_config: token::TokenMutabilityConfig +
+
+ +
+
+property_keys: vector<string::String> +
+
+ +
+
+property_values: vector<vector<u8>> +
+
+ +
+
+property_types: vector<string::String> +
+
+ +
+
+ +
@@ -1103,6 +1294,7 @@ mint token event. This event triggered when creator adds more supply to existing
#[event]
+#[deprecated]
 struct MintToken has drop, store
 
@@ -1128,6 +1320,46 @@ mint token event. This event triggered when creator adds more supply to existing + + + + +## Struct `Mint` + + + +
#[event]
+struct Mint has drop, store
+
+ + + +
+Fields + + +
+
+creator: address +
+
+ +
+
+id: token::TokenDataId +
+
+ +
+
+amount: u64 +
+
+ +
+
+ +
@@ -1170,6 +1402,7 @@ mint token event. This event triggered when creator adds more supply to existing
#[event]
+#[deprecated]
 struct BurnToken has drop, store
 
@@ -1195,6 +1428,46 @@ mint token event. This event triggered when creator adds more supply to existing + + + + +## Struct `Burn` + + + +
#[event]
+struct Burn has drop, store
+
+ + + +
+Fields + + +
+
+account: address +
+
+ +
+
+id: token::TokenId +
+
+ +
+
+amount: u64 +
+
+ +
+
+ +
@@ -1255,6 +1528,7 @@ mint token event. This event triggered when creator adds more supply to existing
#[event]
+#[deprecated]
 struct MutateTokenPropertyMap has drop, store
 
@@ -1298,6 +1572,64 @@ mint token event. This event triggered when creator adds more supply to existing + + + + +## Struct `MutatePropertyMap` + + + +
#[event]
+struct MutatePropertyMap has drop, store
+
+ + + +
+Fields + + +
+
+account: address +
+
+ +
+
+old_id: token::TokenId +
+
+ +
+
+new_id: token::TokenId +
+
+ +
+
+keys: vector<string::String> +
+
+ +
+
+values: vector<vector<u8>> +
+
+ +
+
+types: vector<string::String> +
+
+ +
+
+ +
@@ -2247,11 +2579,11 @@ The token is owned at address owner let burn_by_creator_flag = property_map::read_bool(&token_data.default_properties, &string::utf8(BURNABLE_BY_CREATOR)); assert!(burn_by_creator_flag, error::permission_denied(ECREATOR_CANNOT_BURN_TOKEN)); - // Burn the tokens. + // Burn the tokens. let Token { id: _, amount: burned_amount, token_properties: _ } = withdraw_with_event_internal(owner, token_id, amount); let token_store = borrow_global_mut<TokenStore>(owner); if (std::features::module_event_migration_enabled()) { - event::emit(BurnToken { id: token_id, amount: burned_amount }); + event::emit(Burn { account: owner, id: token_id, amount: burned_amount }); }; event::emit_event<BurnTokenEvent>( &mut token_store.burn_events, @@ -2336,11 +2668,11 @@ Burn a token by the token owner let burn_by_owner_flag = property_map::read_bool(&token_data.default_properties, &string::utf8(BURNABLE_BY_OWNER)); assert!(burn_by_owner_flag, error::permission_denied(EOWNER_CANNOT_BURN_TOKEN)); - // Burn the tokens. + // Burn the tokens. let Token { id: _, amount: burned_amount, token_properties: _ } = withdraw_token(owner, token_id, amount); let token_store = borrow_global_mut<TokenStore>(signer::address_of(owner)); if (std::features::module_event_migration_enabled()) { - event::emit(BurnToken { id: token_id, amount: burned_amount }); + event::emit(Burn { account: signer::address_of(owner), id: token_id, amount: burned_amount }); }; event::emit_event<BurnTokenEvent>( &mut token_store.burn_events, @@ -2737,7 +3069,8 @@ Mutate the token_properties of one token. direct_deposit(token_owner, new_token); update_token_property_internal(token_owner, new_token_id, keys, values, types); if (std::features::module_event_migration_enabled()) { - event::emit(MutateTokenPropertyMap { + event::emit(MutatePropertyMap { + account: token_owner, old_id: token_id, new_id: new_token_id, keys, @@ -2764,7 +3097,8 @@ Mutate the token_properties of one token. // only 1 copy for the token with property verion bigger than 0 update_token_property_internal(token_owner, token_id, keys, values, types); if (std::features::module_event_migration_enabled()) { - event::emit(MutateTokenPropertyMap { + event::emit(MutatePropertyMap { + account: token_owner, old_id: token_id, new_id: token_id, keys, @@ -3436,7 +3770,8 @@ Create a new collection to hold tokens table::add(&mut collections.token_data, token_data_id, token_data); if (std::features::module_event_migration_enabled()) { event::emit( - CreateTokenData { + TokenDataCreation { + creator: account_addr, id: token_data_id, description, maximum, @@ -3795,7 +4130,7 @@ return the TokenId for a given Token // we add more tokens with property_version 0 let token_id = create_token_id(token_data_id, 0); if (std::features::module_event_migration_enabled()) { - event::emit(MintToken { id: token_data_id, amount }) + event::emit(Mint { creator: creator_addr, id: token_data_id, amount }) }; event::emit_event<MintTokenEvent>( &mut borrow_global_mut<Collections>(creator_addr).mint_token_events, @@ -3862,7 +4197,7 @@ create tokens and directly deposite to receiver's address. The receiver should o let token_id = create_token_id(token_data_id, 0); if (std::features::module_event_migration_enabled()) { - event::emit(MintToken { id: token_data_id, amount }) + event::emit(Mint { creator: creator_addr, id: token_data_id, amount }) }; event::emit_event<MintTokenEvent>( &mut borrow_global_mut<Collections>(creator_addr).mint_token_events, @@ -4750,7 +5085,7 @@ return if the collection maximum is mutable with collection mutability config let token_store = borrow_global_mut<TokenStore>(account_addr); if (std::features::module_event_migration_enabled()) { - event::emit(Withdraw { id, amount }) + event::emit(TokenWithdraw { account: account_addr, id, amount }) }; event::emit_event<WithdrawEvent>( &mut token_store.withdraw_events, @@ -4832,7 +5167,7 @@ Deposit the token balance into the recipients account and emit an event. let token_store = borrow_global_mut<TokenStore>(account_addr); if (std::features::module_event_migration_enabled()) { - event::emit(Deposit { id: token.id, amount: token.amount }); + event::emit(TokenDeposit { account: account_addr, id: token.id, amount: token.amount }); }; event::emit_event<DepositEvent>( &mut token_store.deposit_events, diff --git a/aptos-move/framework/aptos-token/doc/token_transfers.md b/aptos-move/framework/aptos-token/doc/token_transfers.md index 960c9e0ce2094..86946fbc5580e 100644 --- a/aptos-move/framework/aptos-token/doc/token_transfers.md +++ b/aptos-move/framework/aptos-token/doc/token_transfers.md @@ -9,10 +9,13 @@ This module provides the foundation for transferring of Tokens - [Resource `PendingClaims`](#0x3_token_transfers_PendingClaims) - [Struct `TokenOfferId`](#0x3_token_transfers_TokenOfferId) - [Struct `TokenOffer`](#0x3_token_transfers_TokenOffer) -- [Struct `TokenOfferEvent`](#0x3_token_transfers_TokenOfferEvent) +- [Struct `Offer`](#0x3_token_transfers_Offer) - [Struct `TokenCancelOfferEvent`](#0x3_token_transfers_TokenCancelOfferEvent) -- [Struct `TokenCancelOffer`](#0x3_token_transfers_TokenCancelOffer) +- [Struct `CancelOffer`](#0x3_token_transfers_CancelOffer) - [Struct `TokenClaimEvent`](#0x3_token_transfers_TokenClaimEvent) +- [Struct `Claim`](#0x3_token_transfers_Claim) +- [Struct `TokenOfferEvent`](#0x3_token_transfers_TokenOfferEvent) +- [Struct `TokenCancelOffer`](#0x3_token_transfers_TokenCancelOffer) - [Struct `TokenClaim`](#0x3_token_transfers_TokenClaim) - [Constants](#@Constants_0) - [Function `initialize_token_transfers`](#0x3_token_transfers_initialize_token_transfers) @@ -165,14 +168,14 @@ This module provides the foundation for transferring of Tokens - + -## Struct `TokenOfferEvent` +## Struct `Offer`
#[event]
-struct TokenOfferEvent has drop, store
+struct Offer has drop, store
 
@@ -183,6 +186,12 @@ This module provides the foundation for transferring of Tokens
+account: address +
+
+ +
+
to_address: address
@@ -245,14 +254,14 @@ This module provides the foundation for transferring of Tokens - + -## Struct `TokenCancelOffer` +## Struct `CancelOffer`
#[event]
-struct TokenCancelOffer has drop, store
+struct CancelOffer has drop, store
 
@@ -263,6 +272,12 @@ This module provides the foundation for transferring of Tokens
+account: address +
+
+ +
+
to_address: address
@@ -297,6 +312,134 @@ This module provides the foundation for transferring of Tokens +
+Fields + + +
+
+to_address: address +
+
+ +
+
+token_id: token::TokenId +
+
+ +
+
+amount: u64 +
+
+ +
+
+ + +
+ + + +## Struct `Claim` + + + +
#[event]
+struct Claim has drop, store
+
+ + + +
+Fields + + +
+
+account: address +
+
+ +
+
+to_address: address +
+
+ +
+
+token_id: token::TokenId +
+
+ +
+
+amount: u64 +
+
+ +
+
+ + +
+ + + +## Struct `TokenOfferEvent` + + + +
#[event]
+#[deprecated]
+struct TokenOfferEvent has drop, store
+
+ + + +
+Fields + + +
+
+to_address: address +
+
+ +
+
+token_id: token::TokenId +
+
+ +
+
+amount: u64 +
+
+ +
+
+ + +
+ + + +## Struct `TokenCancelOffer` + + + +
#[event]
+#[deprecated]
+struct TokenCancelOffer has drop, store
+
+ + +
Fields @@ -332,6 +475,7 @@ This module provides the foundation for transferring of Tokens
#[event]
+#[deprecated]
 struct TokenClaim has drop, store
 
@@ -511,7 +655,8 @@ Token offer doesn't exist if (std::features::module_event_migration_enabled()) { event::emit( - TokenOffer { + Offer { + account: sender_addr, to_address: receiver, token_id, amount, @@ -596,7 +741,8 @@ Token offer doesn't exist if (std::features::module_event_migration_enabled()) { event::emit( - TokenClaim { + Claim { + account: sender, to_address: signer::address_of(receiver), token_id, amount, @@ -681,7 +827,8 @@ Token offer doesn't exist if (std::features::module_event_migration_enabled()) { event::emit( - TokenCancelOffer { + CancelOffer { + account: sender_addr, to_address: receiver, token_id, amount, @@ -714,6 +861,30 @@ Token offer doesn't exist +Get the amount from sender token + + + + + +
fun spce_get(
+   account_addr: address,
+   id: TokenId,
+   amount: u64
+): u64 {
+   use aptos_token::token::{TokenStore};
+   use aptos_std::table::{Self};
+   let tokens = global<TokenStore>(account_addr).tokens;
+   let balance = table::spec_get(tokens, id).amount;
+   if (balance > amount) {
+       amount
+   } else {
+       table::spec_get(tokens, id).amount
+   }
+}
+
+ + @@ -810,30 +981,6 @@ Abort according to the code -Get the amount from sender token - - - - - -
fun spce_get(
-   account_addr: address,
-   id: TokenId,
-   amount: u64
-): u64 {
-   use aptos_token::token::{TokenStore};
-   use aptos_std::table::{Self};
-   let tokens = global<TokenStore>(account_addr).tokens;
-   let balance = table::spec_get(tokens, id).amount;
-   if (balance > amount) {
-       amount
-   } else {
-       table::spec_get(tokens, id).amount
-   }
-}
-
- - diff --git a/aptos-move/framework/aptos-token/sources/token.move b/aptos-move/framework/aptos-token/sources/token.move index d11f69a379351..fca6c7730bee0 100644 --- a/aptos-move/framework/aptos-token/sources/token.move +++ b/aptos-move/framework/aptos-token/sources/token.move @@ -289,6 +289,15 @@ module aptos_token::token { amount: u64, } + #[event] + /// Set of data sent to the event stream during a receive + struct TokenDeposit has drop, store { + account: address, + id: TokenId, + amount: u64, + } + + #[deprecated] #[event] /// Set of data sent to the event stream during a receive struct Deposit has drop, store { @@ -302,6 +311,7 @@ module aptos_token::token { amount: u64, } + #[deprecated] #[event] /// Set of data sent to the event stream during a withdrawal struct Withdraw has drop, store { @@ -309,6 +319,14 @@ module aptos_token::token { amount: u64, } + #[event] + /// Set of data sent to the event stream during a withdrawal + struct TokenWithdraw has drop, store { + account: address, + id: TokenId, + amount: u64, + } + /// token creation event id of token created struct CreateTokenDataEvent has drop, store { id: TokenDataId, @@ -325,6 +343,7 @@ module aptos_token::token { property_types: vector, } + #[deprecated] #[event] struct CreateTokenData has drop, store { id: TokenDataId, @@ -341,30 +360,64 @@ module aptos_token::token { property_types: vector, } + #[event] + struct TokenDataCreation has drop, store { + creator: address, + id: TokenDataId, + description: String, + maximum: u64, + uri: String, + royalty_payee_address: address, + royalty_points_denominator: u64, + royalty_points_numerator: u64, + name: String, + mutability_config: TokenMutabilityConfig, + property_keys: vector, + property_values: vector>, + property_types: vector, + } + /// mint token event. This event triggered when creator adds more supply to existing token struct MintTokenEvent has drop, store { id: TokenDataId, amount: u64, } + #[deprecated] #[event] struct MintToken has drop, store { id: TokenDataId, amount: u64, } + #[event] + struct Mint has drop, store { + creator: address, + id: TokenDataId, + amount: u64, + } + /// struct BurnTokenEvent has drop, store { id: TokenId, amount: u64, } + #[deprecated] #[event] struct BurnToken has drop, store { id: TokenId, amount: u64, } + #[event] + struct Burn has drop, store { + account: address, + id: TokenId, + amount: u64, + } + + /// struct MutateTokenPropertyMapEvent has drop, store { old_id: TokenId, @@ -374,6 +427,7 @@ module aptos_token::token { types: vector, } + #[deprecated] #[event] struct MutateTokenPropertyMap has drop, store { old_id: TokenId, @@ -383,6 +437,16 @@ module aptos_token::token { types: vector, } + #[event] + struct MutatePropertyMap has drop, store { + account: address, + old_id: TokenId, + new_id: TokenId, + keys: vector, + values: vector>, + types: vector, + } + /// create collection event with creator address and collection name struct CreateCollectionEvent has drop, store { creator: address, @@ -600,7 +664,7 @@ module aptos_token::token { let Token { id: _, amount: burned_amount, token_properties: _ } = withdraw_with_event_internal(owner, token_id, amount); let token_store = borrow_global_mut(owner); if (std::features::module_event_migration_enabled()) { - event::emit(BurnToken { id: token_id, amount: burned_amount }); + event::emit(Burn { account: owner, id: token_id, amount: burned_amount }); }; event::emit_event( &mut token_store.burn_events, @@ -669,7 +733,7 @@ module aptos_token::token { let Token { id: _, amount: burned_amount, token_properties: _ } = withdraw_token(owner, token_id, amount); let token_store = borrow_global_mut(signer::address_of(owner)); if (std::features::module_event_migration_enabled()) { - event::emit(BurnToken { id: token_id, amount: burned_amount }); + event::emit(Burn { account: signer::address_of(owner), id: token_id, amount: burned_amount }); }; event::emit_event( &mut token_store.burn_events, @@ -892,7 +956,8 @@ module aptos_token::token { direct_deposit(token_owner, new_token); update_token_property_internal(token_owner, new_token_id, keys, values, types); if (std::features::module_event_migration_enabled()) { - event::emit(MutateTokenPropertyMap { + event::emit(MutatePropertyMap { + account: token_owner, old_id: token_id, new_id: new_token_id, keys, @@ -919,7 +984,8 @@ module aptos_token::token { // only 1 copy for the token with property verion bigger than 0 update_token_property_internal(token_owner, token_id, keys, values, types); if (std::features::module_event_migration_enabled()) { - event::emit(MutateTokenPropertyMap { + event::emit(MutatePropertyMap { + account: token_owner, old_id: token_id, new_id: token_id, keys, @@ -1252,7 +1318,8 @@ module aptos_token::token { table::add(&mut collections.token_data, token_data_id, token_data); if (std::features::module_event_migration_enabled()) { event::emit( - CreateTokenData { + TokenDataCreation { + creator: account_addr, id: token_data_id, description, maximum, @@ -1391,7 +1458,7 @@ module aptos_token::token { // we add more tokens with property_version 0 let token_id = create_token_id(token_data_id, 0); if (std::features::module_event_migration_enabled()) { - event::emit(MintToken { id: token_data_id, amount }) + event::emit(Mint { creator: creator_addr, id: token_data_id, amount }) }; event::emit_event( &mut borrow_global_mut(creator_addr).mint_token_events, @@ -1438,7 +1505,7 @@ module aptos_token::token { let token_id = create_token_id(token_data_id, 0); if (std::features::module_event_migration_enabled()) { - event::emit(MintToken { id: token_data_id, amount }) + event::emit(Mint { creator: creator_addr, id: token_data_id, amount }) }; event::emit_event( &mut borrow_global_mut(creator_addr).mint_token_events, @@ -1708,7 +1775,7 @@ module aptos_token::token { let token_store = borrow_global_mut(account_addr); if (std::features::module_event_migration_enabled()) { - event::emit(Withdraw { id, amount }) + event::emit(TokenWithdraw { account: account_addr, id, amount }) }; event::emit_event( &mut token_store.withdraw_events, @@ -1750,7 +1817,7 @@ module aptos_token::token { let token_store = borrow_global_mut(account_addr); if (std::features::module_event_migration_enabled()) { - event::emit(Deposit { id: token.id, amount: token.amount }); + event::emit(TokenDeposit { account: account_addr, id: token.id, amount: token.amount }); }; event::emit_event( &mut token_store.deposit_events, diff --git a/aptos-move/framework/aptos-token/sources/token_transfers.move b/aptos-move/framework/aptos-token/sources/token_transfers.move index 6a8ec33b5ae2b..3f654bf2d85bb 100644 --- a/aptos-move/framework/aptos-token/sources/token_transfers.move +++ b/aptos-move/framework/aptos-token/sources/token_transfers.move @@ -36,7 +36,8 @@ module aptos_token::token_transfers { } #[event] - struct TokenOfferEvent has drop, store { + struct Offer has drop, store { + account: address, to_address: address, token_id: TokenId, amount: u64, @@ -50,7 +51,8 @@ module aptos_token::token_transfers { } #[event] - struct TokenCancelOffer has drop, store { + struct CancelOffer has drop, store { + account: address, to_address: address, token_id: TokenId, amount: u64, @@ -64,7 +66,8 @@ module aptos_token::token_transfers { } #[event] - struct TokenClaim has drop, store { + struct Claim has drop, store { + account: address, to_address: address, token_id: TokenId, amount: u64, @@ -126,7 +129,8 @@ module aptos_token::token_transfers { if (std::features::module_event_migration_enabled()) { event::emit( - TokenOffer { + Offer { + account: sender_addr, to_address: receiver, token_id, amount, @@ -171,7 +175,8 @@ module aptos_token::token_transfers { if (std::features::module_event_migration_enabled()) { event::emit( - TokenClaim { + Claim { + account: sender, to_address: signer::address_of(receiver), token_id, amount, @@ -217,7 +222,8 @@ module aptos_token::token_transfers { if (std::features::module_event_migration_enabled()) { event::emit( - TokenCancelOffer { + CancelOffer { + account: sender_addr, to_address: receiver, token_id, amount, @@ -324,4 +330,29 @@ module aptos_token::token_transfers { 0 ) } + + #[deprecated] + #[event] + struct TokenOfferEvent has drop, store { + to_address: address, + token_id: TokenId, + amount: u64, + } + + #[deprecated] + #[event] + struct TokenCancelOffer has drop, store { + to_address: address, + token_id: TokenId, + amount: u64, + } + + #[deprecated] + #[event] + struct TokenClaim has drop, store { + to_address: address, + token_id: TokenId, + amount: u64, + } + }