Add CIC namespace to environment variables.

This commit is contained in:
Spencer Ofwiti 2021-03-18 20:16:43 +03:00
parent ec2d5321ba
commit d1563092b2
2 changed files with 25 additions and 24 deletions

View File

@ -1,9 +1,11 @@
CHAIN_ID= LOG_LEVEL=
LOGGING_URL= SERVER_LEVEL=
META_URL= CIC_CHAIN_ID=
KEYS_URL= CIC_LOGGING_URL=
CACHE_URL= CIC_META_URL=
WEB3_PROVIDER= CIC_KEYS_URL=
USSD_URL= CIC_CACHE_URL=
REGISTRY_ADDRESS= CIC_WEB3_PROVIDER=
TRUSTED_ADDRESS= CIC_USSD_URL=
CIC_REGISTRY_ADDRESS=
CIC_TRUSTED_ADDRESS=

View File

@ -12,17 +12,17 @@ const environmentVars = `import {NgxLoggerLevel} from 'ngx-logger';
export const environment = { export const environment = {
production: ${isProduction}, production: ${isProduction},
bloxbergChainId: ${process.env.CHAIN_ID || 8996}, bloxbergChainId: ${process.env.CIC_CHAIN_ID || 8996},
level: ${process.env.LOG_LEVEL || 'NgxLoggerLevel.OFF'}, level: ${process.env.LOG_LEVEL || 'NgxLoggerLevel.OFF'},
serverLogLevel: ${process.env.SERVER_LEVEL || 'NgxLoggerLevel.OFF'}, serverLogLevel: ${process.env.SERVER_LEVEL || 'NgxLoggerLevel.OFF'},
loggingUrl: '${process.env.LOGGING_URL || 'http://localhost:8000'}', loggingUrl: '${process.env.CIC_LOGGING_URL || 'http://localhost:8000'}',
cicMetaUrl: '${process.env.META_URL || 'https://meta.dev.grassrootseconomics.net'}', cicMetaUrl: '${process.env.CIC_META_URL || 'https://meta.dev.grassrootseconomics.net'}',
publicKeysUrl: '${process.env.KEYS_URL || 'http://localhost:8000/keys.asc'}', publicKeysUrl: '${process.env.CIC_KEYS_URL || 'http://localhost:8000/keys.asc'}',
cicCacheUrl: '${process.env.CACHE_URL || 'https://cache.dev.grassrootseconomics.net'}', cicCacheUrl: '${process.env.CIC_CACHE_URL || 'https://cache.dev.grassrootseconomics.net'}',
web3Provider: '${process.env.WEB3_PROVIDER || 'ws://localhost:63546'}', web3Provider: '${process.env.CIC_WEB3_PROVIDER || 'ws://localhost:63546'}',
cicUssdUrl: '${process.env.USSD_URL || 'https://ussd.dev.grassrootseconomics.net'}', cicUssdUrl: '${process.env.CIC_USSD_URL || 'https://ussd.dev.grassrootseconomics.net'}',
registryAddress: '${process.env.REGISTRY_ADDRESS || '0x6Ca3cB14aA6F761712E1C18646AfBA4d5Ae249E8'}', registryAddress: '${process.env.CIC_REGISTRY_ADDRESS || '0x6Ca3cB14aA6F761712E1C18646AfBA4d5Ae249E8'}',
trustedDeclaratorAddress: '${process.env.TRUSTED_ADDRESS || '0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C'}' trustedDeclaratorAddress: '${process.env.CIC_TRUSTED_ADDRESS || '0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C'}'
}; };
`; `;
@ -31,22 +31,21 @@ function setConfigs(configs): void {
if (err) { if (err) {
throw console.error(err); throw console.error(err);
} else { } else {
console.log(colors.cyan(`Wrote variables to '${targetPath}`)); console.log(colors.green(`Wrote variables to '${targetPath}`));
} }
}); });
} }
if (!process.env.REGISTRY_ADDRESS) { if (!process.env.CIC_REGISTRY_ADDRESS) {
console.error(colors.redBright('All the required environment variables were not provided!')); console.error(colors.red('All the required environment variables were not provided!'));
process.exit(-1); process.exit(-1);
} }
console.log(colors.yellow(process.env.REGISTRY_ADDRESS));
if (isProduction) { if (isProduction) {
console.log(colors.magenta('Running in production environment!')); console.log(colors.cyan('Running in production environment!'));
setConfigs(environmentVars); setConfigs(environmentVars);
} else { } else {
console.log(colors.green('Running in development environment!')); console.log(colors.cyan('Running in development environment!'));
setConfigs(environmentVars); setConfigs(environmentVars);
} }