Skip to content

Commit

Permalink
#245: Add Network Check for Sepolia (#291)
Browse files Browse the repository at this point in the history
* #245: add network check sepolia

* Applying Code Review

* Fix network

---------

Co-authored-by: lauchaves <lauchavesmendez@gmail.comA>
Co-authored-by: Uğur Eren <contact@ugureren.net>
  • Loading branch information
3 people authored Jul 25, 2024
1 parent 4a043c5 commit dd3bcb9
Showing 1 changed file with 26 additions and 1 deletion.
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

0 comments on commit dd3bcb9

Please sign in to comment.