Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ariesgun committed Oct 26, 2024
1 parent 62f9e74 commit 980d99f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
11 changes: 6 additions & 5 deletions static/scripts/rewards/web3/erc20-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { toaster, errorToast, MetaMaskError } from "../toaster";
import { connectWallet } from "./connect-wallet";
import { convertToNetworkId } from "./use-rpc-handler";
import { decodeError } from "@ariesgun/ethers-decode-error";
// import { decodeError } from "./error-decoder";

export async function fetchTreasury(permit: Permit): Promise<{ balance: BigNumber; allowance: BigNumber; decimals: number; symbol: string }> {
let balance: BigNumber, allowance: BigNumber, decimals: number, symbol: string;
Expand Down Expand Up @@ -91,6 +90,7 @@ export async function transferFromPermit(permit2Contract: Contract, reward: Perm
buttonController.hideLoader();
buttonController.showMakeClaim();
} else {
console.error(e);
const { error } = decodeError(e, permit2Abi);
errorToast(e, `Error in permitTransferFrom: ${error}`);
}
Expand Down Expand Up @@ -273,11 +273,12 @@ invalidateButton.addEventListener("click", async function invalidateButtonClickH

if (!app.signer) return;
await invalidateNonce(app.signer, app.reward.nonce);
} catch (error: unknown) {
if (error instanceof Error) {
const e = error as unknown as MetaMaskError;
} catch (err: unknown) {
if (err instanceof Error) {
const e = err as unknown as MetaMaskError;
console.error(e);
errorToast(e, e.reason);
const { error } = decodeError(e, permit2Abi);
errorToast(e, `Error in invalidateNonce: ${error}`);
return;
}
}
Expand Down
5 changes: 1 addition & 4 deletions static/scripts/rewards/web3/erc721-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ export function claimErc721PermitHandler(reward: ERC721Permit) {
}

buttonController.showLoader();

const nftContract = new ethers.Contract(reward.tokenAddress, nftRewardAbi, signer);
if (!nftContract) return;

try {
const nftContract = new ethers.Contract(reward.tokenAddress, nftRewardAbi, signer);
const tx: TransactionResponse = await nftContract.safeMint(
{
beneficiary: reward.beneficiary,
Expand Down

0 comments on commit 980d99f

Please sign in to comment.