Skip to content

Commit 04baed7

Browse files
committed
Add action
Update validation.
1 parent 7b75d21 commit 04baed7

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

app/components/Views/confirmations/hooks/alerts/useInsufficientPayTokenBalanceAlert.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export function useInsufficientPayTokenBalanceAlert({
2727
const totals = useTransactionPayTotals();
2828
const formatFiat = useFiatFormatter({ currency: 'usd' });
2929
const isLoading = useIsTransactionPayLoading();
30+
const isSourceGasFeeToken = totals?.fees.isSourceGasFeeToken ?? false;
3031

3132
const sourceChainId = payToken?.chainId ?? '0x0';
3233

@@ -64,20 +65,20 @@ export function useInsufficientPayTokenBalanceAlert({
6465
}
6566

6667
return new BigNumber(totals?.sourceAmount.raw ?? '0').plus(
67-
isPayTokenNative
68+
isPayTokenNative || isSourceGasFeeToken
6869
? new BigNumber(totals?.fees.sourceNetwork.max.raw ?? '0')
6970
: '0',
7071
);
71-
}, [isLoading, isPayTokenNative, totals]);
72+
}, [isLoading, isPayTokenNative, isSourceGasFeeToken, totals]);
7273

7374
const totalSourceAmountUsd = useMemo(
7475
() =>
7576
new BigNumber(totals?.sourceAmount.usd ?? '0').plus(
76-
isPayTokenNative
77+
isPayTokenNative || isSourceGasFeeToken
7778
? new BigNumber(totals?.fees.sourceNetwork.max.usd ?? '0')
7879
: '0',
7980
),
80-
[isPayTokenNative, totals],
81+
[isPayTokenNative, isSourceGasFeeToken, totals],
8182
);
8283

8384
const targetAmountUsd = useMemo(() => {
@@ -104,9 +105,11 @@ export function useInsufficientPayTokenBalanceAlert({
104105
() =>
105106
payToken &&
106107
!isPayTokenNative &&
108+
!isSourceGasFeeToken &&
107109
totalSourceNetworkFeeRaw.isGreaterThan(nativeToken?.balanceRaw ?? '0'),
108110
[
109111
isPayTokenNative,
112+
isSourceGasFeeToken,
110113
nativeToken?.balanceRaw,
111114
payToken,
112115
totalSourceNetworkFeeRaw,

app/components/Views/confirmations/utils/transaction-pay.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import {
1111
TransactionPayRequiredToken,
1212
TransactionPaymentToken,
1313
} from '@metamask/transaction-pay-controller';
14-
import { getNativeTokenAddress } from './asset';
15-
import { strings } from '../../../../../locales/i18n';
1614
import { BigNumber } from 'bignumber.js';
1715
import { isTestNet } from '../../../../util/networks';
1816

@@ -126,22 +124,8 @@ export function getAvailableTokens({
126124
payToken?.address.toLowerCase() === token.address.toLowerCase() &&
127125
payToken?.chainId === token.chainId;
128126

129-
const nativeTokenAddress = getNativeTokenAddress(token.chainId as Hex);
130-
131-
const nativeToken = tokens.find(
132-
(t) => t.address === nativeTokenAddress && t.chainId === token.chainId,
133-
);
134-
135-
const disabled = new BigNumber(nativeToken?.balance ?? 0).isZero();
136-
137-
const disabledMessage = disabled
138-
? strings('pay_with_modal.no_gas')
139-
: undefined;
140-
141127
return {
142128
...token,
143-
disabled,
144-
disabledMessage,
145129
isSelected,
146130
};
147131
});

app/core/Engine/messengers/transaction-pay-controller-messenger/transaction-pay-controller-messenger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function getTransactionPayControllerMessenger(
3535
'TokenListController:getState',
3636
'TokenRatesController:getState',
3737
'TokensController:getState',
38+
'TransactionController:getGasFeeTokens',
3839
'TransactionController:getState',
3940
'TransactionController:updateTransaction',
4041
],

0 commit comments

Comments
 (0)