Commit Graph

6283 Commits

Author SHA1 Message Date
Pascal Precht c1a911893f
feat(plugins/rpc-interceptors): Introduce embark_getSmartContracts RPC API 2020-04-09 12:25:45 +02:00
Pascal Precht 947ea23c35
refactor(stack/proxy): make rpc-manager stack component
This commit refactors the `rpc-manager` to be a stack component and therefore
making it available to a variaty of plugins that might need access to its APIs
so they can register new RPC interceptors.

RpcModifiers have been renamed to `rpc-interceptors` and extracted from the `rpc-manager`
source into their own plugin. The reason for the renaming was that modifiers aren't always
modifying RPC APIs, but potentially introduce brand new ones.

There are a bunch of new APIs that can be used to register new RPC APIs:

```
events.request('rpc:request:interceptor:register', 'method_name',  requestInterceptorFn);
events.request('rpc:response:interceptor:register', 'method_name',  responseInterceptorFn);

function requestInterceptorFn(params: ProxyRequestParams<T>) {
  // mutate `params` here
  return params;
}

function responseInterceptorFn(params: ProxyResponseParams<T, S>) {
  // mutate `params` here
  return params;
}
```

A few things to note here:

- `method_name` is either `string`, `string[]`, or `Regex`. This make registering custom RPC
  APIs extremely flexible.
- A `requestInterceptorFn()` gets access to `ProxyRequestParams<T>` where `T` is the type of the
  params being send to the RPC API.
- A `responseInterceptorFn()` gets access to `ProxyResponseParams<T, S>` where `T` is the type of the
  original request parameters and `S` the type of the response coming from the RPC API.

These APIs are used by all `rpc-interceptors` and can be used the same way by any oother plugin
that aims to create new or intercept existing APIs.
2020-04-09 12:25:37 +02:00
Pascal Precht 4199124e40
fix(utils/testing): teach testing APIs request options 2020-04-08 08:37:18 +02:00
Jonathan Rainville deb682c9d2 fix(@embark/mocha): reset contracts before each test file
Caused issues because we kept in memory the old contracts, including
the onDeploys.
2020-04-07 13:32:25 -04:00
EmbarkBot 1278365768 chore(prerelease): 5.3.0-nightly.16 2020-04-03 00:14:04 +00:00
Pascal Precht 3ce666b165 fix(cockpit/console): ensure console for processes is rendered
Prior to this commit, `Console` would only be rendered when Embark's API returns
at least one registered process from `/embark-api/processes`.
`Console` itself would then add another processes "embark" resulting in two tabs
with console output. This used to work fine because Embark always registered
at least a blockchain process.

In cd934f8157 however, this has changed.
With Ganache being the default blockchain, there's no longer a processes registered for this
service, resulting in an empty list for `processes` inside Cockpit, causing `Console` not to render
at all. Which also means the `embark` process logs aren't rendered either.

This commit removes the requirement of `processes` being non-empty so that embark process
logs are always shown.

It also fixes `Console` to updates its own `processes` state when its properties change.
This is needed because it's no longer guarded by `DataWrapper`, which previously ensured
`Console` is only rendered when there are processes.

Kudos to @jrainville for helping me cracking this nut.
2020-04-02 14:03:23 -04:00
Pascal Precht de8f2170ba fix(plugins/solc): don't read pluginConfig from plugin.config
In https://github.com/embarklabs/embark/pull/2330#discussion_r389906144 we've changed the `solc` plugin to read its
`pluginConfig` from `embark.config`. This was done under the assumption that
the `embark.config` is always properly populated with a dedicated `pluginConfig`.
In our testing environment we pass `Embark` objects to plugins, while in reality, we pass `Plugin` instances.
These two are different in nature, so relying on `embark.config` inside the plugin seemed the
most pragmatic way forward without introducing a bigger refactoring in the testing APIs.

Unfortunately it turned out that `embark.config` isn't populated with a `pluginConfig`
which essentially caused it to break apps.

This commit reverts that change done in the mentioned PR and patches the Embark testing
API to behave like a `Plugin` while still being an `Embark` instance.
2020-04-02 10:55:58 +02:00
EmbarkBot 1a61bc6b8d chore(prerelease): 5.3.0-nightly.15 2020-03-26 00:15:45 +00:00
emizzle c343367223 chore(@embark/vyper): Update README for Vyper plugin
See the associated PR https://github.com/embarklabs/blog/pull/18.
2020-03-25 15:18:49 -04:00
Pascal Precht 533a2e380e test(plugins/solc): add tests for plugins/solc 2020-03-25 15:05:02 +01:00
EmbarkBot d578e548cf chore(prerelease): 5.3.0-nightly.14 2020-03-25 00:18:59 +00:00
Pascal Precht 2170753dfd test(stack/proxy): introduce tests 2020-03-24 14:49:03 +01:00
Pascal Precht 0e32cc09b5 feat(utils/testing): introduce async/await for actions in tests 2020-03-24 14:49:03 +01:00
Pascal Precht ec134b9307 fix(stack/proxy): have proxy.stop() receive callback 2020-03-24 14:49:03 +01:00
Pascal Precht d9c8109201 fix(stack/proxy): ensure wsProxy and httpProxy have correct type
Both, `httpProxy` and `wsProxy` inside `Proxymanager` have been assigned
the value of `new Proxy(...).serve()` which is an instance of `express`.

This was wrong and causes runtime errors when proxies are being stopped as
they don't have a `stop()` API.
2020-03-24 14:49:03 +01:00
EmbarkBot 7ae17612dd chore(prerelease): 5.3.0-nightly.13 2020-03-24 00:15:01 +00:00
emizzle 72e609a7e9 feat(@embark/accounts-manager): Get alternative coinbase address
In dev mode, accounts are funded per the blockchain accounts config. In specific situations, there may not be enough funds on the account returned by `eth_coinbase`. In that case, and in the case when `eth_coinbase` returns `0x0` (or equivalent), loop through all accounts and find the one that has the most funds and use that as the coinbase account.
2020-03-23 20:19:04 +01:00
emizzle edf43470e4 fix(@embark/storage): Fix hang when changing environments
Fix an issue with storage process launcher hanging when changing environments. This occurred most frequently when the IPFS process was forced to restart due to the change in environment. Change in enviroment can be considered:
1. `embark run env1`
2. `Ctrl+c`
3. `embark run env2`
2020-03-23 20:19:04 +01:00
emizzle 095bd0b971 feat(@embark/quorum): Add support for Quorum blockchains
Add support for *connecting to* Quorum blockchains. This plugin will not start a Quorum node or nodes automatically as Embark does with other chains.

This plugins supports deploying contracts publically and privately using the Tessera private transaction manager.

This plugin supports sending of public and private transactions using the Tessera private transaction manager.

Add ability to skip bytecode checking as part of the contract deployment process. Instruct the deployer to skip checking if the contract bytecode exists on-chain before deploying the contract. This is important in the case of having many private nodes in a network because if a contract is deployed privately to node 1 and 7, running Embark on node 2 should skip the bytecode check as the contract *is not* deployed on node 2, nor do we want it deployed on node 2. If the bytecode check was in place, Embark would have deployed it to node 2 and therefore not adhered to the privacy needs.

Add Ethereum contract deployer for Quorum, allowing for deploying of public and private contracts using `privateFor` and `privateFrom` (see Contract config updates below).

Add web3 extensions enabling specific functionality for Quorum. Extensions includes those provided by [`quorum-js`](https://github.com/jpmorganchase/quorum.js), as well as some custom monkeypatches that override web3 method output formatting, including:
 - web3.eth.getBlock
 - web3.eth.getTransaction
 - web3.eth.getTransactionReceipt
 - web3.eth.decodeParameters
DApps wishing to take advantage of these overrides will need to patch web3 as follows:
```
import {patchWeb3} from "embark-quorum";
import Web3 from "web3";

let web3 = new Web3(...);
web3 = patchWeb3(web3);
```

Add support for sending a raw private transaction in the Quorum network. This includes running actions from the proxy after an `eth_sendTransaction` RPC request has been transformed in to `eth_sendRawTransaction` after being signed.

fix(@embark/transaction-logger): Fix bug when sending a 0-value transaction.

Add `originalRequest` to the proxy when modifying `eth_sendTransaction` to `eth_sendRawTransaction`, so that the original transaction parameters (including `privateFor` and `privateFrom`) can be used to sign a raw private transaction in the `eth_sendRawTransaction` action.

Added the following properties on to blockchain config:
 - *`client`* `{boolean}` - Allows `quorum` to be specified as the blockchain client
 - *`clientConfig/tesseraPrivateUrl`* `{string}` - URL of the Tessera private transaction manager
```
client: "quorum",
clientConfig: {
  tesseraPrivateUrl: "http://localhost:9081" // URL of the Tessera private transaction manager
}
```
Added the following properties to the contracts config:
 - *`skipBytecodeCheck`* `{boolean}` - Instructs the deployer to skip checking if the bytecode of the contract exists on the chain before deploying the contract. This is important in the case of having many private nodes in a network because if a contract is deployed privately to node 1 and 7, running Embark on node 2 should skip the bytecode check as the contract *is not* deployed on node 2, nor do we want it deployed on node 2. If the bytecode check was in place, Embark would have deployed it to node 2 and therefore not adhered to the privacy needs.
  - *`privateFor`* `{string[]}` - When sending a private transaction, an array of the recipient nodes' base64-encoded public keys.
  - *`privateFrom`* `{string}` - When sending a private transaction, the sending party's base64-encoded public key to use
```
environment: {
  deploy: {
    SimpleStorage: {
      skipBytecodeCheck: true,
      privateFor: ["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc"],
      privateFrom: "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo="
    }
  }
},
```

 - *`proxy:endpoint:http:get`* - get the HTTP endpoint of the proxy regardless of blockchain settings
 - *`proxy:endpoint:ws:get`* - get the WS endpoint of the proxy regardless of blockchain settings

 - *`runcode:register:<variable>`* - when variables are registered in the console using `runcode:register`, actions with the name of the variable (ie `runcode:register:web3`) will be run *before* the variable is actually registered in the console. This allows a variable to be modified by plugins before being registered in the console.
2020-03-23 20:19:04 +01:00
Pascal Precht 0c9b917371 fix(@embark/cmd_controller): don't try to load pipeline module group in build cmd
We've made the `basic-pipeline` optional in 948956ab1f but are still
trying to load the pipeline module group in inside the `build` cmd.
This breaks at runtime as no such module group exists anymore.
2020-03-23 17:01:35 +01:00
Jonathan Rainville 897aa3f839 fix(@embark-ganache): fix ganache having different node accounts
When using accounts, yes those account are always the same, but
ganache still creates it's own accounts, with a random mnemonic.
So Plugins that rely on the node accounts were crashing on second
run, because the node accounts were no longer the same.
2020-03-23 15:21:35 +01:00
Jonathan Rainville fde1eeb3a7 fix(@embark/blockchain): fix blockchain plugins' use of async whilst 2020-03-23 15:21:35 +01:00
Pascal Precht 031ebe8bb2 fix(plugins/basic-pipeline): ensure correct webpack config is loaded
When making `basic-pipeline` in 948956ab1f we've introduced a regression
and with this fix, a behaviour change as well::

1. The `webpackConfigName` passed to `Engine` is completely ignored, caused it to be
  `undefined` down the line when the plugin tries to do its work (we essentially broke bundling)
2. With that configuration being ignored, we need a new way to make this configurable.
  Since `basic-pipeline` is now a true plugin, it makes sense for itself to have configuration
  options for that, while still providing decent defaults.
3. The trickly thing is that `webpackConfigName` used to have different values per command.
  For example `build` used to use `production` while `run` used `development` as config.
4. This commit introduces new configuration options for `basic-pipeline` that lets users configure
the `webpackConfigName` per environment:

```json
// embark.json
{
  ...
  "plugins": {
    "embark-basic-pipeline": {
      "development": {
        webpackConfigName: "development"
      },
      "production": {
        webpackConfigName: "production"
      }
    }
  }
}
```
^ These are also the defaults. So not providing this configuration will make
Embark imply it.

Notice that this does not account for the "different config per command" case.
This means `embark build` will also use `development` by default.

Prior to this commit and the one mentioned above, the `webpackConfigName` was configurable
through the CMD `--pipeline` option. Since this a) no longer a built-in feature
and b) ignored at the moment anyways, I've removed the `--pipeline` options
from all commands as well.

BREAKING CHANGES

The commands `embark eject-webpack` and `embark eject-build-config` are no longer available.
The `--pipeline` option has been removed from all commands that used to support it.
2020-03-23 15:19:58 +01:00
emizzle 5fe318bf23 feat(@embark/dapps): Add blockchain config to simple template
Add blockchain config to simple template, and supporting files (ie passwords, genesis) that aid in examples set forth in the blockchain config.
2020-03-23 13:21:05 +01:00
emizzle a454ae8b11 feat(@embark/core): Support minimum truffle projects
When taking a bare-minimum truffle project, created from the [`metacoin` truffle box](https://github.com/truffle-box/metacoin-box), there were only two steps that needed to happen as a prerequisite:
1. First, run `embark init`, creating a default `embark.json`
2. Second, run `npm init`, creating a default `package.json`.

Trying to run `embark run` before those prequisites would error with appropriate directions in the console, guiding the user to run those steps explicitly.

After running these two steps, Embark would hang waiting for the namesystem plugin to come up.

Changing the default namesystem config to disabled allows Embark to start up successfully without hanging.

The rationale behind this decision is that if `embark.json` doesn’t exist, then we cannot expect that the namesystem plugin will be installed in the project either, and thefore its default value should be disabled.
2020-03-23 13:20:34 +01:00
Michael Bradley, Jr 469504f3b2 refactor: modify check-yarn-lock.js to use a blacklist instead of a whitelist
Refactor `scripts/check-yarn-lock.js` to use a dynamically calculated
blacklist (`npx lerna ls --all --json`) instead of a hard-coded whitelist to
improve accuracy and reduce future maintenance.
2020-03-22 22:30:21 -05:00
Michael Bradley, Jr bc92b7aac5 build: implement a script to fix intra-monorepo dep range specifiers in rebased branches
Range specifiers for intra-monorepo dependencies can, because of nightly or
stable releases, get out of sync between PR branches and `master`. In many
cases, what then happens is that yarn can't satisfy the dep range with the
version in the monorepo, so it installs from the registry and updates
`yarn.lock` accordingly. We have a `check-yarn-lock.js` script (`yarn cylock`)
that detects the situation and prevents CI from passing. However, to date the
problem has to be fixed manually.

Implement a script that fixes the problem by scanning all the `package.json`
files and updating mismatched ranges.

It's best to run the script *after* rebasing against `master`.
2020-03-21 15:44:54 -05:00
EmbarkBot 7f52634331 chore(prerelease): 5.3.0-nightly.12 2020-03-21 00:15:48 +00:00
Pascal Precht c9a35faa1e test(stack/storage): updates dependencies and add missing tests 2020-03-20 17:24:17 +01:00
emizzle 471a33a331 chore(@embark/blockchain): Add unit tests to blockchain stack component
fix(@embark/blockchain): Add callback to `blockchain:node:register` and `blockchain:client:register`

Add unit tests for the stack/blockchain and update supporting API documentation in the Wiki.

Add injectables `Web3` and `warnIfPackageNotDefinedLocally` to stack/blockchain so that those functions can be tested properly.

Update stack/blockchain dependencies in `package.json`.
2020-03-20 14:40:14 +01:00
emizzle 56d5b45bbb chore(@embark/testing): Add testables to embark test objects
1. Add IPC mock and assertions.
2. Add console command registration assertion and console command mock.
3. Add event emission assertions
2020-03-20 14:40:14 +01:00
EmbarkBot d5e0897231 chore(prerelease): 5.3.0-nightly.11 2020-03-20 00:17:02 +00:00
Michael Bradley, Jr a5f0a1254e test(@embark/snark): re-active test script but skip tests that need additional refactoring 2020-03-19 16:13:17 -05:00
Michael Bradley, Jr eb33aa16ee build: activate linter in ci/qa for packages that were missing it 2020-03-19 16:13:17 -05:00
Michael Bradley, Jr ece942b3a8 refactor(@embarkjs/snark): use same "main" pattern as other packages 2020-03-19 16:13:17 -05:00
Michael Bradley, Jr 11b53970fb chore: update intra-monorepo dependencies that were out of sync with current prerelease versions 2020-03-19 16:13:17 -05:00
emizzle c1129dc15f feat(@embark/snarks): Allow embark-snark to be used in the dapp
`embark-snark` has been updated such that it can be used, in conjunction with `embarkjs-snark`, in the console, and in the DApp.

This could, for example, be used to build a dapp like https://tornado.cash.

Please see the README for usage instructions.

Updated tests were excluded in this PR as a consideration for time already spent on getting this library completed. Tests should be updated in a future PR.
2020-03-18 08:50:48 +01:00
EmbarkBot 444b9eae87 chore(prerelease): 5.3.0-nightly.10 2020-03-14 00:16:39 +00:00
Iuri Matias 948956ab1f chore: make basic-pipeline an optional plugin
chore: make basic-pipeline an optional plugin

chore: make basic-pipeline an optional plugin

chore: make basic-pipeline an optional plugin

chore: make basic-pipeline an optional plugin

chore: make basic-pipeline an optional plugin

chore: make basic-pipeline an optional plugin

chore: make basic-pipeline an optional plugin

fixes

address code review

fix linter issue

fix missing param

fix binding

remove pipeline warning

remove unused var
2020-03-13 13:36:46 -04:00
EmbarkBot db8282c52c chore(prerelease): 5.3.0-nightly.9 2020-03-13 00:16:27 +00:00
Jonathan Rainville b8c090808f fix: don't open external links to another tab by default
This caused a problem for links that were not from the subdomain,
but still part of embarklabs.io, because it opened a new tab
2020-03-12 12:57:12 -04:00
Iuri Matias ee1eb4ed96 feat: support selecting what library to generate artifacts
feat: support selecting what library to generate artifacts

feat: support selecting what library to generate artifacts

feat: support selecting what library to generate artifacts

feat: support selecting what library to generate artifacts

working web3 artifacts

remove unnecessary request

address code review issues

fixes

update tests

WIP: add index.js in packages/plugins/embarkjs/

This is a pattern established in #2285

remove comment

fix some code review issues
2020-03-12 12:23:49 -04:00
EmbarkBot db9e959169 chore(prerelease): 5.3.0-nightly.8 2020-03-11 00:18:13 +00:00
Jonathan Rainville 53dc751981 fix(@embark/ganache): make embark blockchain exit when using Ganache 2020-03-10 09:55:14 -04:00
Pascal Precht c624582d12 feat(stack/blockchain): expose networkId in generated artifact
Closes #2220
2020-03-10 09:54:26 -04:00
EmbarkBot 34f4b0cf1a chore(prerelease): 5.3.0-nightly.7 2020-03-10 00:18:09 +00:00
dependabot-preview[bot] 42a052ec21 build(deps): bump ws from 7.1.2 to 7.2.2
Bumps [ws](https://github.com/websockets/ws) from 7.1.2 to 7.2.2.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.1.2...7.2.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-09 09:32:44 -05:00
dependabot-preview[bot] e0f9d611da build(deps-dev): bump monaco-editor from 0.19.3 to 0.20.0
Bumps [monaco-editor](https://github.com/Microsoft/monaco-editor) from 0.19.3 to 0.20.0.
- [Release notes](https://github.com/Microsoft/monaco-editor/releases)
- [Changelog](https://github.com/microsoft/monaco-editor/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Microsoft/monaco-editor/compare/v0.19.3...v0.20.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-09 09:02:00 -05:00
dependabot-preview[bot] dc0c0ee886 build(deps): bump @babel/preset-env from 7.7.4 to 7.8.7
Bumps [@babel/preset-env](https://github.com/babel/babel) from 7.7.4 to 7.8.7.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/compare/v7.7.4...v7.8.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-09 08:33:31 -05:00
EmbarkBot 7287eda651 chore(prerelease): 5.3.0-nightly.6 2020-03-07 00:14:47 +00:00