Skip to content

Commit

Permalink
Update viem imports and remove console.log statement
Browse files Browse the repository at this point in the history
  • Loading branch information
sasicodes committed Jan 25, 2024
1 parent a38e647 commit 30768a7
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions apps/web/src/components/Create/IrysInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ import {
} from '@tape.xyz/ui'
import React, { useEffect, useState } from 'react'
import toast from 'react-hot-toast'
import { formatEther, formatUnits, parseEther, parseUnits } from 'viem'
import {
formatEther,
formatGwei,
formatUnits,
parseEther,
parseUnits
} from 'viem'
import { useAccount, useBalance, useSendTransaction } from 'wagmi'

const IrysInfo = () => {
const isMounted = useIsMounted()
const { address } = useAccount()
const { data: signer } = useEthersWalletClient()
const { sendTransactionAsync, sendTransaction } = useSendTransaction()
const { sendTransactionAsync } = useSendTransaction()

const { data: userBalance } = useBalance({
address,
Expand Down Expand Up @@ -102,7 +108,6 @@ const IrysInfo = () => {
if (!value || Number(value) < 1) {
return toast.error('Invalid deposit amount')
}
console.log('🚀 ~ depositToIrys ~ userBalance:', userBalance)

const formattedValue = formatUnits(
userBalance?.value ?? BigInt(0),
Expand All @@ -127,14 +132,13 @@ const IrysInfo = () => {
amount: `${number}`,
to: `0x${string}`
): Promise<{ txId: string | undefined; tx: any }> => {
const config = sendTransaction({
to,
value: parseEther(amount.toString(), 'gwei')
})

return {
txId: undefined,
tx: config
tx: {
to,
account: address,
value: parseEther(amount.toString(), 'gwei')
}
}
}
// TEMP:END: override irys functions for viem
Expand All @@ -143,9 +147,9 @@ const IrysInfo = () => {
const fundResult = await irysData.instance.fund(value.toString())
if (fundResult) {
toast.success(
`Deposit of ${formatEther(
`Deposit of ${formatGwei(
BigInt(fundResult?.quantity)
)} is done and it will be reflected in few seconds.`
)} ${IRYS_CURRENCY} is done and it will be reflected in few seconds.`
)
Tower.track(EVENTS.DEPOSIT_MATIC)
}
Expand Down

0 comments on commit 30768a7

Please sign in to comment.