mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Introduce block.chainid
This commit is contained in:
@@ -2922,6 +2922,12 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
|
||||
(memberName == "min" || memberName == "max")
|
||||
)
|
||||
annotation.isPure = true;
|
||||
else if (magicType->kind() == MagicType::Kind::Block && memberName == "chainid" && !m_evmVersion.hasChainID())
|
||||
m_errorReporter.typeError(
|
||||
3081_error,
|
||||
_memberAccess.location(),
|
||||
"\"chainid\" is not supported by the VM version."
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
@@ -368,7 +368,6 @@ void ViewPureChecker::endVisit(MemberAccess const& _memberAccess)
|
||||
{MagicType::Kind::ABI, "encodePacked"},
|
||||
{MagicType::Kind::ABI, "encodeWithSelector"},
|
||||
{MagicType::Kind::ABI, "encodeWithSignature"},
|
||||
{MagicType::Kind::Block, "blockhash"},
|
||||
{MagicType::Kind::Message, "data"},
|
||||
{MagicType::Kind::Message, "sig"},
|
||||
{MagicType::Kind::MetaType, "creationCode"},
|
||||
|
||||
@@ -3825,7 +3825,8 @@ MemberList::MemberMap MagicType::nativeMembers(ASTNode const*) const
|
||||
{"blockhash", TypeProvider::function(strings{"uint"}, strings{"bytes32"}, FunctionType::Kind::BlockHash, false, StateMutability::View)},
|
||||
{"difficulty", TypeProvider::uint256()},
|
||||
{"number", TypeProvider::uint256()},
|
||||
{"gaslimit", TypeProvider::uint256()}
|
||||
{"gaslimit", TypeProvider::uint256()},
|
||||
{"chainid", TypeProvider::uint256()}
|
||||
});
|
||||
case Kind::Message:
|
||||
return MemberList::MemberMap({
|
||||
|
||||
@@ -1576,6 +1576,8 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
|
||||
m_context << Instruction::ORIGIN;
|
||||
else if (member == "gasprice")
|
||||
m_context << Instruction::GASPRICE;
|
||||
else if (member == "chainid")
|
||||
m_context << Instruction::CHAINID;
|
||||
else if (member == "data")
|
||||
m_context << u256(0) << Instruction::CALLDATASIZE;
|
||||
else if (member == "sig")
|
||||
|
||||
@@ -1688,6 +1688,8 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess)
|
||||
define(_memberAccess) << "origin()\n";
|
||||
else if (member == "gasprice")
|
||||
define(_memberAccess) << "gasprice()\n";
|
||||
else if (member == "chainid")
|
||||
define(_memberAccess) << "chainid()\n";
|
||||
else if (member == "data")
|
||||
{
|
||||
IRVariable var(_memberAccess);
|
||||
|
||||
Reference in New Issue
Block a user