Skip to content

Commit

Permalink
[Framework] remove unnecessary lines creating resource acct signer (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmark authored Nov 29, 2022
1 parent 1a73fe0 commit cf6bb40
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
3 changes: 1 addition & 2 deletions aptos-move/framework/aptos-framework/doc/resource_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ the SignerCapability.
<a href="../../aptos-stdlib/doc/simple_map.md#0x1_simple_map_destroy_empty">simple_map::destroy_empty</a>(store);
};

<b>let</b> resource = <a href="account.md#0x1_account_create_signer_with_capability">account::create_signer_with_capability</a>(&resource_signer_cap);
<a href="account.md#0x1_account_rotate_authentication_key_internal">account::rotate_authentication_key_internal</a>(&resource, <a href="resource_account.md#0x1_resource_account_ZERO_AUTH_KEY">ZERO_AUTH_KEY</a>);
<a href="account.md#0x1_account_rotate_authentication_key_internal">account::rotate_authentication_key_internal</a>(resource, <a href="resource_account.md#0x1_resource_account_ZERO_AUTH_KEY">ZERO_AUTH_KEY</a>);
resource_signer_cap
}
</code></pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/// }
/// ```
///
Expand Down Expand Up @@ -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
}

Expand Down
9 changes: 4 additions & 5 deletions aptos-move/move-examples/mint_nft/sources/minting.move
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>[ 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""),
Expand All @@ -156,7 +155,7 @@ module mint_nft::minting {
token_data_id,
expiration_timestamp,
minting_enabled: true,
token_minting_events: account::new_event_handle<TokenMintingEvent>(&resource_signer),
token_minting_events: account::new_event_handle<TokenMintingEvent>(resource_account),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChloesCoin>(
&resource_signer,
account,
string::utf8(b"Chloe's Coin"),
string::utf8(b"CCOIN"),
8,
Expand Down

0 comments on commit cf6bb40

Please sign in to comment.