Support embarkjs-whisper with external pipeline.
`embarkjs-whisper` is required by code that is through the VM, and therefore the `embark` package needs to be able to resolve `embarkjs-whisper`.
Create a dev tx (a 0-value tx that is sent from the —dev account to itself) when a request goes through the proxy, but does not get a response after 5 seconds.
Log requests to disk (when log level is trace - enabled with the embark option `—loglevel trace`) that have not received a response and for which a dev tx has been sent.
Add logging to a `proxyLogs.json` log file as well, so that this information can be gleaned later for debugging purposes.
This particular PR Is meant to workaround an issue with running geth with the `—dev` option, as some transactions appear to get stuck, which then builds up further txs in a queue. Only when another tx is sent is the queue then purged as expected.
The remaining issue is that even though a dev tx is sent to relieve the queued txs, the originally offending tx still never receives a response from the node. This was the motivation behind creating a proxy log, so that a dev can inspect the txs that are essentially dropped.
**NOTE:** the base branch of this branch is `refactor/devfunds`. Please merge that branch first.
Change name “DevFunds” to “DevTxs”.
Remove unused functions in dev_funds (create accounts, unlock accounts, fund accounts).
Add console command `sendtx` to send a one-off dev transaction.
Modify the dev tx to send a 0-value tx to itself (ie the `web3.eth.defaultAccount` which is the `—dev` account).
Deprecate the command `regularTxs on/off` in favour of `devtxs on/off` (notice the casing).
Strip regulartxs from cockpit and modify the browser warning to instruct users to run a console command.
This commit has been originally cherry-picked from d0d89fc5ae and
slightly modified to update all packages, as meanwhile, new packages have been added to `master`.
The reason this commit is cherry-picked from `4.0.x` branch is because
it wasn't created from `master`.
Purpose is mainly to update `CHANGELOG` and get the package versions in sync again.
Display five contracts per page in the dashboard. Display ten contracts per
page in the contracts explorer and deployment page.
Sort contracts by name. In the future we can implement an option to sort by
block number and index within a block by calculating and including that
information as part of the server-side api response (based on a contract's
txhash).
Remove unnecessary contract filtering in the components since the containers
take care of it.
Make use of `listenToContracts` / `stopContracts` in DeploymentContainer.
feature(@embark/embarkjs-whisper: make embarkjs whisper plugin a module on its own
feature(@embark/embarkjs-whisper: make embarkjs whisper plugin a module on its own
During work on PRs #1492 and #1494 it became evident that it's not desirable to
show pagination controls unless the number of pages is greater than one.
Display a truncated account balance if the balance is greater than 20
characters in length. This keeps the "Balance", "Tx Count", and "Index" fields
well-aligned in lists of accounts.
In the account details page continue to show the full balance.
Display two accounts per page in the explorer overview. Display ten accounts
per page in the accounts explorer page.
Sort accounts by their api-supplied index numbers with the lowest index coming
first.
Change the `initBlockHeader` saga so that it triggers a re-fetch of accounts
and therefore the "Tx Count" numbers of displayed accounts will reflect
increased counts.
During deploy with a failing transaction, embark was crashing due to the variable `line` being passed in as undefined.
Add better error handling to catch this error and prevent embark from crashing.
Make tabs draggable so they can be arranged how the user would like.
The dragging functionality locks the tabs to the parent container.
Support for multiple rows of tabs.
Styling updates for selected tabs.
When connected to metamask, and “Injected Web3” is selected on the Deployment page of Cockpit, check to see if contracts have already been deployed or not.
For contracts that have not been deployed, or set to an address in the config, these should now all be re-deployable.
Supports libraries (that have bytecode with `0x73<address><bytecode>`).
Compare a contract's `originalFilename` property to a contract file's
normalized `originalPath` property instead of `filename`. The `filename`
property seems to have been removed.
Contract app hangs when attempting to test the solc contract in the test folder.
There were several causes:
1. The test contract needed a referenced contract path updated
2. 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.
3. Contract filtering was attempting to filter on a property `filename` that must have been changed to `originalFilename` at some point and therefore was not filtering properly.
4. The accounts used by the contract deployer were getting overwritten when `SolcTest` was instantiated and thus preventing the `remix_tests` `Assert` library from getting deployed.
Fix hang when the storage provider (IPFS or Swarm) was started externally before running Embark.
If IPFS/Swarm was already running before `embark run` was run, then the relevant `registerProvider` and `setProvider` code was not being run through the console, and thus the module init event was never fired, preventing the DApp from being built.
This PR refactors the way the IPFS/Swarm process is launched so that the `registerProvider` and `setProvider` code snippets are run through the console in the case of:
* IPFS/Swarm running externally from Embark
* IPFS/Swarm started in a child process by Embark
* Storage is disabled in the DApp config
TL;DR
=====
Unregister (disable) the service worker in production builds of Cockpit. The
CRA dev server doesn't enable the service worker, so no changes are needed in
that context, i.e. `yarn start` in the monorepo.
**NOTE**: to effect these changes a user will need to load production Cockpit at
`localhost:55555` and then close all Cockpit tabs (or restart the
browser). This should be done for each browser that has been used to access
production Cockpit. See the *Step-by-Step* section below for more information.
Rationale
=========
There are a couple of factors:
* It's a bit confusing that after stopping `embark run` the production build of
Cockpit is still accessible at `localhost:55555`. That's owing to CRA's
[offline-first behavior][PWA] per the service worker it creates, which
Cockpit [currently registers][current] (enables).
* It can be really confusing, if you don't know or forget about the service
worker's behavior, that after a production rebuild of Cockpit the old build
is still used in the browser, even after a page refresh. As [explained][ofb]
in CRA's docs: *"users will end up seeing older content until they
close (reloading is not enough) their existing, open tabs."* A similar effect
is seen when switching between DApps, e.g. teller and embark_demo.
The CRA docs point to [some code][code] that could be adapted to an alert in
the UI prompting the user to close all tabs and reopen the app. That approach
definitely makes sense for DApps built with CRA that have opted-in to the
service worker. In fact, the service worker behavior would be critical in DApps
that make use of connected-/react-router because cold loads of routes that
don't actually correspond to static files couldn't otherwise work, i.e. if the
DApp is being served from ipfs/swarm.
But for Cockpit itself, when served from localhost with an express backend that
we control, little seems to be gained from offline-first behavior vs. a more
familiar behavior, i.e. when `embark run` isn't running then Cockpit isn't
accessible.
Step-by-Step
============
Flushing a site's service worker from cache can be tricky. The following steps
outline an approach to making sure the Cockpit in use is the one with service
worker disabled.
1. The first screenshot below shows the JavaScript console from a fresh load of
Cockpit with the service worker enabled, i.e. from a build on `master` at time
of writing and `embark run` running for the `embark_demo`. Note the messages
re: *"workbox"* and *"precaching"*.
![][step-1]
2. The next screenshot shows what happens when `embark run` is stopped and the
browser is refreshed. Service worker makes the page available offline, though
there are errors related to embark's API not being accessible.
![][step-2]
3. (a) Cockpit gets rebuilt on this PR's `refactor/cockpit-service-worker`
branch and `EMBARK_UI_STATIC=t embark run` is started; see [previous
commit][prevcom] re: `EMBARK_UI_STATIC`. (b) The browser is refreshed. Note the
message at the bottom re: *"New content is available"*.
![][step-3]
4. The Chrome browser is closed completely (command-Q), reopened and
`localhost:55555` is loaded again. Note there are *still* messages re:
*"workbox"* and *"precaching"*.
![][step-4]
5. The page is refreshed again and now the messages are completely gone.
![][step-5]
6. `embark run` is stopped and the page is reloaded, but there's a connection
error because no process is listening on `localhost:55555` — proof that
the service worker is no longer in play!
![][step-6]
Steps 3(b) to 6 will need to be repeated for each browser (Firefox, Safari,
etc.) that visited `localhost:55555` when the service worker was enabled. And
they'll need to be repeated again if the browser is later used with a build of
Cockpit predating this PR.
[PWA]: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
[current]: 4d4704ac6f/packages/embark-ui/src/index.js (L39)
[ofb]: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app#offline-first-considerations
[code]: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/src/serviceWorker.js#L66-L93
[step-1]: https://user-images.githubusercontent.com/194260/54885199-adfa0900-4e47-11e9-830b-1b92816b2354.jpg
[step-2]: https://user-images.githubusercontent.com/194260/54885202-b3575380-4e47-11e9-9c1e-24817472d9c4.jpg
[step-3]: https://user-images.githubusercontent.com/194260/54885209-bb16f800-4e47-11e9-8e23-8fbc3b4f48fa.jpg
[prevcom]: https://github.com/embark-framework/embark/commit/322033cc
[step-4]: https://user-images.githubusercontent.com/194260/54885212-bfdbac00-4e47-11e9-9c8c-db90228d953a.jpg
[step-5]: https://user-images.githubusercontent.com/194260/54885214-c538f680-4e47-11e9-9963-58fd041675f0.jpg
[step-6]: https://user-images.githubusercontent.com/194260/54885217-ccf89b00-4e47-11e9-967a-7f8a523d4a92.jpg
Implement a `/*` server-side catch-all route for Cockpit that loads Cockpit's
`index.html`.
This change is necessary with intent to disable offline-first behavior in
production builds of Cockpit. Cockpit's service worker effectively translates
server-side route unavailability into client-side behaviors of
connected-react-router. When the service worker is unregistered the same will
be accomplished via the server-side catch-all route.
Implement fallback pages for when embark is in the monorepo but Cockpit's
Create React App development server isn't yet started or isn't yet responsive.
Implement a fallback page for when the static build of Cockpit is missing. When
embark is in the monorepo, give instructions for building Cockpit. Otherwise,
report that the distribution is broken.
Deprecate the environment variable `EMBARK_DEVELOPMENT` in favor of
`EMBARK_UI_STATIC`. Unless the latter is truthy at runtime, when embark is in
the monorepo the CRA dev server of Cockpit will be accessible at
`localhost:55555` via proxied requests to `localhost:3000`. The deprecation is
not a breaking change as `EMBARK_DEVELOPMENT` / `EMBARK_UI_STATIC` are not
relevant to normal users, but only to developers working on embark itself.
Bump `express-http-proxy` to the latest version.
If a transaction is sent and the proxy is enabled, but the function hash (identified in the data of the transaction) is not recognized as a function of the contract (ie does not match a function hash in the contract’s ABI), then embark would crash.
The fix was to introduce error handling in `transactionUtils.getTransactionParams` that defaults the contract name and params to `UNKNOWN`.
This can be replicated by
1. Clone https://github.com/mortimr/ethvtx_embark
2. `embark run` the dapp
3. Connect with Metamask
4. Ensure you have enough funds
5. In the “Tx calls” bubble, enter a new value, then click “Set Value”.
6. When the Metamask dialog appears, the error should have already happened. The console shows:
```
embark/src/lib/utils/transactionUtils.ts:58
const functionName = func.functionName;
^
TypeError: Cannot read property 'functionName' of undefined
at functionName (/Users/mortimr/Horyus/ethvtx_embark/node_modules/embark/src/lib/utils/transactionUtils.ts:58:29)
at ConsoleListener.getTransactionParams [as _onIpcLogRequest] (/Users/mortimr/Horyus/ethvtx_embark/node_modules/embark/src/lib/modules/console_listener/index.js:102:41)
at _onIpcLogRequest (/Users/mortimr/Horyus/ethvtx_embark/node_modules/embark/src/lib/modules/console_listener/index.js:76:12)
at Server._done (/Users/mortimr/Horyus/ethvtx_embark/node_modules/embark/src/lib/core/ipc.js:81:7)
at Server.emit (/Users/mortimr/Horyus/ethvtx_embark/node_modules/event-pubsub/es5.js:74:21)
at Server.gotData (/Users/mortimr/Horyus/ethvtx_embark/node_modules/node-ipc/dao/socketServer.js:194:14)
at Socket.emit (events.js:189:13)
at Socket.EventEmitter.emit (domain.js:441:20)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:261:13)
at Socket.Readable.push (_stream_readable.js:220:10)
at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
```