Skip to content

Commit

Permalink
chore: add warning update on bridge (#188)
Browse files Browse the repository at this point in the history
Co-authored-by: Hélcio Franco <helciofranco@me.com>
  • Loading branch information
pedronauck and helciofranco authored Feb 22, 2024
1 parent 934392c commit cec8945
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/app-portal/src/systems/Core/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Pages } from '~/types';
export function Header() {
return (
<Nav>
<Nav.Desktop>
<Nav.Desktop css={{ zIndex: 10 }}>
<Nav.Logo />
<Nav.Spacer />
<Nav.Menu>
Expand All @@ -22,7 +22,7 @@ export function Header() {
</Nav.Menu>
<Nav.ThemeToggle />
</Nav.Desktop>
<Nav.Mobile>
<Nav.Mobile css={{ zIndex: 10 }}>
<Nav.MobileContent>
<Nav.Logo />
<Nav.ThemeToggle />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { FuelProvider } from '@fuel-wallet/react';
import { defaultConnectors } from '@fuel-wallet/sdk';
import {
FuelWalletConnector,
FuelWalletDevelopmentConnector,
} from '@fuel-wallet/sdk';
import type { ReactNode } from 'react';
import { IS_PREVIEW, IS_TEST } from '~/config';

Expand All @@ -19,7 +22,10 @@ export function FuelConnectProvider({ children }: ProvidersProps) {
theme={theme}
fuelConfig={{
devMode: IS_DEV,
connnectors: defaultConnectors(),
connectors: [
new FuelWalletConnector(),
new FuelWalletDevelopmentConnector(),
],
}}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { cssObj, globalCss } from '@fuel-ui/css';
import {
Box,
Button,
Dialog,
Icon,
Link,
ThemeProvider,
darkTheme,
lightTheme,
loadIcons,
setFuelThemes,
} from '@fuel-ui/react';
import type { PropsWithChildren } from 'react';
import { PropsWithChildren, useState } from 'react';

import { useQuery } from '@tanstack/react-query';
// eslint-disable-next-line import/no-unresolved
import icons from '/icons/sprite.svg';

Expand All @@ -30,10 +36,84 @@ setFuelThemes({
});

export function FuelUiProvider({ children }: PropsWithChildren) {
const [founded, setFounded] = useState(false);
const { data: isOldWallet, isLoading } = useQuery(
['network'],
async () => {
const oldWindowFuel = (window as any).fuel as any;
const fuelet = (window as any).fuelet;
if (!oldWindowFuel && !founded) {
throw new Error('No Fuel Wallet found');
}
if (!oldWindowFuel && founded) {
setFounded(true);
return;
}
const version = window.fuel?.connectorName;
return fuelet ? false : Boolean(version);
},
{
retry: 5,
retryDelay: 1000,
},
);

return (
<ThemeProvider>
{!isLoading && isOldWallet && (
<Box css={styles.dialog}>
<Box css={styles.content}>
Your wallet version is incompatible with this application. Please
update your wallet for version 0.15.2.
<Button
as="a"
size="sm"
variant="solid"
intent="primary"
href="https://chromewebstore.google.com/detail/fuel-wallet/dldjpboieedgcmpkchcjcbijingjcgok"
target="_blank"
rel="noreferrer"
>
Update Wallet
</Button>
</Box>
</Box>
)}

{globalCss(globalStyles)()}
{children}
</ThemeProvider>
);
}

const OVERLAY_HEIGHT = 100;
const OVERLAY_WIDTH = 300;

const styles = {
dialog: cssObj({
zIndex: 1,
top: 64,
bottom: 0,
left: 0,
right: 0,
position: 'fixed',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
backdropFilter: 'blur(15px)',
}),
content: cssObj({
borderRadius: '$md',
padding: '$4',
display: 'flex',
flexDirection: 'column',
gap: '$4',
width: OVERLAY_WIDTH,
minHeight: OVERLAY_HEIGHT,
maxWidth: OVERLAY_WIDTH,
maxHeight: 'none',
backgroundColor: '$cardBg',
textAlign: 'center',
boxShadow: '$md',
}),
};

0 comments on commit cec8945

Please sign in to comment.