From aee373d7cb166d8570844fc9a8fe5e2be518f748 Mon Sep 17 00:00:00 2001 From: leo Sayous Date: Sat, 22 Jul 2023 22:05:59 +0200 Subject: [PATCH] fix: use use view for verify function --- package.json | 6 +-- src/SismoConnectLib.sol | 50 ++++++++++++------------ src/interfaces/ISismoConnectVerifier.sol | 2 +- test/misc/CheatSheet.sol | 2 +- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index d45b901..44afc70 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "sismo-connect-onchain-verifier", - "version": "1.0.0", + "name": "sismo-connect-solidity", + "version": "1.0.1", "main": "index.js", - "repository": "git@github.com:sismo-core/sismo-connect-onchain-verifier.git", + "repository": "git@github.com:sismo-core/sismo-connect-solidity.git", "author": "Hadrien Charlanes <35774097+dhadrien@users.noreply.github.com>", "license": "MIT", "devDependencies": { diff --git a/src/SismoConnectLib.sol b/src/SismoConnectLib.sol index 3ece713..e8a4b43 100644 --- a/src/SismoConnectLib.sol +++ b/src/SismoConnectLib.sol @@ -78,7 +78,7 @@ contract SismoConnect { ClaimRequest memory claim, SignatureRequest memory signature, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auth, claim, signature, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -89,7 +89,7 @@ contract SismoConnect { AuthRequest memory auth, ClaimRequest memory claim, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auth, claim, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -100,7 +100,7 @@ contract SismoConnect { AuthRequest memory auth, SignatureRequest memory signature, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auth, signature, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -111,7 +111,7 @@ contract SismoConnect { ClaimRequest memory claim, SignatureRequest memory signature, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(claim, signature, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -121,7 +121,7 @@ contract SismoConnect { bytes memory responseBytes, AuthRequest memory auth, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auth, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -131,7 +131,7 @@ contract SismoConnect { bytes memory responseBytes, ClaimRequest memory claim, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(claim, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -142,7 +142,7 @@ contract SismoConnect { AuthRequest memory auth, ClaimRequest memory claim, SignatureRequest memory signature - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auth, claim, signature); return _sismoConnectVerifier.verify(response, request, config()); @@ -152,7 +152,7 @@ contract SismoConnect { bytes memory responseBytes, AuthRequest memory auth, ClaimRequest memory claim - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auth, claim); return _sismoConnectVerifier.verify(response, request, config()); @@ -162,7 +162,7 @@ contract SismoConnect { bytes memory responseBytes, AuthRequest memory auth, SignatureRequest memory signature - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auth, signature); return _sismoConnectVerifier.verify(response, request, config()); @@ -172,7 +172,7 @@ contract SismoConnect { bytes memory responseBytes, ClaimRequest memory claim, SignatureRequest memory signature - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(claim, signature); return _sismoConnectVerifier.verify(response, request, config()); @@ -181,7 +181,7 @@ contract SismoConnect { function verify( bytes memory responseBytes, AuthRequest memory auth - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auth); return _sismoConnectVerifier.verify(response, request, config()); @@ -190,7 +190,7 @@ contract SismoConnect { function verify( bytes memory responseBytes, ClaimRequest memory claim - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(claim); return _sismoConnectVerifier.verify(response, request, config()); @@ -199,7 +199,7 @@ contract SismoConnect { function verify( bytes memory responseBytes, SismoConnectRequest memory request - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); return _sismoConnectVerifier.verify(response, request, config()); } @@ -210,7 +210,7 @@ contract SismoConnect { ClaimRequest[] memory claims, SignatureRequest memory signature, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auths, claims, signature, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -221,7 +221,7 @@ contract SismoConnect { AuthRequest[] memory auths, ClaimRequest[] memory claims, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auths, claims, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -232,7 +232,7 @@ contract SismoConnect { AuthRequest[] memory auths, SignatureRequest memory signature, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auths, signature, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -243,7 +243,7 @@ contract SismoConnect { ClaimRequest[] memory claims, SignatureRequest memory signature, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(claims, signature, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -253,7 +253,7 @@ contract SismoConnect { bytes memory responseBytes, AuthRequest[] memory auths, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auths, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -263,7 +263,7 @@ contract SismoConnect { bytes memory responseBytes, ClaimRequest[] memory claims, bytes16 namespace - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(claims, namespace); return _sismoConnectVerifier.verify(response, request, config()); @@ -274,7 +274,7 @@ contract SismoConnect { AuthRequest[] memory auths, ClaimRequest[] memory claims, SignatureRequest memory signature - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auths, claims, signature); return _sismoConnectVerifier.verify(response, request, config()); @@ -284,7 +284,7 @@ contract SismoConnect { bytes memory responseBytes, AuthRequest[] memory auths, ClaimRequest[] memory claims - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auths, claims); return _sismoConnectVerifier.verify(response, request, config()); @@ -294,7 +294,7 @@ contract SismoConnect { bytes memory responseBytes, AuthRequest[] memory auths, SignatureRequest memory signature - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auths, signature); return _sismoConnectVerifier.verify(response, request, config()); @@ -304,7 +304,7 @@ contract SismoConnect { bytes memory responseBytes, ClaimRequest[] memory claims, SignatureRequest memory signature - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(claims, signature); return _sismoConnectVerifier.verify(response, request, config()); @@ -313,7 +313,7 @@ contract SismoConnect { function verify( bytes memory responseBytes, AuthRequest[] memory auths - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(auths); return _sismoConnectVerifier.verify(response, request, config()); @@ -322,7 +322,7 @@ contract SismoConnect { function verify( bytes memory responseBytes, ClaimRequest[] memory claims - ) internal returns (SismoConnectVerifiedResult memory) { + ) internal view returns (SismoConnectVerifiedResult memory) { SismoConnectResponse memory response = abi.decode(responseBytes, (SismoConnectResponse)); SismoConnectRequest memory request = buildRequest(claims); return _sismoConnectVerifier.verify(response, request, config()); diff --git a/src/interfaces/ISismoConnectVerifier.sol b/src/interfaces/ISismoConnectVerifier.sol index 5749e8f..987e432 100644 --- a/src/interfaces/ISismoConnectVerifier.sol +++ b/src/interfaces/ISismoConnectVerifier.sol @@ -15,7 +15,7 @@ interface ISismoConnectVerifier { SismoConnectResponse memory response, SismoConnectRequest memory request, SismoConnectConfig memory config - ) external returns (SismoConnectVerifiedResult memory); + ) external view returns (SismoConnectVerifiedResult memory); function SISMO_CONNECT_VERSION() external view returns (bytes32); } diff --git a/test/misc/CheatSheet.sol b/test/misc/CheatSheet.sol index cbe7fae..467810e 100644 --- a/test/misc/CheatSheet.sol +++ b/test/misc/CheatSheet.sol @@ -15,7 +15,7 @@ contract CheatSheet is SismoConnect { SismoConnect(buildConfig({appId: _appId, isImpersonationMode: _isImpersonationMode})) {} - function verifySismoConnectResponse(bytes memory response) public { + function verifySismoConnectResponse(bytes memory response) public view { // Recreate the request made in the fontend to verify the proof AuthRequest[] memory auths = new AuthRequest[](6); auths[0] = _authRequestBuilder.build({authType: AuthType.VAULT});