From b6c81ff401f9a81c33388a3e0bfd770116c2223d Mon Sep 17 00:00:00 2001 From: Adam A Date: Tue, 3 Sep 2024 23:12:24 +0300 Subject: [PATCH] feat(namada): decode u256 balances --- packages/namada/NamadaConnection.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/namada/NamadaConnection.ts b/packages/namada/NamadaConnection.ts index 311a472d9a..f0563db3b9 100644 --- a/packages/namada/NamadaConnection.ts +++ b/packages/namada/NamadaConnection.ts @@ -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 { @@ -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