Skip to content

Commit

Permalink
Removing ethers from react example
Browse files Browse the repository at this point in the history
  • Loading branch information
corbanbrook committed Apr 25, 2024
1 parent fde39e8 commit 979b13e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"@0xsequence/network": "^1.9.19",
"@tanstack/react-query": "^5.32.0",
"@vanilla-extract/css": "^1.14.2",
"ethers": "^5.7.2",
"framer-motion": "^8.5.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
14 changes: 7 additions & 7 deletions examples/react/src/components/Homepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ import { Footer } from './Footer'
import { messageToSign } from '../constants'
import { delay, formatAddress, getCheckoutSettings } from '../utils'
import { abi } from '../constants/nft-abi'
import { ethers } from 'ethers'
import { Alert, AlertProps } from './Alert'
import { ConnectionMode } from '../config'
import { formatUnits, parseUnits } from 'viem'

// append ?debug to url to enable debug mode
const searchParams = new URLSearchParams(location.search)
Expand Down Expand Up @@ -465,13 +465,13 @@ export const Homepage = () => {
<Box alignItems="flex-start" flexDirection="column" fontSize="xsmall">
<Box flexDirection="row">
<Text>Fee (in {option.token.name}): </Text>{' '}
<Text>{ethers.utils.formatUnits(option.value, option.token.decimals)}</Text>
<Text>{formatUnits(BigInt(option.value), option.token.decimals)}</Text>
</Box>
<Box flexDirection="row">
<Text>Wallet balance for {option.token.name}: </Text>{' '}
<Text>
{ethers.utils.formatUnits(
feeOptionBalances.find(b => b.tokenName === option.token.name)?.balance,
{formatUnits(
BigInt(feeOptionBalances.find(b => b.tokenName === option.token.name)?.balance || '0'),
option.token.decimals
)}
</Text>
Expand All @@ -491,12 +491,12 @@ export const Homepage = () => {

if (selected.token.contractAddress !== undefined) {
// check if wallet has enough balance, should be balance > feeOption.value
const balance = ethers.utils.parseUnits(
const balance = parseUnits(
feeOptionBalances.find(b => b.tokenName === selected.token.name)?.balance,
selected.token.decimals
)
const feeOptionValue = ethers.utils.parseUnits(selected.value, selected.token.decimals)
if (balance && balance.lt(feeOptionValue)) {
const feeOptionValue = parseUnits(selected.value, selected.token.decimals)
if (balance && balance < feeOptionValue) {
setFeeOptionAlert({
title: 'Insufficient balance',
description: `You do not have enough balance to pay the fee with ${selected.token.name}, please make sure you have enough balance in your wallet for the selected fee option.`,
Expand Down
7 changes: 4 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 979b13e

Please sign in to comment.