From 7803e2a7d1b5b8b30f415025af99c7c8e09b3acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Sat, 9 Nov 2024 15:03:42 +0700 Subject: [PATCH] add part 1 and part 2 solutions --- .github/workflows/test.yml | 8 ++++---- src/Part1_Counter.sol | 4 +++- src/Part3_Keystore.sol | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e158a44..762a296 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: forge build --sizes id: build - # - name: Run Forge tests - # run: | - # forge test -vvv - # id: test + - name: Run Forge tests + run: | + forge test -vvv + id: test diff --git a/src/Part1_Counter.sol b/src/Part1_Counter.sol index cc2ee5a..c996b51 100644 --- a/src/Part1_Counter.sol +++ b/src/Part1_Counter.sol @@ -28,6 +28,8 @@ contract CounterReader { /// @notice Reads `number` and `map[123]` from L1 using L1SLOAD /// @dev This function reads values from L1 function readCounter() external view returns (uint256, uint256) { - // TODO: complete this function + bytes32 mappingSlot = keccak256(abi.encode( /* mapping key: */ 123, /* mapping slot: */ 1)); + (uint256 val0, uint256 val1) = L1SLOAD.readUint256(counter, bytes32(uint256(0)), mappingSlot); + return (val0, val1); } } diff --git a/src/Part3_Keystore.sol b/src/Part3_Keystore.sol index 0d58b5d..856c3be 100644 --- a/src/Part3_Keystore.sol +++ b/src/Part3_Keystore.sol @@ -60,6 +60,8 @@ contract L2Wallet is Wallet { /// @inheritdoc Wallet /// @dev This function reads the signer value from L1 function isAuthorized(address signer) public view override returns (bool) { - // TODO: complete this function + bytes32 mappingSlot = keccak256(abi.encode( /* mapping key: */ signer, /* mapping slot: */ 0)); + bool authorized = L1SLOAD.readBool(l1Wallet, mappingSlot); + return authorized; } }