1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-22 09:56:51 +01:00
This commit is contained in:
Matthias Kretschmann 2023-11-03 00:00:55 +00:00
parent 0728c63b17
commit 2a77163382
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 8 additions and 6 deletions

View File

@ -60,12 +60,13 @@
}
.submit {
width: calc(100% - calc(var(--spacer) / 2) - 2px);
max-width: none;
height: calc(- var(--border-width));
height: calc(var(--height) - calc(var(--border-width) * 2));
border-top-left-radius: 0;
border-top-right-radius: 0;
border: var(--border-width) solid var(--link-color);
padding-top: 0;
padding-bottom: 0;
}
@media (min-width: 40rem) {

View File

@ -5,7 +5,7 @@ import type {
SendTransactionArgs,
WriteContractPreparedArgs
} from 'wagmi/actions'
import { $selectedToken, $isInitSend } from '@features/Web3/stores'
import { $selectedToken, $isInitSend, $txHash } from '@features/Web3/stores'
import siteConfig from '@config/blog.config'
import { prepareTransaction, sendTransaction } from './actions'
import styles from './Send.module.css'
@ -16,6 +16,7 @@ export function Send({ amount }: { amount: string }) {
const { ens } = siteConfig.author.ether
const { chain } = useNetwork()
const selectedToken = useStore($selectedToken)
const txHash = useStore($txHash)
// Always resolve to address from ENS name and vice versa
// so nobody has to trust my config values.
@ -28,7 +29,6 @@ export function Send({ amount }: { amount: string }) {
const [txConfig, setTxConfig] = useState<
SendTransactionArgs | WriteContractPreparedArgs
>()
const [txHash, setTxHash] = useState<string>()
const [isLoading, setIsLoading] = useState(false)
useEffect(() => {
@ -57,7 +57,7 @@ export function Send({ amount }: { amount: string }) {
try {
setIsLoading(true)
const result = await sendTransaction(selectedToken, txConfig)
setTxHash(result?.hash)
$txHash.set(result?.hash)
setIsLoading(false)
} catch (error: unknown) {
console.error((error as Error).message)

View File

@ -1,3 +1,3 @@
export * from './tokens'
export * from './selectedToken'
export * from './isInitSend'
export * from './send'

View File

@ -1,3 +1,4 @@
import { atom } from 'nanostores'
export const $isInitSend = atom<boolean>(false)
export const $txHash = atom<string | undefined>()