-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add signature generation test helper and changed importing directory,…
… remappings.
- Loading branch information
1 parent
5c77691
commit 37c2033
Showing
8 changed files
with
93 additions
and
16 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ | ||
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/ | ||
ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/ | ||
erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/ | ||
forge-std/=lib/forge-std/src/ | ||
@openzeppelin/openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src | ||
@openzeppelin/upgradeable/lib=lib/openzeppelin-contracts-upgradeable/lib/ | ||
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/ | ||
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ | ||
ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/ | ||
erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/ | ||
openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/ | ||
openzeppelin-contracts/=lib/openzeppelin-contracts/ | ||
openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/ | ||
solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ pragma solidity ^0.8.20; | |
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; | ||
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; | ||
import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; | ||
import {ERC20Permit, Nonces} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; | ||
import {ERC20Votes} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol"; | ||
|
||
/// @custom:security-contact [email protected] | ||
|
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
38 changes: 38 additions & 0 deletions
38
test/integration/utils/VotingPowerExchangeTestHelper.t.sol
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,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import {DeployContracts, DeploymentResult} from "script/DeployContracts.s.sol"; | ||
import {Test, console} from "forge-std/Test.sol"; | ||
|
||
import {VotingPowerExchange} from "src/VotingPowerExchange.sol"; | ||
|
||
contract VotingPowerExchangeTestHelper is Test { | ||
bytes32 private constant _EXCHANGE_TYPEHASH = | ||
keccak256("Exchange(address sender,uint256 amount,bytes32 nonce,uint256 expiration)"); | ||
|
||
function generateSignatureFromPrivateKey(uint256 privateKey, uint256 amount, uint256 nonce, uint256 expiration) | ||
public | ||
view | ||
returns (bytes memory) | ||
{ | ||
address sender = address(uint160(privateKey)); | ||
bytes32 structHash = keccak256(abi.encode(_EXCHANGE_TYPEHASH, sender, amount, nonce, expiration)); | ||
|
||
bytes32 domainSeparator = keccak256( | ||
abi.encode( | ||
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), | ||
keccak256(bytes("VotingPowerExchange")), | ||
keccak256(bytes("1")), | ||
block.chainid, | ||
address(this) | ||
) | ||
); | ||
|
||
bytes32 hash = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); | ||
|
||
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, hash); | ||
|
||
return abi.encodePacked(r, s, v); | ||
} | ||
} |
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