Skip to content

Commit

Permalink
feat: support set default chain id from env
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 committed Oct 20, 2023
1 parent ef721a6 commit 0cafbbc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING=
NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING=

# Redefine
NEXT_PUBLIC_REDEFINE_API=
NEXT_PUBLIC_REDEFINE_API=

# Default chain id
NEXT_PUBLIC_DEFAULT_CHAIN_ID=5611
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Here's the list of all the required and optional variables:
| `NEXT_PUBLIC_FIREBASE_VAPID_KEY_PRODUCTION` | optional | FCM vapid key on production
| `NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING` | optional | FCM `initializeApp` options on staging
| `NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING` | optional | FCM vapid key on staging
| `NEXT_DEFAULT_CHAIN_ID` | optional | Default chain id to use when connecting to a wallet

If you don't provide some of the optional vars, the corresponding features will be disabled in the UI.

Expand Down
3 changes: 3 additions & 0 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,6 @@ export const IS_OFFICIAL_HOST = process.env.NEXT_PUBLIC_IS_OFFICIAL_HOST === 'tr
export const REDEFINE_SIMULATION_URL = 'https://dashboard.redefine.net/reports/'
export const REDEFINE_API = process.env.NEXT_PUBLIC_REDEFINE_API
export const REDEFINE_ARTICLE = 'https://safe.mirror.xyz/rInLWZwD_sf7enjoFerj6FIzCYmVMGrrV8Nhg4THdwI'

// Default chain id
export const DEFAULT_CHAIN_ID = process.env.NEXT_PUBLIC_DEFAULT_CHAIN_ID || chains.eth
4 changes: 2 additions & 2 deletions src/hooks/useChainId.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useParams } from 'next/navigation'
import { parse, type ParsedUrlQuery } from 'querystring'
import { IS_PRODUCTION } from '@/config/constants'
import { DEFAULT_CHAIN_ID } from '@/config/constants'
import chains from '@/config/chains'
import { useAppSelector } from '@/store'
import { selectSession } from '@/store/sessionSlice'
Expand All @@ -9,7 +9,7 @@ import { prefixedAddressRe } from '@/utils/url'
import useWallet from './wallets/useWallet'
import useChains from './useChains'

const defaultChainId = IS_PRODUCTION ? chains.eth : chains.gor
const defaultChainId = DEFAULT_CHAIN_ID

// Use the location object directly because Next.js's router.query is available only on mount
const getLocationQuery = (): ParsedUrlQuery => {
Expand Down

0 comments on commit 0cafbbc

Please sign in to comment.