New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Desktop UI #78
Add Desktop UI #78
Conversation
app/desktop-ui.html
Outdated
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no"> | ||
<title>MetaMask</title> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add "MetaMask Desktop" here, but probably It will be replaced by the UI Pairing flow ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really good to see it's working using MM build scripts 🥇 .
Just run lint:fix
and 👍
d56be00
to
fef377a
Compare
7b47b56
to
1ff1514
Compare
9cf3244
to
6d6daff
Compare
ceb1bf7
to
7ac9ce0
Compare
Co-authored-by: Matthew Walsh <matthew.walsh@consensys.net>
7ac9ce0
to
ea4f216
Compare
app/scripts/desktop.js
Outdated
@@ -0,0 +1,9 @@ | |||
import launchDesktopUi from '../../ui/desktop'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it explicit that this is running in a renderer process and not part of the background, shall we call this something like ui.js
and move it inside the desktop
directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, I've tried to solve it quickly, but if we move that file into a different folder, we need to make many modifications to build scripts.
For example, changing the desktop entry point in standartEntryPoints
(development/build/scripts.js#232
) to desktop/ui
causes different bundler requirements (bundler getting confused about folders, e.g lavamoat options development/build/scripts.js#557
).
It's not the best but rather than moving the file, I've renamed it to desktop-ui.js
. Shall we create a task for that and have a look later on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, changing the structure will complicate the build scripts. I'm in favour to create a task in the refactor section to tackle it later.
@@ -175,27 +175,31 @@ class DesktopApp extends EventEmitter { | |||
|
|||
private async createStatusWindow() { | |||
const statusWindow = new BrowserWindow({ | |||
width: 800, | |||
height: 400, | |||
width: process.env.METAMASK_DEBUG ? 1800 : 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a little big to load with as it hits the bounds of my 16" laptop at the default zoom level. Maybe start small but let the user maximise or persist after resize?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -175,27 +175,31 @@ class DesktopApp extends EventEmitter { | |||
|
|||
private async createStatusWindow() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we change all these references for clarity and maybe refer to this as the main window?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
webPreferences: { | ||
preload: path.resolve(__dirname, './status-preload.js'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether we ultimately use a preload script or not, we can delete this file and any old logic if not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added back this line to use version and other use cases from status-preload.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
2cd93e9
to
f01041e
Compare
Socket Security Report👍 No new dependency issues detected in pull request Socket.dev scan summary
Bot CommandsTo ignore an alert, reply with a comment starting with Powered by socket.dev |
1b5aee0
to
5cd81e8
Compare
development/build/static.js
Outdated
@@ -46,7 +47,7 @@ module.exports = function createStaticAssetTasks({ | |||
composeSeries( | |||
...copyTargetsProd.map((target) => { | |||
return async function copyStaticAssets() { | |||
await performCopy(target); | |||
await performCopy(target, includeDesktopUi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to add includeDesktopUi
.. it is already available in the higher scope. Also that method signature only has 1 arg 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it's been forgotten one :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -13,12 +13,13 @@ | |||
"start": "yarn build:dev dev --apply-lavamoat=false", | |||
"build:desktop": "./development/build-desktop.sh", | |||
"build:desktop:mv3": "ENABLE_MV3=true ./development/build-desktop.sh", | |||
"build:desktop:extension": "DESKTOP=EXTENSION yarn start --build-type flask", | |||
"build:desktop:extension": "DESKTOP=EXTENSION yarn start --build-type flask --include-desktop-ui true", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should split this.. Currently this will generate the bundle for the extension and the desktop app ui. Those are 2 different things and should be dealt separately (even if the bundle process is the same).
IMO it would make more sense if the build:desktop
would actually generate both the main
and renderer
process "bundles" (as both are part of the desktop app)
b1bf0cb
to
9eebc14
Compare
Important Note: This PR is going to get merged intoinclude-desktop-ui-builder
PR (already approved), then I will mergeinclude-desktop-ui-builder
intomain-desktop
How to run it locally?
No changes in the mmd start scripts. Follow the steps on
app/scripts/desktop/Readme.md
Important parts of the MMD-UI
Locales
Most of the code(i18nProvider, getMessage, translate function etc.) was copied from MM with few changes. In the long run, it would be more maintainable for us to have separated locales; hence I've put the MMD locales in a separate folder.
State Management
I wanted to keep the same tooling as the MM, so I kept Redux.
I believe we will need some data persistence in the MMD (E.g desktop app settings). For that purpose I've used redux-persist with electron-store
Styling
To use MM components, we are injecting the monolith CSS of MM. (See
app/desktop-ui.html
)It's not ideal, but good to go for the beginning. Since we import MM css file, I've added
mmd.scss
to the MM index scss so we create and use our styles underdesktop-ui
.Communication between Renderer and Main process
It's worth mentioning; we are registering listeners in the
desktop-ui/index.js
(E.gregisterUpdatePairStatus
) if we need that state in the higher scope.And for the other way; we invoke a message from the renderer (E.g
desktop-ui/pages/pair/pair.component.js
seehandleOTPChange
)Known issues
window.require('electron')
There are weird bundling issues if we try to import things from
electron
package.To reproduce: Find & replace
const { ipcRenderer } = window.require('electron');
toimport { ipcRenderer } from 'electron'
Flaky active connection state
The state communication between MMD and MM is getting improved by Vinicius PR, so be aware if you see some discrepancies through your local tests
I've added
Temporary Pair Page Link
in the deactivated state so you can easily navigate the pair page if needed.No message is sent back to MMD if the user disconnects from MM
We will have a look at this issue soon.
OTP component
Not an issue but worth mentioning. For the sake of moving fast, I've used a very basic(0 dependency) package to handle OTP input. We can create our own if we need it in the future.
Todos