Skip to content

Commit

Permalink
fix: negative available balance (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 authored Jun 2, 2022
1 parent d930c10 commit 36b337e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/config/network/crab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const crabConfig: DVMChainConfig = {
name: 'crab',
provider: {
etherscan: '',
rpc: 'wss://darwinia-crab.api.onfinality.io/public-ws',
rpc: 'wss://crab-rpc.darwinia.network',
},
type: ['polkadot', 'darwinia'],
ss58Prefix: 42,
Expand Down
5 changes: 4 additions & 1 deletion src/utils/token/tokenInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export async function getDarwiniaBalances(api: ApiPromise, account = ''): Promis
maxKtonLock = calcMax(item, maxKtonLock);
});

return [free.sub(maxLock).toString(), freeKton.sub(maxKtonLock).toString()];
const ring = free.sub(maxLock);
const kton = freeKton.sub(maxKtonLock);

return [ring.isNeg() ? BN_ZERO.toString() : ring.toString(), kton.isNeg() ? BN_ZERO.toString() : kton.toString()];
} catch (err) {
console.error(err);
return ['0', '0'];
Expand Down

0 comments on commit 36b337e

Please sign in to comment.