Add lookup links to AccordionReceipt

pull/5285/head
Manuel Wedler 4 months ago committed by Aniket
parent 4304c01e2e
commit bbfc497a68
  1. 3
      apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts
  2. 5
      apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts
  3. 5
      apps/contract-verification/src/app/app.tsx
  4. 13
      apps/contract-verification/src/app/components/AccordionReceipt.tsx
  5. 2
      apps/contract-verification/src/app/types/VerificationTypes.ts
  6. 5
      apps/contract-verification/src/app/views/VerifyView.tsx

@ -80,7 +80,8 @@ export class EtherscanVerifier extends AbstractVerifier {
throw new Error(verificationResponse.result) throw new Error(verificationResponse.result)
} }
return { status: 'pending', receiptId: verificationResponse.result } const lookupUrl = this.getContractCodeUrl(submittedContract.address)
return { status: 'pending', receiptId: verificationResponse.result, lookupUrl }
} }
async verifyProxy(submittedContract: SubmittedContract): Promise<VerificationResponse> { async verifyProxy(submittedContract: SubmittedContract): Promise<VerificationResponse> {

@ -87,13 +87,16 @@ export class SourcifyVerifier extends AbstractVerifier {
// Map to a user-facing status message // Map to a user-facing status message
let status: VerificationStatus = 'unknown' let status: VerificationStatus = 'unknown'
let lookupUrl: string | undefined = undefined
if (verificationResponse.result[0].status === 'perfect' || verificationResponse.result[0].status === 'full') { if (verificationResponse.result[0].status === 'perfect' || verificationResponse.result[0].status === 'full') {
status = 'fully verified' status = 'fully verified'
lookupUrl = this.getContractCodeUrl(submittedContract.address, submittedContract.chainId, true)
} else if (verificationResponse.result[0].status === 'partial') { } else if (verificationResponse.result[0].status === 'partial') {
status = 'partially verified' status = 'partially verified'
lookupUrl = this.getContractCodeUrl(submittedContract.address, submittedContract.chainId, false)
} }
return { status, receiptId: null } return { status, receiptId: null, lookupUrl }
} }
async lookup(contractAddress: string, chainId: string): Promise<LookupResponse> { async lookup(contractAddress: string, chainId: string): Promise<LookupResponse> {

@ -103,9 +103,12 @@ const App = () => {
} else { } else {
response = await verifier.checkVerificationStatus(receiptId) response = await verifier.checkVerificationStatus(receiptId)
} }
const { status, message } = response const { status, message, lookupUrl } = response
receipt.status = status receipt.status = status
receipt.message = message receipt.message = message
if (lookupUrl) {
receipt.lookupUrl = lookupUrl
}
} catch (e) { } catch (e) {
receipt.failedChecks++ receipt.failedChecks++
// Only retry 5 times // Only retry 5 times

@ -42,11 +42,11 @@ export const AccordionReceipt: React.FC<AccordionReceiptProps> = ({ contract, in
</div> </div>
<div> <div>
<span className="font-weight-bold">File: </span> <span className="font-weight-bold">File: </span>
{contract.filePath} <span style={{ wordBreak: 'break-word' }}>{contract.filePath}</span>
</div> </div>
<div> <div>
<span className="font-weight-bold">Contract: </span> <span className="font-weight-bold">Contract: </span>
{contract.contractName} <span style={{ wordBreak: 'break-word' }}>{contract.contractName}</span>
</div> </div>
<div> <div>
<span className="font-weight-bold">Submission: </span> <span className="font-weight-bold">Submission: </span>
@ -89,8 +89,8 @@ const ReceiptsBody = ({ receipts }: { receipts: VerificationReceipt[] }) => {
<th>API URL</th> <th>API URL</th>
<th>Status</th> <th>Status</th>
<th>Message</th> <th>Message</th>
<th>Link</th>
<th>ReceiptID</th> <th>ReceiptID</th>
{/*TODO add link*/}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -98,8 +98,13 @@ const ReceiptsBody = ({ receipts }: { receipts: VerificationReceipt[] }) => {
<tr key={`${receipt.isProxyReceipt ? 'proxy' : ''}-${receipt.receiptId}-${receipt.verifierInfo.name}`}> <tr key={`${receipt.isProxyReceipt ? 'proxy' : ''}-${receipt.receiptId}-${receipt.verifierInfo.name}`}>
<td>{receipt.verifierInfo.name}</td> <td>{receipt.verifierInfo.name}</td>
<td>{receipt.verifierInfo.apiUrl}</td> <td>{receipt.verifierInfo.apiUrl}</td>
<td>{receipt.status}</td> <td>
<span className="font-weight-bold" style={{ textTransform: 'capitalize' }}>
{receipt.status}
</span>
</td>
<td>{receipt.message}</td> <td>{receipt.message}</td>
<td>{!!receipt.lookupUrl && <a href={receipt.lookupUrl} target="_blank" className="fa fas fa-arrow-up-right-from-square"></a>}</td>
<td>{receipt.receiptId}</td> <td>{receipt.receiptId}</td>
</tr> </tr>
))} ))}

@ -30,6 +30,7 @@ export interface VerificationReceipt {
verifierInfo: VerifierInfo verifierInfo: VerifierInfo
status: VerificationStatus status: VerificationStatus
message?: string message?: string
lookupUrl?: string
contractId: string contractId: string
isProxyReceipt: boolean isProxyReceipt: boolean
failedChecks: number failedChecks: number
@ -62,6 +63,7 @@ export interface VerificationResponse {
status: VerificationStatus status: VerificationStatus
receiptId: string | null receiptId: string | null
message?: string message?: string
lookupUrl?: string
} }
export interface SourceFile { export interface SourceFile {

@ -134,9 +134,12 @@ export const VerifyView = () => {
} else { } else {
response = await verifier.verify(newSubmittedContract, compilerAbstract) response = await verifier.verify(newSubmittedContract, compilerAbstract)
} }
const { status, message, receiptId } = response const { status, message, receiptId, lookupUrl } = response
receipt.status = status receipt.status = status
receipt.message = message receipt.message = message
if (lookupUrl) {
receipt.lookupUrl = lookupUrl
}
if (receiptId) { if (receiptId) {
receipt.receiptId = receiptId receipt.receiptId = receiptId
} }

Loading…
Cancel
Save