Skip to content

Commit

Permalink
Add force_mint_asset for refund
Browse files Browse the repository at this point in the history
  • Loading branch information
en committed Sep 6, 2022
1 parent bd32336 commit 299dba5
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion appchain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use frame_support::{
sp_runtime::traits::AtLeast32BitUnsigned,
sp_std::fmt::Debug,
traits::{
tokens::{fungibles, nonfungibles},
tokens::{
fungibles::{self, Mutate},
nonfungibles,
},
Currency,
ExistenceRequirement::{AllowDeath, KeepAlive},
OneSessionHandler, StorageVersion,
Expand Down Expand Up @@ -619,6 +622,12 @@ pub mod pallet {
class: T::ClassId,
instance: T::InstanceId,
},
/// Some asset was force-minted.
ForceAssetMinted {
asset_id: T::AssetId,
who: T::AccountId,
amount: T::AssetBalance,
},
}

// Errors inform users that something went wrong.
Expand Down Expand Up @@ -1097,6 +1106,22 @@ pub mod pallet {
);
Ok(())
}

#[pallet::weight(0)]
pub fn force_mint_asset(
origin: OriginFor<T>,
asset_id: T::AssetId,
who: <T::Lookup as StaticLookup>::Source,
amount: T::AssetBalance,
) -> DispatchResult {
ensure_root(origin)?;
let who = T::Lookup::lookup(who)?;
T::Assets::mint_into(asset_id, &who, amount)?;

Self::deposit_event(Event::ForceAssetMinted { asset_id, who, amount });

Ok(())
}
}

impl<T: Config> TokenIdAndAssetIdProvider<T::AssetId> for Pallet<T> {
Expand Down

0 comments on commit 299dba5

Please sign in to comment.