Skip to content

Commit 241d2fe

Browse files
authored
refactor: adding preconfigured env setup for testnet and mainnet for quick switch (#11)
* refactor: minor enhancements; adding testnet/mainnet env configs in comments * chore: addressing pr comments
1 parent 4666b4a commit 241d2fe

File tree

12 files changed

+180
-16
lines changed

12 files changed

+180
-16
lines changed
Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
# ======================
2+
# LocalNet configuration
3+
# uncomment below to use
4+
# ======================
5+
16
VITE_ENVIRONMENT=local
27

38
# Algod
49
VITE_ALGOD_TOKEN={{ algod_token }}
510
VITE_ALGOD_SERVER={{ algod_server }}
611
VITE_ALGOD_PORT={{ algod_port }}
7-
# Empty string by default for sandbox otherwise use `betanet`, `testnet` or `mainnet`
812
VITE_ALGOD_NETWORK=""
913

1014
# Indexer
@@ -13,3 +17,40 @@ VITE_INDEXER_SERVER={{ indexer_server }}
1317
VITE_INDEXER_PORT={{ indexer_port }}
1418

1519

20+
# # ======================
21+
# # TestNet configuration:
22+
# # uncomment below to use
23+
# # ======================
24+
25+
# VITE_ENVIRONMENT=local
26+
27+
# # Algod
28+
# VITE_ALGOD_TOKEN=""
29+
# VITE_ALGOD_SERVER="https://testnet-api.algonode.cloud"
30+
# VITE_ALGOD_PORT=""
31+
# VITE_ALGOD_NETWORK="testnet"
32+
33+
# # Indexer
34+
# VITE_INDEXER_TOKEN=""
35+
# VITE_INDEXER_SERVER="https://testnet-idx.algonode.cloud"
36+
# VITE_INDEXER_PORT=""
37+
38+
39+
# # ======================
40+
# # MainNet configuration:
41+
# # uncomment below to use
42+
# # ======================
43+
44+
# VITE_ENVIRONMENT=production
45+
46+
# # Algod
47+
# VITE_ALGOD_TOKEN=""
48+
# VITE_ALGOD_SERVER="https://mainnet-api.algonode.cloud"
49+
# VITE_ALGOD_PORT=""
50+
# VITE_ALGOD_NETWORK="mainnet"
51+
52+
# # Indexer
53+
# VITE_INDEXER_TOKEN=""
54+
# VITE_INDEXER_SERVER="https://mainnet-idx.algonode.cloud"
55+
# VITE_INDEXER_PORT=""
56+

template_content/src/components/Account.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const Account = () => {
2020
>
2121
Address: {ellipseAddress(activeAddress)}
2222
</a>
23-
<div className="text-xl">Network: {algoConfig.network}</div>
23+
<div className="text-xl">Network: {algoConfig.network === '' ? 'localnet' : algoConfig.network}</div>
2424
</div>
2525
)
2626
}

template_content/src/hooks/useAlgoWalletProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type SupportedProviders = Partial<{
1616
}>
1717

1818
let providerIds: PROVIDER_ID[] = []
19-
if (import.meta.env.VITE_ENVIRONMENT === 'local') {
19+
if (import.meta.env.VITE_ALGOD_NETWORK === '') {
2020
providerIds.push(PROVIDER_ID.KMD)
2121
} else {
2222
providerIds = [PROVIDER_ID.PERA, PROVIDER_ID.DEFLY, PROVIDER_ID.EXODUS]
@@ -61,7 +61,7 @@ export function useAlgoWallet(context: { autoConnect: boolean; network: string;
6161
break
6262

6363
default:
64-
if (import.meta.env.VITE_ENVIRONMENT === 'local') {
64+
if (import.meta.env.VITE_ALGOD_NETWORK === '') {
6565
walletProviders[PROVIDER_ID.KMD] = kmd.init({
6666
algosdkStatic: algosdk,
6767
algodOptions: algodOptions,
Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
# ======================
2+
# LocalNet configuration
3+
# uncomment below to use
4+
# ======================
5+
16
VITE_ENVIRONMENT=local
27

38
# Algod
49
VITE_ALGOD_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
510
VITE_ALGOD_SERVER=http://localhost
611
VITE_ALGOD_PORT=4001
7-
# Empty string by default for sandbox otherwise use `betanet`, `testnet` or `mainnet`
812
VITE_ALGOD_NETWORK=""
913

1014
# Indexer
@@ -13,3 +17,40 @@ VITE_INDEXER_SERVER=http://localhost
1317
VITE_INDEXER_PORT=8980
1418

1519

20+
# # ======================
21+
# # TestNet configuration:
22+
# # uncomment below to use
23+
# # ======================
24+
25+
# VITE_ENVIRONMENT=local
26+
27+
# # Algod
28+
# VITE_ALGOD_TOKEN=""
29+
# VITE_ALGOD_SERVER="https://testnet-api.algonode.cloud"
30+
# VITE_ALGOD_PORT=""
31+
# VITE_ALGOD_NETWORK="testnet"
32+
33+
# # Indexer
34+
# VITE_INDEXER_TOKEN=""
35+
# VITE_INDEXER_SERVER="https://testnet-idx.algonode.cloud"
36+
# VITE_INDEXER_PORT=""
37+
38+
39+
# # ======================
40+
# # MainNet configuration:
41+
# # uncomment below to use
42+
# # ======================
43+
44+
# VITE_ENVIRONMENT=production
45+
46+
# # Algod
47+
# VITE_ALGOD_TOKEN=""
48+
# VITE_ALGOD_SERVER="https://mainnet-api.algonode.cloud"
49+
# VITE_ALGOD_PORT=""
50+
# VITE_ALGOD_NETWORK="mainnet"
51+
52+
# # Indexer
53+
# VITE_INDEXER_TOKEN=""
54+
# VITE_INDEXER_SERVER="https://mainnet-idx.algonode.cloud"
55+
# VITE_INDEXER_PORT=""
56+

tests_generated/test_all_default_parameters_off/src/components/Account.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const Account = () => {
2020
>
2121
Address: {ellipseAddress(activeAddress)}
2222
</a>
23-
<div className="text-xl">Network: {algoConfig.network}</div>
23+
<div className="text-xl">Network: {algoConfig.network === '' ? 'localnet' : algoConfig.network}</div>
2424
</div>
2525
)
2626
}

tests_generated/test_all_default_parameters_off/src/hooks/useAlgoWalletProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type SupportedProviders = Partial<{
1616
}>
1717

1818
let providerIds: PROVIDER_ID[] = []
19-
if (import.meta.env.VITE_ENVIRONMENT === 'local') {
19+
if (import.meta.env.VITE_ALGOD_NETWORK === '') {
2020
providerIds.push(PROVIDER_ID.KMD)
2121
} else {
2222
providerIds = [PROVIDER_ID.PERA, PROVIDER_ID.DEFLY, PROVIDER_ID.EXODUS]
@@ -61,7 +61,7 @@ export function useAlgoWallet(context: { autoConnect: boolean; network: string;
6161
break
6262

6363
default:
64-
if (import.meta.env.VITE_ENVIRONMENT === 'local') {
64+
if (import.meta.env.VITE_ALGOD_NETWORK === '') {
6565
walletProviders[PROVIDER_ID.KMD] = kmd.init({
6666
algosdkStatic: algosdk,
6767
algodOptions: algodOptions,
Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
# ======================
2+
# LocalNet configuration
3+
# uncomment below to use
4+
# ======================
5+
16
VITE_ENVIRONMENT=local
27

38
# Algod
49
VITE_ALGOD_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
510
VITE_ALGOD_SERVER=http://localhost
611
VITE_ALGOD_PORT=4001
7-
# Empty string by default for sandbox otherwise use `betanet`, `testnet` or `mainnet`
812
VITE_ALGOD_NETWORK=""
913

1014
# Indexer
@@ -13,3 +17,40 @@ VITE_INDEXER_SERVER=http://localhost
1317
VITE_INDEXER_PORT=8980
1418

1519

20+
# # ======================
21+
# # TestNet configuration:
22+
# # uncomment below to use
23+
# # ======================
24+
25+
# VITE_ENVIRONMENT=local
26+
27+
# # Algod
28+
# VITE_ALGOD_TOKEN=""
29+
# VITE_ALGOD_SERVER="https://testnet-api.algonode.cloud"
30+
# VITE_ALGOD_PORT=""
31+
# VITE_ALGOD_NETWORK="testnet"
32+
33+
# # Indexer
34+
# VITE_INDEXER_TOKEN=""
35+
# VITE_INDEXER_SERVER="https://testnet-idx.algonode.cloud"
36+
# VITE_INDEXER_PORT=""
37+
38+
39+
# # ======================
40+
# # MainNet configuration:
41+
# # uncomment below to use
42+
# # ======================
43+
44+
# VITE_ENVIRONMENT=production
45+
46+
# # Algod
47+
# VITE_ALGOD_TOKEN=""
48+
# VITE_ALGOD_SERVER="https://mainnet-api.algonode.cloud"
49+
# VITE_ALGOD_PORT=""
50+
# VITE_ALGOD_NETWORK="mainnet"
51+
52+
# # Indexer
53+
# VITE_INDEXER_TOKEN=""
54+
# VITE_INDEXER_SERVER="https://mainnet-idx.algonode.cloud"
55+
# VITE_INDEXER_PORT=""
56+

tests_generated/test_all_default_parameters_on_netlify/src/components/Account.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const Account = () => {
2020
>
2121
Address: {ellipseAddress(activeAddress)}
2222
</a>
23-
<div className="text-xl">Network: {algoConfig.network}</div>
23+
<div className="text-xl">Network: {algoConfig.network === '' ? 'localnet' : algoConfig.network}</div>
2424
</div>
2525
)
2626
}

tests_generated/test_all_default_parameters_on_netlify/src/hooks/useAlgoWalletProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type SupportedProviders = Partial<{
1616
}>
1717

1818
let providerIds: PROVIDER_ID[] = []
19-
if (import.meta.env.VITE_ENVIRONMENT === 'local') {
19+
if (import.meta.env.VITE_ALGOD_NETWORK === '') {
2020
providerIds.push(PROVIDER_ID.KMD)
2121
} else {
2222
providerIds = [PROVIDER_ID.PERA, PROVIDER_ID.DEFLY, PROVIDER_ID.EXODUS]
@@ -61,7 +61,7 @@ export function useAlgoWallet(context: { autoConnect: boolean; network: string;
6161
break
6262

6363
default:
64-
if (import.meta.env.VITE_ENVIRONMENT === 'local') {
64+
if (import.meta.env.VITE_ALGOD_NETWORK === '') {
6565
walletProviders[PROVIDER_ID.KMD] = kmd.init({
6666
algosdkStatic: algosdk,
6767
algodOptions: algodOptions,
Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
# ======================
2+
# LocalNet configuration
3+
# uncomment below to use
4+
# ======================
5+
16
VITE_ENVIRONMENT=local
27

38
# Algod
49
VITE_ALGOD_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
510
VITE_ALGOD_SERVER=http://localhost
611
VITE_ALGOD_PORT=4001
7-
# Empty string by default for sandbox otherwise use `betanet`, `testnet` or `mainnet`
812
VITE_ALGOD_NETWORK=""
913

1014
# Indexer
@@ -13,3 +17,40 @@ VITE_INDEXER_SERVER=http://localhost
1317
VITE_INDEXER_PORT=8980
1418

1519

20+
# # ======================
21+
# # TestNet configuration:
22+
# # uncomment below to use
23+
# # ======================
24+
25+
# VITE_ENVIRONMENT=local
26+
27+
# # Algod
28+
# VITE_ALGOD_TOKEN=""
29+
# VITE_ALGOD_SERVER="https://testnet-api.algonode.cloud"
30+
# VITE_ALGOD_PORT=""
31+
# VITE_ALGOD_NETWORK="testnet"
32+
33+
# # Indexer
34+
# VITE_INDEXER_TOKEN=""
35+
# VITE_INDEXER_SERVER="https://testnet-idx.algonode.cloud"
36+
# VITE_INDEXER_PORT=""
37+
38+
39+
# # ======================
40+
# # MainNet configuration:
41+
# # uncomment below to use
42+
# # ======================
43+
44+
# VITE_ENVIRONMENT=production
45+
46+
# # Algod
47+
# VITE_ALGOD_TOKEN=""
48+
# VITE_ALGOD_SERVER="https://mainnet-api.algonode.cloud"
49+
# VITE_ALGOD_PORT=""
50+
# VITE_ALGOD_NETWORK="mainnet"
51+
52+
# # Indexer
53+
# VITE_INDEXER_TOKEN=""
54+
# VITE_INDEXER_SERVER="https://mainnet-idx.algonode.cloud"
55+
# VITE_INDEXER_PORT=""
56+

0 commit comments

Comments
 (0)