Skip to content

Commit

Permalink
fix: get balance on union
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Feb 16, 2024
1 parent 64ae6bc commit 3fa4ef6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
11 changes: 5 additions & 6 deletions typescript-sdk/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,11 @@ export async function getBalanceOnUnion({
}: GetBalanceOnUnion): Promise<bigint> {
try {
try {
const client = await StargateClient.connect(unionRpcUrl)
const { amount } = await client.getBalance(address, assetId)
return BigInt(amount)
} catch (error) {
console.log('Failed to get balance using StargateClient', error)
const { balances } = await fetcher<{ balances: Array<{ amount: string; denom: string }> }>(
`${process.env.UNION_REST_URL || 'https://union-testnet-api.polkachu.com'}/cosmos/bank/v1beta1/balances/${address}`,
{
mode: 'cors',
headers: {

// no-cors
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
Expand All @@ -93,6 +87,11 @@ export async function getBalanceOnUnion({
)
const balance = balances.find(({ denom }) => denom === assetId)
return BigInt(balance?.amount ?? 0)
} catch (error) {
console.log('Failed to get balance using StargateClient', error)
const client = await StargateClient.connect(unionRpcUrl)
const { amount } = await client.getBalance(address, assetId)
return BigInt(amount)
}
} catch (error) {
const errorMessage = error instanceof Error ? error.message : error
Expand Down
1 change: 0 additions & 1 deletion typescript-sdk/src/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ export async function sendAssetFromUnionToEthereum<
): Promise<ExecuteResult> {
console.log(signer, assetId, amount, denom, receiver, gasPrice, rpcUrl, memo)
const tendermintClient = await Comet38Client.connect(rpcUrl)
// console.log(await tendermintClient.status())
const cosmwasmClient = await SigningCosmWasmClient.createWithSigner(tendermintClient, signer, {
gasPrice: GasPrice.fromString(gasPrice ?? `0.001${denom}`),
})
Expand Down

0 comments on commit 3fa4ef6

Please sign in to comment.