diff --git a/.env.sample b/.env.sample
index 054c3fcda..73997c101 100644
--- a/.env.sample
+++ b/.env.sample
@@ -1,6 +1,6 @@
PUBLIC_BASE_URL=
PUBLIC_CRYPTO_PRIVATE_KEY=
-
+PUBLIC_MODE=
PUBLIC_SHOW_NAME_AS_LOGO= # Please provide true if you want to give platform name with logo
PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID= # Please sepcify your client id
diff --git a/src/common/enums.ts b/src/common/enums.ts
index 493400253..02a7bad94 100644
--- a/src/common/enums.ts
+++ b/src/common/enums.ts
@@ -161,4 +161,10 @@ export enum RequestType {
export enum ProofType {
polygon = 'EcdsaSecp256k1Signature2019',
no_ledger = 'Ed25519Signature2018'
-}
\ No newline at end of file
+}
+
+export enum Environment {
+ Prod = 'Prod',
+ Dev = 'Dev',
+ Qa = 'Qa'
+ }
\ No newline at end of file
diff --git a/src/components/organization/walletCommonComponents/DedicatedAgent.tsx b/src/components/organization/walletCommonComponents/DedicatedAgent.tsx
index 983bd4fb3..a57af44df 100644
--- a/src/components/organization/walletCommonComponents/DedicatedAgent.tsx
+++ b/src/components/organization/walletCommonComponents/DedicatedAgent.tsx
@@ -11,7 +11,7 @@ import {
getLedgerConfig,
getLedgers
} from '../../../api/Agent';
-import { DidMethod, Ledgers, Network} from '../../../common/enums';
+import { DidMethod, Environment, Ledgers, Network} from '../../../common/enums';
import type { IDedicatedAgentForm, ILedgerConfigData, ILedgerItem, IValuesShared, IDedicatedAgentData} from './interfaces';
import { getFromLocalStorage } from '../../../api/Auth';
import CopyDid from '../../../commonComponents/CopyDid';
@@ -20,6 +20,8 @@ import SetPrivateKeyValueInput from './SetPrivateKeyValue';
import { getOrganizationById, setAgentConfigDetails } from '../../../api/organization';
import type { IDedicatedAgentConfig} from '../interfaces';
import React from 'react';
+import { envConfig } from '../../../config/envConfig';
+import { getFilteredNetworks } from '../../../lib/data';
const RequiredAsterisk = () => *
@@ -236,12 +238,13 @@ const networkRenderOptions = (formikHandlers: { handleChange: (e: React.ChangeEv
return null;
}
- let filteredNetworks = Object.keys(networks);
- if (selectedMethod === DidMethod.POLYGON) {
- filteredNetworks = filteredNetworks.filter(network => network === Network.MAINNET);
- }
+ const filterNetworks = getFilteredNetworks(
+ Object.keys(networks),
+ envConfig.MODE,
+ selectedMethod
+ );
- return filteredNetworks.map((network) => (
+ return filterNetworks.map((network) => (
network === Network.MAINNET);
- }
+ const filteredNetworks = getFilteredNetworks(
+ Object.keys(networks),
+ envConfig.MODE,
+ selectedMethod
+ );
return filteredNetworks.map((network) => (
diff --git a/src/config/envConfig.ts b/src/config/envConfig.ts
index 71204908e..caf0896e9 100644
--- a/src/config/envConfig.ts
+++ b/src/config/envConfig.ts
@@ -17,7 +17,7 @@ if (import.meta.env) {
}
}
-const { PUBLIC_BASE_URL, PUBLIC_POLYGON_TESTNET_URL, PUBLIC_POLYGON_MAINNET_URL, PUBLIC_CRYPTO_PRIVATE_KEY,PUBLIC_SHOW_NAME_AS_LOGO, PUBLIC_PLATFORM_NAME, PUBLIC_PLATFORM_LOGO, PUBLIC_POWERED_BY, PUBLIC_PLATFORM_WEB_URL, PUBLIC_POWERED_BY_URL, PUBLIC_PLATFORM_DOCS_URL, PUBLIC_PLATFORM_GIT, PUBLIC_PLATFORM_SUPPORT_EMAIL, PUBLIC_PLATFORM_TWITTER_URL, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET, PUBLIC_PLATFORM_SUPPORT_INVITE, PUBLIC_PLATFORM_DISCORD_URL, PUBLIC_ALLOW_DOMAIN }: any = envVariables;
+const { PUBLIC_BASE_URL, PUBLIC_POLYGON_TESTNET_URL, PUBLIC_POLYGON_MAINNET_URL, PUBLIC_CRYPTO_PRIVATE_KEY,PUBLIC_SHOW_NAME_AS_LOGO, PUBLIC_PLATFORM_NAME, PUBLIC_PLATFORM_LOGO, PUBLIC_POWERED_BY, PUBLIC_PLATFORM_WEB_URL, PUBLIC_POWERED_BY_URL, PUBLIC_PLATFORM_DOCS_URL, PUBLIC_PLATFORM_GIT, PUBLIC_PLATFORM_SUPPORT_EMAIL, PUBLIC_PLATFORM_TWITTER_URL, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET, PUBLIC_PLATFORM_SUPPORT_INVITE, PUBLIC_PLATFORM_DISCORD_URL, PUBLIC_ALLOW_DOMAIN, PUBLIC_MODE }: any = envVariables;
export const envConfig = {
PUBLIC_BASE_URL:
@@ -69,5 +69,6 @@ export const envConfig = {
PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET ||
import.meta.env.PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET,
},
- PUBLIC_ALLOW_DOMAIN: PUBLIC_ALLOW_DOMAIN || import.meta.env.PUBLIC_ALLOW_DOMAIN
+ PUBLIC_ALLOW_DOMAIN: PUBLIC_ALLOW_DOMAIN || import.meta.env.PUBLIC_ALLOW_DOMAIN,
+ MODE: PUBLIC_MODE || import.meta.env.PUBLIC_MODE
}
\ No newline at end of file
diff --git a/src/lib/data.ts b/src/lib/data.ts
index 2e8574dd9..0dffff014 100644
--- a/src/lib/data.ts
+++ b/src/lib/data.ts
@@ -2,6 +2,7 @@
// GraphQL, Databases, REST APIs, CDNs, proxies, S3, Matrix, IPFS, you name it…
import { API_URL, REMOTE_ASSETS_BASE_URL } from '../app/constants.js';
+import { DidMethod, Environment, Network } from '../common/enums.js';
import type { Endpoint, EndpointsToOperations } from '../types/entities.js';
export async function fetchData(endpoint: Selected) {
@@ -31,3 +32,20 @@ export function asset(path: string) {
// NOTE: Fetching remote assets from the Hugo admin dashboard Vercel dist.
return `${REMOTE_ASSETS_BASE_URL}/${path}`;
}
+
+export const getFilteredNetworks = (
+ networks: string[],
+ envMode: Environment,
+ selectedMethod: string
+ ): string[] => {
+ if (envMode === Environment.Prod && selectedMethod === DidMethod.POLYGON) {
+ return networks.filter(network => network === Network.MAINNET);
+ } else if (
+ (envMode === Environment.Dev || envMode === Environment.Qa) &&
+ selectedMethod === DidMethod.POLYGON
+ ) {
+ return networks.filter(network => network === Network.TESTNET);
+ }
+ return networks;
+ };
+