Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: address to bytes32 contract changes #650

Merged
merged 23 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions contracts/Linea_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
*/
contract Linea_SpokePool is SpokePool {
using SafeERC20 for IERC20;
using AddressToBytes32 for address;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shall we use explicit imports? I see that recent commits have been moving in that direction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Reinis-FRP What do you mean here?
These are imported in the SpokePool.sol and used here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, meant using curly braces to explicitly state what contracts/libraries from source files we are importing


/**
* @notice Address of Linea's Canonical Message Service contract on L2.
Expand Down Expand Up @@ -122,8 +123,8 @@ contract Linea_SpokePool is SpokePool {
* @notice Wraps any ETH into WETH before executing base function. This is necessary because SpokePool receives
* ETH over the canonical token bridge instead of WETH.
*/
function _preExecuteLeafHook(address l2TokenAddress) internal override {
if (l2TokenAddress == address(wrappedNativeToken)) _depositEthToWeth();
function _preExecuteLeafHook(bytes32 l2TokenAddress) internal override {
if (l2TokenAddress == address(wrappedNativeToken).toBytes32()) _depositEthToWeth();
}

// Wrap any ETH owned by this contract so we can send expected L2 token to recipient. This is necessary because
Expand Down
6 changes: 4 additions & 2 deletions contracts/Ovm_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ interface IL2ERC20Bridge {
*/
contract Ovm_SpokePool is SpokePool, CircleCCTPAdapter {
using SafeERC20 for IERC20;
using AddressToBytes32 for address;
// "l1Gas" parameter used in call to bridge tokens from this contract back to L1 via IL2ERC20Bridge. Currently
// unused by bridge but included for future compatibility.

uint32 public l1Gas;

// ETH is an ERC20 on OVM.
Expand Down Expand Up @@ -133,8 +135,8 @@ contract Ovm_SpokePool is SpokePool, CircleCCTPAdapter {
* @notice Wraps any ETH into WETH before executing leaves. This is necessary because SpokePool receives
* ETH over the canonical token bridge instead of WETH.
*/
function _preExecuteLeafHook(address l2TokenAddress) internal override {
if (l2TokenAddress == address(wrappedNativeToken)) _depositEthToWeth();
function _preExecuteLeafHook(bytes32 l2TokenAddress) internal override {
if (l2TokenAddress == address(wrappedNativeToken).toBytes32()) _depositEthToWeth();
}

// Wrap any ETH owned by this contract so we can send expected L2 token to recipient. This is necessary because
Expand Down
7 changes: 4 additions & 3 deletions contracts/PolygonZkEVM_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ interface IBridgeMessageReceiver {
*/
contract PolygonZkEVM_SpokePool is SpokePool, IBridgeMessageReceiver {
using SafeERC20 for IERC20;

using AddressToBytes32 for address;
// Address of Polygon zkEVM's Canonical Bridge on L2.

IPolygonZkEVMBridge public l2PolygonZkEVMBridge;

// Polygon zkEVM's internal network id for L1.
Expand Down Expand Up @@ -157,8 +158,8 @@ contract PolygonZkEVM_SpokePool is SpokePool, IBridgeMessageReceiver {
* @notice Wraps any ETH into WETH before executing base function. This is necessary because SpokePool receives
* ETH over the canonical token bridge instead of WETH.
*/
function _preExecuteLeafHook(address l2TokenAddress) internal override {
if (l2TokenAddress == address(wrappedNativeToken)) _depositEthToWeth();
function _preExecuteLeafHook(bytes32 l2TokenAddress) internal override {
if (l2TokenAddress == address(wrappedNativeToken).toBytes32()) _depositEthToWeth();
}

// Wrap any ETH owned by this contract so we can send expected L2 token to recipient. This is necessary because
Expand Down
7 changes: 3 additions & 4 deletions contracts/Polygon_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter
* @param data ABI encoded function call to execute on this contract.
*/
function processMessageFromRoot(
uint256, /*stateId*/
chrismaree marked this conversation as resolved.
Show resolved Hide resolved
uint256,
/*stateId*/
address rootMessageSender,
bytes calldata data
) public validateInternalCalls {
Expand Down Expand Up @@ -203,7 +204,6 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter
* whereby someone batches this call with a bunch of other calls and produces a very large L2 burn transaction.
* This might make the L2 -> L1 message fail due to exceeding the L1 calldata limit.
*/

function executeRelayerRefundLeaf(
uint32 rootBundleId,
SpokePoolInterface.RelayerRefundLeaf memory relayerRefundLeaf,
Expand All @@ -220,7 +220,6 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter
/**************************************
* INTERNAL FUNCTIONS *
**************************************/

function _setFxChild(address _fxChild) internal {
//slither-disable-next-line missing-zero-check
fxChild = _fxChild;
Expand All @@ -232,7 +231,7 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool, CircleCCTPAdapter
emit SetPolygonTokenBridger(address(_polygonTokenBridger));
}

function _preExecuteLeafHook(address) internal override {
function _preExecuteLeafHook(bytes32) internal override {
// Wraps MATIC --> WMATIC before distributing tokens from this contract.
_wrap();
}
Expand Down
Loading
Loading