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

Dynamically populate the Environment dropdown #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

beeman
Copy link
Contributor

@beeman beeman commented Dec 22, 2024

This PR makes the list of available environments dynamic based on the ones that are configured using the environment variables.

image

Copy link

vercel bot commented Dec 22, 2024

@beeman is attempting to deploy a commit to the Metaplex Foundation Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@nhanphan nhanphan left a 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]);
Copy link
Contributor

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);
Copy link
Contributor

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.

@beeman
Copy link
Contributor Author

beeman commented Jan 30, 2025

Thanks for your contributions!

Thanks for reviewing and merging a bunch of them!

I will address the notes above!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants