From cf6bb407d6dc0b09b447562a121f999615c8c767 Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 29 Nov 2022 21:37:48 +0800 Subject: [PATCH] [Framework] remove unnecessary lines creating resource acct signer (#5486) --- .../framework/aptos-framework/doc/resource_account.md | 3 +-- .../aptos-framework/sources/resource_account.move | 10 ++++------ aptos-move/move-examples/mint_nft/sources/minting.move | 9 ++++----- .../resource_account/sources/simple_defi.move | 3 +-- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/aptos-move/framework/aptos-framework/doc/resource_account.md b/aptos-move/framework/aptos-framework/doc/resource_account.md index 683f0334a59f1..0d46e14031f24 100644 --- a/aptos-move/framework/aptos-framework/doc/resource_account.md +++ b/aptos-move/framework/aptos-framework/doc/resource_account.md @@ -356,8 +356,7 @@ the SignerCapability. simple_map::destroy_empty(store); }; - let resource = account::create_signer_with_capability(&resource_signer_cap); - account::rotate_authentication_key_internal(&resource, ZERO_AUTH_KEY); + account::rotate_authentication_key_internal(resource, ZERO_AUTH_KEY); resource_signer_cap } diff --git a/aptos-move/framework/aptos-framework/sources/resource_account.move b/aptos-move/framework/aptos-framework/sources/resource_account.move index e1a7183afd6f4..c8f33ffdc47f2 100644 --- a/aptos-move/framework/aptos-framework/sources/resource_account.move +++ b/aptos-move/framework/aptos-framework/sources/resource_account.move @@ -18,12 +18,11 @@ /// /// Code snippets to help: /// ``` -/// fun init_module(source: &signer) { +/// fun init_module(resource: &signer) { /// let dev_address = @DEV_ADDR; -/// let signer_cap = retrieve_resource_account_cap(&source, dev_address); -/// let lp_signer = create_signer_with_capability(&signer_cap); +/// let signer_cap = retrieve_resource_account_cap(resource, dev_address); /// let lp = LiquidityPoolInfo { signer_cap: signer_cap, ... }; -/// move_to(&lp_signer, lp); +/// move_to(resource, lp); /// } /// ``` /// @@ -182,8 +181,7 @@ module aptos_framework::resource_account { simple_map::destroy_empty(store); }; - let resource = account::create_signer_with_capability(&resource_signer_cap); - account::rotate_authentication_key_internal(&resource, ZERO_AUTH_KEY); + account::rotate_authentication_key_internal(resource, ZERO_AUTH_KEY); resource_signer_cap } diff --git a/aptos-move/move-examples/mint_nft/sources/minting.move b/aptos-move/move-examples/mint_nft/sources/minting.move index 4d6b4af3b64de..afdf00d30b2f6 100644 --- a/aptos-move/move-examples/mint_nft/sources/minting.move +++ b/aptos-move/move-examples/mint_nft/sources/minting.move @@ -120,17 +120,16 @@ module mint_nft::minting { // change source_addr to the actual account that created the resource account let resource_signer_cap = resource_account::retrieve_resource_account_cap(resource_account, @source_addr); - let resource_signer = account::create_signer_with_capability(&resource_signer_cap); // create the nft collection let maximum_supply = 0; let mutate_setting = vector[ false, false, false ]; - let resource_account_address = signer::address_of(&resource_signer); - token::create_collection(&resource_signer, collection_name, description, collection_uri, maximum_supply, mutate_setting); + let resource_account_address = signer::address_of(resource_account); + token::create_collection(resource_account, collection_name, description, collection_uri, maximum_supply, mutate_setting); // create a token data id to specify which token will be minted let token_data_id = token::create_tokendata( - &resource_signer, + resource_account, collection_name, token_name, string::utf8(b""), @@ -156,7 +155,7 @@ module mint_nft::minting { token_data_id, expiration_timestamp, minting_enabled: true, - token_minting_events: account::new_event_handle(&resource_signer), + token_minting_events: account::new_event_handle(resource_account), }); } diff --git a/aptos-move/move-examples/resource_account/sources/simple_defi.move b/aptos-move/move-examples/resource_account/sources/simple_defi.move index ac0ec936fbf63..1c96db3cb68a8 100644 --- a/aptos-move/move-examples/resource_account/sources/simple_defi.move +++ b/aptos-move/move-examples/resource_account/sources/simple_defi.move @@ -37,9 +37,8 @@ module resource_account::simple_defi { fun init_module(account: &signer) { // store the capabilities within `ModuleData` let resource_signer_cap = resource_account::retrieve_resource_account_cap(account, @source_addr); - let resource_signer = account::create_signer_with_capability(&resource_signer_cap); let (burn_cap, freeze_cap, mint_cap) = coin::initialize( - &resource_signer, + account, string::utf8(b"Chloe's Coin"), string::utf8(b"CCOIN"), 8,