Skip to content

Commit

Permalink
Merge pull request #7 from CudoVentures/Fixed-Error-when-wallet-balan…
Browse files Browse the repository at this point in the history
…ce-zero

Fixed error when wallet balance is zero
  • Loading branch information
kstoykov authored Jan 26, 2022
2 parents b826b58 + b6761b1 commit 7b0148a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export default class KeplrLedger implements Ledger {
);

this.txHash = result.transactionHash
console.log('result', result);

assertIsBroadcastTxSuccess(result);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ export default class CudosBridgeComponent extends ContextPageComponent<Props, St
contractBalance = new BigNumber(0);
}
balance = await ledger.getBalance();
if (!balance) {
balance = new BigNumber(0);
}
if (this.isFromCosmos(fromNetwork) === true) {
contractBalance = await this.getContractBalance();
} else {
Expand Down Expand Up @@ -229,6 +232,9 @@ export default class CudosBridgeComponent extends ContextPageComponent<Props, St
contractBalance = new BigNumber(0);
}
balance = await ledger.getBalance();
if (!balance) {
balance = new BigNumber(0);
}
if (this.isFromCosmos(toNetwork) === true) {
contractBalance = await this.getContractBalance();
} else {
Expand All @@ -255,7 +261,11 @@ export default class CudosBridgeComponent extends ContextPageComponent<Props, St

onClickMaxAmount = async () => {
const ledger = await this.checkWalletConnected();
const balance = await ledger.getBalance();
let balance = await ledger.getBalance();

if (!balance) {
balance = new BigNumber(0);
}

const maximumAmount = BigNumber.minimum(balance, this.state.contractBalance);
this.setState({
Expand All @@ -267,8 +277,10 @@ export default class CudosBridgeComponent extends ContextPageComponent<Props, St

onGetBalance = async () => {
const ledger = await this.checkWalletConnected();
const balance = await ledger.getBalance();

let balance = await ledger.getBalance();
if (!balance) {
balance = new BigNumber(0);
}
this.setState({
walletBalance: balance,
})
Expand Down Expand Up @@ -374,6 +386,9 @@ export default class CudosBridgeComponent extends ContextPageComponent<Props, St

if (toConnected) {
balance = await ledger.getBalance();
if (!balance) {
balance = new BigNumber(0);
}
}
if (this.isFromCosmos(toNetwork) === true) {
contractBalance = await this.getContractBalance();
Expand Down Expand Up @@ -435,6 +450,9 @@ export default class CudosBridgeComponent extends ContextPageComponent<Props, St

if (fromConnected) {
balance = await ledger.getBalance();
if (!balance) {
balance = new BigNumber(0);
}
}
if (this.isFromCosmos(fromNetwork) === true) {
contractBalance = await this.getContractBalance();
Expand Down

0 comments on commit 7b0148a

Please sign in to comment.