-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from Consensys/chore/testing-on-local-stack
Chore: testing on local stack
- Loading branch information
Showing
19 changed files
with
1,778 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"require": "ts-node/register", | ||
"loader": "ts-node/esm", | ||
"extensions": ["ts", "tsx"], | ||
"spec": ["test/**/*.spec.*"], | ||
"watch-files": ["src"] | ||
} | ||
"extensions": [ | ||
"ts", | ||
"tsx" | ||
] | ||
} |
89 changes: 89 additions & 0 deletions
89
packages/linea-ens-resolver/contracts/clones-with-immutable-args/Clone.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// SPDX-License-Identifier: BSD | ||
pragma solidity ^0.8.4; | ||
|
||
/// @title Clone | ||
/// @author zefram.eth | ||
/// @notice Provides helper functions for reading immutable args from calldata | ||
contract Clone { | ||
/// @notice Reads an immutable arg with type address | ||
/// @param argOffset The offset of the arg in the packed data | ||
/// @return arg The arg value | ||
function _getArgAddress( | ||
uint256 argOffset | ||
) internal pure returns (address arg) { | ||
uint256 offset = _getImmutableArgsOffset(); | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
arg := shr(0x60, calldataload(add(offset, argOffset))) | ||
} | ||
} | ||
|
||
/// @notice Reads an immutable arg with type uint256 | ||
/// @param argOffset The offset of the arg in the packed data | ||
/// @return arg The arg value | ||
function _getArgUint256( | ||
uint256 argOffset | ||
) internal pure returns (uint256 arg) { | ||
uint256 offset = _getImmutableArgsOffset(); | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
arg := calldataload(add(offset, argOffset)) | ||
} | ||
} | ||
|
||
/// @notice Reads a uint256 array stored in the immutable args. | ||
/// @param argOffset The offset of the arg in the packed data | ||
/// @param arrLen Number of elements in the array | ||
/// @return arr The array | ||
function _getArgUint256Array( | ||
uint256 argOffset, | ||
uint64 arrLen | ||
) internal pure returns (uint256[] memory arr) { | ||
uint256 offset = _getImmutableArgsOffset(); | ||
uint256 el; | ||
arr = new uint256[](arrLen); | ||
for (uint64 i = 0; i < arrLen; i++) { | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
el := calldataload(add(add(offset, argOffset), mul(i, 32))) | ||
} | ||
arr[i] = el; | ||
} | ||
return arr; | ||
} | ||
|
||
/// @notice Reads an immutable arg with type uint64 | ||
/// @param argOffset The offset of the arg in the packed data | ||
/// @return arg The arg value | ||
function _getArgUint64( | ||
uint256 argOffset | ||
) internal pure returns (uint64 arg) { | ||
uint256 offset = _getImmutableArgsOffset(); | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
arg := shr(0xc0, calldataload(add(offset, argOffset))) | ||
} | ||
} | ||
|
||
/// @notice Reads an immutable arg with type uint8 | ||
/// @param argOffset The offset of the arg in the packed data | ||
/// @return arg The arg value | ||
function _getArgUint8(uint256 argOffset) internal pure returns (uint8 arg) { | ||
uint256 offset = _getImmutableArgsOffset(); | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
arg := shr(0xf8, calldataload(add(offset, argOffset))) | ||
} | ||
} | ||
|
||
/// @return offset The offset of the packed immutable args in calldata | ||
function _getImmutableArgsOffset() internal pure returns (uint256 offset) { | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
offset := sub( | ||
calldatasize(), | ||
add(shr(240, calldataload(sub(calldatasize(), 2))), 2) | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.