Embark's `File.content` is an asynchrononus getter that potentially downloads the
contents of a file from its `externalUrl`. This can potentially fail but is not properly
reported to the user as the error itself is ignored.
This commit ensures errors are propagated and displayed to the user.
The blockchain module should not contain any ethereum-specific code, and currently it contains a check to see if the blockchain has already been started.
This PR moves this check to blockchain client (ie geth or parity). This check function is registered along with the started callback.
style(@embark/stack/blockchain): add missing semicolon
Turns out that, when Embark tries to replace ENS subdomains, it would fail
if `subdomains` aren't defined in the namesystem configuration.
This commit adds a safeguard so that not defining `subdomains` is fine.
This commit fixes the issue that it wasn't possible anymore to use named constructor arguments
in Smart Contract configurations.
For example, the following Smart Contract expects two constructor arguments:
```solidity
contract SomeContract {
constructor(address[] _addresses, int initialValue) public {}
}
```
The first being a list of addresses, the second one a number. This can be configured as:
```js
SomeContract: {
args: [
["$MyToken2", "$SimpleStorage"],
123
]
}
```
Notice how the order of arguments matters here. `_addresses` come first in the constructor,
so they have to be defined first in the configuration as well.
Another way to configure this is using named arguments, which is what's broken prior to this commit:
```js
SomeContract: {
args: {
initialValue: 123,
_addresses: ["$MyToken2", "$SimpleStorage"]
}
}
```
Using a notation like this ^ the order no longer matters as Embark will figure out the right
values for the constructor arguments by their names.
The reason this is broken is because there are several modules in Embark that register and
run a `deployment:contract:beforeDeploy` action, which are allowed to mutate this configuration
object. One of those modules is the `ens` module, which searches for ENS names in the arguments
and figure out whether it has to replace it with a resolved address.
One thing that particular module didn't take into account is that `args` could be either and
array, or an object and will always return an array, changing the shape of `args` in case it was
an object.
This is a problem because another module, `ethereum-blockchain-client`, another action is registered
that takes this mutated object in `determineArguments()` and ensure that, if `args` is actually an
object, the values are put in the correct position matching the constructor of the Smart Contract in
question.
One way to solve this was to use the newly introduced [priority](https://github.com/embark-framework/embark/pull/2031) and ensure
that `ens` action is executed after `ethereum-blockchain-client`'s.
However, the actual bug here is that the ENS module changes the shape of `args` in the first place,
so this commit ensures that it preserves it.
Update event name `"deploy:contract:deployed"` to
`"deployment:contract:deployed"`.
Also, listen one time for `"deployment:deployContracts:afterAll"` and then
request the full contracts list so as to pickup contract names that were
already deployed. This is necessary for subsequent `embark run` (without
reset), otherwise the suggestions list will be missing contracts.
The `WhisperGethClient` returns empty strings for its "new account" and "list
accounts" commands; if a command is an empty string then `Blockchain` should
not execute it.
Previously, in the embark cli dashboard/console, if you were to type `Foo.` and
hit tab for autocomplete then (assuming you hadn't defined `Foo`) there would
be unhandled errors and the console could even become unusable.
Refactor `packages/core/console` and related code so that nothing happens when
you attempt to autocomplete a bad reference (the same behavior as Node's own
REPL).
Also bump peerDeps: @emotion/core from 0.13.1 to 10.0.22 and @emotion/styled
from 0.10.6 to 10.0.23. Satisfy @babel/runtime peerDep with 7.6.3.
Make small refactors in components/FileExplorer and
containers/FileExplorerRowContainer re: the package upgrades.
Replaces #1998
* fix(@embark/solidity): fix solidity ipc connection with blockchain
When blockchain was run in another process, the IPC was connected,
but the compiler was not loaded, so the IPC calls never returned
* fix(@embark/geth): fix cb is not a fn because it needs request2
`embark console` registers and tries to spin up `Cockpit`, even when there's already
a Cockpit instance running and thefore exits with an error that a certain port is already
in use.
This commit ensures that Cockpit is only bootstrapped when `embark console` is
executed as a non-secondary process, meaning that there's no other `embark run`
process active that might occupy Cockpit's default port.
We've introduced a regression in https://github.com/embark-framework/embark/commit/f9557d4c9 where invalid data
has been sent to web3's `ecRecover()` method to verify signed messages.
This causes an internal server error and the utility feature inside Cockpit
unsuable.
This commit ensures that the correct data is sent to `ecRecover()` making verifying
messages through Cockpit functional again.
Fix the proxy’s handling of WebSocket connections when subscribing to contract events and node data using the `eth_subscribe` RPC request.
Previously, the client connection that the subscription data was sent to was often in a closed state. It was determined that this connection was the wrong connection to forward the data in the first place. The connection was in fact generally the connection created for the Ethereum service check which was then (correctly and subsequently) closed after it had finished its operation.
The flow of a proxy request handling a WebSocket “eth_subscribe” RPC request is now as follows:
1. A WebSocket RPC request `”eth_subscribe”` is sent from a client to the proxy.
2. Proxy forwards the request to the node by way of a new instance of `RequestManager`.
3. When the node receives an event matching the subscription, it sends the event data back to same socket connection it received the request on (ie the specific instance of `RequestManager`).
4. The `RequestManager` fires the `”data”` event containing the subscription data, and this event is picked up in the proxy.
5. The proxy then forwards the subscription data on to the originating WS client connection.
All other requests (ie non-WS or WS RPC requests that are not `eth_subscribe`) will be serviced to/from the node using a single `RequestManager` instance.
Co-authored-by: Pascal Precht <pascal.precht@gmail.com>
* Revert "fix(@embark/core): set loglevel back to info"
This reverts commit a03ffd56e5.
* Revert "fix(@embark/proxy): Fix contract event subscriptions"
This reverts commit 173d53de2f.
Fix the proxy’s handling of WebSocket connections when subscribing to contract events and node data using the `eth_subscribe` RPC request.
Previously, the client connection that the subscription data was sent to was often in a closed state. It was determined that this connection was the wrong connection to forward the data in the first place. The connection was in fact generally the connection created for the Ethereum service check which was then (correctly and subsequently) closed after it had finished its operation.
The flow of a proxy request handling a WebSocket “eth_subscribe” RPC request is now as follows:
1. A WebSocket RPC request `”eth_subscribe”` is sent from a client to the proxy.
2. Proxy forwards the request to the node by way of a new instance of `RequestManager`.
3. When the node receives an event matching the subscription, it sends the event data back to same socket connection it received the request on (ie the specific instance of `RequestManager`).
4. The `RequestManager` fires the `”data”` event containing the subscription data, and this event is picked up in the proxy.
5. The proxy then forwards the subscription data on to the originating WS client connection.
All other requests (ie non-WS or WS RPC requests that are not `eth_subscribe`) will be serviced to/from the node using a single `RequestManager` instance.
Co-authored-by: Pascal Precht <pascal.precht@gmail.com>
Running embark's `blockchain` command resulted in a runtime error where the `blockchain`
module couldn't be found. This is a bug introduced in ed0d3afb4f where
we forgot to update `blockchainStackComponents` in Embark's engine accordingly.
Fixing this results in `embark blockchain` hanging. This is because there's a similar bug
in `blockchainStackCopmnonents` introduced in 3b8f8f9ea7.
This commit fixes both bugs by ensuring `embark-blockchain` and `embark-blockchain-client`
packages are loaded using the correct APIs.
If the version in the embark package's own `package.json` has a prerelease
identifier then appending `.x` to the major version isn't viable for resolving
the latest version of the template package that's in the same prerelease line;
a more complex semver range must be used:
```
"${pkg}@^${major}.${minor}.${patch}- <${major}.${minor}.${patch}"
```
When making use of the `useBuiltIns: 'usage'` option for @babel/preset-env
(which is the case for all transpiled packages in Embark's monorepo) a package
needs to have both @babel/runtime-corejs3 and core-js@3 specified as
dependencies.
Embark relies on certain specific plugin properties, e.g. registered compilers,
and retrieves them using `plugins.getPluginProperties('compilers', 'compilers')`.
In order to make this work in the testing environment, we need those same APIs
in the `embark-testing` package as well.
This commit adds necessary APIs to `Plugins` and `Plugin` to make registering and
loading compiler plugins work.
* build(deps): move deps needed by embark-basic-pipeline from packages/embark
Introduce additional refactors to ensure the packages can be resolved by the
basic pipeline's webpack child process.
* build(deps): move @types/os-locale from packages/embark to packages/core/i18n
* build(deps) move @types/globule from packages/embark to packages/plugins/coverage
* build(deps): refactor stack/{api,proxy,webserver} deps relative to packages/embark
* build(deps): remove unneeded @types/async dep from packages/stack/test-runner
* build(deps): remove unneeded deps from packages/embark
* build(deps): upgrade create-react-app for cockpit by bumping react-scripts to latest
Also get rid of a peer dependency warning related to storybook. After some
investigation it seems that storybook can't practically (at present) be made
aware of CRA in the same project satisfying storybook's peer deps, so it's best
to just satisfy all of them explicitly, which in any case won't interfere with
CRA (react-scripts).
* build(deps): move @types/os-locale from packages/embark to packages/core/i18n
* build(deps) move @types/globule from packages/embark to packages/plugins/coverage
* build(deps): refactor stack/{api,proxy,webserver} deps relative to packages/embark
* build(deps): remove unneeded @types/async dep from packages/stack/test-runner
* build(deps): remove unneeded deps from packages/embark
Introduce some light refactoring related to embark-testing facilities, and also
a configurable stdout option so the output of the reporter implemented in this
package isn't confusingly mixed into unit test reporting for this package.
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.
* refactor(@embark/dapps/tests/app): use function syntax
These changes don't fix the race conditions related to the test dapp's tests
but are a step in the right direction.
* refactor(@embark/dapps/tests/contracts): adjustments to get tests passing
Further refactoring is needed re: potentially duplicated or overlapping logic
in `packages/plugins/solidity-tests` and
`packages/core/utils/src/solidity/remapImports.ts`, as well in disabled test
dapp tests
* test(dapps/tests/app): temporarily disable intermittently failing tests
They are failing because of a race condition; once that race condition has been
fixed these tests should be reenabled.
* fix(@embark/solidity-tests): fix importing the library for the tests
* build(@embark/stack/blockchain-client): remove unneeded typescript related scripts and deps
In addition to being unneeded their presence is causing build errors.
* build(embark): remove unneeded typescript related scripts and deps
In addition to being unneeded their presence is causing build errors.
* build(@embark/plugins/ethereum-blockchain-client): remove unneeded typescript related scripts, deps
In addition to being unneeded their presence is causing build errors.
* build(@embark/plugins/ganache): remove unneeded typescript related scripts and deps
In addition to being unneeded their presence is causing build errors.
* build(@embark/plugins/geth): remove unneeded typescript related scripts and deps
In addition to being unneeded their presence is causing build errors.
* fix(@embark/plugins/transaction-logger): require 'web3' not 'Web3'
* fix(@embark/utils/solo): spawn npm(.cmd) instead of npx(.cmd)
* test(@embark/plugins/basic-pipeline): add test stub
* test(@embark/stack/blockchain): add test stub
Fix a lot of bugs and reenable a couple of modules
Some tests were kept disabled, mostly the ENS and EmbarkJS tests
Those need to add back a fairly significant feature to work
Add back missing solidity contracts
In d6bf5c24b9 we've ensured that certain modules of
embark only executed if their functionality is actually enabled.
This broke one of our tests in the communication module.
This commit fixes the test by explicitly enabling the module's functionality.
* 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
Contains bug fixes to get parity to work as a blockchain client.
**NOTE:** Please merge https://github.com/embark-framework/embark/pull/1950 first before merging this PR, as this PR contains removal of dependencies from `packages/embark` that are needed for geth. So if this is merged first, and the geth PR (https://github.com/embark-framework/embark/pull/1950) is not merged, then geth will not have some of the dependencies it needs.
**NOTE:** Running a dapp with `client: “vm”` does not work, however I am not sure if that is intentional in v5 or not.
**NOTE:** Running `embark test` in the demo DApp does work, although there is an error that I am assuming does actually pertain to this PR:
```
made request without listener: whisper:node:register
Trace:
at EmbarkEmitter.trace [as request] (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/events.js:142:13)
at new request (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/modules/geth/index.js:49:17)
at Plugin.loadInternalPlugin (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/plugin.js:117:10)
at Plugins.loadInternalPlugin (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/plugins.js:96:40)
at Engine.loadInternalPlugin [as registerModule] (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/engine.js:69:18)
at Engine.registerModule [as blockchainComponents] (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/engine.js:183:10)
at Engine.apply [as registerModuleGroup] (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/engine.js:104:18)
at registerModuleGroup (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/cmd/cmd_controller.js:740:16)
at nextTask (/Users/emizzle/Code/__Github/embk-fw/embark/node_modules/async/dist/async.js:5324:14)
at next (/Users/emizzle/Code/__Github/embk-fw/embark/node_modules/async/dist/async.js:5331:9)
at /Users/emizzle/Code/__Github/embk-fw/embark/node_modules/async/dist/async.js:969:16
at callback (/Users/emizzle/Code/__Github/embk-fw/embark/packages/embark/src/lib/core/engine.js:47:9)
at Client.done (/Users/emizzle/Code/__Github/embk-fw/embark/packages/core/core/src/ipc.js:46:11)
at Client.emit (/Users/emizzle/Code/__Github/embk-fw/embark/node_modules/event-pubsub/es5.js:74:21)
at Socket.connectionClosed (/Users/emizzle/Code/__Github/embk-fw/embark/node_modules/node-ipc/dao/client.js:201:20)
at Socket.emit (events.js:198:13)
```
**TODO:** The `embark eject-webpack` command needs to be updated. @michaelsbradleyjr - do you have suggestions as to how we could port this over? We could **assume** that the `basic-pipeline` plugin will be installed, and then read the embark config and overrides from the file system, however this feels like we are sort adding a dependency to a plugin, which is not right. Any suggestions?
* bugfix(@embark/embark): fix default values so choosing different environment doesn't cause hang
* bugfix(@embark/stack/watcher): add callback so initializating watcher does not hang cmd controller
Change components/TexEditor re: how monaco-editor is loaded, since difficulties
with monaco-editor were the original motivation for "ejecting" the CRA setup.
Specify "nohoist" for `embark-ui/react-scripts` and all its dependencies to
avoid potential headaches when upgrading the react-scripts, i.e. upgrading to
newer versions of create-react-app.
It's principal use was in `stack/compiler`, but that package was refactored
in #1878 to use async/await. There was a replica in
`packages/embark/src/lib/utils/async_extend.js` but it wasn't being used to do
async operations and could be replaced with `Object.entries().forEach()`. It
was required by `plugins/vyper` but the wrapper's custom `eachObject` method
wasn't being used. `stack/api` had it as a dependency but wasn't using it.
* chore: test framework
* chore(@embark/testing): introduce Plugin apis and other changes
* refactor(@embark/deployment): use new testing APIs for tests
* feat(@embark/compiler): support :before and :after hooks on event compiler:contracts:compile
* style: keep root package.json sorted cleanly
* style: formatting with prettier where print-width is 200
Per the suggestion of @iurimatias
* WIP: PR review
* WIP: PR review
* WIP: refactor to check if file.path is within dappPath() or os.tmpdir()
* WIP: PR review
* WIP: use native async functions (and related JS lang constructs) instead of the async library
* WIP: async.eachObject is no longer a dependency
* fix: fix test-app, contracts index file and reload on change
* fix(@embark/cmd_controller): fix missing nodes
Was removed by accident
* feat(@embark/demo): add favicon to embark demo
* chore(@embark/cockpit): change favicon to new Embark logo
* fix(@embark/embarkjs-ens): fix ENS config for embarkjs-ens
* remove comments
When an options object is not supplied the tests fail because the constructor
expects the options argument to be an object, i.e. referencing
`options.plugins` should not cause a TypeError
* chore(@embark/): move embarkjs packages to their own folder
* chore(@embark/): rename embark-ui folder to cockpit
* chore(@embark/): rename packages already in logical folders to remove embark- prefix
chore(@embark/): rename packages already in logical folders to remove embark- prefix
update package.json files to use correct eslint config
remove core/* from package.json workspaces
* fix(@embark/cmd_controller): fix embark blockchain command
* feat(@embark/blockchain): ping endpoint before starting the node
also use web3 instead of function to ping endpoint
* dont override console.error completely
* 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
There was an error that would display on the second+ run of embark, that was causing by trying to read JSON of an empty file.
The solution was a combination of ensuring the file existed with defaults when enabled, and also ensuring we await the saving of the file.
Included is a bit of a refactor of how the tracking functions handled the “current chain”. Hopefully, this should make things more clear.
Tests have been updated accordingly.
* 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
* address some of the issues in the code review
* address some of the issues in the code review
* address some of the issues in the code review
* refactor(@embark/cmd-controller): re add cargo for file watcher
(cherry picked from commit 5c77b4000742a14f42a6dc5c145672b9cd0957a3)
* use generate:all instea dof the event
This is crucial as the storage module tries to generate/eval artifacts that
depend on a `web3` object inside the VM scope. The registration of that object
can only be garuanteed when the `blockchain:started` event has been fired.
This commit ensures these modules are not spinned up in parallel as we're running
into race conditions.