Skip to content

Commit

Permalink
fix(SRB): fix getTokenBalance
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKozAllB committed Jan 10, 2024
1 parent cfbc177 commit 29ca622
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/services/token/srb/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Horizon } from "stellar-sdk";
import { Horizon, NotFoundError } from "stellar-sdk";
import { HorizonApi } from "stellar-sdk/lib/horizon";
import { ChainDecimalsByType, chainProperties, ChainSymbol, ChainType } from "../../../chains";
import { AllbridgeCoreClient } from "../../../client/core-api";
Expand Down Expand Up @@ -35,7 +35,15 @@ export class SrbTokenService extends ChainTokenService {
const [symbol, srbTokenAddress] = params.token.originTokenAddress.split(":");

const stellar = new Horizon.Server(this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.STLR));
const stellarAccount = await stellar.loadAccount(params.account);
let stellarAccount;
try {
stellarAccount = await stellar.loadAccount(params.account);
} catch (err) {
if (err instanceof NotFoundError) {
return "0";
}
throw err;
}
const balances = stellarAccount.balances;

const balanceInfo = balances.find(
Expand Down

0 comments on commit 29ca622

Please sign in to comment.