From be7ce215bf900f3883e7ac94bebfdc5df459028d Mon Sep 17 00:00:00 2001 From: broody Date: Wed, 29 May 2024 06:48:31 -1000 Subject: [PATCH] Revert "Revert "Fix est fee (#314)" (#315)" This reverts commit 2830319fa30bd1b59822cd16d8d81fbf1a5e5cd6. --- packages/keychain/src/components/Execute/index.tsx | 10 +++------- packages/keychain/src/pages/index.tsx | 2 -- packages/keychain/src/utils/account.ts | 11 ++++++++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/keychain/src/components/Execute/index.tsx b/packages/keychain/src/components/Execute/index.tsx index 01e2a4b4b..c0695900c 100644 --- a/packages/keychain/src/components/Execute/index.tsx +++ b/packages/keychain/src/components/Execute/index.tsx @@ -58,9 +58,6 @@ export function Execute({ const [ethApproved, setEthApproved] = useState(); const [lowEthInfo, setLowEthInfo] = useState(); const [bridging, setBridging] = useState(false); - // temporary boosting max fees - // @ts-expect-error there's no setter field for now - const [multiplier, setMultiplier] = useState(2n); const account = controller.account(chainId); const calls = useMemo(() => { @@ -103,8 +100,8 @@ export function Execute({ if (account.status === Status.DEPLOYED && transactionsDetail.maxFee) { setFees({ - base: BigInt(transactionsDetail.maxFee) * multiplier, - max: BigInt(transactionsDetail.maxFee) * multiplier, + base: BigInt(transactionsDetail.maxFee), + max: BigInt(transactionsDetail.maxFee), }); return; } @@ -126,7 +123,7 @@ export function Execute({ account .estimateInvokeFee(calls, transactionsDetail) .then((fees) => { - setFees({ base: fees.overall_fee * multiplier, max: fees.suggestedMaxFee * multiplier }); + setFees({ base: fees.overall_fee, max: fees.suggestedMaxFee }); }) .catch((e) => { console.error(e); @@ -141,7 +138,6 @@ export function Execute({ calls, chainId, transactionsDetail, - multiplier ]); useEffect(() => { diff --git a/packages/keychain/src/pages/index.tsx b/packages/keychain/src/pages/index.tsx index e139e6009..9d9a485ab 100644 --- a/packages/keychain/src/pages/index.tsx +++ b/packages/keychain/src/pages/index.tsx @@ -192,8 +192,6 @@ const Index: NextPage = () => { nonce: transactionsDetail.nonce, }) ).suggestedMaxFee; - - console.log("execute", { estFee: transactionsDetail.maxFee }); } if ( diff --git a/packages/keychain/src/utils/account.ts b/packages/keychain/src/utils/account.ts index f7690f9b7..effcaeadd 100644 --- a/packages/keychain/src/utils/account.ts +++ b/packages/keychain/src/utils/account.ts @@ -28,6 +28,8 @@ import Storage from "./storage"; import { CartridgeAccount } from "@cartridge/account-wasm"; import { Session } from "@cartridge/controller"; +const EST_FEE_MULTIPLIER = 2n; + export enum Status { COUNTERFACTUAL = "COUNTERFACTUAL", DEPLOYING = "DEPLOYING", @@ -178,8 +180,6 @@ class Account extends BaseAccount { transactionsDetail.nonce ?? (await this.getNonce("pending")); transactionsDetail.maxFee = num.toHex(transactionsDetail.maxFee); - console.log("account", { estFee: transactionsDetail.maxFee }); - const res = await this.cartridge .execute(calls as Array, transactionsDetail, session) .catch((e) => { @@ -217,7 +217,12 @@ class Account extends BaseAccount { details.nonce = details.nonce ?? (await super.getNonce("pending")); - return await super.estimateInvokeFee(calls, details); + const estFee = await super.estimateInvokeFee(calls, details); + console.log("estimated", { estFee }); + estFee.suggestedMaxFee *= EST_FEE_MULTIPLIER; + console.log("multiplied", { estFee }); + + return estFee; } async verifyMessageHash(