Skip to content

Commit

Permalink
add derived filter and release version
Browse files Browse the repository at this point in the history
  • Loading branch information
tj327 committed Feb 1, 2024
1 parent af21064 commit 2f99458
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config/constants.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

const (
InterxVersion = "v0.4.43"
InterxVersion = "v0.4.44"
SekaiVersion = "v0.3.40"
CosmosVersion = "v0.47.6"

Expand Down
25 changes: 18 additions & 7 deletions gateway/cosmos/bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,22 @@ func queryBalancesHandle(r *http.Request, gwCosmosmux *runtime.ServeMux) (interf
excludedMap[token] = true
}

excludedData := make([]types.Coin, 0)
filteredData := make([]types.Coin, 0)
for _, balance := range allBalances {
if !excludedMap[balance.Denom] {
excludedData = append(excludedData, balance)
denom := balance.Denom
if excludedMap[denom] {
continue
}

isDerivedDenom := len(denom) > 2 && denom[0] == 'v' && strings.Contains(denom, "/")
if derivedParam == "true" && !isDerivedDenom {
continue
}
if derivedParam == "false" && isDerivedDenom {
continue
}

filteredData = append(filteredData, balance)
}

// if request does not have tokens list, return with pagination
Expand All @@ -148,16 +159,16 @@ func queryBalancesHandle(r *http.Request, gwCosmosmux *runtime.ServeMux) (interf
}

lastIndex := offset + limit
if lastIndex > len(excludedData) {
lastIndex = len(excludedData)
if lastIndex > len(filteredData) {
lastIndex = len(filteredData)
}
data = excludedData[offset:lastIndex]
data = filteredData[offset:lastIndex]

result := BalancesResult{
Balances: data,
Pagination: &Pagination{
NextKey: lastIndex,
Total: len(excludedData),
Total: len(filteredData),
},
}

Expand Down

0 comments on commit 2f99458

Please sign in to comment.