Merge branch 'master' into localstorage

pull/2137/head
Rob 3 years ago committed by GitHub
commit 14a0e9c925
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      apps/remix-ide-e2e/src/tests/importFromGithub.test.ts
  2. 50
      libs/remix-lib/src/execution/eventsDecoder.ts
  3. 2
      libs/remix-ui/settings/src/lib/remix-ui-settings.tsx
  4. 2
      libs/remix-ui/terminal/src/lib/components/RenderCall.tsx
  5. 11
      libs/remix-ui/workspace/src/lib/actions/index.ts
  6. 6
      libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx
  7. 9
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  8. 1
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  9. 7
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  10. 2
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  11. 2
      libs/remix-ui/workspace/src/lib/types/index.ts
  12. 6
      libs/remix-ui/workspace/src/lib/utils/index.ts
  13. 12
      libs/remix-url-resolver/src/resolve.ts
  14. 2
      package.json

@ -4,7 +4,8 @@ import init from '../helpers/init'
const testData = { const testData = {
validURL: 'https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67bca857eedf99bf44a4b6a0fc5b5ed553135316/contracts/access/Roles.sol', validURL: 'https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67bca857eedf99bf44a4b6a0fc5b5ed553135316/contracts/access/Roles.sol',
invalidURL: 'https://github.com/Oppelin/Roles.sol' invalidURL: 'https://github.com/Oppelin/Roles.sol',
JSON: 'https://github.com/ethereum/remix-project/blob/master/package.json'
} }
module.exports = { module.exports = {
@ -57,6 +58,27 @@ module.exports = {
.scrollAndClick('[data-id="homeTab-modal-footer-ok-react"]') .scrollAndClick('[data-id="homeTab-modal-footer-ok-react"]')
.openFile('github/OpenZeppelin/openzeppelin-solidity/contracts/access/Roles.sol') .openFile('github/OpenZeppelin/openzeppelin-solidity/contracts/access/Roles.sol')
.waitForElementVisible("div[title='default_workspace/github/OpenZeppelin/openzeppelin-solidity/contracts/access/Roles.sol'") .waitForElementVisible("div[title='default_workspace/github/OpenZeppelin/openzeppelin-solidity/contracts/access/Roles.sol'")
.getEditorValue((content) => {
browser.assert.ok(content.indexOf('library Roles {') !== -1, 'content does contain "library Roles {"')
})
},
'Import JSON From Github For Valid URL': function (browser: NightwatchBrowser) {
browser
.click('div[title="home"]')
.scrollAndClick('*[data-id="landingPageImportFromGitHubButton"]')
.waitForElementVisible('*[data-id="homeTabModalDialogCustomPromptText"]')
.clearValue('*[data-id="homeTabModalDialogCustomPromptText"]')
.execute(() => {
(document.querySelector('input[data-id="homeTabModalDialogCustomPromptText"]') as any).focus()
}, [], () => {})
.setValue('input[data-id="homeTabModalDialogCustomPromptText"]', testData.JSON)
.waitForElementVisible('*[data-id="homeTab-modal-footer-ok-react"]')
.scrollAndClick('[data-id="homeTab-modal-footer-ok-react"]')
.openFile('github/ethereum/remix-project/package.json')
.waitForElementVisible("div[title='default_workspace/github/ethereum/remix-project/package.json'")
.getEditorValue((content) => {
browser.assert.ok(content.indexOf('"name": "remix-project",') !== -1, 'content does contain "name": "remix-project"')
})
.end() .end()
} }
} }

@ -56,21 +56,22 @@ export class EventsDecoder {
return eventsABI return eventsABI
} }
_event (hash: string, eventsABI: Record<string, unknown>, contractName: string) { _event (hash, eventsABI) {
const events = eventsABI[contractName] // get all the events responding to that hash.
if (!events) return null const contracts = []
for (const k in eventsABI) {
if (events[hash]) { if (eventsABI[k][hash]) {
const event = events[hash] const event = eventsABI[k][hash]
for (const input of event.inputs) { for (const input of event.inputs) {
if (input.type === 'function') { if (input.type === 'function') {
input.type = 'bytes24' input.type = 'bytes24'
input.baseType = 'bytes24' input.baseType = 'bytes24'
}
} }
contracts.push(event)
} }
return event
} }
return null return contracts
} }
_stringifyBigNumber (value): string { _stringifyBigNumber (value): string {
@ -95,16 +96,23 @@ export class EventsDecoder {
// [address, topics, mem] // [address, topics, mem]
const log = logs[i] const log = logs[i]
const topicId = log.topics[0] const topicId = log.topics[0]
const eventAbi = this._event(topicId.replace('0x', ''), eventsABI, contractName) const eventAbis = this._event(topicId.replace('0x', ''), eventsABI)
if (eventAbi) { for (const eventAbi of eventAbis) {
const decodedlog = eventAbi.abi.parseLog(log) try {
const decoded = {} if (eventAbi) {
for (const v in decodedlog.args) { const decodedlog = eventAbi.abi.parseLog(log)
decoded[v] = this._stringifyEvent(decodedlog.args[v]) const decoded = {}
for (const v in decodedlog.args) {
decoded[v] = this._stringifyEvent(decodedlog.args[v])
}
events.push({ from: log.address, topic: topicId, event: eventAbi.event, args: decoded })
} else {
events.push({ from: log.address, data: log.data, topics: log.topics })
}
break // if one of the iteration is successful
} catch (e) {
continue
} }
events.push({ from: log.address, topic: topicId, event: eventAbi.event, args: decoded })
} else {
events.push({ from: log.address, data: log.data, topics: log.topics })
} }
} }
cb(null, { decoded: events, raw: logs }) cb(null, { decoded: events, raw: logs })

@ -198,7 +198,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
<div className="border-top"> <div className="border-top">
<div className="card-body pt-3 pb-2"> <div className="card-body pt-3 pb-2">
<h6 className="card-title">{ swarmSettingsTitle }</h6> <h6 className="card-title">{ swarmSettingsTitle }</h6>
<div className=""><label>PRIVATE BEE ADDRESS:</label> <div className="pt-2"><label>PRIVATE BEE ADDRESS:</label>
<div className="text-secondary mb-0 h6"> <div className="text-secondary mb-0 h6">
<input id="swarmprivatebeeaddress" data-id="settingsPrivateBeeAddress" className="form-control" onChange={handleSavePrivateBeeAddress} value={ privateBeeAddress } /> <input id="swarmprivatebeeaddress" data-id="settingsPrivateBeeAddress" className="form-control" onChange={handleSavePrivateBeeAddress} value={ privateBeeAddress } />
</div> </div>

@ -34,7 +34,7 @@ const RenderCall = ({ tx, resolvedData, logs, index, plugin, showTableHash, txDe
<div className='remix_ui_terminal_buttons'> <div className='remix_ui_terminal_buttons'>
<div className="remix_ui_terminal_debug btn btn-primary btn-sm" onClick={(event) => debug(event, tx)}>Debug</div> <div className="remix_ui_terminal_debug btn btn-primary btn-sm" onClick={(event) => debug(event, tx)}>Debug</div>
</div> </div>
<i className="remix_ui_terminal_arrow fas fa-angle-down"></i> <i className={`remix_ui_terminal_arrow fas ${(showTableHash.includes(tx.hash)) ? 'fa-angle-up' : 'fa-angle-down'}`}></i>
</div> </div>
{showTableHash.includes(tx.hash) ? showTable({ {showTableHash.includes(tx.hash) ? showTable({
hash: tx.hash, hash: tx.hash,

@ -256,17 +256,6 @@ export const runScript = async (path: string) => {
}) })
} }
export const runScriptWithMocha = async (path: string) => {
const provider = plugin.fileManager.currentFileProvider()
provider.get(path, (error, content: string) => {
if (error) {
return dispatch(displayPopUp(error))
}
if (content) content = content + '\n' + 'mocha.run()'
plugin.call('scriptRunner', 'execute', content)
})
}
export const emitContextMenuEvent = async (cmd: customAction) => { export const emitContextMenuEvent = async (cmd: customAction) => {
await plugin.call(cmd.id, cmd.name, cmd) await plugin.call(cmd.id, cmd.name, cmd)
} }

@ -12,7 +12,7 @@ declare global {
const _paq = window._paq = window._paq || [] //eslint-disable-line const _paq = window._paq = window._paq || [] //eslint-disable-line
export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) => { export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) => {
const { actions, createNewFile, createNewFolder, deletePath, renamePath, hideContextMenu, pushChangesToGist, publishFileToGist, publishFolderToGist, copy, paste, runScript, runScriptWithMocha, emit, pageX, pageY, path, type, focus, ...otherProps } = props const { actions, createNewFile, createNewFolder, deletePath, renamePath, hideContextMenu, pushChangesToGist, publishFileToGist, publishFolderToGist, copy, paste, runScript, emit, pageX, pageY, path, type, focus, ...otherProps } = props
const contextMenuRef = useRef(null) const contextMenuRef = useRef(null)
useEffect(() => { useEffect(() => {
contextMenuRef.current.focus() contextMenuRef.current.focus()
@ -98,10 +98,6 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
_paq.push(['trackEvent', 'fileExplorer', 'runScript']) _paq.push(['trackEvent', 'fileExplorer', 'runScript'])
runScript(path) runScript(path)
break break
case 'Run with Mocha':
_paq.push(['trackEvent', 'fileExplorer', 'runScriptWithMocha'])
runScriptWithMocha(path)
break
case 'Copy': case 'Copy':
copy(path, type) copy(path, type)
break break

@ -221,14 +221,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
} }
} }
const runScriptWithMocha = async (path: string) => {
try {
props.dispatchRunScriptWithMocha(path)
} catch (error) {
props.toast('Run script with Mocha failed')
}
}
const emitContextMenuEvent = (cmd: customAction) => { const emitContextMenuEvent = (cmd: customAction) => {
try { try {
props.dispatchEmitContextMenuEvent(cmd) props.dispatchEmitContextMenuEvent(cmd)
@ -462,7 +454,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
deletePath={deletePath} deletePath={deletePath}
renamePath={editModeOn} renamePath={editModeOn}
runScript={runScript} runScript={runScript}
runScriptWithMocha={runScriptWithMocha}
copy={handleCopyClick} copy={handleCopyClick}
paste={handlePasteClick} paste={handlePasteClick}
emit={emitContextMenuEvent} emit={emitContextMenuEvent}

@ -25,7 +25,6 @@ export const FileSystemContext = createContext<{
dispatchCopyFile: (src: string, dest: string) => Promise<void>, dispatchCopyFile: (src: string, dest: string) => Promise<void>,
dispatchCopyFolder: (src: string, dest: string) => Promise<void>, dispatchCopyFolder: (src: string, dest: string) => Promise<void>,
dispatchRunScript: (path: string) => Promise<void>, dispatchRunScript: (path: string) => Promise<void>,
dispatchRunScriptWithMocha: (path: string) => Promise<void>,
dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>, dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>,
dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void> dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void>
dispatchHandleExpandPath: (paths: string[]) => Promise<void> dispatchHandleExpandPath: (paths: string[]) => Promise<void>

@ -5,7 +5,7 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
import { FileSystemContext } from '../contexts' import { FileSystemContext } from '../contexts'
import { browserReducer, browserInitialState } from '../reducers/workspace' import { browserReducer, browserInitialState } from '../reducers/workspace'
import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, runScriptWithMocha, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile } from '../actions' import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile } from '../actions'
import { Modal, WorkspaceProps } from '../types' import { Modal, WorkspaceProps } from '../types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Workspace } from '../remix-ui-workspace' import { Workspace } from '../remix-ui-workspace'
@ -103,10 +103,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await runScript(path) await runScript(path)
} }
const dispatchRunScriptWithMocha = async (path: string) => {
await runScriptWithMocha(path)
}
const dispatchEmitContextMenuEvent = async (cmd: customAction) => { const dispatchEmitContextMenuEvent = async (cmd: customAction) => {
await emitContextMenuEvent(cmd) await emitContextMenuEvent(cmd)
} }
@ -216,7 +212,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchCopyFile, dispatchCopyFile,
dispatchCopyFolder, dispatchCopyFolder,
dispatchRunScript, dispatchRunScript,
dispatchRunScriptWithMocha,
dispatchEmitContextMenuEvent, dispatchEmitContextMenuEvent,
dispatchHandleClickFile, dispatchHandleClickFile,
dispatchHandleExpandPath dispatchHandleExpandPath

@ -198,7 +198,6 @@ export function Workspace () {
dispatchCopyFolder={global.dispatchCopyFolder} dispatchCopyFolder={global.dispatchCopyFolder}
dispatchPublishToGist={global.dispatchPublishToGist} dispatchPublishToGist={global.dispatchPublishToGist}
dispatchRunScript={global.dispatchRunScript} dispatchRunScript={global.dispatchRunScript}
dispatchRunScriptWithMocha={global.dispatchRunScriptWithMocha}
dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent} dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent}
dispatchHandleClickFile={global.dispatchHandleClickFile} dispatchHandleClickFile={global.dispatchHandleClickFile}
dispatchSetFocusElement={global.dispatchSetFocusElement} dispatchSetFocusElement={global.dispatchSetFocusElement}
@ -234,7 +233,6 @@ export function Workspace () {
dispatchCopyFolder={global.dispatchCopyFolder} dispatchCopyFolder={global.dispatchCopyFolder}
dispatchPublishToGist={global.dispatchPublishToGist} dispatchPublishToGist={global.dispatchPublishToGist}
dispatchRunScript={global.dispatchRunScript} dispatchRunScript={global.dispatchRunScript}
dispatchRunScriptWithMocha={global.dispatchRunScriptWithMocha}
dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent} dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent}
dispatchHandleClickFile={global.dispatchHandleClickFile} dispatchHandleClickFile={global.dispatchHandleClickFile}
dispatchSetFocusElement={global.dispatchSetFocusElement} dispatchSetFocusElement={global.dispatchSetFocusElement}

@ -87,7 +87,6 @@ export interface FileExplorerProps {
dispatchCopyFile: (src: string, dest: string) => Promise<void>, dispatchCopyFile: (src: string, dest: string) => Promise<void>,
dispatchCopyFolder: (src: string, dest: string) => Promise<void>, dispatchCopyFolder: (src: string, dest: string) => Promise<void>,
dispatchRunScript: (path: string) => Promise<void>, dispatchRunScript: (path: string) => Promise<void>,
dispatchRunScriptWithMocha: (path: string) => Promise<void>,
dispatchPublishToGist: (path?: string, type?: string) => Promise<void>, dispatchPublishToGist: (path?: string, type?: string) => Promise<void>,
dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>, dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>,
dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void>, dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void>,
@ -118,7 +117,6 @@ export interface FileExplorerContextMenuProps {
publishFolderToGist?: (path?: string, type?: string) => void, publishFolderToGist?: (path?: string, type?: string) => void,
publishFileToGist?: (path?: string, type?: string) => void, publishFileToGist?: (path?: string, type?: string) => void,
runScript?: (path: string) => void, runScript?: (path: string) => void,
runScriptWithMocha?: (path: string) => void,
emit?: (cmd: customAction) => void, emit?: (cmd: customAction) => void,
pageX: number, pageX: number,
pageY: number, pageY: number,

@ -30,12 +30,6 @@ export const contextMenuActions: MenuItems = [{
extension: ['.js'], extension: ['.js'],
multiselect: false, multiselect: false,
label: '' label: ''
}, {
id: 'runWithMocha',
name: 'Run with Mocha',
extension: ['.js'],
multiselect: false,
label: ''
}, { }, {
id: 'pushChangesToGist', id: 'pushChangesToGist',
name: 'Push changes to gist', name: 'Push changes to gist',

@ -55,7 +55,7 @@ export class RemixURLResolver {
// eslint-disable-next-line no-useless-catch // eslint-disable-next-line no-useless-catch
try { try {
const req = `https://raw.githubusercontent.com/${root}/${reference}/${filePath}` const req = `https://raw.githubusercontent.com/${root}/${reference}/${filePath}`
const response: AxiosResponse = await axios.get(req) const response: AxiosResponse = await axios.get(req, { transformResponse: [] })
return { content: response.data, cleanUrl: root + '/' + filePath } return { content: response.data, cleanUrl: root + '/' + filePath }
} catch (e) { } catch (e) {
throw e throw e
@ -70,7 +70,7 @@ export class RemixURLResolver {
async handleHttp (url: string, cleanUrl: string): Promise<HandlerResponse> { async handleHttp (url: string, cleanUrl: string): Promise<HandlerResponse> {
// eslint-disable-next-line no-useless-catch // eslint-disable-next-line no-useless-catch
try { try {
const response: AxiosResponse = await axios.get(url) const response: AxiosResponse = await axios.get(url, { transformResponse: [] })
return { content: response.data, cleanUrl } return { content: response.data, cleanUrl }
} catch (e) { } catch (e) {
throw e throw e
@ -85,7 +85,7 @@ export class RemixURLResolver {
async handleHttps (url: string, cleanUrl: string): Promise<HandlerResponse> { async handleHttps (url: string, cleanUrl: string): Promise<HandlerResponse> {
// eslint-disable-next-line no-useless-catch // eslint-disable-next-line no-useless-catch
try { try {
const response: AxiosResponse = await axios.get(url) const response: AxiosResponse = await axios.get(url, { transformResponse: [] })
return { content: response.data, cleanUrl } return { content: response.data, cleanUrl }
} catch (e) { } catch (e) {
throw e throw e
@ -97,7 +97,7 @@ export class RemixURLResolver {
try { try {
const bzz = new Bzz({ url: this.protocol + '//swarm-gateways.net' }) const bzz = new Bzz({ url: this.protocol + '//swarm-gateways.net' })
const url = bzz.getDownloadURL(cleanUrl, { mode: 'raw' }) const url = bzz.getDownloadURL(cleanUrl, { mode: 'raw' })
const response: AxiosResponse = await axios.get(url) const response: AxiosResponse = await axios.get(url, { transformResponse: [] })
return { content: response.data, cleanUrl } return { content: response.data, cleanUrl }
} catch (e) { } catch (e) {
throw e throw e
@ -116,7 +116,7 @@ export class RemixURLResolver {
const req = 'https://ipfs.remixproject.org/' + url const req = 'https://ipfs.remixproject.org/' + url
// If you don't find greeter.sol on ipfs gateway use local // If you don't find greeter.sol on ipfs gateway use local
// const req = 'http://localhost:8080/' + url // const req = 'http://localhost:8080/' + url
const response: AxiosResponse = await axios.get(req) const response: AxiosResponse = await axios.get(req, { transformResponse: [] })
return { content: response.data, cleanUrl: url.replace('ipfs/', '') } return { content: response.data, cleanUrl: url.replace('ipfs/', '') }
} catch (e) { } catch (e) {
throw e throw e
@ -131,7 +131,7 @@ export class RemixURLResolver {
// eslint-disable-next-line no-useless-catch // eslint-disable-next-line no-useless-catch
try { try {
const req = 'https://unpkg.com/' + url const req = 'https://unpkg.com/' + url
const response: AxiosResponse = await axios.get(req) const response: AxiosResponse = await axios.get(req, { transformResponse: [] })
return { content: response.data, cleanUrl: url } return { content: response.data, cleanUrl: url }
} catch (e) { } catch (e) {
throw e throw e

@ -161,7 +161,7 @@
"@remixproject/plugin-ws": "^0.3.28", "@remixproject/plugin-ws": "^0.3.28",
"ansi-gray": "^0.1.1", "ansi-gray": "^0.1.1",
"async": "^2.6.2", "async": "^2.6.2",
"axios": ">=0.21.1", "axios": ">=0.26.0",
"brace": "^0.8.0", "brace": "^0.8.0",
"change-case": "^4.1.1", "change-case": "^4.1.1",
"chokidar": "^2.1.8", "chokidar": "^2.1.8",

Loading…
Cancel
Save