|
|
|
@ -1,10 +1,10 @@ |
|
|
|
|
import React, { useMemo } from 'react' |
|
|
|
|
import { SubmittedContract, SubmittedProxyContract, isContract, isProxy } from '../types' |
|
|
|
|
import { SubmittedContract } from '../types' |
|
|
|
|
import { shortenAddress, CustomTooltip } from '@remix-ui/helper' |
|
|
|
|
import { AppContext } from '../AppContext' |
|
|
|
|
|
|
|
|
|
interface AccordionReceiptProps { |
|
|
|
|
contract: SubmittedContract | SubmittedProxyContract |
|
|
|
|
contract: SubmittedContract |
|
|
|
|
index: number |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -13,11 +13,8 @@ export const AccordionReceipt: React.FC<AccordionReceiptProps> = ({ contract, in |
|
|
|
|
|
|
|
|
|
const [expanded, setExpanded] = React.useState(false) |
|
|
|
|
|
|
|
|
|
const address = isProxy(contract) ? contract.implementation.address : contract.address |
|
|
|
|
|
|
|
|
|
const chainName = useMemo(() => { |
|
|
|
|
const chainId = isProxy(contract) ? contract.implementation.chainId : contract.chainId |
|
|
|
|
return chains.find((chain) => chain.chainId === parseInt(chainId))?.name ?? 'Unknown Chain' |
|
|
|
|
return chains.find((chain) => chain.chainId === parseInt(contract.chainId))?.name ?? 'Unknown Chain' |
|
|
|
|
}, [contract, chains]) |
|
|
|
|
|
|
|
|
|
const toggleAccordion = () => { |
|
|
|
@ -25,21 +22,21 @@ export const AccordionReceipt: React.FC<AccordionReceiptProps> = ({ contract, in |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div key={address + '-' + index} className="bg-secondary p-3 accordion-item" id={address + '-accordion-' + index}> |
|
|
|
|
<div key={contract.address + '-' + index} className="bg-secondary p-3 accordion-item" id={contract.address + '-accordion-' + index}> |
|
|
|
|
<h3 className="accordion-header" id={`heading${index}`}> |
|
|
|
|
<button className="accordion-button d-flex flex-row align-items-center text-left w-100 border-0" type="button" onClick={toggleAccordion} aria-expanded={expanded} aria-controls={`collapse${index}`}> |
|
|
|
|
<span className={`accordion-arrow ${expanded ? 'fa-angle-down' : 'fa-angle-right'} fa w-0`} style={{ width: '0' }}></span> |
|
|
|
|
<span className="pl-4" style={{ fontSize: '1rem' }}> |
|
|
|
|
<CustomTooltip tooltipText={address}> |
|
|
|
|
<span>{shortenAddress(address)}</span> |
|
|
|
|
<CustomTooltip tooltipText={contract.address}> |
|
|
|
|
<span>{shortenAddress(contract.address)}</span> |
|
|
|
|
</CustomTooltip>{' '} |
|
|
|
|
on {chainName} {isProxy(contract) ? 'with proxy' : ''} |
|
|
|
|
on {chainName} {contract.proxyAddress ? 'with proxy' : ''} |
|
|
|
|
</span> |
|
|
|
|
</button> |
|
|
|
|
</h3> |
|
|
|
|
<div id={`collapse${index}`} className={`accordion-collapse p-2 collapse ${expanded ? 'show' : ''}`} aria-labelledby={`heading${index}`} data-bs-parent="#receiptsAccordion"> |
|
|
|
|
<div className="accordion-body"> |
|
|
|
|
{isContract(contract) ? ( |
|
|
|
|
{!contract.proxyAddress ? ( |
|
|
|
|
<ReceiptsBody contract={contract}></ReceiptsBody> |
|
|
|
|
) : ( |
|
|
|
|
<> |
|
|
|
@ -47,16 +44,17 @@ export const AccordionReceipt: React.FC<AccordionReceiptProps> = ({ contract, in |
|
|
|
|
<span className="font-weight-bold" style={{ fontSize: '1.2rem' }}> |
|
|
|
|
Implementation |
|
|
|
|
</span> |
|
|
|
|
<ReceiptsBody contract={contract.implementation}></ReceiptsBody> |
|
|
|
|
<ReceiptsBody contract={contract}></ReceiptsBody> |
|
|
|
|
</div> |
|
|
|
|
<div className="mt-3"> |
|
|
|
|
<span className="font-weight-bold" style={{ fontSize: '1.2rem' }}> |
|
|
|
|
Proxy |
|
|
|
|
</span>{' '} |
|
|
|
|
<CustomTooltip tooltipText={contract.proxy.address}> |
|
|
|
|
<span>{shortenAddress(contract.proxy.address)}</span> |
|
|
|
|
<CustomTooltip tooltipText={contract.proxyAddress}> |
|
|
|
|
<span>{shortenAddress(contract.proxyAddress)}</span> |
|
|
|
|
</CustomTooltip> |
|
|
|
|
<ReceiptsBody contract={contract.proxy}></ReceiptsBody> |
|
|
|
|
{/* TODO add body for proxies */} |
|
|
|
|
{/* <ReceiptsBody contract={contract.proxy}></ReceiptsBody> */} |
|
|
|
|
</div> |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|