From 45e730a8ce00587b169b056c0d8313e33cce0cb0 Mon Sep 17 00:00:00 2001 From: Uncle Fatso Date: Wed, 16 Sep 2026 14:13:51 +0300 Subject: [PATCH] make weaver dependant on chainid Signed-off-by: Uncle Fatso --- deployer.sh | 2 ++ src/mocks/WeaverMock.sol | 2 +- src/types/Weaver.sol | 10 ++++++++-- test/gatekeeper/GatekeeperWeaver.t.sol | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/deployer.sh b/deployer.sh index 314743a..498d6f6 100644 --- a/deployer.sh +++ b/deployer.sh @@ -117,6 +117,8 @@ for i in $(seq $START $END); do CONTRACT="AfterPartyThird" elif [ "69" == "$i" ]; then CONTRACT="Gatekeeper" + elif [ "420" == "$i" ]; then + CONTRACT="WeaverMock" else echo "No contract found for index $i" exit diff --git a/src/mocks/WeaverMock.sol b/src/mocks/WeaverMock.sol index 053ff75..13d4208 100644 --- a/src/mocks/WeaverMock.sol +++ b/src/mocks/WeaverMock.sol @@ -22,7 +22,7 @@ contract WeaverMock is Weaver { uint256 index, uint256 amount, bytes32 receiver - ) external pure returns (bytes32) { + ) external view returns (bytes32) { return _computeArgumentsHash(index, amount, receiver); } } diff --git a/src/types/Weaver.sol b/src/types/Weaver.sol index 8bf06cb..8098efd 100644 --- a/src/types/Weaver.sol +++ b/src/types/Weaver.sol @@ -163,8 +163,14 @@ abstract contract Weaver is IWeaver { emit ThreadInserted(globalIndex, session); } - function _computeArgumentsHash(uint256 i, uint256 a, bytes32 r) internal pure returns (bytes32) { - return Hashes.efficientKeccak256(Hashes.efficientKeccak256(bytes32(a), r), bytes32(i)); + function _computeArgumentsHash(uint256 i, uint256 a, bytes32 r) internal view returns (bytes32) { + return Hashes.efficientKeccak256( + Hashes.efficientKeccak256( + Hashes.efficientKeccak256(bytes32(a), r), + bytes32(i) + ), + bytes32(block.chainid) + ); } function _initialize(address _previousAddress) internal { diff --git a/test/gatekeeper/GatekeeperWeaver.t.sol b/test/gatekeeper/GatekeeperWeaver.t.sol index 279638c..84fe864 100644 --- a/test/gatekeeper/GatekeeperWeaver.t.sol +++ b/test/gatekeeper/GatekeeperWeaver.t.sol @@ -65,7 +65,7 @@ contract GatekeeperWeaver is Gatekeeper { return bytes32(_treeNodes[session][slotIndex].latest()); } - function computePreimage(uint256 globalIndex, uint256 a, bytes32 r) public pure returns (bytes32) { + function computePreimage(uint256 globalIndex, uint256 a, bytes32 r) public view returns (bytes32) { uint256 valueIndex = globalIndex / SLOTS; return _computeArgumentsHash(valueIndex, a, r); } @@ -76,7 +76,7 @@ contract GatekeeperWeaver is Gatekeeper { uint256 globalIndex, uint256 amount, bytes32 who - ) public pure returns (bytes32) { + ) public view returns (bytes32) { if (proof.length != DEPTH) { return bytes32(0); } if (values.length == 0) { return bytes32(0); }