Commit Graph

95 Commits

Author SHA1 Message Date
Michael Bradley, Jr 52d54f0d87 fix(@cockpit/explorers): consistently display "Mined on" timestamps
Adjust the API endpoints to augment transaction objects with a timestamp
property from their corresponding blocks. This removes the necessity to copy
the timestamp property from a block to its transactions in the client.

Introduce a `formatTimestampForDisplay` util function in Cockpit for
consistently transforming timestamps into relative or absolute dates, depending
on whether a date is sometime during the last day.
2019-07-03 08:25:08 -05:00
Pascal Precht fc7eb0cca6 uiux(@cockpit/sign-and-verify): improve wording for verifying messages 2019-07-01 11:10:37 +02:00
Michael Bradley, Jr eecb48f5b6 chore(release): 4.1.0-beta.4 2019-06-27 14:23:32 -05:00
Pascal Precht 610d8f1baa fix(@cockpit/utils): Ensure whisper channels are at least 4 characters long
This check was already made when sending messages to whisper channel, however, we didn't
perform the same check when subscribing to channels within cockpit.
2019-06-27 08:36:25 -05:00
Michael Bradley, Jr ff3100b035 chore(release): 4.1.0-beta.3 2019-06-07 13:42:13 -05:00
Pascal Precht d10c0b7951 feat(@cockpit/explorer): enable users to send ether through payable methods (#1649) 2019-06-06 12:52:01 -04:00
Michael Bradley, Jr ac76a40a61 fix(@cockpit/explorer): slice contract function result string only if starts/ends with double-quote
Closes #1636.
2019-05-28 09:36:38 +02:00
Michael Bradley, Jr 030aba190d build: change the engines range for NodeJS to indicate embark is not compatible with v12.x 2019-05-28 09:35:44 +02:00
Michael Bradley, Jr 91f87d2057 chore(release): 4.1.0-beta.2 2019-05-22 18:09:06 -05:00
Pascal Precht 2c6c9489fc fix(@cockpit/whisper): ensure message subscription call is working
When introducing the `embark-api-client` in https://github.com/embark-framework/embark/commit/c1bbdbf34
we didn't properly update Cockpits apiService, resulting in calls to API endpoints
that don't exist.

This commit fixes a bug where calls to Embark's API to subscribe to whisper
channels are in a broken state.

It also updates Cockpit's apiService to no longer pass ignored parameters to embark-api-client.
2019-05-22 17:16:16 +02:00
Pascal Precht 7a0609b66c fix(@cockpit/utils): properly detect if ENS is enabled
With the move of Embark's modules into their own packages, the names under
which they are registered in the API service have changed as well.

This caused Cockpit to no longer being able to properly detect whether
ENS is enabled in the current Embark project
2019-05-22 17:15:57 +02:00
Michael Bradley, Jr 4ee1567264 chore(release): 4.1.0-beta.1 2019-05-15 18:44:46 -05:00
Michael Bradley, Jr 78f7c52080 build: supply missing deps so production builds can function correctly 2019-05-15 18:15:50 -05:00
emizzle 634feb597a feat(@embark/api): Add command `service api on/off`
Add support for `service api on/off` commands.

Deprecate commands `api start/stop` in favor of `service api on/off`.

`service api on` - Enables the API server serving Cockpit. Shows an error if the API server is already starting or started.

`service api off` - Disables the API server serving Cockpit. Shows an error if the API server is already stopping or stopped.

`api start` - This command has been deprecated in favor of `service api on` and will be removed in future versions.

`api stop` - This command has been deprecated in favor of `service api off` and will be removed in future versions.

`api:start` - This event has been deprecated and will be removed in future versions.

`api:stop` - This event has been deprecated and will be removed in future versions.
2019-05-15 14:28:10 +02:00
Michael Bradley, Jr 2f2c0eefbf refactor(@cockpit/explorer): revise transactions explorer per techniques of PRs #1492, #1494
In addition to introducing improvements per #1492 and #1494, adjust the
transactions request action to allow for a `blockLimit` argument, since that
API parameter is supported by embark.

Revise `changePage` to invoke `fetchTransactions` correctly, i.e. with
arguments pertaining to a starting block number and a block limit.

These changes together fix most of the pagination problems related to exploring
transactions, i.e. badly mis-ordered results are no longer displayed.

However, a *wart* still remains related to estimation of the total number of
transactions and pages. Sometimes the calculated number of pages for the
transactions explorer doesn't match up to the actual number of transactions on
the blockchain (owing to estimation). The pagination controls and display of
transactions will temporarily behave a little strangely if one jumps ahead in
the pages, e.g. a jump from cockpit explorer overview's transactions page 1 to
page 5 for embark's demo, if an additional transaction has been added and the
explorer overview is freshly loaded. This behavior is related to the fact that
actions such as `fetchBlocksFull` and `fetchTransactions` are async without any
means to determine when all actions have completed and React re-/rendering has
settled down.

There are probably some architectural changes that could improve the situation,
but they're outside the scope of this PR and in no way easy to solve by means
of React lifecycle methods. In fact, attempts to make an improvement with
`componentDidUpdate` (and watching what happens in the debugger) revealed the
nature of the problem, as described above.
2019-05-07 10:40:27 -05:00
Michael Bradley, Jr fa2807b335 refactor(@cockpit/explorer): revise blocks explorer per techniques of PRs #1492, #1494 2019-05-07 10:39:58 -05:00
Michael Bradley, Jr 579328a9f4 chore(release): 4.1.0-beta.0 2019-04-17 11:11:28 -05:00
Michael Bradley, Jr eb9de680d3 fix(@cockpit/services): send only process names to embark-api-client
`webSocketProcess` function in `embark-api-client` expects only a process name,
but cockpit was calling it with name-strings prepended with `/process-logs/`
resulting in bad URLs. Revise cockpit's `services/api` module to call
`webSocketProcess` with process names only.
2019-04-16 14:25:35 -04:00
emizzle 36be50e5dc feat(@embark/proxy): Add dev tx to proxy when request fails to get response
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.
2019-04-12 14:48:07 -04:00
emizzle 0c98af7977 refactor(@embark/blockchain_process): Refactor dev_funds
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.
2019-04-12 14:48:07 -04:00
Iuri Matias 4d2ffb9f28 [CHERRY PICKED] chore(release): 4.0.1
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.
2019-04-10 12:18:35 +02:00
Andre Medeiros 776cb140d2 feature: stop debugging button 2019-04-04 14:47:26 -04:00
Michael Bradley, Jr d71352b781 feat(@cockpit): implement pagination for contracts
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.
2019-04-04 13:14:53 -05:00
Michael Bradley, Jr b751b9c559 refactor(@cockpit/explorer): show pagination when num pages > 1
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.
2019-04-04 12:59:12 -04:00
Michael Bradley, Jr 6b2dc95fad feat(@cockpit/explorer): display truncated account balances
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.
2019-04-04 12:49:17 -04:00
Michael Bradley, Jr 745edafee4 feat(@cockpit/explorer): implement pagination for accounts explorer
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.
2019-04-04 12:49:17 -04:00
emizzle f27cde9261 feat(@cockpit/editor): Make tabs draggable
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.
2019-04-04 12:46:47 -04:00
emizzle c23316351e fix(@cockpit/deployment): Check if contracts deployed when connected to metamask
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>`).
2019-04-04 12:45:34 -04:00
Pascal Precht 4c3ec26fff uiux(@cockpit/explorer): render timestamp of transactions 2019-04-04 12:45:00 -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
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 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
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 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
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
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