parent
52c656f59b
commit
7fa4c5fb5e
@ -0,0 +1,34 @@ |
||||
import React, {useState, useEffect} from 'react' |
||||
import {EtherscanVerifier} from '../Verifiers/EtherscanVerifier' |
||||
import {ReceiptProps} from './props' |
||||
|
||||
export const EtherscanReceipt: React.FC<ReceiptProps> = ({verifyPromise, address, chainId, verifier}) => { |
||||
const [status, setStatus] = useState<string | null>(null) |
||||
const [submissionDate] = useState(new Date()) |
||||
|
||||
useEffect(() => { |
||||
// Handle the promise here or perform other side effects
|
||||
verifyPromise |
||||
.then(() => { |
||||
// Handle promise resolution
|
||||
// Update status based on the result
|
||||
}) |
||||
.catch(() => { |
||||
// Handle promise rejection
|
||||
}) |
||||
|
||||
// This effect should only run once on mount, hence the empty dependency array
|
||||
}, [verifyPromise]) |
||||
|
||||
return ( |
||||
<div> |
||||
<h1>Verification Receipt</h1> |
||||
<p>Address: {address}</p> |
||||
<p>Chain ID: {chainId}</p> |
||||
<p>Submission Date: {submissionDate.toLocaleString()}</p> |
||||
<p>Status: {status ? status : 'Pending'}</p> |
||||
</div> |
||||
) |
||||
} |
||||
|
||||
export default EtherscanReceipt |
@ -0,0 +1,36 @@ |
||||
import React, {useState, useEffect} from 'react' |
||||
import {SourcifyVerifier} from '../Verifiers/SourcifyVerifier' |
||||
import {SourcifyVerificationStatus} from '../types/VerificationTypes' |
||||
import {ReceiptProps} from './props' |
||||
|
||||
// A receipt is something to be rendered
|
||||
export const SourcifyReceipt: React.FC<ReceiptProps> = ({verifyPromise, address, chainId, verifier}) => { |
||||
const [status, setStatus] = useState<SourcifyVerificationStatus | null>(null) |
||||
const [submissionDate] = useState(new Date()) // This will be set once and not change
|
||||
|
||||
useEffect(() => { |
||||
// You might want to handle the promise here or perform other side effects
|
||||
verifyPromise |
||||
.then(() => { |
||||
// Handle promise resolution
|
||||
// Update status based on the result
|
||||
}) |
||||
.catch(() => { |
||||
// Handle promise rejection
|
||||
}) |
||||
|
||||
// This effect should only run once on mount, hence the empty dependency array
|
||||
}, [verifyPromise]) |
||||
|
||||
return ( |
||||
<div> |
||||
<h1>Verification Receipt</h1> |
||||
<p>Address: {address}</p> |
||||
<p>Chain ID: {chainId}</p> |
||||
<p>Submission Date: {submissionDate.toLocaleString()}</p> |
||||
<p>Status: {status ? status : 'Pending'}</p> |
||||
</div> |
||||
) |
||||
} |
||||
|
||||
export default SourcifyReceipt |
@ -0,0 +1,9 @@ |
||||
import {EtherscanVerifier} from '../Verifiers/EtherscanVerifier' |
||||
import {SourcifyVerifier} from '../Verifiers/SourcifyVerifier' |
||||
|
||||
export interface ReceiptProps { |
||||
verifyPromise: Promise<any> |
||||
address: string |
||||
chainId: string |
||||
verifier: EtherscanVerifier | SourcifyVerifier |
||||
} |
@ -0,0 +1,37 @@ |
||||
import React from 'react' |
||||
import {AppContext} from '../AppContext' |
||||
|
||||
export const ReceiptsView = () => { |
||||
const {submittedContracts} = React.useContext(AppContext) |
||||
|
||||
return ( |
||||
<div className="my-4"> |
||||
{Object.values(submittedContracts).map((contract) => ( |
||||
<div key={contract.address}> |
||||
<div>Contract Address: {contract.address}</div> |
||||
<div>Chain ID: {contract.chainId}</div> |
||||
<div> |
||||
filePath: {contract.filePath} contractName: {contract.contractName} |
||||
</div> |
||||
<div>Submission Date: {contract.date.toLocaleString()}</div> |
||||
<div> |
||||
Receipts:{' '} |
||||
<ul> |
||||
{contract.receipts.map((receipt) => ( |
||||
<li key={`${contract.address}-${receipt.verifier.name}`}> |
||||
<ul> |
||||
<li>Verifier: {receipt.verifier.name}</li> |
||||
<li>API URL: {receipt.verifier.apiUrl}</li> |
||||
<li>Status: {receipt.status}</li> |
||||
<li>Receipt ID: {receipt.receiptId}</li> |
||||
<li>Message: {receipt.message}</li> |
||||
</ul> |
||||
</li> |
||||
))} |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
))} |
||||
</div> |
||||
) |
||||
} |
Loading…
Reference in new issue