@@ -61,8 +61,8 @@ module aptos_framework::aptos_coin {
61
61
62
62
/// Only called during genesis to destroy the aptos framework account's mint capability once all initial validators
63
63
/// and accounts have been initialized during genesis.
64
- public (friend ) fun destroy_mint_cap (aptos_framework : &signer ) acquires MintCapStore {
65
- system_addresses::assert_aptos_framework (aptos_framework );
64
+ public (friend ) fun destroy_mint_cap (account : &signer ) acquires MintCapStore {
65
+ system_addresses::assert_aptos_framework (account );
66
66
let MintCapStore { mint_cap } = move_from <MintCapStore >(@aptos_framework );
67
67
coin::destroy_mint_cap (mint_cap);
68
68
}
@@ -109,16 +109,19 @@ module aptos_framework::aptos_coin {
109
109
110
110
/// Desroy the mint capability from the account.
111
111
public fun destroy_mint_capability_from (account: &signer , from: address ) acquires MintCapStore {
112
- system_addresses::assert_aptos_framework ( account);
112
+ system_addresses::assert_core_resource_address ( signer :: address_of ( account) );
113
113
let MintCapStore { mint_cap } = move_from <MintCapStore >(from);
114
114
coin::destroy_mint_cap (mint_cap);
115
115
}
116
116
117
117
/// Only callable in tests and testnets where the core resources account exists.
118
118
/// Create delegated token for the address so the account could claim MintCapability later.
119
119
public entry fun delegate_mint_capability (account: &signer , to: address ) acquires Delegations {
120
- system_addresses::assert_core_resource (account);
120
+ system_addresses::assert_aptos_framework (account);
121
121
let delegations = &mut borrow_global_mut <Delegations >(@core_resources ).inner;
122
+ if (!exists <Delegations >(signer ::address_of (account))) {
123
+ move_to (account, Delegations { inner: vector [] });
124
+ };
122
125
vector ::for_each_ref (delegations, |element| {
123
126
let element: &DelegatedMintCapability = element;
124
127
assert !(element.to != to, error::invalid_argument (EALREADY_DELEGATED ));
@@ -214,10 +217,8 @@ module aptos_framework::aptos_coin {
214
217
aptos_framework: &signer ,
215
218
destination: &signer ,
216
219
) acquires Delegations , MintCapStore {
217
-
218
220
// initialize the `aptos_coin`
219
221
let (burn_cap, mint_cap) = initialize_for_test (aptos_framework);
220
- let core_resource
221
222
222
223
// delegate and claim the mint capability
223
224
delegate_mint_capability (aptos_framework, signer ::address_of (destination));
0 commit comments