mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Rename methods encode* to eip712Encode*
This commit is contained in:
parent
4382dc3d2e
commit
e7bb0b38e1
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user