handle error

pull/4845/head
aniket-engg 6 months ago committed by Aniket
parent fba3013fd1
commit 5d9f931aa5
  1. 1
      apps/remix-ide/src/app/tabs/locales/en/udapp.json
  2. 18
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx

@ -85,6 +85,7 @@
"udapp.solScan.modalMessage": "Contract code will be shared to third party Solidity Scan.\n Would you like to continue?", "udapp.solScan.modalMessage": "Contract code will be shared to third party Solidity Scan.\n Would you like to continue?",
"udapp.solScan.modalOkLabel": "Continue", "udapp.solScan.modalOkLabel": "Continue",
"udapp.solScan.modalCancelLabel": "Cancel", "udapp.solScan.modalCancelLabel": "Cancel",
"udapp.solScan.errModalTitle": "Error",
"udapp._comment_recorderCardUI.tsx": "libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx", "udapp._comment_recorderCardUI.tsx": "libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx",
"udapp.transactionsRecorded": "Transactions recorded", "udapp.transactionsRecorded": "Transactions recorded",

@ -220,6 +220,7 @@ export function UniversalDappUI(props: UdappProps) {
} }
const handleScanContinue = async () => { const handleScanContinue = async () => {
await props.plugin.call('notification', 'toast', 'Running scan...')
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}`
// const existsOrNot = await props.plugin.call('fileManager', 'exists', fileName) // const existsOrNot = await props.plugin.call('fileManager', 'exists', fileName)
@ -270,10 +271,10 @@ export function UniversalDappUI(props: UdappProps) {
ws.addEventListener('error', console.error); ws.addEventListener('error', console.error);
ws.addEventListener('open', (event) => { ws.addEventListener('open', (event) => {
console.log('Connected to the server.') console.log('Connected to the solidityscan server.')
}) })
ws.addEventListener('message', (event) => { ws.addEventListener('message', async (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 reqToInitScan = {
@ -290,6 +291,14 @@ export function UniversalDappUI(props: UdappProps) {
} }
} }
ws.send(JSON.stringify(reqToInitScan)) ws.send(JSON.stringify(reqToInitScan))
} else if (data.type === "scan_status" && data.payload.scan_status === "download_failed") {
const modal: AppModal = {
id: 'SolidityScanError',
title: <FormattedMessage id="udapp.solScan.errModalTitle" />,
message: data.payload.scan_status_err_message,
okLabel: 'Close'
}
await props.plugin.call('notification', 'modal', modal)
} }
}) })
@ -304,11 +313,10 @@ export function UniversalDappUI(props: UdappProps) {
message: <FormattedMessage id="udapp.solScan.modalMessage" />, message: <FormattedMessage id="udapp.solScan.modalMessage" />,
okLabel: <FormattedMessage id="udapp.solScan.modalOkLabel" />, okLabel: <FormattedMessage id="udapp.solScan.modalOkLabel" />,
okFn: handleScanContinue, okFn: handleScanContinue,
cancelLabel: <FormattedMessage id="udapp.solScan.modalCancelLabel" /> cancelLabel: <FormattedMessage id="udapp.solScan.modalCancelLabel" />,
} }
const result = await props.plugin.call('notification', 'modal', modal) await props.plugin.call('notification', 'modal', modal)
console.log('askPermissionToScan----> result----->', result)
} }
const label = (key: string | number, value: string) => { const label = (key: string | number, value: string) => {

Loading…
Cancel
Save