Merge pull request #10351 from ethereum/useNewPragma

Use new abi coder pragma
This commit is contained in:
chriseth 2020-11-24 15:44:03 +01:00 committed by GitHub
commit 3e5816097e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
277 changed files with 325 additions and 320 deletions

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint x; }

View File

@ -1,5 +1,5 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint[] calldata) pure external {}
}
}

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
pragma experimental ABIEncoderV2;
pragma abicoder v2;
// The point of this test is to check that the
// AST IDs are removed from the optimized IR

View File

@ -2,7 +2,7 @@
"language": "Solidity",
"sources": {
"a.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0\npragma experimental ABIEncoderV2; contract A { function f(uint[] memory) public view returns (uint256) { } }"
"content": "// SPDX-License-Identifier: GPL-3.0\npragma abicoder v2; contract A { function f(uint[] memory) public view returns (uint256) { } }"
}
},
"settings": {

View File

@ -82,5 +82,5 @@
}
}
","id":1,"language":"Yul","name":"#utility.yul"}],"immutableReferences":{},"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"70:74:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;83:59;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;130:7;83:59;;;:::o;24:622:1:-;;145:80;160:64;217:6;160:64;:::i;:::-;145:80;:::i;:::-;136:89;;245:5;273:6;266:5;259:21;299:4;292:5;288:16;281:23;;324:6;374:3;366:4;358:6;354:17;349:3;345:27;342:36;339:2;;;391:1;388;381:12;339:2;419:1;404:236;429:6;426:1;423:13;404:236;;;496:3;524:37;557:3;545:10;524:37;:::i;:::-;519:3;512:50;591:4;586:3;582:14;575:21;;625:4;620:3;616:14;609:21;;464:176;451:1;448;444:9;439:14;;404:236;;;408:14;126:520;;;;;;;:::o;669:303::-;;789:3;782:4;774:6;770:17;766:27;756:2;;807:1;804;797:12;756:2;847:6;834:20;872:94;962:3;954:6;947:4;939:6;935:17;872:94;:::i;:::-;863:103;;746:226;;;;;:::o;978:139::-;;1062:6;1049:20;1040:29;;1078:33;1105:5;1078:33;:::i;:::-;1030:87;;;;:::o;1123:403::-;;1256:2;1244:9;1235:7;1231:23;1227:32;1224:2;;;1272:1;1269;1262:12;1224:2;1342:1;1331:9;1327:17;1314:31;1372:18;1364:6;1361:30;1358:2;;;1404:1;1401;1394:12;1358:2;1431:78;1501:7;1492:6;1481:9;1477:22;1431:78;:::i;:::-;1421:88;;1286:233;1214:312;;;;:::o;1532:118::-;1619:24;1637:5;1619:24;:::i;:::-;1614:3;1607:37;1597:53;;:::o;1656:222::-;;1787:2;1776:9;1772:18;1764:26;;1800:71;1868:1;1857:9;1853:17;1844:6;1800:71;:::i;:::-;1754:124;;;;:::o;1884:278::-;;1950:2;1944:9;1934:19;;1992:4;1984:6;1980:17;2099:6;2087:10;2084:22;2063:18;2051:10;2048:34;2045:62;2042:2;;;2110:13;;:::i;:::-;2042:2;2145:10;2141:2;2134:22;1924:238;;;;:::o;2168:306::-;;2335:18;2327:6;2324:30;2321:2;;;2357:13;;:::i;:::-;2321:2;2402:4;2394:6;2390:17;2382:25;;2462:4;2456;2452:15;2444:23;;2250:224;;;:::o;2480:77::-;;2546:5;2535:16;;2525:32;;;:::o;2563:48::-;2596:9;2617:122;2690:24;2708:5;2690:24;:::i;:::-;2683:5;2680:35;2670:2;;2729:1;2726;2719:12;2670:2;2660:79;:::o"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version!
","id":1,"language":"Yul","name":"#utility.yul"}],"immutableReferences":{},"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"56:74:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;69:59;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;116:7;69:59;;;:::o;24:622:1:-;;145:80;160:64;217:6;160:64;:::i;:::-;145:80;:::i;:::-;136:89;;245:5;273:6;266:5;259:21;299:4;292:5;288:16;281:23;;324:6;374:3;366:4;358:6;354:17;349:3;345:27;342:36;339:2;;;391:1;388;381:12;339:2;419:1;404:236;429:6;426:1;423:13;404:236;;;496:3;524:37;557:3;545:10;524:37;:::i;:::-;519:3;512:50;591:4;586:3;582:14;575:21;;625:4;620:3;616:14;609:21;;464:176;451:1;448;444:9;439:14;;404:236;;;408:14;126:520;;;;;;;:::o;669:303::-;;789:3;782:4;774:6;770:17;766:27;756:2;;807:1;804;797:12;756:2;847:6;834:20;872:94;962:3;954:6;947:4;939:6;935:17;872:94;:::i;:::-;863:103;;746:226;;;;;:::o;978:139::-;;1062:6;1049:20;1040:29;;1078:33;1105:5;1078:33;:::i;:::-;1030:87;;;;:::o;1123:403::-;;1256:2;1244:9;1235:7;1231:23;1227:32;1224:2;;;1272:1;1269;1262:12;1224:2;1342:1;1331:9;1327:17;1314:31;1372:18;1364:6;1361:30;1358:2;;;1404:1;1401;1394:12;1358:2;1431:78;1501:7;1492:6;1481:9;1477:22;1431:78;:::i;:::-;1421:88;;1286:233;1214:312;;;;:::o;1532:118::-;1619:24;1637:5;1619:24;:::i;:::-;1614:3;1607:37;1597:53;;:::o;1656:222::-;;1787:2;1776:9;1772:18;1764:26;;1800:71;1868:1;1857:9;1853:17;1844:6;1800:71;:::i;:::-;1754:124;;;;:::o;1884:278::-;;1950:2;1944:9;1934:19;;1992:4;1984:6;1980:17;2099:6;2087:10;2084:22;2063:18;2051:10;2048:34;2045:62;2042:2;;;2110:13;;:::i;:::-;2042:2;2145:10;2141:2;2134:22;1924:238;;;;:::o;2168:306::-;;2335:18;2327:6;2324:30;2321:2;;;2357:13;;:::i;:::-;2321:2;2402:4;2394:6;2390:17;2382:25;;2462:4;2456;2452:15;2444:23;;2250:224;;;:::o;2480:77::-;;2546:5;2535:16;;2525:32;;;:::o;2563:48::-;2596:9;2617:122;2690:24;2708:5;2690:24;:::i;:::-;2683:5;2680:35;2670:2;;2729:1;2726;2719:12;2670:2;2660:79;:::o"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version!
","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"}],"sources":{"a.sol":{"id":0}}}

View File

@ -2,7 +2,7 @@
"language": "Solidity",
"sources": {
"a.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0\npragma experimental ABIEncoderV2; contract A { function f(uint[] memory) public view returns (uint256) { } }"
"content": "// SPDX-License-Identifier: GPL-3.0\npragma abicoder v2; contract A { function f(uint[] memory) public view returns (uint256) { } }"
}
},
"settings": {

View File

@ -35,5 +35,5 @@
tail := add(headStart, 32)
mstore(headStart, value0)
}
}","id":1,"language":"Yul","name":"#utility.yul"}],"immutableReferences":{},"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"70:74:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;83:59;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;130:7:0;;83:59::o;14:1140:1:-;;129:2;172;160:9;151:7;147:23;143:32;140:2;;;193:6;185;178:22;140:2;238:9;225:23;267:18;308:2;300:6;297:14;294:2;;;329:6;321;314:22;294:2;372:6;361:9;357:22;347:32;;417:7;410:4;406:2;402:13;398:27;388:2;;444:6;436;429:22;388:2;485;472:16;507:2;503;500:10;497:2;;;513:9;497:2;551;547;543:11;583:2;577:9;634:2;629;621:6;617:15;613:24;687:6;675:10;672:22;667:2;655:10;652:18;649:46;646:2;;;698:9;646:2;725;718:22;775:18;;;809:15;;;;-1:-1:-1;844:11:1;;;874;;;870:20;;867:33;-1:-1:-1;864:2:1;;;918:6;910;903:22;864:2;945:6;936:15;;960:163;974:2;971:1;968:9;960:163;;;1031:17;;1019:30;;992:1;985:9;;;;;1069:12;;;;1101;;960:163;;;-1:-1:-1;1142:6:1;109:1045;-1:-1:-1;;;;;;;;109:1045:1:o;1159:177::-;1305:25;;;1293:2;1278:18;;1260:76::o"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version!
}","id":1,"language":"Yul","name":"#utility.yul"}],"immutableReferences":{},"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"56:74:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;69:59;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;116:7:0;;69:59::o;14:1140:1:-;;129:2;172;160:9;151:7;147:23;143:32;140:2;;;193:6;185;178:22;140:2;238:9;225:23;267:18;308:2;300:6;297:14;294:2;;;329:6;321;314:22;294:2;372:6;361:9;357:22;347:32;;417:7;410:4;406:2;402:13;398:27;388:2;;444:6;436;429:22;388:2;485;472:16;507:2;503;500:10;497:2;;;513:9;497:2;551;547;543:11;583:2;577:9;634:2;629;621:6;617:15;613:24;687:6;675:10;672:22;667:2;655:10;652:18;649:46;646:2;;;698:9;646:2;725;718:22;775:18;;;809:15;;;;-1:-1:-1;844:11:1;;;874;;;870:20;;867:33;-1:-1:-1;864:2:1;;;918:6;910;903:22;864:2;945:6;936:15;;960:163;974:2;971:1;968:9;960:163;;;1031:17;;1019:30;;992:1;985:9;;;;;1069:12;;;;1101;;960:163;;;-1:-1:-1;1142:6:1;109:1045;-1:-1:-1;;;;;;;;109:1045:1:o;1159:177::-;1305:25;;;1293:2;1278:18;;1260:76::o"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version!
","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"}],"sources":{"a.sol":{"id":0}}}

View File

@ -180,14 +180,14 @@ function force_solc_settings
function force_abi_v2
{
# Add "pragma experimental ABIEncoderV2" to all files.
printLog "Forcibly enabling ABIEncoderV2..."
# Add "pragma abi coder v2" to all files.
printLog "Forcibly enabling abi coder v2..."
find contracts test -name '*.sol' -type f -print0 | \
while IFS= read -r -d '' file
do
# Only add the pragma if it is not already there.
if grep -q -v 'pragma experimental ABIEncoderV2' "$file"; then
sed -i -e '1 i pragma experimental ABIEncoderV2;' "$file"
if grep -q -v 'pragma abicoder v2' "$file"; then
sed -i -e '1 i pragma abicoder v2;' "$file"
fi
done
}
@ -257,7 +257,7 @@ function truffle_run_test
do
clean
force_solc_settings "$CONFIG" "$optimize" "istanbul"
# Force ABIEncoderV2 in the last step. Has to be the last because code is modified.
# Force abi coder v2 in the last step. Has to be the last because code is modified.
if [ "$FORCE_ABIv2" = true ]; then
[[ "$optimize" =~ yul ]] && force_abi_v2
fi

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint a; T[] sub; bytes b; }
struct T { uint[2] x; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
struct S { uint a; }
contract C {
function f(S calldata s) external view {}

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint a; T[] sub; }
struct T { uint[2] x; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { C[] x; C y; }
function f() public returns (S memory s, C c) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
library L {
struct S { uint a; T[] sub; bytes b; }
struct T { uint[2] x; }

View File

@ -1983,7 +1983,7 @@ BOOST_AUTO_TEST_CASE(event_really_really_lots_of_data_from_storage)
BOOST_AUTO_TEST_CASE(event_struct_memory_v2)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint a; }
event E(S);
@ -2005,7 +2005,7 @@ BOOST_AUTO_TEST_CASE(event_struct_memory_v2)
BOOST_AUTO_TEST_CASE(event_struct_storage_v2)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint a; }
event E(S);
@ -2053,7 +2053,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_memory)
BOOST_AUTO_TEST_CASE(event_dynamic_array_memory_v2)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
event E(uint[]);
function createEvent(uint x) public {
@ -2078,7 +2078,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_memory_v2)
BOOST_AUTO_TEST_CASE(event_dynamic_nested_array_memory_v2)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
event E(uint[][]);
function createEvent(uint x) public {
@ -2136,7 +2136,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_storage)
BOOST_AUTO_TEST_CASE(event_dynamic_array_storage_v2)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
event E(uint[]);
uint[] arr;
@ -2167,7 +2167,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_storage_v2)
BOOST_AUTO_TEST_CASE(event_dynamic_nested_array_storage_v2)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
event E(uint[][]);
uint[][] arr;
@ -2332,7 +2332,7 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall)
for (auto v2: {false, true})
{
string source = (v2 ? "pragma experimental ABIEncoderV2;\n" : "") + string(sourceCode);
string source = "pragma abicoder " + string(v2 ? "v2" : "v1") + ";\n" + string(sourceCode);
compileAndRun(source, 0, "Receiver");
u160 const c_receiverAddress = m_contractAddress;
@ -2660,7 +2660,7 @@ BOOST_AUTO_TEST_CASE(storing_invalid_boolean)
BOOST_AUTO_TEST_CASE(struct_referencing)
{
static char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
interface I {
struct S { uint a; }
}
@ -2803,7 +2803,7 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_abi)
// NOTE: This does not really test copying from storage to ABI directly,
// because it will always copy to memory first.
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract c {
uint8[] x;
uint16[] y;
@ -3191,7 +3191,7 @@ BOOST_AUTO_TEST_CASE(memory_types_initialisation)
BOOST_AUTO_TEST_CASE(calldata_struct_short)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint256 a; uint256 b; }
function f(S calldata) external pure returns (uint256) {
@ -3214,7 +3214,7 @@ BOOST_AUTO_TEST_CASE(calldata_struct_short)
BOOST_AUTO_TEST_CASE(calldata_struct_function_type)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { function (uint) external returns (uint) fn; }
function f(S calldata s) external returns (uint256) {
@ -3263,7 +3263,7 @@ BOOST_AUTO_TEST_CASE(calldata_array_dynamic_three_dimensional)
arrayType += outerDynamicallySized ? "[]" : "[2]";
string sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function test()" + arrayType + R"( calldata a) external returns (uint256) {
return a.length;
@ -3865,7 +3865,7 @@ BOOST_AUTO_TEST_CASE(using_library_mappings_external)
)";
for (auto v2: {false, true})
{
string prefix = v2 ? "pragma experimental ABIEncoderV2;\n" : "";
string prefix = "pragma abicoder " + string(v2 ? "v2" : "v1") + ";\n";
compileAndRun(prefix + libSourceCode, 0, "Lib");
compileAndRun(prefix + sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(2), u256(0), u256(84), u256(46), u256(0), u256(198)));
@ -5137,7 +5137,8 @@ BOOST_AUTO_TEST_CASE(abi_encodePacked)
)";
for (auto v2: {false, true})
{
compileAndRun(string(v2 ? "pragma experimental ABIEncoderV2;\n" : "") + sourceCode, 0, "C");
string prefix = "pragma abicoder " + string(v2 ? "v2" : "v1") + ";\n";
compileAndRun(prefix + sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f0()"), encodeArgs(0x20, 0));
ABI_CHECK(callContractFunction("f1()"), encodeArgs(0x20, 2, "\x01\x02"));
ABI_CHECK(callContractFunction("f2()"), encodeArgs(0x20, 5, "\x01" "abc" "\x02"));
@ -5211,7 +5212,8 @@ BOOST_AUTO_TEST_CASE(abi_encodePacked_from_storage)
)";
for (auto v2: {false, true})
{
compileAndRun(string(v2 ? "pragma experimental ABIEncoderV2;\n" : "") + sourceCode, 0, "C");
string prefix = "pragma abicoder " + string(v2 ? "v2" : "v1") + ";\n";
compileAndRun(prefix + sourceCode, 0, "C");
bytes payload = encodeArgs(0xfffff1, 0, 0xfffff2, 0, 0, 0xfffff3, 0, 0, 0xfffff4);
bytes encoded = encodeArgs(0x20, 0x122, "\x01" + asString(payload) + "\x02");
ABI_CHECK(callContractFunction("sf()"), encoded);
@ -5281,7 +5283,8 @@ BOOST_AUTO_TEST_CASE(abi_encodePacked_from_memory)
)";
for (auto v2: {false, true})
{
compileAndRun(string(v2 ? "pragma experimental ABIEncoderV2;\n" : "") + sourceCode, 0, "C");
string prefix = "pragma abicoder " + string(v2 ? "v2" : "v1") + ";\n";
compileAndRun(prefix + sourceCode, 0, "C");
bytes payload = encodeArgs(0xfffff1, 0, 0xfffff2, 0, 0, 0xfffff3, 0, 0, 0xfffff4);
bytes encoded = encodeArgs(0x20, 0x122, "\x01" + asString(payload) + "\x02");
ABI_CHECK(callContractFunction("sf()"), encoded);
@ -5324,7 +5327,8 @@ BOOST_AUTO_TEST_CASE(abi_encodePacked_functionPtr)
)";
for (auto v2: {false, true})
{
compileAndRun(string(v2 ? "pragma experimental ABIEncoderV2;\n" : "") + sourceCode, 0, "C");
string prefix = "pragma abicoder " + string(v2 ? "v2" : "v1") + ";\n";
compileAndRun(prefix + sourceCode, 0, "C");
string directEncoding = asString(fromHex("08" "1112131400000000000011121314000000000087" "26121ff0" "02"));
ABI_CHECK(callContractFunction("testDirect()"), encodeArgs(0x20, directEncoding.size(), directEncoding));
string arrayEncoding = asString(fromHex("08" "1112131400000000000011121314000000000087" "26121ff0" "0000000000000000" "02"));
@ -5336,7 +5340,7 @@ BOOST_AUTO_TEST_CASE(abi_encodePacked_functionPtr)
BOOST_AUTO_TEST_CASE(abi_encodePackedV2_structs)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S {
uint8 a;
@ -5378,7 +5382,7 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_structs)
BOOST_AUTO_TEST_CASE(abi_encodePackedV2_nestedArray)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S {
uint8 a;
@ -5407,7 +5411,7 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_nestedArray)
BOOST_AUTO_TEST_CASE(abi_encodePackedV2_arrayOfStrings)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
string[] x;
event E(string[] indexed);
@ -5441,7 +5445,7 @@ 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;
pragma abicoder v2;
library L {
struct S {
uint8 a;
@ -5498,7 +5502,7 @@ BOOST_AUTO_TEST_CASE(abi_encode_with_selector)
BOOST_AUTO_TEST_CASE(abi_encode_with_selectorv2)
{
char const* sourceCode = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f0() public pure returns (bytes memory) {
return abi.encodeWithSelector(0x12345678);
@ -5588,7 +5592,7 @@ BOOST_AUTO_TEST_CASE(abi_encode_with_signature)
BOOST_AUTO_TEST_CASE(abi_encode_with_signaturev2)
{
char const* sourceCode = R"T(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f0() public pure returns (bytes memory) {
return abi.encodeWithSignature("f(uint256)");

View File

@ -132,11 +132,12 @@ bytes SolidityExecutionFramework::compileContract(
string SolidityExecutionFramework::addPreamble(string const& _sourceCode)
{
// Silence compiler version warning
string preamble = "pragma solidity >=0.0;\n";
string preamble = "pragma solidity >=0.0;\n// SPDX-License-Identifier: unlicensed\n";
if (
solidity::test::CommonOptions::get().useABIEncoderV2 &&
_sourceCode.find("pragma experimental ABIEncoderV2;") == string::npos
_sourceCode.find("pragma experimental ABIEncoderV2;") == string::npos &&
_sourceCode.find("pragma abicoder") == string::npos
)
preamble += "pragma experimental ABIEncoderV2;\n";
preamble += "pragma abicoder v2;\n";
return preamble + _sourceCode;
}

View File

@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE(enum_external_type)
BOOST_AUTO_TEST_CASE(external_struct_signatures)
{
char const* text = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract Test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
struct Simple { uint i; }
@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE(external_struct_signatures)
BOOST_AUTO_TEST_CASE(external_struct_signatures_in_libraries)
{
char const* text = R"(
pragma experimental ABIEncoderV2;
pragma abicoder v2;
library Test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
struct Simple { uint i; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
uint public a;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
uint public a;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function exp_neg_one(uint exponent) public returns(int) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function exp_neg_one(uint exponent) public returns(int) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function enc_packed_bytes(bytes calldata data, uint256 start, uint256 end) external returns (bytes memory) {
return abi.encodePacked(data[start:end]);

View File

@ -1,6 +1,6 @@
// Tests that this will not end up using a "bytes0" type
// (which would assert)
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,5 +1,5 @@
// Tests that rational numbers (even negative ones) are encoded properly.
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,5 +1,5 @@
==== Source: A ====
pragma experimental ABIEncoderV2;
pragma abicoder v2;
struct Data {
uint a;

View File

@ -1,5 +1,5 @@
==== Source: A ====
pragma experimental ABIEncoderV2;
pragma abicoder v2;
struct Data {
uint value;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(bool b) public pure returns (bool) { return b; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint a, bytes memory b, uint c)

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function g(uint256[] calldata) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint256[] calldata s) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint256[] calldata s) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint8[][1][] calldata s) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint256[][2][] calldata x) external returns (uint256) {
x[0]; // trigger bounds checks

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint256[][2][] calldata x) external returns (uint256) {
return 42;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(function() external returns (uint)[] calldata s) external returns (uint, uint, uint) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint256[][] calldata s) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint256[3] calldata s) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint8[1][][1] calldata s) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint256[3] calldata s) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint256[] a; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint256[] calldata s1, uint256[] calldata s2, bool which) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint256[3] calldata s1, uint256[2] calldata s2, bool which) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint256[] a; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct A {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint256 a; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function g(address x) external pure returns (uint256 r) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function gggg(bool x) external pure returns (bool) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function gg1(bytes1 x) external pure returns (bytes32) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint16 a, int16 b, address c, bytes3 d, bool e)

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function ggg(uint8[] calldata s) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { function() external f; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function ggg8(int8 x) external pure returns (int256) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint8 a; bytes1 b; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function gggggggg(uint8[2] calldata s) external pure returns (bytes memory) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function ggg8(uint8 x) external pure returns (uint256) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint a, uint16[] memory b, uint c)

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(uint a, uint16[][] memory b, uint[2][][3] memory c, uint d)

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
enum E { A, B }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(bytes memory a, bytes calldata b, uint[] memory c)

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
// tests encoding from storage arrays

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { C c; uint[] x; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { C c; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { function () external returns (uint) f; uint b; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { int a; uint b; bytes16 c; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { uint a; uint8 b; uint8 c; bytes2 d; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { int16 a; uint8 b; bytes2 c; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S { function () external x; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(bytes calldata x) public returns (C[] memory) {
return abi.decode(x, (C[]));

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function test(uint256[][2] calldata a) external returns (uint256) {
return a.length;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function test(uint256[][] calldata a) external returns (uint256) {
return a.length;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function f(bytes[] calldata a, uint256 i) external returns (uint) {
return uint8(a[0][i]);

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract c {
uint256[][] a1;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
struct S {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
uint256[] s;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
struct S {
uint16 x;
bytes a;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
bytes[] a;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {
function g(uint[][2] calldata s) internal pure returns (uint, uint[] calldata) {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
struct S {
uint x;

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract C {

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
// Checks that address types are properly cleaned before they are compared.

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
// Checks that bytesXX types are properly cleaned before they are compared.

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
contract test {
function a(bytes32 h, uint8 v, bytes32 r, bytes32 s) public returns (address addr) {
return ecrecover(h, v, r, s);

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
library L {
struct S { uint256 a; }
function f(S storage s) external returns (uint) { return s.a; }

View File

@ -1,4 +1,4 @@
pragma experimental ABIEncoderV2;
pragma abicoder v2;
library Lib {
struct Items {

Some files were not shown because too many files have changed in this diff Show More