diff --git a/src/backendMiddleware.ts b/src/backendMiddleware.ts index e8eb490b75..205df0b673 100644 --- a/src/backendMiddleware.ts +++ b/src/backendMiddleware.ts @@ -11,7 +11,7 @@ import { IpfsCustomConnector } from './lib/ipfs' import { jolocomContractsAdapter } from 'jolocom-lib/js/contracts/contractsAdapter' import { jolocomEthereumResolver } from 'jolocom-lib/js/ethereum/ethereum' import { jolocomContractsGateway } from 'jolocom-lib/js/contracts/contractsGateway' -import { skipIdentityRegisteration } from './config'; +import { SKIP_IDENTITY_REGISTRATION } from './env' export class BackendMiddleware { public identityWallet!: IdentityWallet @@ -41,8 +41,9 @@ export class BackendMiddleware { gateway: jolocomContractsGateway, }, }) - if (skipIdentityRegisteration) { - this.registry.commit = this.fuelKeyWithEther = async (arg: any) => undefined + if (SKIP_IDENTITY_REGISTRATION) { + this.registry.commit = this.fuelKeyWithEther = async (arg: any) => + undefined this.setIdentityWallet = async function( userVault: SoftwareKeyProvider, pass: string, diff --git a/src/config.ts b/src/config.ts index 840a003145..f78f3cde34 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,14 +1,5 @@ import typeOrmConf from '../ormconfig' -const env = process.env['NODE_ENV'] || 'development' -const isDev = env === 'development' -// @ts-ignore -const isTest = env === 'test' -const isTestE2E = env === 'test-e2e' - -export const skipEntropyCollection = isDev || isTest || isTestE2E -export const skipIdentityRegisteration = isDev || isTestE2E - export default { fuelingEndpoint: 'https://faucet.jolocom.com/request', typeOrmConfig: typeOrmConf, diff --git a/src/env.ts b/src/env.ts new file mode 100644 index 0000000000..4b0b40445a --- /dev/null +++ b/src/env.ts @@ -0,0 +1,8 @@ +const env = process.env['NODE_ENV'] || 'development' +const isDev = env === 'development' +// @ts-ignore unused so far +const isTest = env === 'test' +const isTestE2E = env === 'test-e2e' + +export const SKIP_ENTROPY_COLLECTION = isDev || isTest || isTestE2E +export const SKIP_IDENTITY_REGISTRATION = isDev || isTestE2E diff --git a/src/ui/registration/containers/entropy.tsx b/src/ui/registration/containers/entropy.tsx index 2f3ca224b6..06c6f64cb4 100644 --- a/src/ui/registration/containers/entropy.tsx +++ b/src/ui/registration/containers/entropy.tsx @@ -1,4 +1,5 @@ -import { skipEntropyCollection } from 'src/config' +import { SKIP_ENTROPY_COLLECTION } from 'src/env' + import React from 'react' import { connect } from 'react-redux' import { registrationActions } from 'src/actions' @@ -11,7 +12,7 @@ import { import { generateSecureRandomBytes } from 'src/lib/util' import { withErrorScreen } from 'src/actions/modifiers' import { ThunkDispatch } from 'src/store' -import { AppError, ErrorCode } from '../../../lib/errors' +import { AppError, ErrorCode } from 'src/lib/errors' import { routeList } from 'src/routeList' import { StatusBar } from 'react-native' @@ -59,8 +60,9 @@ export class EntropyContainer extends React.Component { } private updateEntropyProgress = async (): Promise => { - const entropyProgress = skipEntropyCollection ? 1 : this.state.entropyProgress - + const entropyProgress = SKIP_ENTROPY_COLLECTION + ? 1 + : this.state.entropyProgress if (entropyProgress >= 1) { this.setState({ sufficientEntropy: true, entropyProgress: 1 }) while (this.entropyGenerator.getProgress() < 1) {