-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45d78e3
commit 6c588b7
Showing
4 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.0; | ||
|
||
library SigUtils { | ||
struct Delegation { | ||
address delegatee; | ||
uint256 nonce; | ||
uint256 expiry; | ||
} | ||
|
||
bytes32 private constant DELEGATION_TYPEHASH = | ||
keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); | ||
|
||
/// @dev Computes the hash of the EIP-712 encoded data. | ||
function getTypedDataHash(Delegation memory delegation) public pure returns (bytes32) { | ||
return keccak256(bytes.concat("\x19\x01", hashStruct(delegation))); | ||
} | ||
|
||
function hashStruct(Delegation memory delegation) internal pure returns (bytes32) { | ||
return keccak256(abi.encode(DELEGATION_TYPEHASH, delegation.delegatee, delegation.nonce, delegation.expiry)); | ||
} | ||
} |