-
Notifications
You must be signed in to change notification settings - Fork 601
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
Take revenue #1228
Take revenue #1228
Conversation
runtime/karura/src/lib.rs
Outdated
@@ -1060,6 +1062,15 @@ impl OnUnbalanced<NegativeImbalance> for DealWithFees { | |||
} | |||
} | |||
} | |||
impl TakeRevenue for DealWithFees { | |||
fn take_revenue(revenue: MultiAsset) { | |||
if let MultiAsset::ConcreteFungible { amount, .. } = revenue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all concrete fungible revenue is in KSM, need to check the the location.
runtime/mandala/src/lib.rs
Outdated
@@ -1106,6 +1108,15 @@ impl OnUnbalanced<NegativeImbalance> for DealWithFees { | |||
} | |||
} | |||
} | |||
impl TakeRevenue for DealWithFees { | |||
fn take_revenue(revenue: MultiAsset) { | |||
if let MultiAsset::ConcreteFungible { amount, .. } = revenue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
runtime/mandala/src/lib.rs
Outdated
if let MultiAsset::ConcreteFungible { amount, .. } = revenue { | ||
// ensure KaruraTreasuryAccount have ed for DOT. | ||
// Ignore the result. | ||
let _ = Tokens::deposit(AUSD, &TreasuryAccount::get(), amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let _ = Tokens::deposit(AUSD, &TreasuryAccount::get(), amount); | |
let _ = Tokens::deposit(DOT, &TreasuryAccount::get(), amount); |
runtime/karura/src/lib.rs
Outdated
@@ -1060,6 +1062,15 @@ impl OnUnbalanced<NegativeImbalance> for DealWithFees { | |||
} | |||
} | |||
} | |||
impl TakeRevenue for DealWithFees { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not to reuse the DealWithFees
. We should make each struct type concern their own business. Declare a new struct before XcmConfig
and name it ToTreasury
.
Codecov Report
@@ Coverage Diff @@
## master #1228 +/- ##
==========================================
- Coverage 66.04% 65.80% -0.24%
==========================================
Files 224 222 -2
Lines 19753 19213 -540
==========================================
- Hits 13045 12643 -402
+ Misses 6708 6570 -138
Continue to review full report at Codecov.
|
runtime/karura/src/lib.rs
Outdated
impl TakeRevenue for ToTreasury { | ||
fn take_revenue(revenue: MultiAsset) { | ||
if let MultiAsset::ConcreteFungible { id, amount } = revenue { | ||
if CurrencyIdConvert::convert(id).is_some() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_some
check only ensures id
could be converted to a CurrencyId
but it doesn't have to be KSM.
To handle it correctly, get the wrapped currency_id
in result and deposit with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now. We need to do end to end test before merging it.
The treasury( |
How hard to write some tests for this? |
BTW, learn about the xcm transaction process. |
We only need to mock the execution of received XCM from Kusama in integration tests. You may refer to the commented out ones in integration tests. Acala/runtime/mandala/tests/integration_test.rs Line 1654 in 8c69db0
|
Closes: #1115