|
|
@ -18,13 +18,15 @@ export const ContractDropdown: React.FC<ContractDropdownProps> = ({label, id}) = |
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
console.log('CompiilationOutput chainged', compilationOutput) |
|
|
|
console.log('CompiilationOutput chainged', compilationOutput) |
|
|
|
if (!compilationOutput) return |
|
|
|
if (!compilationOutput) return |
|
|
|
const isOnlyOneFileCompiled = Object.keys(compilationOutput).length === 1 |
|
|
|
// Otherwise select the first by default
|
|
|
|
if (isOnlyOneFileCompiled) { |
|
|
|
const triggerFilePath = Object.keys(compilationOutput)[0] |
|
|
|
const onlyFileName = Object.keys(compilationOutput)[0] |
|
|
|
const contracts = compilationOutput[triggerFilePath]?.data?.contracts |
|
|
|
const isOnlyOneContractCompiled = Object.keys(compilationOutput[onlyFileName].data.contracts[onlyFileName]).length === 1 |
|
|
|
if (contracts && Object.keys(contracts).length) { |
|
|
|
if (isOnlyOneContractCompiled) { |
|
|
|
const firstFilePath = Object.keys(contracts)[0] |
|
|
|
const onlyContractName = Object.keys(compilationOutput[onlyFileName].data.contracts[onlyFileName])[0] |
|
|
|
const contractsInFile = contracts[firstFilePath] |
|
|
|
setSelectedContractFileAndName(onlyFileName + ':' + onlyContractName) |
|
|
|
if (contractsInFile && Object.keys(contractsInFile).length) { |
|
|
|
|
|
|
|
const firstContractName = Object.keys(contractsInFile)[0] |
|
|
|
|
|
|
|
setSelectedContractFileAndName(triggerFilePath + ':' + firstFilePath + ':' + firstContractName) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, [compilationOutput]) |
|
|
|
}, [compilationOutput]) |
|
|
|