slither websocket listener

pull/1398/head
aniket-engg 4 years ago committed by Aniket
parent b35ab8eb5a
commit 4a1c86fe14
  1. 8
      libs/remixd/src/bin/remixd.ts
  2. 4
      libs/remixd/src/index.ts
  3. 1
      libs/remixd/src/serviceList.ts
  4. 3
      libs/remixd/src/websocket.ts

@ -25,6 +25,7 @@ async function warnLatestVersion () {
const services = {
git: (readOnly: boolean) => new servicesList.GitClient(readOnly),
hardhat: (readOnly: boolean) => new servicesList.HardhatClient(readOnly),
slither: (readOnly: boolean) => new servicesList.SlitherClient(readOnly),
folder: (readOnly: boolean) => new servicesList.Sharedfolder(readOnly)
}
@ -32,11 +33,12 @@ const services = {
const ports = {
git: 65521,
hardhat: 65522,
slither: 65523,
folder: 65520
}
const killCallBack: Array<Function> = []
function startService<S extends 'git' | 'hardhat' | 'folder'> (service: S, callback: (ws: WS, sharedFolderClient: servicesList.Sharedfolder, error?:Error) => void) {
function startService<S extends 'git' | 'hardhat' | 'slither' | 'folder'> (service: S, callback: (ws: WS, sharedFolderClient: servicesList.Sharedfolder, error?:Error) => void) {
const socket = new WebSocket(ports[service], { remixIdeUrl: program.remixIde }, () => services[service](program.readOnly || false))
socket.start(callback)
killCallBack.push(socket.close.bind(socket))
@ -94,6 +96,10 @@ function errorHandler (error: any, service: string) {
sharedFolderClient.setupNotifications(program.sharedFolder)
sharedFolderClient.sharedFolder(program.sharedFolder)
})
startService('slither', (ws: WS, sharedFolderClient: servicesList.Sharedfolder) => {
sharedFolderClient.setWebSocket(ws)
sharedFolderClient.sharedFolder(program.sharedFolder)
})
// Run hardhat service if a hardhat project is shared as folder
const hardhatConfigFilePath = absolutePath('./', program.sharedFolder) + '/hardhat.config.js'
const isHardhatProject = fs.existsSync(hardhatConfigFilePath)

@ -2,6 +2,7 @@
import { RemixdClient as sharedFolder } from './services/remixdClient'
import { GitClient } from './services/gitClient'
import { HardhatClient } from './services/hardhatClient'
import { SlitherClient } from './services/slitherClient'
import Websocket from './websocket'
import * as utils from './utils'
@ -11,6 +12,7 @@ module.exports = {
services: {
sharedFolder,
GitClient,
HardhatClient
HardhatClient,
SlitherClient
}
}

@ -1,3 +1,4 @@
export { RemixdClient as Sharedfolder } from './services/remixdClient'
export { GitClient } from './services/gitClient'
export { HardhatClient } from './services/hardhatClient'
export { SlitherClient } from './services/slitherClient'

@ -19,7 +19,8 @@ export default class WebSocket {
const listeners = {
65520: 'remixd',
65521: 'git',
65522: 'hardhat'
65522: 'hardhat',
65523: 'slither'
}
this.server.on('error', (error: Error) => {

Loading…
Cancel
Save