|
|
@ -16,6 +16,7 @@ import Tabs from 'react-bootstrap/Tabs' |
|
|
|
import { AnalysisTab, SolHintReport } from '../staticanalyser' |
|
|
|
import { AnalysisTab, SolHintReport } from '../staticanalyser' |
|
|
|
import { run } from './actions/staticAnalysisActions' |
|
|
|
import { run } from './actions/staticAnalysisActions' |
|
|
|
import { BasicTitle, calculateWarningStateEntries } from './components/BasicTitle' |
|
|
|
import { BasicTitle, calculateWarningStateEntries } from './components/BasicTitle' |
|
|
|
|
|
|
|
import { Nav, TabContainer } from 'react-bootstrap' |
|
|
|
|
|
|
|
|
|
|
|
declare global { |
|
|
|
declare global { |
|
|
|
interface Window { |
|
|
|
interface Window { |
|
|
@ -31,6 +32,8 @@ export interface RemixUiStaticAnalyserProps { |
|
|
|
analysisModule: AnalysisTab |
|
|
|
analysisModule: AnalysisTab |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type tabSelectionType = 'remix' | 'solhint' | 'slither' | 'none' |
|
|
|
|
|
|
|
|
|
|
|
export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
const [runner] = useState(new CodeAnalysis()) |
|
|
|
const [runner] = useState(new CodeAnalysis()) |
|
|
|
|
|
|
|
|
|
|
@ -81,6 +84,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
const [hints, setHints] = useState<SolHintReport[]>([]) |
|
|
|
const [hints, setHints] = useState<SolHintReport[]>([]) |
|
|
|
const [slitherWarnings, setSlitherWarnings] = useState([]) |
|
|
|
const [slitherWarnings, setSlitherWarnings] = useState([]) |
|
|
|
const [ssaWarnings, setSsaWarnings] = useState([]) |
|
|
|
const [ssaWarnings, setSsaWarnings] = useState([]) |
|
|
|
|
|
|
|
const [selectedTab, setSelectedTab] = useState<tabSelectionType>('remix') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const warningContainer = useRef(null) |
|
|
|
const warningContainer = useRef(null) |
|
|
@ -397,7 +401,11 @@ useEffect(() => { |
|
|
|
|
|
|
|
|
|
|
|
const handleBasicEnabled = () => { |
|
|
|
const handleBasicEnabled = () => { |
|
|
|
if (basicEnabled) { |
|
|
|
if (basicEnabled) { |
|
|
|
|
|
|
|
console.log('remix is: ', { basicEnabled }) |
|
|
|
setBasicEnabled(false) |
|
|
|
setBasicEnabled(false) |
|
|
|
|
|
|
|
if (solhintEnabled) { |
|
|
|
|
|
|
|
setSelectedTab('solhint') |
|
|
|
|
|
|
|
} |
|
|
|
props.event.trigger('staticAnalysisWarning', [-1]) |
|
|
|
props.event.trigger('staticAnalysisWarning', [-1]) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setBasicEnabled(true) |
|
|
|
setBasicEnabled(true) |
|
|
@ -430,7 +438,8 @@ useEffect(() => { |
|
|
|
|
|
|
|
|
|
|
|
const tabKeys = [ |
|
|
|
const tabKeys = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
tabKey: "linter", |
|
|
|
tabKey: "solhint", |
|
|
|
|
|
|
|
connectedState: solhintEnabled, |
|
|
|
child: ( |
|
|
|
child: ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
{hints.length > 0 ? ( |
|
|
|
{hints.length > 0 ? ( |
|
|
@ -545,7 +554,8 @@ useEffect(() => { |
|
|
|
), |
|
|
|
), |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
tabKey: "basic", |
|
|
|
tabKey: "remix", |
|
|
|
|
|
|
|
connectedState: basicEnabled, |
|
|
|
title: ( |
|
|
|
title: ( |
|
|
|
<BasicTitle |
|
|
|
<BasicTitle |
|
|
|
warningStateEntries={Object.entries(warningState)} |
|
|
|
warningStateEntries={Object.entries(warningState)} |
|
|
@ -600,6 +610,7 @@ useEffect(() => { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
tabKey: "slither", |
|
|
|
tabKey: "slither", |
|
|
|
|
|
|
|
connectedState: slitherEnabled, |
|
|
|
title: ( |
|
|
|
title: ( |
|
|
|
<span> |
|
|
|
<span> |
|
|
|
Slither |
|
|
|
Slither |
|
|
@ -687,7 +698,13 @@ useEffect(() => { |
|
|
|
})) |
|
|
|
})) |
|
|
|
}).flat().every(el => categoryIndex.includes(el)) |
|
|
|
}).flat().every(el => categoryIndex.includes(el)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
const getLastCompiled = async () => { |
|
|
|
|
|
|
|
const lastComp = await props.analysisModule.call('compilerArtefacts', 'getLastCompilationResult') |
|
|
|
|
|
|
|
console.log({ lastComp }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
getLastCompiled() |
|
|
|
|
|
|
|
}, [props, state]) |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="analysis_3ECCBV px-3 pb-1"> |
|
|
|
<div className="analysis_3ECCBV px-3 pb-1"> |
|
|
|
<div className="my-2 d-flex flex-column align-items-left"> |
|
|
|
<div className="my-2 d-flex flex-column align-items-left"> |
|
|
@ -740,8 +757,10 @@ useEffect(() => { |
|
|
|
{state.data && state.file.length > 0 && state.source ? <Button |
|
|
|
{state.data && state.file.length > 0 && state.source ? <Button |
|
|
|
buttonText={`Analyse ${state.file}`} |
|
|
|
buttonText={`Analyse ${state.file}`} |
|
|
|
classList="btn btn-sm btn-primary btn-block" |
|
|
|
classList="btn btn-sm btn-primary btn-block" |
|
|
|
onClick={async () => await run(state.data, state.source, state.file, state , props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, |
|
|
|
onClick={async () => { |
|
|
|
message, showWarnings, allWarnings, warningContainer, calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis, solhintEnabled, basicEnabled)} |
|
|
|
await run(state.data, state.source, state.file, state , props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, |
|
|
|
|
|
|
|
message, showWarnings, allWarnings, warningContainer, calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis, solhintEnabled, basicEnabled) |
|
|
|
|
|
|
|
}} |
|
|
|
disabled={(state.data === null || !isSupportedVersion) || (!solhintEnabled && !basicEnabled) } |
|
|
|
disabled={(state.data === null || !isSupportedVersion) || (!solhintEnabled && !basicEnabled) } |
|
|
|
/> : <Button |
|
|
|
/> : <Button |
|
|
|
buttonText={`Analyze ${state.file}`} |
|
|
|
buttonText={`Analyze ${state.file}`} |
|
|
@ -752,14 +771,16 @@ useEffect(() => { |
|
|
|
disabled={(state.data === null || !isSupportedVersion) || (!solhintEnabled && !basicEnabled) } |
|
|
|
disabled={(state.data === null || !isSupportedVersion) || (!solhintEnabled && !basicEnabled) } |
|
|
|
/>} |
|
|
|
/>} |
|
|
|
{state && state.data !== null && state.source !== null && state.file.length > 0 ? (<div className="d-flex border-top flex-column"> |
|
|
|
{state && state.data !== null && state.source !== null && state.file.length > 0 ? (<div className="d-flex border-top flex-column"> |
|
|
|
{slitherWarnings.length > 0 || hints.length > 0 || Object.entries(warningState).length > 0 ? ( |
|
|
|
{slitherWarnings.length > 0 || hints.length > 0 || ssaWarnings.length > 0 ? ( |
|
|
|
<div className={`mt-4 p-2 d-flex ${slitherWarnings.length > 0 || hints.length > 0 || Object.entries(warningState).length > 0 ? 'border-top' : ''} flex-column`}> |
|
|
|
<div className={`mt-4 p-2 d-flex ${slitherWarnings.length > 0 || hints.length > 0 || ssaWarnings.length > 0 ? 'border-top' : ''} flex-column`}> |
|
|
|
<span>Last results for:</span> |
|
|
|
<span>Last results for:</span> |
|
|
|
<span |
|
|
|
<span |
|
|
|
className="text-break break-word word-break font-weight-bold" |
|
|
|
className="text-break break-word word-break font-weight-bold" |
|
|
|
id="staticAnalysisCurrentFile" |
|
|
|
id="staticAnalysisCurrentFile" |
|
|
|
> |
|
|
|
> |
|
|
|
{state.file} |
|
|
|
{ |
|
|
|
|
|
|
|
state.file |
|
|
|
|
|
|
|
} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) : null} |
|
|
|
) : null} |
|
|
@ -785,37 +806,37 @@ useEffect(() => { |
|
|
|
onChange={() => {}} |
|
|
|
onChange={() => {}} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<Tabs |
|
|
|
<TabContainer |
|
|
|
defaultActiveKey={tabKeys[1].tabKey} |
|
|
|
defaultActiveKey={tabKeys[1].tabKey} |
|
|
|
className="px-1" |
|
|
|
activeKey={selectedTab} |
|
|
|
|
|
|
|
onSelect={(tabKey: tabSelectionType) => { |
|
|
|
|
|
|
|
setSelectedTab(tabKey) |
|
|
|
|
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
{ |
|
|
|
<Nav variant="tabs" className="px-1"> |
|
|
|
checkBasicStatus() ? <Tab |
|
|
|
{checkBasicStatus() ? <Nav.Item> |
|
|
|
key={tabKeys[1].tabKey} |
|
|
|
<Nav.Link className="text-decoration-none font-weight-bold px-2" eventKey={tabKeys[1].tabKey}>{tabKeys[1].title}</Nav.Link> |
|
|
|
title={tabKeys[1].title} |
|
|
|
</Nav.Item> : null} |
|
|
|
eventKey={tabKeys[1].tabKey} |
|
|
|
{solhintEnabled ? <Nav.Item className="text-decoration-none font-weight-bold px-2"> |
|
|
|
tabClassName="text-decoration-none font-weight-bold px-2" |
|
|
|
<Nav.Link className="text-decoration-none font-weight-bold px-2" eventKey={tabKeys[0].tabKey}>{tabKeys[0].title}</Nav.Link> |
|
|
|
> |
|
|
|
</Nav.Item> : null} |
|
|
|
|
|
|
|
{slitherEnabled && showSlither ? <Nav.Item className="text-decoration-none font-weight-bold px-2"> |
|
|
|
|
|
|
|
<Nav.Link className="text-decoration-none font-weight-bold px-2" eventKey={tabKeys[2].tabKey}>{tabKeys[2].title}</Nav.Link> |
|
|
|
|
|
|
|
</Nav.Item> : null} |
|
|
|
|
|
|
|
</Nav> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Tab.Content> |
|
|
|
|
|
|
|
<Tab.Pane eventKey={tabKeys[1].tabKey}> |
|
|
|
{tabKeys[1].child} |
|
|
|
{tabKeys[1].child} |
|
|
|
</Tab> : null |
|
|
|
</Tab.Pane> |
|
|
|
} |
|
|
|
<Tab.Pane eventKey={tabKeys[0].tabKey}> |
|
|
|
{solhintEnabled ? <Tab |
|
|
|
{tabKeys[0].child} |
|
|
|
key={tabKeys[0].tabKey} |
|
|
|
</Tab.Pane> |
|
|
|
title={tabKeys[0].title} |
|
|
|
<Tab.Pane eventKey={tabKeys[2].tabKey}> |
|
|
|
eventKey={tabKeys[0].tabKey} |
|
|
|
{tabKeys[2].child} |
|
|
|
tabClassName="text-decoration-none font-weight-bold px-2" |
|
|
|
</Tab.Pane> |
|
|
|
> |
|
|
|
</Tab.Content> |
|
|
|
{tabKeys[0].child} |
|
|
|
</TabContainer> |
|
|
|
</Tab> : null} |
|
|
|
|
|
|
|
{ showSlither && slitherEnabled ? <Tab |
|
|
|
|
|
|
|
key={tabKeys[2].tabKey} |
|
|
|
|
|
|
|
title={tabKeys[2].title} |
|
|
|
|
|
|
|
eventKey={tabKeys[2].tabKey} |
|
|
|
|
|
|
|
tabClassName="text-decoration-none font-weight-bold px-2" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{tabKeys[2].child} |
|
|
|
|
|
|
|
</Tab> : null } |
|
|
|
|
|
|
|
</Tabs> |
|
|
|
|
|
|
|
</div>) : null} |
|
|
|
</div>) : null} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|