Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove orml dependency #18

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
}