Skip to content

Commit 48a647f

Browse files
committed
Add link to verification details in ReceiptsView and fix compatibility with legacy data
1 parent b74b502 commit 48a647f

File tree

8 files changed

+37
-10
lines changed

8 files changed

+37
-10
lines changed

apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ interface SourcifyLookupResponse {
5656
export class SourcifyVerifier extends AbstractVerifier {
5757
LOOKUP_STORE_DIR = 'sourcify-verified'
5858

59+
constructor(apiUrl: string, explorerUrl: string, protected receiptsUrl?: string) {
60+
super(apiUrl, explorerUrl)
61+
}
62+
5963
async verify(submittedContract: SubmittedContract, compilerAbstract: CompilerAbstract): Promise<VerificationResponse> {
6064
const metadata = JSON.parse(compilerAbstract.data.contracts[submittedContract.filePath][submittedContract.contractName].metadata)
6165
const compilerVersion = `v${metadata.compiler.version}`
@@ -92,10 +96,15 @@ export class SourcifyVerifier extends AbstractVerifier {
9296
return {
9397
status: 'pending',
9498
receiptId: verificationResponse.verificationId,
99+
receiptLookupUrl: this.receiptLookupUrl(verificationResponse.verificationId),
95100
lookupUrl: this.getContractCodeUrl(submittedContract.address, submittedContract.chainId),
96101
}
97102
}
98103

104+
receiptLookupUrl(receiptId: string): string {
105+
return `${this.receiptsUrl}/${receiptId}`
106+
}
107+
99108
async checkVerificationStatus(receiptId: string, chainId: string): Promise<VerificationResponse> {
100109
const response = await fetch(`${this.apiUrl}/v2/verify/${receiptId}`, {
101110
method: 'GET',

apps/contract-verification/src/app/Verifiers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function getVerifier(identifier: VerifierIdentifier, settings: VerifierSe
2222
if (settings?.useV1API) {
2323
return new SourcifyV1Verifier(settings.apiUrl, settings.explorerUrl)
2424
}
25-
return new SourcifyVerifier(settings.apiUrl, settings.explorerUrl)
25+
return new SourcifyVerifier(settings.apiUrl, settings.explorerUrl, settings.receiptsUrl)
2626
case 'Etherscan':
2727
if (!settings?.explorerUrl) {
2828
throw new Error('The Etherscan verifier requires an explorer URL.')

apps/contract-verification/src/app/components/AccordionReceipt.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,27 @@ const ReceiptsBody = ({ receipts }: { receipts: VerificationReceipt[] }) => {
105105
<span className="mr-2">
106106
{['verified', 'partially verified', 'already verified'].includes(receipt.status) ?
107107
<i className="fas fa-check text-success px-1"></i> :
108-
receipt.status === 'exactly verified' ?
108+
receipt.status === 'exactly verified' || receipt.status === 'fully verified' ?
109109
<i className="fas fa-check-double text-success px-1"></i> :
110110
receipt.status === 'failed' ?
111111
<i className="fas fa-xmark text-warning px-1"></i> :
112112
['pending', 'awaiting implementation verification'].includes(receipt.status) ?
113-
<i className="fas fa-spinner fa-spin"></i> :
114-
<i className="fas fa-question"></i>
113+
<i className="fas fa-spinner fa-spin px-1"></i> :
114+
<i className="fas fa-question px-1"></i>
115115
}
116116
</span>
117117
</CustomTooltip>
118118
<div className="d-flex flex-row w-100 justify-content-between">
119-
<CustomTooltip placement="top" tooltipClasses=" text-break" tooltipText={`API: ${receipt.verifierInfo.apiUrl}`}>
120-
<span className="font-weight-bold pr-2">{receipt.verifierInfo.name}</span>
121-
</CustomTooltip>
119+
<div>
120+
<CustomTooltip placement="top" tooltipClasses=" text-break" tooltipText={`API: ${receipt.verifierInfo.apiUrl}`}>
121+
<span className="font-weight-bold pr-2">{receipt.verifierInfo.name}</span>
122+
</CustomTooltip>
123+
{
124+
!!receipt.receiptLookupUrl && <CustomTooltip placement="top" tooltipClasses=" text-break" tooltipText="View verification details">
125+
<a href={receipt.receiptLookupUrl} target="_blank" className="fa fas fa-receipt" rel="noreferrer"></a>
126+
</CustomTooltip>
127+
}
128+
</div>
122129
<div className="ml-1">
123130
{!!receipt.lookupUrl && receipt.verifierInfo.name === 'Blockscout' ?
124131
<CopyToClipboard classList="pr-0 py-0" tip="Copy code URL" content={receipt.lookupUrl} direction="top" /> :

apps/contract-verification/src/app/types/SettingsTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface VerifierSettings {
55
explorerUrl?: string
66
apiKey?: string
77
useV1API?: boolean // For Sourcify, whether to use the v1 API
8+
receiptsUrl?: string
89
}
910

1011
export type SettingsForVerifier = Partial<Record<VerifierIdentifier, VerifierSettings>>

apps/contract-verification/src/app/types/VerificationTypes.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface VerificationReceipt {
3131
status: VerificationStatus
3232
message?: string
3333
lookupUrl?: string
34+
receiptLookupUrl?: string
3435
contractId: string
3536
isProxyReceipt: boolean
3637
failedChecks: number
@@ -55,13 +56,17 @@ export interface SubmittedContracts {
5556
[id: string]: SubmittedContract
5657
}
5758

58-
export type VerificationStatus = 'exactly verified' | 'verified' | 'already verified' | 'failed' | 'pending' | 'awaiting implementation verification' | 'not verified' | 'lookup failed' | 'unknown'
59+
// Keep fully and partially verified for compatibility with old data in local storage
60+
type SourcifyStatus = 'exactly verified' | 'verified' | 'fully verified' | 'partially verified'
61+
type EtherscanStatus = 'verified' | 'already verified'
62+
export type VerificationStatus = SourcifyStatus | EtherscanStatus | 'failed' | 'pending' | 'awaiting implementation verification' | 'not verified' | 'lookup failed' | 'unknown'
5963

6064
export interface VerificationResponse {
6165
status: VerificationStatus
6266
receiptId: string | null
6367
message?: string
6468
lookupUrl?: string
69+
receiptLookupUrl?: string
6570
}
6671

6772
export interface SourceFile {

apps/contract-verification/src/app/utils/default-apis.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"Sourcify": {
33
"apiUrl": "https://sourcify.dev/server",
4-
"explorerUrl": "https://repo.sourcify.dev"
4+
"explorerUrl": "https://repo.sourcify.dev",
5+
"receiptsUrl": "https://verify.sourcify.dev/jobs"
56
},
67
"Etherscan": {
78
"apiUrl": "https://api.etherscan.io/v2",

apps/contract-verification/src/app/views/SettingsView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const SettingsView = () => {
5353
</div>
5454
</CustomTooltip>
5555
<ConfigInput label="Repo URL" id="sourcify-explorer-url" secret={false} initialValue={chainSettings.verifiers['Sourcify']?.explorerUrl ?? ''} saveResult={(result) => handleChange('Sourcify', 'explorerUrl', result)} />
56+
<ConfigInput label="Jobs URL" id="sourcify-receipts-url" secret={false} initialValue={chainSettings.verifiers['Sourcify']?.receiptsUrl ?? ''} saveResult={(result) => handleChange('Sourcify', 'receiptsUrl', result)} />
5657
</div>
5758
<div className="p-2 my-2 border">
5859
<span className="font-weight-bold">Etherscan - {selectedChain.name}</span>

apps/contract-verification/src/app/views/VerifyView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export const VerifyView = () => {
152152
} else {
153153
response = await verifier.verify(newSubmittedContract, compilerAbstract)
154154
}
155-
const { status, message, receiptId, lookupUrl } = response
155+
const { status, message, receiptId, lookupUrl, receiptLookupUrl } = response
156156
receipt.status = status
157157
receipt.message = message
158158
if (lookupUrl) {
@@ -161,6 +161,9 @@ export const VerifyView = () => {
161161
if (receiptId) {
162162
receipt.receiptId = receiptId
163163
}
164+
if (receiptLookupUrl) {
165+
receipt.receiptLookupUrl = receiptLookupUrl
166+
}
164167
} catch (e) {
165168
const err = e as Error
166169
receipt.status = 'failed'

0 commit comments

Comments
 (0)