Skip to content

Commit

Permalink
feat(namada): decode u256 balances
Browse files Browse the repository at this point in the history
  • Loading branch information
egasimus committed Sep 3, 2024
1 parent f86f05a commit b6c81ff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/namada/NamadaConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as PGF from './NamadaPGF'
import * as Gov from './NamadaGov'
import * as Epoch from './NamadaEpoch'
import type { Chain as Namada } from './Namada'
import { decode, u256 } from '@hackbg/borshest'

export default class NamadaConnection extends CW.Connection {
get chain (): Namada {
Expand Down Expand Up @@ -49,8 +50,11 @@ export default class NamadaConnection extends CW.Connection {
const balanceKey = this.decode.balance_key(token, address)
const balanceAbci = `/shell/value/${balanceKey}`
const balance = await this.abciQuery(balanceAbci)
this.log.debug({balanceKey, balanceAbci, balance})
result[address][token] = balance
if (balance.length > 0) {
result[address][token] = String(decode(u256, balance))
} else {
result[address][token] = "0"
}
}
}
return result
Expand Down

0 comments on commit b6c81ff

Please sign in to comment.