Update swap button

This commit is contained in:
armaniferrante 2021-09-03 11:55:07 -07:00
parent 7f6771d600
commit 634fdd435e
No known key found for this signature in database
GPG Key ID: 58BEF301E91F7828
2 changed files with 13 additions and 1 deletions

View File

@ -45,6 +45,7 @@ import {
refreshAccountInfo,
useSolanaExplorerUrlSuffix,
} from '../utils/connection';
import { useRegion } from '../utils/region';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import { serumMarkets, priceStore } from '../utils/markets';
import { swapApiRequest } from '../utils/swap/api';
@ -118,6 +119,7 @@ export default function BalancesList() {
const isExtensionWidth = useIsExtensionWidth();
// Dummy var to force rerenders on demand.
const [, setForceUpdate] = useState(false);
const region = useRegion();
const selectedAccount = accounts.find((a) => a.isSelected);
const allTokensLoaded = loaded && fairsIsLoaded(publicKeys);
let sortedPublicKeys = publicKeys;
@ -272,7 +274,7 @@ export default function BalancesList() {
</IconButton>
</Tooltip>
<DomainsList open={showDomains} setOpen={setShowDomains} />
<SwapButton size={iconSize} />
{region.result && !region.result.isRestricted && <SwapButton size={iconSize} />}
<Tooltip title="Migrate Tokens" arrow>
<IconButton
size={iconSize}

10
src/utils/region.ts Normal file
View File

@ -0,0 +1,10 @@
import { useAsync } from 'react-async-hook';
const ENDPOINT = 'https://calm-hat-66c2.project-serum.workers.dev';
export function useRegion() {
return useAsync(async () => {
const resp = await fetch(ENDPOINT);
return await resp.json();
}, []);
}