Merge pull request #13629 from ethereum/metadata-standard-json-bugfix

fix: `bytecodeHash` cannot be set to non-none for `appendCBOR=false`
This commit is contained in:
Kamil Śliwak 2022-10-19 21:21:41 +02:00 committed by GitHub
commit 4679ae0275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 0 deletions

View File

@ -929,6 +929,13 @@ std::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompiler:
metadataHash == "bzzr1" ? metadataHash == "bzzr1" ?
CompilerStack::MetadataHash::Bzzr1 : CompilerStack::MetadataHash::Bzzr1 :
CompilerStack::MetadataHash::None; CompilerStack::MetadataHash::None;
if (ret.metadataFormat == CompilerStack::MetadataFormat::NoMetadata && ret.metadataHash != CompilerStack::MetadataHash::None)
return formatFatalError(
Error::Type::JSONError,
"When the parameter \"appendCBOR\" is set to false, the parameter \"bytecodeHash\" cannot be set to \"" +
metadataHash +
"\". The parameter \"bytecodeHash\" should either be skipped, or set to \"none\"."
);
} }
Json::Value outputSelection = settings.get("outputSelection", Json::Value()); Json::Value outputSelection = settings.get("outputSelection", Json::Value());

View File

@ -0,0 +1 @@
--pretty-json --json-indent 4

View File

@ -0,0 +1,29 @@
{
"language": "Solidity",
"sources":
{
"A":
{
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0;\n\ncontract test {}"
}
},
"settings":
{
"viaIR": true,
"optimizer": {
"enabled": true
},
"metadata":
{
"appendCBOR": false,
"bytecodeHash": "ipfs"
},
"outputSelection":
{
"A":
{
"test": ["evm.bytecode"]
}
}
}
}

View File

@ -0,0 +1,12 @@
{
"errors":
[
{
"component": "general",
"formattedMessage": "When the parameter \"appendCBOR\" is set to false, the parameter \"bytecodeHash\" cannot be set to \"ipfs\". The parameter \"bytecodeHash\" should either be skipped, or set to \"none\".",
"message": "When the parameter \"appendCBOR\" is set to false, the parameter \"bytecodeHash\" cannot be set to \"ipfs\". The parameter \"bytecodeHash\" should either be skipped, or set to \"none\".",
"severity": "error",
"type": "JSONError"
}
]
}