Skip to content

Commit

Permalink
Temporary multiply maxFee by 2 (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiSugiura authored May 28, 2024
1 parent f0e812b commit 80bfc78
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
10 changes: 7 additions & 3 deletions packages/keychain/src/components/Execute/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ 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 @@ -100,8 +103,8 @@ export function Execute({

if (account.status === Status.DEPLOYED && transactionsDetail.maxFee) {
setFees({
base: BigInt(transactionsDetail.maxFee),
max: BigInt(transactionsDetail.maxFee),
base: BigInt(transactionsDetail.maxFee) * multiplier,
max: BigInt(transactionsDetail.maxFee) * multiplier,
});
return;
}
Expand All @@ -123,7 +126,7 @@ export function Execute({
account
.estimateInvokeFee(calls, transactionsDetail)
.then((fees) => {
setFees({ base: fees.overall_fee, max: fees.suggestedMaxFee });
setFees({ base: fees.overall_fee * multiplier, max: fees.suggestedMaxFee * multiplier });
})
.catch((e) => {
console.error(e);
Expand All @@ -138,6 +141,7 @@ export function Execute({
calls,
chainId,
transactionsDetail,
multiplier
]);

useEffect(() => {
Expand Down
8 changes: 4 additions & 4 deletions packages/keychain/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ const Index: NextPage = () => {
: [transactions];
const policies = calls.map(
(txn) =>
({
target: addAddressPadding(txn.contractAddress),
method: txn.entrypoint,
} as Policy),
({
target: addAddressPadding(txn.contractAddress),
method: txn.entrypoint,
} as Policy),
);

const session = controller.session(origin, cId);
Expand Down
5 changes: 3 additions & 2 deletions packages/keychain/src/utils/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
waitForTransactionOptions,
TransactionFinalityStatus,
InvocationsDetails,
num,
} from "starknet";
import {
AccountContractDocument,
Expand Down Expand Up @@ -176,8 +177,8 @@ class Account extends BaseAccount {
transactionsDetail.nonce =
transactionsDetail.nonce ?? (await this.getNonce("pending"));
// FIXME: estimated max fee is always too low
//transactionsDetail.maxFee = num.toHex(transactionsDetail.maxFee);
transactionsDetail.maxFee = "0x38D7EA4C68000"; // 0.001 eth
transactionsDetail.maxFee = num.toHex(transactionsDetail.maxFee);
// transactionsDetail.maxFee = "0x38D7EA4C68000"; // 0.001 eth

const res = await this.cartridge
.execute(calls as Array<Call>, transactionsDetail, session)
Expand Down

0 comments on commit 80bfc78

Please sign in to comment.