Skip to content

Commit

Permalink
Merge pull request #538 from BibliothecaDAO/fix/aa-errors
Browse files Browse the repository at this point in the history
revert back to old max fee check
  • Loading branch information
starknetdev authored Jan 17, 2024
2 parents 366930b + 36e9049 commit c03e658
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ui/src/app/hooks/useTransactionCartStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { create } from "zustand";
import { Call } from "@/app/types";
import { AccountInterface } from "starknet";
import { MAX_FEE_CHECK } from "../lib/constants";

type TransactionCartState = {
error: boolean;
Expand Down Expand Up @@ -52,18 +53,19 @@ const useTransactionCartStore = create<TransactionCartState>((set) => {
showTopUpDialog: (show: boolean) => void,
setTopUpAccount: (account: string) => void
) => {
const onMainnet = process.env.NEXT_PUBLIC_NETWORK === "mainnet";
const maxFee = onMainnet ? MAX_FEE_CHECK : MAX_FEE_CHECK / 10;
try {
let tx;
if (isArcade) {
// If they have an arcade account, estimate the max fee
const feeEstimateResult = await account.estimateInvokeFee(calls);
if (ethBalance < feeEstimateResult.suggestedMaxFee! * BigInt(2)) {
if (ethBalance < maxFee) {
showTopUpDialog(true);
setTopUpAccount(account?.address ?? "");
throw new Error("Not enough eth for gas.");
} else {
tx = await account.execute(calls, undefined, {
maxFee: feeEstimateResult.suggestedMaxFee! * BigInt(2),
maxFee: maxFee,
});
}
} else {
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const MIN_BALANCE = 100000000000000; // 0.00001ETH or $0.15
export const TRANSACTION_WAIT_RETRY_INTERVAL = 6000; // 6 seconds
export const ETH_INCREMENT = 0.001;
export const LORDS_INCREMENT = 5;
export const MAX_FEE_CHECK = 0.003 * 10 ** 18; // 0.03ETH

export const deathMessages = [
{
Expand Down

1 comment on commit c03e658

@vercel
Copy link

@vercel vercel bot commented on c03e658 Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.