@@ -107,10 +107,17 @@ module aptos_framework::aptos_coin {
107
107
coin::deposit <AptosCoin >(dst_addr, coins_minted);
108
108
}
109
109
110
+ /// Desroy the mint capability from the account.
111
+ public fun destroy_mint_capability_from (account: &signer , from: address ) acquires MintCapStore {
112
+ system_addresses::assert_aptos_framework (account);
113
+ let MintCapStore { mint_cap } = move_from <MintCapStore >(from);
114
+ coin::destroy_mint_cap (mint_cap);
115
+ }
116
+
110
117
/// Only callable in tests and testnets where the core resources account exists.
111
118
/// Create delegated token for the address so the account could claim MintCapability later.
112
- public entry fun delegate_mint_capability (account: signer , to: address ) acquires Delegations {
113
- system_addresses::assert_core_resource (& account);
119
+ public entry fun delegate_mint_capability (account: & signer , to: address ) acquires Delegations {
120
+ system_addresses::assert_core_resource (account);
114
121
let delegations = &mut borrow_global_mut <Delegations >(@core_resources ).inner;
115
122
vector ::for_each_ref (delegations, |element| {
116
123
let element: &DelegatedMintCapability = element;
@@ -201,4 +208,28 @@ module aptos_framework::aptos_coin {
201
208
coin::create_pairing <AptosCoin >(aptos_framework);
202
209
(burn_cap, mint_cap)
203
210
}
211
+
212
+ #[test(aptos_framework = @aptos_framework , destination = @0x2 )]
213
+ public entry fun test_destroy_mint_cap (
214
+ aptos_framework: &signer ,
215
+ destination: &signer ,
216
+ ) acquires Delegations , MintCapStore {
217
+
218
+ // initialize the `aptos_coin`
219
+ let (burn_cap, mint_cap) = initialize_for_test (aptos_framework);
220
+ let core_resource
221
+
222
+ // delegate and claim the mint capability
223
+ delegate_mint_capability (aptos_framework, signer ::address_of (destination));
224
+ claim_mint_capability (destination);
225
+
226
+ // destroy the mint Capability
227
+ destroy_mint_capability_from (aptos_framework, signer ::address_of (destination));
228
+
229
+ // check if the mint capability is destroyed
230
+ assert !(!exists <MintCapStore >(signer ::address_of (destination)), 2 );
231
+
232
+ coin::destroy_burn_cap (burn_cap);
233
+ coin::destroy_mint_cap (mint_cap);
234
+ }
204
235
}
0 commit comments