Rename methods encode* to eip712Encode*

This commit is contained in:
Anton Bukov 2023-05-09 12:16:06 +02:00
parent 4382dc3d2e
commit e7bb0b38e1
2 changed files with 11 additions and 11 deletions

View File

@ -391,7 +391,7 @@ std::vector<std::pair<ASTPointer<IdentifierPath>, std::optional<Token>>> UsingFo
return ranges::zip_view(m_functionsOrLibrary, m_operators) | ranges::to<vector>;
}
void StructDefinition::insertEncodedSubtypes(std::set<std::string>& subtypes) const
void StructDefinition::insertEip712EncodedSubtypes(std::set<std::string>& subtypes) const
{
for (size_t i = 0; i < m_members.size(); i++)
{
@ -401,13 +401,13 @@ void StructDefinition::insertEncodedSubtypes(std::set<std::string>& subtypes) co
StructDefinition const* structDef = dynamic_cast<StructDefinition const*>(declaration);
solAssert(structDef != nullptr);
subtypes.insert(structDef->encodeTypeWithoutSubtypes());
structDef->insertEncodedSubtypes(subtypes);
subtypes.insert(structDef->eip712EncodeTypeWithoutSubtypes());
structDef->insertEip712EncodedSubtypes(subtypes);
}
}
}
std::string StructDefinition::encodeTypeWithoutSubtypes() const
std::string StructDefinition::eip712EncodeTypeWithoutSubtypes() const
{
std::string str = name() + "(";
for (size_t i = 0; i < m_members.size(); i++)
@ -418,17 +418,17 @@ std::string StructDefinition::encodeTypeWithoutSubtypes() const
return str + ")";
}
std::string StructDefinition::encodeType() const
std::string StructDefinition::eip712EncodeType() const
{
// std::set enables duplicates elimination and ordered enumeration
std::set<std::string> subtypes;
insertEncodedSubtypes(subtypes);
return std::accumulate(subtypes.begin(), subtypes.end(), encodeTypeWithoutSubtypes());
insertEip712EncodedSubtypes(subtypes);
return std::accumulate(subtypes.begin(), subtypes.end(), eip712EncodeTypeWithoutSubtypes());
}
util::h256 StructDefinition::typehash() const
{
return util::keccak256(encodeType());
return util::keccak256(eip712EncodeType());
}
Type const* StructDefinition::type() const

View File

@ -742,13 +742,13 @@ public:
std::vector<ASTPointer<VariableDeclaration>> const& members() const { return m_members; }
/// Fills set with the EIP-712 compatible struct encodings without subtypes concatenated.
void insertEncodedSubtypes(std::set<std::string>& subtypes) const;
void insertEip712EncodedSubtypes(std::set<std::string>& subtypes) const;
/// @returns the EIP-712 compatible struct encoding but without subtypes concatenated.
std::string encodeTypeWithoutSubtypes() const;
std::string eip712EncodeTypeWithoutSubtypes() const;
/// @returns the EIP-712 compatible struct encoding with subtypes sorted and concatenated.
std::string encodeType() const;
std::string eip712EncodeType() const;
/// @returns the EIP-712 compatible typehash of this struct.
util::h256 typehash() const;