Skip to content

Commit 439aee7

Browse files
committed
[Framework] remove unnecessary lines creating resource acct signer
1 parent d5e4887 commit 439aee7

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

aptos-move/framework/aptos-framework/doc/resource_account.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,7 @@ the SignerCapability.
356356
<a href="../../aptos-stdlib/doc/simple_map.md#0x1_simple_map_destroy_empty">simple_map::destroy_empty</a>(store);
357357
};
358358

359-
<b>let</b> resource = <a href="account.md#0x1_account_create_signer_with_capability">account::create_signer_with_capability</a>(&resource_signer_cap);
360-
<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>);
359+
<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>);
361360
resource_signer_cap
362361
}
363362
</code></pre>

aptos-move/framework/aptos-framework/sources/resource_account.move

+4-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
///
1919
/// Code snippets to help:
2020
/// ```
21-
/// fun init_module(source: &signer) {
21+
/// fun init_module(resource: &signer) {
2222
/// let dev_address = @DEV_ADDR;
23-
/// let signer_cap = retrieve_resource_account_cap(&source, dev_address);
24-
/// let lp_signer = create_signer_with_capability(&signer_cap);
23+
/// let signer_cap = retrieve_resource_account_cap(resource, dev_address);
2524
/// let lp = LiquidityPoolInfo { signer_cap: signer_cap, ... };
26-
/// move_to(&lp_signer, lp);
25+
/// move_to(resource, lp);
2726
/// }
2827
/// ```
2928
///
@@ -182,8 +181,7 @@ module aptos_framework::resource_account {
182181
simple_map::destroy_empty(store);
183182
};
184183

185-
let resource = account::create_signer_with_capability(&resource_signer_cap);
186-
account::rotate_authentication_key_internal(&resource, ZERO_AUTH_KEY);
184+
account::rotate_authentication_key_internal(resource, ZERO_AUTH_KEY);
187185
resource_signer_cap
188186
}
189187

aptos-move/framework/aptos-token/doc/token.md

+2
Original file line numberDiff line numberDiff line change
@@ -2212,6 +2212,8 @@ Burn a token by the token owner
22122212
<a href="token.md#0x3_token_assert_tokendata_exists">assert_tokendata_exists</a>(creator, token_data_id);
22132213
<b>let</b> all_token_data = &<b>mut</b> <b>borrow_global_mut</b>&lt;<a href="token.md#0x3_token_Collections">Collections</a>&gt;(token_data_id.creator).token_data;
22142214
<b>let</b> token_data = <a href="../../aptos-framework/../aptos-stdlib/doc/table.md#0x1_table_borrow_mut">table::borrow_mut</a>(all_token_data, token_data_id);
2215+
// cannot change maximum from 0 and cannot change maximum <b>to</b> 0
2216+
<b>assert</b>!(token_data.maximum != 0 && maximum != 0, <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="token.md#0x3_token_EINVALID_MAXIMUM">EINVALID_MAXIMUM</a>));
22152217
<b>assert</b>!(maximum &gt;= token_data.supply, <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="token.md#0x3_token_EINVALID_MAXIMUM">EINVALID_MAXIMUM</a>));
22162218
<b>assert</b>!(token_data.mutability_config.maximum, <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_permission_denied">error::permission_denied</a>(<a href="token.md#0x3_token_EFIELD_NOT_MUTABLE">EFIELD_NOT_MUTABLE</a>));
22172219
token_data.maximum = maximum;

aptos-move/move-examples/mint_nft/sources/minting.move

+4-5
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,16 @@ module mint_nft::minting {
120120

121121
// change source_addr to the actual account that created the resource account
122122
let resource_signer_cap = resource_account::retrieve_resource_account_cap(resource_account, @source_addr);
123-
let resource_signer = account::create_signer_with_capability(&resource_signer_cap);
124123

125124
// create the nft collection
126125
let maximum_supply = 0;
127126
let mutate_setting = vector<bool>[ false, false, false ];
128-
let resource_account_address = signer::address_of(&resource_signer);
129-
token::create_collection(&resource_signer, collection_name, description, collection_uri, maximum_supply, mutate_setting);
127+
let resource_account_address = signer::address_of(resource_account);
128+
token::create_collection(resource_account, collection_name, description, collection_uri, maximum_supply, mutate_setting);
130129

131130
// create a token data id to specify which token will be minted
132131
let token_data_id = token::create_tokendata(
133-
&resource_signer,
132+
resource_account,
134133
collection_name,
135134
token_name,
136135
string::utf8(b""),
@@ -156,7 +155,7 @@ module mint_nft::minting {
156155
token_data_id,
157156
expiration_timestamp,
158157
minting_enabled: true,
159-
token_minting_events: account::new_event_handle<TokenMintingEvent>(&resource_signer),
158+
token_minting_events: account::new_event_handle<TokenMintingEvent>(resource_account),
160159
});
161160
}
162161

aptos-move/move-examples/resource_account/sources/simple_defi.move

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ module resource_account::simple_defi {
3737
fun init_module(account: &signer) {
3838
// store the capabilities within `ModuleData`
3939
let resource_signer_cap = resource_account::retrieve_resource_account_cap(account, @source_addr);
40-
let resource_signer = account::create_signer_with_capability(&resource_signer_cap);
4140
let (burn_cap, freeze_cap, mint_cap) = coin::initialize<ChloesCoin>(
42-
&resource_signer,
41+
account,
4342
string::utf8(b"Chloe's Coin"),
4443
string::utf8(b"CCOIN"),
4544
8,

0 commit comments

Comments
 (0)