Skip to content

Commit

Permalink
Add dRPC endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonmanRolls committed Nov 28, 2024
1 parent 570c86f commit df0b007
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pages-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Cloudflare Pages
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
NEXT_PUBLIC_INTERCOM_ID: re9q5yti
NEXT_PUBLIC_DRPC_KEY: AnmpasF2C0JBqeAEzxVO8aTteiMlrW4R75hpDonbV6cR

on: [push]
jobs:
Expand Down
17 changes: 10 additions & 7 deletions src/utils/query/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createClient, type FallbackTransport, type HttpTransport, type Transport } from 'viem'
import { createConfig, createStorage, fallback, http } from 'wagmi'
import { goerli, holesky, localhost, mainnet, sepolia } from 'wagmi/chains'
import { holesky, localhost, mainnet, sepolia } from 'wagmi/chains'

import { ccipRequest } from '@ensdomains/ensjs/utils'

Expand All @@ -24,12 +24,16 @@ const connectors = getDefaultWallets({

const infuraKey = process.env.NEXT_PUBLIC_INFURA_KEY || 'cfa6ae2501cc4354a74e20432507317c'
const tenderlyKey = process.env.NEXT_PUBLIC_TENDERLY_KEY || '4imxc4hQfRjxrVB2kWKvTo'
const drpcKey = process.env.NEXT_PUBLIC_DRPC_KEY || 'AnmpasF2C0JBqeAEzxVO8aRuvzLTrWcR75hmDonbV6cR'

export const infuraUrl = (chainName: string) => `https://${chainName}.infura.io/v3/${infuraKey}`
const cloudflareUrl = (chainName: string) => `https://web3.ens.domains/v1/${chainName}`
const tenderlyUrl = (chainName: string) => `https://${chainName}.gateway.tenderly.co/${tenderlyKey}`
const drpcUrl = (chainName: string) =>
`https://lb.drpc.org/ogrpc?network=${
chainName === 'mainnet' ? 'ethereum' : chainName
}&dkey=${drpcKey}`

type SupportedUrlFunc = typeof infuraUrl | typeof cloudflareUrl | typeof tenderlyUrl
type SupportedUrlFunc = typeof infuraUrl | typeof dRPCUrl | typeof tenderlyUrl

const initialiseTransports = <const UrlFuncArray extends SupportedUrlFunc[]>(
chainName: string,
Expand Down Expand Up @@ -97,10 +101,9 @@ const transports = {
// this is a hack to make the types happy, dont remove pls
[localhost.id]: HttpTransport
})),
[mainnet.id]: initialiseTransports('mainnet', [infuraUrl, cloudflareUrl, tenderlyUrl]),
[sepolia.id]: initialiseTransports('sepolia', [infuraUrl, cloudflareUrl, tenderlyUrl]),
[goerli.id]: initialiseTransports('goerli', [infuraUrl, cloudflareUrl, tenderlyUrl]),
[holesky.id]: initialiseTransports('holesky', [tenderlyUrl]),
[mainnet.id]: initialiseTransports('mainnet', [drpcUrl, infuraUrl, tenderlyUrl]),
[sepolia.id]: initialiseTransports('sepolia', [drpcUrl, infuraUrl, tenderlyUrl]),
[holesky.id]: initialiseTransports('holesky', [drpcUrl, tenderlyUrl]),
} as const

const wagmiConfig_ = createConfig({
Expand Down

0 comments on commit df0b007

Please sign in to comment.