Skip to content

Commit

Permalink
fix: access to stonks resolver form without connected wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
katamarinaki committed Apr 11, 2024
1 parent 714cae7 commit 5fb1f3d
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import { Fieldset } from './StonksOrderResolverFormStyle'
import { Form } from 'modules/shared/ui/Controls/Form'
import { InputControl } from 'modules/shared/ui/Controls/Input'
import { validateAddress } from 'modules/motions/utils/validateAddress'
import { getBackendRpcUrl } from 'modules/blockChain/utils/getBackendRpcUrl'
import { getStaticRpcBatchProvider } from '@lido-sdk/providers'
import { useMemo } from 'react'

type FormData = {
txHashOrAddress: string
}

export function StonksOrderResolverForm() {
const { chainId, library } = useWeb3()
const { chainId } = useWeb3()
const router = useRouter()

const formMethods = useForm<FormData>({
Expand All @@ -31,8 +34,12 @@ export function StonksOrderResolverForm() {

const { isSubmitting } = formMethods.formState

const library = useMemo(
() => getStaticRpcBatchProvider(chainId, getBackendRpcUrl(chainId)),
[chainId],
)

const handleSubmit = async (values: FormData) => {
if (!library) return
try {
const isAddress = utils.isAddress(values.txHashOrAddress)
if (isAddress) {
Expand Down Expand Up @@ -91,7 +98,7 @@ export function StonksOrderResolverForm() {
loading={isSubmitting}
disabled={!formMethods.formState.isValid}
>
Go to order
Find order
</Button>
</Fieldset>
</Form>
Expand Down

0 comments on commit 5fb1f3d

Please sign in to comment.