Skip to content

Commit

Permalink
Merge pull request #212 from nguvictor/env-vars
Browse files Browse the repository at this point in the history
prototype env vars
  • Loading branch information
EvgeniiaVak authored Jan 10, 2024
2 parents 62c8272 + 1e8142d commit b352d2e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_NETWORK=stokenet # Options: mainnet or stokenet
NEXT_PUBLIC_DAPP_DEFINITION_ADDRESS=account_tdx_2_129kev9w27tsl7qjg0dlyze70kxnlzycs8v2c85kzec40gg8mt73f7y
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ next-env.d.ts
/playwright/.cache/

localhost:3000/
.env
32 changes: 28 additions & 4 deletions src/app/subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,22 @@ function setRdt(rdt: RDT) {
let subs: Subscription[] = [];

export function initializeSubscriptions(store: AppStore) {
let networkId;
switch (process.env.NEXT_PUBLIC_NETWORK) {
case "mainnet":
networkId = RadixNetwork.Mainnet;
break;
case "stokenet":
networkId = RadixNetwork.Stokenet;
break;
default:
networkId = RadixNetwork.Stokenet;
}
rdtInstance = RadixDappToolkit({
dAppDefinitionAddress:
"account_tdx_2_129kev9w27tsl7qjg0dlyze70kxnlzycs8v2c85kzec40gg8mt73f7y",
networkId: RadixNetwork.Stokenet,
dAppDefinitionAddress: process.env.NEXT_PUBLIC_DAPP_DEFINITION_ADDRESS
? process.env.NEXT_PUBLIC_DAPP_DEFINITION_ADDRESS
: "",
networkId,
});
rdtInstance.walletApi.setRequestData(
DataRequestBuilder.accounts().exactly(1)
Expand All @@ -48,7 +60,19 @@ export function initializeSubscriptions(store: AppStore) {
setRdt(rdtInstance);
// TODO: "black" on the light theme
rdtInstance.buttonApi.setTheme("white");
adex.init("stokenet");
let network;
switch (process.env.NEXT_PUBLIC_NETWORK) {
case "mainnet":
network = adex.ApiNetworkOptions.indexOf("mainnet");
break;
case "stokenet":
network = adex.ApiNetworkOptions.indexOf("stokenet");
break;
default:
network = adex.ApiNetworkOptions.indexOf("stokenet");
}

adex.init(adex.ApiNetworkOptions[network]);
subs.push(
adex.clientState.stateChanged$.subscribe((newState) => {
const serializedState: adex.StaticState = JSON.parse(
Expand Down

0 comments on commit b352d2e

Please sign in to comment.