Adapt AccordionReceipt to proxy receipts

pull/5285/head
Manuel Wedler 4 months ago committed by Aniket
parent e75671ced3
commit 2b98c79615
  1. 93
      apps/contract-verification/src/app/components/AccordionReceipt.tsx

@ -1,5 +1,5 @@
import React, { useMemo } from 'react' import React, { useMemo } from 'react'
import { SubmittedContract } from '../types' import { SubmittedContract, VerificationReceipt } from '../types'
import { shortenAddress, CustomTooltip } from '@remix-ui/helper' import { shortenAddress, CustomTooltip } from '@remix-ui/helper'
import { AppContext } from '../AppContext' import { AppContext } from '../AppContext'
@ -36,15 +36,31 @@ export const AccordionReceipt: React.FC<AccordionReceiptProps> = ({ contract, in
</h3> </h3>
<div id={`collapse${index}`} className={`accordion-collapse p-2 collapse ${expanded ? 'show' : ''}`} aria-labelledby={`heading${index}`} data-bs-parent="#receiptsAccordion"> <div id={`collapse${index}`} className={`accordion-collapse p-2 collapse ${expanded ? 'show' : ''}`} aria-labelledby={`heading${index}`} data-bs-parent="#receiptsAccordion">
<div className="accordion-body"> <div className="accordion-body">
<div>
<span className="font-weight-bold">Chain ID: </span>
{contract.chainId}
</div>
<div>
<span className="font-weight-bold">File: </span>
{contract.filePath}
</div>
<div>
<span className="font-weight-bold">Contract: </span>
{contract.contractName}
</div>
<div>
<span className="font-weight-bold">Submission: </span>
{new Date(contract.date).toLocaleString()}
</div>
{!contract.proxyAddress ? ( {!contract.proxyAddress ? (
<ReceiptsBody contract={contract}></ReceiptsBody> <ReceiptsBody receipts={contract.receipts}></ReceiptsBody>
) : ( ) : (
<> <>
<div> <div>
<span className="font-weight-bold" style={{ fontSize: '1.2rem' }}> <span className="font-weight-bold" style={{ fontSize: '1.2rem' }}>
Implementation Implementation
</span> </span>
<ReceiptsBody contract={contract}></ReceiptsBody> <ReceiptsBody receipts={contract.receipts}></ReceiptsBody>
</div> </div>
<div className="mt-3"> <div className="mt-3">
<span className="font-weight-bold" style={{ fontSize: '1.2rem' }}> <span className="font-weight-bold" style={{ fontSize: '1.2rem' }}>
@ -53,8 +69,7 @@ export const AccordionReceipt: React.FC<AccordionReceiptProps> = ({ contract, in
<CustomTooltip tooltipText={contract.proxyAddress}> <CustomTooltip tooltipText={contract.proxyAddress}>
<span>{shortenAddress(contract.proxyAddress)}</span> <span>{shortenAddress(contract.proxyAddress)}</span>
</CustomTooltip> </CustomTooltip>
{/* TODO add body for proxies */} <ReceiptsBody receipts={contract.proxyReceipts}></ReceiptsBody>
{/* <ReceiptsBody contract={contract.proxy}></ReceiptsBody> */}
</div> </div>
</> </>
)} )}
@ -64,50 +79,32 @@ export const AccordionReceipt: React.FC<AccordionReceiptProps> = ({ contract, in
) )
} }
const ReceiptsBody = ({ contract }: { contract: SubmittedContract }) => { const ReceiptsBody = ({ receipts }: { receipts: VerificationReceipt[] }) => {
return ( return (
<> <div className="table-responsive">
<div> <table className="table">
<span className="font-weight-bold">Chain ID: </span> <thead>
{contract.chainId} <tr>
</div> <th>Verifier</th>
<div> <th>API URL</th>
<span className="font-weight-bold">File: </span> <th>Status</th>
{contract.filePath} <th>Message</th>
</div> <th>ReceiptID</th>
<div> {/*TODO add link*/}
<span className="font-weight-bold">Contract: </span> </tr>
{contract.contractName} </thead>
</div> <tbody>
<div> {receipts.map((receipt) => (
<span className="font-weight-bold">Submission: </span> <tr key={`${receipt.isProxyReceipt ? 'proxy' : ''}-${receipt.receiptId}-${receipt.verifierInfo.name}`}>
{new Date(contract.date).toLocaleString()} <td>{receipt.verifierInfo.name}</td>
</div> <td>{receipt.verifierInfo.apiUrl}</td>
<div className="table-responsive"> <td>{receipt.status}</td>
<table className="table"> <td>{receipt.message}</td>
<thead> <td>{receipt.receiptId}</td>
<tr>
<th>Verifier</th>
<th>API URL</th>
<th>Status</th>
<th>Message</th>
<th>ReceiptID</th>
{/*TODO add link*/}
</tr> </tr>
</thead> ))}
<tbody> </tbody>
{contract.receipts.map((receipt) => ( </table>
<tr key={`${contract.id}-${receipt.verifierInfo.name}`}> </div>
<td>{receipt.verifierInfo.name}</td>
<td>{receipt.verifierInfo.apiUrl}</td>
<td>{receipt.status}</td>
<td>{receipt.message}</td>
<td>{receipt.receiptId}</td>
</tr>
))}
</tbody>
</table>
</div>
</>
) )
} }

Loading…
Cancel
Save