Skip to content

Commit

Permalink
fix: catch EVM provider error in create
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Nov 9, 2024
1 parent 957f43c commit 50ed8b7
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/components/CreateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,27 +250,30 @@ export const CreateButton = () => {

let claimAddress = onchainAddress();

if (assetReceive() === RBTC) {
const [balance, gasPrice] = await Promise.all([
signer().provider.getBalance(await signer().getAddress()),
signer()
.provider.getFeeData()
.then((data) => data.gasPrice),
]);
log.debug("RSK balance", balance);
try {
if (assetReceive() === RBTC) {
const [balance, gasPrice] = await Promise.all([
signer().provider.getBalance(await signer().getAddress()),
signer()
.provider.getFeeData()
.then((data) => data.gasPrice),
]);
log.debug("RSK balance", balance);

const balanceNeeded = gasPrice * GasNeededToClaim;
log.debug("RSK balance needed", balanceNeeded);
const balanceNeeded = gasPrice * GasNeededToClaim;
log.debug("RSK balance needed", balanceNeeded);

if (balance <= balanceNeeded) {
claimAddress = (await getSmartWalletAddress(signer())).address;
log.info("Using RIF smart wallet as claim address");
if (balance <= balanceNeeded) {
claimAddress = (await getSmartWalletAddress(signer()))
.address;
log.info("Using RIF smart wallet as claim address");
} else {
log.info("RIF smart wallet not needed");
}
}
}

const useRif = onchainAddress() !== claimAddress;
const useRif = onchainAddress() !== claimAddress;

try {
let data: SomeSwap;
switch (swapType()) {
case SwapType.Submarine:
Expand Down

0 comments on commit 50ed8b7

Please sign in to comment.