import { Row, Col, Card, Button } from 'react-bootstrap'; import { Project } from '../../../core/project'; import { useState } from 'react'; import Contract from '../Contract'; import { InfinityMintDeploymentLive } from 'infinitymint/dist/app/interfaces'; export default function Contracts({ project = { deployedProject: {}, } as any, selectComponent, selectTab, defaultContract = null, }: { project: Project; selectComponent: (component: string) => void; selectTab: (tab: string, props?: any) => void; defaultContract: InfinityMintDeploymentLive; }) { const [selectedContract, setSelectedContract] = useState(defaultContract); let deployments = Object.values(project.deployedProject.deployments); //filter duplicate contracts let contracts = deployments.filter( (contract, index, self) => index === self.findIndex((t) => t.contractName === contract.contractName) ); return ( <> {!selectedContract ? ( <>

Smart Contracts

Here are all the smart contracts that are part of this project.

{Object.values(contracts).map((contract) => { return ( {contract.contractName}{' '} {contract.network.name} {' '} {contract.module} Address
{contract.address}
Deployer
{contract.deployer}
); })}
) : ( <>

{selectedContract.contractName}

Deployed by {selectedContract.deployer} on{' '} {selectedContract.network.name} network.

{ setSelectedContract(null); }} /> )}
); }