Commit Graph

52 Commits

Author SHA1 Message Date
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 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
Michael Bradley, Jr e0f7913a02 feat: add support for `embark.config.js`
This commit introduces support for using `embark.config.js` to calculate the
embark configuration object that is otherwise provided via `embark.json`.

If an `embark.config.js` file is present, it will be used over the
`embark.json` file.  The `embark.config.js` module needs to export either an
object or a function that can be asynchronous and has to return or resolve with
an embark configuration object:

```js
// embark.config.js

module.exports = async function () {
  let config = ...; // do lazy calculation of `embarkConfig`;
  return config;
}
```
2020-03-06 09:45:43 -06:00
Jonathan Rainville 67581ce482 feat(@embark/test-runner): make evmMethod globally available + docs 2020-03-05 14:12:07 +11:00
Pascal Precht a4a0e9dc33 feat(plugins/specialconfigs): adds support for Smart Contract args as functions
This commit introduces a new feature that enables users to calculate Smart Contract
constructor arguments lazily using an (async) function. Similar to normal Smart Contract
configurations, the return or resolved value from that function has to be either a list
of arguments in the order as they are needed for the constructor, or as an object with
named members that match the arguments individually.

```
...
development: {
  deploy: {
    SimpleStorage: {
      args: async ({ contracts, web3, logger}) => {
        // do something with `contracts` and `web3` to determine
        // arguments
        let someValue = await ...;
        return [someValue];

        // or
        return {
          initialValue: someValue
        };
      }
    }
  }
}
...
```

Closes #2270
2020-03-03 10:14:58 +01:00
Iuri Matias db10064dd6 feat: remove optional plugins from coming as default
feat(@embark/utils): add method to verify if a plugin is installed & configured

feature(@embark/utils): add method to verify if a plugin is installed & configured

feature: warn about packages that will be independent plugins and are not configured

chore: update templates to specify plugins

refactor: add to plugin api params so that blockchain plugins no longer need to be passed options

address changes in code review

remove unneded space

Update packages/core/utils/src/index.ts

Co-Authored-By: Jonathan Rainville <rainville.jonathan@gmail.com>

Update packages/core/utils/src/index.ts

Co-Authored-By: Michael Bradley <michaelsbradleyjr@gmail.com>

fix linting issue

add missing import

remove optional plugins from coming as default

Revert "chore: update hooks examples to destructure dependencies object"

This reverts commit 448eab724b.

remove trailing comma

fix linting issue

include tsconfig
2020-02-27 20:31:29 -05:00
Jonathan Rainville 0461fa01e0 fix(@embar/site): fix proxyFor docs
Change to smart contract and fix forProxy -> proxyFor
2020-02-19 09:16:41 -05:00
Jonathan Rainville b2f670ba46 docs(@embark/contracts-config): add docs for proxyFor 2020-02-14 08:27:34 -05:00
Pascal Precht 40c3d98217 feat(plugins/scripts-runner): introduce exec command to run scripts
This commit introduces a new feature that enables users to run (migration) scripts.
Similar to deployment hooks, scripts are functions that may perform operations on newly
deployed Smart Contracts.

Therefore a script needs to export a function that has access to some dependencies:

```
// scripts/001-some-script.js

module.exports = async ({contracts, web3, logger}) => {
  ...
};
```

Where `contracts` is a map of newly deployed Smart Contract instances, `web3` a blockchain connector
instance and `logger` Embark's logger instance. Script functions can but don't have to be `async`.

To execute such a script users use the newly introduced `exec` command:

```
$ embark exec development scripts/001-some-script.js
```

In the example above, `development` defines the environment in which Smart Contracts are being
deployed to as well as where tracking data is stored.
Alternativey, users can also provide a directory in which case Embark will try to execute every
script living inside of it:

```
$ embark exec development scripts
```

Scripts can fail and therefore emit an error accordingly. When this happens, Embark will
abort the script execution (in case multiple are scheduled to run) and informs the user
about the original error:

```
.. 001_foo.js running....
Script '001_foo.js' failed to execute. Original error: Error: Some error
```

It's recommended for scripts to emit proper instances of `Error`.

(Migration) scripts can be tracked as well but there are a couple of rules to be aware of:

- Generally, tracking all scripts that have been executed by default is not a good thing because
  some scripts might be one-off operations.
- OTOH, there might be scripts that should always be tracked by default
- Therefore, we introduce a dedicated `migrations` directory in which scripts live that should be
  tracked by default
- Any other scripts that does not live in the specified `migrations` directory will not be tracked **unless**
- The new `--track` option was provided

For more information see: https://notes.status.im/h8XwB7xkR7GKnfNh6OnPMQ
2020-02-12 16:47:04 -06:00
Jonathan Rainville c7eb2744cd doc(@embark/ens): document $accounts for ENS configuration
Adds docs for $accounts in subdomain registers and improve the docs
2020-02-06 12:36:36 -05:00
Iuri Matias c0042844a3 chore: update hooks examples to destructure dependencies object
chore: update hooks examples to destructure dependencies object

Update site/source/docs/contracts_configuration.md

Co-Authored-By: Michael Bradley <michaelsbradleyjr@gmail.com>

chore: update hooks examples to destructure dependencies object
2020-02-06 11:55:23 -05:00
Jonathan Rainville a5354df1ee docs(@embark/site): improve documentation on global test function
Add docs for mineAtTimestamp and getEvmVersion and improve the
other ones a bit (typos, format, etc)
2020-02-03 13:00:33 -05:00
Michael Bradley, Jr 030fb4acc6 build(deps): bump web3[-*] from 1.2.4 to 1.2.6
Remove `bignumber.js` workaround (in the root, from PR #2152) because it's no
longer needed (verified locally).

Remove the `"skipLibCheck"` workaround (in `packages/plugins/solidity-tests`,
from PR #2152) because it's no longer needed (verified locally).

Refactor a typing in `packages/plugins/geth`. What's happening is that in web3
v1.2.4 `sendTransaction` has a return type of `PromiEvent<TransactionReceipt>`
but in v1.2.6 it has a return type of `PromiEvent<TransactionReceipt |
TransactionRevertInstructionError>`.

Compare:
* [v1.2.4/packages/web3-eth/types/index.d.ts#L291-L294](https://github.com/ethereum/web3.js/blob/v1.2.4/packages/web3-eth/types/index.d.ts#L291-L294)
* [v1.2.6/packages/web3-eth/types/index.d.ts#L295-L298](https://github.com/ethereum/web3.js/blob/v1.2.6/packages/web3-eth/types/index.d.ts#L295-L298)

The problem is that the `TransactionRevertInstructionError` type doesn't have a
`transactionHash` property. Since at present the code in
`packages/plugins/geth/src/devtxs.ts` only deals with the success case re:
`sendTransaction`, import the `TransactionReceipt` type from `web3-eth` and
cast the resolved return value's type using TypeScript's `as` operator.
2020-02-03 10:17:07 -06:00
Iuri Matias d328b9953a chore: update site urls 2020-01-28 12:07:17 -05:00
Iuri Matias 9aeddaa998 chore: rename org references from embark-framework to embarklabs 2020-01-16 15:36:29 -05:00
Pascal Precht 73d04433cf feat(@embark/deployment): introduce `interfaces` and `libraries` configuration
This commit adds two new configuration settings for Smart Contract configuration:

- `interfaces` - Any Smart Contract that represent an interface or is used for inheritance
- `libraries` - Any Smart Contract that is used as a library

This makes the configuration less redundant in cases where otherwise the `deploy`
property has been set to `false`, such as:

```
deploy: {
  Ownable: {
    deploy: false
  },
  ...
}
```

The above can now be done via:

```
interfaces: ['Ownable'],
deploy: {
  ...
}
```
2020-01-15 09:45:42 -05:00
Jonathan Rainville 9711790f92 docs(@embark/site): add migration guide to Embark v5 2020-01-14 17:42:47 +01:00
Michael Bradley, Jr 7e550f0e6f build(deps): bump web3[-*] from 1.2.1 to 1.2.4
Refactor typings as necessary. In order for `bignumber.js` in the root
`node_modules` to not conflict with `@types/bignumber.js`, specify
`"bignumber.js": "5.0.0"` in `devDependencies` and `"embark-ui/bignumber.js"`
in `nohoist` of the root `package.json`.

In `packages/plugins/rpc-manager` switch from callback to promise usage with
respect to `web3.eth.accounts.signTransaction` because of a [bug][bug]
discovered in web3 v1.2.4.

In `packages/plugins/solidity-tests` specialize the tsc compiler options with
`"skipLibCheck": true` because of a problematic web3-related typing in the
`.d.ts` files of the remix-tests package.

Bump ganache-cli from 6.4.3 to 6.7.0 (latest) because 6.4.3 doesn't support
`eth_chainId` but web3 1.2.4 makes use of the `eth_chainId` RPC method (EIP
695).

BREAKING CHANGE: bump embark's minimum supported version of parity from
`>=2.0.0` to `>=2.2.1`. This is necessary since web3 1.2.4 makes use of the
`eth_chainId` RPC method (EIP 695) and that parity version is the earliest one
to implement it.

[bug]: https://github.com/ethereum/web3.js/issues/3283
2019-12-20 08:35:48 -06:00
emizzle bd4b110a78 feat(@embark/whisper): Add Whisper client config
Add option in communication config to choose which Whisper client to use.

Because Parity’s implementation of Whisper is not compatible with Whisper v6, and therefore web3.js in its current form, the following changes have been made:
1. remove any functionality associated with launching a Parity Whisper process.
2. Warn the user when the Parity Whisper client has been opted for in the communication config.
3. Return an error for API calls when Parity Whisper client has been opted for in the communication config.
4. Update Cockpit’s Communication module to show errors returned from API calls.
5. Update the messaging configuration documentation for the new communication client option.
2019-12-11 11:12:18 -05:00
emizzle db0e45e96e chore(@embark/site): Add `—template` deprecation notice. 2019-12-11 09:39:20 -05:00
Pascal Precht 0c5984c66d docs: clarify supported node version 2019-12-10 12:36:08 +01:00
emizzle f6f45077e9
fix(@embark/proxy): Fix unsubsribe handling and add new provider
When `eth_unsubscribe` is received in the proxy, ensure this request is forwarded through on the correct socket (the same socket that was used for the corresponding `eth_subscribe`).

Move subscription handling for `eth_subscribe` and `eth_unsubscribe` to RpcModifiers (in `rpc-manager` package).

For each `eth_subscribe` request, a new `RequestManager` is created. Since the endpoint property on the proxy class was updated to be a provider, the same provider was being assigned to each new `RequestManager` and thus creating multiple event handlers for each subscription created. To circumvent this, we are now creating a new provider for each `RequestManager`.

Co-authored-by: Pascal Precht <pascal.precht@googlemail.com>
2019-11-21 15:38:48 +01:00
Michael Bradley, Jr 2543acad75 refactor(@embark/library-manager): restrict versionable packages to only solc
BREAKING CHANGE:

Remove support for specifying the versions of `web3` and `ipfs-api` in a
project's `embark.json`.
2019-11-08 11:27:20 -06:00
Jonathan Rainville 776db1b7f7 feat(@embark/plugin): add priority to regsiterActionForEvents 2019-11-08 08:46:32 -05:00
Pascal Precht 08be5e40fc docs: remove docs for `service` command (#2023)
As discussed in #2008, the `service on/off` command in Embark's interactive console
is non-functioning. As solving the root of the problem requires a bit more effort
than anticipated, we've decided offline to remove this command for the time-being.

The functionality is already gone, this commit removes the corresponding docs.
2019-11-05 10:21:02 -05:00
Michael Bradley ed02cc849f build: bump all packages' engines settings (#1985)
BREAKING CHANGE:

node: >=10.17.0 <12.0.0
npm: >=6.11.3
yarn: >=1.19.1

node v10.17.0 is the latest in the 10.x series and is still in the Active LTS
lifecycle. Embark is still not compatible with node's 12.x and 13.x
series (because of some dependencies), otherwise it would probably make sense
to bump our minimum supported node version all the way to the most recent 12.x
release.

npm v6.11.3 is the version that's bundled with node v10.17.0.

yarn v1.19.1 is the most recent version as of the time node v10.17.0 was
released.
2019-10-24 09:52:05 -04:00
Jonathan Rainville a3b52676fc Fix part of the test app and add new test util functions (#1977)
* fix: fix tests hanging because the console is not started

* fix(@embark/proxy): send back errors correctly to the client

Code originally by @emizzle and fixed by me

* feat(@embark/test-runner): add assert.reverts to test reverts

* fix: make test app actually run its test and not hang

* fix(@embark/proxy): fix listening to contract event in the proxy

* feat(@embark/test-runner): add assertion for events being triggered

* docs(@embark/site): add docs for the new assert functions

* feat(@embark/test-runner): add increaseTime util function to globals

* docs(@embark/site): add docs for increaseTime
2019-10-17 14:39:25 -04:00
Ferran Figueredo 7846e499e8 Typo on messages_configuration 2019-10-15 12:44:23 -04:00
burrrata cde01cd845 Update installation.md (#1881)
updated IPFS installation link
2019-09-07 11:26:25 -04:00
Pascal Precht 86ee867689 feat(@embark/specialconfigs): introduce dynamic addresses (#1873)
* fix embarkjs generation

fix ens setProvider

fix embarkjs objects

fix generated embarkjs provider

generate contracts

fix embarkjs-ens

* address some of the issues in the code review

* feat(@embark/specialconfigs): introduce dynamic addresses

This commit introduces a new Smart Contract configuration addressHandler
that lets users define a function to "lazily" compute the address of the
Smart Contract in question.

This is useful when a third-party takes care of deploying a dependency
Smart Contract, but the address of that Smart Contract only being available
at run-time.

Example:
```
deploy: {
  SimpleStorage: {
    fromIndex: 0,
    args: [100],
  },
  OtherContract: {
    deps: ['SimpleStorage'],
    address: async (deps) => {
      // use `deps.contracts.SimpleStorage` to determine address
    },
    abiDefinition: ABI
  },
}
```

In the example above, OtherContract will be deployed after SimpleStorage
because it uses the deps property to define Smart Contracts that it depends
on. All dependencies are exposed on the addressHandler function parameter
similar to deployment hooks.

Closes #1690
2019-09-06 15:02:51 -04:00
Michael Bradley b736ebefcd refactor: initial steps toward 5.0.0-alpha.0 (#1856)
BREAKING CHANGE:

There are more than several breaking changes, including DApp configuration for
accounts.
2019-08-30 16:50:20 -04:00
Michael Bradley, Jr ad30a98169 refactor: upgrade to web3 v1.2.1
Upgrade all dependencies on web3/web3-* v1.0.0-beta.37 to v1.2.1.

Make various adjustments related to the previous convention of
`"web3": "1.0.0-beta"` in `embark.json` signifying that embark's own web3
dependency should be used in dapp builds.

Fix bugs in library manager, including a switch from using the
live-plugin-manager package to using npm in a child process to install
`"versions"` dependencies specified in `embark.json` when a specified version
doesn't match up with embark's own version for that package.

Avoid race conditions when installing `"versions"` by completing all installs
prior to starting other services. If an install fails, then after all the
installs have completed or failed the embark command will exit with error.

Change various comments and update docs to reflect the new default of web3
v1.2.1.
2019-08-07 11:01:23 -05:00
Jonathan Rainville 59eb69c412 feat(@embark/site): add docs on filteredFields 2019-08-01 13:53:47 -04:00
Jonathan Rainville f9fb302740 feat(@embark/site): add documentation on minimalContractSize 2019-08-01 13:53:47 -04:00
Pascal Precht 8aba85c7d8
docs(deployment): fix type in headline 2019-07-19 11:12:53 +02:00
Your Name e1496a98a2
docs(deployment): add chainstack example 2019-07-19 11:11:21 +02:00
Jonathan Rainville 9c0923c207 fix(@embark/site): fix configuring contract link in structure.md
Originally discovered by christine-ho-dev
2019-07-15 09:16:09 +02:00
Jonathan Rainville ad796bc8f8 fix(@embark/site): update contractGeneration plugin api 2019-07-08 10:26:16 -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
Jonathan Rainville 0a388d741e chore(@embark/site): remove connect() doc and add back onReady 2019-06-26 11:55:26 +02:00
Jonathan Rainville 5044403a03 feat(@embark/site): add section on getting account from describe 2019-06-21 11:00:27 -04:00
Pascal Precht 9f1c4cb329 docs: fix Messages.listenTo() API docs 2019-06-20 15:30:44 +02: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 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
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
Jonathan Rainville f9d7a3f41b feat(@embark/test-runner): show interface contract message in tests
But only show it if the contract was in the contract config
2019-05-10 09:49:34 -04:00
Jonathan Rainville 1f02e493c4 feat(@embark-site): add troubleshooting guide on interface contracts 2019-05-10 09:49:34 -04:00
Jonathan Rainville 8781585341 fix(@embark/site): fix strategy not put in the right section 2019-05-08 16:25:17 -04:00
yanqian 0f2a8231e0 docs(using_the_console): fix typo of methods call 2019-05-07 09:50:00 +02:00
Jonathan Rainville c7c923dec2 fix(embark-site): error in tracking section 2019-04-30 10:50:49 +02:00