Skip to content

Commit

Permalink
Revert "Revert "Fix est fee (#314)" (#315)"
Browse files Browse the repository at this point in the history
This reverts commit 2830319.
  • Loading branch information
broody committed May 29, 2024
1 parent fa21f52 commit 550318e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function StarknetProvider({ children }: PropsWithChildren) {
);
}

const url = "https://keychain-git-preview-test.preview.cartridge.gg";
const url = "https://keychain-git-preview-test.preview.cartridge.gg/";

const connectors = [
new CartridgeConnector(
Expand Down
10 changes: 3 additions & 7 deletions packages/keychain/src/components/Execute/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ export function Execute({
const [ethApproved, setEthApproved] = useState<bigint>();
const [lowEthInfo, setLowEthInfo] = useState<LowEthInfo>();
const [bridging, setBridging] = useState<boolean>(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(() => {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand All @@ -141,7 +138,6 @@ export function Execute({
calls,
chainId,
transactionsDetail,
multiplier
]);

useEffect(() => {
Expand Down
2 changes: 0 additions & 2 deletions packages/keychain/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ const Index: NextPage = () => {
nonce: transactionsDetail.nonce,
})
).suggestedMaxFee;

console.log("execute", { estFee: transactionsDetail.maxFee });
}

if (
Expand Down
11 changes: 8 additions & 3 deletions packages/keychain/src/utils/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import Storage from "./storage";
import { CartridgeAccount } from "@cartridge/account-wasm";
import { Session } from "@cartridge/controller";

const EST_FEE_MULTIPLIER = 10n;

export enum Status {
COUNTERFACTUAL = "COUNTERFACTUAL",
DEPLOYING = "DEPLOYING",
Expand Down Expand Up @@ -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<Call>, transactionsDetail, session)
.catch((e) => {
Expand Down Expand Up @@ -217,7 +217,12 @@ class Account extends BaseAccount {

details.nonce = details.nonce ?? (await super.getNonce("pending"));

return await super.estimateInvokeFee(calls, details);
let estFee = await super.estimateInvokeFee(calls, details);
console.log("estimated", { suggestedMax: estFee.suggestedMaxFee });
estFee.suggestedMaxFee *= EST_FEE_MULTIPLIER;
console.log("estimated", { suggestedMax: estFee.suggestedMaxFee });

return estFee;
}

async verifyMessageHash(
Expand Down

0 comments on commit 550318e

Please sign in to comment.