Skip to content

Commit

Permalink
fix: revert #fdb5a58e "fix for (decentraland#561)" (decentraland#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Miras authored and eordano committed Mar 9, 2019
1 parent 3faa1ba commit 1faa0b4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
10 changes: 3 additions & 7 deletions packages/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,9 @@ export namespace visualConfigurations {
export const far = farDistance
}

export const PREVIEW: boolean = !!(global as any).preview

export const EDITOR: boolean = !!(global as any).isEditor

export const AVOID_WEB3: boolean = !!(global as any).avoidWeb3 || EDITOR

export const DEBUG = location.search.indexOf('DEBUG') !== -1 || !!(global as any).mocha || PREVIEW || EDITOR
export const PREVIEW: boolean = !!(global as any)['preview']
export const EDITOR: boolean = !!(global as any)['isEditor']
export const DEBUG = location.search.indexOf('DEBUG') !== -1 || !!(global as any)['mocha'] || PREVIEW || EDITOR
export const MOBILE_DEBUG = location.search.indexOf('MOBILE_DEBUG') !== -1
export const DEBUG_METRICS = DEBUG && location.search.indexOf('DEBUG_METRICS') !== -1

Expand Down
16 changes: 4 additions & 12 deletions packages/entryPoints/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
global['preview'] = window['preview'] = true
global['avoidWeb3'] = window['avoidWeb3']

import 'engine'

Expand All @@ -10,7 +9,7 @@ import { log } from '../engine/logger'
import { bodyReadyFuture, engine } from '../engine/renderer/init'
import { initShared } from '../shared'
import { loadedParcelSceneWorkers, enablePositionReporting } from '../shared/world/parcelSceneManager'
import { ETHEREUM_NETWORK, DEBUG, AVOID_WEB3 } from '../config'
import { ETHEREUM_NETWORK, DEBUG } from '../config'
import { ILandToLoadableParcelScene, ILand, IScene, MappingsResponse } from '../shared/types'
import { SceneWorker } from '../shared/world/SceneWorker'
import { WebGLParcelScene } from '../dcl/WebGLParcelScene'
Expand Down Expand Up @@ -64,14 +63,6 @@ async function initializePreview(userScene: ILand) {
}
}

async function initEth() {
if (!AVOID_WEB3) {
return initShared()
}

return { address: '0x0000000000000000000000000000000000000000', net: ETHEREUM_NETWORK.MAINNET }
}

async function loadClient() {
await initBabylonClient()
await loadScene()
Expand All @@ -88,11 +79,12 @@ async function loadClient() {

bodyReadyFuture
.then(async body => {
const { net } = await initShared()

await loadClient()
const { net } = await initEth()

// Warn in case wallet is set in mainnet
if (net === ETHEREUM_NETWORK.MAINNET && DEBUG && !AVOID_WEB3) {
if (net === ETHEREUM_NETWORK.MAINNET && DEBUG) {
const style = document.createElement('style') as HTMLStyleElement
style.appendChild(
document.createTextNode(
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/ethereum/provider.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { WebSocketProvider, RequestManager } from 'eth-connect'
import { error } from 'engine/logger'
import { future } from 'fp-future'
import { AVOID_WEB3 } from 'config'
import { EDITOR } from 'config'

export const providerFuture = future()
export const requestManager = new RequestManager(null)

{
if (!AVOID_WEB3) {
if (!EDITOR) {
window.addEventListener('load', async () => {
// Modern dapp browsers...
if (window['ethereum']) {
Expand Down

0 comments on commit 1faa0b4

Please sign in to comment.