Skip to content

Commit

Permalink
Remove orml dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszaaa committed Feb 3, 2022
1 parent 84ad6f4 commit a731523
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
2 changes: 0 additions & 2 deletions frame/treasury/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
pallet-balances = { version = "4.0.0-dev", default-features = false, path = "../balances" }
orml-tokens = { git = 'https://github.com/mangata-finance/open-runtime-module-library', default-features = false, branch="mangata-dev-v4" }

[dev-dependencies]
sp-io = { version = "4.0.0-dev", path = "../../primitives/io" }
Expand All @@ -45,7 +44,6 @@ std = [
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"orml-tokens/std",
]
runtime-benchmarks = [
"frame-benchmarking",
Expand Down
35 changes: 2 additions & 33 deletions frame/treasury/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@ use sp_std::prelude::*;
use frame_support::{
print,
traits::{
Currency, ExistenceRequirement::KeepAlive, Get, Imbalance, Instance, OnUnbalanced,
ReservableCurrency, TryDrop, WithdrawReasons,
Currency, ExistenceRequirement::KeepAlive, Get, Imbalance, OnUnbalanced,
ReservableCurrency, WithdrawReasons,
},
weights::Weight,
PalletId,
};

use orml_tokens::{MultiTokenCurrency, MultiTokenCurrencyAdapter, MultiTokenNegativeImbalance};

pub use pallet::*;
pub use weights::WeightInfo;

Expand Down Expand Up @@ -503,32 +501,3 @@ impl<T: Config<I>, I: 'static> OnUnbalanced<NegativeImbalanceOf<T, I>> for Palle
Self::deposit_event(Event::Deposit(numeric_amount));
}
}

pub struct MultiOnUnbalancedWrapper<Pallet> {
_marker: sp_std::marker::PhantomData<Pallet>,
}

impl<T, I, Tokens> OnUnbalanced<MultiTokenNegativeImbalance<Tokens>>
for MultiOnUnbalancedWrapper<Pallet<T, I>>
where
T: Config<I>,
I: 'static,
Tokens: orml_tokens::Config,
Tokens::AccountId: From<T::AccountId>,
<T::Currency as Currency<T::AccountId>>::Balance: From<u128>,
MultiTokenNegativeImbalance<Tokens>: TryDrop + Imbalance<BalanceOf<T, I>>,
{
fn on_nonzero_unbalanced(amount: MultiTokenNegativeImbalance<Tokens>) {
let numeric_amount = amount.peek().into();
let currency_id = amount.0;

// Must resolve into existing but better to be safe.
let _ = MultiTokenCurrencyAdapter::<Tokens>::resolve_creating(
currency_id,
&Pallet::<T, I>::account_id().into(),
amount,
);

Pallet::<T, I>::deposit_event(Event::Deposit(numeric_amount));
}
}

0 comments on commit a731523

Please sign in to comment.