Skip to content

Commit 86a1566

Browse files
committed
Remove RPC URL from frontend
1 parent f997b83 commit 86a1566

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

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)