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. 26
      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 = {
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()
}
}

@ -56,21 +56,22 @@ export class EventsDecoder {
return eventsABI
}
_event (hash: string, eventsABI: Record<string, unknown>, contractName: string) {
const events = eventsABI[contractName]
if (!events) return null
if (events[hash]) {
const event = events[hash]
_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'
}
}
return event
contracts.push(event)
}
}
return null
return contracts
}
_stringifyBigNumber (value): string {
@ -95,7 +96,9 @@ export class EventsDecoder {
// [address, topics, mem]
const log = logs[i]
const topicId = log.topics[0]
const eventAbi = this._event(topicId.replace('0x', ''), eventsABI, contractName)
const eventAbis = this._event(topicId.replace('0x', ''), eventsABI)
for (const eventAbi of eventAbis) {
try {
if (eventAbi) {
const decodedlog = eventAbi.abi.parseLog(log)
const decoded = {}
@ -106,6 +109,11 @@ export class EventsDecoder {
} else {
events.push({ from: log.address, data: log.data, topics: log.topics })
}
break // if one of the iteration is successful
} catch (e) {
continue
}
}
}
cb(null, { decoded: events, raw: logs })
}

@ -198,7 +198,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
<div className="border-top">
<div className="card-body pt-3 pb-2">
<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">
<input id="swarmprivatebeeaddress" data-id="settingsPrivateBeeAddress" className="form-control" onChange={handleSavePrivateBeeAddress} value={ privateBeeAddress } />
</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_debug btn btn-primary btn-sm" onClick={(event) => debug(event, tx)}>Debug</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>
{showTableHash.includes(tx.hash) ? showTable({
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) => {
await plugin.call(cmd.id, cmd.name, cmd)
}

@ -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

@ -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}

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

@ -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}

@ -87,7 +87,6 @@ export interface FileExplorerProps {
dispatchCopyFile: (src: string, dest: string) => Promise<void>,
dispatchCopyFolder: (src: string, dest: string) => Promise<void>,
dispatchRunScript: (path: string) => Promise<void>,
dispatchRunScriptWithMocha: (path: string) => Promise<void>,
dispatchPublishToGist: (path?: string, type?: string) => Promise<void>,
dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>,
dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise<void>,
@ -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,

@ -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',

@ -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<HandlerResponse> {
// 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<HandlerResponse> {
// 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

@ -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",

Loading…
Cancel
Save