Commit Graph

5546 Commits

Author SHA1 Message Date
Michael Bradley, Jr 52d54f0d87 fix(@cockpit/explorers): consistently display "Mined on" timestamps
Adjust the API endpoints to augment transaction objects with a timestamp
property from their corresponding blocks. This removes the necessity to copy
the timestamp property from a block to its transactions in the client.

Introduce a `formatTimestampForDisplay` util function in Cockpit for
consistently transforming timestamps into relative or absolute dates, depending
on whether a date is sometime during the last day.
2019-07-03 08:25:08 -05:00
Michael Bradley, Jr 7d27125eed fix(@embark/code-runner): restore EmbarkJS.environment property in the cli dashboard
The property is set/available on EmbarkJS in the artifacts, i.e. in a browser
build; but sometime since v3.2.4 it was no longer availble in the cli dashboard
environment.
2019-07-02 10:48:53 -05:00
Pascal Precht 93ca3ad97c fix(@embark/embarkjs-whisper): Messages.isAvailable() should always return a promise
`EmbarkJS.Messages.isAvailable()` in some cases return synchronously (when whisper isn't
set up), in other cases asynchronously. This actually breaks our demo application for
the following reason:

We check for Whisper's availability via:

```
EmbarkJS.Messages.Providers.whisper.getWhisperVersion((err, _version) => {
  if (err) {
    return console.log(err);
  }
  this.setState({whisperEnabled: true});
});
```

There's a couple of problems here:

- This code will break right away when whisper isn't available, resulting in an error:
  ```
  Cannot read property _requestManager of undefined
  ```

- The reason this error happens is because there's no `web3` object available inside
  our EmbarkJS.Messages code. Even though there **is** a web3 object, EmbarkJS.Messages
  doesn't know about this because it only sets it when its `setProvider()` API is called,
  which effectively doesn't happen at all when Whisper isn't enabled on the connected
  node

- While this could be fixed with a simple check on whether EmbarkJS.Messages' internal
  `web3` references is a thing, really what should be used in the demo is the `isAvailable()`
  API.

`isAvailable()` should always return a promise (similar to `EmbarkJS.Storage.isAvailable()`.

This commit ensures that `isAvailable()` always returns a promise and changes the demo
template to use `isAvailable()` over `getWhisperVersion()`.
2019-07-01 11:11:03 +02:00
Pascal Precht fc7eb0cca6 uiux(@cockpit/sign-and-verify): improve wording for verifying messages 2019-07-01 11:10:37 +02:00
Michael Bradley, Jr eecb48f5b6 chore(release): 4.1.0-beta.4 2019-06-27 14:23:32 -05:00
Jonathan Rainville f6d7a54195 fix(@embark/deploy-tracker): fix getting the block 0 with sim --fork 2019-06-27 14:12:29 -05:00
Pascal Precht 1b6987ee8f fix(@dapps/templates/demo): ensure whisper channel state is set correctly 2019-06-27 14:11:24 -05:00
Jonathan Rainville 198a5dc3f4 fix(@embark/solidity): show a better error message in debug 2019-06-27 14:10:53 -05:00
Michael Bradley, Jr 7652e1d75c refactor(@embark/site): remove embarkjs-connector-web3 instructions
Also include a note on the "How to upgrade to Embark 4" blog post from March
2019.
2019-06-27 14:10:12 -05:00
Iuri Matias fc4faa8ba9 fix: alleviate races re: embarkjs by introducing Plugin#addGeneratedCode and related refactors 2019-06-27 14:10:12 -05:00
Michael Bradley, Jr d684b9af0f refactor(@embarkjs/web3): make web3 connector an internal plugin like the other embarkjs-* packages
Effectively deprecate the `embarkjs-connector-web3` package but don't introduce
a breaking change by simply not loading the plugin if it's specified in a
DApp's `embark.json`. If the deprecated plugin is specified, display a message
indicating the plugin was ignored and suggesting it be removed from the
project's `embark.json` and `package.json`.
2019-06-27 14:10:12 -05:00
emizzle 71cb161525 feat(@embark/blockchain-connector): Add command to get full account info
This PR adds a command to get full account details from the contradts config that includes info like private key.

The existing, and similar command, `blockchain:provider:contract:accounts:get` would only return account addresses if they existed, and not the full account info.
2019-06-27 08:42:58 -05:00
Michael Bradley, Jr 2ce9ca6bb0 fix(@embark/coverage): function types and single statement ifs 2019-06-27 08:40:24 -05:00
Pascal Precht 610d8f1baa fix(@cockpit/utils): Ensure whisper channels are at least 4 characters long
This check was already made when sending messages to whisper channel, however, we didn't
perform the same check when subscribing to channels within cockpit.
2019-06-27 08:36:25 -05:00
Pascal Precht 322397f81c fix(@dapps/demo): don't allow subscription to whisper channels with less than 4 chars
This has been a problem in Cockpit as well and was fixed accordingly.
Whisper doesn't allow subscribing to channels with names that have less
than 4 characters.

This could be fixed in different ways, one being on the library level
(e.g. have embark check for the given length and not subscribing when it
doesn't pass the check), the other one being on the application/ui level.

The reason it makes sense to solve this in the application layers is because
we keep the it open for users of EmbarkJS.Messages APIs to handle errors
the way they want.

Fixes #1666
2019-06-27 08:36:05 -05:00
Jonathan Rainville 0a388d741e chore(@embark/site): remove connect() doc and add back onReady 2019-06-26 11:55:26 +02:00
Jonathan Rainville 908aa3b148 fix(templates): fix templates because tests don't like empty files 2019-06-21 11:00:27 -04:00
Jonathan Rainville 9646673c6f fix(@embark/test-runner): only run tests on files with describe 2019-06-21 11:00:27 -04:00
Jonathan Rainville 5044403a03 feat(@embark/site): add section on getting account from describe 2019-06-21 11:00:27 -04:00
Jonathan Rainville 332229ff9d feat(@embark/test-runner): return accounts in the describe callback 2019-06-21 11:00:27 -04:00
Jonathan Rainville 8c16541019 feat(@embark/test-runner): wait for deploy before enterning describe 2019-06-21 11:00:27 -04:00
Pascal Precht ae5b92ff45 chore(docs): remove encoded special chars for paginator buttons 2019-06-21 10:51:14 -04:00
Pascal Precht ebe61f4085 fix(docs): ensure paginator helper has `__()` local
Templates used for rendering data inside helpers need to all over their local variables
passed down so they can be evaluated against some context object.

We didn't pass down the i18n `__()` function to the paginator template of our custom
theme resulting in compilation errors during site generation.

This commit fixes it.
2019-06-21 10:51:14 -04:00
Pascal Precht 9f1c4cb329 docs: fix Messages.listenTo() API docs 2019-06-20 15:30:44 +02:00
Robin Percy f81e25710f 1 grammatical change hangover from other PR. 2019-06-20 09:04:58 -04:00
Pascal Precht 5e18674504 chore: localize static sites
This commit localizes messages of the mostly static sites of embark's
website. This is needed to have them internationalized into different
languages.
2019-06-20 10:49:26 +02:00
Pascal Precht 24b53395b0 fix(@embark/config): disable webserver if pipeline is disabled
The webserver's job is to serve files generated by Embark's built-in pipeline,
however, since v4 users can choose they front-end tool to take care of building,
bundling and packing their DApps. Usually these tools come with a built-in
dev server as well.

Therefore, when the pipeline is turned off (which also soon will be the default),
there's not need start a webserver.
2019-06-20 10:49:00 +02:00
Pascal Precht 9e5c9c7f17 fix(@embark/deployment): don't break when using abiDefinitions
In https://github.com/embark-framework/embark/pull/1119 we've introduced a feature where
users can provide an already compiled ABI for Smart Contracts so they can be used
without the need to compiling them again.

This also means that, internally, those Smart Contract object won't have any
bytecode attached to it.

Later on, in 387d33a076,  we've introduced a warning
which is rendered when a Smart Contract's bytecode is too large. The check expects
a Smart Contract object to have bytecode associated to it, which will break the code
in cases where a Smart Contract has already an ABI and therefore didn't need compilation.

This commit ensures we only check a Smart Contract's bytecode when bytecode exists for
the Smart Contract in question.
2019-06-19 11:48:57 +02:00
Jonathan Rainville e288483661 fix(@embark/test-runenr): fix event listener overflow 2019-06-17 11:37:07 -04:00
Shailendra Shukla 09d7428e7e fix(@embark/dapps): old link updated to the latest documentation at website
The previous link was pointing to readthedocs.io, which wasn't active. So here I've replaced it with the link to the official documentation on the Embark website.
2019-06-11 09:50:44 -04:00
Jonathan Rainville d5bce81e56 refactor: add normalizePath and toForwardSlashes for replaces 2019-06-11 10:02:08 +02:00
Jonathan Rainville 1edd68f3bd fix(@embark/solidity): fix recursive error on Windows 2019-06-11 10:02:08 +02:00
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