Skip to content

Commit 17d7c5b

Browse files
committed
fix: showing balance for cosmos
1 parent 04b4c05 commit 17d7c5b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

app/src/lib/queries/balance/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { raise } from "$lib/utilities/index.ts"
33
import { getCosmosChainBalances } from "./cosmos.ts"
44
import { createQueries } from "@tanstack/svelte-query"
55
import { erc20ReadMulticall } from "./evm/multicall.ts"
6-
import { bytesToBech32Address } from "@unionlabs/client"
6+
import { bech32ToBech32Address } from "@unionlabs/client"
77
import type { Chain, UserAddresses } from "$lib/types.ts"
88
import { getBalancesFromAlchemy } from "./evm/alchemy.ts"
99
import { getBalancesFromRoutescan } from "./evm/routescan.ts"
@@ -72,10 +72,11 @@ export function userBalancesQuery({
7272
const url = chain.rpcs.filter(rpc => rpc.type === "rest").at(0)?.url
7373
if (!url) raise(`No REST RPC available for chain ${chain.chain_id}`)
7474

75-
const bech32Address = bytesToBech32Address({
75+
const bech32Address = bech32ToBech32Address({
7676
toPrefix: chain.addr_prefix,
77-
bytes: userAddr.cosmos.bytes
77+
address: userAddr.cosmos.canonical
7878
})
79+
7980
return getCosmosChainBalances({ url, walletAddress: bech32Address })
8081
}
8182

app/src/lib/utilities/address.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import type { Chain, UserAddresses } from "$lib/types"
2-
import { bytesToBech32Address } from "@unionlabs/client"
2+
import { bech32ToBech32Address } from "@unionlabs/client"
33

44
export const userAddrOnChain = (userAddr: UserAddresses, chain?: Chain): string | null => {
55
if (!chain) return null
66

77
if (chain.rpc_type === "cosmos") {
88
if (userAddr.cosmos?.bytes) {
9-
return bytesToBech32Address({ bytes: userAddr.cosmos.bytes, toPrefix: chain.addr_prefix })
9+
return bech32ToBech32Address({
10+
toPrefix: chain.addr_prefix,
11+
address: userAddr.cosmos.canonical
12+
})
1013
}
1114
console.log("userAddrOnChain got no cosmos address")
1215
return null

0 commit comments

Comments
 (0)