Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log('auctionStart: ', auctionStart.toNumber())
console.log('price: ', price.map(n => n.toNumber()))
if (closingPrice[1].gt(0) || currentAuctionIndex.gt(index)) return { status: AuctionStatus.ENDED }
// this should show theoretically auctions as ENDED and allow to claim,
// which internally closes the auction with a 0 buy order
// TODO: consider if (currentAuctionIndex < index && auction has sell volume) return AuctionStatus.PLANNED
if (currentAuctionIndex.lt(index)) return { status: AuctionStatus.PLANNED }
if (auctionStart.equals(1)) return { status: AuctionStatus.INIT }
if (currentAuctionIndex.equals(index) && closingPrice[0].equals(0) && outstandingVolume.eq(0)) {
console.log('Theoretically closed')
return { status: AuctionStatus.ENDED, theoretically: true }
}
if (!price[1].equals(0)) return { status: AuctionStatus.ACTIVE }
return { status: AuctionStatus.INACTIVE }
}
auctionStart,
price,
outstandingVolume,
}: AuctionStatusArgs) => {
console.log('closingPrice: ', closingPrice.map(n => n.toNumber()))
console.log('index: ', index)
console.log('currentAuctionIndex: ', currentAuctionIndex.toNumber())
console.log('auctionStart: ', auctionStart.toNumber())
console.log('price: ', price.map(n => n.toNumber()))
if (closingPrice[1].gt(0) || currentAuctionIndex.gt(index)) return { status: AuctionStatus.ENDED }
// this should show theoretically auctions as ENDED and allow to claim,
// which internally closes the auction with a 0 buy order
// TODO: consider if (currentAuctionIndex < index && auction has sell volume) return AuctionStatus.PLANNED
if (currentAuctionIndex.lt(index)) return { status: AuctionStatus.PLANNED }
if (auctionStart.equals(1)) return { status: AuctionStatus.INIT }
if (currentAuctionIndex.equals(index) && closingPrice[0].equals(0) && outstandingVolume.eq(0)) {
console.log('Theoretically closed')
return { status: AuctionStatus.ENDED, theoretically: true }
}
if (!price[1].equals(0)) return { status: AuctionStatus.ACTIVE }
return { status: AuctionStatus.INACTIVE }
}
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 (blocked) {
disabledReason = 'geoblock'
} else {
blocked = await netBlockedPromise
!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 netBlockedPromise = isNetBlocked(['1'])
// geoblock gets precedence, checked last
blocked = await isGeoBlocked()
if (blocked) {
disabledReason = 'geoblock'
} else {
blocked = await netBlockedPromise
if (blocked) disabledReason = 'networkblock'
}
// init GA
ReactGA.initialize(GA_CODES.MAIN)
}
else {
// fallback
console.warn('No hostname match - fallingback to geographical block')
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 (blocked) {
disabledReason = 'geoblock'
} else {
blocked = await netBlockedPromise
if (blocked) disabledReason = 'networkblock'
}
// init GA
ReactGA.initialize(GA_CODES.MAIN)
}
else {
// fallback
console.warn('No hostname match - fallingback to geographical block')
index,
currentAuctionIndex,
auctionStart,
price,
outstandingVolume,
}: AuctionStatusArgs) => {
console.log('closingPrice: ', closingPrice.map(n => n.toNumber()))
console.log('index: ', index)
console.log('currentAuctionIndex: ', currentAuctionIndex.toNumber())
console.log('auctionStart: ', auctionStart.toNumber())
console.log('price: ', price.map(n => n.toNumber()))
if (closingPrice[1].gt(0) || currentAuctionIndex.gt(index)) return { status: AuctionStatus.ENDED }
// this should show theoretically auctions as ENDED and allow to claim,
// which internally closes the auction with a 0 buy order
// TODO: consider if (currentAuctionIndex < index && auction has sell volume) return AuctionStatus.PLANNED
if (currentAuctionIndex.lt(index)) return { status: AuctionStatus.PLANNED }
if (auctionStart.equals(1)) return { status: AuctionStatus.INIT }
if (currentAuctionIndex.equals(index) && closingPrice[0].equals(0) && outstandingVolume.eq(0)) {
console.log('Theoretically closed')
return { status: AuctionStatus.ENDED, theoretically: true }
}
if (!price[1].equals(0)) return { status: AuctionStatus.ACTIVE }
return { status: AuctionStatus.INACTIVE }
}
if (closingPrice[1].gt(0) || currentAuctionIndex.gt(index)) return { status: AuctionStatus.ENDED }
// this should show theoretically auctions as ENDED and allow to claim,
// which internally closes the auction with a 0 buy order
// TODO: consider if (currentAuctionIndex < index && auction has sell volume) return AuctionStatus.PLANNED
if (currentAuctionIndex.lt(index)) return { status: AuctionStatus.PLANNED }
if (auctionStart.equals(1)) return { status: AuctionStatus.INIT }
if (currentAuctionIndex.equals(index) && closingPrice[0].equals(0) && outstandingVolume.eq(0)) {
console.log('Theoretically closed')
return { status: AuctionStatus.ENDED, theoretically: true }
}
if (!price[1].equals(0)) return { status: AuctionStatus.ACTIVE }
return { status: AuctionStatus.INACTIVE }
}
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 netBlockedPromise = isNetBlocked(['1'])
// geoblock gets precedence, checked last
async function conditionalRender() {
/* User's environment does not have access to window API (e.g user on mobile?) */
if (typeof window === 'undefined') return false
let blocked = true, disabledReason, ALLOWED_NETWORK
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 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()