Skip to content

Commit 784dfc9

Browse files
authored
Merge branch 'master' into starkNet
2 parents d106be6 + a76a14c commit 784dfc9

File tree

26 files changed

+269
-172
lines changed

26 files changed

+269
-172
lines changed

apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function App () {
3333

3434
useEffect(() => {
3535
client.onload(async () => {
36-
const customProfiles = ['menuicons', 'tabs', 'solidityUnitTesting', 'hardhat-provider']
36+
const customProfiles = ['menuicons', 'tabs', 'solidityUnitTesting', 'hardhat-provider', 'notification']
3737

3838
client.testCommand = async (data: any) => {
3939
console.log(data)

apps/remix-ide-e2e/src/tests/ballot.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ module.exports = {
8484
.openFile('Untitled.sol')
8585
.clickLaunchIcon('udapp')
8686
.click('*[data-id="settingsWeb3Mode"]')
87-
.waitForElementPresent('[data-id="udappNotify-modal-footer-ok-react"]')
87+
.waitForElementPresent('[data-id="envNotification-modal-footer-ok-react"]')
8888
.execute(function () {
89-
const modal = document.querySelector('[data-id="udappNotify-modal-footer-ok-react"]') as any
89+
const modal = document.querySelector('[data-id="envNotification-modal-footer-ok-react"]') as any
9090

9191
modal.click()
9292
})

apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ module.exports = {
7979
.openFile('Untitled.sol')
8080
.clickLaunchIcon('udapp')
8181
.click('*[data-id="settingsWeb3Mode"]')
82-
.waitForElementPresent('[data-id="udappNotify-modal-footer-ok-react"]')
82+
.waitForElementPresent('[data-id="envNotification-modal-footer-ok-react"]')
8383
.execute(function () {
84-
const modal = document.querySelector('[data-id="udappNotify-modal-footer-ok-react"]') as any
84+
const modal = document.querySelector('[data-id="envNotification-modal-footer-ok-react"]') as any
8585

8686
modal.click()
8787
})

apps/remix-ide-e2e/src/tests/plugin_api.ts

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,16 @@ const clearPayLoad = async (browser: NightwatchBrowser) => {
6464
})
6565
}
6666

67-
const clickButton = async (browser: NightwatchBrowser, buttonText: string) => {
67+
const clickButton = async (browser: NightwatchBrowser, buttonText: string, waitResult: boolean = true) => {
6868
return new Promise((resolve) => {
6969
browser.useXpath().waitForElementVisible(`//*[@data-id='${buttonText}']`).pause(100)
7070
.click(`//*[@data-id='${buttonText}']`, async () => {
7171
await checkForAcceptAndRemember(browser)
72-
browser.waitForElementContainsText('//*[@id="callStatus"]', 'stop').perform(() => resolve(true))
72+
if (waitResult) {
73+
browser.waitForElementContainsText('//*[@id="callStatus"]', 'stop').perform(() => resolve(true))
74+
} else {
75+
resolve(true)
76+
}
7377
})
7478
})
7579
}
@@ -103,7 +107,7 @@ const checkForAcceptAndRemember = async function (browser: NightwatchBrowser) {
103107
* @return {Promise}
104108
*/
105109

106-
const clickAndCheckLog = async (browser: NightwatchBrowser, buttonText: string, methodResult: any, eventResult: any, payload: any) => {
110+
const clickAndCheckLog = async (browser: NightwatchBrowser, buttonText: string, methodResult: any, eventResult: any, payload: any, waitResult: boolean = true) => {
107111
if (payload) {
108112
await setPayload(browser, payload)
109113
} else {
@@ -112,10 +116,14 @@ const clickAndCheckLog = async (browser: NightwatchBrowser, buttonText: string,
112116
if (methodResult && typeof methodResult !== 'string') { methodResult = JSON.stringify(methodResult) }
113117
if (eventResult && typeof eventResult !== 'string') { eventResult = JSON.stringify(eventResult) }
114118
if (buttonText) {
115-
await clickButton(browser, buttonText)
119+
await clickButton(browser, buttonText, waitResult)
120+
}
121+
if (methodResult) {
122+
await debugValues(browser, 'methods', methodResult)
123+
}
124+
if (eventResult) {
125+
await debugValues(browser, 'events', eventResult)
116126
}
117-
await debugValues(browser, 'methods', methodResult)
118-
await debugValues(browser, 'events', eventResult)
119127
}
120128

121129
const assertPluginIsActive = function (browser: NightwatchBrowser, id: string, shouldBeVisible: boolean) {
@@ -364,5 +372,72 @@ module.exports = {
364372
const result = '{"jsonrpc":"2.0","result":true,"id":9999}'
365373
await clickAndCheckLog(browser, 'hardhat-provider:sendAsync', result, null, request)
366374
})
375+
},
376+
377+
// MODAL
378+
379+
'Should open 2 alert in a row and trigger 2 toaster in between #group9': function (browser: NightwatchBrowser) {
380+
browser
381+
.frameParent()
382+
.useCss()
383+
.addFile('test_modal.js', { content: testModalToasterApi })
384+
.executeScript('remix.execute(\'test_modal.js\')')
385+
.clickLaunchIcon('localPlugin')
386+
.useXpath()
387+
// @ts-ignore
388+
.frame(0)
389+
.perform(async () => {
390+
await clickAndCheckLog(browser, 'notification:toast', null, null, 'message toast from local plugin', false) // create a toast on behalf of the localplugin
391+
await clickAndCheckLog(browser, 'notification:alert', null, null, { message: 'message from local plugin', id: 'test_id_1_local_plugin' }, false) // create an alert on behalf of the localplugin
392+
})
393+
.frameParent()
394+
.useCss()
395+
// check the local plugin notifications
396+
.waitForElementVisible('*[data-id="test_id_1_local_pluginModalDialogModalBody-react"]')
397+
.assert.containsText('*[data-id="test_id_1_local_pluginModalDialogModalBody-react"]', 'message from local plugin')
398+
.modalFooterOKClick('test_id_1_local_plugin')
399+
// check the script runner notifications
400+
.waitForElementVisible('*[data-id="test_id_1_ModalDialogModalBody-react"]')
401+
.assert.containsText('*[data-id="test_id_1_ModalDialogModalBody-react"]', 'message 1')
402+
.modalFooterOKClick('test_id_1_')
403+
.waitForElementVisible('*[data-id="test_id_2_ModalDialogModalBody-react"]')
404+
.assert.containsText('*[data-id="test_id_2_ModalDialogModalBody-react"]', 'message 2')
405+
.modalFooterOKClick('test_id_2_')
406+
.waitForElementVisible('*[data-id="test_id_3_ModalDialogModalBody-react"]')
407+
.modalFooterOKClick('test_id_3_')
408+
.journalLastChildIncludes('default value... ') // check the return value of the prompt
409+
// check the toasters
410+
.waitForElementVisible('*[data-shared="tooltipPopup"]')
411+
.waitForElementContainsText('*[data-shared="tooltipPopup"]', 'message toast from local plugin')
412+
.waitForElementContainsText('*[data-shared="tooltipPopup"]', 'I am a toast')
413+
.waitForElementContainsText('*[data-shared="tooltipPopup"]', 'I am a re-toast')
367414
}
368415
}
416+
417+
const testModalToasterApi = `
418+
// Right click on the script name and hit "Run" to execute
419+
(async () => {
420+
try {
421+
setTimeout(async () => {
422+
console.log('test .. ')
423+
remix.call('notification', 'alert', { message: 'message 1', id: 'test_id_1_' })
424+
remix.call('notification', 'toast', 'I am a toast')
425+
remix.call('notification', 'toast', 'I am a re-toast')
426+
remix.call('notification', 'alert', { message: 'message 2', id: 'test_id_2_' })
427+
428+
const modalContent = {
429+
id: 'test_id_3_',
430+
title: 'test with input title',
431+
message: 'test with input content',
432+
modalType: 'prompt',
433+
okLabel: 'OK',
434+
cancelLabel: 'Cancel',
435+
defaultValue: 'default value... '
436+
}
437+
const result = await remix.call('notification', 'modal', modalContent)
438+
console.log(result)
439+
}, 500)
440+
} catch (e) {
441+
console.log(e.message)
442+
}
443+
})() `

apps/remix-ide-e2e/src/tests/terminal.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = {
5151
.click('*[data-id="terminalClearConsole"]') // clear the terminal
5252
.clickLaunchIcon('udapp')
5353
.click('*[data-id="settingsWeb3Mode"]')
54-
.modalFooterOKClick('udappNotify')
54+
.modalFooterOKClick('envNotification')
5555
.executeScript('web3.eth.getAccounts()')
5656
.waitForElementContainsText('*[data-id="terminalJournal"]', '["', 60000) // we check if an array is present, don't need to check for the content
5757
.waitForElementContainsText('*[data-id="terminalJournal"]', '"]', 60000)

apps/remix-ide/src/app.js

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
'use strict'
22
import { RunTab, makeUdapp } from './app/udapp'
3-
import { RemixEngine } from './remixEngine'
43
import { RemixAppManager } from './remixAppManager'
5-
import { ThemeModule } from './app/tabs/theme-module'
6-
import { NetworkModule } from './app/tabs/network-module'
7-
import { Web3ProviderModule } from './app/tabs/web3-provider'
8-
import { SidePanel } from './app/components/side-panel'
9-
import { HiddenPanel } from './app/components/hidden-panel'
10-
import { VerticalIcons } from './app/components/vertical-icons'
11-
import { LandingPage } from './app/ui/landing-page/landing-page'
12-
import { MainPanel } from './app/components/main-panel'
13-
import { PermissionHandlerPlugin } from './app/plugins/permission-handler-plugin'
144

155
import { WalkthroughService } from './walkthroughService'
166

@@ -19,7 +9,7 @@ import { OffsetToLineColumnConverter, CompilerMetadata, CompilerArtefacts, Fetch
199
import Registry from './app/state/registry'
2010
import { ConfigPlugin } from './app/plugins/config'
2111
import { Layout } from './app/panels/layout'
22-
import { ModalPlugin } from './app/plugins/modal'
12+
import { NotificationPlugin } from './app/plugins/notification'
2313
import { Blockchain } from './blockchain/blockchain.js'
2414
import { HardhatProvider } from './app/tabs/hardhat-provider'
2515

@@ -95,7 +85,7 @@ class AppComponent {
9585
const pluginLoader = self.appManager.pluginLoader
9686
self.panels = {}
9787
self.workspace = pluginLoader.get()
98-
self.engine = new RemixEngine()
88+
self.engine = new (await import('./remixEngine')).RemixEngine
9989
self.engine.register(appManager)
10090

10191
const matomoDomains = {
@@ -126,7 +116,7 @@ class AppComponent {
126116
// ----------------- gist service ---------------------------------
127117
self.gistHandler = new GistHandler()
128118
// ----------------- theme service ---------------------------------
129-
self.themeModule = new ThemeModule()
119+
self.themeModule = new (await import('./app/tabs/theme-module')).ThemeModule()
130120
Registry.getInstance().put({ api: self.themeModule, name: 'themeModule' })
131121

132122
// ----------------- editor service ----------------------------
@@ -159,9 +149,9 @@ class AppComponent {
159149
// service which fetch contract artifacts from sourve-verify, put artifacts in remix and compile it
160150
const fetchAndCompile = new FetchAndCompile()
161151
// ----------------- network service (resolve network id / name) -----
162-
const networkModule = new NetworkModule(blockchain)
152+
const networkModule = new (await import('./app/tabs/network-module')).NetworkModule(blockchain)
163153
// ----------------- represent the current selected web3 provider ----
164-
const web3Provider = new Web3ProviderModule(blockchain)
154+
const web3Provider = new (await import('./app/tabs/web3-provider')).Web3ProviderModule(blockchain)
165155
const hardhatProvider = new HardhatProvider(blockchain)
166156
// ----------------- convert offset to line/column service -----------
167157
const offsetToLineColumnConverter = new OffsetToLineColumnConverter()
@@ -187,17 +177,17 @@ class AppComponent {
187177
)
188178
const contextualListener = new EditorContextListener()
189179

190-
self.modal = new ModalPlugin()
180+
self.notification = new NotificationPlugin()
191181

192182
const configPlugin = new ConfigPlugin()
193183
self.layout = new Layout()
194184

195-
const permissionHandler = new PermissionHandlerPlugin()
185+
const permissionHandler = new (await import('./app/plugins/permission-handler-plugin')).PermissionHandlerPlugin()
196186

197187
self.engine.register([
198188
permissionHandler,
199189
self.layout,
200-
self.modal,
190+
self.notification,
201191
self.gistHandler,
202192
configPlugin,
203193
blockchain,
@@ -219,22 +209,22 @@ class AppComponent {
219209
])
220210

221211
// LAYOUT & SYSTEM VIEWS
222-
const appPanel = new MainPanel()
212+
const appPanel = new (await import('./app/components/main-panel')).MainPanel()
223213
Registry.getInstance().put({ api: self.mainview, name: 'mainview' })
224214
const tabProxy = new TabProxy(fileManager, editor)
225215
self.engine.register([appPanel, tabProxy])
226216

227217
// those views depend on app_manager
228-
self.menuicons = new VerticalIcons()
229-
self.sidePanel = new SidePanel()
230-
self.hiddenPanel = new HiddenPanel()
218+
self.menuicons = new (await import('./app/components/vertical-icons')).VerticalIcons()
219+
self.sidePanel = new (await import('./app/components/side-panel')).SidePanel()
220+
self.hiddenPanel = new (await import('./app/components/hidden-panel')).HiddenPanel()
231221

232222
const pluginManagerComponent = new PluginManagerComponent(
233223
appManager,
234224
self.engine
235225
)
236226
const filePanel = new FilePanel(appManager)
237-
const landingPage = new LandingPage(
227+
const landingPage = new (await import('./app/ui/landing-page/landing-page')).LandingPage(
238228
appManager,
239229
self.menuicons,
240230
fileManager,

apps/remix-ide/src/app/plugins/modal.tsx renamed to apps/remix-ide/src/app/plugins/notification.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { AppModal } from '@remix-ui/app'
44
import { AlertModal } from 'libs/remix-ui/app/src/lib/remix-app/interface'
55
import { dispatchModalInterface } from 'libs/remix-ui/app/src/lib/remix-app/context/context'
66

7-
interface IModalApi {
7+
interface INotificationApi {
88
events: StatusEvents,
99
methods: {
1010
modal: (args: AppModal) => void
@@ -13,14 +13,14 @@ interface IModalApi {
1313
}
1414
}
1515

16-
const profile:LibraryProfile<IModalApi> = {
16+
const profile:LibraryProfile<INotificationApi> = {
1717
name: 'notification',
1818
displayName: 'Notification',
1919
description: 'Displays notifications',
2020
methods: ['modal', 'alert', 'toast']
2121
}
2222

23-
export class ModalPlugin extends Plugin implements MethodApi<IModalApi> {
23+
export class NotificationPlugin extends Plugin implements MethodApi<INotificationApi> {
2424
dispatcher: dispatchModalInterface
2525
constructor () {
2626
super(profile)
@@ -38,7 +38,7 @@ export class ModalPlugin extends Plugin implements MethodApi<IModalApi> {
3838
return this.dispatcher.alert(args)
3939
}
4040

41-
async toast (message: string) {
41+
async toast (message: string | JSX.Element) {
4242
this.dispatcher.toast(message)
4343
}
4444
}

apps/remix-ide/src/index.tsx

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
11
// eslint-disable-next-line no-use-before-define
22
import React from 'react'
3-
import ReactDOM from 'react-dom'
4-
import AppComponent from './app'
3+
import { render } from 'react-dom'
54
// eslint-disable-next-line no-unused-vars
65
import { RemixApp } from '@remix-ui/app'
76

8-
const appComponent = new AppComponent()
9-
appComponent.run()
7+
(function () {
8+
render(
9+
<React.StrictMode>
10+
<div style={{ display: 'block' }} className='centered'>
11+
<svg id="Ebene_2" data-name="Ebene 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 105 100">
12+
<path d="M91.84,35a.09.09,0,0,1-.1-.07,41,41,0,0,0-79.48,0,.09.09,0,0,1-.1.07C9.45,35,1,35.35,1,42.53c0,8.56,1,16,6,20.32,2.16,1.85,5.81,2.3,9.27,2.22a44.4,44.4,0,0,0,6.45-.68.09.09,0,0,0,.06-.15A34.81,34.81,0,0,1,17,45c0-.1,0-.21,0-.31a35,35,0,0,1,70,0c0,.1,0,.21,0,.31a34.81,34.81,0,0,1-5.78,19.24.09.09,0,0,0,.06.15,44.4,44.4,0,0,0,6.45.68c3.46.08,7.11-.37,9.27-2.22,5-4.27,6-11.76,6-20.32C103,35.35,94.55,35,91.84,35Z"/>
13+
<path d="M52,74,25.4,65.13a.1.1,0,0,0-.1.17L51.93,91.93a.1.1,0,0,0,.14,0L78.7,65.3a.1.1,0,0,0-.1-.17L52,74A.06.06,0,0,1,52,74Z"/>
14+
<path d="M75.68,46.9,82,45a.09.09,0,0,0,.08-.09,29.91,29.91,0,0,0-.87-6.94.11.11,0,0,0-.09-.08l-6.43-.58a.1.1,0,0,1-.06-.18l4.78-4.18a.13.13,0,0,0,0-.12,30.19,30.19,0,0,0-3.65-6.07.09.09,0,0,0-.11,0l-5.91,2a.1.1,0,0,1-.12-.14L72.19,23a.11.11,0,0,0,0-.12,29.86,29.86,0,0,0-5.84-4.13.09.09,0,0,0-.11,0l-4.47,4.13a.1.1,0,0,1-.17-.07l.09-6a.1.1,0,0,0-.07-.1,30.54,30.54,0,0,0-7-1.47.1.1,0,0,0-.1.07l-2.38,5.54a.1.1,0,0,1-.18,0l-2.37-5.54a.11.11,0,0,0-.11-.06,30,30,0,0,0-7,1.48.12.12,0,0,0-.07.1l.08,6.05a.09.09,0,0,1-.16.07L37.8,18.76a.11.11,0,0,0-.12,0,29.75,29.75,0,0,0-5.83,4.13.11.11,0,0,0,0,.12l2.59,5.6a.11.11,0,0,1-.13.14l-5.9-2a.11.11,0,0,0-.12,0,30.23,30.23,0,0,0-3.62,6.08.11.11,0,0,0,0,.12l4.79,4.19a.1.1,0,0,1-.06.17L23,37.91a.1.1,0,0,0-.09.07A29.9,29.9,0,0,0,22,44.92a.1.1,0,0,0,.07.1L28.4,47a.1.1,0,0,1,0,.18l-5.84,3.26a.16.16,0,0,0,0,.11,30.17,30.17,0,0,0,2.1,6.76c.32.71.67,1.4,1,2.08a.1.1,0,0,0,.06,0L52,68.16H52l26.34-8.78a.1.1,0,0,0,.06-.05,30.48,30.48,0,0,0,3.11-8.88.1.1,0,0,0-.05-.11l-5.83-3.26A.1.1,0,0,1,75.68,46.9Z"/>
15+
</svg>
16+
<div className="info-secondary splash">
17+
REMIX IDE
18+
</div>
19+
</div>
20+
</React.StrictMode>,
21+
document.getElementById('root')
22+
)
23+
})()
1024

11-
ReactDOM.render(
12-
<React.StrictMode>
13-
<RemixApp app={appComponent}></RemixApp>
14-
</React.StrictMode>,
15-
document.getElementById('root')
16-
)
25+
import ('./app').then((AppComponent) => {
26+
const appComponent = new AppComponent.default()
27+
appComponent.run().then(() => {
28+
render(
29+
<React.StrictMode>
30+
<RemixApp app={appComponent} />
31+
</React.StrictMode>,
32+
document.getElementById('root')
33+
)
34+
})
35+
}).catch(err => {
36+
console.log('Error on loading Remix:', err)
37+
})

apps/remix-ide/src/remixEngine.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export class RemixEngine extends Engine {
1414
if (name === 'slither') return { queueTimeout: 60000 * 4 } // Requires when a solc version is installed
1515
if (name === 'hardhat') return { queueTimeout: 60000 * 4 }
1616
if (name === 'localPlugin') return { queueTimeout: 60000 * 4 }
17+
if (name === 'notification') return { queueTimeout: 60000 * 4 }
1718
return { queueTimeout: 10000 }
1819
}
1920

apps/remix-ide/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
"jsx": "react",
55
"allowJs": true,
66
"esModuleInterop": true,
7-
"resolveJsonModule": true,
87
"allowSyntheticDefaultImports": true,
98
"types": ["node", "jest"],
10-
"module": "es6",
119
"resolveJsonModule": true
1210
},
1311
"files": [

0 commit comments

Comments
 (0)