-
Notifications
You must be signed in to change notification settings - Fork 10
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
Dynamically populate the Environment dropdown #14
base: main
Are you sure you want to change the base?
Conversation
@beeman is attempting to deploy a commit to the Metaplex Foundation Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contributions!
return process.env.NEXT_PUBLIC_DEVNET_RPC_URL; | ||
} | ||
}, [env]); | ||
const endpoint = useMemo(() => envOptions.find(({ env: e }) => e === env)?.endpoint, [env]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if the app correctly handles endpoint
being null
, it should probably be defaulted to something (solana mainnet?) if the find
does not find anything
|
||
export function Providers({ children }: { children: ReactNode }) { | ||
const router = useRouter(); | ||
const searchParams = useSearchParams(); | ||
const pathname = usePathname(); | ||
const queryEnv = searchParams.get('env'); | ||
const [client] = useState(new QueryClient()); | ||
const [env, setEnv] = useState<Env>((queryEnv === 'mainnet' || queryEnv === 'devnet') ? queryEnv : 'mainnet'); | ||
const [env, setEnv] = useState<Env>((queryEnv === 'mainnet' || queryEnv === 'devnet') ? queryEnv : envOptions[0]?.env); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you found a bug here (thanks!), the logic should probably be: if the queryEnv
is valid (i.e. contained within envOptions
) then set the corresponding env otherwise use the first thing in the env options
I checked on the current site and when navigating to a page via url and env set as a search param, the env for sonic/eclipse is not set properly.
Thanks for reviewing and merging a bunch of them! I will address the notes above! |
This PR makes the list of available environments dynamic based on the ones that are configured using the environment variables.