mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add helper to show if contract can be deployed.
This commit is contained in:
parent
01ad4bffe7
commit
a9fa2658d8
@ -138,6 +138,11 @@ bool ContractDefinition::constructorIsPublic() const
|
||||
return !f || f->isPublic();
|
||||
}
|
||||
|
||||
bool ContractDefinition::canBeDeployed() const
|
||||
{
|
||||
return constructorIsPublic() && annotation().unimplementedFunctions.empty();
|
||||
}
|
||||
|
||||
FunctionDefinition const* ContractDefinition::fallbackFunction() const
|
||||
{
|
||||
for (ContractDefinition const* contract: annotation().linearizedBaseContracts)
|
||||
|
@ -408,6 +408,10 @@ public:
|
||||
FunctionDefinition const* constructor() const;
|
||||
/// @returns true iff the constructor of this contract is public (or non-existing).
|
||||
bool constructorIsPublic() const;
|
||||
/// @returns true iff the contract can be deployed, i.e. is not abstract and has a
|
||||
/// public constructor.
|
||||
/// Should only be called after the type checker has run.
|
||||
bool canBeDeployed() const;
|
||||
/// Returns the fallback function or nullptr if no fallback function was specified.
|
||||
FunctionDefinition const* fallbackFunction() const;
|
||||
|
||||
|
@ -3423,7 +3423,7 @@ MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const*) const
|
||||
"Only contracts supported for now"
|
||||
);
|
||||
ContractDefinition const& contract = dynamic_cast<ContractType const&>(*m_typeArgument).contractDefinition();
|
||||
if (contract.annotation().unimplementedFunctions.empty() && contract.constructorIsPublic())
|
||||
if (contract.canBeDeployed())
|
||||
return MemberList::MemberMap({
|
||||
{"creationCode", std::make_shared<ArrayType>(DataLocation::Memory)},
|
||||
{"runtimeCode", std::make_shared<ArrayType>(DataLocation::Memory)}
|
||||
|
@ -800,11 +800,7 @@ void CompilerStack::compileContract(
|
||||
{
|
||||
solAssert(m_stackState >= AnalysisSuccessful, "");
|
||||
|
||||
if (
|
||||
_otherCompilers.count(&_contract) ||
|
||||
!_contract.annotation().unimplementedFunctions.empty() ||
|
||||
!_contract.constructorIsPublic()
|
||||
)
|
||||
if (_otherCompilers.count(&_contract) || !_contract.canBeDeployed())
|
||||
return;
|
||||
for (auto const* dependency: _contract.annotation().contractDependencies)
|
||||
compileContract(*dependency, _otherCompilers);
|
||||
|
Loading…
Reference in New Issue
Block a user