Skip to content

Commit

Permalink
grab network from subdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonmanRolls committed Dec 3, 2024
1 parent de0f4f9 commit 32101ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "ens-app-v2",
"version": "0.1.123",
"scripts": {
"dev": "NODE_NO_WARNINGS=1 next dev --experimental-https --port 443",
"dev:https": "next-dev-https --https --qr --port 443",
"dev": "NODE_NO_WARNINGS=1 next dev",
"dev:https": "next dev --experimental-https --port 443",
"dev:nlocal": "NEXT_PUBLIC_PROVIDER=http://localhost:8545 NEXT_PUBLIC_AVUP_ENDPOINT=http://localhost:8787 pnpm dev",
"dev:localname": "NEXT_PUBLIC_PROVIDER=\"http://$(\"hostname\"):8545\" && NEXT_PUBLIC_AVUP_ENDPOINT=\"http://$(\"hostname\"):8787\" && NEXT_PUBLIC_GRAPH_URI=\"http://$(\"hostname\"):8000/subgraphs/name/graphprotocol/ens\" && pnpm dev",
"dev:glocal": "rm -rf .next && NEXT_PUBLIC_GRAPH_URI=http://localhost:8000/subgraphs/name/graphprotocol/ens NEXT_PUBLIC_ETH_NODE=anvil pnpm dev:nlocal",
Expand Down
9 changes: 8 additions & 1 deletion src/utils/query/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { match } from 'ts-pattern'
import { createClient, type FallbackTransport, type HttpTransport, type Transport } from 'viem'
import { createConfig, createStorage, fallback, http } from 'wagmi'
import { holesky, localhost, mainnet, sepolia } from 'wagmi/chains'
Expand Down Expand Up @@ -105,7 +106,13 @@ const wagmiConfig_ = createConfig({
multiInjectedProviderDiscovery: true,
storage: createStorage({ storage: localStorageWithInvertMiddleware(), key: prefix }),
chains,
client: ({ chain }) => {
client: () => {
const subdomain = typeof window !== 'undefined' ? window.location.hostname.split('.')[0] : ''
const chain = match(subdomain)
.with('sepolia', () => sepoliaWithEns)
.with('holesky', () => holeskyWithEns)
.otherwise(() => mainnetWithEns)

const chainId = chain.id

return createClient<Transport, typeof chain>({
Expand Down

0 comments on commit 32101ea

Please sign in to comment.