Skip to content

Commit

Permalink
🩹 always use optimism
Browse files Browse the repository at this point in the history
  • Loading branch information
sebipap committed Sep 28, 2023
1 parent 16c365c commit 871c497
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/getEXA/SelectRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const SelectRoute = () => {
<Typography fontSize={14} fontWeight={500}>
{t('Network')}:
</Typography>
<ChainSelector disabled={!walletAddress} />
<ChainSelector disabled />
</Box>
{chain && (
<Box ml="auto" display="flex" alignItems="center" gap={1} fontSize="14px">
Expand Down
21 changes: 14 additions & 7 deletions contexts/GetEXAContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from 'viem';
import * as wagmiChains from 'wagmi/chains';

import { useNetwork, useSignTypedData, useWalletClient } from 'wagmi';
import { useSignTypedData, useWalletClient } from 'wagmi';
import { optimism } from 'wagmi/chains';

import {
Expand Down Expand Up @@ -129,7 +129,7 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {
const [activeRoutes, setActiveRoutes] = useState<ContextValues['activeRoutes']>();
const [bridgeStatus, setBridgeStatus] = useState<ContextValues['bridgeStatus']>();

const { chain: activeChain } = useNetwork();
// const { chain: activeChain } = useNetwork();
const { walletAddress, opts, chain: appChain } = useWeb3();

const { data: walletClient } = useWalletClient({ chainId: chain?.chainId });
Expand Down Expand Up @@ -193,6 +193,7 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {
setRoutes([]);
setRoute(undefined);
setSocketError({ message: t('Error fetching routes from socket'), status: true });
console.log('196', e);
}
}, [asset, chain, qtyIn, swapper, t, walletAddress]);

Expand Down Expand Up @@ -235,10 +236,10 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {
setTX({ status: status ? 'success' : 'error', hash: transactionHash });
}
}
setTXStep(TXStep.CONFIRM);
}
setTXStep(TXStep.CONFIRM);
} catch (err) {
setTXError({ message: t('Error approving token'), status: true });
console.log('245', err);
}
}, [asset, erc20, isMultiSig, isPermit, opts, permit2, qtyIn, swapper, t, walletAddress]);

Expand Down Expand Up @@ -282,7 +283,7 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {
}).then(splitSignature);

const permit = {
owner: walletAddress,
// owner: walletAddress,
value,
deadline,
...{ v, r: r as Hex, s: s as Hex },
Expand Down Expand Up @@ -384,6 +385,7 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {
setTXError({ status: true, message: handleOperationError(err) });
}
setTXStep(TXStep.APPROVE);
console.log('392', err);
}
}, [asset?.symbol, chain?.chainId, erc20, opts, route, screen, walletAddress, walletClient]);

Expand All @@ -405,6 +407,7 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {
} catch (err) {
setTXError({ status: true, message: handleOperationError(err) });
setTXStep(TXStep.CONFIRM);
console.log('414', err);
}
}, [destinationCallData, route, txStep, walletClient]);

Expand Down Expand Up @@ -437,6 +440,7 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {
switch (permit.type) {
case 'permit': {
const args = [erc20.address, permit.value, txData, minEXA, keepETH] as const;
console.log({ args });
const gas = await swapper.estimateGas.swap(args, opts);
hash = await swapper.write.swap(args, {
...opts,
Expand All @@ -463,6 +467,7 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {
}
} catch (err) {
setTXError({ status: true, message: handleOperationError(err) });
console.log('474', err);
} finally {
setTXStep(undefined);
}
Expand All @@ -489,6 +494,7 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {
setScreen(Screen.TX_STATUS);
} catch (err) {
setTXError({ status: true, message: handleOperationError(err) });
console.log('501', err);
} finally {
setTXStep(undefined);
}
Expand All @@ -513,6 +519,7 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {
setBridgeStatus(response);
} catch (err) {
setSocketError({ status: true, message: handleOperationError(err) });
console.log('526', err);
}
};
const interval = setInterval(() => {
Expand All @@ -532,10 +539,10 @@ export const GetEXAProvider: FC<PropsWithChildren> = ({ children }) => {

useEffect(() => {
if (!chains) return;
const id = activeChain?.id || optimism.id;
const id = optimism.id;
const activeNetwork = chains.find(({ chainId }) => chainId === id);
if (activeNetwork) setChain(activeNetwork);
}, [activeChain?.id, chains, setChain]);
}, [chains, setChain]);

useEffect(() => {
setAsset(chainAssets[0]);
Expand Down

0 comments on commit 871c497

Please sign in to comment.