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

Fix query balance response #464

Merged
merged 1 commit into from
Mar 22, 2021
Merged
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
17 changes: 11 additions & 6 deletions helpers/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ func QueryBalance(chain *relayer.Chain, address string, showDenoms bool) (sdk.Co

var out sdk.Coins
for _, c := range coins {
for _, d := range dts.DenomTraces {
switch {
case c.Amount.Equal(sdk.NewInt(0)):
case c.Denom == d.IBCDenom():
out = append(out, sdk.NewCoin(d.IBCDenom(), c.Amount))
default:
if c.Amount.Equal(sdk.NewInt(0)) {
continue
}

for i, d := range dts.DenomTraces {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should just do a query using this route instead of looping over all the traces

if c.Denom == d.IBCDenom() {
out = append(out, sdk.Coin{Denom: d.GetFullDenomPath(), Amount: c.Amount})
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd rather make our own coin type, something like

type Coin struct {
    Denom string
    Amount uint64
}

It is a little unnecessary, but I don't really trust things not to go wrong, since using the full denom path is an invalid sdk.Coin

break
}

if i == len(dts.DenomTraces)-1 {
out = append(out, c)
}
}
Expand Down