Skip to content

Electron+Browser Hybrid MVP

Ghost User requested to merge am-electron-mvp into next

MVP to have UI + dapps running in both Electron and browser. Still requires parity to serve 127.0.0.1:8180.

Usage

Important: Build parity first with cargo build --release --no-default-features --features ui with a correct ref to this branch

  • In dev: npm start in one terminal (to have :3000), and npm run electron:dev in another (spawns an Electron instance that listens to :3000)
  • In prod: npm run electron, builds the app and spawns an Electron instance that loads 127.0.0.1:8180.

How it works

  • In Dapp/dapp.js, we check if the shell is launched in browser or electron environment.
    • If browser, then we create an iframe to launch dapps. Communication between shell-dapp is done via Api.Provider.PostMessage.
    • If electron, then we create a webview to launch dapps. Communication between shell-dapp is done via Api.Provider.Ipc.
  • inject.js
    • In electron, the webview injects itself the inject.js, so there would be no need for parity to inject this script when serving HTML :8545, like currently done.
    • In browser, no clean way to inject some js into an iframe. Currently the dapp takes from :8545. This part is still to be discussed, i.e.: Who should inject inject.js into dapps?

Known bugs

  • Functionality-wise: just played around, everything seems to be working fine.
  • Cmd+V for pasting doesn't work on Mac (Electron issue)
  • Code-wise: in v1, every v1: starting Tokens Provider... seems to be called twice. Minor, since not blocking any functionality.

Notes

The next branch currently is on par with master. We can add PRs on that branch to always have a functional electron-based UI, ideally shippable for 1.10.

Merge request reports