Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunnini committed Jan 31, 2025
2 parents 72dc080 + 028b8bc commit 34887af
Show file tree
Hide file tree
Showing 6 changed files with 369 additions and 336 deletions.
53 changes: 48 additions & 5 deletions apps/extension/src/components/input/fee-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ export const FeeControl: FunctionComponent<{

const [isModalOpen, setIsModalOpen] = useState(false);

const isShowingEstimatedFee = isForEVMTx && !!gasSimulator?.gasEstimated;
// EVM 트랜잭션의 경우, 외부에서 fee를 설정한 경우를 구분하기 위해서 사용
const isFeeSetByUser = isForEVMTx && feeConfig.type !== "manual";

// gasAdjustment와 gasEstimated를 사용해 계산된 값을 보여주는 경우
const isShowingFeeWithGasEstimated =
!!gasSimulator?.enabled && !!gasSimulator?.gasEstimated && isFeeSetByUser;

return (
<Box>
Expand Down Expand Up @@ -274,18 +279,40 @@ export const FeeControl: FunctionComponent<{
})()
.map((fee) =>
fee
.sub(
new Dec(feeConfig.l1DataFee?.toString() || "0")
)
.quo(
new Dec(
isShowingEstimatedFee ? gasConfig?.gas || 1 : 1
isShowingFeeWithGasEstimated
? gasConfig?.gas || 1
: 1
)
)
.mul(
new Dec(
isShowingEstimatedFee
isShowingFeeWithGasEstimated
? gasSimulator?.gasEstimated || 1
: 1
)
)
.mul(
new Dec(
isShowingFeeWithGasEstimated
? gasSimulator?.gasAdjustment || 1
: 1
)
)
.add(
new Dec(feeConfig.l1DataFee?.toString() || "0")
)
.add(
isFeeSetByUser
? new Dec(0)
: new Dec(
feeConfig.l1DataFee?.toString() || "0"
) // evm fee가 외부에서 설정된 경우, fee = gasLimit * gasPrice이므로 l1DataFee를 더해줘야 함
)
.maxDecimals(6)
.inequalitySymbol(true)
.trim(true)
Expand Down Expand Up @@ -320,18 +347,34 @@ export const FeeControl: FunctionComponent<{
} else {
const price = priceStore.calculatePrice(
fee
.sub(new Dec(feeConfig.l1DataFee?.toString() || "0"))
.quo(
new Dec(
isShowingEstimatedFee ? gasConfig?.gas || 1 : 1
isShowingFeeWithGasEstimated
? gasConfig?.gas || 1
: 1
)
)
.mul(
new Dec(
isShowingEstimatedFee
isShowingFeeWithGasEstimated
? gasSimulator?.gasEstimated || 1
: 1
)
)
.mul(
new Dec(
isShowingFeeWithGasEstimated
? gasSimulator?.gasAdjustment || 1
: 1
)
)
.add(new Dec(feeConfig.l1DataFee?.toString() || "0"))
.add(
isFeeSetByUser
? new Dec(0)
: new Dec(feeConfig.l1DataFee?.toString() || "0")
)
);
if (price) {
if (!total) {
Expand Down
Loading

0 comments on commit 34887af

Please sign in to comment.