From 1faa0b49a73f86d14ef18656714182ce706a883e Mon Sep 17 00:00:00 2001 From: Federico Miras Date: Mon, 18 Feb 2019 14:37:29 -0300 Subject: [PATCH] fix: revert #fdb5a58e "fix for (#561)" (#569) --- packages/config/index.ts | 10 +++------- packages/entryPoints/preview.ts | 16 ++++------------ packages/shared/ethereum/provider.ts | 4 ++-- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/packages/config/index.ts b/packages/config/index.ts index ccd1aaed2..30b41c790 100644 --- a/packages/config/index.ts +++ b/packages/config/index.ts @@ -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 diff --git a/packages/entryPoints/preview.ts b/packages/entryPoints/preview.ts index 80633a685..101de23c7 100644 --- a/packages/entryPoints/preview.ts +++ b/packages/entryPoints/preview.ts @@ -1,5 +1,4 @@ global['preview'] = window['preview'] = true -global['avoidWeb3'] = window['avoidWeb3'] import 'engine' @@ -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' @@ -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() @@ -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( diff --git a/packages/shared/ethereum/provider.ts b/packages/shared/ethereum/provider.ts index f6cfed1a8..cd9070cc6 100644 --- a/packages/shared/ethereum/provider.ts +++ b/packages/shared/ethereum/provider.ts @@ -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']) {