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

[FIL-417] Add env to set network #162

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 .env.prod.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ NEXT_PUBLIC_GLIF_URL=
NEXTAUTH_SECRET=
NEXTAUTH_URL=
GITHUB_ID=
GITHUB_SECRET=
GITHUB_SECRET=
NEXT_PUBLIC_IS_TESTNET=
1 change: 1 addition & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
echo "NEXT_PUBLIC_NODE_TOKEN='${{ vars.NEXT_PUBLIC_NODE_TOKEN }}'" >> .env
echo "NEXT_PUBLIC_DMOB_API_URL='${{ vars.NEXT_PUBLIC_DMOB_API_URL }}'" >> .env
echo "NEXT_PUBLIC_GLIF_URL='${{ vars.NEXT_PUBLIC_GLIF_URL }}'" >> .env
echo "NEXT_PUBLIC_IS_TESTNET='${{ vars.NEXT_PUBLIC_IS_TESTNET }}'" >> .env
echo "NEXTAUTH_URL='${{ vars.NEXTAUTH_URL }}'" >> .env
echo "NEXTAUTH_SECRET='placeholder'" >> .env
echo "GITHUB_ID='placeholder'" >> .env
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ To get started with the Fil+ Registry Frontend, you can visit the live applicati
GITHUB_ID
GITHUB_SECRET
NEXT_PUBLIC_MODE=development
NEXT_PUBLIC_IS_TESTNET
```

## Support and Community
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const localConfig = {
dmobApiKey: process.env.NEXT_PUBLIC_DMOB_API_KEY ?? '',
glifNodeUrl:
process.env.NEXT_PUBLIC_GLIF_URL ?? 'https://api.node.glif.io/rpc/v1',
isTestnet: process.env.NEXT_PUBLIC_IS_TESTNET ?? 'true',
}

const prodConfig = {
Expand All @@ -49,6 +50,7 @@ const prodConfig = {
dmobApiUrl: process.env.NEXT_PUBLIC_DMOB_API_URL ?? '',
dmobApiKey: process.env.NEXT_PUBLIC_DMOB_API_KEY ?? '',
glifNodeUrl: process.env.NEXT_PUBLIC_GLIF_URL ?? '',
isTestnet: process.env.NEXT_PUBLIC_IS_TESTNET ?? 'false',
}

export const config =
Expand Down
4 changes: 2 additions & 2 deletions src/lib/wallet/BurnerWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export class BurnerWallet extends BaseWallet {
: {
token: async () => this.lotusNode?.token,
}

const isTestnet = config.isTestnet === 'true'
this.api = new VerifyAPI(
VerifyAPI.browserProvider(this.lotusNode.url, tokenProvider),
{ sign: this.sign, getAccounts: this.getAccounts },
this.lotusNode.name !== 'Mainnet',
isTestnet,
)
} catch (error) {
console.error('Error loading wallet:', error)
Expand Down
3 changes: 2 additions & 1 deletion src/lib/wallet/LedgerWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class LedgerWallet extends BaseWallet {
* @private
*/
private async initializeApi(): Promise<void> {
const isTestnet = config.isTestnet === 'true'
this.api = new VerifyAPI(
VerifyAPI.browserProvider(this.lotusNode.url, {
token: async () => this.lotusNode?.token,
Expand All @@ -46,7 +47,7 @@ export class LedgerWallet extends BaseWallet {
sign: this.sign,
getAccounts: () => this.loadedAccounts,
},
process.env.NEXT_PUBLIC_MODE !== 'production',
isTestnet,
)
}

Expand Down