1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-22 09:13:35 +01:00
This commit is contained in:
Matthias Kretschmann 2024-03-13 10:37:05 +00:00
parent feee0c678b
commit 8c63ec0c47
Signed by: m
GPG Key ID: 606EEEF3C479A91F
5 changed files with 11 additions and 18 deletions

View File

@ -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
})

View File

@ -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);
}

View File

@ -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}{' '}
<ExplorerLink url={explorerUrl}>{explorerName}</ExplorerLink>.
</p>
<p>
<ExplorerLink url={explorerUrl}>
<code>{txHash}</code>
</ExplorerLink>
</p>
<footer className={styles.actions}>
<button
onClick={() => $isInitSend.set(false)}
className="btn btn-primary"
>
Reset
Close
</button>
</footer>
</div>

View File

@ -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

View File

@ -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