mirror of
https://github.com/kremalicious/blog.git
synced 2025-02-14 21:10:25 +01:00
ens tweaks
This commit is contained in:
parent
70f091368d
commit
0ae8161b34
@ -9,7 +9,10 @@ export default {
|
|||||||
mastodon: 'https://mas.to/@krema',
|
mastodon: 'https://mas.to/@krema',
|
||||||
github: 'https://github.com/kremalicious',
|
github: 'https://github.com/kremalicious',
|
||||||
bitcoin: '171qDmKEXm9YBgBLXyGjjPvopP5o9htQ1V',
|
bitcoin: '171qDmKEXm9YBgBLXyGjjPvopP5o9htQ1V',
|
||||||
ether: '0xf50F267b5689b005FE107cfdb34619f24c014457'
|
ether: {
|
||||||
|
ens: 'krema.eth',
|
||||||
|
address: '0xf50F267b5689b005FE107cfdb34619f24c014457'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
rss: '/feed.xml',
|
rss: '/feed.xml',
|
||||||
jsonfeed: '/feed.json',
|
jsonfeed: '/feed.json',
|
||||||
|
@ -8,6 +8,8 @@ export function Conversion({ amount }: { amount: string }): ReactElement {
|
|||||||
const [dollar, setDollar] = useState('0.00')
|
const [dollar, setDollar] = useState('0.00')
|
||||||
const [euro, setEuro] = useState('0.00')
|
const [euro, setEuro] = useState('0.00')
|
||||||
|
|
||||||
|
console.log(selectedToken?.price)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedToken?.price || !amount) {
|
if (!selectedToken?.price || !amount) {
|
||||||
setDollar('0.00')
|
setDollar('0.00')
|
||||||
@ -21,7 +23,7 @@ export function Conversion({ amount }: { amount: string }): ReactElement {
|
|||||||
const euro = eur ? (Number(amount) * eur).toFixed(2) : '0.00'
|
const euro = eur ? (Number(amount) * eur).toFixed(2) : '0.00'
|
||||||
setDollar(dollar)
|
setDollar(dollar)
|
||||||
setEuro(euro)
|
setEuro(euro)
|
||||||
}, [selectedToken, amount])
|
}, [selectedToken?.price, amount])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
max-width: 25rem;
|
max-width: 25rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.rainbowkit button > div {
|
.rainbowkit button > div {
|
||||||
|
@ -63,7 +63,7 @@ export default function Web3Form(): ReactElement {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className={styles.disclaimer}>
|
<div className={styles.disclaimer}>
|
||||||
Sends tokens to this address, suitable for any ERC-20 token.
|
Sends tokens to my account, suitable for any ERC-20 token.
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { parseUnits } from 'viem'
|
import { parseUnits } from 'viem'
|
||||||
import { useContractWrite, usePrepareContractWrite } from 'wagmi'
|
import { useContractWrite, useEnsAddress, usePrepareContractWrite } from 'wagmi'
|
||||||
import siteConfig from '@config/blog.config'
|
import siteConfig from '@config/blog.config'
|
||||||
import { abiErc20Transfer } from './abiErc20Transfer'
|
import { abiErc20Transfer } from './abiErc20Transfer'
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
@ -13,15 +13,16 @@ export function SendPrepareErc20({
|
|||||||
setSendFormData: any
|
setSendFormData: any
|
||||||
}) {
|
}) {
|
||||||
const { selectedToken } = useTokens()
|
const { selectedToken } = useTokens()
|
||||||
|
const { data: to } = useEnsAddress({
|
||||||
|
name: siteConfig.author.ether.ens,
|
||||||
|
chainId: 1
|
||||||
|
})
|
||||||
|
|
||||||
const { config } = usePrepareContractWrite({
|
const { config } = usePrepareContractWrite({
|
||||||
address: selectedToken?.address,
|
address: selectedToken?.address,
|
||||||
abi: abiErc20Transfer,
|
abi: abiErc20Transfer,
|
||||||
functionName: 'transfer',
|
functionName: 'transfer',
|
||||||
args: [
|
args: [to || undefined, parseUnits(amount, selectedToken?.decimals || 18)]
|
||||||
siteConfig.author.ether,
|
|
||||||
parseUnits(amount, selectedToken?.decimals || 18)
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { parseEther } from 'viem'
|
import { parseEther } from 'viem'
|
||||||
import {
|
import {
|
||||||
|
useEnsAddress,
|
||||||
useNetwork,
|
useNetwork,
|
||||||
usePrepareSendTransaction,
|
usePrepareSendTransaction,
|
||||||
useSendTransaction
|
useSendTransaction
|
||||||
@ -15,9 +16,13 @@ export function SendPrepareNative({
|
|||||||
setSendFormData: any
|
setSendFormData: any
|
||||||
}) {
|
}) {
|
||||||
const { chain } = useNetwork()
|
const { chain } = useNetwork()
|
||||||
|
const { data: to } = useEnsAddress({
|
||||||
|
name: siteConfig.author.ether.ens,
|
||||||
|
chainId: 1
|
||||||
|
})
|
||||||
const { config } = usePrepareSendTransaction({
|
const { config } = usePrepareSendTransaction({
|
||||||
chainId: chain?.id,
|
chainId: chain?.id,
|
||||||
to: siteConfig.author.ether,
|
to: to || undefined,
|
||||||
value: parseEther(amount)
|
value: parseEther(amount)
|
||||||
})
|
})
|
||||||
const {
|
const {
|
||||||
|
@ -30,10 +30,10 @@ export function useTokens() {
|
|||||||
// Set default token data to first item,
|
// Set default token data to first item,
|
||||||
// which most of time is native token
|
// which most of time is native token
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!tokens?.[0]?.address) return
|
if (!tokens?.[0]?.chainId) return
|
||||||
|
|
||||||
setSelectedToken(tokens?.[0])
|
setSelectedToken(tokens?.[0])
|
||||||
}, [tokens?.[0]?.address])
|
}, [tokens?.[0]?.chainId])
|
||||||
|
|
||||||
return { ...fetchResults, selectedToken, setSelectedToken }
|
return { ...fetchResults, selectedToken, setSelectedToken }
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,12 @@ import CodeCopy from '@components/CopyCode.astro'
|
|||||||
border-top: 1px solid var(--border-color);
|
border-top: 1px solid var(--border-color);
|
||||||
border-bottom: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.metaText {
|
||||||
|
display: block;
|
||||||
|
font-size: var(--font-size-mini);
|
||||||
|
margin: calc(var(--spacer) / 6) 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<LayoutBase title="Say Thanks">
|
<LayoutBase title="Say Thanks">
|
||||||
@ -68,14 +74,14 @@ import CodeCopy from '@components/CopyCode.astro'
|
|||||||
<h3 class="subTitle">Send Magic Internet Money</h3>
|
<h3 class="subTitle">Send Magic Internet Money</h3>
|
||||||
|
|
||||||
<section class="section">
|
<section class="section">
|
||||||
If you like what I do and want to support me in a decentralized way, you
|
If you like what I do and want to support me in a decentralized way,
|
||||||
can send me some Ether or Bitcoin.
|
send me some Ether, ERC-20 token, or Bitcoin.
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="section highlight">
|
<section class="section highlight">
|
||||||
<h4 class="titleCoin"><Wallet /> Web3 Wallet</h4>
|
<h4 class="titleCoin"><Wallet /> Web3 Wallet</h4>
|
||||||
<Web3 client:load />
|
<Web3 client:load />
|
||||||
<CodeCopy address={config.author.ether} />
|
<CodeCopy address={config.author.ether.ens} />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="section">
|
<section class="section">
|
||||||
|
Loading…
Reference in New Issue
Block a user