Skip to content

Commit

Permalink
Merge branch 'feat/small-sign' into tmp/20240823
Browse files Browse the repository at this point in the history
  • Loading branch information
cs1707 committed Aug 23, 2024
2 parents 3af735b + 44500f3 commit 029bc26
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 41 deletions.
30 changes: 17 additions & 13 deletions src/ui/utils/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ export const sendTransaction = async ({
isGasLess,
waitCompleted = true,
pushType = 'default',
ignoreGasNotEnoughCheck,
}: {
tx: Tx;
chainServerId: string;
wallet: WalletControllerType;
ignoreGasCheck?: boolean;
ignoreGasNotEnoughCheck?: boolean;
onProgress?: (status: ProgressStatus) => void;
gasLevel?: GasLevel;
lowGasDeadline?: number;
Expand Down Expand Up @@ -155,19 +157,21 @@ export const sendTransaction = async ({
});

// check gas errors
const checkErrors = checkGasAndNonce({
recommendGasLimit: `0x${gas.toString(16)}`,
recommendNonce,
gasLimit: Number(gasLimit),
nonce: Number(recommendNonce || tx.nonce),
gasExplainResponse: gasCost,
isSpeedUp: false,
isCancel: false,
tx,
isGnosisAccount: false,
nativeTokenBalance: balance,
recommendGasLimitRatio,
});
const checkErrors = ignoreGasNotEnoughCheck
? []
: checkGasAndNonce({
recommendGasLimit: `0x${gas.toString(16)}`,
recommendNonce,
gasLimit: Number(gasLimit),
nonce: Number(recommendNonce || tx.nonce),
gasExplainResponse: gasCost,
isSpeedUp: false,
isCancel: false,
tx,
isGnosisAccount: false,
nativeTokenBalance: balance,
recommendGasLimitRatio,
});

const isGasNotEnough = !isGasLess && checkErrors.some((e) => e.code === 3001);
const ETH_GAS_USD_LIMIT = process.env.DEBUG
Expand Down
60 changes: 32 additions & 28 deletions src/ui/views/Approval/components/MiniSignTx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export const MiniSignTx = ({
waitCompleted: false,
pushType: pushInfo.type,
ignoreGasCheck: true,
ignoreGasNotEnoughCheck: true,
},
status: 'idle',
};
Expand Down Expand Up @@ -372,36 +373,39 @@ export const MiniSignTx = ({
})
);
}
Promise.all(
txsResult.map(async (item) => {
const tx = {
...item.tx,
...(support1559
? {
maxFeePerGas: intToHex(Math.round(gas.price)),
maxPriorityFeePerGas:
gas.maxPriorityFee <= 0
? item.tx.maxFeePerGas
: intToHex(Math.round(gas.maxPriorityFee)),
}
: { gasPrice: intToHex(Math.round(gas.price)) }),
};
return {
...item,
tx,
gasCost: await explainGas({
gasUsed: item.gasUsed,
gasPrice: gas.price,
chainId: chain.id,
nativeTokenPrice: item.preExecResult.native_token.price,
wallet,
tx,
gasLimit: item.gasLimit,
}),
};
})
).then((res) => {
setTxsResult(res);
});
if (support1559) {
setTxsResult((pre) => {
return pre.map((item) => {
return {
...item,
tx: {
...item.tx,
maxFeePerGas: intToHex(Math.round(gas.price)),
maxPriorityFeePerGas:
gas.maxPriorityFee <= 0
? item.tx.maxFeePerGas
: intToHex(Math.round(gas.maxPriorityFee)),
},
};
});
});
setMaxPriorityFee(Math.round(gas.maxPriorityFee));
} else {
setTxsResult((pre) => {
return pre.map((item) => {
return {
...item,
tx: {
...item.tx,
gasPrice: intToHex(Math.round(gas.price)),
// gas: intToHex(gas.gasLimit),
},
};
});
});
}
};

Expand Down

0 comments on commit 029bc26

Please sign in to comment.