Skip to content

Commit

Permalink
feat(idea/frontend): drop is network data available request (#1632)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitayutanov authored Aug 26, 2024
1 parent b525485 commit d46609b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
12 changes: 2 additions & 10 deletions idea/frontend/src/app/providers/chain/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ProviderProps, useApi } from '@gear-js/react-hooks';
import { useEffect, useState } from 'react';

import { RpcMethods } from '@/shared/config';
import { GENESIS, RpcMethods } from '@/shared/config';
import { rpcService } from '@/shared/services/rpcService';

import { ChainContext } from './Context';
Expand All @@ -11,19 +11,11 @@ const { Provider } = ChainContext;
const ChainProvider = ({ children }: ProviderProps) => {
const { api } = useApi();
const genesis = api?.genesisHash.toHex();
const isDevChain = genesis ? genesis !== GENESIS.MAINNET && genesis !== GENESIS.TESTNET : undefined;

const [isDevChain, setIsDevChain] = useState<boolean>();
const [isTestBalanceAvailable, setIsTestBalanceAvailable] = useState<boolean>();
const isChainRequestReady = isDevChain !== undefined && isTestBalanceAvailable !== undefined;

useEffect(() => {
setIsDevChain(undefined);

if (!genesis) return;

rpcService.callRPC<boolean>(RpcMethods.NetworkData, { genesis }).then(({ result }) => setIsDevChain(!result));
}, [genesis]);

useEffect(() => {
setIsTestBalanceAvailable(undefined);

Expand Down
1 change: 0 additions & 1 deletion idea/frontend/src/shared/config/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ enum RpcMethods {
AddMetadata = 'meta.add',
GetMetadata = 'meta.get',
GetTestBalance = 'testBalance.get',
NetworkData = 'networkData.available',
TestBalanceAvailable = 'testBalance.available',
}

Expand Down

0 comments on commit d46609b

Please sign in to comment.