From d9ac556d663b6a79e50688cc58737ae6bde17cb9 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Fri, 10 Nov 2023 00:14:30 +0100 Subject: [PATCH] init structs --- contracts/optimism/DepositDataCodec.sol | 9 +++++---- contracts/optimism/L1ERC20TokenBridge.sol | 11 ++++++----- contracts/token/ERC20Rebasable.sol | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/contracts/optimism/DepositDataCodec.sol b/contracts/optimism/DepositDataCodec.sol index a7bc919a..91b8c574 100644 --- a/contracts/optimism/DepositDataCodec.sol +++ b/contracts/optimism/DepositDataCodec.sol @@ -26,10 +26,11 @@ contract DepositDataCodec { revert ErrorDepositDataLength(); } - DepositData memory depositData; - depositData.rate = uint256(bytes32(buffer[0:32])); - depositData.time = uint256(bytes32(buffer[32:64])); - depositData.data = buffer[64:]; + DepositData memory depositData = DepositData({ + rate: uint256(bytes32(buffer[0:32])), + time: uint256(bytes32(buffer[32:64])), + data: buffer[64:] + }); return depositData; } diff --git a/contracts/optimism/L1ERC20TokenBridge.sol b/contracts/optimism/L1ERC20TokenBridge.sol index 1353325f..e1aa72be 100644 --- a/contracts/optimism/L1ERC20TokenBridge.sol +++ b/contracts/optimism/L1ERC20TokenBridge.sol @@ -129,11 +129,12 @@ contract L1ERC20TokenBridge is uint32 l2Gas_, bytes calldata data_ ) internal { - - DepositData memory depositData; - depositData.rate = IERC20Wrapable(l1TokenNonRebasable).tokensPerStEth(); - depositData.time = block.timestamp; - depositData.data = data_; + + DepositData memory depositData = DepositData({ + rate: IERC20Wrapable(l1TokenNonRebasable).tokensPerStEth(), + time: block.timestamp, + data: data_ + }); bytes memory encodedDepositData = encodeDepositData(depositData); diff --git a/contracts/token/ERC20Rebasable.sol b/contracts/token/ERC20Rebasable.sol index 0501dde8..d55c1542 100644 --- a/contracts/token/ERC20Rebasable.sol +++ b/contracts/token/ERC20Rebasable.sol @@ -75,7 +75,7 @@ contract ERC20Rebasable is IERC20Wrapable, IERC20, ERC20Metadata { return sharesAmount; } - function tokensPerStEth() external view returns (uint256) { + function tokensPerStEth() external pure returns (uint256) { return 0; }