-
Notifications
You must be signed in to change notification settings - Fork 86
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
Investments: simplify constraints and remove InvestmentProperties trait #1571
Conversation
2392851
to
bf1224f
Compare
@@ -595,7 +572,7 @@ where | |||
amount, | |||
})?; | |||
|
|||
let info = T::Accountant::info(investment_id).map_err(|_| Error::<T>::UnknownInvestment)?; | |||
let _ = T::Accountant::info(investment_id).map_err(|_| Error::<T>::UnknownInvestment)?; |
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.
Actually, this line could be removed to save a read access to the database, but there is a test that checks for the error UnknownInvestment
. If removed a future Accountant::transfer()
fails with a different error but I think the logic would be still ok
@@ -662,7 +638,7 @@ where | |||
who: T::AccountId, | |||
investment_id: T::InvestmentId, | |||
) -> DispatchResultWithPostInfo { | |||
let info = T::Accountant::info(investment_id).map_err(|_| Error::<T>::UnknownInvestment)?; | |||
let _ = T::Accountant::info(investment_id).map_err(|_| Error::<T>::UnknownInvestment)?; |
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
@@ -955,7 +928,7 @@ where | |||
&mut total_order.amount, | |||
)?; | |||
|
|||
T::Accountant::transfer(info.id(), send, recv, transfer_amount) | |||
T::Accountant::transfer(investment_id, send, recv, transfer_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.
info.id()
and investment_id
always match with the same value, so we can save from using info
in some places
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.
Changes look sane. But I am still thinking whether it is worth the refactor. Just am wondering whether we need to have that abstraction for pallet-linked-pools
.
But I we can go back and change it again if we want to.
Ok! Happy to revert some parts if needed in the future. Note that the |
Description
Some simplifications regarding investment info/properties. Slack conversation
Changes and Descriptions
InvestmentProperties
trait. Now, the typeInvestmentInfo
is used directly (which I think simplifies some parts)where
bound everywhere the investment pallets is used to determine the correctInvestmentInfo
(this simplifies things for future integration tests)