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

fix: web3auth env. var. #126

Merged
merged 6 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ jobs:
echo "NEXT_PUBLIC_TESTNET_API_URL=${{ vars.NEXT_PUBLIC_TESTNET_API_URL }}" >> .env
echo "NEXT_PUBLIC_ABLY_API_KEY=${{ secrets.NEXT_PUBLIC_ABLY_API_KEY }}" >> .env
echo "NEXT_PUBLIC_WALLETCONNECT_KEY=${{ secrets.NEXT_PUBLIC_WALLETCONNECT_KEY }}" >> .env
echo "NEXT_PUBLIC_WEB3_CLIENT_ID=${{ secrets.NEXT_PUBLIC_WEB3_CLIENT_ID }}" >> .env
echo "NEXT_PUBLIC_WEB3AUTH_NETWORK=${{ vars.NEXT_PUBLIC_WEB3AUTH_NETWORK }}" >> .env
echo "NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=${{ secrets.NEXT_PUBLIC_WEB3AUTH_CLIENT_ID }}" >> .env
echo "NEXT_PUBLIC_TESTNET_EXPLORER_URL=${{ vars.NEXT_PUBLIC_TESTNET_EXPLORER_URL }}" >> .env
echo "NEXT_PUBLIC_MAINNET_EXPLORER_URL=${{ vars.NEXT_PUBLIC_MAINNET_EXPLORER_URL }}" >> .env
echo "NEXT_PUBLIC_TESTNET_INDEXER_URL=${{ vars.NEXT_PUBLIC_TESTNET_INDEXER_URL }}" >> .env
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ For more information on the Manifest Network and its modules, please visit the [

```
NEXT_PUBLIC_WALLETCONNECT_KEY=
NEXT_PUBLIC_WEB3_CLIENT_ID=
NEXT_PUBLIC_WEB3AUTH_NETWORK=
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=
NEXT_PUBLIC_CHAIN=manifest
NEXT_PUBLIC_CHAIN_ID=manifest-1
NEXT_PUBLIC_TESTNET_CHAIN_ID=manifest-ledger-beta
Expand Down
15 changes: 13 additions & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import MobileNav from '@/components/react/mobileNav';

import { useEndpointStore } from '@/store/endpointStore';
import EndpointSelector from '@/components/react/endpointSelector';
import { OPENLOGIN_NETWORK, OPENLOGIN_NETWORK_TYPE } from '@toruslabs/openlogin-utils';

type ManifestAppProps = AppProps & {
Component: AppProps['Component'];
Expand Down Expand Up @@ -111,6 +112,16 @@ function ManifestApp({ Component, pageProps }: ManifestAppProps) {
}
| undefined
>();

const isValidNetwork = (network: string | undefined): network is OPENLOGIN_NETWORK_TYPE => {
return Object.values(OPENLOGIN_NETWORK).includes(network as OPENLOGIN_NETWORK_TYPE);
};

const network = process.env.NEXT_PUBLIC_WEB3AUTH_NETWORK;
if (!isValidNetwork(network)) {
console.error(`Invalid WEB3AUTH_NETWORK: ${network}. Using default: testnet`);
}

const web3AuthWallets = useMemo(
() =>
makeWeb3AuthWallets({
Expand Down Expand Up @@ -148,8 +159,8 @@ function ManifestApp({ Component, pageProps }: ManifestAppProps) {
],

client: {
clientId: process.env.NEXT_PUBLIC_WEB3_CLIENT_ID ?? '',
web3AuthNetwork: 'testnet',
clientId: process.env.NEXT_PUBLIC_WEB3AUTH_CLIENT_ID ?? '',
web3AuthNetwork: isValidNetwork(network) ? network : 'testnet',
},

promptSign: async (_, signData) =>
Expand Down
Loading