Merge branch 'master' into react-plugin-manager

pull/1344/head
Joe Izang 3 years ago committed by GitHub
commit 1fb89b0177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 77
      apps/remix-ide/src/app/files/dgitProvider.js
  2. 8
      libs/remixd/src/bin/remixd.ts
  3. 1
      libs/remixd/src/services/slitherClient.ts

@ -38,6 +38,13 @@ class DGitProvider extends Plugin {
protocol: 'https',
ipfsurl: 'https://ipfs.io/ipfs/'
}
this.remixIPFS = {
host: 'ipfs.remixproject.org',
port: 443,
protocol: 'https',
ipfsurl: 'https://ipfs.remixproject.org/ipfs/'
}
this.ipfsSources = [this.remixIPFS, this.globalIPFSConfig, this.ipfsconfig]
}
async getGitConfig () {
@ -287,36 +294,58 @@ class DGitProvider extends Plugin {
}
};
async importIPFSFiles (config, cid, workspace) {
const ipfs = IpfsHttpClient(config)
let result = false
try {
const data = ipfs.get(cid, { timeout: 10000 })
for await (const file of data) {
if (file.path) result = true
file.path = file.path.replace(cid, '')
if (!file.content) {
continue
}
const content = []
for await (const chunk of file.content) {
content.push(chunk)
}
const dir = path.dirname(file.path)
try {
this.createDirectories(`${workspace.absolutePath}/${dir}`)
} catch (e) {}
try {
window.remixFileSystem.writeFileSync(`${workspace.absolutePath}/${file.path}`, Buffer.concat(content) || new Uint8Array())
} catch (e) {}
}
} catch (e) {
}
return result
}
calculateLocalStorage () {
var _lsTotal = 0
var _xLen; var _x
for (_x in localStorage) {
// eslint-disable-next-line no-prototype-builtins
if (!localStorage.hasOwnProperty(_x)) {
continue
}
_xLen = ((localStorage[_x].length + _x.length) * 2)
_lsTotal += _xLen
};
return (_lsTotal / 1024).toFixed(2)
}
async pull (cmd) {
const permission = await this.askUserPermission('pull', 'Import multiple files into your workspaces.')
console.log(this.ipfsconfig)
if (!permission) return false
if (this.calculateLocalStorage() > 10000) throw new Error('Local browser storage is full.')
const cid = cmd.cid
if (!cmd.local) {
this.ipfs = IpfsHttpClient(this.globalIPFSConfig)
} else {
if (!this.checkIpfsConfig()) return false
}
await this.call('filePanel', 'createWorkspace', `workspace_${Date.now()}`, false)
const workspace = await this.call('filePanel', 'getCurrentWorkspace')
for await (const file of this.ipfs.get(cid)) {
file.path = file.path.replace(cid, '')
if (!file.content) {
continue
}
const content = []
for await (const chunk of file.content) {
content.push(chunk)
}
const dir = path.dirname(file.path)
try {
this.createDirectories(`${workspace.absolutePath}/${dir}`)
} catch (e) {}
try {
window.remixFileSystem.writeFileSync(`${workspace.absolutePath}/${file.path}`, Buffer.concat(content) || new Uint8Array())
} catch (e) {}
}
this.call('fileManager', 'refresh')
const result = await this.importIPFSFiles(this.remixIPFS, cid, workspace) || await this.importIPFSFiles(this.ipfsconfig, cid, workspace) || await this.importIPFSFiles(this.globalIPFSConfig, cid, workspace)
await this.call('fileManager', 'refresh')
if (!result) throw new Error(`Cannot pull files from IPFS at ${cid}`)
}
async getItem (name) {

@ -6,7 +6,7 @@ import * as servicesList from '../serviceList'
import * as WS from 'ws' // eslint-disable-line
import { getDomain, absolutePath } from '../utils'
import Axios from 'axios'
import * as fs from 'fs-extra'
import { writeJSON, existsSync } from 'fs-extra'
import * as path from 'path'
import * as program from 'commander'
@ -83,7 +83,7 @@ function errorHandler (error: any, service: string) {
console.log('\x1b[33m%s\x1b[0m', '[WARN] You may now only use IDE at ' + program.remixIde + ' to connect to that instance')
}
if (program.sharedFolder) {
if (program.sharedFolder && existsSync(absolutePath('./', program.sharedFolder))) {
console.log('\x1b[33m%s\x1b[0m', '[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.')
console.log('\x1b[33m%s\x1b[0m', '[WARN] Symbolic links are not forwarded to Remix IDE\n')
try {
@ -102,7 +102,7 @@ function errorHandler (error: any, service: string) {
})
// Run hardhat service if a hardhat project is shared as folder
const hardhatConfigFilePath = absolutePath('./', program.sharedFolder) + '/hardhat.config.js'
const isHardhatProject = fs.existsSync(hardhatConfigFilePath)
const isHardhatProject = existsSync(hardhatConfigFilePath)
if (isHardhatProject) {
startService('hardhat', (ws: WS, sharedFolderClient: servicesList.Sharedfolder, error: Error) => {
if (error) {
@ -151,7 +151,7 @@ function errorHandler (error: any, service: string) {
const { data } = await Axios.get(gistUrl)
try {
await fs.writeJSON(path.resolve(path.join(__dirname, '..', 'origins.json')), { data })
await writeJSON(path.resolve(path.join(__dirname, '..', 'origins.json')), { data })
} catch (e) {
console.error(e)
}

@ -137,7 +137,6 @@ export class SlitherClient extends PluginClient {
const outputFile: string = 'remix-slitherReport_' + Math.floor(Date.now() / 1000) + '.json'
const cmd: string = `slither ${filePath} ${solcArgs} ${solcRemaps} --json ${outputFile}`
console.log('\x1b[32m%s\x1b[0m', '[Slither Analysis]: Running Slither...')
console.log(cmd)
// Added `stdio: 'ignore'` as for contract with NPM imports analysis which is exported in 'stderr'
// get too big and hangs the process. We process analysis from the report file only
const child = spawn(cmd, { cwd: this.currentSharedFolder, shell: true, stdio: 'ignore' })

Loading…
Cancel
Save