Skip to content

Commit a08c3d6

Browse files
committed
fix: test_destroy_mint_cap
1 parent 84bf78d commit a08c3d6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ 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_core_resource_address(signer::address_of(account));
112+
system_addresses::assert_aptos_framework(account);
113113
let MintCapStore { mint_cap } = move_from<MintCapStore>(from);
114114
coin::destroy_mint_cap(mint_cap);
115115
}
@@ -118,7 +118,7 @@ module aptos_framework::aptos_coin {
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 {
120120
system_addresses::assert_aptos_framework(account);
121-
let delegations = &mut borrow_global_mut<Delegations>(@core_resources).inner;
121+
let delegations = &mut borrow_global_mut<Delegations>(@aptos_framework).inner;
122122
if (!exists<Delegations>(signer::address_of(account))) {
123123
move_to(account, Delegations { inner: vector[] });
124124
};
@@ -135,16 +135,16 @@ module aptos_framework::aptos_coin {
135135
let maybe_index = find_delegation(signer::address_of(account));
136136
assert!(option::is_some(&maybe_index), EDELEGATION_NOT_FOUND);
137137
let idx = *option::borrow(&maybe_index);
138-
let delegations = &mut borrow_global_mut<Delegations>(@core_resources).inner;
138+
let delegations = &mut borrow_global_mut<Delegations>(@aptos_framework).inner;
139139
let DelegatedMintCapability { to: _ } = vector::swap_remove(delegations, idx);
140140

141141
// Make a copy of mint cap and give it to the specified account.
142-
let mint_cap = borrow_global<MintCapStore>(@core_resources).mint_cap;
142+
let mint_cap = borrow_global<MintCapStore>(@aptos_framework).mint_cap;
143143
move_to(account, MintCapStore { mint_cap });
144144
}
145145

146146
fun find_delegation(addr: address): Option<u64> acquires Delegations {
147-
let delegations = &borrow_global<Delegations>(@core_resources).inner;
147+
let delegations = &borrow_global<Delegations>(@aptos_framework).inner;
148148
let i = 0;
149149
let len = vector::length(delegations);
150150
let index = option::none();
@@ -195,6 +195,7 @@ module aptos_framework::aptos_coin {
195195
#[test_only]
196196
public fun initialize_for_test(aptos_framework: &signer): (BurnCapability<AptosCoin>, MintCapability<AptosCoin>) {
197197
aggregator_factory::initialize_aggregator_factory_for_test(aptos_framework);
198+
init_delegations(aptos_framework);
198199
let (burn_cap, mint_cap) = initialize(aptos_framework);
199200
coin::create_coin_conversion_map(aptos_framework);
200201
coin::create_pairing<AptosCoin>(aptos_framework);
@@ -212,6 +213,15 @@ module aptos_framework::aptos_coin {
212213
(burn_cap, mint_cap)
213214
}
214215

216+
/// Initializes the Delegations resource under `@aptos_framework`.
217+
#[test_only]
218+
public entry fun init_delegations(framework_signer: &signer) {
219+
// Ensure the delegations resource does not already exist
220+
if (!exists<Delegations>(@aptos_framework)) {
221+
move_to(framework_signer, Delegations { inner: vector[] });
222+
}
223+
}
224+
215225
#[test(aptos_framework = @aptos_framework, destination = @0x2)]
216226
public entry fun test_destroy_mint_cap(
217227
aptos_framework: &signer,

0 commit comments

Comments
 (0)