From b3769a82c2afdbc1b2393f21ebeb667da5057599 Mon Sep 17 00:00:00 2001
From: aniket-engg
Date: Thu, 6 Jan 2022 18:12:17 +0530
Subject: [PATCH 01/28] local compiler should be loaded without worker
---
.../solidity-compiler/src/lib/compiler-container.tsx | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
index eabccbd8a8..8f53164da5 100644
--- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
+++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
@@ -356,12 +356,13 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
return console.log('loading ' + selectedVersion + ' not allowed, version should start with "soljson"')
}
}
-
// Workers cannot load js on "file:"-URLs and we get a
// "Uncaught RangeError: Maximum call stack size exceeded" error on Chromium,
// resort to non-worker version in that case.
- if (selectedVersion === 'builtin') selectedVersion = state.defaultVersion
- if (selectedVersion !== 'builtin' && canUseWorker(selectedVersion)) {
+ if (selectedVersion === 'builtin') {
+ selectedVersion = state.defaultVersion
+ compileTabLogic.compiler.loadVersion(false, url)
+ } else if (canUseWorker(selectedVersion)) {
compileTabLogic.compiler.loadVersion(true, url)
} else {
compileTabLogic.compiler.loadVersion(false, url)
From f089c044ce71851017f0c3bc32f94fa63613b89d Mon Sep 17 00:00:00 2001
From: David Disu
Date: Fri, 7 Jan 2022 06:34:57 +0100
Subject: [PATCH 02/28] Reset udapp on workspace change
---
.../remix-ui/run-tab/src/lib/actions/index.ts | 56 +++++++++++--------
.../run-tab/src/lib/actions/payload.ts | 6 ++
.../run-tab/src/lib/reducers/runTab.ts | 7 +++
3 files changed, 45 insertions(+), 24 deletions(-)
diff --git a/libs/remix-ui/run-tab/src/lib/actions/index.ts b/libs/remix-ui/run-tab/src/lib/actions/index.ts
index 9c0b06e36b..ea12ad7efa 100644
--- a/libs/remix-ui/run-tab/src/lib/actions/index.ts
+++ b/libs/remix-ui/run-tab/src/lib/actions/index.ts
@@ -3,7 +3,7 @@ import React from 'react'
import * as ethJSUtil from 'ethereumjs-util'
import Web3 from 'web3'
import { addressToString, createNonClashingNameAsync, shortenAddress } from '@remix-ui/helper'
-import { addNewInstance, addProvider, clearAllInstances, clearRecorderCount, displayNotification, displayPopUp, fetchAccountsListFailed, fetchAccountsListRequest, fetchAccountsListSuccess, fetchContractListSuccess, hidePopUp, removeExistingInstance, removeProvider, setBaseFeePerGas, setConfirmSettings, setCurrentFile, setDecodedResponse, setEnvToasterContent, setExecutionEnvironment, setExternalEndpoint, setGasLimit, setGasPrice, setGasPriceStatus, setLoadType, setMatchPassphrase, setMaxFee, setMaxPriorityFee, setNetworkName, setPassphrase, setPathToScenario, setRecorderCount, setSelectedAccount, setSendUnit, setSendValue, setTxFeeContent, setWeb3Dialog } from './payload'
+import { addNewInstance, addProvider, clearAllInstances, clearRecorderCount, displayNotification, displayPopUp, fetchAccountsListFailed, fetchAccountsListRequest, fetchAccountsListSuccess, fetchContractListSuccess, hidePopUp, removeExistingInstance, removeProvider, resetUdapp, setBaseFeePerGas, setConfirmSettings, setCurrentFile, setDecodedResponse, setEnvToasterContent, setExecutionEnvironment, setExternalEndpoint, setGasLimit, setGasPrice, setGasPriceStatus, setLoadType, setMatchPassphrase, setMaxFee, setMaxPriorityFee, setNetworkName, setPassphrase, setPathToScenario, setRecorderCount, setSelectedAccount, setSendUnit, setSendValue, setTxFeeContent, setWeb3Dialog } from './payload'
import { RunTab } from '../types/run-tab'
import { CompilerAbstract } from '@remix-project/remix-solidity'
import * as remixLib from '@remix-project/remix-lib'
@@ -23,6 +23,7 @@ let plugin: RunTab, dispatch: React.Dispatch
export const initRunTab = (udapp: RunTab) => async (reducerDispatch: React.Dispatch) => {
plugin = udapp
dispatch = reducerDispatch
+ resetAndInit()
setupEvents()
setInterval(() => {
fillAccountsList()
@@ -30,29 +31,6 @@ export const initRunTab = (udapp: RunTab) => async (reducerDispatch: React.Dispa
}
const setupEvents = () => {
- plugin.blockchain.resetAndInit(plugin.config, {
- getAddress: (cb) => {
- cb(null, plugin.REACT_API.accounts.selectedAccount)
- },
- getValue: (cb) => {
- try {
- const number = plugin.REACT_API.sendValue
- const unit = plugin.REACT_API.sendUnit
-
- cb(null, Web3.utils.toWei(number, unit))
- } catch (e) {
- cb(e)
- }
- },
- getGasLimit: (cb) => {
- try {
- cb(null, '0x' + new ethJSUtil.BN(plugin.REACT_API.gasLimit, 10).toString(16))
- } catch (e) {
- cb(e.message)
- }
- }
- })
-
plugin.blockchain.events.on('newTransaction', (tx, receipt) => {
plugin.emit('newTransaction', tx, receipt)
})
@@ -103,6 +81,11 @@ const setupEvents = () => {
setExecutionContext(env, plugin.REACT_API.web3Dialog())
})
+ plugin.on('filePanel', 'setWorkspace', () => {
+ dispatch(resetUdapp())
+ resetAndInit()
+ })
+
plugin.fileManager.events.on('currentFileChanged', (currentFile: string) => {
if (/.(.abi)$/.exec(currentFile)) {
dispatch(setLoadType('abi'))
@@ -718,3 +701,28 @@ export const getFuncABIInputs = (funcABI: FuncABI) => {
export const setSendTransactionValue = (value: string) => {
dispatch(setSendValue(value))
}
+
+const resetAndInit = () => {
+ plugin.blockchain.resetAndInit(plugin.config, {
+ getAddress: (cb) => {
+ cb(null, plugin.REACT_API.accounts.selectedAccount)
+ },
+ getValue: (cb) => {
+ try {
+ const number = plugin.REACT_API.sendValue
+ const unit = plugin.REACT_API.sendUnit
+
+ cb(null, Web3.utils.toWei(number, unit))
+ } catch (e) {
+ cb(e)
+ }
+ },
+ getGasLimit: (cb) => {
+ try {
+ cb(null, '0x' + new ethJSUtil.BN(plugin.REACT_API.gasLimit, 10).toString(16))
+ } catch (e) {
+ cb(e.message)
+ }
+ }
+ })
+}
diff --git a/libs/remix-ui/run-tab/src/lib/actions/payload.ts b/libs/remix-ui/run-tab/src/lib/actions/payload.ts
index bf547cbecf..bf1194c85b 100644
--- a/libs/remix-ui/run-tab/src/lib/actions/payload.ts
+++ b/libs/remix-ui/run-tab/src/lib/actions/payload.ts
@@ -283,3 +283,9 @@ export const setWeb3Dialog = () => {
type: 'SET_WEB3_DIALOG'
}
}
+
+export const resetUdapp = () => {
+ return {
+ type: 'RESET_STATE'
+ }
+}
diff --git a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
index 7ad0b0f500..c932202aa5 100644
--- a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
+++ b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
@@ -656,6 +656,13 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A
}
}
+ case 'RESET_STATE': {
+ return {
+ ...runTabInitialState,
+ ipfsChecked: state.ipfsChecked
+ }
+ }
+
default:
return state
}
From 9d5582f68489189c3102cb2850646272a0ee9fe1 Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Sun, 9 Jan 2022 10:52:42 +0100
Subject: [PATCH 03/28] async await modal
undo compiler
unde compiler
undo coompiler
---
apps/remix-ide/src/app/plugins/modal.tsx | 4 +--
.../src/app/plugins/remixd-handle.tsx | 26 +++++++------------
.../components/modals/modal-wrapper.tsx | 25 +++++++++++++++---
.../src/lib/remix-app/context/provider.tsx | 10 ++++---
.../app/src/lib/remix-app/interface/index.ts | 7 ++---
.../app/src/lib/remix-app/reducer/modals.ts | 6 ++++-
.../modal-dialog/src/lib/types/index.ts | 3 ++-
.../src/lib/compiler-container.tsx | 7 +++--
8 files changed, 53 insertions(+), 35 deletions(-)
diff --git a/apps/remix-ide/src/app/plugins/modal.tsx b/apps/remix-ide/src/app/plugins/modal.tsx
index f69cfda0d4..f5a855f0c2 100644
--- a/apps/remix-ide/src/app/plugins/modal.tsx
+++ b/apps/remix-ide/src/app/plugins/modal.tsx
@@ -31,11 +31,11 @@ export class ModalPlugin extends Plugin implements MethodApi {
}
async modal (args: AppModal) {
- this.dispatcher.modal(args)
+ return this.dispatcher.modal(args)
}
async alert (args: AlertModal) {
- this.dispatcher.alert(args)
+ return this.dispatcher.alert(args)
}
async toast (message: string) {
diff --git a/apps/remix-ide/src/app/plugins/remixd-handle.tsx b/apps/remix-ide/src/app/plugins/remixd-handle.tsx
index 3b6d27c815..6f4c522647 100644
--- a/apps/remix-ide/src/app/plugins/remixd-handle.tsx
+++ b/apps/remix-ide/src/app/plugins/remixd-handle.tsx
@@ -30,7 +30,6 @@ enum State {
export class RemixdHandle extends WebsocketPlugin {
localhostProvider: any
appManager: PluginManager
- state: State
constructor (localhostProvider, appManager) {
super(profile)
this.localhostProvider = localhostProvider
@@ -48,7 +47,8 @@ export class RemixdHandle extends WebsocketPlugin {
}
async activate () {
- await this.connectToLocalhost()
+ this.connectToLocalhost()
+ return true
}
async canceled () {
@@ -95,13 +95,15 @@ export class RemixdHandle extends WebsocketPlugin {
this.deactivate()
} else if (!isElectron()) {
// warn the user only if he/she is in the browser context
- this.state = State.new
const mod:AppModal = {
id: 'remixdConnect',
title: 'Connect to localhost',
message: remixdDialog(),
- okFn: () => {
- this.state = State.ok
+ okLabel: 'Connect',
+ cancelLabel: 'Cancel',
+ }
+ const result = await this.call('modal', 'modal', mod)
+ if(result) {
try {
this.localhostProvider.preInit()
super.activate()
@@ -115,18 +117,10 @@ export class RemixdHandle extends WebsocketPlugin {
} catch (error) {
connection(error)
}
- },
- cancelFn: async () => {
- this.state = State.cancel
- await this.canceled()
- },
- okLabel: 'Connect',
- cancelLabel: 'Cancel',
- hideFn: async () => {
- if (this.state === State.new) await this.canceled()
- }
}
- await this.call('modal', 'modal', mod)
+ else {
+ await this.canceled()
+ }
} else {
try {
super.activate()
diff --git a/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx b/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx
index cff3215e1f..74cdf04e32 100644
--- a/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx
+++ b/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx
@@ -14,13 +14,21 @@ const ModalWrapper = (props: ModalWrapperProps) => {
const onFinishPrompt = async () => {
if (ref.current === undefined) {
- props.okFn()
+ onOkFn()
} else {
// @ts-ignore: Object is possibly 'null'.
- props.okFn(ref.current.value)
+ (props.resolve) ? props.resolve(ref.current.value) : props.okFn(ref.current.value)
}
}
+ const onOkFn = async () => {
+ (props.resolve) ? props.resolve(true) : props.okFn()
+ }
+
+ const onCancelFn = async () => {
+ (props.resolve) ? props.resolve(false) : props.cancelFn()
+ }
+
const createModalMessage = (defaultValue: string) => {
return (
<>
@@ -37,15 +45,24 @@ const ModalWrapper = (props: ModalWrapperProps) => {
setState({
...props,
okFn: onFinishPrompt,
+ cancelFn: onCancelFn,
message: createModalMessage(props.defaultValue)
})
break
default:
- setState({ ...props })
+ setState({
+ ...props,
+ okFn: (onOkFn),
+ cancelFn: onCancelFn
+ })
break
}
} else {
- setState({ ...props })
+ setState({
+ ...props,
+ okFn: onOkFn,
+ cancelFn: onCancelFn
+ })
}
}, [props])
diff --git a/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx b/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx
index 73a3a97305..61b98a4873 100644
--- a/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx
+++ b/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx
@@ -11,14 +11,16 @@ export const ModalProvider = ({ children = [], reducer = modalReducer, initialSt
const modal = (data: AppModal) => {
const { id, title, message, okLabel, okFn, cancelLabel, cancelFn, modalType, defaultValue, hideFn } = data
- dispatch({
- type: modalActionTypes.setModal,
- payload: { id, title, message, okLabel, okFn, cancelLabel, cancelFn, modalType: modalType || ModalTypes.default, defaultValue: defaultValue, hideFn }
+ return new Promise((resolve, reject) => {
+ dispatch({
+ type: modalActionTypes.setModal,
+ payload: { id, title, message, okLabel, okFn, cancelLabel, cancelFn, modalType: modalType || ModalTypes.default, defaultValue: defaultValue, hideFn, resolve }
+ })
})
}
const alert = (data: AlertModal) => {
- modal({ id: data.id, title: data.title || 'Alert', message: data.message || data.title, okLabel: 'OK', okFn: (value?:any) => {}, cancelLabel: '', cancelFn: () => {} })
+ return modal({ id: data.id, title: data.title || 'Alert', message: data.message || data.title, okLabel: 'OK', okFn: (value?:any) => {}, cancelLabel: '', cancelFn: () => {} })
}
const handleHideModal = () => {
diff --git a/libs/remix-ui/app/src/lib/remix-app/interface/index.ts b/libs/remix-ui/app/src/lib/remix-app/interface/index.ts
index dcfcd7a1eb..6546f22b0f 100644
--- a/libs/remix-ui/app/src/lib/remix-app/interface/index.ts
+++ b/libs/remix-ui/app/src/lib/remix-app/interface/index.ts
@@ -7,12 +7,13 @@ export interface AppModal {
// eslint-disable-next-line no-undef
message: string | JSX.Element
okLabel: string
- okFn: (value?:any) => void
+ okFn?: (value?:any) => void
cancelLabel: string
- cancelFn: () => void,
+ cancelFn?: () => void,
modalType?: ModalTypes,
defaultValue?: string
- hideFn?: () => void
+ hideFn?: () => void,
+ resolve?: (value?:any) => void
}
export interface AlertModal {
diff --git a/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts b/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts
index cf202585f4..fb4f12d826 100644
--- a/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts
+++ b/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts
@@ -19,7 +19,8 @@ export const modalReducer = (state: ModalState = ModalInitialState, action: Moda
cancelFn: modalList[0].cancelFn,
modalType: modalList[0].modalType,
defaultValue: modalList[0].defaultValue,
- hideFn: modalList[0].hideFn
+ hideFn: modalList[0].hideFn,
+ resolve: modalList[0].resolve
}
modalList = modalList.slice()
@@ -29,6 +30,9 @@ export const modalReducer = (state: ModalState = ModalInitialState, action: Moda
return { ...state, modals: modalList }
}
case modalActionTypes.handleHideModal:
+ if (state.focusModal.resolve) {
+ state.focusModal.resolve(undefined)
+ } else
if (state.focusModal.hideFn) {
state.focusModal.hideFn()
}
diff --git a/libs/remix-ui/modal-dialog/src/lib/types/index.ts b/libs/remix-ui/modal-dialog/src/lib/types/index.ts
index acb171fc0f..dd12c8e680 100644
--- a/libs/remix-ui/modal-dialog/src/lib/types/index.ts
+++ b/libs/remix-ui/modal-dialog/src/lib/types/index.ts
@@ -11,5 +11,6 @@ export interface ModalDialogProps {
showCancelIcon?: boolean,
hide?: boolean,
handleHide: (hideState?: boolean) => void,
- children?: React.ReactNode
+ children?: React.ReactNode,
+ resolve?: (value?:any) => void,
}
diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
index 8f53164da5..eabccbd8a8 100644
--- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
+++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
@@ -356,13 +356,12 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
return console.log('loading ' + selectedVersion + ' not allowed, version should start with "soljson"')
}
}
+
// Workers cannot load js on "file:"-URLs and we get a
// "Uncaught RangeError: Maximum call stack size exceeded" error on Chromium,
// resort to non-worker version in that case.
- if (selectedVersion === 'builtin') {
- selectedVersion = state.defaultVersion
- compileTabLogic.compiler.loadVersion(false, url)
- } else if (canUseWorker(selectedVersion)) {
+ if (selectedVersion === 'builtin') selectedVersion = state.defaultVersion
+ if (selectedVersion !== 'builtin' && canUseWorker(selectedVersion)) {
compileTabLogic.compiler.loadVersion(true, url)
} else {
compileTabLogic.compiler.loadVersion(false, url)
From fd448fd9cef218ebcf46c28399ccf7cbea4ad8d3 Mon Sep 17 00:00:00 2001
From: David Disu
Date: Mon, 10 Jan 2022 06:56:49 +0100
Subject: [PATCH 04/28] Remove focus for file closed in the editor
---
libs/remix-ui/workspace/src/lib/actions/events.ts | 6 +++++-
libs/remix-ui/workspace/src/lib/actions/payload.ts | 7 +++++++
libs/remix-ui/workspace/src/lib/reducers/workspace.ts | 9 +++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/libs/remix-ui/workspace/src/lib/actions/events.ts b/libs/remix-ui/workspace/src/lib/actions/events.ts
index 0f9d7ba29f..7ea0b03053 100644
--- a/libs/remix-ui/workspace/src/lib/actions/events.ts
+++ b/libs/remix-ui/workspace/src/lib/actions/events.ts
@@ -1,7 +1,7 @@
import { extractParentFromKey } from '@remix-ui/helper'
import React from 'react'
import { action } from '../types'
-import { displayNotification, displayPopUp, fileAddedSuccess, fileRemovedSuccess, fileRenamedSuccess, folderAddedSuccess, loadLocalhostError, loadLocalhostRequest, loadLocalhostSuccess, removeContextMenuItem, rootFolderChangedSuccess, setContextMenuItem, setMode, setReadOnlyMode } from './payload'
+import { displayNotification, displayPopUp, fileAddedSuccess, fileRemovedSuccess, fileRenamedSuccess, folderAddedSuccess, loadLocalhostError, loadLocalhostRequest, loadLocalhostSuccess, removeContextMenuItem, removeFocus, rootFolderChangedSuccess, setContextMenuItem, setMode, setReadOnlyMode } from './payload'
import { addInputField, createWorkspace, deleteWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile } from './workspace'
const LOCALHOST = ' - connect to localhost - '
@@ -45,6 +45,10 @@ export const listenOnPluginEvents = (filePanelPlugin) => {
plugin.on('fileManager', 'rootFolderChanged', async (path: string) => {
rootFolderChanged(path)
})
+
+ plugin.on('fileManager', 'fileClosed', async (file: string) => {
+ dispatch(removeFocus(file))
+ })
}
export const listenOnProviderEvents = (provider) => (reducerDispatch: React.Dispatch) => {
diff --git a/libs/remix-ui/workspace/src/lib/actions/payload.ts b/libs/remix-ui/workspace/src/lib/actions/payload.ts
index ee59ac24a3..a0ed0850cb 100644
--- a/libs/remix-ui/workspace/src/lib/actions/payload.ts
+++ b/libs/remix-ui/workspace/src/lib/actions/payload.ts
@@ -187,6 +187,13 @@ export const focusElement = (elements: { key: string, type: 'file' | 'folder' |
}
}
+export const removeFocus = (name: string) => {
+ return {
+ type: 'REMOVE_FOCUS_ELEMENT',
+ payload: name
+ }
+}
+
export const setContextMenuItem = (item: action) => {
return {
type: 'SET_CONTEXT_MENU_ITEM',
diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts
index ef769f5c5b..a41365224b 100644
--- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts
+++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts
@@ -497,6 +497,15 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
}
}
+ case 'REMOVE_FOCUS_ELEMENT': {
+ const payload: string = action.payload
+
+ return {
+ ...state,
+ focusElement: state.focusElement.filter(element => element.key !== payload)
+ }
+ }
+
case 'SET_CONTEXT_MENU_ITEM': {
const payload = action.payload as action
From ca1ae9fc3ef721b866607639a16d562208727d5e Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Mon, 10 Jan 2022 09:13:06 +0100
Subject: [PATCH 05/28] non async handles
---
.../src/lib/remix-app/components/modals/modal-wrapper.tsx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx b/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx
index 74cdf04e32..8d36d75cda 100644
--- a/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx
+++ b/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx
@@ -17,16 +17,16 @@ const ModalWrapper = (props: ModalWrapperProps) => {
onOkFn()
} else {
// @ts-ignore: Object is possibly 'null'.
- (props.resolve) ? props.resolve(ref.current.value) : props.okFn(ref.current.value)
+ (props.okFn) ? props.okFn(ref.current.value) : props.resolve(ref.current.value)
}
}
const onOkFn = async () => {
- (props.resolve) ? props.resolve(true) : props.okFn()
+ (props.okFn) ? props.okFn() : props.resolve(true)
}
const onCancelFn = async () => {
- (props.resolve) ? props.resolve(false) : props.cancelFn()
+ (props.cancelFn) ? props.cancelFn() : props.resolve(false)
}
const createModalMessage = (defaultValue: string) => {
From 88c90b6de92af74515a837923ba7c367b5265b9d Mon Sep 17 00:00:00 2001
From: yann300
Date: Mon, 10 Jan 2022 14:44:59 +0100
Subject: [PATCH 06/28] use fixed version for colors
---
libs/remix-tests/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/remix-tests/package.json b/libs/remix-tests/package.json
index 2055922334..610720e923 100644
--- a/libs/remix-tests/package.json
+++ b/libs/remix-tests/package.json
@@ -47,7 +47,7 @@
"axios": ">=0.21.1",
"change-case": "^3.0.1",
"color-support": "^1.1.3",
- "colors": "^1.1.2",
+ "colors": "1.4.0",
"commander": "^2.13.0",
"deep-equal": "^1.0.1",
"ethereumjs-util": "^7.0.10",
From 4fe38259df1023842c7092e25706b3ec952150b3 Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Mon, 10 Jan 2022 15:04:31 +0100
Subject: [PATCH 07/28] Update modals.ts
---
libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts b/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts
index fb4f12d826..0a39da08ef 100644
--- a/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts
+++ b/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts
@@ -30,12 +30,12 @@ export const modalReducer = (state: ModalState = ModalInitialState, action: Moda
return { ...state, modals: modalList }
}
case modalActionTypes.handleHideModal:
- if (state.focusModal.resolve) {
- state.focusModal.resolve(undefined)
- } else
if (state.focusModal.hideFn) {
state.focusModal.hideFn()
}
+ else if (state.focusModal.resolve) {
+ state.focusModal.resolve(undefined)
+ }
state.focusModal = { ...state.focusModal, hide: true, message: null }
return { ...state }
From dcae2098e86233b89f7063a22a02a18c18bb7ccb Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Mon, 10 Jan 2022 15:08:09 +0100
Subject: [PATCH 08/28] lint
---
libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts b/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts
index 0a39da08ef..d83b9792c7 100644
--- a/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts
+++ b/libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts
@@ -32,8 +32,7 @@ export const modalReducer = (state: ModalState = ModalInitialState, action: Moda
case modalActionTypes.handleHideModal:
if (state.focusModal.hideFn) {
state.focusModal.hideFn()
- }
- else if (state.focusModal.resolve) {
+ } else if (state.focusModal.resolve) {
state.focusModal.resolve(undefined)
}
state.focusModal = { ...state.focusModal, hide: true, message: null }
From 8f09a98bb09ff3e7a91c503d540db13e766a91e0 Mon Sep 17 00:00:00 2001
From: aniket-engg
Date: Tue, 11 Jan 2022 12:20:53 +0530
Subject: [PATCH 09/28] encode data on click
---
.../copy-to-clipboard/copy-to-clipboard.tsx | 7 ++--
.../src/lib/components/contractGUI.tsx | 39 +++++++++----------
2 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx b/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx
index 88d91d3867..6f37267f3c 100644
--- a/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx
+++ b/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx
@@ -12,10 +12,11 @@ interface ICopyToClipboard {
direction?: Placement,
className?: string,
title?: string,
- children?: JSX.Element
+ children?: JSX.Element,
+ onmousedown?: any
}
export const CopyToClipboard = (props: ICopyToClipboard) => {
- let { content, tip = 'Copy', icon = 'fa-copy', direction = 'right', children, ...otherProps } = props
+ let { content, tip = 'Copy', icon = 'fa-copy', direction = 'right', children, onmousedown, ...otherProps } = props
const [message, setMessage] = useState(tip)
const handleClick = (e) => {
if (content && content !== '') { // module `copy` keeps last copied thing in the memory, so don't show tooltip if nothing is copied, because nothing was added to memory
@@ -41,7 +42,7 @@ export const CopyToClipboard = (props: ICopyToClipboard) => {
return (
// eslint-disable-next-line jsx-a11y/anchor-is-valid
-
+
{ message }
diff --git a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
index 2006999b35..0175f272f9 100644
--- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
+++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
@@ -18,25 +18,6 @@ export function ContractGUI (props: ContractGUIProps) {
const [clipboardContent, setClipboardContent] = useState('')
const multiFields = useRef>([])
- useEffect(() => {
- const multiString = getMultiValsString()
- const multiJSON = JSON.parse('[' + multiString + ']')
- let encodeObj
-
- if (props.evmBC) {
- encodeObj = txFormat.encodeData(props.funcABI, multiJSON, props.evmBC)
- } else {
- encodeObj = txFormat.encodeData(props.funcABI, multiJSON, null)
- }
- if (encodeObj.error) {
- console.error(encodeObj.error)
- // throw new Error(encodeObj.error)
- setClipboardContent(encodeObj.error)
- } else {
- setClipboardContent(encodeObj.data)
- }
- }, [])
-
useEffect(() => {
if (props.title) {
setTitle(props.title)
@@ -75,6 +56,24 @@ export function ContractGUI (props: ContractGUIProps) {
}
}, [props.lookupOnly, props.funcABI, title])
+ const onCTCMouseDown = () => {
+ const multiString = getMultiValsString()
+ const multiJSON = JSON.parse('[' + multiString + ']')
+ let encodeObj
+
+ if (props.evmBC) {
+ encodeObj = txFormat.encodeData(props.funcABI, multiJSON, props.evmBC)
+ } else {
+ encodeObj = txFormat.encodeData(props.funcABI, multiJSON, null)
+ }
+ if (encodeObj.error) {
+ console.error(encodeObj.error)
+ setClipboardContent(encodeObj.error)
+ } else {
+ setClipboardContent(encodeObj.data)
+ }
+ }
+
const switchMethodViewOn = () => {
setToggleContainer(true)
makeMultiVal()
@@ -187,7 +186,7 @@ export function ContractGUI (props: ContractGUIProps) {
})}
-
+
{ buttonOptions.content }
From c4de63b087fb4da033a3d2cdcd93b4df66584976 Mon Sep 17 00:00:00 2001
From: aniket-engg
Date: Tue, 11 Jan 2022 12:28:42 +0530
Subject: [PATCH 10/28] handle empty arguments
---
libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
index 0175f272f9..c8dc13be19 100644
--- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
+++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
@@ -58,6 +58,11 @@ export function ContractGUI (props: ContractGUIProps) {
const onCTCMouseDown = () => {
const multiString = getMultiValsString()
+ // copy-to-clipboard icon is only visible for method requiring input params
+ if (!multiString) {
+ setClipboardContent('cannot encode empty arguments')
+ return
+ }
const multiJSON = JSON.parse('[' + multiString + ']')
let encodeObj
From 46b27f97d2a28d412f41602b475ce1b1214b1e89 Mon Sep 17 00:00:00 2001
From: aniket-engg
Date: Tue, 11 Jan 2022 12:57:27 +0530
Subject: [PATCH 11/28] getContent for CTC
---
.../copy-to-clipboard/copy-to-clipboard.tsx | 40 ++++++++++++-------
.../src/lib/components/contractGUI.tsx | 12 +++---
2 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx b/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx
index 6f37267f3c..055a0a1e4b 100644
--- a/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx
+++ b/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx
@@ -6,31 +6,41 @@ import { Placement } from 'react-bootstrap/esm/Overlay'
import './copy-to-clipboard.css'
interface ICopyToClipboard {
- content: any,
+ content?: any,
tip?: string,
icon?: string,
direction?: Placement,
className?: string,
title?: string,
children?: JSX.Element,
- onmousedown?: any
+ getContent?: () => {}
}
export const CopyToClipboard = (props: ICopyToClipboard) => {
- let { content, tip = 'Copy', icon = 'fa-copy', direction = 'right', children, onmousedown, ...otherProps } = props
+ let { content, tip = 'Copy', icon = 'fa-copy', direction = 'right', children, getContent, ...otherProps } = props
const [message, setMessage] = useState(tip)
- const handleClick = (e) => {
- if (content && content !== '') { // module `copy` keeps last copied thing in the memory, so don't show tooltip if nothing is copied, because nothing was added to memory
- try {
- if (typeof content !== 'string') {
- content = JSON.stringify(content, null, '\t')
- }
- copy(content)
- setMessage('Copied')
- } catch (e) {
- console.error(e)
+
+ const copyData = () => {
+ try {
+ if (content === '') {
+ setMessage('Cannot copy empty content!')
+ return
+ }
+ if (typeof content !== 'string') {
+ content = JSON.stringify(content, null, '\t')
}
+ copy(content)
+ setMessage('Copied')
+ } catch (e) {
+ console.error(e)
+ }
+ }
+
+ const handleClick = (e) => {
+ if (content) { // module `copy` keeps last copied thing in the memory, so don't show tooltip if nothing is copied, because nothing was added to memory
+ copyData()
} else {
- setMessage('Cannot copy empty content!')
+ content = getContent && getContent()
+ copyData()
}
e.preventDefault()
return false
@@ -42,7 +52,7 @@ export const CopyToClipboard = (props: ICopyToClipboard) => {
return (
// eslint-disable-next-line jsx-a11y/anchor-is-valid
-
+
{ message }
diff --git a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
index c8dc13be19..dd13a983ef 100644
--- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
+++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
@@ -15,7 +15,6 @@ export function ContractGUI (props: ContractGUIProps) {
classList: string,
dataId: string
}>({ title: '', content: '', classList: '', dataId: '' })
- const [clipboardContent, setClipboardContent] = useState('')
const multiFields = useRef>([])
useEffect(() => {
@@ -56,12 +55,11 @@ export function ContractGUI (props: ContractGUIProps) {
}
}, [props.lookupOnly, props.funcABI, title])
- const onCTCMouseDown = () => {
+ const getContentOnCTC = () => {
const multiString = getMultiValsString()
// copy-to-clipboard icon is only visible for method requiring input params
if (!multiString) {
- setClipboardContent('cannot encode empty arguments')
- return
+ return 'cannot encode empty arguments'
}
const multiJSON = JSON.parse('[' + multiString + ']')
let encodeObj
@@ -73,9 +71,9 @@ export function ContractGUI (props: ContractGUIProps) {
}
if (encodeObj.error) {
console.error(encodeObj.error)
- setClipboardContent(encodeObj.error)
+ return encodeObj.error
} else {
- setClipboardContent(encodeObj.data)
+ return encodeObj.data
}
}
@@ -191,7 +189,7 @@ export function ContractGUI (props: ContractGUIProps) {
})}
-
+
{ buttonOptions.content }
From a4d12d6d328e3f4678ee130b8c5f8b992de8e2cc Mon Sep 17 00:00:00 2001
From: aniket-engg
Date: Tue, 11 Jan 2022 13:16:53 +0530
Subject: [PATCH 12/28] remove extra line
---
.../clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx | 1 -
1 file changed, 1 deletion(-)
diff --git a/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx b/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx
index 055a0a1e4b..92ef7cf768 100644
--- a/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx
+++ b/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx
@@ -43,7 +43,6 @@ export const CopyToClipboard = (props: ICopyToClipboard) => {
copyData()
}
e.preventDefault()
- return false
}
const reset = () => {
From ff1ccbb1a075c8e4d5792843497944d0d8a5733f Mon Sep 17 00:00:00 2001
From: yann300
Date: Thu, 6 Jan 2022 18:04:04 +0100
Subject: [PATCH 13/28] fix add and remove provider
---
apps/remix-ide-e2e/src/tests/plugin_api.ts | 23 ++++++++++++++++++
.../src/app/tabs/hardhat-provider.tsx | 4 ++--
.../remix-ui/run-tab/src/lib/actions/index.ts | 2 +-
.../run-tab/src/lib/reducers/runTab.ts | 24 ++++++++++++++-----
4 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts
index 2ad4d82144..d3ce74a639 100644
--- a/apps/remix-ide-e2e/src/tests/plugin_api.ts
+++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts
@@ -324,5 +324,28 @@ module.exports = {
'Should get compilationresults #group6': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'solidity:getCompilationResult', 'contracts/1_Storage.sol', null, null)
+ },
+
+ // PROVIDER
+
+ 'Should switch to hardhat provider (provider plugin)': async function (browser: NightwatchBrowser) {
+ browser
+ .clickLaunchIcon('udapp')
+ .click('*[data-id="Hardhat provider"]')
+ .modalFooterOKClick('hardhatprovider')
+ .waitForElementContainsText('*[data-id="settingsNetworkEnv"]', 'Custom') // e.g Custom (1337) network
+ .getValue('*[data-id="settingsNetworkEnv"]', (result) => {
+ browser.assert.ok((result.value as string).match(/^Custom \(\d+\) network$/) !== undefined, 'Expected to ')
+ })
+ .perform(async () => {
+ const request = {
+ id: 9999,
+ jsonrpc: "2.0",
+ method: "net_listening",
+ params: []
+ }
+ const result = true
+ await clickAndCheckLog(browser, 'hardhat-provider:sendAsync', {}, result, request)
+ })
}
}
diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.tsx b/apps/remix-ide/src/app/tabs/hardhat-provider.tsx
index abb5eabddf..c84a6d09c2 100644
--- a/apps/remix-ide/src/app/tabs/hardhat-provider.tsx
+++ b/apps/remix-ide/src/app/tabs/hardhat-provider.tsx
@@ -66,7 +66,7 @@ export class HardhatProvider extends Plugin {
value = await ((): Promise => {
return new Promise((resolve, reject) => {
const modalContent: AppModal = {
- id: 'harrhatprovider',
+ id: 'hardhatprovider',
title: 'Hardhat node request',
message: this.hardhatProviderDialogBody(),
modalType: ModalTypes.prompt,
@@ -110,7 +110,7 @@ export class HardhatProvider extends Plugin {
} catch (error) {
this.blocked = true
const modalContent: AlertModal = {
- id: 'harrhatprovider',
+ id: 'hardhatprovider',
title: 'Hardhat Provider',
message: `Error while connecting to the hardhat provider: ${error.message}`,
}
diff --git a/libs/remix-ui/run-tab/src/lib/actions/index.ts b/libs/remix-ui/run-tab/src/lib/actions/index.ts
index ea12ad7efa..97c5c4c7f9 100644
--- a/libs/remix-ui/run-tab/src/lib/actions/index.ts
+++ b/libs/remix-ui/run-tab/src/lib/actions/index.ts
@@ -237,7 +237,7 @@ export const setExecutionContext = (executionContext: { context: string, fork: s
}, () => { setFinalContext() }))
}, (alertMsg) => {
dispatch(displayPopUp(alertMsg))
- }, setFinalContext())
+ }, () => { setFinalContext() })
}
export const setWeb3Endpoint = (endpoint: string) => {
diff --git a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
index c932202aa5..9f0624d561 100644
--- a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
+++ b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
@@ -171,6 +171,11 @@ export const runTabInitialState: RunTabState = {
web3Dialog: null
}
+type AddProvider = {
+ name: string,
+ provider: any
+}
+
export const runTabReducer = (state: RunTabState = runTabInitialState, action: Action) => {
switch (action.type) {
case 'FETCH_ACCOUNTS_LIST_REQUEST': {
@@ -328,25 +333,32 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A
}
case 'ADD_PROVIDER': {
- const payload: string = action.payload
-
+ const payload: AddProvider = action.payload
+ const id = action.payload.name
+ state.providers.providerList.push({
+ content: payload.name,
+ dataId: id,
+ id,
+ title: payload.name,
+ value: id
+ })
return {
...state,
providers: {
...state.providers,
- providerList: { ...state.providers.providerList, payload }
+ providerList: state.providers.providerList
}
}
}
case 'REMOVE_PROVIDER': {
- const payload: string = action.payload
-
+ const id: string = action.payload
+ const providers = state.providers.providerList.filter((el) => el.id !== id)
return {
...state,
providers: {
...state.providers,
- providerList: delete state.providers.providerList[payload] ? state.providers.providerList : state.providers.providerList
+ providerList: providers
}
}
}
From ed452a6650262a0d76cf14dfc343546913e089e9 Mon Sep 17 00:00:00 2001
From: yann300
Date: Mon, 10 Jan 2022 16:19:20 +0100
Subject: [PATCH 14/28] fix using web3Dialog
---
libs/remix-ui/run-tab/src/lib/actions/index.ts | 2 +-
libs/remix-ui/run-tab/src/lib/actions/payload.ts | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/libs/remix-ui/run-tab/src/lib/actions/index.ts b/libs/remix-ui/run-tab/src/lib/actions/index.ts
index 97c5c4c7f9..c659b2a802 100644
--- a/libs/remix-ui/run-tab/src/lib/actions/index.ts
+++ b/libs/remix-ui/run-tab/src/lib/actions/index.ts
@@ -110,7 +110,7 @@ const setupEvents = () => {
export const initWebDialogs = (envToasterContent: (env: { context: string, fork: string }, from: string) => void, web3Dialog: () => void) => async (dispatch: React.Dispatch) => {
dispatch(setEnvToasterContent(envToasterContent))
- dispatch(setWeb3Dialog)
+ dispatch(setWeb3Dialog(web3Dialog))
}
const updateAccountBalances = () => {
diff --git a/libs/remix-ui/run-tab/src/lib/actions/payload.ts b/libs/remix-ui/run-tab/src/lib/actions/payload.ts
index bf1194c85b..4d70582ce3 100644
--- a/libs/remix-ui/run-tab/src/lib/actions/payload.ts
+++ b/libs/remix-ui/run-tab/src/lib/actions/payload.ts
@@ -278,9 +278,10 @@ export const setEnvToasterContent = (content: (env: { context: string, fork: str
}
}
-export const setWeb3Dialog = () => {
+export const setWeb3Dialog = (web3Dialog: () => void) => {
return {
- type: 'SET_WEB3_DIALOG'
+ type: 'SET_WEB3_DIALOG',
+ payload: web3Dialog
}
}
From 487a616a6e36d7bd9a7aed6f67d94091de927208 Mon Sep 17 00:00:00 2001
From: yann300
Date: Mon, 10 Jan 2022 16:49:19 +0100
Subject: [PATCH 15/28] linting
---
apps/remix-ide-e2e/src/tests/plugin_api.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts
index d3ce74a639..1741a5a66b 100644
--- a/apps/remix-ide-e2e/src/tests/plugin_api.ts
+++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts
@@ -340,8 +340,8 @@ module.exports = {
.perform(async () => {
const request = {
id: 9999,
- jsonrpc: "2.0",
- method: "net_listening",
+ jsonrpc: '2.0',
+ method: 'net_listening',
params: []
}
const result = true
From 748329f98173c39988683dd33bbd658fb8b6a832 Mon Sep 17 00:00:00 2001
From: yann300
Date: Mon, 10 Jan 2022 17:00:27 +0100
Subject: [PATCH 16/28] fix E2E test
---
.../src/local-plugin/src/app/app.tsx | 2 +-
apps/remix-ide-e2e/src/tests/plugin_api.ts | 21 ++++++++++++-------
apps/remix-ide/ci/browser_tests_plugin_api.sh | 1 +
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx b/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx
index 50c4699997..d1a559764e 100644
--- a/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx
+++ b/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx
@@ -33,7 +33,7 @@ function App () {
useEffect(() => {
client.onload(async () => {
- const customProfiles = ['menuicons', 'tabs', 'solidityUnitTesting']
+ const customProfiles = ['menuicons', 'tabs', 'solidityUnitTesting', 'hardhat-provider']
client.testCommand = async (data: any) => {
console.log(data)
diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts
index 1741a5a66b..b303864438 100644
--- a/apps/remix-ide-e2e/src/tests/plugin_api.ts
+++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts
@@ -10,7 +10,7 @@ declare global {
const localPluginData: Profile & LocationProfile & ExternalProfile = {
name: 'localPlugin',
displayName: 'Local Plugin',
- canActivate: ['dGitProvider', 'flattener', 'solidityUnitTesting', 'udapp'],
+ canActivate: ['dGitProvider', 'flattener', 'solidityUnitTesting', 'udapp', 'hardhat-provider'],
url: 'http://localhost:2020',
location: 'sidePanel'
}
@@ -328,15 +328,20 @@ module.exports = {
// PROVIDER
- 'Should switch to hardhat provider (provider plugin)': async function (browser: NightwatchBrowser) {
+ 'Should switch to hardhat provider (provider plugin) #group8': function (browser: NightwatchBrowser) {
browser
+ .frameParent()
+ .useCss()
+ .clickLaunchIcon('pluginManager')
+ .scrollAndClick('[data-id="pluginManagerComponentActivateButtonhardhat-provider"]')
.clickLaunchIcon('udapp')
- .click('*[data-id="Hardhat provider"]')
+ .click('*[data-id="Hardhat Provider"]')
.modalFooterOKClick('hardhatprovider')
.waitForElementContainsText('*[data-id="settingsNetworkEnv"]', 'Custom') // e.g Custom (1337) network
- .getValue('*[data-id="settingsNetworkEnv"]', (result) => {
- browser.assert.ok((result.value as string).match(/^Custom \(\d+\) network$/) !== undefined, 'Expected to ')
- })
+ .clickLaunchIcon('localPlugin')
+ .useXpath()
+ // @ts-ignore
+ .frame(0)
.perform(async () => {
const request = {
id: 9999,
@@ -344,8 +349,8 @@ module.exports = {
method: 'net_listening',
params: []
}
- const result = true
- await clickAndCheckLog(browser, 'hardhat-provider:sendAsync', {}, result, request)
+ const result = '{"jsonrpc":"2.0","result":true,"id":9999}'
+ await clickAndCheckLog(browser, 'hardhat-provider:sendAsync', result, null, request)
})
}
}
diff --git a/apps/remix-ide/ci/browser_tests_plugin_api.sh b/apps/remix-ide/ci/browser_tests_plugin_api.sh
index eae0d5b389..282b979c98 100755
--- a/apps/remix-ide/ci/browser_tests_plugin_api.sh
+++ b/apps/remix-ide/ci/browser_tests_plugin_api.sh
@@ -6,6 +6,7 @@ BUILD_ID=${CIRCLE_BUILD_NUM:-${TRAVIS_JOB_NUMBER}}
echo "$BUILD_ID"
TEST_EXITCODE=0
+npm run ganache-cli &
npm run serve:production &
npx nx serve remix-ide-e2e-src-local-plugin &
From 942ef8dada08fa1d7700f2d0119d403f92baa7d6 Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Mon, 10 Jan 2022 14:59:31 +0100
Subject: [PATCH 17/28] start perms dialog
---
.../src/lib/permission-dialog.css | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 libs/remix-ui/permission-handler/src/lib/permission-dialog.css
diff --git a/libs/remix-ui/permission-handler/src/lib/permission-dialog.css b/libs/remix-ui/permission-handler/src/lib/permission-dialog.css
new file mode 100644
index 0000000000..b2584800b1
--- /dev/null
+++ b/libs/remix-ui/permission-handler/src/lib/permission-dialog.css
@@ -0,0 +1,25 @@
+.permission h4 {
+ text-transform: uppercase;
+ text-align: center;
+ }
+ .permission h6 {
+ text-transform: uppercase;
+ }
+ .remember {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+ .images {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ padding: 10px;
+ }
+ .images img {
+ width: 40px;
+ height: 40px;
+ }
+ .images i {
+ margin: 0 20px;
+ }
\ No newline at end of file
From 1ca03961c6c97ed1c1cc8b3c44fe215a05364349 Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Mon, 10 Jan 2022 14:59:40 +0100
Subject: [PATCH 18/28] perms dialog
---
.../app/src/lib/remix-app/remix-app.tsx | 2 +
libs/remix-ui/permission-handler/.babelrc | 4 ++
.../permission-handler/.eslintrc.json | 18 ++++++
libs/remix-ui/permission-handler/src/index.ts | 1 +
.../permission-handler/src/interface/index.ts | 13 ++++
.../src/lib/permission-dialog.tsx | 63 +++++++++++++++++++
.../src/lib/permission-handler.tsx | 25 ++++++++
.../remix-ui/permission-handler/tsconfig.json | 20 ++++++
.../permission-handler/tsconfig.lib.json | 13 ++++
nx.json | 3 +
tsconfig.base.json | 3 +-
workspace.json | 15 +++++
12 files changed, 179 insertions(+), 1 deletion(-)
create mode 100644 libs/remix-ui/permission-handler/.babelrc
create mode 100644 libs/remix-ui/permission-handler/.eslintrc.json
create mode 100644 libs/remix-ui/permission-handler/src/index.ts
create mode 100644 libs/remix-ui/permission-handler/src/interface/index.ts
create mode 100644 libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx
create mode 100644 libs/remix-ui/permission-handler/src/lib/permission-handler.tsx
create mode 100644 libs/remix-ui/permission-handler/tsconfig.json
create mode 100644 libs/remix-ui/permission-handler/tsconfig.lib.json
diff --git a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx
index 27d5a7b832..605dcae501 100644
--- a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx
+++ b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx
@@ -8,6 +8,7 @@ import DragBar from './components/dragbar/dragbar'
import { AppProvider } from './context/provider'
import AppDialogs from './components/modals/dialogs'
import DialogViewPlugin from './components/modals/dialogViewPlugin'
+import { Permissionhandler } from '@remix-ui/permission-handler'
interface IRemixAppUi {
app: any
@@ -104,6 +105,7 @@ const RemixApp = (props: IRemixAppUi) => {
{components.hiddenPanel}
+
)
}
diff --git a/libs/remix-ui/permission-handler/.babelrc b/libs/remix-ui/permission-handler/.babelrc
new file mode 100644
index 0000000000..64a3748691
--- /dev/null
+++ b/libs/remix-ui/permission-handler/.babelrc
@@ -0,0 +1,4 @@
+{
+ "presets": ["@nrwl/react/babel"],
+ "plugins": []
+}
\ No newline at end of file
diff --git a/libs/remix-ui/permission-handler/.eslintrc.json b/libs/remix-ui/permission-handler/.eslintrc.json
new file mode 100644
index 0000000000..5a1c541d11
--- /dev/null
+++ b/libs/remix-ui/permission-handler/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["plugin:@nrwl/nx/react", "../../../.eslintrc"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
\ No newline at end of file
diff --git a/libs/remix-ui/permission-handler/src/index.ts b/libs/remix-ui/permission-handler/src/index.ts
new file mode 100644
index 0000000000..6e662ed485
--- /dev/null
+++ b/libs/remix-ui/permission-handler/src/index.ts
@@ -0,0 +1 @@
+export { default as Permissionhandler } from './lib/permission-handler'
diff --git a/libs/remix-ui/permission-handler/src/interface/index.ts b/libs/remix-ui/permission-handler/src/interface/index.ts
new file mode 100644
index 0000000000..7fbbbaaa34
--- /dev/null
+++ b/libs/remix-ui/permission-handler/src/interface/index.ts
@@ -0,0 +1,13 @@
+import { IconProfile } from 'libs/remix-ui/vertical-icons-panel/src/lib/components/Icon'
+
+export interface PermissionHandlerValue {
+ from: IconProfile,
+ to: IconProfile,
+ remember: boolean,
+ method: string,
+ message: string
+}
+
+export interface PermissionHandlerProps {
+ value: PermissionHandlerValue
+}
diff --git a/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx b/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx
new file mode 100644
index 0000000000..4550064754
--- /dev/null
+++ b/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx
@@ -0,0 +1,63 @@
+import React, { useContext, useEffect, useRef, useState } from 'react' // eslint-disable-line
+import { PermissionHandlerProps } from '../interface'
+import './permission-dialog.css'
+
+const PermissionHandlerDialog = (props: PermissionHandlerProps) => {
+ const { from, to, remember, method, message } = props.value
+
+ const switchMode = () => {
+
+ }
+
+ const rememberSwitch = () => {
+ return
+ }
+ const reset = () => {
+
+ }
+
+ const imgFrom = () => { return }
+ const imgTo = () => { return }
+ const pluginsImages = () => {
+ return (
+
+ {imgFrom}
+
+ {imgTo}
+
+ )
+ }
+
+ const text = () => {
+ return `"${from.displayName}" ${(remember ? 'has changed and' : '')} would like to access to "${method}" of "${to.displayName}"`
+ }
+
+ const pluginMessage = () => {
+ return message
+ ?
+
Description
+
{message}
+
: null
+ }
+
+ return (
+ {pluginsImages}
+
+ {text} :
+ {from.displayName}
+ {from.description} || No description Provided
+ {to.displayName} :
+ {to.description} || No description Provided
+ {pluginMessage}
+
+
+
+ {rememberSwitch}
+ Remember this choice
+
+ Reset all Permissions
+
+ )
+}
+
+export default PermissionHandlerDialog
diff --git a/libs/remix-ui/permission-handler/src/lib/permission-handler.tsx b/libs/remix-ui/permission-handler/src/lib/permission-handler.tsx
new file mode 100644
index 0000000000..f6b06c23f4
--- /dev/null
+++ b/libs/remix-ui/permission-handler/src/lib/permission-handler.tsx
@@ -0,0 +1,25 @@
+import { useDialogDispatchers } from 'libs/remix-ui/app/src/lib/remix-app/context/provider'
+import React, { useContext, useEffect, useRef, useState } from 'react' // eslint-disable-line
+import { PermissionHandlerValue } from '../interface'
+import PermissionHandlerDialog from './permission-dialog'
+
+const PermissionHandler = () => {
+ const { alert, toast, modal } = useDialogDispatchers()
+ const [value, setValue] = useState()
+ useEffect(() => {
+ if (value) {
+ modal({
+ id: 'PermissionHandler',
+ title: 'permissions',
+ message: ,
+ okFn: () => {},
+ cancelFn: () => {},
+ okLabel: 'sure',
+ cancelLabel: 'no'
+ })
+ }
+ }, [value])
+ return (<>>)
+}
+
+export default PermissionHandler
diff --git a/libs/remix-ui/permission-handler/tsconfig.json b/libs/remix-ui/permission-handler/tsconfig.json
new file mode 100644
index 0000000000..8bd701c578
--- /dev/null
+++ b/libs/remix-ui/permission-handler/tsconfig.json
@@ -0,0 +1,20 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "allowJs": true,
+ "esModuleInterop": true,
+ "allowSyntheticDefaultImports": true,
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ }
+ ]
+}
diff --git a/libs/remix-ui/permission-handler/tsconfig.lib.json b/libs/remix-ui/permission-handler/tsconfig.lib.json
new file mode 100644
index 0000000000..b560bc4dec
--- /dev/null
+++ b/libs/remix-ui/permission-handler/tsconfig.lib.json
@@ -0,0 +1,13 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "types": ["node"]
+ },
+ "files": [
+ "../../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
+ "../../../node_modules/@nrwl/react/typings/image.d.ts"
+ ],
+ "exclude": ["**/*.spec.ts", "**/*.spec.tsx"],
+ "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
+}
diff --git a/nx.json b/nx.json
index 5f50461adc..7f7de57643 100644
--- a/nx.json
+++ b/nx.json
@@ -159,6 +159,9 @@
},
"remix-ui-run-tab": {
"tags": []
+ },
+ "remix-ui-permission-handler": {
+ "tags": []
}
},
"targetDependencies": {
diff --git a/tsconfig.base.json b/tsconfig.base.json
index c483b6f07e..8105a813ef 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -76,7 +76,8 @@
"@remix-ui/panel": ["libs/remix-ui/panel/src/index.ts"],
"@remix-ui/editor-context-view": ["libs/remix-ui/editor-context-view/src/index.ts"],
"@remix-ui/solidity-unit-testing": ["libs/remix-ui/solidity-unit-testing/src/index.ts"],
- "@remix-ui/run-tab": ["libs/remix-ui/run-tab/src/index.ts"]
+ "@remix-ui/run-tab": ["libs/remix-ui/run-tab/src/index.ts"],
+ "@remix-ui/permission-handler": ["libs/remix-ui/permission-handler/src/index.ts"]
}
},
"exclude": ["node_modules", "tmp"]
diff --git a/workspace.json b/workspace.json
index fa7930463c..5ff3f1ca9f 100644
--- a/workspace.json
+++ b/workspace.json
@@ -1170,6 +1170,21 @@
}
}
}
+ },
+ "remix-ui-permission-handler": {
+ "root": "libs/remix-ui/permission-handler",
+ "sourceRoot": "libs/remix-ui/permission-handler/src",
+ "projectType": "library",
+ "architect": {
+ "lint": {
+ "builder": "@nrwl/linter:lint",
+ "options": {
+ "linter": "eslint",
+ "tsConfig": ["libs/remix-ui/permission-handler/tsconfig.lib.json"],
+ "exclude": ["**/node_modules/**", "libs/remix-ui/permission-handler/**/*.d.ts", "!libs/remix-ui/permission-handler/**/*"]
+ }
+ }
+ }
}
},
"cli": {
From 2f8682835a532608e070fb53dc3d7c5dce2019cb Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Tue, 11 Jan 2022 12:50:12 +0100
Subject: [PATCH 19/28] permission handler
---
apps/remix-ide/src/app.js | 6 +-
.../app/plugins/permission-handler-plugin.tsx | 126 +++++++++++
.../src/app/ui/persmission-handler.js | 202 ------------------
apps/remix-ide/src/remixAppManager.js | 4 +-
.../app/src/lib/remix-app/remix-app.tsx | 2 -
libs/remix-ui/permission-handler/src/index.ts | 3 +-
.../permission-handler/src/interface/index.ts | 8 +-
.../src/lib/permission-dialog.css | 4 +
.../src/lib/permission-dialog.tsx | 34 +--
.../src/lib/permission-handler.tsx | 25 ---
package-lock.json | 70 +++---
package.json | 14 +-
12 files changed, 204 insertions(+), 294 deletions(-)
create mode 100644 apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx
delete mode 100644 apps/remix-ide/src/app/ui/persmission-handler.js
delete mode 100644 libs/remix-ui/permission-handler/src/lib/permission-handler.tsx
diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js
index 7038c120cd..5a7c9b8dc0 100644
--- a/apps/remix-ide/src/app.js
+++ b/apps/remix-ide/src/app.js
@@ -10,6 +10,7 @@ import { HiddenPanel } from './app/components/hidden-panel'
import { VerticalIcons } from './app/components/vertical-icons'
import { LandingPage } from './app/ui/landing-page/landing-page'
import { MainPanel } from './app/components/main-panel'
+import { PermissionHandlerPlugin } from './app/plugins/permission-handler-plugin'
import { WalkthroughService } from './walkthroughService'
@@ -191,8 +192,11 @@ class AppComponent {
const configPlugin = new ConfigPlugin()
self.layout = new Layout()
+
+ const permissionHandler = new PermissionHandlerPlugin()
self.engine.register([
+ permissionHandler,
self.layout,
self.modal,
self.gistHandler,
@@ -317,7 +321,7 @@ class AppComponent {
await self.appManager.activatePlugin(['layout'])
await self.appManager.activatePlugin(['modal'])
await self.appManager.activatePlugin(['editor'])
- await self.appManager.activatePlugin(['theme', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter'])
+ await self.appManager.activatePlugin(['permissionhandler', 'theme', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter'])
await self.appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs'])
await self.appManager.activatePlugin(['sidePanel']) // activating host plugin separately
await self.appManager.activatePlugin(['home'])
diff --git a/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx b/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx
new file mode 100644
index 0000000000..530a8dfba2
--- /dev/null
+++ b/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx
@@ -0,0 +1,126 @@
+import React from 'react' // eslint-disable-line
+import { Plugin } from '@remixproject/engine'
+import { AppModal } from 'libs/remix-ui/app/src'
+import { PermissionHandlerDialog, PermissionHandlerValue } from 'libs/remix-ui/permission-handler/src'
+import { Profile } from '@remixproject/plugin-utils'
+
+const profile = {
+ name: 'permissionhandler',
+ displayName: 'permissionhandler',
+ description: 'permissionhandler',
+ methods: ['askPermission']
+}
+
+export class PermissionHandlerPlugin extends Plugin {
+ permissions: any
+ currentVersion: number
+ constructor() {
+ super(profile)
+ this.permissions = this._getFromLocal()
+ this.currentVersion = 1
+ // here we remove the old permissions saved before adding 'permissionVersion'
+ // since with v1 the structure has been changed because of new engine ^0.2.0-alpha.6 changes
+ if (!localStorage.getItem('permissionVersion')) {
+ localStorage.setItem('plugins/permissions', '')
+ localStorage.setItem('permissionVersion', this.currentVersion.toString())
+ }
+ }
+
+ _getFromLocal() {
+ const permission = localStorage.getItem('plugins/permissions')
+ return permission ? JSON.parse(permission) : {}
+ }
+
+ persistPermissions() {
+ const permissions = JSON.stringify(this.permissions)
+ localStorage.setItem('plugins/permissions', permissions)
+ }
+
+ switchMode (from: Profile, to: Profile, method: string, set: boolean) {
+ set
+ ? this.permissions[to.name][method][from.name] = {}
+ : delete this.permissions[to.name][method][from.name]
+ }
+
+ clear() {
+ localStorage.removeItem('plugins/permissions')
+ }
+
+ notAllowWarning(from: Profile, to: Profile, method: string) {
+ return `${from.displayName || from.name} is not allowed to call ${method} method of ${to.displayName || to.name}.`
+ }
+
+ async getTheme() {
+ return (await this.call('theme', 'currentTheme')).quality
+ }
+
+ /**
+ * Check if a plugin has the permission to call another plugin and askPermission if needed
+ * @param {PluginProfile} from the profile of the plugin that make the call
+ * @param {ModuleProfile} to The profile of the module that receive the call
+ * @param {string} method The name of the function to be called
+ * @param {string} message from the caller plugin to add more details if needed
+ * @returns {Promise}
+ */
+ async askPermission(from: Profile, to: Profile, method: string, message: string) {
+ try {
+ this.permissions = this._getFromLocal()
+ if (!this.permissions[to.name]) this.permissions[to.name] = {}
+ if (!this.permissions[to.name][method]) this.permissions[to.name][method] = {}
+ if (!this.permissions[to.name][method][from.name]) return this.openPermission(from, to, method, message)
+
+ const { allow, hash } = this.permissions[to.name][method][from.name]
+ if (!allow) {
+ const warning = this.notAllowWarning(from, to, method)
+ this.call('modal', 'toast', warning)
+ return false
+ }
+ return hash === from.hash
+ ? true // Allow
+ : await this.openPermission(from, to, method, message)
+ } catch (err) {
+ throw new Error(err)
+ }
+ }
+
+ async openPermission(from: Profile, to: Profile, method: string, message: string) {
+ const remember = this.permissions[to.name][method][from.name]
+ const value: PermissionHandlerValue = {
+ from,
+ to,
+ method,
+ message,
+ remember
+ }
+ const modal: AppModal = {
+ id: 'PermissionHandler',
+ title: `Permission needed for ${to.displayName || to.name}`,
+ message: ,
+ okLabel: 'sure',
+ cancelLabel: 'no'
+ }
+
+ const result = await this.call('modal', 'modal', modal)
+ return new Promise((resolve, reject) => {
+ if (result) {
+ if (this.permissions[to.name][method][from.name]) {
+ this.permissions[to.name][method][from.name] = {
+ allow: true,
+ hash: from.hash
+ }
+ this.persistPermissions()
+ }
+ resolve(true)
+ } else {
+ if (this.permissions[to.name][method][from.name]) {
+ this.permissions[to.name][method][from.name] = {
+ allow: false,
+ hash: from.hash
+ }
+ this.persistPermissions()
+ }
+ reject(this.notAllowWarning(from, to, method))
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/apps/remix-ide/src/app/ui/persmission-handler.js b/apps/remix-ide/src/app/ui/persmission-handler.js
deleted file mode 100644
index f3f10b5b63..0000000000
--- a/apps/remix-ide/src/app/ui/persmission-handler.js
+++ /dev/null
@@ -1,202 +0,0 @@
-import Registry from '../state/registry'
-
-/* global localStorage */
-const yo = require('yo-yo')
-const csjs = require('csjs-inject')
-const addTooltip = require('./tooltip')
-const modalDialog = require('./modaldialog')
-
-const css = csjs`
-.permission h4 {
- text-transform: uppercase;
- text-align: center;
-}
-.permission h6 {
- text-transform: uppercase;
-}
-.remember {
- display: flex;
- justify-content: space-between;
- align-items: center;
-}
-.images {
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 10px;
-}
-.images img {
- width: 40px;
- height: 40px;
-}
-.images i {
- margin: 0 20px;
-}
-`
-
-function notAllowWarning (from, to, method) {
- return `${from.displayName || from.name} is not allowed to call ${method} method of ${to.displayName || to.name}.`
-}
-
-export class PermissionHandler {
- constructor () {
- this.permissions = this._getFromLocal()
- this.currentVersion = 1
- // here we remove the old permissions saved before adding 'permissionVersion'
- // since with v1 the structure has been changed because of new engine ^0.2.0-alpha.6 changes
- if (!localStorage.getItem('permissionVersion')) {
- localStorage.setItem('plugins/permissions', '')
- localStorage.setItem('permissionVersion', this.currentVersion)
- }
- }
-
- _getFromLocal () {
- const permission = localStorage.getItem('plugins/permissions')
- return permission ? JSON.parse(permission) : {}
- }
-
- persistPermissions () {
- const permissions = JSON.stringify(this.permissions)
- localStorage.setItem('plugins/permissions', permissions)
- }
-
- clear () {
- localStorage.removeItem('plugins/permissions')
- addTooltip('All Permissions have been reset')
- }
-
- /**
- * Show a message to ask the user for a permission
- * @param {PluginProfile} from The name and hash of the plugin that make the call
- * @param {ModuleProfile} to The name of the plugin that receive the call
- * @param {string} method The name of the function to be called
- * @param {string} message from the caller plugin to add more details if needed
- * @returns {Promise<{ allow: boolean; remember: boolean }} Answer from the user to the permission
- */
- async openPermission (from, to, method, message) {
- return new Promise((resolve, reject) => {
- modalDialog(
- `Permission needed for ${to.displayName || to.name}`,
- this.form(from, to, method, message),
- {
- label: 'Accept',
- fn: () => {
- if (this.permissions[to.name][method][from.name]) {
- this.permissions[to.name][method][from.name] = {
- allow: true,
- hash: from.hash
- }
- this.persistPermissions()
- }
- resolve(true)
- }
- },
- {
- label: 'Decline',
- fn: () => {
- if (this.permissions[to.name][method][from.name]) {
- this.permissions[to.name][method][from.name] = {
- allow: false,
- hash: from.hash
- }
- this.persistPermissions()
- }
- reject(notAllowWarning(from, to, method))
- }
- }
- )
- })
- }
-
- /**
- * Check if a plugin has the permission to call another plugin and askPermission if needed
- * @param {PluginProfile} from the profile of the plugin that make the call
- * @param {ModuleProfile} to The profile of the module that receive the call
- * @param {string} method The name of the function to be called
- * @param {string} message from the caller plugin to add more details if needed
- * @returns {Promise}
- */
- async askPermission (from, to, method, message) {
- try {
- this.permissions = this._getFromLocal()
- if (!this.permissions[to.name]) this.permissions[to.name] = {}
- if (!this.permissions[to.name][method]) this.permissions[to.name][method] = {}
- if (!this.permissions[to.name][method][from.name]) return this.openPermission(from, to, method, message)
-
- const { allow, hash } = this.permissions[to.name][method][from.name]
- if (!allow) {
- const warning = notAllowWarning(from, to, method)
- addTooltip(warning)
- return false
- }
- return hash === from.hash
- ? true // Allow
- : this.openPermission(from, to, method, message) // New version of a plugin
- } catch (err) {
- throw new Error(err)
- }
- }
-
- /**
- * The permission form
- * @param {PluginProfile} from The name and hash of the plugin that make the call
- * @param {ModuleProfile} to The name of the plugin that receive the call
- * @param {string} method The name of te methode to be called
- * @param {string} message from the caller plugin to add more details if needed
- */
- form (from, to, method, message) {
- const fromName = from.displayName || from.name
- const toName = to.displayName || to.name
- const remember = this.permissions[to.name][method][from.name]
-
- const switchMode = (e) => {
- e.target.checked
- ? this.permissions[to.name][method][from.name] = {}
- : delete this.permissions[to.name][method][from.name]
- }
- const rememberSwitch = remember
- ? yo` `
- : yo` `
- const text = `"${fromName}" ${(remember ? 'has changed and' : '')} would like to access to "${method}" of "${toName}"`
- const imgFrom = yo` `
- const imgTo = yo` `
- const pluginsImages = yo`
-
- ${imgFrom}
-
- ${imgTo}
-
- `
-
- Registry.getInstance().get('themeModule').api.fixInvert(imgFrom)
- Registry.getInstance().get('themeModule').api.fixInvert(imgTo)
-
- const pluginMessage = message ? yo`
-
-
Description
-
${message}
-
- ` : ''
- return yo`
-
- ${pluginsImages}
-
- ${text} :
- ${fromName}
- ${from.description || yo`No description Provided `}
- ${toName} :
- ${to.description || yo`No description Provided `}
- ${pluginMessage}
-
-
-
-
- ${rememberSwitch}
- Remember this choice
-
- Reset all Permissions
-
-
- `
- }
-}
diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js
index 5f5fa2f8eb..dcfd1fe385 100644
--- a/apps/remix-ide/src/remixAppManager.js
+++ b/apps/remix-ide/src/remixAppManager.js
@@ -2,7 +2,6 @@
import { PluginManager } from '@remixproject/engine'
import { EventEmitter } from 'events'
import QueryParams from './lib/query-params'
-import { PermissionHandler } from './app/ui/persmission-handler'
import { IframePlugin } from '@remixproject/engine-web'
const _paq = window._paq = window._paq || []
@@ -40,7 +39,6 @@ export class RemixAppManager extends PluginManager {
this.event = new EventEmitter()
this.pluginsDirectory = 'https://raw.githubusercontent.com/ethereum/remix-plugins-directory/master/build/metadata.json'
this.pluginLoader = new PluginLoader()
- this.permissionHandler = new PermissionHandler()
}
async canActivatePlugin (from, to) {
@@ -72,7 +70,7 @@ export class RemixAppManager extends PluginManager {
return true
}
// ask the user for permission
- return await this.permissionHandler.askPermission(this.profiles[from], this.profiles[to], method, message)
+ return await this.call('permissionhandler', 'askPermission', this.profiles[from], this.profiles[to], method, message)
}
onPluginActivated (plugin) {
diff --git a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx
index 605dcae501..27d5a7b832 100644
--- a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx
+++ b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx
@@ -8,7 +8,6 @@ import DragBar from './components/dragbar/dragbar'
import { AppProvider } from './context/provider'
import AppDialogs from './components/modals/dialogs'
import DialogViewPlugin from './components/modals/dialogViewPlugin'
-import { Permissionhandler } from '@remix-ui/permission-handler'
interface IRemixAppUi {
app: any
@@ -105,7 +104,6 @@ const RemixApp = (props: IRemixAppUi) => {
{components.hiddenPanel}
-
)
}
diff --git a/libs/remix-ui/permission-handler/src/index.ts b/libs/remix-ui/permission-handler/src/index.ts
index 6e662ed485..dfa55cfc9d 100644
--- a/libs/remix-ui/permission-handler/src/index.ts
+++ b/libs/remix-ui/permission-handler/src/index.ts
@@ -1 +1,2 @@
-export { default as Permissionhandler } from './lib/permission-handler'
+export { default as PermissionHandlerDialog } from './lib/permission-dialog'
+export { PermissionHandlerValue, PermissionHandlerProps } from './interface/index'
diff --git a/libs/remix-ui/permission-handler/src/interface/index.ts b/libs/remix-ui/permission-handler/src/interface/index.ts
index 7fbbbaaa34..a24c8570c6 100644
--- a/libs/remix-ui/permission-handler/src/interface/index.ts
+++ b/libs/remix-ui/permission-handler/src/interface/index.ts
@@ -1,8 +1,8 @@
-import { IconProfile } from 'libs/remix-ui/vertical-icons-panel/src/lib/components/Icon'
+import { Profile } from '@remixproject/plugin-utils'
export interface PermissionHandlerValue {
- from: IconProfile,
- to: IconProfile,
+ from: Profile,
+ to: Profile,
remember: boolean,
method: string,
message: string
@@ -10,4 +10,6 @@ export interface PermissionHandlerValue {
export interface PermissionHandlerProps {
value: PermissionHandlerValue
+ theme: string
+ plugin: any
}
diff --git a/libs/remix-ui/permission-handler/src/lib/permission-dialog.css b/libs/remix-ui/permission-handler/src/lib/permission-dialog.css
index b2584800b1..68e0d845b5 100644
--- a/libs/remix-ui/permission-handler/src/lib/permission-dialog.css
+++ b/libs/remix-ui/permission-handler/src/lib/permission-dialog.css
@@ -22,4 +22,8 @@
}
.images i {
margin: 0 20px;
+ }
+
+ .invert {
+ filter: invert(1);
}
\ No newline at end of file
diff --git a/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx b/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx
index 4550064754..5d7928b2f4 100644
--- a/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx
+++ b/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx
@@ -1,35 +1,38 @@
-import React, { useContext, useEffect, useRef, useState } from 'react' // eslint-disable-line
+import React, { ChangeEventHandler, useContext, useEffect, useRef, useState } from 'react' // eslint-disable-line
import { PermissionHandlerProps } from '../interface'
import './permission-dialog.css'
const PermissionHandlerDialog = (props: PermissionHandlerProps) => {
const { from, to, remember, method, message } = props.value
+ const [feedback, setFeedback] = useState('')
+ const theme = props.theme
- const switchMode = () => {
-
+ const switchMode = (e: any) => {
+ props.plugin.switchMode(from, to, method, e.target.checked)
}
const rememberSwitch = () => {
return
}
const reset = () => {
-
+ props.plugin.clear()
+ setFeedback('All permisssions have been reset.')
}
- const imgFrom = () => { return }
- const imgTo = () => { return }
+ const imgFrom = () => { return }
+ const imgTo = () => { return }
const pluginsImages = () => {
return (
- {imgFrom}
+ {imgFrom()}
- {imgTo}
+ {imgTo()}
)
}
const text = () => {
- return `"${from.displayName}" ${(remember ? 'has changed and' : '')} would like to access to "${method}" of "${to.displayName}"`
+ return <>"{from.displayName}" {(remember ? 'has changed and' : '')} would like to access to "{method}" of "{to.displayName}"`>
}
const pluginMessage = () => {
@@ -41,22 +44,23 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => {
}
return (
- {pluginsImages}
+ {pluginsImages()}
- {text} :
+ {text()} :
{from.displayName}
- {from.description} || No description Provided
+ {from.description || No description Provided }
{to.displayName} :
- {to.description} || No description Provided
- {pluginMessage}
+ {to.description || No description Provided }
+ {pluginMessage()}
- {rememberSwitch}
+ {rememberSwitch()}
Remember this choice
Reset all Permissions
+ {feedback}
)
}
diff --git a/libs/remix-ui/permission-handler/src/lib/permission-handler.tsx b/libs/remix-ui/permission-handler/src/lib/permission-handler.tsx
deleted file mode 100644
index f6b06c23f4..0000000000
--- a/libs/remix-ui/permission-handler/src/lib/permission-handler.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import { useDialogDispatchers } from 'libs/remix-ui/app/src/lib/remix-app/context/provider'
-import React, { useContext, useEffect, useRef, useState } from 'react' // eslint-disable-line
-import { PermissionHandlerValue } from '../interface'
-import PermissionHandlerDialog from './permission-dialog'
-
-const PermissionHandler = () => {
- const { alert, toast, modal } = useDialogDispatchers()
- const [value, setValue] = useState()
- useEffect(() => {
- if (value) {
- modal({
- id: 'PermissionHandler',
- title: 'permissions',
- message: ,
- okFn: () => {},
- cancelFn: () => {},
- okLabel: 'sure',
- cancelLabel: 'no'
- })
- }
- }, [value])
- return (<>>)
-}
-
-export default PermissionHandler
diff --git a/package-lock.json b/package-lock.json
index bab7da51d1..e28009392f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9782,46 +9782,46 @@
"integrity": "sha512-IXf3XA7+XyN7CP9gGh/XB0UxVMlvARGEgGXLubFICsUMGz6Q+DU+i4gGlpOxTjKvXjkJDJC8YdqdKkDj9qZHEQ=="
},
"@remixproject/engine": {
- "version": "0.3.24",
- "resolved": "https://registry.npmjs.org/@remixproject/engine/-/engine-0.3.24.tgz",
- "integrity": "sha512-XVPaRIAwxTxEmc+u+bq9nIqUcP1NDdQFTm/8xmw8HcZicgagUW/y0RuLEMBj5GTGXF+EsljY27t6bPy7fmVHWQ==",
+ "version": "0.3.25",
+ "resolved": "https://registry.npmjs.org/@remixproject/engine/-/engine-0.3.25.tgz",
+ "integrity": "sha512-6XaXZ6BHKEoYfnAQSN7Hy2UZt8M/rKA2Vfq6Wy2tYocfzHVRXb3PeZncdumeO4vdnTldbrrRhgn4i4/ORcYAnA==",
"requires": {
- "@remixproject/plugin-api": "0.3.24",
- "@remixproject/plugin-utils": "0.3.24"
+ "@remixproject/plugin-api": "0.3.25",
+ "@remixproject/plugin-utils": "0.3.25"
}
},
"@remixproject/engine-web": {
- "version": "0.3.24",
- "resolved": "https://registry.npmjs.org/@remixproject/engine-web/-/engine-web-0.3.24.tgz",
- "integrity": "sha512-6P2NLoL9KSa/84FumEM3QxvOW4g/hIEsq8NcbBA+/PHz9VnIRoxRg2K/jGJUHHqKw+dfoSdk5lQ+LkFQHcrp+w==",
+ "version": "0.3.25",
+ "resolved": "https://registry.npmjs.org/@remixproject/engine-web/-/engine-web-0.3.25.tgz",
+ "integrity": "sha512-RzmDDE7Eh+gW1A/pQkGovQA+A6dRPKGfFmkShXcCkKZghNKc+DSCCKkgVxfYu2ckgr5Q5N11tBiAA+5OFduLRg==",
"requires": {
- "@remixproject/engine": "0.3.24",
- "@remixproject/plugin-api": "0.3.24",
- "@remixproject/plugin-utils": "0.3.24"
+ "@remixproject/engine": "0.3.25",
+ "@remixproject/plugin-api": "0.3.25",
+ "@remixproject/plugin-utils": "0.3.25"
}
},
"@remixproject/plugin": {
- "version": "0.3.24",
- "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.24.tgz",
- "integrity": "sha512-nGtt3IZA5X2kcXauu5h5P8EEoMtHbVGm5wWnv0c7aYYWbffhQdK8dqtNNEAtQavWrsp5TL61zekqpkFzgxVv9w==",
+ "version": "0.3.25",
+ "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.25.tgz",
+ "integrity": "sha512-EVFtZ42+BmfZ+6UWcTo7Ig+7RQ1LiaBe4hnM8lQVyVhKqsYnev7/NAQycDmrtTSZR7kaLhy/nH3vTfxryleqQw==",
"requires": {
- "@remixproject/plugin-api": "0.3.24",
- "@remixproject/plugin-utils": "0.3.24",
+ "@remixproject/plugin-api": "0.3.25",
+ "@remixproject/plugin-utils": "0.3.25",
"events": "3.2.0"
}
},
"@remixproject/plugin-api": {
- "version": "0.3.24",
- "resolved": "https://registry.npmjs.org/@remixproject/plugin-api/-/plugin-api-0.3.24.tgz",
- "integrity": "sha512-mBxou9OSsQt7ggMmKTJR433jJaSAckBmVj82Ek7i/+EGxEAxSqKhPfRlh5sFiTgvUmzHQzuvqa8ndyw0Bbcq4w==",
+ "version": "0.3.25",
+ "resolved": "https://registry.npmjs.org/@remixproject/plugin-api/-/plugin-api-0.3.25.tgz",
+ "integrity": "sha512-GPjPfGRv955En5AILLYf62zqZdALuDCJiq3DKR1XdkVukbI9Soc2FcGs8O2phNhqieIjgXMoUcl1Or6brfuLAw==",
"requires": {
- "@remixproject/plugin-utils": "0.3.24"
+ "@remixproject/plugin-utils": "0.3.25"
}
},
"@remixproject/plugin-utils": {
- "version": "0.3.24",
- "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.24.tgz",
- "integrity": "sha512-nMXGCgs6filbgUc/Zvh1gReGG5HN2Bq+AI4Q7Ao08Thhg5ALj1UsbzQf86Ya/L7Q+EF6Em1CbgPT0VhcGlP66A==",
+ "version": "0.3.25",
+ "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.25.tgz",
+ "integrity": "sha512-FzOKItdfwbQBYlFcK+erLu/ol1htxjAYeuvpxZ1CzbuMXtupA/GW58vCYzIbNZqd0LlYGqIUgEY+fsm3QuU41w==",
"requires": {
"tslib": "2.0.1"
},
@@ -9834,13 +9834,13 @@
}
},
"@remixproject/plugin-webview": {
- "version": "0.3.24",
- "resolved": "https://registry.npmjs.org/@remixproject/plugin-webview/-/plugin-webview-0.3.24.tgz",
- "integrity": "sha512-Wcyi+gGq1AYprE58vhQS181swAKZpoLAfKlKuHJ+ezbysUDuX8jgsEiQ6u1c17nQfy8Hp9sntK6VcCcDddn8gg==",
+ "version": "0.3.25",
+ "resolved": "https://registry.npmjs.org/@remixproject/plugin-webview/-/plugin-webview-0.3.25.tgz",
+ "integrity": "sha512-pjF1qAjgCFHciIDRKTsu2+9rdopjw6+H0GH5moUCGs9WsxmQT1NyfTxvJB+Qkf9GaWdak+ECBlrcn7DAX29BPA==",
"requires": {
- "@remixproject/plugin": "0.3.24",
- "@remixproject/plugin-api": "0.3.24",
- "@remixproject/plugin-utils": "0.3.24",
+ "@remixproject/plugin": "0.3.25",
+ "@remixproject/plugin-api": "0.3.25",
+ "@remixproject/plugin-utils": "0.3.25",
"axios": "^0.21.1"
},
"dependencies": {
@@ -9855,13 +9855,13 @@
}
},
"@remixproject/plugin-ws": {
- "version": "0.3.24",
- "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.24.tgz",
- "integrity": "sha512-COIROJX61vS2TRH82MflIUlScxLauNtLkMRY7vzncVOIvufApvNc84Ua8Vr6vhSb2tZeWX+u4UTiFnpFDRL7xw==",
+ "version": "0.3.25",
+ "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.25.tgz",
+ "integrity": "sha512-ligtZmDUUpEhtMjt6sD33ibFQmcP6qdybLMA6DL94wW5x6d+aM0K8+dtWYFnK3HPfgbpvqHFf/7A7ulFJphcPg==",
"requires": {
- "@remixproject/plugin": "0.3.24",
- "@remixproject/plugin-api": "0.3.24",
- "@remixproject/plugin-utils": "0.3.24"
+ "@remixproject/plugin": "0.3.25",
+ "@remixproject/plugin-api": "0.3.25",
+ "@remixproject/plugin-utils": "0.3.25"
}
},
"@restart/context": {
diff --git a/package.json b/package.json
index 0e55dd276d..a7c37245dc 100644
--- a/package.json
+++ b/package.json
@@ -147,13 +147,13 @@
"@ethereumjs/tx": "^3.3.2",
"@ethereumjs/vm": "^5.5.3",
"@monaco-editor/react": "^4.3.1",
- "@remixproject/engine": "^0.3.24",
- "@remixproject/engine-web": "^0.3.24",
- "@remixproject/plugin": "^0.3.24",
- "@remixproject/plugin-api": "^0.3.24",
- "@remixproject/plugin-utils": "^0.3.24",
- "@remixproject/plugin-webview": "^0.3.24",
- "@remixproject/plugin-ws": "^0.3.24",
+ "@remixproject/engine": "^0.3.25",
+ "@remixproject/engine-web": "^0.3.25",
+ "@remixproject/plugin": "^0.3.25",
+ "@remixproject/plugin-api": "^0.3.25",
+ "@remixproject/plugin-utils": "^0.3.25",
+ "@remixproject/plugin-webview": "^0.3.25",
+ "@remixproject/plugin-ws": "^0.3.25",
"ansi-gray": "^0.1.1",
"async": "^2.6.2",
"axios": ">=0.21.1",
From 9b0cfc038e3830ee9a8b0d0c482ade4f4628fb76 Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Tue, 11 Jan 2022 13:52:10 +0100
Subject: [PATCH 20/28] fix test
---
apps/remix-ide-e2e/src/tests/plugin_api.ts | 2 +-
apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts
index b303864438..638ffc2b17 100644
--- a/apps/remix-ide-e2e/src/tests/plugin_api.ts
+++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts
@@ -82,7 +82,7 @@ const checkForAcceptAndRemember = async function (browser: NightwatchBrowser) {
// @ts-ignore
browser.frame(0, () => { resolve(true) })
} else {
- browser.waitForElementVisible('//*[@data-id="permissionHandlerRememberUnchecked"]').click('//*[@data-id="permissionHandlerRememberUnchecked"]').waitForElementVisible('//*[@id="modal-footer-ok"]').click('//*[@id="modal-footer-ok"]', () => {
+ browser.waitForElementVisible('//*[@data-id="permissionHandlerRememberUnchecked"]').click('//*[@data-id="permissionHandlerRememberUnchecked"]').waitForElementVisible('//*[@data-id="PermissionHandler-modal-footer-ok-react"]').click('//*[@id="PermissionHandler-modal-footer-ok-react"]', () => {
// @ts-ignore
browser.frame(0, () => { resolve(true) })
})
diff --git a/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx b/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx
index 530a8dfba2..ce76cc7cc6 100644
--- a/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx
+++ b/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx
@@ -96,8 +96,8 @@ export class PermissionHandlerPlugin extends Plugin {
id: 'PermissionHandler',
title: `Permission needed for ${to.displayName || to.name}`,
message: ,
- okLabel: 'sure',
- cancelLabel: 'no'
+ okLabel: 'Accept',
+ cancelLabel: 'Decline'
}
const result = await this.call('modal', 'modal', modal)
From e0e5cc880dd6467a7c27b3b561d222469dc0c9d0 Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Tue, 11 Jan 2022 13:52:56 +0100
Subject: [PATCH 21/28] fix test
---
apps/remix-ide-e2e/src/tests/plugin_api.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts
index 638ffc2b17..d3df343415 100644
--- a/apps/remix-ide-e2e/src/tests/plugin_api.ts
+++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts
@@ -82,7 +82,7 @@ const checkForAcceptAndRemember = async function (browser: NightwatchBrowser) {
// @ts-ignore
browser.frame(0, () => { resolve(true) })
} else {
- browser.waitForElementVisible('//*[@data-id="permissionHandlerRememberUnchecked"]').click('//*[@data-id="permissionHandlerRememberUnchecked"]').waitForElementVisible('//*[@data-id="PermissionHandler-modal-footer-ok-react"]').click('//*[@id="PermissionHandler-modal-footer-ok-react"]', () => {
+ browser.waitForElementVisible('//*[@data-id="permissionHandlerRememberUnchecked"]').click('//*[@data-id="permissionHandlerRememberUnchecked"]').waitForElementVisible('//*[@data-id="PermissionHandler-modal-footer-ok-react"]').click('//*[@data-id="PermissionHandler-modal-footer-ok-react"]', () => {
// @ts-ignore
browser.frame(0, () => { resolve(true) })
})
From bd7244f42bc0096c872302a2a1402255397ed376 Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Tue, 11 Jan 2022 13:55:43 +0100
Subject: [PATCH 22/28] add to required
---
apps/remix-ide/src/remixAppManager.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js
index dcfd1fe385..a841c84f1b 100644
--- a/apps/remix-ide/src/remixAppManager.js
+++ b/apps/remix-ide/src/remixAppManager.js
@@ -8,7 +8,7 @@ const _paq = window._paq = window._paq || []
const requiredModules = [ // services + layout views + system views
'manager', 'config', 'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme',
'fileManager', 'contentImport', 'blockchain', 'web3Provider', 'scriptRunner', 'fetchAndCompile', 'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons',
- 'filePanel', 'terminal', 'settings', 'pluginManager', 'tabs', 'udapp', 'dGitProvider', 'solidity-logic', 'gistHandler', 'layout', 'modal']
+ 'filePanel', 'terminal', 'settings', 'pluginManager', 'tabs', 'udapp', 'dGitProvider', 'solidity-logic', 'gistHandler', 'layout', 'modal', 'permissionhandler']
const dependentModules = ['git', 'hardhat', 'slither'] // module which shouldn't be manually activated (e.g git is activated by remixd)
From a06e7fe6ec62084b4588ea11e19b24a534a533b6 Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Tue, 11 Jan 2022 14:10:03 +0100
Subject: [PATCH 23/28] update plugin
---
package-lock.json | 70 +++++++++++++++++++++++------------------------
package.json | 16 +++++------
2 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index e28009392f..021806d07c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9782,46 +9782,46 @@
"integrity": "sha512-IXf3XA7+XyN7CP9gGh/XB0UxVMlvARGEgGXLubFICsUMGz6Q+DU+i4gGlpOxTjKvXjkJDJC8YdqdKkDj9qZHEQ=="
},
"@remixproject/engine": {
- "version": "0.3.25",
- "resolved": "https://registry.npmjs.org/@remixproject/engine/-/engine-0.3.25.tgz",
- "integrity": "sha512-6XaXZ6BHKEoYfnAQSN7Hy2UZt8M/rKA2Vfq6Wy2tYocfzHVRXb3PeZncdumeO4vdnTldbrrRhgn4i4/ORcYAnA==",
+ "version": "0.3.26",
+ "resolved": "https://registry.npmjs.org/@remixproject/engine/-/engine-0.3.26.tgz",
+ "integrity": "sha512-6Rq6aTUyhtXAaoQamAI8ocFSVy2txpGwu1aoYZGrqova/p/tRWn4/+PU713sffyiAQVBCk7C1z/5VKLm7tUYrQ==",
"requires": {
- "@remixproject/plugin-api": "0.3.25",
- "@remixproject/plugin-utils": "0.3.25"
+ "@remixproject/plugin-api": "0.3.26",
+ "@remixproject/plugin-utils": "0.3.26"
}
},
"@remixproject/engine-web": {
- "version": "0.3.25",
- "resolved": "https://registry.npmjs.org/@remixproject/engine-web/-/engine-web-0.3.25.tgz",
- "integrity": "sha512-RzmDDE7Eh+gW1A/pQkGovQA+A6dRPKGfFmkShXcCkKZghNKc+DSCCKkgVxfYu2ckgr5Q5N11tBiAA+5OFduLRg==",
+ "version": "0.3.26",
+ "resolved": "https://registry.npmjs.org/@remixproject/engine-web/-/engine-web-0.3.26.tgz",
+ "integrity": "sha512-QSW9KVOgHWuRDNqTZIp1jjBeDOXlXQZWYABgljTsC+Nig8EwlyRTfIza9PuCb+MDYT/kID8VgSPXnMrlOtvhjQ==",
"requires": {
- "@remixproject/engine": "0.3.25",
- "@remixproject/plugin-api": "0.3.25",
- "@remixproject/plugin-utils": "0.3.25"
+ "@remixproject/engine": "0.3.26",
+ "@remixproject/plugin-api": "0.3.26",
+ "@remixproject/plugin-utils": "0.3.26"
}
},
"@remixproject/plugin": {
- "version": "0.3.25",
- "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.25.tgz",
- "integrity": "sha512-EVFtZ42+BmfZ+6UWcTo7Ig+7RQ1LiaBe4hnM8lQVyVhKqsYnev7/NAQycDmrtTSZR7kaLhy/nH3vTfxryleqQw==",
+ "version": "0.3.26",
+ "resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.26.tgz",
+ "integrity": "sha512-j0sgl4yDOVJLCuRWOEb/Wo9/fumrWlIpsO0MrtficuhVc1FGhZxKVv8Vdu3x3HgWhXkuhLUMs8VoJ1Ntd9ZkUQ==",
"requires": {
- "@remixproject/plugin-api": "0.3.25",
- "@remixproject/plugin-utils": "0.3.25",
+ "@remixproject/plugin-api": "0.3.26",
+ "@remixproject/plugin-utils": "0.3.26",
"events": "3.2.0"
}
},
"@remixproject/plugin-api": {
- "version": "0.3.25",
- "resolved": "https://registry.npmjs.org/@remixproject/plugin-api/-/plugin-api-0.3.25.tgz",
- "integrity": "sha512-GPjPfGRv955En5AILLYf62zqZdALuDCJiq3DKR1XdkVukbI9Soc2FcGs8O2phNhqieIjgXMoUcl1Or6brfuLAw==",
+ "version": "0.3.26",
+ "resolved": "https://registry.npmjs.org/@remixproject/plugin-api/-/plugin-api-0.3.26.tgz",
+ "integrity": "sha512-6vR9nVF4EfXDHA0r8MrlLyVYRMJMG7J3Y3jzpaAumetW+YpvfJqgE/uhGgm2me2ypDM8vW0POQGhRaGeZTGwFg==",
"requires": {
- "@remixproject/plugin-utils": "0.3.25"
+ "@remixproject/plugin-utils": "0.3.26"
}
},
"@remixproject/plugin-utils": {
- "version": "0.3.25",
- "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.25.tgz",
- "integrity": "sha512-FzOKItdfwbQBYlFcK+erLu/ol1htxjAYeuvpxZ1CzbuMXtupA/GW58vCYzIbNZqd0LlYGqIUgEY+fsm3QuU41w==",
+ "version": "0.3.26",
+ "resolved": "https://registry.npmjs.org/@remixproject/plugin-utils/-/plugin-utils-0.3.26.tgz",
+ "integrity": "sha512-K/v+TXYOMV13dLf1LEgiF7CfqbOc105hC/2oapkSoHKSf3WVyWIUDlBsChRQl7osfUs/zT93q2+jNlLofWQUxg==",
"requires": {
"tslib": "2.0.1"
},
@@ -9834,13 +9834,13 @@
}
},
"@remixproject/plugin-webview": {
- "version": "0.3.25",
- "resolved": "https://registry.npmjs.org/@remixproject/plugin-webview/-/plugin-webview-0.3.25.tgz",
- "integrity": "sha512-pjF1qAjgCFHciIDRKTsu2+9rdopjw6+H0GH5moUCGs9WsxmQT1NyfTxvJB+Qkf9GaWdak+ECBlrcn7DAX29BPA==",
+ "version": "0.3.26",
+ "resolved": "https://registry.npmjs.org/@remixproject/plugin-webview/-/plugin-webview-0.3.26.tgz",
+ "integrity": "sha512-hqWaFapUfcAX2Odsj0ANKvLXQbkzZ/xNONMqE0wRxFRYTIhFGZqFzJVzwSD+U4bSehP1JtzkrxwKBqNyjz5GxQ==",
"requires": {
- "@remixproject/plugin": "0.3.25",
- "@remixproject/plugin-api": "0.3.25",
- "@remixproject/plugin-utils": "0.3.25",
+ "@remixproject/plugin": "0.3.26",
+ "@remixproject/plugin-api": "0.3.26",
+ "@remixproject/plugin-utils": "0.3.26",
"axios": "^0.21.1"
},
"dependencies": {
@@ -9855,13 +9855,13 @@
}
},
"@remixproject/plugin-ws": {
- "version": "0.3.25",
- "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.25.tgz",
- "integrity": "sha512-ligtZmDUUpEhtMjt6sD33ibFQmcP6qdybLMA6DL94wW5x6d+aM0K8+dtWYFnK3HPfgbpvqHFf/7A7ulFJphcPg==",
+ "version": "0.3.26",
+ "resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.26.tgz",
+ "integrity": "sha512-Nerd/2vGb96G6B8pGRCRNAGlO97KnJpbFmpa47SYipgjaq5Yj5iCUY+fbQzMWdGW2W4BrUPE+YBZCkq/KlfbGw==",
"requires": {
- "@remixproject/plugin": "0.3.25",
- "@remixproject/plugin-api": "0.3.25",
- "@remixproject/plugin-utils": "0.3.25"
+ "@remixproject/plugin": "0.3.26",
+ "@remixproject/plugin-api": "0.3.26",
+ "@remixproject/plugin-utils": "0.3.26"
}
},
"@restart/context": {
diff --git a/package.json b/package.json
index a7c37245dc..b7c4a85e11 100644
--- a/package.json
+++ b/package.json
@@ -45,7 +45,7 @@
"workspace-schematic": "nx workspace-schematic",
"dep-graph": "nx dep-graph",
"help": "nx help",
- "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-helper,remix-ui-debugger-ui,remix-ui-workspace,remix-ui-static-analyser,remix-ui-checkbox,remix-ui-settings,remix-core-plugin,remix-ui-renderer,remix-ui-publish-to-storage,remix-ui-solidity-compiler,solidity-unit-testing,remix-ui-plugin-manager,remix-ui-terminal,remix-ui-editor,remix-ui-app,remix-ui-tabs,remix-ui-panel,remix-ui-run-tab",
+ "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-helper,remix-ui-debugger-ui,remix-ui-workspace,remix-ui-static-analyser,remix-ui-checkbox,remix-ui-settings,remix-core-plugin,remix-ui-renderer,remix-ui-publish-to-storage,remix-ui-solidity-compiler,solidity-unit-testing,remix-ui-plugin-manager,remix-ui-terminal,remix-ui-editor,remix-ui-app,remix-ui-tabs,remix-ui-panel,remix-ui-run-tab,remix-ui-permission-handle",
"build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd",
"test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd",
"publish:libs": "npm run build:libs && lerna publish --skip-git && npm run bumpVersion:libs",
@@ -147,13 +147,13 @@
"@ethereumjs/tx": "^3.3.2",
"@ethereumjs/vm": "^5.5.3",
"@monaco-editor/react": "^4.3.1",
- "@remixproject/engine": "^0.3.25",
- "@remixproject/engine-web": "^0.3.25",
- "@remixproject/plugin": "^0.3.25",
- "@remixproject/plugin-api": "^0.3.25",
- "@remixproject/plugin-utils": "^0.3.25",
- "@remixproject/plugin-webview": "^0.3.25",
- "@remixproject/plugin-ws": "^0.3.25",
+ "@remixproject/engine": "^0.3.26",
+ "@remixproject/engine-web": "^0.3.26",
+ "@remixproject/plugin": "^0.3.26",
+ "@remixproject/plugin-api": "^0.3.26",
+ "@remixproject/plugin-utils": "^0.3.26",
+ "@remixproject/plugin-webview": "^0.3.26",
+ "@remixproject/plugin-ws": "^0.3.26",
"ansi-gray": "^0.1.1",
"async": "^2.6.2",
"axios": ">=0.21.1",
From 1484cfae5ae44087f0e1d32cbaebeb0ae5405c68 Mon Sep 17 00:00:00 2001
From: David Disu
Date: Mon, 10 Jan 2022 16:51:05 +0100
Subject: [PATCH 24/28] Remove plugin manager settings and replace old toaster
in file-manager
---
apps/remix-ide/src/app.js | 2 +-
.../components/plugin-manager-component.js | 3 -
.../app/components/plugin-manager-settings.js | 147 ------------------
apps/remix-ide/src/app/files/fileManager.ts | 24 +--
apps/remix-ide/src/app/plugins/modal.tsx | 6 +-
.../app/src/lib/remix-app/actions/modals.ts | 2 +-
.../src/lib/remix-app/context/provider.tsx | 2 +-
.../app/src/lib/remix-app/interface/index.ts | 4 +-
libs/remix-ui/helper/src/index.ts | 1 +
libs/remix-ui/helper/src/lib/components.tsx | 12 ++
libs/remix-ui/helper/tsconfig.json | 6 +
.../lib/components/permissionsSettings.tsx | 6 +-
.../src/lib/components/rootView.tsx | 5 +-
.../src/lib/remix-ui-plugin-manager.tsx | 4 +-
libs/remix-ui/toaster/src/lib/toaster.tsx | 27 +++-
15 files changed, 59 insertions(+), 192 deletions(-)
delete mode 100644 apps/remix-ide/src/app/components/plugin-manager-settings.js
create mode 100644 libs/remix-ui/helper/src/lib/components.tsx
diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js
index 5a7c9b8dc0..9b39076918 100644
--- a/apps/remix-ide/src/app.js
+++ b/apps/remix-ide/src/app.js
@@ -319,7 +319,7 @@ class AppComponent {
console.log("couldn't register iframe plugins", e.message)
}
await self.appManager.activatePlugin(['layout'])
- await self.appManager.activatePlugin(['modal'])
+ await self.appManager.activatePlugin(['notification'])
await self.appManager.activatePlugin(['editor'])
await self.appManager.activatePlugin(['permissionhandler', 'theme', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter'])
await self.appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs'])
diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js
index e86a62da92..72acd7cbf6 100644
--- a/apps/remix-ide/src/app/components/plugin-manager-component.js
+++ b/apps/remix-ide/src/app/components/plugin-manager-component.js
@@ -1,5 +1,4 @@
import { ViewPlugin } from '@remixproject/engine-web'
-import { PluginManagerSettings } from './plugin-manager-settings'
import React from 'react' // eslint-disable-line
import ReactDOM from 'react-dom'
import {RemixUiPluginManager} from '@remix-ui/plugin-manager' // eslint-disable-line
@@ -24,7 +23,6 @@ class PluginManagerComponent extends ViewPlugin {
super(profile)
this.appManager = appManager
this.engine = engine
- this.pluginManagerSettings = new PluginManagerSettings()
this.htmlElement = document.createElement('div')
this.htmlElement.setAttribute('id', 'pluginManager')
this.filter = ''
@@ -90,7 +88,6 @@ class PluginManagerComponent extends ViewPlugin {
ReactDOM.render(
,
this.htmlElement)
}
diff --git a/apps/remix-ide/src/app/components/plugin-manager-settings.js b/apps/remix-ide/src/app/components/plugin-manager-settings.js
deleted file mode 100644
index bdd233ff15..0000000000
--- a/apps/remix-ide/src/app/components/plugin-manager-settings.js
+++ /dev/null
@@ -1,147 +0,0 @@
-const yo = require('yo-yo')
-const csjs = require('csjs-inject')
-const modalDialog = require('../ui/modaldialog')
-
-const css = csjs`
-.remixui_permissions {
- position: sticky;
- bottom: 0;
- display: flex;
- justify-content: flex-end;
- align-items: center;
- padding: 5px 20px;
-}
-.permissions button {
- padding: 2px 5px;
- cursor: pointer;
-}
-.permissionForm h4 {
- font-size: 1.3rem;
- text-align: center;
-}
-.permissionForm h6 {
- font-size: 1.1rem;
-}
-.permissionForm hr {
- width: 80%;
-}
-.permissionKey {
- display: flex;
- justify-content: space-between;
- align-items: center;
-}
-.permissionKey i {
- cursor: pointer;
-}
-.checkbox {
- display: flex;
- align-items: center;
-}
-.checkbox label {
- margin: 0;
- font-size: 1rem;
-}
-`
-
-export class PluginManagerSettings {
- constructor () {
- const fromLocal = window.localStorage.getItem('plugins/permissions')
- this.permissions = JSON.parse(fromLocal || '{}')
- }
-
- openDialog () {
- this.currentSetting = this.settings()
- modalDialog('Plugin Manager Permissions', this.currentSetting,
- { fn: () => this.onValidation() }
- )
- }
-
- onValidation () {
- const permissions = JSON.stringify(this.permissions)
- window.localStorage.setItem('plugins/permissions', permissions)
- }
-
- /** Clear one permission from a plugin */
- clearPersmission (from, to, method) {
- // eslint-disable-next-line no-debugger
- debugger
- if (this.permissions[to] && this.permissions[to][method]) {
- delete this.permissions[to][method][from]
- if (Object.keys(this.permissions[to][method]).length === 0) {
- delete this.permissions[to][method]
- }
- if (Object.keys(this.permissions[to]).length === 0) {
- delete this.permissions[to]
- }
- yo.update(this.currentSetting, this.settings())
- }
- }
-
- /** Clear all persmissions from a plugin */
- clearAllPersmission (to) {
- // eslint-disable-next-line no-debugger
- debugger
- if (!this.permissions[to]) return
- delete this.permissions[to]
- yo.update(this.currentSetting, this.settings())
- }
-
- settings () {
- const permissionByToPlugin = (toPlugin, funcObj) => {
- const permissionByMethod = (methodName, fromPlugins) => {
- const togglePermission = (fromPlugin) => {
- this.permissions[toPlugin][methodName][fromPlugin].allow = !this.permissions[toPlugin][methodName][fromPlugin].allow
- }
- return Object.keys(fromPlugins).map(fromName => {
- const fromPluginPermission = fromPlugins[fromName]
- const checkbox = fromPluginPermission.allow
- ? yo` togglePermission(fromName)} class="mr-2" type="checkbox" checked id="permission-checkbox-${toPlugin}-${methodName}-${toPlugin}" aria-describedby="module ${fromPluginPermission} asks permission for ${methodName}" />`
- : yo` togglePermission(fromName)} class="mr-2" type="checkbox" id="permission-checkbox-${toPlugin}-${methodName}-${toPlugin}" aria-describedby="module ${fromPluginPermission} asks permission for ${methodName}" />`
- return yo`
-
- `
- })
- }
-
- const permissionsByFunctions = Object
- .keys(funcObj)
- .map(methodName => permissionByMethod(methodName, funcObj[methodName]))
-
- return yo`
-
-
-
${toPlugin} permissions:
-
-
- ${permissionsByFunctions}
-
`
- }
-
- const byToPlugin = Object
- .keys(this.permissions)
- .map(toPlugin => permissionByToPlugin(toPlugin, this.permissions[toPlugin]))
-
- const title = byToPlugin.length === 0
- ? yo`No Permission requested yet. `
- : yo`Current Permission settings `
-
- return yo``
- }
-
- render () {
- return yo`
- `
- }
-}
diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts
index 14aa2d424c..7a1b7c375b 100644
--- a/apps/remix-ide/src/app/files/fileManager.ts
+++ b/apps/remix-ide/src/app/files/fileManager.ts
@@ -1,13 +1,11 @@
'use strict'
-
-import yo from 'yo-yo'
import async from 'async'
import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../../../package.json'
import Registry from '../state/registry'
import { EventEmitter } from 'events'
import { RemixAppManager } from '../../../../../libs/remix-ui/plugin-manager/src/types'
-const toaster = require('../ui/tooltip')
+import { fileChangedToasterMsg } from '@remix-ui/helper'
const helper = require('../../lib/helper.js')
/*
@@ -317,7 +315,7 @@ class FileManager extends Plugin {
if (isFile) {
if (newPathExists) {
- this.call('modal', 'alert', {
+ this.call('notification', 'alert', {
id: 'fileManagerAlert',
message: 'File already exists'
})
@@ -326,7 +324,7 @@ class FileManager extends Plugin {
return provider.rename(oldPath, newPath, false)
} else {
if (newPathExists) {
- this.call('modal', 'alert', {
+ this.call('notification', 'alert', {
id: 'fileManagerAlert',
message: 'Directory already exists'
})
@@ -528,17 +526,7 @@ class FileManager extends Plugin {
const required = this.appManager.isRequired(this.currentRequest.from)
if (canCall && !required) {
// inform the user about modification after permission is granted and even if permission was saved before
- toaster(yo`
-
-
-
- ${this.currentRequest.from}
-
- is modifying
- ${path}
-
-
- `, '', { time: 3000 })
+ this.call('notification','toast', fileChangedToasterMsg(this.currentRequest.from, path))
}
}
return await this._setFileInternal(path, content)
@@ -778,12 +766,12 @@ class FileManager extends Plugin {
helper.createNonClashingName(file, self._deps.filesProviders[fileProvider],
(error, name) => {
if (error) {
- this.call('modal', 'alert', {
+ this.call('notification', 'alert', {
id: 'fileManagerAlert',
message: 'Unexpected error loading file ' + file + ': ' + error
})
} else if (helper.checkSpecialChars(name)) {
- this.call('modal', 'alert', {
+ this.call('notification', 'alert', {
id: 'fileManagerAlert',
message: 'Special characters are not allowed in file names.'
})
diff --git a/apps/remix-ide/src/app/plugins/modal.tsx b/apps/remix-ide/src/app/plugins/modal.tsx
index f5a855f0c2..d96e9b93f2 100644
--- a/apps/remix-ide/src/app/plugins/modal.tsx
+++ b/apps/remix-ide/src/app/plugins/modal.tsx
@@ -14,9 +14,9 @@ interface IModalApi {
}
const profile:LibraryProfile = {
- name: 'modal',
- displayName: 'Modal',
- description: 'Modal',
+ name: 'notification',
+ displayName: 'Notification',
+ description: 'Displays notifications',
methods: ['modal', 'alert', 'toast']
}
diff --git a/libs/remix-ui/app/src/lib/remix-app/actions/modals.ts b/libs/remix-ui/app/src/lib/remix-app/actions/modals.ts
index 95400ca77b..3a1788a8ad 100644
--- a/libs/remix-ui/app/src/lib/remix-app/actions/modals.ts
+++ b/libs/remix-ui/app/src/lib/remix-app/actions/modals.ts
@@ -21,7 +21,7 @@ export const enum modalActionTypes {
type ModalPayload = {
[modalActionTypes.setModal]: AppModal
[modalActionTypes.handleHideModal]: any
- [modalActionTypes.setToast]: string
+ [modalActionTypes.setToast]: string | JSX.Element
[modalActionTypes.handleToaster]: any
}
diff --git a/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx b/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx
index 61b98a4873..ab444470f6 100644
--- a/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx
+++ b/libs/remix-ui/app/src/lib/remix-app/context/provider.tsx
@@ -30,7 +30,7 @@ export const ModalProvider = ({ children = [], reducer = modalReducer, initialSt
})
}
- const toast = (message: string) => {
+ const toast = (message: string | JSX.Element) => {
dispatch({
type: modalActionTypes.setToast,
payload: message
diff --git a/libs/remix-ui/app/src/lib/remix-app/interface/index.ts b/libs/remix-ui/app/src/lib/remix-app/interface/index.ts
index 6546f22b0f..46aacf70b8 100644
--- a/libs/remix-ui/app/src/lib/remix-app/interface/index.ts
+++ b/libs/remix-ui/app/src/lib/remix-app/interface/index.ts
@@ -24,7 +24,7 @@ export interface AlertModal {
export interface ModalState {
modals: AppModal[],
- toasters: string[],
+ toasters: string[] | JSX.Element[],
focusModal: AppModal,
- focusToaster: string
+ focusToaster: string | JSX.Element
}
diff --git a/libs/remix-ui/helper/src/index.ts b/libs/remix-ui/helper/src/index.ts
index 961f14639b..0bd8695a4a 100644
--- a/libs/remix-ui/helper/src/index.ts
+++ b/libs/remix-ui/helper/src/index.ts
@@ -1 +1,2 @@
export * from './lib/remix-ui-helper'
+export * from './lib/components'
diff --git a/libs/remix-ui/helper/src/lib/components.tsx b/libs/remix-ui/helper/src/lib/components.tsx
new file mode 100644
index 0000000000..361a4e1d87
--- /dev/null
+++ b/libs/remix-ui/helper/src/lib/components.tsx
@@ -0,0 +1,12 @@
+import React from 'react'
+
+export const fileChangedToasterMsg = (from: string, path: string) => (
+
+
+ {from}
+
+ is modifying
+ {path}
+
+
+)
\ No newline at end of file
diff --git a/libs/remix-ui/helper/tsconfig.json b/libs/remix-ui/helper/tsconfig.json
index f4023e39ff..d52e31ad74 100644
--- a/libs/remix-ui/helper/tsconfig.json
+++ b/libs/remix-ui/helper/tsconfig.json
@@ -1,5 +1,11 @@
{
"extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "jsx": "react",
+ "allowJs": true,
+ "esModuleInterop": true,
+ "allowSyntheticDefaultImports": true
+ },
"files": [],
"include": [],
"references": [
diff --git a/libs/remix-ui/plugin-manager/src/lib/components/permissionsSettings.tsx b/libs/remix-ui/plugin-manager/src/lib/components/permissionsSettings.tsx
index 690dadad8a..5936ec3f0d 100644
--- a/libs/remix-ui/plugin-manager/src/lib/components/permissionsSettings.tsx
+++ b/libs/remix-ui/plugin-manager/src/lib/components/permissionsSettings.tsx
@@ -5,11 +5,7 @@ import { ModalDialog } from '@remix-ui/modal-dialog'
import useLocalStorage from '../custom-hooks/useLocalStorage'
import { PluginPermissions } from '../../types'
-interface PermissionSettingsProps {
- pluginSettings: any
-}
-
-function PermisssionsSettings ({ pluginSettings }: PermissionSettingsProps) {
+function PermisssionsSettings () {
const [modalVisibility, setModalVisibility] = useState(true)
const [permissions, setPermissions] = useLocalStorage('plugins/permissions', {} as PluginPermissions)
const [permissionCache, setpermissionCache] = useState()
diff --git a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx
index 0e6d377146..1359e04ec3 100644
--- a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx
+++ b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx
@@ -7,7 +7,6 @@ import LocalPluginForm from './LocalPluginForm'
interface RootViewProps {
pluginComponent: PluginManagerComponent
- pluginManagerSettings: PluginManagerSettings
children: ReactNode
}
@@ -21,7 +20,7 @@ export interface pluginActivated {
profile: Profile
}
-function RootView ({ pluginComponent, pluginManagerSettings, children }: RootViewProps) {
+function RootView ({ pluginComponent, children }: RootViewProps) {
const [visible, setVisible] = useState(true)
const [filterPlugins, setFilterPlugin] = useState('')
@@ -52,7 +51,7 @@ function RootView ({ pluginComponent, pluginManagerSettings, children }: RootVie
{children}
-
+
{
+export const RemixUiPluginManager = ({ pluginComponent }: RemixUiPluginManagerProps) => {
const [activeProfiles, setActiveProfiles] = useState(pluginComponent.activePlugins)
const [inactiveProfiles, setinactiveProfiles] = useState(pluginComponent.inactivePlugins)
return (
-
+
void
}
export const Toaster = (props: ToasterProps) => {
- const [state, setState] = useState({
+ const [state, setState] = useState<{
+ message: string | JSX.Element,
+ hide: boolean,
+ hiding: boolean,
+ timeOutId: any,
+ timeOut: number,
+ showModal: boolean,
+ showFullBtn: boolean
+ }>({
message: '',
hide: true,
hiding: false,
timeOutId: null,
timeOut: props.timeOut || 7000,
- showModal: false
+ showModal: false,
+ showFullBtn: false
})
useEffect(() => {
@@ -29,9 +38,15 @@ export const Toaster = (props: ToasterProps) => {
}, state.timeOut)
setState(prevState => {
- const shortTooltipText = props.message.length > 201 ? props.message.substring(0, 200) + '...' : props.message
+ if (typeof props.message === 'string' && (props.message.length > 201)) {
+ const shortTooltipText = props.message.substring(0, 200) + '...'
- return { ...prevState, hide: false, hiding: false, timeOutId, message: shortTooltipText }
+ return { ...prevState, hide: false, hiding: false, timeOutId, message: shortTooltipText }
+ } else {
+ const shortTooltipText = props.message
+
+ return { ...prevState, hide: false, hiding: false, timeOutId, message: shortTooltipText }
+ }
})
}
}, [props.message])
@@ -103,7 +118,7 @@ export const Toaster = (props: ToasterProps) => {
{ state.message }
- { (props.message.length > 201) && Show full message }
+ { state.showFullBtn && Show full message }
From 403354735854d8cb7239eccfa468585f4a90aec8 Mon Sep 17 00:00:00 2001
From: David Disu
Date: Tue, 11 Jan 2022 14:01:47 +0100
Subject: [PATCH 25/28] Replace yo-yo toaster with new toaster plugin call in
debugger and compiler plugins
---
apps/remix-ide/src/app/files/fileManager.ts | 4 +-
apps/remix-ide/src/app/files/fileProvider.js | 8 +--
apps/remix-ide/src/app/tabs/compile-tab.js | 19 +++----
apps/remix-ide/src/app/tabs/debugger-tab.js | 33 +++++------
.../app/src/lib/remix-app/interface/index.ts | 2 +-
libs/remix-ui/helper/src/index.ts | 2 +-
libs/remix-ui/helper/src/lib/components.tsx | 12 ----
.../helper/src/lib/helper-components.tsx | 55 +++++++++++++++++++
8 files changed, 84 insertions(+), 51 deletions(-)
delete mode 100644 libs/remix-ui/helper/src/lib/components.tsx
create mode 100644 libs/remix-ui/helper/src/lib/helper-components.tsx
diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts
index 7a1b7c375b..1c4a3e61bf 100644
--- a/apps/remix-ide/src/app/files/fileManager.ts
+++ b/apps/remix-ide/src/app/files/fileManager.ts
@@ -5,7 +5,7 @@ import * as packageJson from '../../../../../package.json'
import Registry from '../state/registry'
import { EventEmitter } from 'events'
import { RemixAppManager } from '../../../../../libs/remix-ui/plugin-manager/src/types'
-import { fileChangedToasterMsg } from '@remix-ui/helper'
+import { fileChangedToastMsg } from '@remix-ui/helper'
const helper = require('../../lib/helper.js')
/*
@@ -526,7 +526,7 @@ class FileManager extends Plugin {
const required = this.appManager.isRequired(this.currentRequest.from)
if (canCall && !required) {
// inform the user about modification after permission is granted and even if permission was saved before
- this.call('notification','toast', fileChangedToasterMsg(this.currentRequest.from, path))
+ this.call('notification','toast', fileChangedToastMsg(this.currentRequest.from, path))
}
}
return await this._setFileInternal(path, content)
diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js
index d5873e43ef..9ab67a84b3 100644
--- a/apps/remix-ide/src/app/files/fileProvider.js
+++ b/apps/remix-ide/src/app/files/fileProvider.js
@@ -2,8 +2,6 @@
import { CompilerImports } from '@remix-project/core-plugin'
const EventManager = require('events')
-const modalDialogCustom = require('../ui/modal-dialog-custom')
-const tooltip = require('../ui/tooltip')
const remixLib = require('@remix-project/remix-lib')
const Storage = remixLib.Storage
@@ -49,7 +47,7 @@ class FileProvider {
return this.externalFolders.includes(path)
}
- discardChanges (path) {
+ discardChanges (path, toastCb, modalCb) {
this.remove(path)
const compilerImport = new CompilerImports()
this.providerExternalsStorage.keys().map(value => {
@@ -57,10 +55,10 @@ class FileProvider {
compilerImport.import(
this.getNormalizedName(value),
true,
- (loadingMsg) => { tooltip(loadingMsg) },
+ (loadingMsg) => { toastCb(loadingMsg) },
(error, content, cleanUrl, type, url) => {
if (error) {
- modalDialogCustom.alert(error)
+ modalCb(error)
} else {
this.addExternal(type + '/' + cleanUrl, content, url)
}
diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js
index f409129bb1..bcc11fa2dd 100644
--- a/apps/remix-ide/src/app/tabs/compile-tab.js
+++ b/apps/remix-ide/src/app/tabs/compile-tab.js
@@ -8,11 +8,7 @@ import { ViewPlugin } from '@remixproject/engine-web'
import QueryParams from '../../lib/query-params'
// import { ICompilerApi } from '@remix-project/remix-lib-ts'
import * as packageJson from '../../../../../package.json'
-
-const yo = require('yo-yo')
-const addTooltip = require('../ui/tooltip')
-
-const css = require('./styles/compile-tab-styles')
+import { compilerConfigChangedToastMsg, compileToastMsg } from '@remix-ui/helper'
const profile = {
name: 'solidity',
@@ -41,6 +37,8 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA
this.compiler = this.compileTabLogic.compiler
this.compileTabLogic.init()
this.initCompilerApi()
+ this.el = document.createElement('div')
+ this.el.setAttribute('id', 'compileTabView')
}
renderComponent () {
@@ -70,11 +68,6 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA
}
render () {
- if (this.el) return this.el
- this.el = yo`
- `
this.renderComponent()
return this.el
@@ -101,11 +94,13 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA
super.setCompilerConfig(settings)
this.renderComponent()
// @todo(#2875) should use loading compiler return value to check whether the compiler is loaded instead of "setInterval"
- addTooltip(yo`${this.currentRequest.from} is updating the
Solidity compiler configuration .
${JSON.stringify(settings, null, '\t')} `)
+ const value = JSON.stringify(settings, null, '\t')
+
+ this.call('notification', 'toast', compilerConfigChangedToastMsg(this.currentRequest.from, value))
}
compile (fileName) {
- addTooltip(yo`${this.currentRequest.from} is requiring to compile ${fileName}
`)
+ this.call('notification', 'toast', compileToastMsg(this.currentRequest.from, fileName))
super.compile(fileName)
}
diff --git a/apps/remix-ide/src/app/tabs/debugger-tab.js b/apps/remix-ide/src/app/tabs/debugger-tab.js
index 97fc748e91..741a433795 100644
--- a/apps/remix-ide/src/app/tabs/debugger-tab.js
+++ b/apps/remix-ide/src/app/tabs/debugger-tab.js
@@ -1,14 +1,12 @@
-import toaster from '../ui/tooltip'
import { DebuggerUI } from '@remix-ui/debugger-ui' // eslint-disable-line
import { DebuggerApiMixin } from '@remixproject/debugger-plugin'
import { ViewPlugin } from '@remixproject/engine-web'
import * as packageJson from '../../../../../package.json'
import React from 'react' // eslint-disable-line
import ReactDOM from 'react-dom'
-import modalDialogCustom from '../ui/modal-dialog-custom'
import * as remixBleach from '../../lib/remixBleach'
+import { compilationFinishedToastMsg, compilingToastMsg, localCompilationToastMsg, notFoundToastMsg, sourceVerificationNotAvailableToastMsg } from '@remix-ui/helper'
const css = require('./styles/debugger-tab-styles')
-const yo = require('yo-yo')
const profile = {
name: 'debugger',
@@ -26,46 +24,45 @@ const profile = {
export class DebuggerTab extends DebuggerApiMixin(ViewPlugin) {
constructor () {
super(profile)
- this.el = null
+ this.el = document.createElement('div')
+ this.el.setAttribute('id', 'debugView')
+ this.el.classList.add(css.debuggerTabView)
this.initDebuggerApi()
}
render () {
- if (this.el) return this.el
-
- this.el = yo`
- `
-
this.on('fetchAndCompile', 'compiling', (settings) => {
- toaster(yo`Recompiling and debugging with params ${JSON.stringify(settings, null, '\t')} `)
+ settings = JSON.stringify(settings, null, '\t')
+ this.call('notification', 'toast', compilingToastMsg(settings))
})
this.on('fetchAndCompile', 'compilationFailed', (data) => {
- toaster(yo`Compilation failed... continuing without source code debugging.
`)
+ this.call('notification', 'toast', compilationFinishedToastMsg())
})
this.on('fetchAndCompile', 'notFound', (contractAddress) => {
- toaster(yo`Contract ${contractAddress} not found in source code repository continuing without source code debugging.
`)
+ this.call('notification', 'toast', notFoundToastMsg(contractAddress))
})
this.on('fetchAndCompile', 'usingLocalCompilation', (contractAddress) => {
- toaster(yo`Using compilation result from Solidity module
`)
+ this.call('notification', 'toast', localCompilationToastMsg())
})
this.on('fetchAndCompile', 'sourceVerificationNotAvailable', () => {
- toaster(yo`Source verification plugin not activated or not available. continuing without source code debugging.
`)
+ this.call('notification', 'toast', sourceVerificationNotAvailableToastMsg())
})
this.renderComponent()
-
return this.el
}
showMessage (title, message) {
try {
- modalDialogCustom.alert(title, remixBleach.sanitize(message))
+ this.call('notification', 'alert', {
+ id: 'debuggerTabShowMessage',
+ title,
+ message: remixBleach.sanitize(message)
+ })
} catch (e) {
console.log(e)
}
diff --git a/libs/remix-ui/app/src/lib/remix-app/interface/index.ts b/libs/remix-ui/app/src/lib/remix-app/interface/index.ts
index 46aacf70b8..0432c71e2d 100644
--- a/libs/remix-ui/app/src/lib/remix-app/interface/index.ts
+++ b/libs/remix-ui/app/src/lib/remix-app/interface/index.ts
@@ -24,7 +24,7 @@ export interface AlertModal {
export interface ModalState {
modals: AppModal[],
- toasters: string[] | JSX.Element[],
+ toasters: (string | JSX.Element)[],
focusModal: AppModal,
focusToaster: string | JSX.Element
}
diff --git a/libs/remix-ui/helper/src/index.ts b/libs/remix-ui/helper/src/index.ts
index 0bd8695a4a..31c21f0564 100644
--- a/libs/remix-ui/helper/src/index.ts
+++ b/libs/remix-ui/helper/src/index.ts
@@ -1,2 +1,2 @@
export * from './lib/remix-ui-helper'
-export * from './lib/components'
+export * from './lib/helper-components'
diff --git a/libs/remix-ui/helper/src/lib/components.tsx b/libs/remix-ui/helper/src/lib/components.tsx
deleted file mode 100644
index 361a4e1d87..0000000000
--- a/libs/remix-ui/helper/src/lib/components.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import React from 'react'
-
-export const fileChangedToasterMsg = (from: string, path: string) => (
-
-
- {from}
-
- is modifying
- {path}
-
-
-)
\ No newline at end of file
diff --git a/libs/remix-ui/helper/src/lib/helper-components.tsx b/libs/remix-ui/helper/src/lib/helper-components.tsx
new file mode 100644
index 0000000000..daa07cc110
--- /dev/null
+++ b/libs/remix-ui/helper/src/lib/helper-components.tsx
@@ -0,0 +1,55 @@
+import React from 'react'
+
+export const fileChangedToastMsg = (from: string, path: string) => (
+
+
+ {from}
+
+ is modifying
+ {path}
+
+
+)
+
+export const compilerConfigChangedToastMsg = (from: string, value: string) => (
+
+
{ from } is updating the
Solidity compiler configuration .
+
{value}
+
+)
+
+export const compileToastMsg = (from: string, fileName: string) => (
+
+ {from} is requiring to compile {fileName}
+
+)
+
+export const compilingToastMsg = (settings: string) => (
+
+
Recompiling and debugging with params
+
{settings}
+)
+
+export const compilationFinishedToastMsg = () => (
+
+ Compilation failed... continuing without source code debugging.
+
+)
+
+export const notFoundToastMsg = (address: string) => (
+
+ Contract {address} not found in source code repository continuing without source code debugging.
+
+)
+
+export const localCompilationToastMsg = () => (
+
+ Using compilation result from Solidity module
+
+)
+
+export const sourceVerificationNotAvailableToastMsg = () => (
+
+ Source verification plugin not activated or not available. continuing without source code debugging.
+
+)
\ No newline at end of file
From d2e8c3978ec85519c33d97f957faf7f9a7477eef Mon Sep 17 00:00:00 2001
From: David Disu
Date: Tue, 11 Jan 2022 15:18:16 +0100
Subject: [PATCH 26/28] Remove old toaster and modal in yo-yo
---
apps/remix-ide/src/app.js | 3 +-
.../src/app/ui/modal-dialog-custom.js | 114 -------------
apps/remix-ide/src/app/ui/modaldialog.js | 150 ------------------
apps/remix-ide/src/app/ui/tooltip.js | 110 -------------
4 files changed, 1 insertion(+), 376 deletions(-)
delete mode 100644 apps/remix-ide/src/app/ui/modal-dialog-custom.js
delete mode 100644 apps/remix-ide/src/app/ui/modaldialog.js
delete mode 100644 apps/remix-ide/src/app/ui/tooltip.js
diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js
index 9b39076918..d327647549 100644
--- a/apps/remix-ide/src/app.js
+++ b/apps/remix-ide/src/app.js
@@ -36,7 +36,6 @@ const FileManager = require('./app/files/fileManager')
const FileProvider = require('./app/files/fileProvider')
const DGitProvider = require('./app/files/dgitProvider')
const WorkspaceFileProvider = require('./app/files/workspaceFileProvider')
-const toolTip = require('./app/ui/tooltip')
const PluginManagerComponent = require('./app/components/plugin-manager-component')
@@ -368,7 +367,7 @@ class AppComponent {
if (params.call) {
const callDetails = params.call.split('//')
if (callDetails.length > 1) {
- toolTip(`initiating ${callDetails[0]} ...`)
+ self.appManager.call('notification', 'toast', `initiating ${callDetails[0]} ...`)
// @todo(remove the timeout when activatePlugin is on 0.3.0)
self.appManager.call(...callDetails).catch(console.error)
}
diff --git a/apps/remix-ide/src/app/ui/modal-dialog-custom.js b/apps/remix-ide/src/app/ui/modal-dialog-custom.js
deleted file mode 100644
index d2b1daba44..0000000000
--- a/apps/remix-ide/src/app/ui/modal-dialog-custom.js
+++ /dev/null
@@ -1,114 +0,0 @@
-var modal = require('./modaldialog.js')
-var yo = require('yo-yo')
-var css = require('./styles/modal-dialog-custom-styles')
-
-module.exports = {
- alert: function (title, text) {
- if (text) return modal(title, yo`${text}
`, null, { label: null })
- return modal('Alert', yo`${title}
`, null, { label: null })
- },
- prompt: function (title, text, inputValue, ok, cancel, focus) {
- return prompt(title, text, false, inputValue, ok, cancel, focus)
- },
- promptPassphrase: function (title, text, inputValue, ok, cancel) {
- return prompt(title, text, true, inputValue, ok, cancel)
- },
- promptPassphraseCreation: function (ok, cancel) {
- var text = 'Please provide a Passphrase for the account creation'
- var input = yo`
-
-
-
-
-
-
- `
- return modal(null, yo``,
- {
- fn: () => {
- if (typeof ok === 'function') {
- if (input.querySelector('#prompt1').value === input.querySelector('#prompt2').value) {
- ok(null, input.querySelector('#prompt1').value)
- } else {
- ok('Passphase does not match')
- }
- }
- }
- },
- {
- fn: () => {
- if (typeof cancel === 'function') cancel()
- }
- }
- )
- },
- promptMulti: function ({ title, text, inputValue }, ok, cancel) {
- if (!inputValue) inputValue = ''
- const input = yo`
-
- `
- return modal(title, yo``,
- {
- fn: () => { if (typeof ok === 'function') ok(document.getElementById('prompt_text').value) }
- },
- {
- fn: () => { if (typeof cancel === 'function') cancel() }
- }
- )
- },
- confirm: function (title, text, ok, cancel) {
- return modal(title, yo`${text}
`,
- {
- fn: () => { if (typeof ok === 'function') ok() }
- },
- {
- fn: () => { if (typeof cancel === 'function') cancel() }
- }
- )
- }
-}
-
-const validateInput = (e) => {
- if (!document.getElementById('modal-footer-ok')) return
-
- if (e.target.value === '') {
- document.getElementById('modal-footer-ok').classList.add('disabled')
- document.getElementById('modal-footer-ok').style.pointerEvents = 'none'
- } else {
- document.getElementById('modal-footer-ok').classList.remove('disabled')
- document.getElementById('modal-footer-ok').style.pointerEvents = 'auto'
- }
-}
-
-function prompt (title, text, hidden, inputValue, ok, cancel, focus) {
- if (!inputValue) inputValue = ''
- var type = hidden ? 'password' : 'text'
- var input = yo`
-
- `
-
- modal(title, yo``,
- {
- fn: () => { if (typeof ok === 'function') ok(document.getElementById('prompt_text').value) }
- },
- {
- fn: () => { if (typeof cancel === 'function') cancel() }
- },
- focus ? '#prompt_text' : undefined
- )
-}
diff --git a/apps/remix-ide/src/app/ui/modaldialog.js b/apps/remix-ide/src/app/ui/modaldialog.js
deleted file mode 100644
index 1aeae287a4..0000000000
--- a/apps/remix-ide/src/app/ui/modaldialog.js
+++ /dev/null
@@ -1,150 +0,0 @@
-var yo = require('yo-yo')
-var css = require('./styles/modaldialog-styles')
-
-let incomingModal = false // in case modals are queued, ensure we are not hiding the last one.
-module.exports = (title, content, ok, cancel, focusSelector, opts) => {
- let agreed = true
- let footerIsActive = false
- opts = opts || {}
- var container = document.getElementById('modal-dialog')
- if (!container) {
- document.querySelector('body').appendChild(html(opts))
- container = document.getElementById('modal-dialog')
- incomingModal = false
- } else incomingModal = true
-
- var closeDiv = document.getElementById('modal-close')
- if (opts.hideClose) closeDiv.style.display = 'none'
-
- var okDiv = document.getElementById('modal-footer-ok')
- okDiv.innerHTML = (ok && ok.label !== undefined) ? ok.label : 'OK'
- okDiv.style.display = okDiv.innerHTML === '' ? 'none' : 'inline-block'
-
- var cancelDiv = document.getElementById('modal-footer-cancel')
- cancelDiv.innerHTML = (cancel && cancel.label !== undefined) ? cancel.label : 'Cancel'
- cancelDiv.style.display = cancelDiv.innerHTML === '' ? 'none' : 'inline-block'
-
- var modal = document.getElementById('modal-body-id')
- var modalTitle = document.getElementById('modal-title-h6')
-
- modalTitle.innerHTML = ''
- if (title) modalTitle.innerText = title
-
- modal.innerHTML = ''
- if (content) modal.appendChild(content)
-
- setFocusOn('ok')
-
- show()
-
- function setFocusOn (btn) {
- var okDiv = document.getElementById('modal-footer-ok')
- var cancelDiv = document.getElementById('modal-footer-cancel')
- if (btn === 'ok') {
- okDiv.className = okDiv.className.replace(/\bbtn-light\b/g, 'btn-dark')
- cancelDiv.className = cancelDiv.className.replace(/\bbtn-dark\b/g, 'btn-light')
- } else {
- cancelDiv.className = cancelDiv.className.replace(/\bbtn-light\b/g, 'btn-dark')
- okDiv.className = okDiv.className.replace(/\bbtn-dark\b/g, 'btn-light')
- }
- }
-
- function okListener () {
- removeEventListener()
- if (ok && ok.fn && agreed) ok.fn()
- if (!incomingModal) hide()
- incomingModal = false
- }
-
- function cancelListener () {
- removeEventListener()
- if (cancel && cancel.fn) cancel.fn()
- if (!incomingModal) hide()
- incomingModal = false
- }
-
- function modalKeyEvent (e) {
- if (e.keyCode === 27) { // Esc
- cancelListener()
- } else if (e.keyCode === 13) { // Enter
- e.preventDefault()
- okListener()
- } else if (e.keyCode === 37 && footerIsActive) { // Arrow Left
- e.preventDefault()
- agreed = true
- setFocusOn('ok')
- } else if (e.keyCode === 39 && footerIsActive) { // Arrow Right
- e.preventDefault()
- agreed = false
- setFocusOn('cancel')
- }
- }
-
- function hide () {
- if (!container) return
- container.style.display = 'none'
- if (container.parentElement) container.parentElement.removeChild(container)
- container = null
- incomingModal = false
- }
-
- function show () {
- if (!container) return
- container.style.display = 'block'
- if (focusSelector) {
- const focusTarget = document.querySelector(`.modal ${focusSelector}`)
- if (focusTarget) {
- focusTarget.focus()
- if (typeof focusTarget.setSelectionRange === 'function') {
- focusTarget.setSelectionRange(0, focusTarget.value.length)
- }
- }
- }
- }
-
- function removeEventListener () {
- okDiv.removeEventListener('click', okListener)
- cancelDiv.removeEventListener('click', cancelListener)
- closeDiv.removeEventListener('click', cancelListener)
- document.removeEventListener('keydown', modalKeyEvent)
- if (document.getElementById('modal-background')) {
- document.getElementById('modal-background').removeEventListener('click', cancelListener)
- }
- }
- okDiv.addEventListener('click', okListener)
- cancelDiv.addEventListener('click', cancelListener)
- closeDiv.addEventListener('click', cancelListener)
- document.addEventListener('keydown', modalKeyEvent)
-
- const modalDialog = document.getElementById('modal-dialog')
- if (modalDialog) {
- modalDialog.addEventListener('click', (e) => {
- footerIsActive = document.activeElement === modalDialog
- if (e.toElement === modalDialog) {
- cancelListener() // click is outside of modal-content
- }
- })
- }
- return { container, okListener, cancelListener, hide }
-}
-
-function html (opts) {
- return yo`
- `
-}
diff --git a/apps/remix-ide/src/app/ui/tooltip.js b/apps/remix-ide/src/app/ui/tooltip.js
deleted file mode 100644
index 700a08ef56..0000000000
--- a/apps/remix-ide/src/app/ui/tooltip.js
+++ /dev/null
@@ -1,110 +0,0 @@
-/* global Element */
-var yo = require('yo-yo')
-var css = require('./styles/tooltip-styles')
-var modal = require('./modal-dialog-custom')
-
-/**
- * Open a tooltip
- * @param {string} tooltipText The text shown by the tooltip
- * @param {function} [action] Returns An HTMLElement to display for action
- */
-module.exports = function addTooltip (tooltipText, action, opts) {
- action = action || function () { return yo`
` }
- const t = new Toaster()
- return t.render(tooltipText, action(t), opts)
-}
-
-class Toaster {
- hide () {
- if (this.id) clearTimeout(this.id)
- setTimeout(() => {
- // remove from body after the animation is finished
- if (this.tooltip.parentElement) this.tooltip.parentElement.removeChild(this.tooltip)
- }, 2000)
- animation(this.tooltip, css.animateTop.className)
- }
-
- render (tooltipText, actionElement, opts) {
- opts = defaultOptions(opts)
- let canShorten = true
- if (tooltipText instanceof Element) {
- canShorten = false
- } else {
- if (typeof tooltipText === 'object') {
- if (tooltipText.message) {
- tooltipText = tooltipText.message
- } else {
- try {
- tooltipText = JSON.stringify(tooltipText)
- } catch (e) {
- }
- }
- }
- }
-
- return new Promise((resolve, reject) => {
- const shortTooltipText = (canShorten && tooltipText.length > 201) ? tooltipText.substring(0, 200) + '...' : tooltipText
- this.resolveFn = resolve
-
- function showFullMessage () {
- modal.alert(tooltipText)
- }
-
- function closeTheToaster (self) {
- self.hide()
- over()
- resolve()
- }
- const button = tooltipText.length > 201 ? yo`
- showFullMessage()}>Show full message
- ` : ''
-
- this.tooltip = yo`
- { over() }} onmouseleave=${() => { out() }}>
-
- ${shortTooltipText}
- ${button}
- ${actionElement}
-
-
- closeTheToaster(this)}>
-
-
`
- const timeOut = () => {
- return setTimeout(() => {
- if (this.id) {
- this.hide()
- resolve()
- }
- }, opts.time)
- }
- const over = () => {
- if (this.id) {
- clearTimeout(this.id)
- this.id = null
- }
- }
- const out = () => {
- if (!this.id) this.id = timeOut()
- }
- this.id = timeOut()
- document.body.appendChild(this.tooltip)
- animation(this.tooltip, css.animateBottom.className)
- })
- }
-}
-
-const defaultOptions = (opts) => {
- opts = opts || {}
- return {
- time: opts.time || 7000
- }
-}
-
-const animation = (tooltip, anim) => {
- tooltip.classList.remove(css.animateTop.className)
- tooltip.classList.remove(css.animateBottom.className)
- // eslint-disable-next-line
- void tooltip.offsetWidth // trick for restarting the animation
- tooltip.classList.add(anim)
-}
From b81b625edcc78a81fd832e7c025244af5807900f Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Tue, 11 Jan 2022 16:42:24 +0100
Subject: [PATCH 27/28] rn modal
---
.../src/app/plugins/permission-handler-plugin.tsx | 4 ++--
apps/remix-ide/src/app/plugins/remixd-handle.tsx | 6 +++---
apps/remix-ide/src/app/tabs/hardhat-provider.tsx | 4 ++--
libs/remix-core-plugin/src/lib/gist-handler.ts | 12 ++++++------
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx b/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx
index ce76cc7cc6..1b947d75dd 100644
--- a/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx
+++ b/apps/remix-ide/src/app/plugins/permission-handler-plugin.tsx
@@ -72,7 +72,7 @@ export class PermissionHandlerPlugin extends Plugin {
const { allow, hash } = this.permissions[to.name][method][from.name]
if (!allow) {
const warning = this.notAllowWarning(from, to, method)
- this.call('modal', 'toast', warning)
+ this.call('notification', 'toast', warning)
return false
}
return hash === from.hash
@@ -100,7 +100,7 @@ export class PermissionHandlerPlugin extends Plugin {
cancelLabel: 'Decline'
}
- const result = await this.call('modal', 'modal', modal)
+ const result = await this.call('notification', 'modal', modal)
return new Promise((resolve, reject) => {
if (result) {
if (this.permissions[to.name][method][from.name]) {
diff --git a/apps/remix-ide/src/app/plugins/remixd-handle.tsx b/apps/remix-ide/src/app/plugins/remixd-handle.tsx
index 6f4c522647..68367d1df3 100644
--- a/apps/remix-ide/src/app/plugins/remixd-handle.tsx
+++ b/apps/remix-ide/src/app/plugins/remixd-handle.tsx
@@ -69,7 +69,7 @@ export class RemixdHandle extends WebsocketPlugin {
id: 'connectionAlert',
message: 'Cannot connect to the remixd daemon. Please make sure you have the remixd running in the background.'
}
- this.call('modal', 'alert', alert)
+ this.call('notification', 'alert', alert)
this.canceled()
} else {
const intervalId = setInterval(() => {
@@ -80,7 +80,7 @@ export class RemixdHandle extends WebsocketPlugin {
id: 'connectionAlert',
message: 'Connection to remixd terminated.Please make sure remixd is still running in the background.'
}
- this.call('modal', 'alert', alert)
+ this.call('notification', 'alert', alert)
this.canceled()
}
}, 3000)
@@ -102,7 +102,7 @@ export class RemixdHandle extends WebsocketPlugin {
okLabel: 'Connect',
cancelLabel: 'Cancel',
}
- const result = await this.call('modal', 'modal', mod)
+ const result = await this.call('notification', 'modal', mod)
if(result) {
try {
this.localhostProvider.preInit()
diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.tsx b/apps/remix-ide/src/app/tabs/hardhat-provider.tsx
index c84a6d09c2..1ca0547d9a 100644
--- a/apps/remix-ide/src/app/tabs/hardhat-provider.tsx
+++ b/apps/remix-ide/src/app/tabs/hardhat-provider.tsx
@@ -83,7 +83,7 @@ export class HardhatProvider extends Plugin {
},
defaultValue: 'http://127.0.0.1:8545'
}
- this.call('modal', 'modal', modalContent)
+ this.call('notification', 'modal', modalContent)
})
})()
} catch (e) {
@@ -114,7 +114,7 @@ export class HardhatProvider extends Plugin {
title: 'Hardhat Provider',
message: `Error while connecting to the hardhat provider: ${error.message}`,
}
- this.call('modal', 'alert', modalContent)
+ this.call('notification', 'alert', modalContent)
await this.call('udapp', 'setEnvironmentMode', { context: 'vm', fork: 'london' })
this.provider = null
setTimeout(_ => { this.blocked = false }, 1000) // we wait 1 second for letting remix to switch to vm
diff --git a/libs/remix-core-plugin/src/lib/gist-handler.ts b/libs/remix-core-plugin/src/lib/gist-handler.ts
index 6c22c29aa8..23ea64b937 100644
--- a/libs/remix-core-plugin/src/lib/gist-handler.ts
+++ b/libs/remix-core-plugin/src/lib/gist-handler.ts
@@ -45,7 +45,7 @@ export class GistHandler extends Plugin {
setTimeout(() => reject(new Error('Hide')), 0)
}
}
- this.call('modal', 'modal', modalContent)
+ this.call('notification', 'modal', modalContent)
})
})()
} catch (e) {
@@ -63,7 +63,7 @@ export class GistHandler extends Plugin {
title: 'Gist load error',
message: 'Error while loading gist. Please provide a valid Gist ID or URL.'
}
- this.call('modal', 'alert', modalContent)
+ this.call('notification', 'alert', modalContent)
}
} else {
const modalContent = {
@@ -71,7 +71,7 @@ export class GistHandler extends Plugin {
title: 'Gist load error',
message: 'Error while loading gist. Id cannot be empty.'
}
- this.call('modal', 'alert', modalContent)
+ this.call('notification', 'alert', modalContent)
}
return loadingFromGist
} else {
@@ -97,7 +97,7 @@ export class GistHandler extends Plugin {
modalType: 'alert',
okLabel: 'OK'
}
- await this.call('modal', 'modal', modalContent)
+ await this.call('notification', 'modal', modalContent)
return
}
} catch (e: any) {
@@ -107,7 +107,7 @@ export class GistHandler extends Plugin {
message: e.message
}
- await this.call('modal', 'alert', modalContent)
+ await this.call('notification', 'alert', modalContent)
return
}
@@ -124,7 +124,7 @@ export class GistHandler extends Plugin {
message: errorSavingFiles.message || errorSavingFiles
}
- this.call('modal', 'alert', modalContent)
+ this.call('notification', 'alert', modalContent)
}
})
})
From d97bfe86cbc77d68c492846c5c01a7db6e08e769 Mon Sep 17 00:00:00 2001
From: bunsenstraat
Date: Tue, 11 Jan 2022 16:45:01 +0100
Subject: [PATCH 28/28] rn modal
---
apps/remix-ide/src/remixAppManager.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js
index a841c84f1b..b6a0b0e0b6 100644
--- a/apps/remix-ide/src/remixAppManager.js
+++ b/apps/remix-ide/src/remixAppManager.js
@@ -8,12 +8,12 @@ const _paq = window._paq = window._paq || []
const requiredModules = [ // services + layout views + system views
'manager', 'config', 'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme',
'fileManager', 'contentImport', 'blockchain', 'web3Provider', 'scriptRunner', 'fetchAndCompile', 'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons',
- 'filePanel', 'terminal', 'settings', 'pluginManager', 'tabs', 'udapp', 'dGitProvider', 'solidity-logic', 'gistHandler', 'layout', 'modal', 'permissionhandler']
+ 'filePanel', 'terminal', 'settings', 'pluginManager', 'tabs', 'udapp', 'dGitProvider', 'solidity-logic', 'gistHandler', 'layout', 'notification', 'permissionhandler']
const dependentModules = ['git', 'hardhat', 'slither'] // module which shouldn't be manually activated (e.g git is activated by remixd)
export function isNative (name) {
- const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons', 'solidity', 'hardhat-provider', 'solidityStaticAnalysis', 'solidityUnitTesting', 'layout', 'modal']
+ const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons', 'solidity', 'hardhat-provider', 'solidityStaticAnalysis', 'solidityUnitTesting', 'layout', 'notification']
return nativePlugins.includes(name) || requiredModules.includes(name)
}