From 7089c7be63f5f7043a941356438c6213fa00b94b Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 18 Dec 2022 08:50:45 +0700 Subject: [PATCH] update --- .../framework/aptos-framework/doc/aptos_account.md | 2 +- .../aptos-framework/sources/aptos_account.move | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/aptos-move/framework/aptos-framework/doc/aptos_account.md b/aptos-move/framework/aptos-framework/doc/aptos_account.md index b814ca1c9515c..446b3f062dee5 100644 --- a/aptos-move/framework/aptos-framework/doc/aptos_account.md +++ b/aptos-move/framework/aptos-framework/doc/aptos_account.md @@ -416,7 +416,7 @@ Set whether account can receiv if (exists<DirectTransferConfig>(addr)) { let direct_transfer_config = borrow_global_mut<DirectTransferConfig>(addr); // Short-circuit to avoid emitting an event if direct transfer config is not changing. - if (direct_transfer_config.allow_arbitrary_coin_transfers != allow) { + if (direct_transfer_config.allow_arbitrary_coin_transfers == allow) { return }; diff --git a/aptos-move/framework/aptos-framework/sources/aptos_account.move b/aptos-move/framework/aptos-framework/sources/aptos_account.move index 079e8742c982e..ff6bc25a3e53f 100644 --- a/aptos-move/framework/aptos-framework/sources/aptos_account.move +++ b/aptos-move/framework/aptos-framework/sources/aptos_account.move @@ -124,7 +124,7 @@ module aptos_framework::aptos_account { if (exists(addr)) { let direct_transfer_config = borrow_global_mut(addr); // Short-circuit to avoid emitting an event if direct transfer config is not changing. - if (direct_transfer_config.allow_arbitrary_coin_transfers != allow) { + if (direct_transfer_config.allow_arbitrary_coin_transfers == allow) { return }; @@ -253,6 +253,18 @@ module aptos_framework::aptos_account { coin::destroy_freeze_cap(freeze_cap); } + #[test(user = @0x123)] + public fun test_set_allow_direct_coin_transfers(user: &signer) acquires DirectTransferConfig { + let addr = signer::address_of(user); + create_account_for_test(addr); + set_allow_direct_coin_transfers(user, true); + assert!(can_receive_direct_coin_transfers(addr), 0); + set_allow_direct_coin_transfers(user, false); + assert!(!can_receive_direct_coin_transfers(addr), 1); + set_allow_direct_coin_transfers(user, true); + assert!(can_receive_direct_coin_transfers(addr), 2); + } + #[test(from = @0x1, to = @0x12)] public fun test_direct_coin_transfers_with_explicit_direct_coin_transfer_config( from: &signer, to: &signer) acquires DirectTransferConfig {