Commit Graph

5082 Commits

Author SHA1 Message Date
Anthony Laibe 85db678f89 chores: rename env var 2019-01-16 09:03:46 +00:00
emizzle 9a9eb45836 feat(@embark/core): Run all code in VM2
All code to be run in the console is run through a completely sandboxed VM2 instance, instead of the default Node VM.

VM2 will only allow whitelisted packages in a `require` statement. The whitelisted packages needed to run EmbarkJS scripts are:
```
[
  "@babel/runtime-corejs2/helpers/interopRequireDefault",
  "@babel/runtime-corejs2/core-js/json/stringify",
  "@babel/runtime-corejs2/core-js/promise",
  "@babel/runtime-corejs2/core-js/object/assign",
  "eth-ens-namehash"
]
```

This can be circumvented in an Embark context (ie Plugin) if needed, for example in a Plugin constructor:
```
Embark.events.emit('runcode:register', 'require', require('lodash'), false);

Embark.events.request("runcode:eval", "_.head(['a', 'b', 'c', 'd']);", (err, result) => {
  if(err) return console.log('========> error: ' + err);
  console.log('========> ' + result);
});
```
Will emit `========> a`.

NOTE: Attempts to use this method to override `require` and `eval` should be handled by Embark and not allowed.

NOTE: VM2 seems to allow `eval`, however it is in a completely sandboxed environment, so I'm unsure that we need to be too concerned with this. Thoughts?

Refactor tests to use standalone instance of the newly created VM class, so that code is not evaluated through the console. This was done based on the new unit test case where accounts are redefined in a subsequent unit test, which was not originally working with the initial VM2 PR.

Refactor `codeRunner`, put all code-affecting logic in the `VM` class.

Changed `runCode` to `VM` and converted to TypeScript

Add unit tests for `VM`.
2019-01-16 10:16:54 +11:00
Jonathan Rainville bdb6719baf Revert "feat(blockchain/config): adds a cors command to add it to the config"
This reverts commit ebafe45f22.
2019-01-14 08:29:21 -05:00
Jonathan Rainville 84a74ac4a2 feat(blockchain/config): adds a cors command to add it to the config 2019-01-14 08:29:21 -05:00
Jonathan Rainville 1bafc41d97 change to use an object instead and change templates 2019-01-14 08:29:21 -05:00
Jonathan Rainville 9e349ff267 feat(blockchainConfig): enable having auto cors plus other origins 2019-01-14 08:29:21 -05:00
Jonathan Rainville 540ff751a9 fix(code-generator): use isDev instead of checking env 2019-01-14 10:33:42 +01:00
Anthony Laibe 1e4eaa5fb6 fix: allow to debug instanceOf contracts 2019-01-14 10:33:08 +01:00
emizzle 518d319917 fix(@embark/ipfs): Update IPFS config CORS with default config
Check if IPFS config has `API.HTTPHeaders.Access-Control-Allow-Origin` before attempting to update it.

`ipfs init` produces a default configuration without a `API.HTTPHeaders.Access-Control-Allow-Origin` element in the JSON. This caused an error to be thrown when attempting to update the IPFS config to provide CORS values.
2019-01-13 15:51:34 +01:00
Eric Mastro 05803fcf42
Merge pull request #1220 from embark-framework/feat/enable-regular-txs
feat(@embark/core): Disable regular txs until needed
2019-01-11 23:38:50 +11:00
Anthony Laibe 52d830a34b feat: allow to stop debugger 2019-01-11 11:46:50 +00:00
Iuri Matias 2d716e1101 chore(release): 4.0.0-beta.0 2019-01-10 13:07:10 -05:00
Anthony Laibe 34f5f97b28 feat: add option --no-single-use-cockpit-token
This option is added to run and console.
This can be usefull while developing on cockpit,
the auto reload don't always ask to authenticate
2019-01-10 12:05:01 +00:00
emizzle 135fde0a85 feat(@embark/core): Disable regular txs until needed
Regular transactions (aka “dev funds”) exist in embark as a workaround to a known bug in geth when using metamask. The workaround is to send a transaction at a regular interval (1.5s), which pushes through any transactions that were stuck. The problem is that the transaction logs and trace logs become cluttered and difficult to parse visually.

This PR disables regular transactions until the following conditions are met:
1. Embark is running geth
2. The user is running metamask in their browser
3. The user authenticates to the cockpit with `enableRegularTxs=1|true` in the query string.

A console warning is show in large letters in the browser with a link to the cockpit URL that includes the special query string to enable regular txs.

This could be extended later to have a button in the cockpit that start/stops regular txs. Or at least extended to allow disabling of regular txs once started.

Support standalone blockchain process.
2019-01-10 12:43:18 +11:00
Anthony Laibe 8efa8895aa feat: allow cockpit with docker 2019-01-09 17:35:28 -05:00
Anthony Laibe 2505fa5284 feat: add development mode to cockpit 2019-01-09 17:34:13 -05:00
emizzle 2613c56da7 feat(@embark-ui): Change page title and description
Update page title and description tags in the page head when the view changes.
2019-01-09 17:27:55 -05:00
Jonathan Rainville d0711305fc fix(contracts): fix linking libraries with long paths using output 2019-01-09 17:13:08 -05:00
Michael Bradley, Jr 2dea50ab13 fix(@embark/coderunner): use custom require function in vm context
Supply a custom require function to the vm context for `doEval` so that module
resolution succeeds for both DApp dependencies and Embark dependencies.
2019-01-09 17:12:16 -05:00
emizzle c6c6af01c9 Expose embark version to plugin constructor
Expose Embark’s version to the plugin constructor, allowing plugins to make logical decisions based on the version of Embark.
2019-01-09 16:56:47 -05:00
emizzle f54982254d fix(@embark/core): fix to allow large ether values
Specifying large ether values in the configs was causing embark to crash as javascript could not handle the large integer after the value was converted to wei.

The fix involves converting all values to BigNumbers and then comparing and adding/subtracting BigNumbers from that point forward.

There are two specific components that this affected: `config/contracts > accounts > balance` and `config/blockchain > account > balance`. The contracts config is used to fund accounts for contract deployment while the blockchain config is used for dev_funds accounts.

JSON.stringify unknown log messages

Add a unit test in the test app that sets a large ether value in the config before contract deployment and ensures the account balance is the value specified in the config.

Prior to this commit, if subsequent unit tests contained different account configurations, the blockchain VM was essentially reset, however EmbarkJS was hanging on to the old providers it used from the previous configuation.

In addition, there is a limitation with `embark.registerActionForEvent` in that the action will be persisted across configuration changes. In our case, once the configuration was updated in a subsequent unit test, the directive subdomains would be attempted to be registered in ENS using the old configuration.

This commit does two things:
1) It resets the EmbarkJS.Blockchain and EmbarkJS.Names providers to the new chain configuration
2) Update to the ENS directives that prevents attempts at registered configured subdomains for previous configurations.
2019-01-09 16:56:23 -05:00
Anthony Laibe d67863cff6 feat: add API server 2019-01-09 14:11:03 +00:00
Anthony Laibe df3435f02b feat: coverage without emit
For solc version below 0.4.21

fixes #1230
2019-01-09 13:44:48 +00:00
Jonathan Rainville 749c32cf07 fix(blockchain): fix metamask using the old web3 2019-01-08 09:24:13 -05:00
Michael Bradley, Jr 919d271996 feat(@embark/cli): unify command history without needing a restart
Send a message over IPC when a command is executed from the REPL so that
command history is immediately unified across `embark run` and one/more `embark
console`. Previously, for `embark console` to pick up a command entered in the
REPL of an `embark run` of which it was an IPC client it would have to be
restarted, and vice versa.
2019-01-07 17:02:28 -06:00
Iuri Matias 39d5e9f205 chore(release): 4.0.0-alpha.3 2018-12-31 15:10:59 -05:00
Iuri Matias 0958a17f3c refactor(@embark/contracts_manager) fix: The for-in loop variable 'className' should be explicitly scoped with var to avoid pollution 2018-12-24 16:14:01 -05:00
Iuri Matias d2a37f9bdf chore(@embark) remove extra line 2018-12-24 16:14:01 -05:00
Iuri Matias 035dfb84cf refactor(@embark/embark-ui) remove unused variables 2018-12-24 16:14:01 -05:00
Iuri Matias c693db9c2e refactor(@embark/embark-ui) remove usage of use strict 2018-12-24 16:14:01 -05:00
Michael Bradley, Jr 9e7bc53ebf fix(@embark/blockchain_process): proxy listens on the specified host
Change the blockchain proxy so that it listens on the `host` argument passed to
`Proxy#serve` rather than on `defaultHost`.
2018-12-21 22:06:46 -06:00
Michael Bradley d840198fc1 Revert "Fix for error running anything on Windows"
This reverts commit 0bea97c98a.
2018-12-21 21:45:57 -06:00
Wil Bown 0bea97c98a Fix for error running anything on Windows
I had to eject the webpack config and add this to get any project at all to run on Windows/Git Bash without this error:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.                                                                                                                                                                              ││  - configuration.context: The provided value "C:/Users/xxx/GitHub/xxxxxx" is not an absolute path!                                                                                                                                                                                              ││    -> The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory.

Not sure if this is the best place, but should work on any platform.

Context (Environment)
OS: Windows 10, Git Bash v2.20.0 64bit
Embark Version: 3.2.7
Node Version: 10.14.2
NPM Version: 6.4.1
2018-12-21 13:01:41 -05:00
Jonathan Rainville d5f6da3599 fix(ens/web3): use blockchain connector for ens and fix global web3
Use the blockchain connector for the ENS module to remove direct web3 usages
Fix global web3 being overidden by the code generator
2018-12-21 12:55:39 -05:00
Jonathan Rainville 604e267e9d fix(proxy): delete old ids for accounts
Caused issues because the different ids come in
2018-12-21 12:55:39 -05:00
Jonathan Rainville 9a6149fef7 fix(gethClient): clear timeout when call backing 2018-12-21 12:48:41 -05:00
Jonathan Rainville b20bce9880 fix(ws): up fragmentation threshold to patch Geth bug with WS 2018-12-21 12:48:41 -05:00
Jonathan Rainville f2d6f609ba chore(browser): change Go to refresh since that's what they do 2018-12-21 12:48:13 -05:00
emizzle 1ccc3e7796 fix(@embark/core): Support legacy Parity version parsing
Parse legacy version of Parity. Pre-version 2 of Parity outputs “Parity <version>” instead of the post-version 2 “Parity-Ethereum”. Embark was emitting an error when the version of an older Parity client could not be parsed, and no warning messages regarding the version were shown.

This PR modifies the regex that parses the version so that older versions of Parity can be detected and the appropriate warning message can appear.
2018-12-21 11:49:21 -05:00
Michael Bradley, Jr a91a4dd7c0 feat(@embark/core): store IPC files in a dir within os.tmpdir()
This PR replaces #1202.

When embark is running on Linux and macOS, unix socket files are used for
geth's and embark's IPC files. A problem can arise if a DApp is in a deeply
nested directory structure such that character-length of the path to a socket
file exceeds the maximum supported length. See #450.

Also, if the DApp context is a Linux container running on a Windows Docker
host, and if the DApp is mounted from the host's file system, there is a
problem: unix socket files are incompatible with the Windows file system.

Solve both problems at once by storing a DApp's `.ipc` files in a directory
within `os.tmpdir()`. Introduce `ipcPath()` in `core/fs.js` and use a truncated
SHA-512 hash of the DApp's path in the name of the temporary directory created
for that purpose so that DApps won't collide (with an acceptably low
probability of collision).
2018-12-21 11:31:49 -05:00
Jonathan Rainville 9c37f9738e fix(debugger): fix debugger displays 2018-12-20 19:04:21 -05:00
Jonathan Rainville e207537d6e fix(profiler): do not exit on error but print it 2018-12-20 17:42:54 -05:00
Andre Medeiros b0c226a13f feature: disallow eval and require in cockpit 2018-12-20 17:41:03 -05:00
Jonathan Rainville af48788ab5 fix(test): use logger instead of engine.logger 2018-12-20 17:39:45 -05:00
Jonathan Rainville 7811211f91 fix(blockchain/geth): create geth dev account before other accounts 2018-12-20 17:39:45 -05:00
Michael Bradley, Jr 6c7782c435 fix(@embark/cli): start the dashboard after services are started
Start the `embark run` dashboard after services have been started so the REPL
instantiated by the dashboard can successfully request the `console:history`
event.

Delete `cmd/dashboard/command_history.js` since it's no longer in use.
2018-12-20 17:19:18 -05:00
Anthony Laibe e3a7b74284 feat: apply contract change to test
Give the same ability to config function on test
than when running with embark run
2018-12-20 16:38:14 -05:00
Andre Medeiros 3a8808e2f5 fix: allow message signing with wallet address 2018-12-20 16:36:22 -05:00
Pascal Precht 2195475fe6 fix(@embark/ens): make resolve() work with promises and callbacks
Changes in c64c093a48 resulted in a regression
that ENS functions within console/dashboard didn't work properly anymore.

This commit ensures that both APIs, `EmbarkJS.Names.resolve()` as well as
`EmbarkJS.Names.lookup()` can be either used using `async/await` or promised
based syntax within the console/dashboard.

Example:

```
await EmbarkJS.Names.resolve('me.eth.eth');

EmbarkJS.Names.resolve('me.eth.eth').then(val => ..., err => ...)

EmbarkJS.Names.resolve('me.eth.eth', (err, val) => ...)
```

Same with:

```
await EmbarkJS.Names.lookup('0x...');

EmbarkJS.Names.lookup('0x...').then(val => ..., err => ...)

EmbarkJS.Names.lookup('0x...', (err, val) => ...)
```
2018-12-20 16:33:41 -05:00
emizzle ffcff4a16c fix(@embark/core): Proxy support for raw transactions
Contract logs were not occuring in the test_app for reasons unknown, except that it seemed to be pinned to the fact that accounts were being defined using a mnemonic. Turns out this caused transactions to be signed, and therefore sent using `eth_sendRawTransaction`.

Add ability to decode raw transactions in the proxy so that those transactions are also logged.

Refactor Proxy in to a class and add a Proxy unit test test.

Remove RLP package, as there is another way to decode a tx without needed an additional package.

Replace eth transaction methods with constants throughout the codebase.

Add unit tests for Console Listener.
2018-12-20 16:29:33 -05:00