Indicate more clearly that it takes SOL to add a token to your wallet
This commit is contained in:
parent
584684b4f2
commit
2d2e221c37
|
@ -12,6 +12,7 @@ import { useUpdateTokenName } from '../utils/tokens/names';
|
||||||
import { useAsyncData } from '../utils/fetch-loop';
|
import { useAsyncData } from '../utils/fetch-loop';
|
||||||
import LoadingIndicator from './LoadingIndicator';
|
import LoadingIndicator from './LoadingIndicator';
|
||||||
import { useSendTransaction } from '../utils/notifications';
|
import { useSendTransaction } from '../utils/notifications';
|
||||||
|
import { useBalanceInfo } from '../utils/wallet';
|
||||||
|
|
||||||
const feeFormat = new Intl.NumberFormat(undefined, {
|
const feeFormat = new Intl.NumberFormat(undefined, {
|
||||||
minimumFractionDigits: 6,
|
minimumFractionDigits: 6,
|
||||||
|
@ -30,6 +31,10 @@ export default function AddTokenDialog({ open, onClose }) {
|
||||||
let [tokenName, setTokenName] = useState('');
|
let [tokenName, setTokenName] = useState('');
|
||||||
let [tokenSymbol, setTokenSymbol] = useState('');
|
let [tokenSymbol, setTokenSymbol] = useState('');
|
||||||
let [sendTransaction, sending] = useSendTransaction();
|
let [sendTransaction, sending] = useSendTransaction();
|
||||||
|
let balanceInfo = useBalanceInfo(wallet.account.publicKey);
|
||||||
|
|
||||||
|
let { amount } = balanceInfo || {};
|
||||||
|
let noSol = amount === 0;
|
||||||
|
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
let mint = new PublicKey(mintAddress);
|
let mint = new PublicKey(mintAddress);
|
||||||
|
@ -81,8 +86,8 @@ export default function AddTokenDialog({ open, onClose }) {
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={onClose}>Cancel</Button>
|
<Button onClick={onClose}>Cancel</Button>
|
||||||
<Button type="submit" color="primary" disabled={sending}>
|
<Button type="submit" color="primary" disabled={sending || noSol}>
|
||||||
Add
|
{noSol ? 'Requires SOL Balance' : 'Add'}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</DialogForm>
|
</DialogForm>
|
||||||
|
|
Loading…
Reference in New Issue