Skip to content

Commit 84bf78d

Browse files
committed
fix: aptos_framework assertions
1 parent d8306f3 commit 84bf78d

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

aptos-move/framework/aptos-framework/sources/aptos_coin.move

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ module aptos_framework::aptos_coin {
6161

6262
/// Only called during genesis to destroy the aptos framework account's mint capability once all initial validators
6363
/// 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);
6666
let MintCapStore { mint_cap } = move_from<MintCapStore>(@aptos_framework);
6767
coin::destroy_mint_cap(mint_cap);
6868
}
@@ -109,16 +109,19 @@ module aptos_framework::aptos_coin {
109109

110110
/// Desroy the mint capability from the account.
111111
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));
113113
let MintCapStore { mint_cap } = move_from<MintCapStore>(from);
114114
coin::destroy_mint_cap(mint_cap);
115115
}
116116

117117
/// Only callable in tests and testnets where the core resources account exists.
118118
/// Create delegated token for the address so the account could claim MintCapability later.
119119
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);
121121
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+
};
122125
vector::for_each_ref(delegations, |element| {
123126
let element: &DelegatedMintCapability = element;
124127
assert!(element.to != to, error::invalid_argument(EALREADY_DELEGATED));
@@ -214,10 +217,8 @@ module aptos_framework::aptos_coin {
214217
aptos_framework: &signer,
215218
destination: &signer,
216219
) acquires Delegations, MintCapStore {
217-
218220
// initialize the `aptos_coin`
219221
let (burn_cap, mint_cap) = initialize_for_test(aptos_framework);
220-
let core_resource
221222

222223
// delegate and claim the mint capability
223224
delegate_mint_capability(aptos_framework, signer::address_of(destination));

aptos-move/framework/aptos-framework/sources/aptos_coin.spec.move

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ spec aptos_framework::aptos_coin {
5555
}
5656

5757
spec destroy_mint_cap {
58-
let addr = signer::address_of(aptos_framework);
58+
let addr = signer::address_of(account);
5959
aborts_if addr != @aptos_framework;
6060
aborts_if !exists<MintCapStore>(@aptos_framework);
6161
}

0 commit comments

Comments
 (0)