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

add auth for getters, instead of using msg.sender #767

Merged
merged 6 commits into from
Jul 10, 2023

Conversation

alexcos20
Copy link
Member

@alexcos20 alexcos20 commented Jul 5, 2023

Changes proposed in this PR:

  • for auth getters, use signature with validity instead of msg.sender
  • release v2.0.0-alpha.2

@alexcos20 alexcos20 requested a review from trentmc as a code owner July 5, 2023 12:16
Comment on lines +1200 to +1215
function _checkUserAuthorization(userAuth calldata _userAuth) internal view{
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 message = keccak256(
abi.encodePacked(prefix,
keccak256(
abi.encodePacked(
_userAuth.userAddress,
_userAuth.validUntil
)
)
)
);
address signer = ecrecover(message, _userAuth.v, _userAuth.r, _userAuth.s);
require(signer == _userAuth.userAddress, "Invalid auth");
require(_userAuth.validUntil > block.timestamp,'Expired');
}

Check notice

Code scanning / Slither

Block timestamp Low

@@ -968,14 +977,16 @@

function getPrediction(
uint256 blocknum,
address predictoor
address predictoor,
userAuth calldata _userAuth

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

Comment on lines +954 to +960
struct userAuth{
address userAddress;
uint8 v; // v of provider signed message
bytes32 r; // r of provider signed message
bytes32 s; // s of provider signed message
uint256 validUntil;
}

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

Struct ERC20Template3.userAuth is not in CapWords
function getAggPredval(
uint256 blocknum
uint256 blocknum,
userAuth calldata _userAuth

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

Copy link
Contributor

@trizin trizin left a comment

Choose a reason for hiding this comment

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

lgtm! Great that the user is able to query all predictoor contracts using the same signature. At first I thought about adding the contract address into the signature but that's not necessary, we're already checking if the user has a valid subscription + current implementation makes things simpler on the frontend side. 🙌

@alexcos20 alexcos20 merged commit b2fbaf1 into v2.0 Jul 10, 2023
16 checks passed
@alexcos20 alexcos20 deleted the feature/predictoor_with_auth branch July 10, 2023 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants