mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6042 from ethereum/fixEventSignatureInLibraries
Fix event signature in libraries
This commit is contained in:
commit
03b8fcd7eb
@ -13,6 +13,7 @@ Bugfixes:
|
||||
* ABIEncoderV2: Fix internal error related to bare delegatecall.
|
||||
* ABIEncoderV2: Fix internal error related to ecrecover.
|
||||
* ABIEncoderV2: Fix internal error related to mappings as library parameters.
|
||||
* ABIEncoderV2: Fix invalid signature for events containing structs emitted in libraries.
|
||||
* Inline Assembly: Proper error message for missing variables.
|
||||
* SMTChecker: Fixed crash when used with fixed-sized arrays.
|
||||
* Yul: Properly detect name clashes with functions before their declaration.
|
||||
|
@ -3062,7 +3062,8 @@ string FunctionType::externalSignature() const
|
||||
solAssert(false, "Invalid function type for requesting external signature.");
|
||||
}
|
||||
|
||||
bool const inLibrary = dynamic_cast<ContractDefinition const&>(*m_declaration->scope()).isLibrary();
|
||||
// "inLibrary" is only relevant if this is not an event.
|
||||
bool const inLibrary = kind() != Kind::Event && dynamic_cast<ContractDefinition const&>(*m_declaration->scope()).isLibrary();
|
||||
FunctionTypePointer external = interfaceFunctionType();
|
||||
solAssert(!!external, "External function type requested.");
|
||||
auto parameterTypes = external->parameterTypes();
|
||||
|
@ -444,6 +444,7 @@ BOOST_AUTO_TEST_CASE(structs)
|
||||
);
|
||||
BOOST_CHECK(callContractFunction("f()") == encoded);
|
||||
REQUIRE_LOG_DATA(encoded);
|
||||
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("e(uint16,(uint16,uint16,(uint64[2])[],uint16))")));
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -14097,6 +14097,35 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_arrayOfStrings)
|
||||
BOOST_CHECK_EQUAL(m_logs[0].topics[1], dev::keccak256(asString(arrayEncoding)));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(event_signature_in_library)
|
||||
{
|
||||
// This tests a bug that was present where the "internal signature"
|
||||
// for structs was also used for events.
|
||||
char const* sourceCode = R"(
|
||||
pragma experimental ABIEncoderV2;
|
||||
library L {
|
||||
struct S {
|
||||
uint8 a;
|
||||
int16 b;
|
||||
}
|
||||
event E(S indexed, S);
|
||||
function f() internal {
|
||||
S memory s;
|
||||
emit E(s, s);
|
||||
}
|
||||
}
|
||||
contract C {
|
||||
constructor() public {
|
||||
L.f();
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 2);
|
||||
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("E((uint8,int16),(uint8,int16))")));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(abi_encode_with_selector)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
|
Loading…
Reference in New Issue
Block a user