1import{j as o}from"./vendor-dotlottie-CKWLB76h.js";import{W as G,a as n,j as re,i as _e,n as ue}from"./vendor-react-CCzXVbVA.js";import{f as de,h as pe,a as C,j as fe,k as me,b as ke,A as he,c as be}from"./app-ZGxtfi_0.js";import{Q as ye}from"./QuickScanForm-CcPvU9vR.js";import{u as Se,Q as je,a as qe}from"./useQsModules-CCEZPS96.js";import{T as ge}from"./TurnstileComponent-DGwBZ16v.js";import{F as xe}from"./index.esm-DOW5uEmc.js";import{k as Ae,f as Ce,F as w,V as I,T as N,H as we,I as Pe,am as Te}from"./vendor-chakra-z2eW50qa.js";import"./vendor-analytics-kxESroPO.js";import"./vendor-victory-2uYGyQN6.js";import"./vendor-query-Cq2FYR_1.js";import"./vendor-monaco-CiJro7ev.js";import"./jszip.min-D8_qSb1X.js";import"./index.esm-Ds02zZ7m.js";import"./react-select.esm-f8TJ4I6W.js";import"./assertThisInitialized-DtB8HoZg.js";import"./FormatOptionLabelWithImage-40ApY-OR.js";import"./ModalBlurOverlay-CoS6iLx6.js";import"./debounce-CxjSGMPP.js";import"./index.esm-C221wYgj.js";import"./jszip-ptFiYCmq.js";import"./SolidityScoreProgress-nGrh_wmi.js";import"./ReportTag-CSqGGrUl.js";import"./ResultOverview-BTgcR7b5.js";import"./OverviewDetails-CSr34Mre.js";import"./SecurityScoreIcon-CvrdT_4t.js";import"./vendor-nivo-DiDy6rd6.js";import"./VulnerabilityBox-BnCfkBDE.js";import"./UnverifiedContract-BFdZDnXq.js";const rs=()=>{const D=Ae(),[M,r]=G.useState(null),[B,W]=n.useState(""),[u,$]=n.useState(""),[k,O]=n.useState(""),{sendMessage:K,setKeepWSOpen:P,updateMessageQueue:Y,messageQueue:h,setNeedAuthToken:z,scanProgress:J}=de();n.useRef(null);const{isOpen:Ee,onClose:Re,onOpen:V}=Ce(),g=re(),X=_e(),_=new URLSearchParams(g.search),{blockAddress:d,blockPlatform:b,blockChain:y}=ue(),[v,S]=G.useState(!!(d&&y&&b||g.state||_.get("url"))),[s,p]=n.useState(null),[Z,j]=n.useState(""),f=_.get("ref"),ee=fe("QuickScans"),[m,T]=n.useState(""),[F,Qe]=n.useState(0),[se,H]=n.useState(!1),[E,te]=n.useState([]),[De,q]=n.useState("yes"),[ae,ie]=n.useState([]),{data:x}=Se(se),[L,R]=n.useState(!1),[ne,U]=n.useState();n.useEffect(()=>{let a;if(document.referrer&&(a=new URL(document.referrer)),a&&a?.hostname&&!a.hostname.includes("solidityscan")&&localStorage.setItem("referrer",a.hostname),f)localStorage.setItem("campaign_type",f),localStorage.setItem("campaign_id",f),sessionStorage.setItem("ref",f);else if(!localStorage.getItem("campaign_id")&&!localStorage.getItem("campaign_type")){const c=_.get("utm_source")||"quickscan",A=_.get("utm_campaign")||"quickscan";localStorage.setItem("campaign_type",c),localStorage.setItem("campaign_id",A)}r(null),q("yes");const e=g.state,t=_.get("url")||void 0,i=_.get("branch")||void 0,l=_.get("commit")||void 0;if(d&&y&&b){const c=_.get("imp_address");b==="fuse"?p({blockAddress:d,blockPlatform:"blockscout",blockChain:`fuse-${y}`,blockImpAddress:c}):(p({blockAddress:d,blockPlatform:b,blockChain:y,blockImpAddress:c}),j("Validated"))}else if(e||t){let c=[];const A=_.get("skip_file_paths");if(A)try{c=JSON.parse(decodeURIComponent(A))}catch(le){console.error("Error parsing skip_file_paths from URL",le)}else e?.skip_file_paths&&(c=e.skip_file_paths);p({project_url:t,project_branch:i,project_commit:l,project_name:e?.project_name||t&&pe(t),skip_file_paths:c,file_urls:e?.file_urls,zip_file_paths:e?.zip_file_paths}),j("Validated"),S(!0),q("no")}else p(null),S(!1),U(null)},[g]),n.useEffect(()=>{if(x&&s){const a=x.data?.qs_modules?.sort((t,i)=>t.issue_sequence_id-i.issue_sequence_id).map(t=>({...t,issue_status:"scanning"})),e=s.blockAddress?x.data?.ts_modules?.sort((t,i)=>t.issue_sequence_id-i.issue_sequence_id).map(t=>({...t,issue_status:"scanning"})):[];te(a),ie(e),r({contract_address:s.blockAddress,contract_chain:s.blockChain,contract_platform:s.blockPlatform,project_url:s.project_url,project_branch:s.project_branch,project_name:s.project_name,project_commit:s.project_commit,quick_file_scan_details:a,ts_scan_details:e}),H(!1)}},[x]),n.useEffect(()=>{s&&(C().reCAPTCHA_enabled&&m||!C().reCAPTCHA_enabled)&&(ee("quick-scan","quick-scan"),H(!0),E&&E.length&&r({contract_address:s.blockAddress,contract_chain:s.blockChain,contract_platform:s.blockPlatform,quick_file_scan_details:E,ts_scan_details:ae}),ce())},[m,s]),n.useEffect(()=>{if(h.length>0&&h.some(a=>["transaction_stimulation_status","transaction_stimulation_result","quick_scan_result","quick_scan_status","quick_scan_acknowledge","public_project_scan_acknowledge","scan_status","error"].includes(a.type))){h.forEach(e
1=>{if(["quick_scan_status","scan_status"].includes(e.type)&&e.payload.scan_status==="scan_done"&&(e.payload.scan_id===u||e.request_uuid===k||!k)){const t=e.payload.scan_details;t.ts_scan_details?r({...t,ts_scan_details:t?.ts_scan_details?.sort((i,l)=>i.issue_sequence_id-l.issue_sequence_id)||[]}):r(i=>({...t,quick_file_scan_details:t.quick_file_scan_details||i?.quick_file_scan_details,ts_scan_details:i?.ts_scan_details||[]})),t.ts_scan_status==="scan_failed"?q("failed"):t.ts_scan_details&&!t.ts_scan_details.length&&q("no"),W(e.payload.project_id),$(e.payload.scan_id),Q()}else if(e.type==="transaction_stimulation_result"&&(e.payload.scan_id===u||e.request_uuid===k)){const t=e.payload.transaction_stimulation_data;t&&r(i=>{const l=i?.ts_scan_details?i?.ts_scan_details.map(c=>c.issue_id===t.issue_id?{...t}:c):[t];return{...i,quick_file_scan_details:i?.quick_file_scan_details||[],ts_scan_details:l}})}else if(e.type==="transaction_stimulation_status")(u&&e.payload.scan_id===u||e.request_uuid===k)&&(["stimulation_finished"].includes(e.payload.transaction_stimulation_status)?r(t=>{const i=t?.ts_scan_details&&t?.ts_scan_details.filter(l=>l.issue_status!=="scanning");return{...t,quick_file_scan_details:t?.quick_file_scan_details||[],ts_scan_details:i}}):["stimulation_not_supported","stimulation_env_setup_failed"].includes(e.payload.transaction_stimulation_status)&&(r(t=>({...t,quick_file_scan_details:t?.quick_file_scan_details||[],ts_scan_details:[]})),q(e.payload.transaction_stimulation_status==="stimulation_not_supported"?"no":"failed")));else if(e.type==="quick_scan_result"&&(e.payload.scan_id===u||e.request_uuid===k)){const t=e.payload.module_result;r(i=>{const l=i?.quick_file_scan_details?i?.quick_file_scan_details.map(c=>c.issue_id===t.issue_id?{...t}:c):[t];return{...i,quick_file_scan_details:l}})}else["quick_scan_status","scan_status"].includes(e.type)&&["download_failed","scan_failed"].includes(e.payload.scan_status)?(D({title:e.payload.scan_status_err_message,status:"error",duration:3e3,isClosable:!0,position:"bottom"}),r(null),Q()):["quick_scan_status","scan_status"].includes(e.type)&&["scanning"].includes(e.payload.scan_status)?($(e.payload.scan_id),W(e.payload.project_id)):e.type&&["quick_scan_acknowledge","public_project_scan_acknowledge"].includes(e.type)?(j("Scanned"),O(e.request_uuid)):e.type==="error"&&(e?.payload?.payload?.error_message?.implementation_address&&U({address:s?.blockAddress,platform:s?.blockPlatform,chain:s?.blockChain,implAddress:e.payload.payload.error_message.implementation_address}),r(null),Q())});let a=h;a=a.filter(e=>!["transaction_stimulation_result","transaction_stimulation_status","quick_scan_result","quick_scan_status","quick_scan_acknowledge","public_project_scan_acknowledge","scan_status","error"].includes(e.type)),Y(a)}},[h]),n.useEffect(()=>{const a=setInterval(()=>{const e=document.getElementById("hubspot-messages-iframe-container");e&&(e.remove(),clearInterval(a))},1e3);return()=>clearInterval(a)},[]);const ce=async()=>{if(s){if(j("Validated"),S(!0),z(!1),s?.blockPlatform&&!["buidlbear","tronscan"].includes(s.blockPlatform)&&!me(s.blockAddress?.trim())){D({title:"Contract Adddress not Valid",status:"error",duration:3e3,isClosable:!0,position:"bottom"}),S(!1),p(null),P(!1);return}let a=s.blockAddress?{contract_address:s.blockAddress.trim(),contract_platform:s.blockPlatform,[s.blockPlatform==="buildbear"?"node_id":"contract_chain"]:s.blockChain,contract_implementation_address:s.blockImpAddress?.trim()||void 0}:s.file_urls?{file_urls:s.file_urls,project_name:s.project_name,project_visibility:"public",project_type:"new",skip_file_paths:s.skip_file_paths,zip_file_paths:s.zip_file_paths?.length?s.zip_file_paths:null}:{project_url:s.project_url,project_name:s.project_name,project_type:"new",project_branch:s.project_branch,project_commit:s.project_commit,project_visibility:"public",skip_file_paths:s.skip_file_paths};const e=s.blockAddress?"quick_scan_initiate":"public_project_scan_initiate";f&&(a={...a,ref:f}),P(!0),z(!1),K({type:e,body:a,"cf-turnstile-response":m})}},Q=()=>{S(!1),j(""),P(!1),p(null),T("")},oe=async()=>{try{if(!L){R(!0);const{data:a}
1=await he.get(`${be.API_GENERATE_QS_PREVIEW}?scan_id=${u}`);V(),R(!1)}}catch{R(!1),V()}};return o.jsx(w,{as:"section",w:"100%",justifyContent:"flex-start",alignItems:"center",p:0,textAlign:"center",flexDir:"column",height:"4000px",bg:"black",children:o.jsx(w,{alignItems:"center",flexDir:"column",w:"100%",bg:"black",children:v&&s?o.jsxs(I,{w:"90%",maxW:"1800px",alignItems:"center",justify:"flex-start",mb:"150px",spacing:10,children:[o.jsx(je,{qsStatus:Z,scanDetails:s,scanProgress:J,scanId:u}),(d&&y&&b||s.project_url||s.file_urls)&&!m&&C().reCAPTCHA_enabled?o.jsx(ge,{setTurnstileToken:T,resetKey:F}):null]}):M===null?o.jsx(ye,{view:"quickscan",runQuickScan:(a,e,t,i,l)=>{const c=l?`/quickscan/${a}/${e}/${t}?imp_address=${l}`:`/quickscan/${a}/${e}/${t}`;window.open(c,"_blank","noopener,noreferrer")},isLoading:v,isStartScanDisabled:C().reCAPTCHA_enabled?!m:!1,turnstileToken:m,setTurnstileToken:T,resetKey:F,defaultValues:ne,isWidget:!0}):o.jsxs(I,{w:"90%",maxW:"1800px",alignItems:"center",justify:"flex-start",mb:"150px",children:[o.jsxs(w,{w:"100%",color:"white",justifyContent:"space-between",pl:6,children:[o.jsx(N,{fontSize:"lg",fontWeight:700,children:"SECURITY ANALYSIS"}),o.jsxs(we,{color:"#B0B7C3",spacing:1,children:[d?o.jsxs(w,{alignItems:"center",bg:"#252525",borderRadius:9,px:4,py:1,cursor:"pointer",onClick:oe,children:[o.jsx(N,{color:"white",fontSize:"sm",fontWeight:400,mr:2,children:"Share"}),L?o.jsx(ke,{size:20,color:"white",py:0}):o.jsx(Pe,{_hover:{bgColor:"#222222"},as:xe,boxSize:5,borderRadius:6})]}):null,o.jsx(Te,{_hover:{bgColor:"#222222"},onClick:()=>{X.push("/quickscan")}})]})]}),o.jsx(qe,{scanReport:M,scanId:u,projectId:B})]})})})};export{rs as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.