-
Notifications
You must be signed in to change notification settings - Fork 208
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
reward converter - add trade route ID to portId #1011
reward converter - add trade route ID to portId #1011
Conversation
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
Lots of places I would think, surely we can combine these two functions, or wow that seems wordy or there has to be a way to make the function take fewer inputs.... and each time when I would look at the minimum information needed to accomplish the goal you would be right. It is well done but it doesn't feel elegant because this particular piece of code can't be elegant no matter how we try to wrap and contain the interfaces between functions. Managing the async life cycle for ICAs which don't exist on a hostZone struct are just going to carry around a lot of extra fields no matter what, I think this is about the best we can do for the inherent complexity of this part of the system
@ethan-stride what are you thoughts on the func FormatTradeRouteICAOwnerFromAccount(chainId, tradeRouteId string, icaAccountType ICAAccountType) string {
return fmt.Sprintf("%s.%s.%s", chainId, tradeRouteId, icaAccountType.String())
} it would muddy the invocation a bit // from
owner := types.FormatTradeRouteICAOwnerFromAccount(route.GetRouteId(), route.TradeAccount)
// to
tradeAccount := route.TradeAccount
owner := types.FormatTradeRouteICAOwnerFromAccount(tradeAccount.ChainId, route.GetRouteId(), tradeAccount.Type) But it would be a little more explicit about which fields are used instead of having to know that the ICAAccount struct needs both chainId and type filled out |
From discussion on Slack: being explicit about which fields from the account are going into the function call makes it harder to mistakenly pass in an account which is not yet initialized without realizing it. This makes the function clearer but calling it slightly more work -- overall a tradeoff which is probably worth it so the new proposed function params make sense. |
LGTM I think it is ready |
Context
We need to have a separate trade ICA for each trade route. Otherwise, if two trade routes shared a common denom, it could interfere with the queries.
Brief Changelog
FormatTradeRouteICAOwner
andFormatTradeRouteICAOwnerFromAccount
FormatICAAccountOwner
toFormatHostZoneICAOwner
NOTE: @ethan-stride, I'm not really loving the implementation of these owner functions. Curious if you can think of a better way to do it