refactor: rename fetching -> isFetchingBalances

This commit is contained in:
Ben Kremer 2022-02-10 17:16:08 +01:00
parent 2b25de2f30
commit fa72dd6577
2 changed files with 9 additions and 9 deletions

View File

@ -44,7 +44,7 @@ export default function App() {
chains, chains,
accounts, accounts,
balances, balances,
fetching, isFetchingBalances,
isInitializing, isInitializing,
setChains, setChains,
} = useWalletConnectClient(); } = useWalletConnectClient();
@ -179,7 +179,7 @@ export default function App() {
active={chains.includes(chainId)} active={chains.includes(chainId)}
/> />
))} ))}
<SConnectButton left onClick={onConnect} fetching={fetching} disabled={!chains.length}> <SConnectButton left onClick={onConnect} disabled={!chains.length}>
{"Connect"} {"Connect"}
</SConnectButton> </SConnectButton>
</SButtonContainer> </SButtonContainer>
@ -196,7 +196,7 @@ export default function App() {
key={account} key={account}
active={true} active={true}
chainData={chainData} chainData={chainData}
fetching={fetching} fetching={isFetchingBalances}
address={address} address={address}
chainId={chainId} chainId={chainId}
balances={balances} balances={balances}

View File

@ -30,11 +30,11 @@ interface IContext {
connect: (pairing?: { topic: string }) => Promise<void>; connect: (pairing?: { topic: string }) => Promise<void>;
disconnect: () => Promise<void>; disconnect: () => Promise<void>;
isInitializing: boolean; isInitializing: boolean;
fetching: boolean;
chains: string[]; chains: string[];
pairings: string[]; pairings: string[];
accounts: string[]; accounts: string[];
balances: AccountBalances; balances: AccountBalances;
isFetchingBalances: boolean;
setChains: any; setChains: any;
} }
@ -51,7 +51,7 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac
const [pairings, setPairings] = useState<string[]>([]); const [pairings, setPairings] = useState<string[]>([]);
const [session, setSession] = useState<SessionTypes.Created>(); const [session, setSession] = useState<SessionTypes.Created>();
const [fetching, setFetching] = useState(false); const [isFetchingBalances, setIsFetchingBalances] = useState(false);
const [isInitializing, setIsInitializing] = useState(false); const [isInitializing, setIsInitializing] = useState(false);
const [balances, setBalances] = useState<AccountBalances>({}); const [balances, setBalances] = useState<AccountBalances>({});
@ -67,7 +67,7 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac
}; };
const getAccountBalances = async (_accounts: string[]) => { const getAccountBalances = async (_accounts: string[]) => {
setFetching(true); setIsFetchingBalances(true);
try { try {
const arr = await Promise.all( const arr = await Promise.all(
_accounts.map(async account => { _accounts.map(async account => {
@ -86,7 +86,7 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} finally { } finally {
setFetching(false); setIsFetchingBalances(false);
} }
}; };
@ -249,9 +249,9 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac
const value = useMemo( const value = useMemo(
() => ({ () => ({
pairings, pairings,
fetching,
isInitializing, isInitializing,
balances, balances,
isFetchingBalances,
accounts, accounts,
chains, chains,
client, client,
@ -262,9 +262,9 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac
}), }),
[ [
pairings, pairings,
fetching,
isInitializing, isInitializing,
balances, balances,
isFetchingBalances,
accounts, accounts,
chains, chains,
client, client,