Commit Graph

5614 Commits

Author SHA1 Message Date
Pascal Precht dc7974c42d docs: fix broken code snippet in installation guide
Unfortunately, markdown syntax isn't properly supported within the
notification tag, so we have to be explicit here.
2019-06-11 09:59:41 +02:00
Michael Bradley, Jr ff3100b035 chore(release): 4.1.0-beta.3 2019-06-07 13:42:13 -05:00
Michael Bradley, Jr d264070069 style(@embark/contracts-manager): add semicolon to end of statement 2019-06-06 15:49:53 -05:00
Pascal Precht d10c0b7951 feat(@cockpit/explorer): enable users to send ether through payable methods (#1649) 2019-06-06 12:52:01 -04:00
Michael Bradley, Jr ed65b066e7 refactor (@embark/embarkjs-ens): move embarkjs-ens to its own module 2019-06-06 11:47:03 -05:00
Michael Bradley, Jr b45b2e21db fix(@embarkjs): unconditionally require symlinked embarkjs-* modules 2019-06-06 08:26:20 -05:00
André Medeiros 312c631f86
fix: gas estimates in test (#1650) 2019-06-04 13:12:43 -04:00
Ricardo Guilherme Schmidt 6d844d72e5 fix(@embark/swarm): update url-scheme to bzz-raw
bzzr was removed in swarm 0.4.0. This change is necessary to this test dapp work with swarm 0.4.0.
2019-06-04 11:14:53 +02:00
Andre Medeiros 0f633cd04e chore: make contract artifacts usable in node 2019-06-01 17:35:10 -05:00
Pascal Precht f2903e7577 fix(@embarkjs/whisper): don't rely on global EmbarkJS in whisper APIs
When trying to either sending, or listening to whisper channels within
Embark's consoles (CLI and Cockpit), the console outputs an error that
`EmbarkJS` isn't defined.

E.g. running:

```
> EmbarkJS.Messages.listenTo({ topic: ['somechannel'])
```

Outputs:

```
EmbarkJS is not defined
```

This seemed very odd as outputting `EmbarkJS` and all of its members
worked totally fine.

It turns out that both methods, `listenTo()` and `sendMessage()`, in
`EmbarkJS.Messages` are not necessarily what one thinks they are.
EmbarkJS decorates both methods to create some options that need to be
available in the delegate, two of them being `EmbarkJS.Utils.toAscii`
and `EmbarkJS.Utils.fromAscii` (ac76a40a61/packages/embarkjs-whisper/src/index.js (L43-L62) and ac76a40a61/packages/embarkjs-whisper/src/index.js (L64-L73))

These two global references to `EmbarkJS` are the only ones in `embarkjs-whisper`
and they are not the same reference as the `EmbarkJS` sandbox global
registered in the VM here ac76a40a61/packages/embark-code-runner/src/index.ts (L33).

In other words, the `EmbarkJS is not defined` message actually refers
to the `EmbarkJS` in the wrapping method, not the one registered with
the VM, which is also why inspecting the `EmbarkJS` object through the
VM works fine.

Since the `toAscii()` and `fromAscii()` methods in use are really just
facades around `web3.utils.[fromAscii|toAscii]()`, we can replace the
global EmbarkJS dependency with web3 utils that are already available
anyways.
2019-05-31 14:07:38 +02:00
Michael Bradley, Jr 3c9ed4183d refactor(@embark/watcher): downgrade from chokidar 3.x to latest 2.x
chokidar 3.x has fsevents `^2.0.6` [as a dependency][dependency], which
introduced node v12.x compatibility, a sought-after goal of our PR
1638. However, fsevents `2.0.6` node compatibility range is quite
[complicated][complicated]. After fsevents `2.0.6` was published its
maintainers published `1.2.9`, which backports NodeJS v12.x compatibility minus
some performance increases, while offering [much more
straightforward][straightforward] node compatibility. fsevents `1.2.9` [is
compatible][compatible] with the latest v2.x release of
chokidar (`2.1.6`). Since Embark advertises runtime compatibility with node
`>=8.11.3`, downgrade chokidar to `2.1.6`.

[dependency]: https://github.com/paulmillr/chokidar/blob/3.0.0/package.json#L25
[complicated]: https://github.com/fsevents/fsevents/blob/v2.0.6/package.json#L10
[straightforward]: https://github.com/fsevents/fsevents/blob/v1.2.9/package.json#L14
[compatible]: https://github.com/paulmillr/chokidar/blob/2.1.6/package.json#L49
2019-05-29 22:09:23 -05:00
Michael Bradley, Jr ac76a40a61 fix(@cockpit/explorer): slice contract function result string only if starts/ends with double-quote
Closes #1636.
2019-05-28 09:36:38 +02:00
Michael Bradley, Jr d116549c32 refactor(@embark/watcher): upgrade chokidar to 3.0.0
Upgrade chokidar to a version that's compatible with NodeJS v12.x.

Unfortunately, embark has other transitive dependencies that are not compatible
with v12.x, but upgrading chokidar is still a good step.
2019-05-28 09:36:06 +02:00
Michael Bradley, Jr 030aba190d build: change the engines range for NodeJS to indicate embark is not compatible with v12.x 2019-05-28 09:35:44 +02:00
Michael Bradley, Jr d477adc87e feat(@embark/cli): exit with error if --template and --contracts-only are both used with 'new' cmd 2019-05-28 09:35:24 +02:00
Pascal Precht e5fc12e256 fix(@embark/test-runner): don't try to deploy and register ENS domains after JS tests have run
When running unit tests inside a project that configures ENS subdomains using Smart Contract directives,
the tests will output an error because of that particular Smart Contract's `deployedAddress` being `undefined`.

This happens only when running tests, not when deploying the Smart Contracts including the custom ENS setup.

It turns out that Embark attempts to compile and deploy the Smart Contracts of the project *twice* - once
before tests are executed, and another time **after** tests are done executing.

Both compilations/deployments are triggered through our custom `config()` function within test context,
which ensures all Smart Contracts are deployed before tests are executed.

This explains a few things:

1. There's no such issue when running `embark run`, in fact the custom ENS subdomains work perfectly fine
2. That's also why the tests are passing fine as well as the first compilation/deployment doesn't have any issues.
The errors only appear *after* the tests have been executed.

Still, this raises a few more questions, mainly

- Why is the Smart Contract's `deployedAddress` property `undefined` when `config()` is executed a second time?
- Why is `config()` executed a second time in the first place?

Let's look into both of these.

Assuming that there's a valid reason that `config()` is called twice, it's remains unclear why that property
of a Smart Contract object is `undefined` in the second run. The reason for that is that Embark determines whether
or not a particular Smart Contract should be deployed. One of the routines ensures that only the Smart Contracts
configured for deployment are actually attempted to be deployed (as opposed to just deploying all Smart Contracts
found in the file system).

It turns out that the second `config()` call is done without any Smart Contract configuration, resulting basically in no deployment
for any Smart Contract of the application. The `address` and `deployedAddress` of a Smart Contract object are however only set
 *after* deployment, resulting in them being `undefined`.

**All this makes sense.**

`config()` is simply not designed for being used with an empty `contracts: {}` config. This raises another question:

Why is `config()` called with an empty configuration? This leads us to the second point.

It does seem a bit weird that Embark tries to configure compile *and* deploy a DApp's Smart Contracts again right **after**
the tests have been executed. So why is that?

A quick `git blame` (no blame intended here) shows us that this routine has been introduced in https://github.com/embark-framework/embark/commit/12cbb7bdd.

Notice the second list point of the commit:

> Contracts that had been compiled in the JS tests were being deleted at the end of the JS test run, which caused errors
> with the files not being found. The fix was to reset the contracts config to no longer require the non-test contracts
> to be compiled/deployed.

The above is a little tricky to understand without a little bit of context: Embark runs two types of tests, JavaScript tests
and Solidity tests. It does that as part of a single process, keeping state in memory in-between those two test runs.

With that in mind, the commit mentioned above says the following:

1. Artifacts that Embark generates as part of its compilation process are erased after JS tests are done executing.
This makes a lot of sense as we don't want to leave any side effects undone when tests are finished.

2. The commit ensures that not only the artifacts are removed from disc, but also updates Embark's state in memory
for `contractFiles`. The reason for that is that otherwise, in the second test run for Solidity tests, Embark will
  throw errors as it tries to look up the path for the artifacts in memory for all the Smart Contracts that had been
  compiled before.

3. Last but not least, there's *another* state that needs a reset and that's the Smart Contract configuration. If Embark
doesn't reset the memory it'll assume in the second run that all of those Smart Contracts left in memory
"have no code associated to it", while in reality, they shouldn't be in memory in the first place.

So it seems that `config()` is called a second time with an empty Smart Contracts configuration just to ensure that memory
is reset and no error messages are shown.

As discussed earlier, this unfortunately also introduced a lot of side effects along the way as Embark tries to reregister
ENS subdomains from Smart Contracts that are marked as undeployed and therefore don't have an address to interpolate.

While there's probably different ways to go about it, the most straight forward fix is to simply not call `config()`
a second time when it's really not needed. If the goal is to just reset the memory, we can take advantage of
Embark's internal `config:contractsConfig:set` event, which is what this commit is doing.
2019-05-28 09:34:52 +02:00
snyk-bot 9029bfe947 fix: packages/embark/package.json to reduce vulnerabilities
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-HANDLEBARS-174183
- https://snyk.io/vuln/SNYK-JS-TAR-174125
- https://snyk.io/vuln/npm:mem:20180117
2019-05-24 10:38:22 -05:00
Michael Bradley, Jr 91f87d2057 chore(release): 4.1.0-beta.2 2019-05-22 18:09:06 -05:00
Michael Bradley, Jr 0253c90111 fix(@embark/utils): add find-up and globule to dependencies
The embark-utils package, since 4.1.0-beta.1, is a transitive DApp dependency;
but it's loaded in the main process (not a child process), so embark-utils' own
deps can't be indirectly supplied from embark itself via NODE_PATH.
2019-05-22 17:44:41 -05:00
Pascal Precht 2c6c9489fc fix(@cockpit/whisper): ensure message subscription call is working
When introducing the `embark-api-client` in https://github.com/embark-framework/embark/commit/c1bbdbf34
we didn't properly update Cockpits apiService, resulting in calls to API endpoints
that don't exist.

This commit fixes a bug where calls to Embark's API to subscribe to whisper
channels are in a broken state.

It also updates Cockpit's apiService to no longer pass ignored parameters to embark-api-client.
2019-05-22 17:16:16 +02:00
Pascal Precht 7a0609b66c fix(@cockpit/utils): properly detect if ENS is enabled
With the move of Embark's modules into their own packages, the names under
which they are registered in the API service have changed as well.

This caused Cockpit to no longer being able to properly detect whether
ENS is enabled in the current Embark project
2019-05-22 17:15:57 +02:00
Pascal Precht 3aca2fe17b refactor(@embark/code-runner): move code-runner into its own package 2019-05-22 17:15:39 +02:00
Pascal Precht 038928f8a5 feat(@embark/utils): introduce setUpEnv() function
This package comes with a `setUpEnv()` function that can be called to
prepare Embark's environment variables for different process contexts.

This allows us to set up Embark's environment within a test runner context
without the requirement of importing `packages/embark/src/lib/core/env.js`,
which happens to set up those necessary environment variables as a side effect.

It's important that a path to `packages/embark`'s root is passed down to `setUpEnv()`
to ensure `EMBARK_PATH` gets the correct value.

E.g. within a package `embark-console`, `setUpEnv()` can be called within its tests
like the following:

```
// packages/embark-console/src/test/console.js

import { joinPath, setUpEnv } from 'embark-utils';

setUpEnv(joinPath(__dirname, '../../../embark'));
```

Here, `__dirname + '../../../embark'` ensures `EMBARK_PATH` points to the root
of `packages/embark`. This might look different in other contexts.

For example calling this function from a test file within `packages/embark`, this would
look like this:

```
// packages/embark/src/test/some_file.js

import { joinPath, setUpEnv } from 'embark-utils';

setUpEnv(joinPath(__dirname, '../../'));
```
2019-05-22 12:23:04 +02:00
Pascal Precht 57c3502f1f refactor(@embark/coverage): move coverage module into own package
This commit also moves several utility methods into @embark/utils as needed.
2019-05-22 11:47:29 +02:00
Pascal Precht 8ca6419a4e fix(@embark/pipeline): ensure color methods for logs are available
As part of 880a3a6946, we've introduced a
regression where the `colors` package isn't imported in the scope anymore where it's
needed. In this case the pipeline package. This resulted in log output messages
such as:

```
undefinedwriting fileundefined
```

Adding the `colors` package as dependency and importing it accordingly
fixes the issue.
2019-05-21 14:46:03 +02:00
Michael Bradley, Jr a10bd69756 docs: move root readme into packages/embark and symlink into root 2019-05-21 12:12:15 +02:00
Ricardo Guilherme Schmidt 4d079de1f4 fix(@embark/ens): use namehash for resolver 2019-05-21 12:11:14 +02:00
Pascal Precht 3df7f81732
refactor: move `dappPath`, `ipcPath` and `embarkPath` into @embark/utils 2019-05-17 11:25:40 +02:00
Michael Bradley, Jr a519a5d527 build: adjust reset script to delete coverage dirs if pkg has test script
Make the adjustment even if the test script is currently disabled. Consistently
use nyc to generate coverage with mocha even if the test script is currently
disabled.
2019-05-16 12:30:03 -05:00
Michael Bradley, Jr 4ee1567264 chore(release): 4.1.0-beta.1 2019-05-15 18:44:46 -05:00
Michael Bradley, Jr c4d647c299 fix(@embark/api): setup the embark-ui build dir before the express instance 2019-05-15 18:16:41 -05:00
Michael Bradley, Jr 78f7c52080 build: supply missing deps so production builds can function correctly 2019-05-15 18:15:50 -05:00
Pascal Precht 880a3a6946 refactor(@embark/pipeline): move pipeline into own package 2019-05-15 19:59:59 +02:00
Michael Bradley, Jr 79873bd3e7 build(@embark/deploy-tracker): disable watch:typecheck script 2019-05-15 12:52:20 -05:00
Michael Bradley, Jr 5799e00708 refactor(@embark/template_generator): use yarn to install template deps if embark cli is in monorepo
If the `embark` cli is detected to be inside the monorepo, the template
generator yarn-links any template deps that are part of the monorepo into the
dapp. However, `embarkjs-connector-web3` now has a dependency on `embark-core`,
which in turn has a dependency on `embark-i18n`. That causes `npm install` to
fail inside the dapp because npm checks for deps of `embarkjs-connector-web3`
relative to the dapp instead of checking relative to the symlink. `yarn
install` does not suffer from that behavior so use it instead.
2019-05-15 11:54:30 -05:00
Michael Bradley, Jr e1434259d6 build: add nohoist entry for bootstrap package relative to dapps/templates/demo
The demo's `embark.json` relies on the bootstrap package being within the
demo's own `node_modules`, but in the monorepo yarn was hoisting it up to the
root `node_modules`.
2019-05-15 09:38:00 -05:00
emizzle f5722546b1 refactor(@embark/debugger): Move to embark-debugger
Move the debugger module to the `embark-debugger` package.

Handle case where `debug` is entered as a console command, and there is no transaction to be debugged.

add embark-i18n and mocha deps
2019-05-15 14:39:00 +02:00
Andre Medeiros 46c4a5c79c chore: move deploytracker to embark-deploy-tracker module 2019-05-15 14:38:34 +02:00
emizzle 634feb597a feat(@embark/api): Add command `service api on/off`
Add support for `service api on/off` commands.

Deprecate commands `api start/stop` in favor of `service api on/off`.

`service api on` - Enables the API server serving Cockpit. Shows an error if the API server is already starting or started.

`service api off` - Disables the API server serving Cockpit. Shows an error if the API server is already stopping or stopped.

`api start` - This command has been deprecated in favor of `service api on` and will be removed in future versions.

`api stop` - This command has been deprecated in favor of `service api off` and will be removed in future versions.

`api:start` - This event has been deprecated and will be removed in future versions.

`api:stop` - This event has been deprecated and will be removed in future versions.
2019-05-15 14:28:10 +02:00
Andre Medeiros 3a07d34cc2 chore: move embark_listener to module 2019-05-15 14:27:44 +02:00
emizzle fc01daf3e9 feat(@embark/whisper): Remove support for `service whisper on/off`
Remove support for `service whisper on/off` because Whisper cannot be started without first disabling it in the communications config, then restarting Embark.

Add documentation for the `service [process] on/off` command

This command was only added a few commits back so it is not considered a breaking change.

Refactor the `service [process] on/off` commands so that there is only one command. Previously we had a command registered for each process, ie:
```
service blockchain on/off
service ipfs on/off
…
```

Now, we only have one command with many options:
```
service [process] on/off - Starts/stops the process. Options: blockchain, embark, ipfs, api
```

Whisper is deliberately not included in the available options for the aforementioned reasons.
2019-05-15 13:34:13 +02:00
Pascal Precht e3ecf68fbc refactor: move embarkPath, ipcPath and dappPath into embark-core
This enables removing unnecessary `core/fs` dependencies which can be
replaced with `fs-extra`.

This commit also fixes a bug introduced in f868d1216d
where methods from `embark.fs` weren't available.

The reason for that is because we have several *Process instances
that are created through child process communication, specifically
process.send() APIs. Using those APIs, we can only send data structures
however, methods attached on any of those will get lost.

This is the case when sending embark.fs through process.send().

We still need fs in those places though, mostly because they are relying
on embarkPath and dappPath().

These places are now importing those functions from `embark-core`. Other
API such as writeFile or mkdirp() can be accessed through fs-extra
or fs modules.
2019-05-15 12:20:22 +02:00
Michael Bradley, Jr cae583137c refactor: bump ganache-cli to latest stable version for compat with newer solc
Fixes #1461
2019-05-14 10:12:24 -05:00
Andre Medeiros 85cf9ac44b chore: upgrade ethereumjs-wallet
This pull-request upgrades `ethereumjs-wallet`, which has upgraded the underlying dependency on scrypt.js to 0.3.0, making scrypt an optional dependency and offering a pure JS version as a fallback.

The reasoning behind this is that scrypt is problematic to install in some systems, particularly those that don't have node-gyp setup and we have seen some weird issues when installing with elevated privileges (i.e. `sudo npm install -g scrypt`)
2019-05-12 18:20:34 -04:00
Michael Bradley, Jr efb63af71e hotfix: bump yarn.lock
PR #1607 didn't include changes to `yarn.lock` after a dependency was added to
`dapps/templates/demo`.
2019-05-10 18:04:36 -05:00
Pascal Precht 192549add1 refactor(@embark/blockchain-connector): move blockchain connector into own module 2019-05-10 16:57:23 -04:00
Pascal Precht 8dd7300e3c chore: remove process-logs-api package from embark package
This module has been moved already and is therefore a left over here.
2019-05-10 16:56:59 -04:00
Pascal Precht 9239012bc6 chore(site): fix typos 2019-05-10 16:54:21 -04:00
Ricardo Guilherme Schmidt 438e9178ce fix(@embark/demo): link css from dependency 2019-05-10 16:51:45 -04:00
Pascal Precht cae8075682 refactor(@embark/solidity): move solidity module into own package 2019-05-10 16:44:54 -04:00