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

modify query balance #484

Closed
wants to merge 2 commits into from
Closed

Conversation

akhilkumarpilli
Copy link
Contributor

break
}
// splitting denom to get hash
denomSplit := strings.Split(c.Denom, "/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can assume an account only has IBC tokens. We need to check if the prefix of the coin is ibc/. I added an issue on ibc-go since there should be a helper function for this

It also seems odd to me that we need to parse out ibc before doing the QueryDenomTrace, so I added another issue

I'm okay actually closing this issue and leaving the code as is until we fix the above issues upstream. I'd like a function that looks something like this:

for _, c := range coins {
    if IsIBCDenom(c.Denom) {
        dt, err := chain.QueryDenomTrace(c.Denom)
        if err != nil {
            return fmt.Errorf("unregistered token in balance")
        }
        
        out = append(out, NewToken(dt.DenomTrace.GetFullDenomPath(), c.Amount)
    } else {
         out = append(out, c)
    }
}

@jackzampolin jackzampolin marked this pull request as ready for review October 25, 2021 22:10
@jackzampolin jackzampolin deleted the akhil/modify-query-balance branch October 25, 2021 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

query balance cmd returns duplicate responses
3 participants