mirror of
https://github.com/status-im/contracts.git
synced 2025-02-23 12:08:47 +00:00
encapstulate message hashing as views
This commit is contained in:
parent
6fbb3b703a
commit
3ac4be7bbd
@ -69,9 +69,7 @@ contract MessageTribute is MessageSigned {
|
||||
require(_timeLimit <= block.timestamp);
|
||||
address grantor = recoverAddress(
|
||||
getSignHash(
|
||||
keccak256(
|
||||
address(this),
|
||||
bytes4(keccak256("grantAudience(bytes32,bool,bool,bytes32)")),
|
||||
getGrantAudienceHash(
|
||||
keccak256(_requesterSignature),
|
||||
_approve,
|
||||
_waive,
|
||||
@ -86,9 +84,7 @@ contract MessageTribute is MessageSigned {
|
||||
granted[hashedSecret] = true;
|
||||
address requester = recoverAddress(
|
||||
getSignHash(
|
||||
keccak256(
|
||||
address(this),
|
||||
bytes4(keccak256("requestAudience(address,bytes32,uint256)")),
|
||||
getRequestAudienceHash(
|
||||
grantor,
|
||||
hashedSecret,
|
||||
_timeLimit
|
||||
@ -96,6 +92,7 @@ contract MessageTribute is MessageSigned {
|
||||
),
|
||||
_requesterSignature
|
||||
);
|
||||
|
||||
require(lastAudienceDeniedTimestamp[grantor][requester] + 3 days <= now);
|
||||
if(!_approve)
|
||||
lastAudienceDeniedTimestamp[grantor][requester] = block.timestamp;
|
||||
@ -111,6 +108,44 @@ contract MessageTribute is MessageSigned {
|
||||
emit AudienceGranted(grantor, requester, _approve);
|
||||
}
|
||||
|
||||
function getGrantAudienceHash(
|
||||
bytes32 _requesterSignatureHash,
|
||||
bool _approve,
|
||||
bool _waive,
|
||||
bytes32 _secret
|
||||
)
|
||||
public
|
||||
view
|
||||
returns(bytes32)
|
||||
{
|
||||
return keccak256(
|
||||
address(this),
|
||||
bytes4(keccak256("grantAudience(bytes32,bool,bool,bytes32)")),
|
||||
_requesterSignatureHash,
|
||||
_approve,
|
||||
_waive,
|
||||
_secret
|
||||
);
|
||||
}
|
||||
|
||||
function getRequestAudienceHash(
|
||||
address grantor,
|
||||
bytes32 hashedSecret,
|
||||
uint _timeLimit
|
||||
)
|
||||
public
|
||||
view
|
||||
returns(bytes32)
|
||||
{
|
||||
return keccak256(
|
||||
address(this),
|
||||
bytes4(keccak256("requestAudience(address,bytes32,uint256)")),
|
||||
grantor,
|
||||
hashedSecret,
|
||||
_timeLimit
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Determine if msg.sender ha enough funds to chat with `_to`
|
||||
* @param _to Account `msg.sender` wishes to talk to
|
||||
|
Loading…
x
Reference in New Issue
Block a user