diff --git a/src/components/Signin.tsx b/src/components/Signin.tsx index 47b1e9d..b94a786 100644 --- a/src/components/Signin.tsx +++ b/src/components/Signin.tsx @@ -1,37 +1,45 @@ -import { FC } from 'react' -import useGlobalStore from '@/stores/globalStore' -import { Medusa } from '@medusa-network/medusa-sdk' -import { CHAIN_CONFIG } from '@/lib/consts' -import { useNetwork, useSigner } from 'wagmi' +import { FC } from "react"; +import useGlobalStore from "@/stores/globalStore"; +import { Medusa } from "@medusa-network/medusa-sdk"; +import { CHAIN_CONFIG } from "@/lib/consts"; +import { useNetwork, useSigner } from "wagmi"; const Signin: FC = () => { - const { chain } = useNetwork() - const medusa = useGlobalStore((state) => state.medusa) - const updateMedusa = useGlobalStore((state) => state.updateMedusa) - const { data: signer } = useSigner() + const { chain } = useNetwork(); + const medusa = useGlobalStore((state) => state.medusa); + const updateMedusa = useGlobalStore((state) => state.updateMedusa); + const { data: signer } = useSigner(); const signMessage = async () => { - if (!signer) return - const medusa = await Medusa.init(CHAIN_CONFIG[chain?.id]?.oracleContractAddress, signer) - await medusa.signForKeypair() - updateMedusa(medusa) - } + if (!signer) return; + const medusa = await Medusa.init( + CHAIN_CONFIG[chain?.id]?.oracleContractAddress, + signer, + "localhost", + ); + await medusa.signForKeypair(); + updateMedusa(medusa); + }; if (medusa?.keypair) { - return + ); + } + + return ( + - } - - return -} + ); +}; export default Signin; diff --git a/src/hooks/useSwitchChain.tsx b/src/hooks/useSwitchChain.tsx index aff777b..7621385 100644 --- a/src/hooks/useSwitchChain.tsx +++ b/src/hooks/useSwitchChain.tsx @@ -1,38 +1,42 @@ -import { useSwitchNetwork } from 'wagmi'; -import { getProvider } from '@wagmi/core'; -import { VoidSigner } from 'ethers'; -import { Medusa } from '@medusa-network/medusa-sdk'; +import { useSwitchNetwork } from "wagmi"; +import { getProvider } from "@wagmi/core"; +import { VoidSigner } from "ethers"; +import { Medusa } from "@medusa-network/medusa-sdk"; -import useGlobalStore from '@/stores/globalStore' -import { CHAIN_CONFIG } from '@/lib/consts'; -import { useCallback } from 'react'; +import useGlobalStore from "@/stores/globalStore"; +import { CHAIN_CONFIG } from "@/lib/consts"; +import { useCallback } from "react"; export default function useSwitchChain() { - const { switchNetworkAsync } = useSwitchNetwork() + const { switchNetworkAsync } = useSwitchNetwork(); - const medusa = useGlobalStore((state) => state.medusa) - const updateMedusa = useGlobalStore((state) => state.updateMedusa) - const updateListings = useGlobalStore((state) => state.updateListings) - const updateSales = useGlobalStore((state) => state.updateSales) - const updateDecryptions = useGlobalStore((state) => state.updateDecryptions) + const medusa = useGlobalStore((state) => state.medusa); + const updateMedusa = useGlobalStore((state) => state.updateMedusa); + const updateListings = useGlobalStore((state) => state.updateListings); + const updateSales = useGlobalStore((state) => state.updateSales); + const updateDecryptions = useGlobalStore((state) => state.updateDecryptions); return useCallback( async (chainId: number) => { - await switchNetworkAsync?.(chainId) + await switchNetworkAsync?.(chainId); - updateListings([]) - updateSales([]) - updateDecryptions([]) + updateListings([]); + updateSales([]); + updateDecryptions([]); if (medusa) { const newMedusa = await Medusa.init( CHAIN_CONFIG[chainId].oracleContractAddress, - new VoidSigner(await medusa.signer.getAddress(), getProvider({ chainId })) - ) - newMedusa.setKeypair(medusa.keypair) - updateMedusa(newMedusa) + new VoidSigner( + await medusa.signer.getAddress(), + getProvider({ chainId }), + ), + "localhost", + ); + newMedusa.setKeypair(medusa.keypair); + updateMedusa(newMedusa); } - }, [switchNetworkAsync] - ) + }, + [switchNetworkAsync], + ); } -