Skip to content

Commit

Permalink
fix: ambient env is missing singer
Browse files Browse the repository at this point in the history
  • Loading branch information
creed-victor committed Nov 12, 2024
1 parent 60de546 commit 2ef631b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/frontend/src/contexts/CrocContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, {
import { getProvider } from '@sovryn/ethers-provider';
import { CrocEnv } from '@sovryn/sdex';

import { useAccount } from '../hooks/useAccount';
import { useCurrentChain } from '../hooks/useChainStore';

type CrocContextValue = {
Expand All @@ -26,13 +27,14 @@ export const useCrocContext = () => useContext(CrocContext) as CrocContextValue;

export const CrocContextProvider: FC<PropsWithChildren> = ({ children }) => {
const chainId = useCurrentChain();
const { account, signer } = useAccount();
const [croc, setCroc] = useState(defaultContextValue.croc);

useEffect(() => {
if (!croc) {
setCroc(new CrocEnv(getProvider(chainId)));
if (!croc && account) {
setCroc(new CrocEnv(getProvider(chainId), signer));
}
}, [croc, chainId]);
}, [croc, account, signer, chainId]);

return (
<CrocContext.Provider value={{ croc }}>{children}</CrocContext.Provider>
Expand Down

0 comments on commit 2ef631b

Please sign in to comment.