Skip to content

Commit

Permalink
Add env to toggle network
Browse files Browse the repository at this point in the history
  • Loading branch information
filip-neti committed Nov 19, 2024
1 parent eff8820 commit b057add
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
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

0 comments on commit b057add

Please sign in to comment.