Skip to content

Commit

Permalink
Add natspec
Browse files Browse the repository at this point in the history
  • Loading branch information
cristovaoth committed Sep 28, 2023
1 parent 5fff34e commit 0167e0b
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion contracts/signature/Eip712Signature.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.0 <0.9.0;

/// @title EIP712Signature - A contract that extracts and inspects EIP-712 signatures appended to calldata.

abstract contract EIP712Signature {
uint256 private nonce;

function eip712Nonce() public view returns (uint256 signed) {
/**
* @dev Returns the current nonce value.
*/
function eip712Nonce() public view returns (uint256) {
return nonce;
}

/**
* @dev Increments nonce.
*/
function eip712BumpNonce() internal {
nonce = nonce + 1;
}

/**
* @dev When signature present, returns the signer address.
*/
function eip712SignedBy() internal returns (address signer) {
if (msg.data.length >= 4 + 65) {
(
Expand All @@ -27,6 +38,10 @@ abstract contract EIP712Signature {
}
}

/**
* @dev Extracts signature from calldata, and divides it into `uint8 v, bytes32 r, bytes32 s`.
* @param data current transaction calldata.
*/
function _splitSignature(
bytes calldata data
)
Expand All @@ -41,6 +56,12 @@ abstract contract EIP712Signature {
v = uint8(bytes1(data[length - 1:]));
}

/**
* @dev Hashes the EIP-712 data structure that will be signed by owner.
* @param data The data for the transaction.
* @param _nonce The nonce value.
* @return the bytes32 hash to be signed by owners.
*/
function _transactionHash(
bytes calldata data,
uint256 _nonce
Expand Down

0 comments on commit 0167e0b

Please sign in to comment.