fix(@embark/demo): Fix demo

Fix demo not running, by fixing the following issues:

This was due to the removal of `Web3` from the VM initialisation in a recent PR. The reasoning behind the removal was so that the modules that need Web3 could require it as needed, however, it is needed in 3 modules (ENS, Whisper, and web3Connector), all of which would define `const Web = …` in the code generated EmbarkJS, thus causing issues in itself. This needs to be rethought prior to removing it from the VM sandbox.

Because Web3 is back to being required in the global sandbox of the VM, it does not need to be registered in the `web3Connector` module, hence the removal of the `runcode:register`.

Module not found: Error: Can't resolve 'embarkArtifacts/contracts/SimpleStorage.js' in '/Users/emizzle/temp/embark_demo/app/components’`
This was fixed by replacing
```
import SimpleStorage from 'Embark/contracts/SimpleStorage';
```
with
```
import SimpleStorage from '../../embarkArtifacts/contracts/SimpleStorage';
```

revert changes changing __Web3 to Web3
This commit is contained in:
emizzle 2019-02-21 15:23:11 +11:00 committed by Eric Mastro
parent 5e9955e828
commit 58ea3d9c30
2 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,7 @@
const VM = require('./vm'); const VM = require('./vm');
const fs = require('../../core/fs'); const fs = require('../../core/fs');
const EmbarkJS = require('embarkjs'); const EmbarkJS = require('embarkjs');
const Web3 = require('web3');
class CodeRunner { class CodeRunner {
constructor(embark, options) { constructor(embark, options) {
@ -13,7 +14,8 @@ class CodeRunner {
this.ipc = options.ipc; this.ipc = options.ipc;
this.vm = new VM({ this.vm = new VM({
sandbox: { sandbox: {
EmbarkJS EmbarkJS,
Web3
}, },
require: { require: {
mock: { mock: {

View File

@ -1,5 +1,5 @@
import EmbarkJS from 'Embark/EmbarkJS'; import EmbarkJS from 'Embark/EmbarkJS';
import SimpleStorage from 'Embark/contracts/SimpleStorage'; import SimpleStorage from '../../embarkArtifacts/contracts/SimpleStorage';
import React from 'react'; import React from 'react';
import { Form, FormGroup, FormControl, HelpBlock, Button } from 'react-bootstrap'; import { Form, FormGroup, FormControl, HelpBlock, Button } from 'react-bootstrap';