Skip to content

Commit

Permalink
move environment based constants to src/env.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mnzaki committed Aug 20, 2019
1 parent 3dd3258 commit 9448d62
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
7 changes: 4 additions & 3 deletions src/backendMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions src/ui/registration/containers/entropy.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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'

Expand Down Expand Up @@ -59,8 +60,9 @@ export class EntropyContainer extends React.Component<Props, State> {
}

private updateEntropyProgress = async (): Promise<void> => {
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) {
Expand Down

0 comments on commit 9448d62

Please sign in to comment.