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>;
|
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++)
|
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);
|
StructDefinition const* structDef = dynamic_cast<StructDefinition const*>(declaration);
|
||||||
solAssert(structDef != nullptr);
|
solAssert(structDef != nullptr);
|
||||||
|
|
||||||
subtypes.insert(structDef->encodeTypeWithoutSubtypes());
|
subtypes.insert(structDef->eip712EncodeTypeWithoutSubtypes());
|
||||||
structDef->insertEncodedSubtypes(subtypes);
|
structDef->insertEip712EncodedSubtypes(subtypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StructDefinition::encodeTypeWithoutSubtypes() const
|
std::string StructDefinition::eip712EncodeTypeWithoutSubtypes() const
|
||||||
{
|
{
|
||||||
std::string str = name() + "(";
|
std::string str = name() + "(";
|
||||||
for (size_t i = 0; i < m_members.size(); i++)
|
for (size_t i = 0; i < m_members.size(); i++)
|
||||||
@ -418,17 +418,17 @@ std::string StructDefinition::encodeTypeWithoutSubtypes() const
|
|||||||
return str + ")";
|
return str + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StructDefinition::encodeType() const
|
std::string StructDefinition::eip712EncodeType() const
|
||||||
{
|
{
|
||||||
// std::set enables duplicates elimination and ordered enumeration
|
// std::set enables duplicates elimination and ordered enumeration
|
||||||
std::set<std::string> subtypes;
|
std::set<std::string> subtypes;
|
||||||
insertEncodedSubtypes(subtypes);
|
insertEip712EncodedSubtypes(subtypes);
|
||||||
return std::accumulate(subtypes.begin(), subtypes.end(), encodeTypeWithoutSubtypes());
|
return std::accumulate(subtypes.begin(), subtypes.end(), eip712EncodeTypeWithoutSubtypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
util::h256 StructDefinition::typehash() const
|
util::h256 StructDefinition::typehash() const
|
||||||
{
|
{
|
||||||
return util::keccak256(encodeType());
|
return util::keccak256(eip712EncodeType());
|
||||||
}
|
}
|
||||||
|
|
||||||
Type const* StructDefinition::type() const
|
Type const* StructDefinition::type() const
|
||||||
|
@ -742,13 +742,13 @@ public:
|
|||||||
std::vector<ASTPointer<VariableDeclaration>> const& members() const { return m_members; }
|
std::vector<ASTPointer<VariableDeclaration>> const& members() const { return m_members; }
|
||||||
|
|
||||||
/// Fills set with the EIP-712 compatible struct encodings without subtypes concatenated.
|
/// 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.
|
/// @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.
|
/// @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.
|
/// @returns the EIP-712 compatible typehash of this struct.
|
||||||
util::h256 typehash() const;
|
util::h256 typehash() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user