Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* Scenario 1: User is a developer running app locally: BLOCK: nothing */
if (
FE_CONDITIONAL_ENV !== 'production' ||
URLS.APP_URLS_DEV.includes(hostname) ||
URLS.APP_URLS_LOCAL.includes(hostname) ||
hostname.startsWith('10')
) return preAppRender().catch(console.error)
/* PRODUCTION builds should be geoBlocked */
if (FE_CONDITIONAL_ENV === 'production') {
/* Scenario 1a: User is a developer on any of the STAGING URLS OR ipfs */
if (URLS.APP_URLS_STAGING.includes(hostname) || hostname.includes('ipfs')) {
blocked = await isGeoBlocked()
blocked && (disabledReason = 'geoblock')
!URLS.APP_URLS_STAGING.includes(hostname) && ReactGA.initialize(GA_CODES.IPFS)
}
// Main release Scenarios:
/* Scenario 2: User is using the dx on dutchx-rinkeby (RINKEBY): BLOCK: networks */
else if (hostname === URLS.APP_URLS_PROD[1]) {
ALLOWED_NETWORK = 'Rinkeby Test Network'
blocked = await isNetBlocked(['4'])
if (blocked) disabledReason = 'networkblock'
// init GA
ReactGA.initialize(GA_CODES.RINKEBY)
}
/* Scenario 3: User is using the dx on dutchx.app (MAIN): BLOCK: all networks + geoblock */
else if (hostname === URLS.APP_URLS_PROD[0]) {
ALLOWED_NETWORK = 'Ethereum Mainnet'
const netBlockedPromise = isNetBlocked(['1'])
// geoblock gets precedence, checked last
blocked = await isGeoBlocked()
if (
FE_CONDITIONAL_ENV !== 'production' ||
URLS.APP_URLS_DEV.includes(hostname) ||
URLS.APP_URLS_LOCAL.includes(hostname) ||
URLS.APP_URLS_PR_REVIEW_TEST(hostname) ||
hostname.startsWith('10')
) return preAppRender().catch(console.error)
/* PRODUCTION builds should be geoBlocked */
if (FE_CONDITIONAL_ENV === 'production') {
/* Scenario 1a: User is a developer on any of the STAGING URLS OR ipfs */
if (URLS.APP_URLS_STAGING.includes(hostname) || hostname.includes('ipfs')) {
blocked = await isGeoBlocked()
blocked && (disabledReason = 'geoblock')
!URLS.APP_URLS_STAGING.includes(hostname) && ReactGA.initialize(GA_CODES.IPFS)
/* Scenario 1b: User is a developer on a PR-review URL */
} else if (URLS.APP_URLS_PR_REVIEW_TEST(hostname)) {
blocked = false
}
// Main release Scenarios:
/* Scenario 2: User is using the dx on dutchx-rinkeby (RINKEBY): BLOCK: networks */
else if (URLS.APP_URLS_PROD.RINKEBY.includes(hostname)) {
ALLOWED_NETWORK = 'Rinkeby Test Network'
blocked = await isNetBlocked(['4'])
if (blocked) disabledReason = 'networkblock'
// init GA
ReactGA.initialize(GA_CODES.RINKEBY)
}
/* Scenario 3: User is using the dx on dutchx.app (MAIN): BLOCK: all networks + geoblock */
else if (URLS.APP_URLS_PROD.MAIN.includes(hostname)) {
ALLOWED_NETWORK = 'Ethereum Mainnet'
const { hostname } = window.location
const { FE_CONDITIONAL_ENV } = process.env
/* Scenario 1: User is a developer running app locally: BLOCK: nothing */
if (
FE_CONDITIONAL_ENV !== 'production' ||
URLS.APP_URLS_DEV.includes(hostname) ||
URLS.APP_URLS_LOCAL.includes(hostname) ||
hostname.startsWith('10')
) return preAppRender().catch(console.error)
/* PRODUCTION builds should be geoBlocked */
if (FE_CONDITIONAL_ENV === 'production') {
/* Scenario 1a: User is a developer on any of the STAGING URLS OR ipfs */
if (URLS.APP_URLS_STAGING.includes(hostname) || hostname.includes('ipfs')) {
blocked = await isGeoBlocked()
blocked && (disabledReason = 'geoblock')
!URLS.APP_URLS_STAGING.includes(hostname) && ReactGA.initialize(GA_CODES.IPFS)
}
// Main release Scenarios:
/* Scenario 2: User is using the dx on dutchx-rinkeby (RINKEBY): BLOCK: networks */
else if (hostname === URLS.APP_URLS_PROD[1]) {
ALLOWED_NETWORK = 'Rinkeby Test Network'
blocked = await isNetBlocked(['4'])
if (blocked) disabledReason = 'networkblock'
// init GA
ReactGA.initialize(GA_CODES.RINKEBY)
}
/* Scenario 3: User is using the dx on dutchx.app (MAIN): BLOCK: all networks + geoblock */
else if (hostname === URLS.APP_URLS_PROD[0]) {
const { hostname } = window.location
const { FE_CONDITIONAL_ENV } = process.env
/* Scenario 1: User is a developer running app locally: BLOCK: nothing */
if (
FE_CONDITIONAL_ENV !== 'production' ||
URLS.APP_URLS_DEV.includes(hostname) ||
URLS.APP_URLS_LOCAL.includes(hostname) ||
URLS.APP_URLS_PR_REVIEW_TEST(hostname) ||
hostname.startsWith('10')
) return preAppRender().catch(console.error)
/* PRODUCTION builds should be geoBlocked */
if (FE_CONDITIONAL_ENV === 'production') {
/* Scenario 1a: User is a developer on any of the STAGING URLS OR ipfs */
if (URLS.APP_URLS_STAGING.includes(hostname) || hostname.includes('ipfs')) {
blocked = await isGeoBlocked()
blocked && (disabledReason = 'geoblock')
!URLS.APP_URLS_STAGING.includes(hostname) && ReactGA.initialize(GA_CODES.IPFS)
/* Scenario 1b: User is a developer on a PR-review URL */
} else if (URLS.APP_URLS_PR_REVIEW_TEST(hostname)) {
blocked = false
}
// Main release Scenarios:
/* Scenario 2: User is using the dx on dutchx-rinkeby (RINKEBY): BLOCK: networks */
else if (URLS.APP_URLS_PROD.RINKEBY.includes(hostname)) {
ALLOWED_NETWORK = 'Rinkeby Test Network'
blocked = await isNetBlocked(['4'])
if (blocked) disabledReason = 'networkblock'
// init GA
ReactGA.initialize(GA_CODES.RINKEBY)