websocket proxy serve

pull/4735/head
aniket-engg 6 months ago committed by Aniket
parent f110b55acd
commit 231c65a931
  1. 28
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx

@ -220,11 +220,8 @@ export function UniversalDappUI(props: UdappProps) {
} }
const handleScanContinue = async () => { const handleScanContinue = async () => {
console.log('inside handleScanContinue')
const workspace = await props.plugin.call('filePanel', 'getCurrentWorkspace') const workspace = await props.plugin.call('filePanel', 'getCurrentWorkspace')
const fileName = props.instance.filePath || `${workspace.name}/${props.instance.contractData.contract.file}` const fileName = props.instance.filePath || `${workspace.name}/${props.instance.contractData.contract.file}`
console.log('fileName---->', fileName)
// const existsOrNot = await props.plugin.call('fileManager', 'exists', fileName) // const existsOrNot = await props.plugin.call('fileManager', 'exists', fileName)
// console.log('existsOrNot---->', existsOrNot) // console.log('existsOrNot---->', existsOrNot)
// const file = await props.plugin.call('fileManager', 'readFile', fileName) // const file = await props.plugin.call('fileManager', 'readFile', fileName)
@ -259,40 +256,27 @@ export function UniversalDappUI(props: UdappProps) {
return number; return number;
} }
}` }`
console.log('file---->', file)
const urlResponse = await axios.post(`https://solidityscan.remixproject.org/`, { const urlResponse = await axios.post(`https://solidityscan.remixproject.org/`, {
file, file,
fileName fileName
}) })
console.log('urlResponse----->', urlResponse.data)
// websocket connection // websocket connection
if (urlResponse.data.status === 'success') { if (urlResponse.data.status === 'success') {
const ws = new WebSocket('wss://api-ws.solidityscan.com') const ws = new WebSocket('wss://solidityscan.remixproject.org/solidityscan')
ws.addEventListener('error', console.error); ws.addEventListener('error', console.error);
const bearerToken = ""
ws.addEventListener('open', (event) => { ws.addEventListener('open', (event) => {
const tokenRegRequest = { console.log('Connected to the server.')
"action": "message",
"payload": {
"type": "auth_token_register",
"body": {
"auth_token": bearerToken
}
}
}
ws.send(JSON.stringify(tokenRegRequest))
}) })
ws.addEventListener('message', (event) => { ws.addEventListener('message', (event) => {
const data = JSON.parse(event.data) const data = JSON.parse(event.data)
if (data.type === "auth_token_register" && data.payload.message === "Auth token registered.") { if (data.type === "auth_token_register" && data.payload.message === "Auth token registered.") {
const reqToInitScan = {
const request2 = {
"action": "message", "action": "message",
"payload": { "payload": {
"type": "private_project_scan_initiate", "type": "private_project_scan_initiate",
@ -300,12 +284,12 @@ export function UniversalDappUI(props: UdappProps) {
"file_urls": [ "file_urls": [
urlResponse.data.result.url urlResponse.data.result.url
], ],
"project_name": "TestRemix", "project_name": "RemixProject",
"project_type": "new" "project_type": "new"
} }
} }
} }
ws.send(JSON.stringify(request2)) ws.send(JSON.stringify(reqToInitScan))
} }
}) })

Loading…
Cancel
Save