Commit Graph

5324 Commits

Author SHA1 Message Date
Iuri Matias a46ea71dbd refactor(@embark/embark-whisper): move whisper module to its own package
refactor(@embark/embark-whisper): move whisper module to its own package

add eslint to dependencies

register whisper module
2019-03-28 14:33:10 -04:00
Iuri Matias 9b493ae7e3 bugfix(@embark/embark-utils): fix import of dockerHostSwap
bugfix(@embark/embark-utils): fix import of dockerHostSwap

bugfix(@embark/embark-utils): fix ts npm call

add ts declartion for embark-utils

add ts declartion for embark-utils
2019-03-28 12:02:54 -04:00
Andre Medeiros 1107138cf5 feature: migrate to azure pipelines 2019-03-27 14:51:27 -04:00
Iuri Matias 3b396cf0c0 refactor(@embark/embark-utils): move host utils to embark-utils 2019-03-27 14:32:32 -04:00
Michael Bradley 5a5d0a69a8 Update packages/embark-utils/README.md
Co-Authored-By: iurimatias <iuri.matias@gmail.com>
2019-03-27 14:14:29 -04:00
Iuri Matias c8475da144 refactor(@embark/embark-utils): move joinPath to embark-utils 2019-03-27 14:14:29 -04:00
Iuri Matias c65a4a7f55 refactor(@embark/specialconfigs): move specialconfigs module 2019-03-27 14:11:03 -04:00
Iuri Matias 0f1a58730e gst 2019-03-27 14:09:26 -04:00
Iuri Matias 6cb14d90f6 refactor(@embark/embark-profiler): move profiler module 2019-03-27 14:09:26 -04:00
Iuri Matias 573237dc81 feature(@embark/embark-ui): add gwei and pwei units to unit converter 2019-03-27 12:35:20 -04:00
Pascal Precht 74683fdc73 uiux(@cockpit): use new Embark logo 2019-03-26 17:40:40 -04:00
Iuri Matias c1bbdbf345 move embark api client code into its own package
move embark api client code into its own package

move embark api client code into its own package

remove unused dependencies

fix linting
2019-03-26 17:36:26 -04:00
emizzle 12cbb7bdd0 fix(@embark/tests): Fix contracts app hanging
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.
2019-03-26 17:35:51 -04:00
emizzle eca456f4cb fix(@embark/storage): Fix hang when IPFS/Swarm started externally
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
2019-03-26 17:35:27 -04:00
Michael Bradley, Jr a609035182 refactor(@cockpit): unregister the service worker
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` &mdash; 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
2019-03-26 16:00:13 -04:00
Michael Bradley, Jr 9829e925b4 refactor(@embark/api): catch-all route, fallback pages for Cockpit
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.
2019-03-26 16:00:13 -04:00
emizzle e4d1e4ea87 fix(@embark/ipfs): Fix IPFS gateway CORS for embark-status plugin
As well as the IPFS API CORS, update the IPFS gateway CORS to successfully run the `embark-status` plugin.
2019-03-22 13:28:05 -04:00
emizzle 774ae4af9a docs(contributing): Update the syntax of the header and scope
Add more detailed syntax and examples surround the commit header and scopes.
2019-03-22 13:27:46 -04:00
emizzle 431d366652 fix(@embark/utils): Fix proxy crash with unknown function
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)
```
2019-03-22 13:27:22 -04:00
Iulian Rotaru (mortimr) 4d4704ac6f feat(@embark/embarkjs): add bytecode to contract
Contract artifacts built by `new.EmbarkJS.Blockchain.Contract(config)` now save the bytecode and runtime bytecode from the config in the instance
2019-03-20 13:11:21 -04:00
Pascal Precht 30e5af5038
chore: ensure root CHANGELOG contains all previous releases 2019-03-19 21:03:46 +09:00
Michael Bradley, Jr 21e23313ba chore(release): 4.0.0 2019-03-18 18:26:56 -05:00
Michael Bradley, Jr 5161f54a39 fix(embark-ui): don't show debug button for txs of silent contracts 2019-03-18 17:53:51 -05:00
Michael Bradley, Jr fa89390ee0 chore(release): 4.0.0-beta.2 2019-03-18 17:04:40 -05:00
Iuri Matias b3b2b317c7 Fix linting 2019-03-18 17:49:00 -04:00
Iuri Matias 9c74da3a7b bugfix(@embark/code_generator): write blockchain config file before writing embarkjs artifact 2019-03-18 17:49:00 -04:00
Michael Bradley, Jr 832f16ae08 fix(embark-ui): detect fallback functions in the contracts explorer
When a fallback function is encountered give its signature as `function()`,
disable row expansion, and omit the interaction form. Also label with a
`fallback` badge.
2019-03-18 16:07:18 -04:00
Andre Medeiros 9d34355994 fix: typed commands in console 2019-03-18 12:23:18 -04:00
Michael Bradley, Jr 7f6c1be390 chore(release): 4.0.0-beta.1 2019-03-17 19:56:29 -05:00
Michael Bradley, Jr f4626f8fec fix(embark-ui): specify PUBLIC_URL=/ for production builds
Create React App automatically determines the base path for links within
production build artifacts based on the project's `"homepage"` field in
`package.json`.

An [alternative][alt-setting] is to set the `PUBLIC_URL` environment variable
in `.env.production`. Take that approach so embark-ui's `"homepage"` can
continue to point to its home in the monorepo on GitHub.

Generate source maps in the production build of embark-ui. Doing so increases
the size of the package's tarball by a few MB (it was already large because of
the editor component), but the benefits of being able to much more easily debug
a production build (e.g. when interacting with users experiencing problems)
outweigh the size cost.

[alt-setting]: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/paths.js#L36
2019-03-17 20:07:19 -04:00
Michael Bradley, Jr db40f03d68 fix(embark): specify "rxjs" as a dependency vs. "@reactivex/rxjs"
`"rxjs"` is [preferable][rxjs-pkg-name] in a CommonJS context,
e.g. node. Existing embark code is `require`-ing from the unscoped package
name, which worked in the monorepo because some other dependency specifies
`"rxjs"` and yarn hoists it to the root of the workspace. In a production
install of embark, though, `require('rxjs')` was failing.

[rxjs-pkg-name]: https://github.com/ReactiveX/rxjs/issues/2577
2019-03-17 20:07:12 -04:00
Michael Bradley, Jr e37598309f refactor(embark): restrict path for fs ops only in VM2 context
When testing production installs of embark 4.0.0-beta.1 (local registry), the
`restrictPath` mechanism of `core/fs` was too restrictive, interfering with
template generation (cause not completely determined). Also, it's known that
`restrictPath` causes problems when resolving plugins, etc. from "higher up"
`node_modules` paths, e.g. in the monorepo.

Introduce `codeRunner/fs` which uses `restrictPath` as before, and in `core/fs`
remove `restrictPath`. Revise the other `codeRunner` modules to use
`codeRunner/fs`.
2019-03-17 20:07:05 -04:00
Michael Bradley, Jr 6758a652eb build(embark-vyper): use a caret range for embark-async-wrapper
Member packages of the monorepo should use caret ranges when specifying other
packages in the monorepo as dependencies.
2019-03-17 20:06:57 -04:00
Michael Bradley, Jr 949015525c build(embark-compiler): use a caret range for embark-async-wrapper
Member packages of the monorepo should use caret ranges when specifying other
packages in the monorepo as dependencies.
2019-03-17 20:06:49 -04:00
Michael Bradley, Jr fd7909087d fix(embark-ui): AccountContainer should get txs for cold load case
Don't implicitly rely on explorer overview having been loaded to initially
populate `entities.transactions`. Also, that container should watch for new
blocks/transactions same as the other explorer containers.

Restore `fetchTransactions` and related to TransactionsContainer. It's no
longer the basis of pagination (it didn't work as desired), but when navigating
through the transaction pages that action will ensure more transactions are
fetched so that the account page will list more of an account's transactions
over time. That was a side effect of `getTransactions` before it was removed in
favor of `getBlocksFull`, which is still the basis of revised pagination logic
in the transactions explorer.
2019-03-15 15:25:56 -05:00
Michael Bradley, Jr fbeea47a6e fix(embark-ui): correctly calculate which transactions to display
Revise calculations related to transactions and pagination in the transactions
explorer and explorers overview.

Make the number of transactions to display per page configurable and set it to
3 in the explorers overview. Display a "No transactions..." message instead of
"0" when there are no transactions to display.

Introduce a `blocksFull` prop, action, api, etc. for calculating lists of
transactions relative to block objects that contain full transaction objects
instead of hash strings (the function backing the blocks endpoint already
supports that) and transaction receipts. In the future, the receipts can be
used to filter out constructor transactions for silent contracts.

Make pagination display conditional within the blocks explorer, same as in the
transactions explorer.
2019-03-15 15:25:56 -05:00
Jonathan Rainville b1881719e0 Fix tests (CI) and debug button (#1443)
* fix(embark/tests): fix tests by not tampering with the contract addr

* fix(cockpit/debugButtong): use deployedAddress instead address
2019-03-15 16:22:24 -04:00
Michael Bradley f60c979c75 refactor(embark-ui): filter silent contracts from contracts listings (#1444)
Filter silent contracts in the views that display contracts lists rather than
with `formatContractForDisplay` because the old approach prevents interaction
with a silent contract if a link to it is followed from the blocks or
transactions explorer, which is not desirable.
2019-03-15 16:22:15 -04:00
Michael Bradley, Jr 9afdbd9848 refactor(embark-ui): improve cockpit's contracts explorer
Rename contract "Transactions" tab to "Log". Display and allow filtering of all
contract methods. Disable debug button for pure/view functions and the
constructor.

Revise the filtering logic so that filters are combined together. Make the
status filter a drop down menu like the others.

Revise styling for consistent row height, alignment of text, and button sizes;
use a monospaced font in some cases to achieve the effect.

Handle enter/return correctly in forms within a contract's Interact tab.

Remove event rows from a contract's Interact tab.

Track pure/view calls in the blockchain proxy so they can be logged server-side
by console listener and reported in Cockpit within a contract's Log tab.

Eliminate double logging in the contracts manager. Ensure contracts deployed on
a fresh `embark run` have an `address` / `deployedAddress` property.
2019-03-15 12:03:52 -05:00
Andre Medeiros b15467f64a feature: decode raw transactions in tx decoder 2019-03-15 12:28:21 -04:00
Jonathan Rainville 5e4a80edec fix(embark/storage): fix hang when storage is disabled 2019-03-14 17:32:04 -04:00
Jonathan Rainville 4d424c06b9 fix(embark/solidity): fix getting the original filename of contracts 2019-03-14 14:15:45 -04:00
Andre Medeiros aba4e0e059 fix: track and debug last transaction correctly 2019-03-14 14:15:19 -04:00
Jonathan Rainville 9bb33e9274 fix(cockpit/suggestions): fix suggestions with slashes 2019-03-14 14:14:52 -04:00
Iuri Matias cfd06b5fe1 feature(@embark/ipfs) add other gateway urls for ipfs 2019-03-14 14:13:51 -04:00
Andre Medeiros 2cc0d305e6 fix: pressing enter on "Display additional results" does the expected thing 2019-03-14 14:13:35 -04:00
Jonathan Rainville 5816a79ae6 fix(cockpit/sidebar): fix closed sidebar in the dark-theme 2019-03-14 14:01:57 -04:00
Jonathan Rainville 22e771bbda fix(cockpit/console): fix cockpit's console outputting "console >" 2019-03-14 14:01:47 -04:00
Iuri Matias 785edf4c9d use e.key instead of e.which 2019-03-14 14:01:28 -04:00
emizzle 8b7a374313 fix(@embark/cockpit): Utils/Communications handle enter
Handle enter pressed when listening to channels and sending messages.
2019-03-14 14:01:28 -04:00