Commit 4a1c86fe authored by aniket-engg's avatar aniket-engg Committed by Aniket

slither websocket listener

parent b35ab8eb
...@@ -25,6 +25,7 @@ async function warnLatestVersion () { ...@@ -25,6 +25,7 @@ async function warnLatestVersion () {
const services = { const services = {
git: (readOnly: boolean) => new servicesList.GitClient(readOnly), git: (readOnly: boolean) => new servicesList.GitClient(readOnly),
hardhat: (readOnly: boolean) => new servicesList.HardhatClient(readOnly), hardhat: (readOnly: boolean) => new servicesList.HardhatClient(readOnly),
slither: (readOnly: boolean) => new servicesList.SlitherClient(readOnly),
folder: (readOnly: boolean) => new servicesList.Sharedfolder(readOnly) folder: (readOnly: boolean) => new servicesList.Sharedfolder(readOnly)
} }
...@@ -32,11 +33,12 @@ const services = { ...@@ -32,11 +33,12 @@ const services = {
const ports = { const ports = {
git: 65521, git: 65521,
hardhat: 65522, hardhat: 65522,
slither: 65523,
folder: 65520 folder: 65520
} }
const killCallBack: Array<Function> = [] 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)) const socket = new WebSocket(ports[service], { remixIdeUrl: program.remixIde }, () => services[service](program.readOnly || false))
socket.start(callback) socket.start(callback)
killCallBack.push(socket.close.bind(socket)) killCallBack.push(socket.close.bind(socket))
...@@ -94,6 +96,10 @@ function errorHandler (error: any, service: string) { ...@@ -94,6 +96,10 @@ function errorHandler (error: any, service: string) {
sharedFolderClient.setupNotifications(program.sharedFolder) sharedFolderClient.setupNotifications(program.sharedFolder)
sharedFolderClient.sharedFolder(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 // Run hardhat service if a hardhat project is shared as folder
const hardhatConfigFilePath = absolutePath('./', program.sharedFolder) + '/hardhat.config.js' const hardhatConfigFilePath = absolutePath('./', program.sharedFolder) + '/hardhat.config.js'
const isHardhatProject = fs.existsSync(hardhatConfigFilePath) const isHardhatProject = fs.existsSync(hardhatConfigFilePath)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { RemixdClient as sharedFolder } from './services/remixdClient' import { RemixdClient as sharedFolder } from './services/remixdClient'
import { GitClient } from './services/gitClient' import { GitClient } from './services/gitClient'
import { HardhatClient } from './services/hardhatClient' import { HardhatClient } from './services/hardhatClient'
import { SlitherClient } from './services/slitherClient'
import Websocket from './websocket' import Websocket from './websocket'
import * as utils from './utils' import * as utils from './utils'
...@@ -11,6 +12,7 @@ module.exports = { ...@@ -11,6 +12,7 @@ module.exports = {
services: { services: {
sharedFolder, sharedFolder,
GitClient, GitClient,
HardhatClient HardhatClient,
SlitherClient
} }
} }
export { RemixdClient as Sharedfolder } from './services/remixdClient' export { RemixdClient as Sharedfolder } from './services/remixdClient'
export { GitClient } from './services/gitClient' export { GitClient } from './services/gitClient'
export { HardhatClient } from './services/hardhatClient' export { HardhatClient } from './services/hardhatClient'
export { SlitherClient } from './services/slitherClient'
...@@ -19,7 +19,8 @@ export default class WebSocket { ...@@ -19,7 +19,8 @@ export default class WebSocket {
const listeners = { const listeners = {
65520: 'remixd', 65520: 'remixd',
65521: 'git', 65521: 'git',
65522: 'hardhat' 65522: 'hardhat',
65523: 'slither'
} }
this.server.on('error', (error: Error) => { this.server.on('error', (error: Error) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment