Introduce block.chainid

This commit is contained in:
Alex Beregszaszi
2020-12-10 17:07:54 +00:00
parent d0551b67d7
commit 7cd05bf603
13 changed files with 42 additions and 2 deletions
@@ -0,0 +1,12 @@
contract C {
function f() public returns (uint) {
return block.chainid;
}
}
// ====
// EVMVersion: >=istanbul
// compileViaYul: also
// ----
// f() -> 1
// f() -> 1
// f() -> 1
@@ -11,6 +11,11 @@ contract C {
function i() public view returns (uint) {
return block.timestamp;
}
function j() public view returns (uint) {
return block.chainid;
}
}
// ====
// EVMVersion: <istanbul
// ----
// TypeError 3081: (420-433): "chainid" is not supported by the VM version.
@@ -11,6 +11,9 @@ contract C {
function i() public view returns (uint) {
return block.timestamp;
}
function j() public view returns (uint) {
return block.chainid;
}
}
// ====
// EVMVersion: >=istanbul
@@ -2,8 +2,12 @@ contract C {
function f() public pure {
assembly { pop(chainid()) }
}
function g() public pure returns (uint) {
return block.chainid;
}
}
// ====
// EVMVersion: >=istanbul
// ----
// TypeError 2527: (67-76): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
// TypeError 2527: (147-160): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
@@ -2,6 +2,9 @@ contract C {
function f() public view {
assembly { pop(chainid()) }
}
function g() public view returns (uint) {
return block.chainid;
}
}
// ====
// EVMVersion: >=istanbul