Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#245: Add Network Check for Sepolia #291

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion JoyboyCommunity/src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import '@walletconnect/react-native-compat';

import {starknetChainId, useAccount} from '@starknet-react/core';
import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import {useCallback, useEffect, useState} from 'react';
import {View} from 'react-native';

import {CHAIN_ID} from '../constants/env';
import {useTips} from '../hooks';
import {useToast} from '../hooks/modals';
import {useDialog, useToast} from '../hooks/modals';
import {Router} from './Router';

SplashScreen.preventAutoHideAsync();
Expand All @@ -18,6 +20,29 @@ export default function App() {
const tips = useTips();
const {showToast} = useToast();

const {showDialog, hideDialog} = useDialog();

const account = useAccount();

useEffect(() => {
const chainId = account.chainId ? starknetChainId(account.chainId) : undefined;

if (chainId) {
if (chainId !== CHAIN_ID) {
showDialog({
title: 'Wrong Network',
description:
'Joyboy currently only supports the Starknet Sepolia network. Please switch to the Sepolia network to continue.',
buttons: [],
});
} else {
hideDialog();
}
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [account.chainId]);

useEffect(() => {
(async () => {
try {
Expand Down
Loading