Skip to content
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

Desktop metamask #5618

Draft
wants to merge 57 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
702d3ad
1.0.9
bunsenstraat Sep 26, 2024
df31283
Merge branch 'master' of https://github.com/ethereum/remix-project in…
bunsenstraat Oct 14, 2024
2cf3b5c
fix workspace name position
bunsenstraat Oct 31, 2024
623bfd3
git status fix
bunsenstraat Oct 31, 2024
d7cf54c
Merge pull request #5357 from ethereum/desktop-gitstatus
bunsenstraat Oct 31, 2024
bd5527c
Merge branch 'desktop-master' of https://github.com/ethereum/remix-pr…
bunsenstraat Dec 13, 2024
328eb89
Merge branch 'master' into desktop-master
bunsenstraat Dec 13, 2024
07515d9
desktop metamask
bunsenstraat Dec 15, 2024
8a32bf4
add tab to terminal
bunsenstraat Dec 18, 2024
89d7d39
Merge branch 'master' of https://github.com/ethereum/remix-project in…
bunsenstraat Dec 18, 2024
2cb247f
use plugin as connector
bunsenstraat Dec 22, 2024
e46bb7d
blockchain events
bunsenstraat Dec 23, 2024
1c1be87
focus on app after transaction
bunsenstraat Dec 30, 2024
ebd4f40
move to app state
bunsenstraat Jan 1, 2025
0f9a3ad
handle double connections
bunsenstraat Jan 1, 2025
5c2e700
fix sync accounts
bunsenstraat Jan 2, 2025
cf59bd9
handle response errors
bunsenstraat Jan 2, 2025
50ca839
handle disconnection
bunsenstraat Jan 2, 2025
9439ef7
focus event
bunsenstraat Jan 2, 2025
baa1a4c
start on random ports
bunsenstraat Jan 2, 2025
89e77b6
add logging
bunsenstraat Jan 2, 2025
5549011
use cbor for messaging
bunsenstraat Jan 7, 2025
9859468
Merge branch 'master' of https://github.com/ethereum/remix-project in…
bunsenstraat Jan 7, 2025
b04cc75
fix grid
bunsenstraat Jan 8, 2025
15d57f2
create component
bunsenstraat Jan 8, 2025
4dfee36
typing
bunsenstraat Jan 8, 2025
2cce63f
add filter
bunsenstraat Jan 8, 2025
c0c9fe7
add filter
bunsenstraat Jan 8, 2025
f7c801e
filter fn
bunsenstraat Jan 8, 2025
6fcecc3
refactor
bunsenstraat Jan 8, 2025
8b180b4
connection grid
bunsenstraat Jan 8, 2025
5dc62dd
hide panel
bunsenstraat Jan 8, 2025
f061075
trace events
bunsenstraat Jan 9, 2025
b059e84
debounce events
bunsenstraat Jan 9, 2025
3e2c01a
move UI
bunsenstraat Jan 9, 2025
78b649b
brave title
bunsenstraat Jan 9, 2025
a01da62
visuals
bunsenstraat Jan 9, 2025
3b0d487
Merge branch 'master' of https://github.com/ethereum/remix-project in…
bunsenstraat Jan 9, 2025
d85c7c5
clean up
bunsenstraat Jan 9, 2025
6c745d4
e2e
bunsenstraat Jan 9, 2025
0e01442
revert
bunsenstraat Jan 10, 2025
785793d
Merge branch 'master' of https://github.com/ethereum/remix-project in…
bunsenstraat Jan 10, 2025
95e9ea7
rm logs
bunsenstraat Jan 10, 2025
cfb6a9e
rm file
bunsenstraat Jan 10, 2025
fcb6aef
rm log
bunsenstraat Jan 10, 2025
af44bd7
revert
bunsenstraat Jan 10, 2025
916ac7f
revert changes
bunsenstraat Jan 10, 2025
0d04a3e
fix linting
bunsenstraat Jan 10, 2025
fab9ced
v icons refactor
bunsenstraat Jan 10, 2025
7cbe76a
clean up
bunsenstraat Jan 10, 2025
c4889a5
revert all
bunsenstraat Jan 10, 2025
d4e8c4f
refactor
bunsenstraat Jan 10, 2025
f934e46
rename
bunsenstraat Jan 10, 2025
e780a55
debugging
bunsenstraat Jan 13, 2025
1fed8e5
disable brave wallet
bunsenstraat Jan 14, 2025
8af12fe
add simple test
bunsenstraat Jan 14, 2025
35e27f5
test
bunsenstraat Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions apps/remix-ide/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ import { HardhatHandleDesktop } from './app/plugins/electron/hardhatPlugin'
import { circomPlugin } from './app/plugins/electron/circomElectronPlugin'
import { GitPlugin } from './app/plugins/git'
import { Matomo } from './app/plugins/matomo'
import { DesktopClient } from './app/plugins/desktop-client'
import { DesktopHost } from './app/plugins/electron/desktopHostPlugin'

import { TemplatesSelectionPlugin } from './app/plugins/templates-selection/templates-selection-plugin'

Expand Down Expand Up @@ -124,6 +126,8 @@ class AppComponent {
})
this.appManager = new RemixAppManager({})
this.queryParams = new QueryParams()
this.params = this.queryParams.get()
this.desktopClientMode = this.params && this.params.activate && this.params.activate.split(',').includes('desktopClient')
this._components = {}
// setup storage
const configStorage = new Storage('config-v0.8:')
Expand Down Expand Up @@ -425,6 +429,12 @@ class AppComponent {
this.engine.register([appUpdater])
const remixAIDesktop = new remixAIDesktopPlugin()
this.engine.register([remixAIDesktop])
const desktopHost = new DesktopHost()
this.engine.register([desktopHost])
} else{
//---- desktop client
const desktopClient = new DesktopClient(blockchain)
this.engine.register([desktopClient])
}

const compilerloader = isElectron() ? new compilerLoaderPluginDesktop() : new compilerLoaderPlugin()
Expand Down Expand Up @@ -513,8 +523,7 @@ class AppComponent {
}

async activate() {
const queryParams = new QueryParams()
const params = queryParams.get()


try {
this.engine.register(await this.appManager.registeredPlugins())
Expand Down Expand Up @@ -591,13 +600,13 @@ class AppComponent {
.activatePlugin(this.workspace)
.then(async () => {
try {
if (params.deactivate) {
await this.appManager.deactivatePlugin(params.deactivate.split(','))
if (this.params.deactivate) {
await this.appManager.deactivatePlugin(this.params.deactivate.split(','))
}
} catch (e) {
console.log(e)
}
if (params.code && (!params.activate || params.activate.split(',').includes('solidity'))) {
if (this.params.code && (!this.params.activate || this.params.activate.split(',').includes('solidity'))) {
// if code is given in url we focus on solidity plugin
this.menuicons.select('solidity')
} else {
Expand All @@ -609,17 +618,17 @@ class AppComponent {
}
}

if (params.call) {
const callDetails = params.call.split('//')
if (this.params.call) {
const callDetails = this.params.call.split('//')
if (callDetails.length > 1) {
this.appManager.call('notification', 'toast', `initiating ${callDetails[0]} and calling "${callDetails[1]}" ...`)
// @todo(remove the timeout when activatePlugin is on 0.3.0)
await this.appManager.call(...callDetails).catch(console.error)
}
}

if (params.calls) {
const calls = params.calls.split('///')
if (this.params.calls) {
const calls = this.params.calls.split('///')

// call all functions in the list, one after the other
for (const call of calls) {
Expand Down Expand Up @@ -660,6 +669,10 @@ class AppComponent {

// activate solidity plugin
this.appManager.activatePlugin(['solidity', 'udapp', 'deploy-libraries', 'link-libraries', 'openzeppelin-proxy', 'scriptRunnerBridge'])

if(isElectron()){
this.appManager.activatePlugin(['desktopHost'])
}
}
}

Expand Down
115 changes: 115 additions & 0 deletions apps/remix-ide/src/app/components/DesktopClientUI.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import React, { useContext, useEffect } from 'react'
import { AppContext, appActionTypes } from '@remix-ui/app'
import { Provider } from '../../blockchain/blockchain'
import { providerLogos } from '../udapp/run-tab'
import { desktopConnection } from '@remix-api'
import { set } from 'lodash'

interface DesktopClientState {
connected: desktopConnection
providers: Provider[]
disableconnect: boolean
currentContext: string
}

const DesktopClientUI = (props: DesktopClientState & { openDesktopApp: () => void } & { onConnect: (providerName: Provider) => void }) => {
const appContext = useContext(AppContext)
const { connected, providers, onConnect, disableconnect, currentContext } = props
const [title, setTitle] = React.useState('Connecting...')
const [disabled, setDisabled] = React.useState(false)
const [hasMetamask, setHasMetamask] = React.useState(false)
const [hasBrave, setHasBrave] = React.useState(false)

useEffect(() => {
console.log('connected', props.connected)
appContext.appStateDispatch({
type: appActionTypes.setConnectedToDesktop,
payload: props.connected,
})
appContext.appStateDispatch({
type: appActionTypes.setShowPopupPanel,
payload: false,
})
}, [props.connected])

useEffect(() => {
console.log('providers', props.providers)
const metamaskProvider = providers.find((provider) => provider.name.toLowerCase().includes('metamask'))
const braveProvider = providers.find((provider) => provider.name.toLowerCase().includes('brave'))
setHasMetamask(!!metamaskProvider)
setHasBrave(!!braveProvider)

}, [providers])

useEffect(() => {
if (hasMetamask) {
setTitle('Connect to MetaMask')
setDisabled(false)
} else if (hasBrave && !hasMetamask) {
setTitle('Brave Wallet is not supported')
setDisabled(true)
} else {
setTitle('Connecting...')
}
},[hasMetamask, hasBrave])

if (disabled) {
return (
<div>
<div className="d-flex p-4 bg-light flex-column">
<h3>{title}</h3>
<p>
The Brave Wallet is not supported at this time.
</p>
</div>
</div>
)
}

return (
<div>
<div className="d-flex p-4 bg-light flex-column">
<h3>{title}</h3>
<p>
1. Connect to your favorite Ethereum wallet provider
<br></br>2. Go back to the Remix Desktop application
<br></br>3. Deploy using 'MetaMask Wallet'
{hasBrave && <div className='text-warning'>
Note: Brave Wallet is not supported.
</div>}
</p>
</div>

<div>
<div className="row">
{providers && providers.length > 0 ? (
providers
.filter((provider) => provider.isInjected && provider.name.toLocaleLowerCase().includes('metamask'))
.map((provider, index) => (
<div key={index} className="col-md-4 mb-4">
<div className="provider-item card h-100">
<div className="card-body d-flex flex-column align-items-center">
<div className="d-flex mb-2">{providerLogos[provider.name] && providerLogos[provider.name].map((logo, index) => <img key={index} src={logo} style={{ width: '2rem', height: '2rem', marginRight: '0.5rem' }} />)}</div>
<h5 className="card-title">{provider.displayName}</h5>
<p className="card-text">{provider.description}</p>
<button data-id={`connection-btn-${provider.name}`} disabled={disableconnect || currentContext === provider.name} className="btn btn-primary mt-auto" onClick={() => onConnect(provider)}>
{disableconnect ? 'please wait ...' : currentContext === provider.name ? 'Connected' : 'Connect'}
</button>
</div>
</div>
</div>
))
) : (
<div className="col-12">
<div className="alert alert-warning" role="alert">
No injected providers found. Please install MetaMask or another browser wallet.
</div>
</div>
)}
</div>
</div>
</div>
)
}

export default DesktopClientUI
10 changes: 8 additions & 2 deletions apps/remix-ide/src/app/components/status-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { RemixUIStatusBar } from '@remix-ui/statusbar'
import { FilePanelType } from '@remix-ui/workspace'
import { VerticalIcons } from './vertical-icons'
import { CustomRemixApi } from '@remix-api'
import { AppAction } from '@remix-ui/app'

const statusBarProfile: PluginProfile = {
name: 'statusBar',
Expand All @@ -22,7 +23,8 @@ export class StatusBar extends Plugin<any, CustomRemixApi> implements StatusBarI
events: EventEmitter
filePanelPlugin: FilePanelType
verticalIcons: VerticalIcons
dispatch: React.Dispatch<any> = () => {}
dispatch: React.Dispatch<any> = () => { }
appStateDispatch: React.Dispatch<AppAction> = () => { }
currentWorkspaceName: string = ''
isGitRepo: boolean = false
isAiActive: boolean = false
Expand Down Expand Up @@ -86,6 +88,10 @@ export class StatusBar extends Plugin<any, CustomRemixApi> implements StatusBarI
this.dispatch = dispatch
}

setAppStateDispatch(appStateDispatch: React.Dispatch<AppAction>) {
this.appStateDispatch = appStateDispatch
}

renderComponent() {
this.dispatch({
plugins: this,
Expand All @@ -99,7 +105,7 @@ export class StatusBar extends Plugin<any, CustomRemixApi> implements StatusBarI
render() {
return (
<div data-id="status-bar-container">
<PluginViewWrapper plugin={this} />
<PluginViewWrapper useAppContext={true} plugin={this} />
</div>
)
}
Expand Down
6 changes: 5 additions & 1 deletion apps/remix-ide/src/app/panels/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { QueryParams } from '@remix-project/remix-lib'
const profile: Profile = {
name: 'layout',
description: 'layout',
methods: ['minimize', 'maximiseSidePanel', 'resetSidePanel', 'maximizeTerminal', 'maximisePinnedPanel', 'resetPinnedPanel']
methods: ['minimize', 'minimizeSidePanel', 'maximiseSidePanel', 'resetSidePanel', 'maximizeTerminal', 'maximisePinnedPanel', 'resetPinnedPanel']
}

interface panelState {
Expand Down Expand Up @@ -141,6 +141,10 @@ export class Layout extends Plugin {
this.emit('change', this.panels)
}

async minimizeSidePanel () {
this.event.emit('minimizesidepanel')
}

async maximiseSidePanel () {
const current = await this.call('sidePanel', 'currentFocus')
this.maximized[current] = true
Expand Down
Loading
Loading