Skip to content

Commit

Permalink
#245: add network check sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
lauchaves authored and lauchaves committed Jul 25, 2024
1 parent 63b9ef2 commit 2f850a3
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions JoyboyCommunity/src/modules/TipModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {NDKEvent} from '@nostr-dev-kit/ndk';
import {mainnet, sepolia} from '@starknet-react/chains';
import {useAccount} from '@starknet-react/core';
import {forwardRef, useState} from 'react';
import {forwardRef, useEffect, useState} from 'react';
import {View} from 'react-native';
import {CallData, uint256} from 'starknet';

import {Avatar, Button, Input, Modalize, Picker, Text} from '../../components';
import {ESCROW_ADDRESSES} from '../../constants/contracts';
import {CHAIN_ID} from '../../constants/env';
import {CHAIN_ID, NETWORK_NAME} from '../../constants/env';
import {DEFAULT_TIMELOCK, Entrypoint} from '../../constants/misc';
import {TOKENS, TokenSymbol} from '../../constants/tokens';
import {useProfile, useStyles, useWaitConnection} from '../../hooks';
Expand Down Expand Up @@ -45,6 +46,26 @@ export const TipModal = forwardRef<Modalize, TipModalProps>(

const {showDialog, hideDialog} = useDialog();

useEffect(() => {
const handleChainIdChange = () => {
const chainId = account.chainId;
const currentChainId = NETWORK_NAME === 'SN_MAIN' ? mainnet.id : sepolia.id;

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

handleChainIdChange();
}, [account.chainId, hideDialog, showDialog]);

const isActive = !!amount && !!token;

const onTipPress = async () => {
Expand Down

0 comments on commit 2f850a3

Please sign in to comment.