Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dRPC endpoint #912

Merged
merged 4 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: ${{ github.ref == 'refs/heads/main' && AnmpasF2C0JBqeAEzxVO8aTteiMlrW4R75hpDonbV6cR || '' }}

on: [push]
jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,6 @@ const Registration = ({ nameDetails, isLoading }: Props) => {
<Typography fontVariant="bodyBold" color="grey">
{t('steps.info.moonpayModalHeader')}
</Typography>
{chainId === 5 && (
<Typography fontVariant="body" color="grey">
{`${t('steps.info.moonpayTestCard')}: 4000 0209 5159 5032, 12/2030, 123`}
</Typography>
)}
</MoonPayHeader>
<MoonPayIFrame
title="Moonpay Checkout"
Expand Down
5 changes: 1 addition & 4 deletions src/constants/chains.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { holesky } from 'viem/chains'
import { goerli, localhost, mainnet, sepolia } from 'wagmi/chains'
import { localhost, mainnet, sepolia } from 'wagmi/chains'

import { addEnsContracts } from '@ensdomains/ensjs'

Expand All @@ -25,13 +25,11 @@ export const mainnetWithEns = {
},
},
}
export const goerliWithEns = addEnsContracts(goerli)
export const sepoliaWithEns = addEnsContracts(sepolia)
export const holeskyWithEns = addEnsContracts(holesky)

export const chainsWithEns = [
mainnetWithEns,
goerliWithEns,
sepoliaWithEns,
holeskyWithEns,
localhostWithEns,
Expand All @@ -42,7 +40,6 @@ export const getSupportedChainById = (chainId: number | undefined) =>

export type SupportedChain =
| typeof mainnetWithEns
| typeof goerliWithEns
| typeof sepoliaWithEns
| typeof holeskyWithEns
| typeof localhostWithEns
7 changes: 2 additions & 5 deletions src/constants/resolverAddressData.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getChainContractAddress } from 'viem/utils'
import { describe, expect, it } from 'vitest'
import { expect, it } from 'vitest'

import { goerliWithEns, localhostWithEns, mainnetWithEns, sepoliaWithEns } from './chains'
import { mainnetWithEns, sepoliaWithEns } from './chains'

;(process.env as any).NODE_ENV = 'development'

Expand All @@ -12,9 +12,6 @@ it('should have the most recent resolver as the first address', async () => {
expect(KNOWN_RESOLVER_DATA['1']![0].address).toEqual(
getChainContractAddress({ chain: mainnetWithEns, contract: 'ensPublicResolver' }),
)
expect(KNOWN_RESOLVER_DATA['5']![0].address).toEqual(
getChainContractAddress({ chain: goerliWithEns, contract: 'ensPublicResolver' }),
)
expect(KNOWN_RESOLVER_DATA['11155111']![0].address).toEqual(
getChainContractAddress({ chain: sepoliaWithEns, contract: 'ensPublicResolver' }),
)
Expand Down
177 changes: 0 additions & 177 deletions src/constants/resolverAddressData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,183 +123,6 @@ export const KNOWN_RESOLVER_DATA: KnownResolverData = {
],
},
],
'5': [
{
address: '0xd7a4F6473f32aC2Af804B3686AE8F1932bC35750',
deployer: 'ENS Labs',
tag: 'latest',
isNameWrapperAware: true,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.MultiCoinAddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.DnsRecordResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
RESOLVER_INTERFACE_IDS.VersionableResolver,
],
},
{
address: '0x342cf18D3e41DE491aa1a3067574C849AdA6a2Ad',
deployer: 'ENS Labs',
tag: null,
isNameWrapperAware: false,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.MultiCoinAddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.DnsRecordResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
RESOLVER_INTERFACE_IDS.VersionableResolver,
],
},
{
address: '0x19c2d5D0f035563344dBB7bE5fD09c8dad62b001',
deployer: 'ENS Labs',
tag: null,
isNameWrapperAware: false,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.MultiCoinAddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.DnsRecordResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
RESOLVER_INTERFACE_IDS.VersionableResolver,
],
},
{
address: '0x2800Ec5BAB9CE9226d19E0ad5BC607e3cfC4347E',
deployer: 'ENS Labs',
tag: null,
isNameWrapperAware: false,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.MultiCoinAddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.DnsRecordResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
RESOLVER_INTERFACE_IDS.VersionableResolver,
],
},
{
address: '0x121304143ea8101E69335F309e2062d299A234B5',
deployer: 'ENS Labs',
tag: null,
isNameWrapperAware: false,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.MultiCoinAddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.DnsRecordResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
],
},
{
address: '0x4B1488B7a6B320d2D721406204aBc3eeAa9AD329',
deployer: 'ENS Labs',
tag: null,
isNameWrapperAware: false,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.MultiCoinAddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.DnsRecordResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
],
},
{
address: '0xfF77b96d6bafCec0D684bB528b22e0Ab09C70663',
deployer: 'ENS Labs',
tag: null,
isNameWrapperAware: false,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.MultiCoinAddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.DnsRecordResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
],
},
{
address: '0x6e1b40ed2d626b97A43d2c12e48a6De49A03c7A4',
deployer: 'ENS Labs',
tag: null,
isNameWrapperAware: false,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.MultiCoinAddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
],
},
{
address: '0xc1EA41786094D1fBE5aded033B5370d51F7a3F96',
deployer: 'ENS Labs',
tag: 'outdated',
isNameWrapperAware: false,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
],
},
{
address: '0xBbe3fD189D18C8b73BA54e9dD01F89E6b3Ee71f0',
deployer: 'ENS Labs',
tag: 'outdated',
isNameWrapperAware: false,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
],
},
{
address: '0x4B1488B7a6B320d2D721406204aBc3eeAa9AD329',
deployer: 'ENS Labs',
tag: 'outdated',
isNameWrapperAware: false,
supportedInterfaces: [
RESOLVER_INTERFACE_IDS.AddressResolver,
RESOLVER_INTERFACE_IDS.NameResolver,
RESOLVER_INTERFACE_IDS.AbiResolver,
RESOLVER_INTERFACE_IDS.TextResolver,
RESOLVER_INTERFACE_IDS.ContentHashResolver,
RESOLVER_INTERFACE_IDS.DnsRecordResolver,
RESOLVER_INTERFACE_IDS.InterfaceResolver,
RESOLVER_INTERFACE_IDS.MultiCoinAddressResolver,
],
},
],
'11155111': [
{
address: '0x8948458626811dd0c23EB25Cc74291247077cC51',
Expand Down
9 changes: 2 additions & 7 deletions src/hooks/useEthPrice.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { Address } from 'viem'
import { useChainId, useReadContract } from 'wagmi'
import { goerli } from 'wagmi/chains'
import { useReadContract } from 'wagmi'

import { useAddressRecord } from './ensjs/public/useAddressRecord'

const ORACLE_ENS = 'eth-usd.data.eth'
const ORACLE_GOERLI = '0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e' as const

export const useEthPrice = () => {
const chainId = useChainId()

const { data: address_ } = useAddressRecord({
name: ORACLE_ENS,
enabled: chainId !== goerli.id,
})

const address = chainId === 5 ? ORACLE_GOERLI : (address_?.value as Address) || undefined
const address = (address_?.value as Address) || undefined

return useReadContract({
abi: [
Expand Down
19 changes: 10 additions & 9 deletions src/utils/query/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
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'

import {
goerliWithEns,
holeskyWithEns,
localhostWithEns,
mainnetWithEns,
Expand All @@ -24,12 +23,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 @@ -83,7 +86,6 @@ const localStorageWithInvertMiddleware = (): Storage | undefined => {
const chains = [
...(isLocalProvider ? ([localhostWithEns] as const) : ([] as const)),
mainnetWithEns,
goerliWithEns,
sepoliaWithEns,
holeskyWithEns,
] as const
Expand All @@ -97,10 +99,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