From 52fd10db50562042864c0a72b1ca90ed3541a350 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Fri, 4 Mar 2022 10:26:18 +0100 Subject: [PATCH 1/6] update resolver --- .../src/tests/importFromGithub.test.ts | 24 ++++++++++++++++++- libs/remix-url-resolver/src/resolve.ts | 12 +++++----- package.json | 2 +- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/importFromGithub.test.ts b/apps/remix-ide-e2e/src/tests/importFromGithub.test.ts index bbf57ca3db..dab5c3a879 100644 --- a/apps/remix-ide-e2e/src/tests/importFromGithub.test.ts +++ b/apps/remix-ide-e2e/src/tests/importFromGithub.test.ts @@ -4,7 +4,8 @@ import init from '../helpers/init' const testData = { 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 = { @@ -57,6 +58,27 @@ module.exports = { .scrollAndClick('[data-id="homeTab-modal-footer-ok-react"]') .openFile('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() } } diff --git a/libs/remix-url-resolver/src/resolve.ts b/libs/remix-url-resolver/src/resolve.ts index 2f30fc4339..e2b77adddc 100644 --- a/libs/remix-url-resolver/src/resolve.ts +++ b/libs/remix-url-resolver/src/resolve.ts @@ -55,7 +55,7 @@ export class RemixURLResolver { // eslint-disable-next-line no-useless-catch try { 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 } } catch (e) { throw e @@ -70,7 +70,7 @@ export class RemixURLResolver { async handleHttp (url: string, cleanUrl: string): Promise { // eslint-disable-next-line no-useless-catch try { - const response: AxiosResponse = await axios.get(url) + const response: AxiosResponse = await axios.get(url, { transformResponse: [] }) return { content: response.data, cleanUrl } } catch (e) { throw e @@ -85,7 +85,7 @@ export class RemixURLResolver { async handleHttps (url: string, cleanUrl: string): Promise { // eslint-disable-next-line no-useless-catch try { - const response: AxiosResponse = await axios.get(url) + const response: AxiosResponse = await axios.get(url, { transformResponse: [] }) return { content: response.data, cleanUrl } } catch (e) { throw e @@ -97,7 +97,7 @@ export class RemixURLResolver { try { const bzz = new Bzz({ url: this.protocol + '//swarm-gateways.net' }) 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 } } catch (e) { throw e @@ -116,7 +116,7 @@ export class RemixURLResolver { const req = 'https://ipfs.remixproject.org/' + url // If you don't find greeter.sol on ipfs gateway use local // 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/', '') } } catch (e) { throw e @@ -131,7 +131,7 @@ export class RemixURLResolver { // eslint-disable-next-line no-useless-catch try { 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 } } catch (e) { throw e diff --git a/package.json b/package.json index 0c67efac02..8672f3fc26 100644 --- a/package.json +++ b/package.json @@ -161,7 +161,7 @@ "@remixproject/plugin-ws": "^0.3.28", "ansi-gray": "^0.1.1", "async": "^2.6.2", - "axios": ">=0.21.1", + "axios": ">=0.26.0", "brace": "^0.8.0", "change-case": "^4.1.1", "chokidar": "^2.1.8", From 7cb9fee16a1edde43ad95f91f4873107d5408e28 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 7 Mar 2022 11:15:17 +0100 Subject: [PATCH 2/6] small ui fix --- libs/remix-ui/settings/src/lib/remix-ui-settings.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index d52e1ad86a..ea3821804f 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -198,7 +198,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
{ swarmSettingsTitle }
-
+
From 5519059ec8fd7e44871b96b0f47fb25ea9c2ca07 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 8 Mar 2022 13:17:34 +0530 Subject: [PATCH 3/6] caret for calls fixed --- libs/remix-ui/terminal/src/lib/components/RenderCall.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx b/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx index acfbc0399e..7656ce2680 100644 --- a/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx +++ b/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx @@ -34,7 +34,7 @@ const RenderCall = ({ tx, resolvedData, logs, index, plugin, showTableHash, txDe
debug(event, tx)}>Debug
- +
{showTableHash.includes(tx.hash) ? showTable({ hash: tx.hash, From 371308835b0c9a86482698319b875b5f4e8ea83d Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 7 Mar 2022 16:44:26 +0100 Subject: [PATCH 4/6] remove run script with Mocha --- libs/remix-ui/workspace/src/lib/actions/index.ts | 11 ----------- .../src/lib/components/file-explorer-context-menu.tsx | 6 +----- .../workspace/src/lib/components/file-explorer.tsx | 9 --------- libs/remix-ui/workspace/src/lib/contexts/index.ts | 1 - .../src/lib/providers/FileSystemProvider.tsx | 7 +------ .../remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 2 -- libs/remix-ui/workspace/src/lib/types/index.ts | 2 -- 7 files changed, 2 insertions(+), 36 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 12f178348c..ae248d6fa8 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -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) => { await plugin.call(cmd.id, cmd.name, cmd) } diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx index b9bad4b170..5e6518c2de 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx @@ -12,7 +12,7 @@ declare global { const _paq = window._paq = window._paq || [] //eslint-disable-line 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) useEffect(() => { contextMenuRef.current.focus() @@ -98,10 +98,6 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) => _paq.push(['trackEvent', 'fileExplorer', 'runScript']) runScript(path) break - case 'Run with Mocha': - _paq.push(['trackEvent', 'fileExplorer', 'runScriptWithMocha']) - runScriptWithMocha(path) - break case 'Copy': copy(path, type) break diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx index d5c0fa8f75..5ae7de8d05 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -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) => { try { props.dispatchEmitContextMenuEvent(cmd) @@ -462,7 +454,6 @@ export const FileExplorer = (props: FileExplorerProps) => { deletePath={deletePath} renamePath={editModeOn} runScript={runScript} - runScriptWithMocha={runScriptWithMocha} copy={handleCopyClick} paste={handlePasteClick} emit={emitContextMenuEvent} diff --git a/libs/remix-ui/workspace/src/lib/contexts/index.ts b/libs/remix-ui/workspace/src/lib/contexts/index.ts index 20c9b46633..1aedce98b5 100644 --- a/libs/remix-ui/workspace/src/lib/contexts/index.ts +++ b/libs/remix-ui/workspace/src/lib/contexts/index.ts @@ -25,7 +25,6 @@ export const FileSystemContext = createContext<{ dispatchCopyFile: (src: string, dest: string) => Promise, dispatchCopyFolder: (src: string, dest: string) => Promise, dispatchRunScript: (path: string) => Promise, - dispatchRunScriptWithMocha: (path: string) => Promise, dispatchEmitContextMenuEvent: (cmd: customAction) => Promise, dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise dispatchHandleExpandPath: (paths: string[]) => Promise diff --git a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx index 330270cf5e..904ed7cade 100644 --- a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx +++ b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx @@ -5,7 +5,7 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line // eslint-disable-next-line @typescript-eslint/no-unused-vars import { FileSystemContext } from '../contexts' 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' // eslint-disable-next-line @typescript-eslint/no-unused-vars import { Workspace } from '../remix-ui-workspace' @@ -103,10 +103,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => { await runScript(path) } - const dispatchRunScriptWithMocha = async (path: string) => { - await runScriptWithMocha(path) - } - const dispatchEmitContextMenuEvent = async (cmd: customAction) => { await emitContextMenuEvent(cmd) } @@ -216,7 +212,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => { dispatchCopyFile, dispatchCopyFolder, dispatchRunScript, - dispatchRunScriptWithMocha, dispatchEmitContextMenuEvent, dispatchHandleClickFile, dispatchHandleExpandPath diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index a5a84e1e1f..a51224f86c 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -198,7 +198,6 @@ export function Workspace () { dispatchCopyFolder={global.dispatchCopyFolder} dispatchPublishToGist={global.dispatchPublishToGist} dispatchRunScript={global.dispatchRunScript} - dispatchRunScriptWithMocha={global.dispatchRunScriptWithMocha} dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent} dispatchHandleClickFile={global.dispatchHandleClickFile} dispatchSetFocusElement={global.dispatchSetFocusElement} @@ -234,7 +233,6 @@ export function Workspace () { dispatchCopyFolder={global.dispatchCopyFolder} dispatchPublishToGist={global.dispatchPublishToGist} dispatchRunScript={global.dispatchRunScript} - dispatchRunScriptWithMocha={global.dispatchRunScriptWithMocha} dispatchEmitContextMenuEvent={global.dispatchEmitContextMenuEvent} dispatchHandleClickFile={global.dispatchHandleClickFile} dispatchSetFocusElement={global.dispatchSetFocusElement} diff --git a/libs/remix-ui/workspace/src/lib/types/index.ts b/libs/remix-ui/workspace/src/lib/types/index.ts index 0db43d51dc..d7ce409d72 100644 --- a/libs/remix-ui/workspace/src/lib/types/index.ts +++ b/libs/remix-ui/workspace/src/lib/types/index.ts @@ -87,7 +87,6 @@ export interface FileExplorerProps { dispatchCopyFile: (src: string, dest: string) => Promise, dispatchCopyFolder: (src: string, dest: string) => Promise, dispatchRunScript: (path: string) => Promise, - dispatchRunScriptWithMocha: (path: string) => Promise, dispatchPublishToGist: (path?: string, type?: string) => Promise, dispatchEmitContextMenuEvent: (cmd: customAction) => Promise, dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise, @@ -118,7 +117,6 @@ export interface FileExplorerContextMenuProps { publishFolderToGist?: (path?: string, type?: string) => void, publishFileToGist?: (path?: string, type?: string) => void, runScript?: (path: string) => void, - runScriptWithMocha?: (path: string) => void, emit?: (cmd: customAction) => void, pageX: number, pageY: number, From bf21d38fbc9b0c00b602cd796e037dd6fc16d325 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 8 Mar 2022 18:25:40 +0530 Subject: [PATCH 5/6] remove action --- libs/remix-ui/workspace/src/lib/utils/index.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/utils/index.ts b/libs/remix-ui/workspace/src/lib/utils/index.ts index f2558c1b2c..0dd70b14bc 100644 --- a/libs/remix-ui/workspace/src/lib/utils/index.ts +++ b/libs/remix-ui/workspace/src/lib/utils/index.ts @@ -30,12 +30,6 @@ export const contextMenuActions: MenuItems = [{ extension: ['.js'], multiselect: false, label: '' -}, { - id: 'runWithMocha', - name: 'Run with Mocha', - extension: ['.js'], - multiselect: false, - label: '' }, { id: 'pushChangesToGist', name: 'Push changes to gist', From f02a5e1905c795c34c4ca11d13a88329da24bd8d Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 10 Mar 2022 09:27:38 +0100 Subject: [PATCH 6/6] fix decoding events --- libs/remix-lib/src/execution/eventsDecoder.ts | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/libs/remix-lib/src/execution/eventsDecoder.ts b/libs/remix-lib/src/execution/eventsDecoder.ts index 4622b245fd..cdb794fd71 100644 --- a/libs/remix-lib/src/execution/eventsDecoder.ts +++ b/libs/remix-lib/src/execution/eventsDecoder.ts @@ -56,21 +56,22 @@ export class EventsDecoder { return eventsABI } - _event (hash: string, eventsABI: Record, contractName: string) { - const events = eventsABI[contractName] - if (!events) return null - - if (events[hash]) { - const event = events[hash] - for (const input of event.inputs) { - if (input.type === 'function') { - input.type = 'bytes24' - input.baseType = 'bytes24' + _event (hash, eventsABI) { + // get all the events responding to that hash. + const contracts = [] + for (const k in eventsABI) { + if (eventsABI[k][hash]) { + const event = eventsABI[k][hash] + for (const input of event.inputs) { + if (input.type === 'function') { + input.type = 'bytes24' + input.baseType = 'bytes24' + } } + contracts.push(event) } - return event } - return null + return contracts } _stringifyBigNumber (value): string { @@ -95,16 +96,23 @@ export class EventsDecoder { // [address, topics, mem] const log = logs[i] const topicId = log.topics[0] - const eventAbi = this._event(topicId.replace('0x', ''), eventsABI, contractName) - if (eventAbi) { - const decodedlog = eventAbi.abi.parseLog(log) - const decoded = {} - for (const v in decodedlog.args) { - decoded[v] = this._stringifyEvent(decodedlog.args[v]) + const eventAbis = this._event(topicId.replace('0x', ''), eventsABI) + for (const eventAbi of eventAbis) { + try { + if (eventAbi) { + const decodedlog = eventAbi.abi.parseLog(log) + 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 })