diff --git a/gen/libraryTestWrapper.ts b/gen/libraryTestWrapper.ts index 13777a5..07ebe58 100644 --- a/gen/libraryTestWrapper.ts +++ b/gen/libraryTestWrapper.ts @@ -1,10 +1,19 @@ //Simple parser for .sol files that finds libraries defined in the file and creates a wrapper -// that converts all their internal functions to external functions so they can be tested -// in forge unit tests. +// that converts all their internal functions to external functions so they can be externally +// called in forge unit tests. +// +//Forge supports vm.expectRevert even for internal functions, so this wrapper is primarily +// helpful for libraries like BytesParsing (the original motivation for this script) where +// you have a large family of similar functions to test and you don't want to write a separate +// test for each one. So, it really mostly is a workaround for Solidity's lack of support for +// generics. + +//Regarding the implementation of this script: //Instead of properly parsing the full AST, we make our task of finding and transforming the // relevant bits easier by making some basic assumptions about code formatting that any sane -// code should almost certainly adhere to regardless. - +// code should almost certainly adhere to regardless, like closing braces of library definitions +// being on their own line with no leading whitespace, etc. +// //Solidity language grammar: // https://docs.soliditylang.org/en/latest/grammar.html @@ -43,8 +52,22 @@ if (process.argv.length != 3) { process.exit(1); } -const filename = process.argv[2]; -let fileCode = readFileSync("../src/" + filename + filename.endsWith(".sol") ? "" : ".sol", "utf8"); +//convenience for use with Makefile: +//If no .sol file ending is specified, this script will use Wormhole Solidity SDK defaults for +// the file paths, the SPDX license header, the pragma version, and the import statement. +const fullPath = (() => { + const filename = process.argv[2]; + if (filename.endsWith(".sol")) + return filename; + + console.log( + `// SPDX-License-Identifier: Apache 2\npragma solidity ^0.8.24;\n\n` + + `import "wormhole-sdk/${filename}.sol";\n` + ); + + return "../src/" + filename + ".sol"; +})(); +let fileCode = readFileSync(fullPath, "utf8"); //we first remove all comments so we can be sure that everything we're parsing is actual code fileCode = removeComments(fileCode); @@ -76,13 +99,13 @@ for (const libs of libMatches) { const [_, funcName, funcParasRaw, modsRaw, close] = funcs; if (close == ';') continue; //function pointer, not a function definition - + if (!modsRaw.includes("internal")) continue; //not an internal function const retParasRegex = /returns\s*\(([\s\S]*?)\)/; const retParasRaw = modsRaw.match(retParasRegex); - + const collapseSpaceRegex = /\s\s+/g; const paramsToArray = (paramList: string) => paramList.replace(collapseSpaceRegex, ' ').trim().split(',').map(param => { @@ -100,12 +123,7 @@ for (const libs of libMatches) { } } -console.log(`// SPDX-License-Identifier: Apache 2 -pragma solidity ^0.8.24; - -//This file was auto-generated by libraryTestWrapper.ts - -import "wormhole-sdk/${filename}.sol";`); +console.log(`// This file was auto-generated by wormhole-solidity-sdk gen/libraryTestWrapper.ts`); const pConcat = (paras: string[]) => (paras.length > 2 ? "\n " : "") + @@ -121,7 +139,7 @@ const pNames = (paras: string[]) => for (const [libName, funcs] of Object.entries(libraries)) { console.log(`\ncontract ${libName}TestWrapper {`); - const funcCode = []; + const funcCode = []; for (const func of funcs) funcCode.push([ ` function ${func.name}(${pConcat(func.paras)}) external ${func.stateMut}` + diff --git a/src/constants/Common.sol b/src/constants/Common.sol new file mode 100644 index 0000000..27f19d9 --- /dev/null +++ b/src/constants/Common.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: Apache 2 +pragma solidity ^0.8.4; + +uint256 constant FREE_MEMORY_PTR = 0x40; +uint256 constant WORD_SIZE = 32; +//we can't define _WORD_SIZE_MINUS_ONE via _WORD_SIZE - 1 because of solc restrictions +// what constants can be used in inline assembly +uint256 constant WORD_SIZE_MINUS_ONE = 31; //=0x1f=0b00011111 + +//see section "prefer `< MAX + 1` over `<= MAX` for const comparison" in docs/Optimization.md +uint256 constant WORD_SIZE_PLUS_ONE = 33; diff --git a/src/libraries/BytesParsing.sol b/src/libraries/BytesParsing.sol index b776d5e..15300b1 100644 --- a/src/libraries/BytesParsing.sol +++ b/src/libraries/BytesParsing.sol @@ -1,14 +1,10 @@ // SPDX-License-Identifier: Apache 2 pragma solidity ^0.8.4; +import "../constants/Common.sol"; + //This file appears comically large, but all unused functions are removed by the compiler. library BytesParsing { - uint256 private constant _FREE_MEMORY_PTR = 0x40; - uint256 private constant _WORD_SIZE = 32; - //we can't define _WORD_SIZE_MINUS_ONE via _WORD_SIZE - 1 because of solc restrictions - // what constants can be used in inline assembly - uint256 private constant _WORD_SIZE_MINUS_ONE = 31; //=0x1f=0b00011111 - error OutOfBounds(uint256 offset, uint256 length); error LengthMismatch(uint256 encodedLength, uint256 expectedLength); error InvalidBoolVal(uint8 val); @@ -57,15 +53,17 @@ library BytesParsing { /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, length) + ret := mload(FREE_MEMORY_PTR) + mstore(ret, length) - let retStart := add(ret, _WORD_SIZE) + let retStart := add(ret, WORD_SIZE) let sliceStart := add(encoded.offset, offset) calldatacopy(retStart, sliceStart, length) //When compiling with --via-ir then normally allocated memory (i.e. via new) will have 32 byte // memory alignment and so we enforce the same memory alignment here. mstore( - _FREE_MEMORY_PTR, - and(add(add(retStart, length), _WORD_SIZE_MINUS_ONE), not(_WORD_SIZE_MINUS_ONE)) + FREE_MEMORY_PTR, + and(add(add(retStart, length), WORD_SIZE_MINUS_ONE), not(WORD_SIZE_MINUS_ONE)) ) } } @@ -78,6 +76,7 @@ library BytesParsing { /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, length) + ret := mload(FREE_MEMORY_PTR) //Explanation on how we copy data here: // The bytes type has the following layout in memory: @@ -93,9 +92,9 @@ library BytesParsing { // overwritting those garbage bytes. //and(length, 31) is equivalent to `mod(length, 32)`, but 2 gas cheaper - let shift := and(length, _WORD_SIZE_MINUS_ONE) + let shift := and(length, WORD_SIZE_MINUS_ONE) if iszero(shift) { - shift := _WORD_SIZE + shift := WORD_SIZE } let dest := add(ret, shift) @@ -103,8 +102,8 @@ library BytesParsing { for { let src := add(add(encoded, shift), offset) } lt(dest, end) { - src := add(src, _WORD_SIZE) - dest := add(dest, _WORD_SIZE) + src := add(src, WORD_SIZE) + dest := add(dest, WORD_SIZE) } { mstore(dest, mload(src)) } @@ -113,8 +112,8 @@ library BytesParsing { //When compiling with --via-ir then normally allocated memory (i.e. via new) will have 32 byte // memory alignment and so we enforce the same memory alignment here. mstore( - _FREE_MEMORY_PTR, - and(add(dest, _WORD_SIZE_MINUS_ONE), not(_WORD_SIZE_MINUS_ONE)) + FREE_MEMORY_PTR, + and(add(dest, WORD_SIZE_MINUS_ONE), not(WORD_SIZE_MINUS_ONE)) ) } } @@ -179,7 +178,8 @@ const funcs = [ `/// @solidity memory-safe-assembly`, `assembly {`, ` nextOffset := add(offset, ${i+1})`, - ` ret := ${cd ? "calldataload" : "mload"}(add(encoded${cd ? ".offset" :""}, nextOffset))`, + cd ? ` ret := shr(${256-(i+1)*8}, calldataload(add(encoded.offset, offset)))` + : ` ret := mload(add(encoded, nextOffset))`, `}` ], `uint${(i+1)*8}` @@ -189,7 +189,7 @@ const funcs = [ cd => [ `/// @solidity memory-safe-assembly`, `assembly {`, - ` ret := ${cd ? "calldataload" : "mload"}(add(encoded${cd ? ".offset" :""}, add(offset, _WORD_SIZE)))`, + ` ret := ${cd ? "calldataload" : "mload"}(add(encoded${cd ? ".offset" :""}, ${cd ? "offset" : "add(offset, WORD_SIZE)"}))`, ` nextOffset := add(offset, ${i+1})`, `}` ], @@ -217,6 +217,7 @@ function ${name}${cd}( `); } ------------------------------------------------------------------------------------------------- */ + function checkLengthCd( bytes calldata encoded, uint256 expected @@ -438,7 +439,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 1) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(248, calldataload(add(encoded.offset, offset))) } } @@ -476,7 +477,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 2) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(240, calldataload(add(encoded.offset, offset))) } } @@ -514,7 +515,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 3) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(232, calldataload(add(encoded.offset, offset))) } } @@ -552,7 +553,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 4) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(224, calldataload(add(encoded.offset, offset))) } } @@ -590,7 +591,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 5) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(216, calldataload(add(encoded.offset, offset))) } } @@ -628,7 +629,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 6) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(208, calldataload(add(encoded.offset, offset))) } } @@ -666,7 +667,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 7) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(200, calldataload(add(encoded.offset, offset))) } } @@ -704,7 +705,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 8) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(192, calldataload(add(encoded.offset, offset))) } } @@ -742,7 +743,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 9) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(184, calldataload(add(encoded.offset, offset))) } } @@ -780,7 +781,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 10) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(176, calldataload(add(encoded.offset, offset))) } } @@ -818,7 +819,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 11) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(168, calldataload(add(encoded.offset, offset))) } } @@ -856,7 +857,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 12) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(160, calldataload(add(encoded.offset, offset))) } } @@ -894,7 +895,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 13) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(152, calldataload(add(encoded.offset, offset))) } } @@ -932,7 +933,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 14) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(144, calldataload(add(encoded.offset, offset))) } } @@ -970,7 +971,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 15) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(136, calldataload(add(encoded.offset, offset))) } } @@ -1008,7 +1009,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 16) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(128, calldataload(add(encoded.offset, offset))) } } @@ -1046,7 +1047,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 17) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(120, calldataload(add(encoded.offset, offset))) } } @@ -1084,7 +1085,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 18) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(112, calldataload(add(encoded.offset, offset))) } } @@ -1122,7 +1123,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 19) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(104, calldataload(add(encoded.offset, offset))) } } @@ -1160,7 +1161,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 20) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(96, calldataload(add(encoded.offset, offset))) } } @@ -1198,7 +1199,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 21) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(88, calldataload(add(encoded.offset, offset))) } } @@ -1236,7 +1237,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 22) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(80, calldataload(add(encoded.offset, offset))) } } @@ -1274,7 +1275,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 23) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(72, calldataload(add(encoded.offset, offset))) } } @@ -1312,7 +1313,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 24) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(64, calldataload(add(encoded.offset, offset))) } } @@ -1350,7 +1351,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 25) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(56, calldataload(add(encoded.offset, offset))) } } @@ -1388,7 +1389,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 26) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(48, calldataload(add(encoded.offset, offset))) } } @@ -1426,7 +1427,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 27) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(40, calldataload(add(encoded.offset, offset))) } } @@ -1464,7 +1465,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 28) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(32, calldataload(add(encoded.offset, offset))) } } @@ -1502,7 +1503,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 29) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(24, calldataload(add(encoded.offset, offset))) } } @@ -1540,7 +1541,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 30) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(16, calldataload(add(encoded.offset, offset))) } } @@ -1578,7 +1579,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 31) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(8, calldataload(add(encoded.offset, offset))) } } @@ -1616,7 +1617,7 @@ function ${name}${cd}( /// @solidity memory-safe-assembly assembly { nextOffset := add(offset, 32) - ret := calldataload(add(encoded.offset, nextOffset)) + ret := shr(0, calldataload(add(encoded.offset, offset))) } } @@ -1653,7 +1654,7 @@ function ${name}${cd}( ) internal pure returns (bytes1 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 1) } } @@ -1672,7 +1673,7 @@ function ${name}${cd}( ) internal pure returns (bytes1 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 1) } } @@ -1691,7 +1692,7 @@ function ${name}${cd}( ) internal pure returns (bytes2 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 2) } } @@ -1710,7 +1711,7 @@ function ${name}${cd}( ) internal pure returns (bytes2 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 2) } } @@ -1729,7 +1730,7 @@ function ${name}${cd}( ) internal pure returns (bytes3 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 3) } } @@ -1748,7 +1749,7 @@ function ${name}${cd}( ) internal pure returns (bytes3 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 3) } } @@ -1767,7 +1768,7 @@ function ${name}${cd}( ) internal pure returns (bytes4 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 4) } } @@ -1786,7 +1787,7 @@ function ${name}${cd}( ) internal pure returns (bytes4 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 4) } } @@ -1805,7 +1806,7 @@ function ${name}${cd}( ) internal pure returns (bytes5 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 5) } } @@ -1824,7 +1825,7 @@ function ${name}${cd}( ) internal pure returns (bytes5 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 5) } } @@ -1843,7 +1844,7 @@ function ${name}${cd}( ) internal pure returns (bytes6 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 6) } } @@ -1862,7 +1863,7 @@ function ${name}${cd}( ) internal pure returns (bytes6 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 6) } } @@ -1881,7 +1882,7 @@ function ${name}${cd}( ) internal pure returns (bytes7 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 7) } } @@ -1900,7 +1901,7 @@ function ${name}${cd}( ) internal pure returns (bytes7 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 7) } } @@ -1919,7 +1920,7 @@ function ${name}${cd}( ) internal pure returns (bytes8 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 8) } } @@ -1938,7 +1939,7 @@ function ${name}${cd}( ) internal pure returns (bytes8 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 8) } } @@ -1957,7 +1958,7 @@ function ${name}${cd}( ) internal pure returns (bytes9 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 9) } } @@ -1976,7 +1977,7 @@ function ${name}${cd}( ) internal pure returns (bytes9 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 9) } } @@ -1995,7 +1996,7 @@ function ${name}${cd}( ) internal pure returns (bytes10 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 10) } } @@ -2014,7 +2015,7 @@ function ${name}${cd}( ) internal pure returns (bytes10 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 10) } } @@ -2033,7 +2034,7 @@ function ${name}${cd}( ) internal pure returns (bytes11 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 11) } } @@ -2052,7 +2053,7 @@ function ${name}${cd}( ) internal pure returns (bytes11 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 11) } } @@ -2071,7 +2072,7 @@ function ${name}${cd}( ) internal pure returns (bytes12 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 12) } } @@ -2090,7 +2091,7 @@ function ${name}${cd}( ) internal pure returns (bytes12 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 12) } } @@ -2109,7 +2110,7 @@ function ${name}${cd}( ) internal pure returns (bytes13 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 13) } } @@ -2128,7 +2129,7 @@ function ${name}${cd}( ) internal pure returns (bytes13 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 13) } } @@ -2147,7 +2148,7 @@ function ${name}${cd}( ) internal pure returns (bytes14 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 14) } } @@ -2166,7 +2167,7 @@ function ${name}${cd}( ) internal pure returns (bytes14 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 14) } } @@ -2185,7 +2186,7 @@ function ${name}${cd}( ) internal pure returns (bytes15 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 15) } } @@ -2204,7 +2205,7 @@ function ${name}${cd}( ) internal pure returns (bytes15 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 15) } } @@ -2223,7 +2224,7 @@ function ${name}${cd}( ) internal pure returns (bytes16 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 16) } } @@ -2242,7 +2243,7 @@ function ${name}${cd}( ) internal pure returns (bytes16 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 16) } } @@ -2261,7 +2262,7 @@ function ${name}${cd}( ) internal pure returns (bytes17 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 17) } } @@ -2280,7 +2281,7 @@ function ${name}${cd}( ) internal pure returns (bytes17 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 17) } } @@ -2299,7 +2300,7 @@ function ${name}${cd}( ) internal pure returns (bytes18 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 18) } } @@ -2318,7 +2319,7 @@ function ${name}${cd}( ) internal pure returns (bytes18 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 18) } } @@ -2337,7 +2338,7 @@ function ${name}${cd}( ) internal pure returns (bytes19 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 19) } } @@ -2356,7 +2357,7 @@ function ${name}${cd}( ) internal pure returns (bytes19 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 19) } } @@ -2375,7 +2376,7 @@ function ${name}${cd}( ) internal pure returns (bytes20 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 20) } } @@ -2394,7 +2395,7 @@ function ${name}${cd}( ) internal pure returns (bytes20 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 20) } } @@ -2413,7 +2414,7 @@ function ${name}${cd}( ) internal pure returns (bytes21 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 21) } } @@ -2432,7 +2433,7 @@ function ${name}${cd}( ) internal pure returns (bytes21 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 21) } } @@ -2451,7 +2452,7 @@ function ${name}${cd}( ) internal pure returns (bytes22 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 22) } } @@ -2470,7 +2471,7 @@ function ${name}${cd}( ) internal pure returns (bytes22 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 22) } } @@ -2489,7 +2490,7 @@ function ${name}${cd}( ) internal pure returns (bytes23 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 23) } } @@ -2508,7 +2509,7 @@ function ${name}${cd}( ) internal pure returns (bytes23 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 23) } } @@ -2527,7 +2528,7 @@ function ${name}${cd}( ) internal pure returns (bytes24 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 24) } } @@ -2546,7 +2547,7 @@ function ${name}${cd}( ) internal pure returns (bytes24 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 24) } } @@ -2565,7 +2566,7 @@ function ${name}${cd}( ) internal pure returns (bytes25 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 25) } } @@ -2584,7 +2585,7 @@ function ${name}${cd}( ) internal pure returns (bytes25 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 25) } } @@ -2603,7 +2604,7 @@ function ${name}${cd}( ) internal pure returns (bytes26 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 26) } } @@ -2622,7 +2623,7 @@ function ${name}${cd}( ) internal pure returns (bytes26 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 26) } } @@ -2641,7 +2642,7 @@ function ${name}${cd}( ) internal pure returns (bytes27 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 27) } } @@ -2660,7 +2661,7 @@ function ${name}${cd}( ) internal pure returns (bytes27 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 27) } } @@ -2679,7 +2680,7 @@ function ${name}${cd}( ) internal pure returns (bytes28 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 28) } } @@ -2698,7 +2699,7 @@ function ${name}${cd}( ) internal pure returns (bytes28 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 28) } } @@ -2717,7 +2718,7 @@ function ${name}${cd}( ) internal pure returns (bytes29 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 29) } } @@ -2736,7 +2737,7 @@ function ${name}${cd}( ) internal pure returns (bytes29 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 29) } } @@ -2755,7 +2756,7 @@ function ${name}${cd}( ) internal pure returns (bytes30 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 30) } } @@ -2774,7 +2775,7 @@ function ${name}${cd}( ) internal pure returns (bytes30 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 30) } } @@ -2793,7 +2794,7 @@ function ${name}${cd}( ) internal pure returns (bytes31 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 31) } } @@ -2812,7 +2813,7 @@ function ${name}${cd}( ) internal pure returns (bytes31 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 31) } } @@ -2831,7 +2832,7 @@ function ${name}${cd}( ) internal pure returns (bytes32 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := calldataload(add(encoded.offset, add(offset, _WORD_SIZE))) + ret := calldataload(add(encoded.offset, offset)) nextOffset := add(offset, 32) } } @@ -2850,7 +2851,7 @@ function ${name}${cd}( ) internal pure returns (bytes32 ret, uint nextOffset) { /// @solidity memory-safe-assembly assembly { - ret := mload(add(encoded, add(offset, _WORD_SIZE))) + ret := mload(add(encoded, add(offset, WORD_SIZE))) nextOffset := add(offset, 32) } } diff --git a/test/BytesParsing.t.sol b/test/BytesParsing.t.sol index ee1cb3e..e23fa63 100644 --- a/test/BytesParsing.t.sol +++ b/test/BytesParsing.t.sol @@ -4,11 +4,203 @@ pragma solidity ^0.8.24; import "forge-std/Test.sol"; +import "wormhole-sdk/constants/Common.sol"; import { BytesParsing } from "wormhole-sdk/libraries/BytesParsing.sol"; +import { BytesParsingTestWrapper } from "./generated/BytesParsingTestWrapper.sol"; contract TestBytesParsing is Test { using BytesParsing for bytes; - function testBytesParsing() public { + BytesParsingTestWrapper wrapper; + + mapping (uint => string) strVal; + + function uintToString(uint value) private pure returns (string memory) { + if (value == 0) + return "0"; + + uint digits; + for (uint temp = value; temp != 0; temp /= 10) + ++digits; + + bytes memory buffer = new bytes(digits); + while (value != 0) { + --digits; + buffer[digits] = bytes1(uint8(48 + (value % 10))); // 48 is the ASCII code for '0' + value /= 10; + } + + return string(buffer); + } + + function setUp() public { unchecked { + wrapper = new BytesParsingTestWrapper(); + for (uint i = 1; i < WORD_SIZE_PLUS_ONE; ++i) { + strVal[i] = uintToString(i); + strVal[8*i] = uintToString(8*i); + } + }} + + function toFunctionSignature( + string memory first, + bool cd, + bool checked, + string memory second + ) private pure returns (string memory) { + return string(abi.encodePacked(first, cd ? "Cd" : "", checked ? "" : "Unchecked", second)); + } + + function encodedOutOfBounds( + uint expectedNewOffset, + uint dataLength + ) private pure returns (bytes memory) { + return abi.encodeWithSelector(BytesParsing.OutOfBounds.selector, expectedNewOffset, dataLength); + } + + /// forge-config: default.fuzz.runs = 20000 + function testFuzzUintAndBytesParsing( + bytes calldata data, + uint size, + uint offset, + bool uintOrBytes, + bool cd, + bool checked + ) public { unchecked { + size = bound(size, 1, WORD_SIZE); + offset = bound(offset, 0, data.length); + uint expectedNewOffset = offset + size; + string memory funcSig = toFunctionSignature( + string(abi.encodePacked( + uintOrBytes ? "asUint" : "asBytes", + strVal[(uintOrBytes ? 8 : 1) * size] + )), + cd, + checked, + "(bytes,uint256)" + ); + (bool success, bytes memory encodedResult) = + address(wrapper).call(abi.encodeWithSignature(funcSig, data, offset)); + + assertEq(success, !checked || expectedNewOffset <= data.length, "call success mismatch"); + if (success) { + (uint result, uint newOffset) = abi.decode(encodedResult, (uint, uint)); + assertEq(newOffset, expectedNewOffset, "wrong offset"); + + if (newOffset > data.length) + return; + + uint expected; + for (uint i = 0; i < size; ++i) + expected |= uint(uint8(data[offset + i])) << 8*(size-1-i); + + if (!uintOrBytes) + expected <<= 8*(WORD_SIZE-size); + + assertEq(result, expected, "wrong result"); + + } + else + assertEq(encodedResult, encodedOutOfBounds(expectedNewOffset, data.length), "wrong error"); + }} + + uint constant BASEWORD = 0x0101010101010101010101010101010101010101010101010101010101010101; + + function largeBytes() private pure returns (bytes memory data) { + data = new bytes(256 * WORD_SIZE); + for (uint i = 1; i < 256; ++i) + assembly ("memory-safe") { mstore(add(data, mul(add(i,1),WORD_SIZE)), mul(i, BASEWORD)) } + } + + /// forge-config: default.fuzz.runs = 20 + function testFuzzLargeBytes(uint word, uint shift) public { + bytes memory data = largeBytes(); + assertEq(data.length, 256*WORD_SIZE, "wrong size"); + word = bound(word, 0, WORD_SIZE_MINUS_ONE); + shift = bound(word, 0, WORD_SIZE_MINUS_ONE); + (uint result, ) = data.asUint256Unchecked(word*WORD_SIZE + shift); + assertEq(result, (word*BASEWORD << 8*shift) + ((word+1)*BASEWORD >> 8*(WORD_SIZE-shift))); + } + + /// forge-config: default.fuzz.runs = 1000 + function testfuzzSlice(uint offset, uint size, bool cd, bool checked) public { + bytes memory data = largeBytes(); + offset = bound(offset, 0, data.length); + //we increase the upper bound of size by 25 % beyond what can be correctly read + // hence resulting in an out of bounds error 20% of the time + size = bound(size, 0, (data.length - offset) * 5/4); + uint expectedNewOffset = offset + size; + + string memory funcSig = toFunctionSignature("slice", cd, checked, "(bytes,uint256,uint256)"); + (bool success, bytes memory encodedResult) = + address(wrapper).call(abi.encodeWithSignature(funcSig, data, offset, size)); + + assertEq(success, !checked || expectedNewOffset <= data.length, "call success mismatch"); + if (success) { + (bytes memory slice, uint newOffset) = abi.decode(encodedResult, (bytes, uint)); + assertEq(slice.length, size, "wrong slice size"); + assertEq(newOffset, expectedNewOffset, "wrong offset"); + uint upperValid = data.length - offset; + if (upperValid > size) + upperValid = size; + for (uint i = 0; i < upperValid; ++i) { + (uint lhs, ) = data.asUint8Unchecked(offset+i); + (uint rhs, ) = slice.asUint8Unchecked(i); + assertEq(lhs, rhs, "wrong slice byte"); + if (lhs != rhs) + return; + } + } + else + assertEq(encodedResult, encodedOutOfBounds(expectedNewOffset, data.length), "wrong error"); + } + + function testFuzzPrefixedSlice( + uint offset, + uint size, + uint prefixSize, + bool cd, + bool checked + ) public { + bytes memory data = largeBytes(); + prefixSize = 2**bound(prefixSize, 0, 2); //=1, 2, 4 + offset = bound(offset, 0, data.length-prefixSize); + //we increase the upper bound of size by 25 % beyond what can be correctly read + // hence resulting in an out of bounds error 20% of the time + size = bound(size, 0, (data.length - offset) * 5/4); + size = bound(size, 0, 2**(8*prefixSize)-1); + uint expectedNewOffset = offset + prefixSize + size; + for (uint i = 0; i < prefixSize; ++i) + data[offset+i] = bytes1(uint8(size >> 8*(prefixSize-1-i))); + + string memory funcSig = toFunctionSignature( + string(abi.encodePacked("sliceUint", strVal[8*prefixSize], "Prefixed")), + cd, + checked, + "(bytes,uint256)" + ); + (bool success, bytes memory encodedResult) = + address(wrapper).call(abi.encodeWithSignature(funcSig, data, offset)); + + assertEq(success, !checked || expectedNewOffset <= data.length, "call success mismatch"); + if (success) { + (bytes memory slice, uint newOffset) = abi.decode(encodedResult, (bytes, uint)); + assertEq(slice.length, size, "wrong slice size"); + assertEq(newOffset, expectedNewOffset, "wrong offset"); + if (data.length < (offset + prefixSize)) + return; + + uint upperValid = data.length - (offset + prefixSize); + if (upperValid > size) + upperValid = size; + for (uint i = 0; i < upperValid; ++i) { + (uint lhs, ) = data.asUint8Unchecked(offset+prefixSize+i); + (uint rhs, ) = slice.asUint8Unchecked(i); + assertEq(lhs, rhs, "wrong slice byte"); + if (lhs != rhs) + return; + } + } + else + assertEq(encodedResult, encodedOutOfBounds(expectedNewOffset, data.length), "wrong error"); } } \ No newline at end of file diff --git a/test/generated/BytesParsingTestWrapper.sol b/test/generated/BytesParsingTestWrapper.sol index b0fb65d..177bfad 100644 --- a/test/generated/BytesParsingTestWrapper.sol +++ b/test/generated/BytesParsingTestWrapper.sol @@ -1,17 +1,21 @@ // SPDX-License-Identifier: Apache 2 pragma solidity ^0.8.24; -//This file was auto-generated by libraryTestWrapper.ts - import "wormhole-sdk/libraries/BytesParsing.sol"; +// This file was auto-generated by wormhole-solidity-sdk gen/libraryTestWrapper.ts + contract BytesParsingTestWrapper { function checkBound(uint offset, uint length) external pure { BytesParsing.checkBound(offset, length); } - function checkLength(bytes calldata encoded, uint256 expected) external pure { - BytesParsing.checkLength(encoded, expected); + function sliceCdUnchecked( + bytes calldata encoded, + uint offset, + uint length + ) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceCdUnchecked(encoded, offset, length); } function sliceUnchecked( @@ -22,24 +26,20 @@ contract BytesParsingTestWrapper { return BytesParsing.sliceUnchecked(encoded, offset, length); } - function sliceUint8PrefixedUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes memory, uint) { - return BytesParsing.sliceUint8PrefixedUnchecked(encoded, offset); - } - - function sliceUint16PrefixedUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes memory, uint) { - return BytesParsing.sliceUint16PrefixedUnchecked(encoded, offset); + function checkLengthCd(bytes calldata encoded, uint256 expected) external pure { + BytesParsing.checkLengthCd(encoded, expected); } - function sliceUint32PrefixedUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes memory, uint) { - return BytesParsing.sliceUint32PrefixedUnchecked(encoded, offset); - } - - function asAddressUnchecked(bytes calldata encoded, uint offset) external pure returns (address, uint) { - return BytesParsing.asAddressUnchecked(encoded, offset); + function sliceCd( + bytes calldata encoded, + uint offset, + uint length + ) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceCd(encoded, offset, length); } - function asBoolUnchecked(bytes calldata encoded, uint offset) external pure returns (bool, uint) { - return BytesParsing.asBoolUnchecked(encoded, offset); + function checkLength(bytes calldata encoded, uint256 expected) external pure { + BytesParsing.checkLength(encoded, expected); } function slice( @@ -50,26 +50,94 @@ contract BytesParsingTestWrapper { return BytesParsing.slice(encoded, offset, length); } + function sliceUint8PrefixedCdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceUint8PrefixedCdUnchecked(encoded, offset); + } + + function sliceUint8PrefixedCd(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceUint8PrefixedCd(encoded, offset); + } + + function sliceUint8PrefixedUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceUint8PrefixedUnchecked(encoded, offset); + } + function sliceUint8Prefixed(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { return BytesParsing.sliceUint8Prefixed(encoded, offset); } + function sliceUint16PrefixedCdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceUint16PrefixedCdUnchecked(encoded, offset); + } + + function sliceUint16PrefixedCd(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceUint16PrefixedCd(encoded, offset); + } + + function sliceUint16PrefixedUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceUint16PrefixedUnchecked(encoded, offset); + } + function sliceUint16Prefixed(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { return BytesParsing.sliceUint16Prefixed(encoded, offset); } + function sliceUint32PrefixedCdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceUint32PrefixedCdUnchecked(encoded, offset); + } + + function sliceUint32PrefixedCd(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceUint32PrefixedCd(encoded, offset); + } + + function sliceUint32PrefixedUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { + return BytesParsing.sliceUint32PrefixedUnchecked(encoded, offset); + } + function sliceUint32Prefixed(bytes calldata encoded, uint offset) external pure returns (bytes memory ret, uint nextOffset) { return BytesParsing.sliceUint32Prefixed(encoded, offset); } + function asAddressCdUnchecked(bytes calldata encoded, uint offset) external pure returns (address ret, uint nextOffset) { + return BytesParsing.asAddressCdUnchecked(encoded, offset); + } + + function asAddressCd(bytes calldata encoded, uint offset) external pure returns (address ret, uint nextOffset) { + return BytesParsing.asAddressCd(encoded, offset); + } + + function asAddressUnchecked(bytes calldata encoded, uint offset) external pure returns (address ret, uint nextOffset) { + return BytesParsing.asAddressUnchecked(encoded, offset); + } + function asAddress(bytes calldata encoded, uint offset) external pure returns (address ret, uint nextOffset) { return BytesParsing.asAddress(encoded, offset); } + function asBoolCdUnchecked(bytes calldata encoded, uint offset) external pure returns (bool ret, uint nextOffset) { + return BytesParsing.asBoolCdUnchecked(encoded, offset); + } + + function asBoolCd(bytes calldata encoded, uint offset) external pure returns (bool ret, uint nextOffset) { + return BytesParsing.asBoolCd(encoded, offset); + } + + function asBoolUnchecked(bytes calldata encoded, uint offset) external pure returns (bool ret, uint nextOffset) { + return BytesParsing.asBoolUnchecked(encoded, offset); + } + function asBool(bytes calldata encoded, uint offset) external pure returns (bool ret, uint nextOffset) { return BytesParsing.asBool(encoded, offset); } + function asUint8CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint8 ret, uint nextOffset) { + return BytesParsing.asUint8CdUnchecked(encoded, offset); + } + + function asUint8Cd(bytes calldata encoded, uint offset) external pure returns (uint8 ret, uint nextOffset) { + return BytesParsing.asUint8Cd(encoded, offset); + } + function asUint8Unchecked(bytes calldata encoded, uint offset) external pure returns (uint8 ret, uint nextOffset) { return BytesParsing.asUint8Unchecked(encoded, offset); } @@ -78,12 +146,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint8(encoded, offset); } - function asBytes1Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes1 ret, uint nextOffset) { - return BytesParsing.asBytes1Unchecked(encoded, offset); + function asUint16CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint16 ret, uint nextOffset) { + return BytesParsing.asUint16CdUnchecked(encoded, offset); } - function asBytes1(bytes calldata encoded, uint offset) external pure returns (bytes1 ret, uint nextOffset) { - return BytesParsing.asBytes1(encoded, offset); + function asUint16Cd(bytes calldata encoded, uint offset) external pure returns (uint16 ret, uint nextOffset) { + return BytesParsing.asUint16Cd(encoded, offset); } function asUint16Unchecked(bytes calldata encoded, uint offset) external pure returns (uint16 ret, uint nextOffset) { @@ -94,12 +162,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint16(encoded, offset); } - function asBytes2Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes2 ret, uint nextOffset) { - return BytesParsing.asBytes2Unchecked(encoded, offset); + function asUint24CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint24 ret, uint nextOffset) { + return BytesParsing.asUint24CdUnchecked(encoded, offset); } - function asBytes2(bytes calldata encoded, uint offset) external pure returns (bytes2 ret, uint nextOffset) { - return BytesParsing.asBytes2(encoded, offset); + function asUint24Cd(bytes calldata encoded, uint offset) external pure returns (uint24 ret, uint nextOffset) { + return BytesParsing.asUint24Cd(encoded, offset); } function asUint24Unchecked(bytes calldata encoded, uint offset) external pure returns (uint24 ret, uint nextOffset) { @@ -110,12 +178,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint24(encoded, offset); } - function asBytes3Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes3 ret, uint nextOffset) { - return BytesParsing.asBytes3Unchecked(encoded, offset); + function asUint32CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint32 ret, uint nextOffset) { + return BytesParsing.asUint32CdUnchecked(encoded, offset); } - function asBytes3(bytes calldata encoded, uint offset) external pure returns (bytes3 ret, uint nextOffset) { - return BytesParsing.asBytes3(encoded, offset); + function asUint32Cd(bytes calldata encoded, uint offset) external pure returns (uint32 ret, uint nextOffset) { + return BytesParsing.asUint32Cd(encoded, offset); } function asUint32Unchecked(bytes calldata encoded, uint offset) external pure returns (uint32 ret, uint nextOffset) { @@ -126,12 +194,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint32(encoded, offset); } - function asBytes4Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes4 ret, uint nextOffset) { - return BytesParsing.asBytes4Unchecked(encoded, offset); + function asUint40CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint40 ret, uint nextOffset) { + return BytesParsing.asUint40CdUnchecked(encoded, offset); } - function asBytes4(bytes calldata encoded, uint offset) external pure returns (bytes4 ret, uint nextOffset) { - return BytesParsing.asBytes4(encoded, offset); + function asUint40Cd(bytes calldata encoded, uint offset) external pure returns (uint40 ret, uint nextOffset) { + return BytesParsing.asUint40Cd(encoded, offset); } function asUint40Unchecked(bytes calldata encoded, uint offset) external pure returns (uint40 ret, uint nextOffset) { @@ -142,12 +210,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint40(encoded, offset); } - function asBytes5Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes5 ret, uint nextOffset) { - return BytesParsing.asBytes5Unchecked(encoded, offset); + function asUint48CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint48 ret, uint nextOffset) { + return BytesParsing.asUint48CdUnchecked(encoded, offset); } - function asBytes5(bytes calldata encoded, uint offset) external pure returns (bytes5 ret, uint nextOffset) { - return BytesParsing.asBytes5(encoded, offset); + function asUint48Cd(bytes calldata encoded, uint offset) external pure returns (uint48 ret, uint nextOffset) { + return BytesParsing.asUint48Cd(encoded, offset); } function asUint48Unchecked(bytes calldata encoded, uint offset) external pure returns (uint48 ret, uint nextOffset) { @@ -158,12 +226,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint48(encoded, offset); } - function asBytes6Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes6 ret, uint nextOffset) { - return BytesParsing.asBytes6Unchecked(encoded, offset); + function asUint56CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint56 ret, uint nextOffset) { + return BytesParsing.asUint56CdUnchecked(encoded, offset); } - function asBytes6(bytes calldata encoded, uint offset) external pure returns (bytes6 ret, uint nextOffset) { - return BytesParsing.asBytes6(encoded, offset); + function asUint56Cd(bytes calldata encoded, uint offset) external pure returns (uint56 ret, uint nextOffset) { + return BytesParsing.asUint56Cd(encoded, offset); } function asUint56Unchecked(bytes calldata encoded, uint offset) external pure returns (uint56 ret, uint nextOffset) { @@ -174,12 +242,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint56(encoded, offset); } - function asBytes7Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes7 ret, uint nextOffset) { - return BytesParsing.asBytes7Unchecked(encoded, offset); + function asUint64CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint64 ret, uint nextOffset) { + return BytesParsing.asUint64CdUnchecked(encoded, offset); } - function asBytes7(bytes calldata encoded, uint offset) external pure returns (bytes7 ret, uint nextOffset) { - return BytesParsing.asBytes7(encoded, offset); + function asUint64Cd(bytes calldata encoded, uint offset) external pure returns (uint64 ret, uint nextOffset) { + return BytesParsing.asUint64Cd(encoded, offset); } function asUint64Unchecked(bytes calldata encoded, uint offset) external pure returns (uint64 ret, uint nextOffset) { @@ -190,12 +258,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint64(encoded, offset); } - function asBytes8Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes8 ret, uint nextOffset) { - return BytesParsing.asBytes8Unchecked(encoded, offset); + function asUint72CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint72 ret, uint nextOffset) { + return BytesParsing.asUint72CdUnchecked(encoded, offset); } - function asBytes8(bytes calldata encoded, uint offset) external pure returns (bytes8 ret, uint nextOffset) { - return BytesParsing.asBytes8(encoded, offset); + function asUint72Cd(bytes calldata encoded, uint offset) external pure returns (uint72 ret, uint nextOffset) { + return BytesParsing.asUint72Cd(encoded, offset); } function asUint72Unchecked(bytes calldata encoded, uint offset) external pure returns (uint72 ret, uint nextOffset) { @@ -206,12 +274,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint72(encoded, offset); } - function asBytes9Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes9 ret, uint nextOffset) { - return BytesParsing.asBytes9Unchecked(encoded, offset); + function asUint80CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint80 ret, uint nextOffset) { + return BytesParsing.asUint80CdUnchecked(encoded, offset); } - function asBytes9(bytes calldata encoded, uint offset) external pure returns (bytes9 ret, uint nextOffset) { - return BytesParsing.asBytes9(encoded, offset); + function asUint80Cd(bytes calldata encoded, uint offset) external pure returns (uint80 ret, uint nextOffset) { + return BytesParsing.asUint80Cd(encoded, offset); } function asUint80Unchecked(bytes calldata encoded, uint offset) external pure returns (uint80 ret, uint nextOffset) { @@ -222,12 +290,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint80(encoded, offset); } - function asBytes10Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes10 ret, uint nextOffset) { - return BytesParsing.asBytes10Unchecked(encoded, offset); + function asUint88CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint88 ret, uint nextOffset) { + return BytesParsing.asUint88CdUnchecked(encoded, offset); } - function asBytes10(bytes calldata encoded, uint offset) external pure returns (bytes10 ret, uint nextOffset) { - return BytesParsing.asBytes10(encoded, offset); + function asUint88Cd(bytes calldata encoded, uint offset) external pure returns (uint88 ret, uint nextOffset) { + return BytesParsing.asUint88Cd(encoded, offset); } function asUint88Unchecked(bytes calldata encoded, uint offset) external pure returns (uint88 ret, uint nextOffset) { @@ -238,12 +306,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint88(encoded, offset); } - function asBytes11Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes11 ret, uint nextOffset) { - return BytesParsing.asBytes11Unchecked(encoded, offset); + function asUint96CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint96 ret, uint nextOffset) { + return BytesParsing.asUint96CdUnchecked(encoded, offset); } - function asBytes11(bytes calldata encoded, uint offset) external pure returns (bytes11 ret, uint nextOffset) { - return BytesParsing.asBytes11(encoded, offset); + function asUint96Cd(bytes calldata encoded, uint offset) external pure returns (uint96 ret, uint nextOffset) { + return BytesParsing.asUint96Cd(encoded, offset); } function asUint96Unchecked(bytes calldata encoded, uint offset) external pure returns (uint96 ret, uint nextOffset) { @@ -254,12 +322,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint96(encoded, offset); } - function asBytes12Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes12 ret, uint nextOffset) { - return BytesParsing.asBytes12Unchecked(encoded, offset); + function asUint104CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint104 ret, uint nextOffset) { + return BytesParsing.asUint104CdUnchecked(encoded, offset); } - function asBytes12(bytes calldata encoded, uint offset) external pure returns (bytes12 ret, uint nextOffset) { - return BytesParsing.asBytes12(encoded, offset); + function asUint104Cd(bytes calldata encoded, uint offset) external pure returns (uint104 ret, uint nextOffset) { + return BytesParsing.asUint104Cd(encoded, offset); } function asUint104Unchecked(bytes calldata encoded, uint offset) external pure returns (uint104 ret, uint nextOffset) { @@ -270,12 +338,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint104(encoded, offset); } - function asBytes13Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes13 ret, uint nextOffset) { - return BytesParsing.asBytes13Unchecked(encoded, offset); + function asUint112CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint112 ret, uint nextOffset) { + return BytesParsing.asUint112CdUnchecked(encoded, offset); } - function asBytes13(bytes calldata encoded, uint offset) external pure returns (bytes13 ret, uint nextOffset) { - return BytesParsing.asBytes13(encoded, offset); + function asUint112Cd(bytes calldata encoded, uint offset) external pure returns (uint112 ret, uint nextOffset) { + return BytesParsing.asUint112Cd(encoded, offset); } function asUint112Unchecked(bytes calldata encoded, uint offset) external pure returns (uint112 ret, uint nextOffset) { @@ -286,12 +354,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint112(encoded, offset); } - function asBytes14Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes14 ret, uint nextOffset) { - return BytesParsing.asBytes14Unchecked(encoded, offset); + function asUint120CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint120 ret, uint nextOffset) { + return BytesParsing.asUint120CdUnchecked(encoded, offset); } - function asBytes14(bytes calldata encoded, uint offset) external pure returns (bytes14 ret, uint nextOffset) { - return BytesParsing.asBytes14(encoded, offset); + function asUint120Cd(bytes calldata encoded, uint offset) external pure returns (uint120 ret, uint nextOffset) { + return BytesParsing.asUint120Cd(encoded, offset); } function asUint120Unchecked(bytes calldata encoded, uint offset) external pure returns (uint120 ret, uint nextOffset) { @@ -302,12 +370,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint120(encoded, offset); } - function asBytes15Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes15 ret, uint nextOffset) { - return BytesParsing.asBytes15Unchecked(encoded, offset); + function asUint128CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint128 ret, uint nextOffset) { + return BytesParsing.asUint128CdUnchecked(encoded, offset); } - function asBytes15(bytes calldata encoded, uint offset) external pure returns (bytes15 ret, uint nextOffset) { - return BytesParsing.asBytes15(encoded, offset); + function asUint128Cd(bytes calldata encoded, uint offset) external pure returns (uint128 ret, uint nextOffset) { + return BytesParsing.asUint128Cd(encoded, offset); } function asUint128Unchecked(bytes calldata encoded, uint offset) external pure returns (uint128 ret, uint nextOffset) { @@ -318,12 +386,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint128(encoded, offset); } - function asBytes16Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes16 ret, uint nextOffset) { - return BytesParsing.asBytes16Unchecked(encoded, offset); + function asUint136CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint136 ret, uint nextOffset) { + return BytesParsing.asUint136CdUnchecked(encoded, offset); } - function asBytes16(bytes calldata encoded, uint offset) external pure returns (bytes16 ret, uint nextOffset) { - return BytesParsing.asBytes16(encoded, offset); + function asUint136Cd(bytes calldata encoded, uint offset) external pure returns (uint136 ret, uint nextOffset) { + return BytesParsing.asUint136Cd(encoded, offset); } function asUint136Unchecked(bytes calldata encoded, uint offset) external pure returns (uint136 ret, uint nextOffset) { @@ -334,12 +402,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint136(encoded, offset); } - function asBytes17Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes17 ret, uint nextOffset) { - return BytesParsing.asBytes17Unchecked(encoded, offset); + function asUint144CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint144 ret, uint nextOffset) { + return BytesParsing.asUint144CdUnchecked(encoded, offset); } - function asBytes17(bytes calldata encoded, uint offset) external pure returns (bytes17 ret, uint nextOffset) { - return BytesParsing.asBytes17(encoded, offset); + function asUint144Cd(bytes calldata encoded, uint offset) external pure returns (uint144 ret, uint nextOffset) { + return BytesParsing.asUint144Cd(encoded, offset); } function asUint144Unchecked(bytes calldata encoded, uint offset) external pure returns (uint144 ret, uint nextOffset) { @@ -350,12 +418,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint144(encoded, offset); } - function asBytes18Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes18 ret, uint nextOffset) { - return BytesParsing.asBytes18Unchecked(encoded, offset); + function asUint152CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint152 ret, uint nextOffset) { + return BytesParsing.asUint152CdUnchecked(encoded, offset); } - function asBytes18(bytes calldata encoded, uint offset) external pure returns (bytes18 ret, uint nextOffset) { - return BytesParsing.asBytes18(encoded, offset); + function asUint152Cd(bytes calldata encoded, uint offset) external pure returns (uint152 ret, uint nextOffset) { + return BytesParsing.asUint152Cd(encoded, offset); } function asUint152Unchecked(bytes calldata encoded, uint offset) external pure returns (uint152 ret, uint nextOffset) { @@ -366,12 +434,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint152(encoded, offset); } - function asBytes19Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes19 ret, uint nextOffset) { - return BytesParsing.asBytes19Unchecked(encoded, offset); + function asUint160CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint160 ret, uint nextOffset) { + return BytesParsing.asUint160CdUnchecked(encoded, offset); } - function asBytes19(bytes calldata encoded, uint offset) external pure returns (bytes19 ret, uint nextOffset) { - return BytesParsing.asBytes19(encoded, offset); + function asUint160Cd(bytes calldata encoded, uint offset) external pure returns (uint160 ret, uint nextOffset) { + return BytesParsing.asUint160Cd(encoded, offset); } function asUint160Unchecked(bytes calldata encoded, uint offset) external pure returns (uint160 ret, uint nextOffset) { @@ -382,12 +450,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint160(encoded, offset); } - function asBytes20Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes20 ret, uint nextOffset) { - return BytesParsing.asBytes20Unchecked(encoded, offset); + function asUint168CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint168 ret, uint nextOffset) { + return BytesParsing.asUint168CdUnchecked(encoded, offset); } - function asBytes20(bytes calldata encoded, uint offset) external pure returns (bytes20 ret, uint nextOffset) { - return BytesParsing.asBytes20(encoded, offset); + function asUint168Cd(bytes calldata encoded, uint offset) external pure returns (uint168 ret, uint nextOffset) { + return BytesParsing.asUint168Cd(encoded, offset); } function asUint168Unchecked(bytes calldata encoded, uint offset) external pure returns (uint168 ret, uint nextOffset) { @@ -398,12 +466,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint168(encoded, offset); } - function asBytes21Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes21 ret, uint nextOffset) { - return BytesParsing.asBytes21Unchecked(encoded, offset); + function asUint176CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint176 ret, uint nextOffset) { + return BytesParsing.asUint176CdUnchecked(encoded, offset); } - function asBytes21(bytes calldata encoded, uint offset) external pure returns (bytes21 ret, uint nextOffset) { - return BytesParsing.asBytes21(encoded, offset); + function asUint176Cd(bytes calldata encoded, uint offset) external pure returns (uint176 ret, uint nextOffset) { + return BytesParsing.asUint176Cd(encoded, offset); } function asUint176Unchecked(bytes calldata encoded, uint offset) external pure returns (uint176 ret, uint nextOffset) { @@ -414,12 +482,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint176(encoded, offset); } - function asBytes22Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes22 ret, uint nextOffset) { - return BytesParsing.asBytes22Unchecked(encoded, offset); + function asUint184CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint184 ret, uint nextOffset) { + return BytesParsing.asUint184CdUnchecked(encoded, offset); } - function asBytes22(bytes calldata encoded, uint offset) external pure returns (bytes22 ret, uint nextOffset) { - return BytesParsing.asBytes22(encoded, offset); + function asUint184Cd(bytes calldata encoded, uint offset) external pure returns (uint184 ret, uint nextOffset) { + return BytesParsing.asUint184Cd(encoded, offset); } function asUint184Unchecked(bytes calldata encoded, uint offset) external pure returns (uint184 ret, uint nextOffset) { @@ -430,12 +498,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint184(encoded, offset); } - function asBytes23Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes23 ret, uint nextOffset) { - return BytesParsing.asBytes23Unchecked(encoded, offset); + function asUint192CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint192 ret, uint nextOffset) { + return BytesParsing.asUint192CdUnchecked(encoded, offset); } - function asBytes23(bytes calldata encoded, uint offset) external pure returns (bytes23 ret, uint nextOffset) { - return BytesParsing.asBytes23(encoded, offset); + function asUint192Cd(bytes calldata encoded, uint offset) external pure returns (uint192 ret, uint nextOffset) { + return BytesParsing.asUint192Cd(encoded, offset); } function asUint192Unchecked(bytes calldata encoded, uint offset) external pure returns (uint192 ret, uint nextOffset) { @@ -446,12 +514,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint192(encoded, offset); } - function asBytes24Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes24 ret, uint nextOffset) { - return BytesParsing.asBytes24Unchecked(encoded, offset); + function asUint200CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint200 ret, uint nextOffset) { + return BytesParsing.asUint200CdUnchecked(encoded, offset); } - function asBytes24(bytes calldata encoded, uint offset) external pure returns (bytes24 ret, uint nextOffset) { - return BytesParsing.asBytes24(encoded, offset); + function asUint200Cd(bytes calldata encoded, uint offset) external pure returns (uint200 ret, uint nextOffset) { + return BytesParsing.asUint200Cd(encoded, offset); } function asUint200Unchecked(bytes calldata encoded, uint offset) external pure returns (uint200 ret, uint nextOffset) { @@ -462,12 +530,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint200(encoded, offset); } - function asBytes25Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes25 ret, uint nextOffset) { - return BytesParsing.asBytes25Unchecked(encoded, offset); + function asUint208CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint208 ret, uint nextOffset) { + return BytesParsing.asUint208CdUnchecked(encoded, offset); } - function asBytes25(bytes calldata encoded, uint offset) external pure returns (bytes25 ret, uint nextOffset) { - return BytesParsing.asBytes25(encoded, offset); + function asUint208Cd(bytes calldata encoded, uint offset) external pure returns (uint208 ret, uint nextOffset) { + return BytesParsing.asUint208Cd(encoded, offset); } function asUint208Unchecked(bytes calldata encoded, uint offset) external pure returns (uint208 ret, uint nextOffset) { @@ -478,12 +546,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint208(encoded, offset); } - function asBytes26Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes26 ret, uint nextOffset) { - return BytesParsing.asBytes26Unchecked(encoded, offset); + function asUint216CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint216 ret, uint nextOffset) { + return BytesParsing.asUint216CdUnchecked(encoded, offset); } - function asBytes26(bytes calldata encoded, uint offset) external pure returns (bytes26 ret, uint nextOffset) { - return BytesParsing.asBytes26(encoded, offset); + function asUint216Cd(bytes calldata encoded, uint offset) external pure returns (uint216 ret, uint nextOffset) { + return BytesParsing.asUint216Cd(encoded, offset); } function asUint216Unchecked(bytes calldata encoded, uint offset) external pure returns (uint216 ret, uint nextOffset) { @@ -494,12 +562,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint216(encoded, offset); } - function asBytes27Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes27 ret, uint nextOffset) { - return BytesParsing.asBytes27Unchecked(encoded, offset); + function asUint224CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint224 ret, uint nextOffset) { + return BytesParsing.asUint224CdUnchecked(encoded, offset); } - function asBytes27(bytes calldata encoded, uint offset) external pure returns (bytes27 ret, uint nextOffset) { - return BytesParsing.asBytes27(encoded, offset); + function asUint224Cd(bytes calldata encoded, uint offset) external pure returns (uint224 ret, uint nextOffset) { + return BytesParsing.asUint224Cd(encoded, offset); } function asUint224Unchecked(bytes calldata encoded, uint offset) external pure returns (uint224 ret, uint nextOffset) { @@ -510,12 +578,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint224(encoded, offset); } - function asBytes28Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes28 ret, uint nextOffset) { - return BytesParsing.asBytes28Unchecked(encoded, offset); + function asUint232CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint232 ret, uint nextOffset) { + return BytesParsing.asUint232CdUnchecked(encoded, offset); } - function asBytes28(bytes calldata encoded, uint offset) external pure returns (bytes28 ret, uint nextOffset) { - return BytesParsing.asBytes28(encoded, offset); + function asUint232Cd(bytes calldata encoded, uint offset) external pure returns (uint232 ret, uint nextOffset) { + return BytesParsing.asUint232Cd(encoded, offset); } function asUint232Unchecked(bytes calldata encoded, uint offset) external pure returns (uint232 ret, uint nextOffset) { @@ -526,12 +594,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint232(encoded, offset); } - function asBytes29Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes29 ret, uint nextOffset) { - return BytesParsing.asBytes29Unchecked(encoded, offset); + function asUint240CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint240 ret, uint nextOffset) { + return BytesParsing.asUint240CdUnchecked(encoded, offset); } - function asBytes29(bytes calldata encoded, uint offset) external pure returns (bytes29 ret, uint nextOffset) { - return BytesParsing.asBytes29(encoded, offset); + function asUint240Cd(bytes calldata encoded, uint offset) external pure returns (uint240 ret, uint nextOffset) { + return BytesParsing.asUint240Cd(encoded, offset); } function asUint240Unchecked(bytes calldata encoded, uint offset) external pure returns (uint240 ret, uint nextOffset) { @@ -542,12 +610,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint240(encoded, offset); } - function asBytes30Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes30 ret, uint nextOffset) { - return BytesParsing.asBytes30Unchecked(encoded, offset); + function asUint248CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint248 ret, uint nextOffset) { + return BytesParsing.asUint248CdUnchecked(encoded, offset); } - function asBytes30(bytes calldata encoded, uint offset) external pure returns (bytes30 ret, uint nextOffset) { - return BytesParsing.asBytes30(encoded, offset); + function asUint248Cd(bytes calldata encoded, uint offset) external pure returns (uint248 ret, uint nextOffset) { + return BytesParsing.asUint248Cd(encoded, offset); } function asUint248Unchecked(bytes calldata encoded, uint offset) external pure returns (uint248 ret, uint nextOffset) { @@ -558,12 +626,12 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint248(encoded, offset); } - function asBytes31Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes31 ret, uint nextOffset) { - return BytesParsing.asBytes31Unchecked(encoded, offset); + function asUint256CdUnchecked(bytes calldata encoded, uint offset) external pure returns (uint256 ret, uint nextOffset) { + return BytesParsing.asUint256CdUnchecked(encoded, offset); } - function asBytes31(bytes calldata encoded, uint offset) external pure returns (bytes31 ret, uint nextOffset) { - return BytesParsing.asBytes31(encoded, offset); + function asUint256Cd(bytes calldata encoded, uint offset) external pure returns (uint256 ret, uint nextOffset) { + return BytesParsing.asUint256Cd(encoded, offset); } function asUint256Unchecked(bytes calldata encoded, uint offset) external pure returns (uint256 ret, uint nextOffset) { @@ -574,6 +642,510 @@ contract BytesParsingTestWrapper { return BytesParsing.asUint256(encoded, offset); } + function asBytes1CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes1 ret, uint nextOffset) { + return BytesParsing.asBytes1CdUnchecked(encoded, offset); + } + + function asBytes1Cd(bytes calldata encoded, uint offset) external pure returns (bytes1 ret, uint nextOffset) { + return BytesParsing.asBytes1Cd(encoded, offset); + } + + function asBytes1Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes1 ret, uint nextOffset) { + return BytesParsing.asBytes1Unchecked(encoded, offset); + } + + function asBytes1(bytes calldata encoded, uint offset) external pure returns (bytes1 ret, uint nextOffset) { + return BytesParsing.asBytes1(encoded, offset); + } + + function asBytes2CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes2 ret, uint nextOffset) { + return BytesParsing.asBytes2CdUnchecked(encoded, offset); + } + + function asBytes2Cd(bytes calldata encoded, uint offset) external pure returns (bytes2 ret, uint nextOffset) { + return BytesParsing.asBytes2Cd(encoded, offset); + } + + function asBytes2Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes2 ret, uint nextOffset) { + return BytesParsing.asBytes2Unchecked(encoded, offset); + } + + function asBytes2(bytes calldata encoded, uint offset) external pure returns (bytes2 ret, uint nextOffset) { + return BytesParsing.asBytes2(encoded, offset); + } + + function asBytes3CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes3 ret, uint nextOffset) { + return BytesParsing.asBytes3CdUnchecked(encoded, offset); + } + + function asBytes3Cd(bytes calldata encoded, uint offset) external pure returns (bytes3 ret, uint nextOffset) { + return BytesParsing.asBytes3Cd(encoded, offset); + } + + function asBytes3Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes3 ret, uint nextOffset) { + return BytesParsing.asBytes3Unchecked(encoded, offset); + } + + function asBytes3(bytes calldata encoded, uint offset) external pure returns (bytes3 ret, uint nextOffset) { + return BytesParsing.asBytes3(encoded, offset); + } + + function asBytes4CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes4 ret, uint nextOffset) { + return BytesParsing.asBytes4CdUnchecked(encoded, offset); + } + + function asBytes4Cd(bytes calldata encoded, uint offset) external pure returns (bytes4 ret, uint nextOffset) { + return BytesParsing.asBytes4Cd(encoded, offset); + } + + function asBytes4Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes4 ret, uint nextOffset) { + return BytesParsing.asBytes4Unchecked(encoded, offset); + } + + function asBytes4(bytes calldata encoded, uint offset) external pure returns (bytes4 ret, uint nextOffset) { + return BytesParsing.asBytes4(encoded, offset); + } + + function asBytes5CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes5 ret, uint nextOffset) { + return BytesParsing.asBytes5CdUnchecked(encoded, offset); + } + + function asBytes5Cd(bytes calldata encoded, uint offset) external pure returns (bytes5 ret, uint nextOffset) { + return BytesParsing.asBytes5Cd(encoded, offset); + } + + function asBytes5Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes5 ret, uint nextOffset) { + return BytesParsing.asBytes5Unchecked(encoded, offset); + } + + function asBytes5(bytes calldata encoded, uint offset) external pure returns (bytes5 ret, uint nextOffset) { + return BytesParsing.asBytes5(encoded, offset); + } + + function asBytes6CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes6 ret, uint nextOffset) { + return BytesParsing.asBytes6CdUnchecked(encoded, offset); + } + + function asBytes6Cd(bytes calldata encoded, uint offset) external pure returns (bytes6 ret, uint nextOffset) { + return BytesParsing.asBytes6Cd(encoded, offset); + } + + function asBytes6Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes6 ret, uint nextOffset) { + return BytesParsing.asBytes6Unchecked(encoded, offset); + } + + function asBytes6(bytes calldata encoded, uint offset) external pure returns (bytes6 ret, uint nextOffset) { + return BytesParsing.asBytes6(encoded, offset); + } + + function asBytes7CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes7 ret, uint nextOffset) { + return BytesParsing.asBytes7CdUnchecked(encoded, offset); + } + + function asBytes7Cd(bytes calldata encoded, uint offset) external pure returns (bytes7 ret, uint nextOffset) { + return BytesParsing.asBytes7Cd(encoded, offset); + } + + function asBytes7Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes7 ret, uint nextOffset) { + return BytesParsing.asBytes7Unchecked(encoded, offset); + } + + function asBytes7(bytes calldata encoded, uint offset) external pure returns (bytes7 ret, uint nextOffset) { + return BytesParsing.asBytes7(encoded, offset); + } + + function asBytes8CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes8 ret, uint nextOffset) { + return BytesParsing.asBytes8CdUnchecked(encoded, offset); + } + + function asBytes8Cd(bytes calldata encoded, uint offset) external pure returns (bytes8 ret, uint nextOffset) { + return BytesParsing.asBytes8Cd(encoded, offset); + } + + function asBytes8Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes8 ret, uint nextOffset) { + return BytesParsing.asBytes8Unchecked(encoded, offset); + } + + function asBytes8(bytes calldata encoded, uint offset) external pure returns (bytes8 ret, uint nextOffset) { + return BytesParsing.asBytes8(encoded, offset); + } + + function asBytes9CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes9 ret, uint nextOffset) { + return BytesParsing.asBytes9CdUnchecked(encoded, offset); + } + + function asBytes9Cd(bytes calldata encoded, uint offset) external pure returns (bytes9 ret, uint nextOffset) { + return BytesParsing.asBytes9Cd(encoded, offset); + } + + function asBytes9Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes9 ret, uint nextOffset) { + return BytesParsing.asBytes9Unchecked(encoded, offset); + } + + function asBytes9(bytes calldata encoded, uint offset) external pure returns (bytes9 ret, uint nextOffset) { + return BytesParsing.asBytes9(encoded, offset); + } + + function asBytes10CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes10 ret, uint nextOffset) { + return BytesParsing.asBytes10CdUnchecked(encoded, offset); + } + + function asBytes10Cd(bytes calldata encoded, uint offset) external pure returns (bytes10 ret, uint nextOffset) { + return BytesParsing.asBytes10Cd(encoded, offset); + } + + function asBytes10Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes10 ret, uint nextOffset) { + return BytesParsing.asBytes10Unchecked(encoded, offset); + } + + function asBytes10(bytes calldata encoded, uint offset) external pure returns (bytes10 ret, uint nextOffset) { + return BytesParsing.asBytes10(encoded, offset); + } + + function asBytes11CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes11 ret, uint nextOffset) { + return BytesParsing.asBytes11CdUnchecked(encoded, offset); + } + + function asBytes11Cd(bytes calldata encoded, uint offset) external pure returns (bytes11 ret, uint nextOffset) { + return BytesParsing.asBytes11Cd(encoded, offset); + } + + function asBytes11Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes11 ret, uint nextOffset) { + return BytesParsing.asBytes11Unchecked(encoded, offset); + } + + function asBytes11(bytes calldata encoded, uint offset) external pure returns (bytes11 ret, uint nextOffset) { + return BytesParsing.asBytes11(encoded, offset); + } + + function asBytes12CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes12 ret, uint nextOffset) { + return BytesParsing.asBytes12CdUnchecked(encoded, offset); + } + + function asBytes12Cd(bytes calldata encoded, uint offset) external pure returns (bytes12 ret, uint nextOffset) { + return BytesParsing.asBytes12Cd(encoded, offset); + } + + function asBytes12Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes12 ret, uint nextOffset) { + return BytesParsing.asBytes12Unchecked(encoded, offset); + } + + function asBytes12(bytes calldata encoded, uint offset) external pure returns (bytes12 ret, uint nextOffset) { + return BytesParsing.asBytes12(encoded, offset); + } + + function asBytes13CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes13 ret, uint nextOffset) { + return BytesParsing.asBytes13CdUnchecked(encoded, offset); + } + + function asBytes13Cd(bytes calldata encoded, uint offset) external pure returns (bytes13 ret, uint nextOffset) { + return BytesParsing.asBytes13Cd(encoded, offset); + } + + function asBytes13Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes13 ret, uint nextOffset) { + return BytesParsing.asBytes13Unchecked(encoded, offset); + } + + function asBytes13(bytes calldata encoded, uint offset) external pure returns (bytes13 ret, uint nextOffset) { + return BytesParsing.asBytes13(encoded, offset); + } + + function asBytes14CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes14 ret, uint nextOffset) { + return BytesParsing.asBytes14CdUnchecked(encoded, offset); + } + + function asBytes14Cd(bytes calldata encoded, uint offset) external pure returns (bytes14 ret, uint nextOffset) { + return BytesParsing.asBytes14Cd(encoded, offset); + } + + function asBytes14Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes14 ret, uint nextOffset) { + return BytesParsing.asBytes14Unchecked(encoded, offset); + } + + function asBytes14(bytes calldata encoded, uint offset) external pure returns (bytes14 ret, uint nextOffset) { + return BytesParsing.asBytes14(encoded, offset); + } + + function asBytes15CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes15 ret, uint nextOffset) { + return BytesParsing.asBytes15CdUnchecked(encoded, offset); + } + + function asBytes15Cd(bytes calldata encoded, uint offset) external pure returns (bytes15 ret, uint nextOffset) { + return BytesParsing.asBytes15Cd(encoded, offset); + } + + function asBytes15Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes15 ret, uint nextOffset) { + return BytesParsing.asBytes15Unchecked(encoded, offset); + } + + function asBytes15(bytes calldata encoded, uint offset) external pure returns (bytes15 ret, uint nextOffset) { + return BytesParsing.asBytes15(encoded, offset); + } + + function asBytes16CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes16 ret, uint nextOffset) { + return BytesParsing.asBytes16CdUnchecked(encoded, offset); + } + + function asBytes16Cd(bytes calldata encoded, uint offset) external pure returns (bytes16 ret, uint nextOffset) { + return BytesParsing.asBytes16Cd(encoded, offset); + } + + function asBytes16Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes16 ret, uint nextOffset) { + return BytesParsing.asBytes16Unchecked(encoded, offset); + } + + function asBytes16(bytes calldata encoded, uint offset) external pure returns (bytes16 ret, uint nextOffset) { + return BytesParsing.asBytes16(encoded, offset); + } + + function asBytes17CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes17 ret, uint nextOffset) { + return BytesParsing.asBytes17CdUnchecked(encoded, offset); + } + + function asBytes17Cd(bytes calldata encoded, uint offset) external pure returns (bytes17 ret, uint nextOffset) { + return BytesParsing.asBytes17Cd(encoded, offset); + } + + function asBytes17Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes17 ret, uint nextOffset) { + return BytesParsing.asBytes17Unchecked(encoded, offset); + } + + function asBytes17(bytes calldata encoded, uint offset) external pure returns (bytes17 ret, uint nextOffset) { + return BytesParsing.asBytes17(encoded, offset); + } + + function asBytes18CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes18 ret, uint nextOffset) { + return BytesParsing.asBytes18CdUnchecked(encoded, offset); + } + + function asBytes18Cd(bytes calldata encoded, uint offset) external pure returns (bytes18 ret, uint nextOffset) { + return BytesParsing.asBytes18Cd(encoded, offset); + } + + function asBytes18Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes18 ret, uint nextOffset) { + return BytesParsing.asBytes18Unchecked(encoded, offset); + } + + function asBytes18(bytes calldata encoded, uint offset) external pure returns (bytes18 ret, uint nextOffset) { + return BytesParsing.asBytes18(encoded, offset); + } + + function asBytes19CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes19 ret, uint nextOffset) { + return BytesParsing.asBytes19CdUnchecked(encoded, offset); + } + + function asBytes19Cd(bytes calldata encoded, uint offset) external pure returns (bytes19 ret, uint nextOffset) { + return BytesParsing.asBytes19Cd(encoded, offset); + } + + function asBytes19Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes19 ret, uint nextOffset) { + return BytesParsing.asBytes19Unchecked(encoded, offset); + } + + function asBytes19(bytes calldata encoded, uint offset) external pure returns (bytes19 ret, uint nextOffset) { + return BytesParsing.asBytes19(encoded, offset); + } + + function asBytes20CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes20 ret, uint nextOffset) { + return BytesParsing.asBytes20CdUnchecked(encoded, offset); + } + + function asBytes20Cd(bytes calldata encoded, uint offset) external pure returns (bytes20 ret, uint nextOffset) { + return BytesParsing.asBytes20Cd(encoded, offset); + } + + function asBytes20Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes20 ret, uint nextOffset) { + return BytesParsing.asBytes20Unchecked(encoded, offset); + } + + function asBytes20(bytes calldata encoded, uint offset) external pure returns (bytes20 ret, uint nextOffset) { + return BytesParsing.asBytes20(encoded, offset); + } + + function asBytes21CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes21 ret, uint nextOffset) { + return BytesParsing.asBytes21CdUnchecked(encoded, offset); + } + + function asBytes21Cd(bytes calldata encoded, uint offset) external pure returns (bytes21 ret, uint nextOffset) { + return BytesParsing.asBytes21Cd(encoded, offset); + } + + function asBytes21Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes21 ret, uint nextOffset) { + return BytesParsing.asBytes21Unchecked(encoded, offset); + } + + function asBytes21(bytes calldata encoded, uint offset) external pure returns (bytes21 ret, uint nextOffset) { + return BytesParsing.asBytes21(encoded, offset); + } + + function asBytes22CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes22 ret, uint nextOffset) { + return BytesParsing.asBytes22CdUnchecked(encoded, offset); + } + + function asBytes22Cd(bytes calldata encoded, uint offset) external pure returns (bytes22 ret, uint nextOffset) { + return BytesParsing.asBytes22Cd(encoded, offset); + } + + function asBytes22Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes22 ret, uint nextOffset) { + return BytesParsing.asBytes22Unchecked(encoded, offset); + } + + function asBytes22(bytes calldata encoded, uint offset) external pure returns (bytes22 ret, uint nextOffset) { + return BytesParsing.asBytes22(encoded, offset); + } + + function asBytes23CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes23 ret, uint nextOffset) { + return BytesParsing.asBytes23CdUnchecked(encoded, offset); + } + + function asBytes23Cd(bytes calldata encoded, uint offset) external pure returns (bytes23 ret, uint nextOffset) { + return BytesParsing.asBytes23Cd(encoded, offset); + } + + function asBytes23Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes23 ret, uint nextOffset) { + return BytesParsing.asBytes23Unchecked(encoded, offset); + } + + function asBytes23(bytes calldata encoded, uint offset) external pure returns (bytes23 ret, uint nextOffset) { + return BytesParsing.asBytes23(encoded, offset); + } + + function asBytes24CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes24 ret, uint nextOffset) { + return BytesParsing.asBytes24CdUnchecked(encoded, offset); + } + + function asBytes24Cd(bytes calldata encoded, uint offset) external pure returns (bytes24 ret, uint nextOffset) { + return BytesParsing.asBytes24Cd(encoded, offset); + } + + function asBytes24Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes24 ret, uint nextOffset) { + return BytesParsing.asBytes24Unchecked(encoded, offset); + } + + function asBytes24(bytes calldata encoded, uint offset) external pure returns (bytes24 ret, uint nextOffset) { + return BytesParsing.asBytes24(encoded, offset); + } + + function asBytes25CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes25 ret, uint nextOffset) { + return BytesParsing.asBytes25CdUnchecked(encoded, offset); + } + + function asBytes25Cd(bytes calldata encoded, uint offset) external pure returns (bytes25 ret, uint nextOffset) { + return BytesParsing.asBytes25Cd(encoded, offset); + } + + function asBytes25Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes25 ret, uint nextOffset) { + return BytesParsing.asBytes25Unchecked(encoded, offset); + } + + function asBytes25(bytes calldata encoded, uint offset) external pure returns (bytes25 ret, uint nextOffset) { + return BytesParsing.asBytes25(encoded, offset); + } + + function asBytes26CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes26 ret, uint nextOffset) { + return BytesParsing.asBytes26CdUnchecked(encoded, offset); + } + + function asBytes26Cd(bytes calldata encoded, uint offset) external pure returns (bytes26 ret, uint nextOffset) { + return BytesParsing.asBytes26Cd(encoded, offset); + } + + function asBytes26Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes26 ret, uint nextOffset) { + return BytesParsing.asBytes26Unchecked(encoded, offset); + } + + function asBytes26(bytes calldata encoded, uint offset) external pure returns (bytes26 ret, uint nextOffset) { + return BytesParsing.asBytes26(encoded, offset); + } + + function asBytes27CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes27 ret, uint nextOffset) { + return BytesParsing.asBytes27CdUnchecked(encoded, offset); + } + + function asBytes27Cd(bytes calldata encoded, uint offset) external pure returns (bytes27 ret, uint nextOffset) { + return BytesParsing.asBytes27Cd(encoded, offset); + } + + function asBytes27Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes27 ret, uint nextOffset) { + return BytesParsing.asBytes27Unchecked(encoded, offset); + } + + function asBytes27(bytes calldata encoded, uint offset) external pure returns (bytes27 ret, uint nextOffset) { + return BytesParsing.asBytes27(encoded, offset); + } + + function asBytes28CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes28 ret, uint nextOffset) { + return BytesParsing.asBytes28CdUnchecked(encoded, offset); + } + + function asBytes28Cd(bytes calldata encoded, uint offset) external pure returns (bytes28 ret, uint nextOffset) { + return BytesParsing.asBytes28Cd(encoded, offset); + } + + function asBytes28Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes28 ret, uint nextOffset) { + return BytesParsing.asBytes28Unchecked(encoded, offset); + } + + function asBytes28(bytes calldata encoded, uint offset) external pure returns (bytes28 ret, uint nextOffset) { + return BytesParsing.asBytes28(encoded, offset); + } + + function asBytes29CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes29 ret, uint nextOffset) { + return BytesParsing.asBytes29CdUnchecked(encoded, offset); + } + + function asBytes29Cd(bytes calldata encoded, uint offset) external pure returns (bytes29 ret, uint nextOffset) { + return BytesParsing.asBytes29Cd(encoded, offset); + } + + function asBytes29Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes29 ret, uint nextOffset) { + return BytesParsing.asBytes29Unchecked(encoded, offset); + } + + function asBytes29(bytes calldata encoded, uint offset) external pure returns (bytes29 ret, uint nextOffset) { + return BytesParsing.asBytes29(encoded, offset); + } + + function asBytes30CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes30 ret, uint nextOffset) { + return BytesParsing.asBytes30CdUnchecked(encoded, offset); + } + + function asBytes30Cd(bytes calldata encoded, uint offset) external pure returns (bytes30 ret, uint nextOffset) { + return BytesParsing.asBytes30Cd(encoded, offset); + } + + function asBytes30Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes30 ret, uint nextOffset) { + return BytesParsing.asBytes30Unchecked(encoded, offset); + } + + function asBytes30(bytes calldata encoded, uint offset) external pure returns (bytes30 ret, uint nextOffset) { + return BytesParsing.asBytes30(encoded, offset); + } + + function asBytes31CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes31 ret, uint nextOffset) { + return BytesParsing.asBytes31CdUnchecked(encoded, offset); + } + + function asBytes31Cd(bytes calldata encoded, uint offset) external pure returns (bytes31 ret, uint nextOffset) { + return BytesParsing.asBytes31Cd(encoded, offset); + } + + function asBytes31Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes31 ret, uint nextOffset) { + return BytesParsing.asBytes31Unchecked(encoded, offset); + } + + function asBytes31(bytes calldata encoded, uint offset) external pure returns (bytes31 ret, uint nextOffset) { + return BytesParsing.asBytes31(encoded, offset); + } + + function asBytes32CdUnchecked(bytes calldata encoded, uint offset) external pure returns (bytes32 ret, uint nextOffset) { + return BytesParsing.asBytes32CdUnchecked(encoded, offset); + } + + function asBytes32Cd(bytes calldata encoded, uint offset) external pure returns (bytes32 ret, uint nextOffset) { + return BytesParsing.asBytes32Cd(encoded, offset); + } + function asBytes32Unchecked(bytes calldata encoded, uint offset) external pure returns (bytes32 ret, uint nextOffset) { return BytesParsing.asBytes32Unchecked(encoded, offset); }