From 03ab532c4c8a37b7caabf3aea4551be6f99f5e2f Mon Sep 17 00:00:00 2001 From: Jean-Grimal <83286814+Jean-Grimal@users.noreply.github.com> Date: Fri, 11 Oct 2024 17:48:45 +0200 Subject: [PATCH] fix: imports --- .../DelegatesUpgradeable.sol | 13 +++---- src/DelegatesContracts/IDelegates.sol | 39 +++++++++++++++++++ 2 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 src/DelegatesContracts/IDelegates.sol diff --git a/src/DelegatesContracts/DelegatesUpgradeable.sol b/src/DelegatesContracts/DelegatesUpgradeable.sol index 75ae405..29a6ff0 100644 --- a/src/DelegatesContracts/DelegatesUpgradeable.sol +++ b/src/DelegatesContracts/DelegatesUpgradeable.sol @@ -2,12 +2,11 @@ pragma solidity ^0.8.20; -import {IVotes} from - "lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/governance/utils/IVotes.sol"; +import {IDelegates} from "./IDelegates.sol"; import {ECDSA} from - "lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts//contracts/utils/cryptography/ECDSA.sol"; -import {ContextUpgradeable} from "lib/openzeppelin-contracts-upgradeable/contracts//utils/ContextUpgradeable.sol"; -import {NoncesUpgradeable} from "lib/openzeppelin-contracts-upgradeable/contracts//utils/NoncesUpgradeable.sol"; + "lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol"; +import {ContextUpgradeable} from "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol"; +import {NoncesUpgradeable} from "lib/openzeppelin-contracts-upgradeable/contracts/utils/NoncesUpgradeable.sol"; import {EIP712Upgradeable} from "lib/openzeppelin-contracts-upgradeable/contracts/utils/cryptography/EIP712Upgradeable.sol"; import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"; @@ -17,7 +16,7 @@ abstract contract DelegatesUpgradeable is ContextUpgradeable, EIP712Upgradeable, NoncesUpgradeable, - IVotes + IDelegates { bytes32 private constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); @@ -79,7 +78,7 @@ abstract contract DelegatesUpgradeable is virtual { if (block.timestamp > expiry) { - revert VotesExpiredSignature(expiry); + revert DelegatesExpiredSignature(expiry); } address signer = ECDSA.recover( _hashTypedDataV4(keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry))), v, r, s diff --git a/src/DelegatesContracts/IDelegates.sol b/src/DelegatesContracts/IDelegates.sol new file mode 100644 index 0000000..a3d734e --- /dev/null +++ b/src/DelegatesContracts/IDelegates.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +interface IDelegates { + /** + * @dev The signature used has expired. + */ + error DelegatesExpiredSignature(uint256 expiry); + + /** + * @dev Emitted when an account changes their delegate. + */ + event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); + + /** + * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of voting units. + */ + event DelegateVotesChanged(address indexed delegate, uint256 previousVotes, uint256 newVotes); + + /** + * @dev Returns the current amount of votes that `account` has. + */ + function getVotes(address account) external view returns (uint256); + + /** + * @dev Returns the delegate that `account` has chosen. + */ + function delegates(address account) external view returns (address); + + /** + * @dev Delegates votes from the sender to `delegatee`. + */ + function delegate(address delegatee) external; + + /** + * @dev Delegates votes from signer to `delegatee`. + */ + function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external; +}