From 8c63ec0c4712ccc19b2e2e6c8b7765e19713026f Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 13 Mar 2024 10:37:05 +0000 Subject: [PATCH] fixes --- src/features/Web3/components/Preview/Preview.tsx | 2 +- .../Web3/components/Success/Success.module.css | 5 +---- src/features/Web3/components/Success/Success.tsx | 11 ++--------- src/features/Web3/hooks/useSend/send.ts | 2 +- src/features/Web3/hooks/useSend/useSend.tsx | 9 ++++++--- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/features/Web3/components/Preview/Preview.tsx b/src/features/Web3/components/Preview/Preview.tsx index 30c42d66..b9f3c5f9 100644 --- a/src/features/Web3/components/Preview/Preview.tsx +++ b/src/features/Web3/components/Preview/Preview.tsx @@ -12,7 +12,7 @@ export function Preview() { const { ens } = siteConfig.author.ether const { data: to } = useEnsAddress({ name: ens, chainId: 1 }) const { data: ensResolved } = useEnsName({ - address: to as `0x${string}` | undefined, + address: to as `0x${string}`, chainId: 1 }) diff --git a/src/features/Web3/components/Success/Success.module.css b/src/features/Web3/components/Success/Success.module.css index 34da4bee..a766cf34 100644 --- a/src/features/Web3/components/Success/Success.module.css +++ b/src/features/Web3/components/Success/Success.module.css @@ -10,6 +10,7 @@ .actions { display: flex; justify-content: center; + margin-top: 2rem; } .actions button { @@ -17,7 +18,3 @@ height: 45px; padding: 0; } - -.success code { - font-size: var(--font-size-small); -} diff --git a/src/features/Web3/components/Success/Success.tsx b/src/features/Web3/components/Success/Success.tsx index afcb9f9d..5c29418f 100644 --- a/src/features/Web3/components/Success/Success.tsx +++ b/src/features/Web3/components/Success/Success.tsx @@ -1,5 +1,4 @@ -import { $txHash, $isInitSend } from '@features/Web3/stores' -import { useStore } from '@nanostores/react' +import { $isInitSend } from '@features/Web3/stores' import styles from './Success.module.css' import { useAccount } from 'wagmi' import { ExplorerLink } from './ExplorerLink' @@ -9,7 +8,6 @@ const description = `Your transaction is on its way. You can check the status on export function Success() { const account = useAccount() - const txHash = useStore($txHash) const explorerName = account?.chain?.blockExplorers?.default.name const explorerUrl = account?.chain?.blockExplorers?.default.url @@ -22,18 +20,13 @@ export function Success() { {description}{' '} {explorerName}.

-

- - {txHash} - -

diff --git a/src/features/Web3/hooks/useSend/send.ts b/src/features/Web3/hooks/useSend/send.ts index b34bdd58..84c92b3d 100644 --- a/src/features/Web3/hooks/useSend/send.ts +++ b/src/features/Web3/hooks/useSend/send.ts @@ -8,7 +8,7 @@ export async function send( config: UseConfigReturnType, selectedToken: GetToken | undefined, amount: string | undefined, - to: `0x${string}` | undefined, + to: `0x${string}` | null | undefined, chainId: number | undefined ) { if (!selectedToken?.decimals || !amount || !to) return diff --git a/src/features/Web3/hooks/useSend/useSend.tsx b/src/features/Web3/hooks/useSend/useSend.tsx index 34422bf2..4f6a1929 100644 --- a/src/features/Web3/hooks/useSend/useSend.tsx +++ b/src/features/Web3/hooks/useSend/useSend.tsx @@ -3,13 +3,16 @@ import { useStore } from '@nanostores/react' import { useState } from 'react' import { send } from './send' import { isUnhelpfulErrorMessage } from './isUnhelpfulErrorMessage' -import { useAccount, useConfig } from 'wagmi' +import { useAccount, useConfig, useEnsAddress } from 'wagmi' +import siteConfig from '@config/blog.config' export function useSend() { const selectedToken = useStore($selectedToken) const amount = useStore($amount) const config = useConfig() - const { address, chainId } = useAccount() + const { chainId } = useAccount() + const { ens } = siteConfig.author.ether + const { data: to } = useEnsAddress({ name: ens, chainId: 1 }) const [isLoading, setIsLoading] = useState(false) const [isError, setIsError] = useState(false) @@ -20,7 +23,7 @@ export function useSend() { setIsError(false) setError(undefined) setIsLoading(true) - const hash = await send(config, selectedToken, amount, address, chainId) + const hash = await send(config, selectedToken, amount, to, chainId) if (hash) $txHash.set(hash) } catch (error: unknown) { const errorMessage = (error as Error).message