Skip to content

Commit

Permalink
fix: add gas estimate for claim (#12066)
Browse files Browse the repository at this point in the history
* fix: add gas estimate for claim

* fix: run codegen

---------

Co-authored-by: nuanyang233 <nuanyang233@users.noreply.github.com>
  • Loading branch information
nuanyang233 and nuanyang233 authored Jan 23, 2025
1 parent 1bee7f7 commit f820892
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type { MouseEventHandler } from 'react'
import { useChainContext } from '@masknet/web3-hooks-base'
import { useChainContext, useNativeTokenBalance } from '@masknet/web3-hooks-base'
import { NetworkPluginID } from '@masknet/shared-base'
import { ChainId } from '@masknet/web3-shared-solana'
import { ActionButton, makeStyles } from '@masknet/theme'
import { Box, useTheme, type BoxProps } from '@mui/material'
import { Icons } from '@masknet/icons'
import { ChainBoundary, WalletConnectedBoundary, SelectProviderModal } from '@masknet/shared'
import { Trans, useLingui } from '@lingui/react/macro'
import { isGreaterThan } from '@masknet/web3-shared-base'
import { SOL_REDPACKET_CREATE_DEFAULT_GAS } from '../../constants.js'

const useStyles = makeStyles()((theme) => {
return {
Expand Down Expand Up @@ -46,6 +48,8 @@ export function OperationFooter({
const { account, chainId: currentChainId } = useChainContext<NetworkPluginID.PLUGIN_SOLANA>({ chainId })
const theme = useTheme()

const { value: nativeTokenBalance } = useNativeTokenBalance()

if (!canClaim && !canRefund && account) return null

function getObtainButton(onClick: MouseEventHandler<HTMLButtonElement>) {
Expand All @@ -56,6 +60,12 @@ export function OperationFooter({
</ActionButton>
)
}
if (nativeTokenBalance && isGreaterThan(SOL_REDPACKET_CREATE_DEFAULT_GAS, nativeTokenBalance))
return (
<ActionButton fullWidth disabled variant="roundedDark">
<Trans>Insufficient Balance for Gas Fee</Trans>
</ActionButton>
)
if (!canClaim && !canRefund) return null
if (!currentChainId) {
return (
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/locale/en-US.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/locale/ja-JP.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/locale/ko-KR.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/locale/zh-CN.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/locale/zh-TW.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f820892

Please sign in to comment.