MCPcopy Create free account
hub / github.com/argotorg/solidity / parseInput

Method parseInput

libsolidity/interface/StandardCompiler.cpp:695–1323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693}
694
695std::variant<StandardCompiler::InputsAndSettings, Json> StandardCompiler::parseInput(Json const& _input)
696{
697 InputsAndSettings ret;
698
699 if (!_input.is_object())
700 return formatFatalError(Error::Type::JSONError, "Input is not a JSON object.");
701
702 if (auto result = checkRootKeys(_input))
703 return *result;
704
705 ret.language = _input.value<std::string>("language", "");
706
707 Json const& sources = _input.value<Json>("sources", Json());
708
709 if (!sources.is_object() && !sources.is_null())
710 return formatFatalError(Error::Type::JSONError, "\"sources\" is not a JSON object.");
711
712 if (sources.empty())
713 return formatFatalError(Error::Type::JSONError, "No input sources specified.");
714
715 ret.errors = Json::array();
716 ret.sources = Json::object();
717
718 if (ret.language == "Solidity" || ret.language == "Yul")
719 {
720 for (auto const& [sourceName, sourceValue]: sources.items())
721 {
722 std::string hash;
723
724 if (auto result = checkSourceKeys(sourceValue, sourceName))
725 return *result;
726
727 if (sourceValue.contains("keccak256") && sourceValue["keccak256"].is_string())
728 hash = sourceValue["keccak256"].get<std::string>();
729
730 if (sourceValue.contains("content") && sourceValue["content"].is_string())
731 {
732 std::string content = sourceValue["content"].get<std::string>();
733 if (!hash.empty() && !hashMatchesContent(hash, content))
734 ret.errors.emplace_back(formatError(
735 Error::Type::IOError,
736 "general",
737 "Mismatch between content and supplied hash for \"" + sourceName + "\""
738 ));
739 else
740 ret.sources[sourceName] = content;
741 }
742 else if (sourceValue["urls"].is_array())
743 {
744 if (!m_readFile)
745 return formatFatalError(
746 Error::Type::JSONError, "No import callback supplied, but URL is requested."
747 );
748
749 std::vector<std::string> failures;
750 bool found = false;
751
752 for (auto const& url: sourceValue["urls"])

Callers

nothing calls this directly

Calls 15

formatFatalErrorFunction · 0.85
checkRootKeysFunction · 0.85
checkSourceKeysFunction · 0.85
hashMatchesContentFunction · 0.85
formatErrorFunction · 0.85
jsonCompactPrintFunction · 0.85
checkAuxiliaryInputKeysFunction · 0.85
checkSettingsKeysFunction · 0.85
checkKeysFunction · 0.85
revertStringsFromStringFunction · 0.85
parseOptimizerSettingsFunction · 0.85
checkMetadataKeysFunction · 0.85

Tested by

no test coverage detected