Skip to content

Commit dcc4fa6

Browse files
authored
Merge branch 'master' into homeFixes
2 parents a3cfba4 + 35614dc commit dcc4fa6

File tree

11 files changed

+55
-115
lines changed

11 files changed

+55
-115
lines changed

apps/remix-ide/src/app/editor/examples.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ const deployWithEthers = `// Right click on the script name and hit "Run" to exe
313313

314314
const readme = `REMIX EXAMPLE PROJECT
315315
316-
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
316+
Remix example project is present when Remix loads for the very first time or there are no files existing in the File Explorer.
317317
It contains 3 directories:
318318
319319
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.

apps/remix-ide/src/app/tabs/runTab/model/recorder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class Recorder {
259259
cb(err)
260260
}
261261
)
262-
}, () => { self.setListen(true); self.clearAll() })
262+
}, () => { self.setListen(true) })
263263
}
264264

265265
runScenario (json, continueCb, promptCb, alertCb, confirmationCb, logCallBack, cb) {

apps/remix-ide/src/app/tabs/theme-module.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ export class ThemeModule extends Plugin {
3535
}
3636
this.themes = themes.reduce((acc, theme) => {
3737
theme.url = window.location.origin + window.location.pathname + theme.url
38-
return { ...acc, [theme.name]: theme }
38+
return { ...acc, [theme.name.toLocaleLowerCase()]: theme }
3939
}, {})
4040
this._paq = _paq
4141
let queryTheme = (new QueryParams()).get().theme
42+
queryTheme = queryTheme && queryTheme.toLocaleLowerCase()
4243
queryTheme = this.themes[queryTheme] ? queryTheme : null
4344
let currentTheme = this._deps.config.get('settings/theme')
45+
currentTheme = currentTheme && currentTheme.toLocaleLowerCase()
4446
currentTheme = this.themes[currentTheme] ? currentTheme : null
4547
this.currentThemeState = { queryTheme, currentTheme }
46-
this.active = queryTheme || currentTheme || 'Dark'
48+
this.active = queryTheme || currentTheme || 'dark'
4749
this.forced = !!queryTheme
4850
}
4951

@@ -82,6 +84,7 @@ export class ThemeModule extends Plugin {
8284
* @param {string} [themeName] - The name of the theme
8385
*/
8486
switchTheme (themeName) {
87+
themeName = themeName && themeName.toLocaleLowerCase()
8588
if (themeName && !Object.keys(this.themes).includes(themeName)) {
8689
throw new Error(`Theme ${themeName} doesn't exist`)
8790
}

libs/remix-ui/editor/src/lib/remix-ui-editor.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
width: auto;
1111
}
1212

13+
.monaco-hover .markdown-hover > .hover-contents:not(.code-hover-contents) {
14+
max-width: none !important;
15+
word-wrap: break-word;
16+
}
17+
1318
.contextview {
1419
opacity: 1;
1520
position: absolute;

libs/remix-ui/helper/src/lib/remix-ui-helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export const createNonClashingNameAsync = async (name: string, fileManager, pref
3737
let exist = true
3838

3939
do {
40-
const isDuplicate = await fileManager.exists(name + _counter + prefix + '.' + ext)
40+
const isDuplicate = await fileManager.exists(name + (_counter || '') + prefix + '.' + ext)
4141

42-
if (isDuplicate) _counter = (_counter | 0) + 1
42+
if (isDuplicate) _counter = (_counter || 0) + 1
4343
else exist = false
4444
} while (exist)
4545
const counter = _counter || ''

libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => {
5656
<article className='remember'>
5757
<div className='form-check'>
5858
{rememberSwitch()}
59-
<label className="form-check-label" data-id="permissionHandlerRememberChoice">Remember this choice</label>
59+
<label htmlFor='remember' className="form-check-label" data-id="permissionHandlerRememberChoice">Remember this choice</label>
6060
</div>
6161
<button className="btn btn-sm" onClick={reset}>Reset all Permissions</button>
6262
</article>

libs/remix-ui/run-tab/src/lib/actions/index.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React from 'react'
33
import * as ethJSUtil from 'ethereumjs-util'
44
import Web3 from 'web3'
5-
import { addressToString, createNonClashingNameAsync, shortenAddress } from '@remix-ui/helper'
5+
import { addressToString, createNonClashingNameAsync, extractNameFromKey, shortenAddress } from '@remix-ui/helper'
66
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'
77
import { RunTab } from '../types/run-tab'
88
import { CompilerAbstract } from '@remix-project/remix-solidity'
@@ -622,38 +622,39 @@ export const runTransactions = (
622622
)
623623
}
624624

625-
const saveScenario = (promptCb, cb) => {
625+
const saveScenario = (newPath: string, provider, promptCb, cb) => {
626626
const txJSON = JSON.stringify(plugin.recorder.getAll(), null, 2)
627-
const path = plugin.fileManager.currentPath()
628-
629-
promptCb(path, async () => {
630-
const fileProvider = plugin.fileManager.fileProviderOf(path)
631627

632-
if (!fileProvider) return
633-
const newFile = path + '/' + plugin.REACT_API.recorder.pathToScenario
628+
promptCb(() => {
634629
try {
635-
const newPath = await createNonClashingNameAsync(newFile, plugin.fileManager)
636-
if (!fileProvider.set(newPath, txJSON)) return cb('Failed to create file ' + newFile)
637-
plugin.fileManager.open(newFile)
630+
if (!provider.set(newPath, txJSON)) return cb('Failed to create file ' + newPath)
631+
plugin.fileManager.open(newPath)
638632
} catch (error) {
639-
if (error) return cb('Failed to create file. ' + newFile + ' ' + error)
633+
if (error) return cb('Failed to create file. ' + newPath + ' ' + error)
640634
}
641635
})
642636
}
643637

644-
export const storeScenario = (prompt: (msg: string) => JSX.Element) => {
645-
saveScenario(
646-
(path, cb) => {
647-
dispatch(displayNotification('Save transactions as scenario', prompt('Transactions will be saved in a file under ' + path), 'Ok', 'Cancel', cb, null))
638+
export const storeScenario = async (prompt: (msg: string, defaultValue: string) => JSX.Element) => {
639+
const path = plugin.fileManager.currentPath()
640+
const fileProvider = plugin.fileManager.fileProviderOf(path)
641+
642+
if (!fileProvider) return displayNotification('Alert', 'Invalid File Provider', 'OK', null)
643+
const newPath = await createNonClashingNameAsync(path + '/' + plugin.REACT_API.recorder.pathToScenario, plugin.fileManager)
644+
const newName = extractNameFromKey(newPath)
645+
646+
saveScenario(newPath, fileProvider,
647+
(cb) => {
648+
dispatch(displayNotification('Save transactions as scenario', prompt('Transactions will be saved in a file under ' + path, newName), 'OK', 'Cancel', cb, null))
648649
},
649650
(error) => {
650-
if (error) return dispatch(displayNotification('Alert', error, 'Ok', null))
651+
if (error) return dispatch(displayNotification('Alert', error, 'OK', null))
651652
}
652653
)
653654
}
654655

655656
const runScenario = (file: string, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt, logBuilder: (msg: string) => JSX.Element) => {
656-
if (!file) return dispatch(displayNotification('Alert', 'Unable to run scenerio, no specified scenario file', 'Ok', null))
657+
if (!file) return dispatch(displayNotification('Alert', 'Unable to run scenerio, no specified scenario file', 'OK', null))
657658

658659
plugin.fileManager.readFile(file).then((json) => {
659660
// TODO: there is still a UI dependency to remove here, it's still too coupled at this point to remove easily
@@ -664,7 +665,7 @@ const runScenario = (file: string, gasEstimationPrompt: (msg: string) => JSX.Ele
664665
}, (okCb, cancelCb) => {
665666
promptHandler(passphrasePrompt, okCb, cancelCb)
666667
}, (msg) => {
667-
dispatch(displayNotification('Alert', msg, 'Ok', null))
668+
dispatch(displayNotification('Alert', msg, 'OK', null))
668669
}, (network, tx, gasEstimation, continueTxExecution, cancelCb) => {
669670
confirmationHandler(confirmDialogContent, network, tx, gasEstimation, continueTxExecution, cancelCb)
670671
}, (msg: string) => {
@@ -673,11 +674,11 @@ const runScenario = (file: string, gasEstimationPrompt: (msg: string) => JSX.Ele
673674
return terminalLogger(log)
674675
}, (error, abi, address, contractName) => {
675676
if (error) {
676-
return dispatch(displayNotification('Alert', error, 'Ok', null))
677+
return dispatch(displayNotification('Alert', error, 'OK', null))
677678
}
678679
addInstance({ name: contractName, address, abi })
679680
})
680-
}).catch((error) => dispatch(displayNotification('Alert', error, 'Ok', null)))
681+
}).catch((error) => dispatch(displayNotification('Alert', error, 'OK', null)))
681682
}
682683

683684
export const runCurrentScenario = (gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt, logBuilder: (msg: string) => JSX.Element) => {

libs/remix-ui/run-tab/src/lib/run-tab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ export function RunTabUI (props: RunTabProps) {
172172
return <PassphrasePrompt message={message} setPassphrase={setPassphrasePrompt} defaultValue={runTab.passphrase} />
173173
}
174174

175-
const scenarioPrompt = (message: string) => {
176-
return <ScenarioPrompt message={message} setScenarioPath={updateScenarioPath} defaultValue={runTab.recorder.pathToScenario} />
175+
const scenarioPrompt = (message: string, defaultValue) => {
176+
return <ScenarioPrompt message={message} setScenarioPath={updateScenarioPath} defaultValue={defaultValue} />
177177
}
178178

179179
const mainnetPrompt = (tx: Tx, network: Network, amount: string, gasEstimation: string, gasFees: (maxFee: string, cb: (txFeeText: string, priceStatus: boolean) => void) => void, determineGasPrice: (cb: (txFeeText: string, gasPriceValue: string, gasPriceStatus: boolean) => void) => void) => {

libs/remix-ui/run-tab/src/lib/types/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ export interface ContractDropdownProps {
189189
}
190190

191191
export interface RecorderProps {
192-
storeScenario: (prompt: (msg: string) => JSX.Element) => void,
192+
storeScenario: (prompt: (msg: string, defaultValue: string) => JSX.Element) => void,
193193
runCurrentScenario: (gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt, logBuilder: (msg: string) => JSX.Element) => void,
194194
logBuilder: (msg: string) => JSX.Element,
195195
mainnetPrompt: MainnetPrompt,
196196
gasEstimationPrompt: (msg: string) => JSX.Element,
197197
passphrasePrompt: (msg: string) => JSX.Element,
198-
scenarioPrompt: (msg: string) => JSX.Element,
198+
scenarioPrompt: (msg: string, defaultValue: string) => JSX.Element,
199199
count: number
200200
}
201201

libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
6767
let [readyTestsNumber, setReadyTestsNumber] = useState<number>(0) // eslint-disable-line
6868
let [runningTestsNumber, setRunningTestsNumber] = useState<number>(0) // eslint-disable-line
6969

70+
const areTestsRunning = useRef<boolean>(false)
7071
const hasBeenStopped = useRef<boolean>(false)
7172
const isDebugging = useRef<boolean>(false)
7273
const allTests = useRef<string[]>([])
7374
const selectedTests = useRef<string[]>([])
7475
const currentErrors:any = useRef([]) // eslint-disable-line @typescript-eslint/no-explicit-any
7576

7677
const defaultPath = 'tests'
77-
let areTestsRunning = false
7878

7979
let runningTestFileName: string
8080
const filesContent: Record<string, Record<string, string>> = {}
@@ -113,7 +113,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
113113
allTests.current = tests
114114
selectedTests.current = [...allTests.current]
115115
updateTestFileList()
116-
if (!areTestsRunning) await updateRunAction(file)
116+
if (!areTestsRunning.current) await updateRunAction(file)
117117
} catch (e: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
118118
console.log(e)
119119
setToasterMsg(e)
@@ -153,7 +153,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
153153
await setCurrentPath(defaultPath)
154154
})
155155

156-
testTab.fileManager.events.on('noFileSelected', () => { }) // eslint-disable-line
156+
testTab.fileManager.events.on('noFileSelected', async () => { await updateForNewCurrent() })
157157
testTab.fileManager.events.on('currentFileChanged', async (file: string) => await updateForNewCurrent(file))
158158

159159
}, []) // eslint-disable-line
@@ -167,15 +167,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
167167
const handleTestDirInput = async (e: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
168168
let testDirInput = trimTestDirInput(e.target.value)
169169
testDirInput = helper.removeMultipleSlashes(testDirInput)
170-
if (testDirInput !== '/') testDirInput = helper.removeTrailingSlashes(testDirInput)
171170
setInputPathValue(testDirInput)
172-
if (e.key === 'Enter') {
173-
if (await testTabLogic.pathExists(testDirInput)) {
174-
testTabLogic.setCurrentPath(testDirInput)
175-
await updateForNewCurrent()
176-
return
177-
}
178-
}
179171
if (testDirInput) {
180172
if (testDirInput.endsWith('/') && testDirInput !== '/') {
181173
testDirInput = helper.removeTrailingSlashes(testDirInput)
@@ -205,17 +197,6 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
205197
}
206198
}
207199

208-
const handleEnter = async (e: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
209-
let inputPath = e.target.value
210-
inputPath = helper.removeMultipleSlashes(trimTestDirInput(inputPath))
211-
setInputPathValue(inputPath)
212-
if (disableCreateButton) {
213-
if (await testTabLogic.pathExists(inputPath)) {
214-
await setCurrentPath(inputPath)
215-
}
216-
}
217-
}
218-
219200
const handleCreateFolder = async () => {
220201
let inputPath = trimTestDirInput(inputPathValue)
221202
let path = helper.removeMultipleSlashes(inputPath)
@@ -519,7 +500,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
519500
if (selectedTests.current?.length !== 0) {
520501
setDisableRunButton(false)
521502
}
522-
areTestsRunning = false
503+
areTestsRunning.current = false
523504
}
524505
}
525506

@@ -566,7 +547,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
566547
}
567548

568549
const runTests = () => {
569-
areTestsRunning = true
550+
areTestsRunning.current = true
570551
hasBeenStopped.current = false
571552
readyTestsNumber = 0
572553
setReadyTestsNumber(readyTestsNumber)
@@ -587,14 +568,14 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
587568

588569
const updateRunAction = async (currentFile: any = null) => { // eslint-disable-line @typescript-eslint/no-explicit-any
589570
const isSolidityActive = await testTab.appManager.isActive('solidity')
590-
if (!isSolidityActive || !selectedTests.current?.length) {
591-
// setDisableRunButton(true)
571+
if (!isSolidityActive || !selectedTests.current.length) {
572+
setDisableRunButton(true)
592573
if (!currentFile || (currentFile && currentFile.split('.').pop().toLowerCase() !== 'sol')) {
593574
setRunButtonTitle('No solidity file selected')
594575
} else {
595576
setRunButtonTitle('The "Solidity Plugin" should be activated')
596577
}
597-
}
578+
} else setDisableRunButton(false)
598579
}
599580

600581
const stopTests = () => {
@@ -611,7 +592,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
611592

612593
const toggleCheckbox = (eChecked: boolean, index: number) => {
613594
testFiles[index].checked = eChecked
614-
setTestFiles(testFiles)
595+
setTestFiles([...testFiles])
615596
selectedTests.current = getCurrentSelectedTests()
616597
if (eChecked) {
617598
setCheckSelectAll(true)
@@ -628,7 +609,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
628609

629610
const checkAll = (event: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
630611
testFiles.forEach((testFileObj) => testFileObj.checked = event.target.checked)
631-
setTestFiles(testFiles)
612+
setTestFiles([...testFiles])
632613
setCheckSelectAll(event.target.checked)
633614
if (event.target.checked) {
634615
selectedTests.current = getCurrentSelectedTests()
@@ -646,7 +627,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
646627
}
647628
else
648629
testFiles = []
649-
setTestFiles(testFiles)
630+
setTestFiles([...testFiles])
650631
}
651632

652633
return (
@@ -674,8 +655,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
674655
title="Press 'Enter' to change the path for test files."
675656
style={{ backgroundImage: "var(--primary)" }}
676657
onKeyDown={() => { if (inputPathValue === '/') setInputPathValue('')} }
677-
onKeyUp={handleTestDirInput}
678-
onChange={handleEnter}
658+
onChange={handleTestDirInput}
679659
onClick = {() => { if (inputPathValue === '/') setInputPathValue('')} }
680660
/>
681661
<button
@@ -728,7 +708,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
728708
/>
729709
<label className="text-nowrap pl-2 mb-0" htmlFor="checkAllTests"> Select all </label>
730710
</div>
731-
<div className="testList py-2 mt-0 border-bottom">{testFiles?.length ? testFiles.map((testFileObj: TestObject, index) => {
711+
<div className="testList py-2 mt-0 border-bottom">{testFiles.length ? testFiles.map((testFileObj: TestObject, index) => {
732712
const elemId = `singleTest${testFileObj.fileName}`
733713
return (
734714
<div className="d-flex align-items-center py-1" key={index}>

0 commit comments

Comments
 (0)