Skip to content

Commit f9e90a4

Browse files
authored
Merge main into prod
2 parents 910059d + 8f1d59f commit f9e90a4

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

src/app/client.tsx

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ import {
2222
TextField,
2323
Theme,
2424
} from '@radix-ui/themes'
25-
import { useIsMounted } from 'connectkit'
25+
import { useIsMounted, useModal } from 'connectkit'
2626
import Link from 'next/link'
2727
import { usePathname, useRouter } from 'next/navigation'
2828
import { useCallback, useEffect, useState } from 'react'
29+
import { toast } from 'sonner'
2930
import useSWR from 'swr'
3031
import { useEventListener } from 'usehooks-ts'
3132
import { parseEther } from 'viem'
@@ -43,6 +44,7 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
4344
const pathname = usePathname()
4445
const isMounted = useIsMounted()
4546
const { address } = useAccount()
47+
const { setOpen } = useModal()
4648

4749
const [color, setColor] = useState(initialColor)
4850
const [randomMintAmount, setRandomMintAmount] = useState(1)
@@ -108,6 +110,11 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
108110
isPending: allowlistMintPending,
109111
} = useWriteRgbSignaturesAllowlistMint()
110112

113+
useEffect(() => {
114+
if (!(mintPending || mintRandomPending || allowlistMintPending)) return
115+
toast('Please confirm in your wallet', { position: 'bottom-right' })
116+
}, [mintPending, mintRandomPending, allowlistMintPending])
117+
111118
useEffect(() => {
112119
if (!mintHash && !mintRandomHash && !allowlistMintHash) return
113120

@@ -206,10 +213,12 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
206213
<Button
207214
size="4"
208215
onClick={() =>
209-
mint({
210-
args: [color.r, color.g, color.b],
211-
value: parseEther('0.004'),
212-
})
216+
address
217+
? mint({
218+
args: [color.r, color.g, color.b],
219+
value: parseEther('0.004'),
220+
})
221+
: setOpen(true)
213222
}
214223
loading={mintPending}
215224
disabled={mintRandomPending || allowlistMintPending}
@@ -244,10 +253,12 @@ export function HomeClientPage({ color: initialColor }: HomeClientPageProps) {
244253
<Button
245254
size="4"
246255
onClick={() =>
247-
mintRandom({
248-
args: [randomMintAmount],
249-
value: parseEther(randomMintCost),
250-
})
256+
address
257+
? mintRandom({
258+
args: [randomMintAmount],
259+
value: parseEther(randomMintCost),
260+
})
261+
: setOpen(true)
251262
}
252263
loading={mintRandomPending}
253264
disabled={mintPending}

src/components/Web3Provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { chain, rpcUrl } from '@/lib/chain'
3+
import { chain } from '@/lib/chain'
44
import { env } from '@/lib/env'
55
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
66
import { track } from '@vercel/analytics/react'
@@ -12,7 +12,7 @@ const config = createConfig(
1212
getDefaultConfig({
1313
chains: [chain],
1414
transports: {
15-
[chain.id]: http(rpcUrl),
15+
[chain.id]: http(),
1616
},
1717
walletConnectProjectId: env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,
1818
appName: 'RGB',

src/lib/chain.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,4 @@ import { env } from './env'
44
export const chain =
55
env.NEXT_PUBLIC_VERCEL_ENV === 'production' ? base : baseSepolia
66

7-
export const rpcUrl =
8-
chain === base
9-
? `https://base-mainnet.g.alchemy.com/v2/${env.NEXT_PUBLIC_ALCHEMY_ID}`
10-
: `https://base-sepolia.g.alchemy.com/v2/${env.NEXT_PUBLIC_ALCHEMY_ID}`
11-
127
export const fromBlock = chain === base ? 23491824n : 18714943n

src/lib/env.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import * as v from 'valibot'
22

33
const schema = v.object({
4-
NEXT_PUBLIC_ALCHEMY_ID: v.pipe(v.string(), v.nonEmpty()),
54
NEXT_PUBLIC_VERCEL_ENV: v.picklist(['production', 'preview', 'development']),
65
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: v.pipe(v.string(), v.nonEmpty()),
76
})
87

98
const parseResult = v.safeParse(schema, {
10-
NEXT_PUBLIC_ALCHEMY_ID: process.env.NEXT_PUBLIC_ALCHEMY_ID,
119
NEXT_PUBLIC_VERCEL_ENV: process.env.NEXT_PUBLIC_VERCEL_ENV,
1210
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID:
1311
process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,

src/lib/viem.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { http, createPublicClient } from 'viem'
2-
import { chain, rpcUrl } from './chain'
2+
import { base } from 'viem/chains'
3+
import { chain } from './chain'
4+
5+
const rpcUrl =
6+
chain === base
7+
? `https://base-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_ID}`
8+
: `https://base-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_ID}`
39

410
export const viemClient = createPublicClient({
511
chain,

0 commit comments

Comments
 (0)