If using `embark-snark` in the dapp as a plugin, and the dapp didn’t have any contracts, the `embark-snark` plugin would not simply exit early and essentially do nothing.
Fix `embark-snark` plugin so that it will run its routine regardless of whether or not the dapp has contracts or not.
Bump `circom` and `snarkjs` to their latest patch version.
## Issue 1 - “register” section missing
When the “register” section of `namesystem.json` was missing, ENS would not deploy the ENS contracts nor create the contracts’ artifacts.
### Fix 1
Fix ENS deployment routine to always deploy the ENS contracts. In the case of testnet/mainnet, the contracts’ addresses will be known and therefore will be understood as “already deployed” by the contract deployer.
## Issue 2 - “register” section exists for non-dev environment
Additionally, if a root domain was specified in the “register” section and the DApp connected to an external node where we do not own the ENS contracts (ie testnet), attempting to register a root domain would not be possible as we do not own the ENS contracts.
### Fix 2
Fix ENS deployment routine to check if we are on a network in which we own the ENS contracts. If we are not, and we have specified a “register” section, print a warning to the user that the registration will be ignored. Additionally, remove the “register” section.
The transaction-logger was slowing down tests because each Tx, it
would read a file and write to it, but that's slow and even got
slower as the file grew bigger
To fix, I removed the Tx-logger from text, along with the profiler
as they are useless for tests
(cherry picked from commit a656eea7dda83ad970615cffd51cce5d53a1d034)
There was a race condition in which the coverage module tried to read a generated
coverage report before it was actually generated.
The issue was that the coverage generation was done on Embark's `tests:finished` event
in a fire and forget manner via `emit('tests:finished')` which doesn't
ensure control flow.
This commit changes it to use `runActionsForEvent('tests:finished')` instead and also
registers the handler for coverage report generation as action via `registerActionForEvent()`.
This ensures that those actions are run first, before the code moves on with other
operations that might rely on the result of any of those actions.
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
Was caused by the fact that each rpc-modifier got its own node
accounts, but once the eth_accounts modifier is enabled, the
"node" accounts are always going to contain the custom accounts too
Now, the node accounts are set once eth_accounts is initiated, so
that every modifier is on the same page
Also implement a second layer of protection to make sure that if a
duplication happens, it is gotten rid of
For the test DApp, when ENS is enabled, ENS controls were not showing in Cockpit (under Utils), nor were they available to test in the DApp interface as they did not exist.
Fix ENS controls not showing in Cockpit when enabled.
Add ENS tab to Test DApp for ENS UI.
During `embark test`, the contracts dapp was throwing an error:
```
connection not open on send()
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/Users/michael/repos/embark/node_modules/web3-core-helpers/src/errors.js:42:16)
at XMLHttpRequest.request.onreadystatechange (/Users/michael/repos/embark/node_modules/web3-providers-http/src/index.js:92:32)
at XMLHttpRequestEventTarget.dispatchEvent (/Users/michael/repos/embark/node_modules/xhr2-cookies/xml-http-request-event-target.ts:44:13)
at XMLHttpRequest._setReadyState (/Users/michael/repos/embark/node_modules/xhr2-cookies/xml-http-request.ts:219:8)
at XMLHttpRequest._onHttpRequestError (/Users/michael/repos/embark/node_modules/xhr2-cookies/xml-http-request.ts:379:8)
at ClientRequest.<anonymous> (/Users/michael/repos/embark/node_modules/xhr2-cookies/xml-http-request.ts:266:37)
at ClientRequest.emit (events.js:198:13)
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:198:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:75120) UnhandledPromiseRejectionWarning: Error: Provider not set or invalid
...
```
This was due to the fact that during testing, the Ganache VM **provider** is used as the blockchain node, instead of spinning up an instance of Ganache. Due to this, there is no HTTP nor WebSockets RPC endpoint opened on the VM node, and the contracts dapp was not able to connect to the node during tests.
Add `$EMBARK` to the contract config’s `dappConnection` list, so that the contract test dapp can successfully connect to Embark’s proxy, which ultimately communicates with the Ganache VM.
As a side note, without `$EMBARK` in the `dappConnection` list, the tests could run successfully when using `embark test —node=embark`. This succeeds because the geth node exposes the RPC WebSockets endpoint that the contracts app connects to on `ws://localhost:8546`.
This fixes a bug that redeployment of contracts has not been properly
reflected in the cockpit contract list.
The reason for that was that it's listening for a websocket API that
only updates when the `contractsState` event has been emitted.
The commit ensures `contractsState` is emitted during dedicated deployment
events.
Since ee56f37713, any deployment hook that
was using simple `console.log()` statements to output information, would result in
unexpected `[[object object], [object object]]`.
Unfortunately, the reason for that was that we switched from non-arrow functions to
arrow functions [here](ee56f37713 (diff-a7c4cef8bfebeb39fcd092aca5570fecL324-L340)). Usually switching from non-arrow functions to arrow functions solves
a lot of lexical scope issues where the current reference of `this` isn't pointing at the
right thing.
We're tempering with the global `console.log` inside Embark, which then, combined with
**proper** lexical scope, causes the output described above.
Generally there are a few ways to go about this:
1. Ensure that our custom log functions doesn't turn every log statement into an array output
2. Tell users not to use `console.log` inside deployment hooks and instead rely on `deps.logger`
3. Revert the changes made in the mentioned commit and use non-arrow functions inside `interceptLogs`
Option 2) is not really a solution as we can't simply tell our users that they can't use one of
the most used functions in JavaScript. Option 1) requires finding out why we're formatting logs
by default in an array shapre in the first place. On top of that, we might be relying on this
inside Embark, so it could break certain output.
Option 3) seems to be the most pragmatic solution for now as it doesn't introduce any of the
downsides mentioned above at the cost of using non-arrow functions.
This PR replaces #2057.
Implement a collective typecheck action that can be invoked in the root of the
monorepo with `yarn typecheck` or in watch-mode with `yarn watch:typecheck`.
Include the watch-mode typecheck action as part of `yarn start` (a.k.a
`yarn watch`).
To activate collective typecheck for a package in the monorepo, its
`package.json` file should specify:
```
{
"embark-collective": {
"typecheck": true
}
}
```
*-or-*
```
{
"embark-collective": {
"typecheck": {...}
}
}
```
Where `{...}` above is a `tsconfig.json` fragment that will be merged into the
config generated for the package according the same rules that `tsc` applies
when merging [configs][config].
When collective typecheck begins, it generates a `tsconfig.json` for the root
of the monorepo and for each package that is activated for the action. If the
generated JSON is different than what's on disk for the respective root/package
config, or if the config is not present on disk, then it will be
written. Changes to generated `tsconfig.json` files should be committed; such
changes will arise when there are structural changes to the monorepo, e.g. a
package is added, removed, moved and/or the directory containing it is
renamed. Since the configs are only generated at the beginning of collective
typecheck, when structural changes are made in the monorepo `yarn typecheck`
(or `yarn start` or `yarn watch:typecheck`) should be restarted.
Nearly all of the packages in the monorepo (i.e. all those for which it makes
sense) have been activated for collective typecheck. Even those packages that
don't contain `.ts` sources are activated because `tsc` can make better sense
of the code base as a whole owing to the project references included in the
generated `tsconfig.json` files. Also, owing to the fully cross-referenced
`tsconfig.json` files, it's possible for `tsc` to type check the whole code
base without babel (`yarn build` or `yarn watch:build`) having been run
beforehand.
**NOTE** that a *"cold typecheck"* of the whole monorepo is resource intensive:
on this author's 2019 MacBook Pro it takes around three minutes, the fans spin
up, and `tsc` uses nearly 0.5 GB of RAM. However, once a full typecheck has
completed, the next full typecheck will complete in a few seconds or less; and
when running in watch-mode there is likewise a *big* speedup once a full
typecheck has completed, whether that full check happened before it's running
in watch-mode or when watch-mode itself resulted in a full check before
switching automatically to incremental check, as well a corresponding *big*
reduction in resource consumption. A full check will be needed any time
`yarn typecheck` (or `yarn start` or `yarn watch:typecheck`) is run in a fresh
clone plus `yarn install`, or after doing `yarn reboot[:full]` or `yarn reset`.
The combination of options in each generated package-level `tsconfig.json` and
the root `tsconfig.base.json` result in `tsc` writing `.d.ts` files (TypeScript
declaration files) into the `dist/` directory of each package. That
output is intended to live side-by-side with babel's output, and therefore the
`"rootDir"` option in each generated config is set to `"./src"`.
In projects activated for collective typecheck, `.js` may be converted to `.ts`
and/or `.ts` sources may be added without any additional changes needed in
package-level `package.json`.
---
Reorganize types in `packages/core/typings` (a.k.a `@types/embark`) into
`packages/core/core` (`embark-core`), refactor other packages' imports
accordingly, and delete `packages/core/typings` from the monorepo. This results
in some similarly named but incompatible types exported from `embark-core`
(e.g. `Events` and `EmbarkEvents`, the latter being the one from
`packages/core/typings`); future refactoring should consolidate those types. To
avoid circular dependency relationships it's also necessary to split out
`Engine` from `embark-core` into its own package (`embark-engine`) and to
introduce a bit of duplication, e.g. the `Maybe` type that's now defined in
both `embark-i18n` and `embark-core`.
In the process of the types reorg, move many dependencies spec'd in various
`package.json` to the `package.json` of the package/s that actually depend on
them, e.g. many are moved from `packages/embark/package.json` to
`packages/core/engine/package.json`. Related to those moves, fix some Node.js
`require`-logic related to bug-prone dependency resolution.
Fix all type errors that appeared as a result of activating collective
typecheck across the whole monorepo.
Reactivate `tslint` in `packages/core/core` and fix the remaining linter errors.
Tidy up and add a few items in the root `package.json` scripts.
Bump lerna from `3.16.4` to `3.19.0`.
Bumpt typescript from `3.6.3` to `3.7.2`.
Bumpt tslint from `5.16.0` to `5.20.1`.
Make various changes related to packages' `import`/`require`ing packages that
weren't spec'd in their respective `package.json`. More refactoring is needed
in this regard, but changes were made as the problems were observed in the
process of authoring this PR.
[config]: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
This was caused by the fact that we registered the action to change
the accounts, but that action needs the node accounts, which is
a request to eth_accounts, hence creating a loop
The transaction logger takes care of intercepting any responses coming from the
blockchain proxy, determines what response it's dealing with and then extracts
information from the response to output useful log information to the user, such as
when a contract methods has been called etc.
It turned out that it didn't properly handle cases where value transactions
from account to account (such as done here in [Status Teller](a5ab4d4b26/embarkConfig/data.js (L100-L110))) have been made.
Since Embark couldn't map any of those accounts to actual contracts, while
still having stored corresponding transactions, it logged them as transactions
from "Unknown Smart Contracts".
This commit ensures via heuristics that, if the address a transactions is sent to is
included in any of the nodes accounts, the transaction logger logs a useful message
that a certain value is sent from one to anover account.
fix(@embark/geth): only register console command if in dev mode; use endpoint; use dev account for regular txs that fix geths stuck tx issue
fix(@embark/geth): only do regular txs if miningMode is dev
fix(@embark/geth): only register console command if in dev mode; use endpoint
fix(@embark/geth): only register console command if in dev mode; use endpoint
fix(@embark/geth): only register console command if in dev mode; use endpoint
fix(@embark/geth): only register console command if in dev mode; use endpoint
It's a relevant `package.json` if the package has a test suite. If `test` isn't
specified then the tests won't run in CI (they have't been running).
Include a fix for one failing test in `packages/plugins/ens` and two failing
test in `packages/stack/deployment`. In all three cases, the mock embark
object's config needed a `blockchainConfig` section with `{ enabled: true }`.