-
Notifications
You must be signed in to change notification settings - Fork 9
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
59e8249
commit 4a5125b
Showing
5 changed files
with
241 additions
and
4 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
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,25 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {BaseTest} from "./helpers/BaseTest.sol"; | ||
|
||
// TODO: Test the following: | ||
// - Test migration flow | ||
// - Test bundler wrapping | ||
contract MorphoTokenMigrationTest is BaseTest { | ||
uint256 internal forkId; | ||
|
||
function setUp() public virtual override { | ||
// DEPLOYMENTS | ||
_fork(); | ||
super.setUp(); | ||
} | ||
|
||
function _fork() internal virtual { | ||
string memory rpcUrl = vm.rpcUrl("ethereum"); | ||
uint256 forkBlockNumber = 20969715; | ||
|
||
forkId = vm.createSelectFork(rpcUrl, forkBlockNumber); | ||
vm.chainId(1); | ||
} | ||
} |
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,54 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {Test, console} from "lib/forge-std/src/Test.sol"; | ||
import {MorphoToken} from "../../src/MorphoToken.sol"; | ||
import {Wrapper} from "../../src/Wrapper.sol"; | ||
import {ERC1967Proxy} from | ||
"lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import {UUPSUpgradeable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol"; | ||
|
||
// TODO: Test the following: | ||
// - Test every paths | ||
// - Test migration flow | ||
// - Test bundler wrapping | ||
// - Test access control | ||
// - Test voting | ||
// - Test delegation | ||
contract BaseTest is Test { | ||
address public constant MORPHO_DAO = 0xcBa28b38103307Ec8dA98377ffF9816C164f9AFa; | ||
|
||
MorphoToken public tokenImplem; | ||
MorphoToken public newMorpho; | ||
ERC1967Proxy public tokenProxy; | ||
Wrapper public wrapper; | ||
|
||
uint256 internal constant MIN_TEST_AMOUNT = 100; | ||
uint256 internal constant MAX_TEST_AMOUNT = 1e28; | ||
|
||
function setUp() public virtual { | ||
// DEPLOYMENTS | ||
tokenImplem = new MorphoToken(); | ||
tokenProxy = new ERC1967Proxy(address(tokenImplem), hex""); | ||
wrapper = new Wrapper(address(tokenProxy)); | ||
|
||
newMorpho = MorphoToken(payable(address(tokenProxy))); | ||
newMorpho.initialize(MORPHO_DAO, address(wrapper)); | ||
} | ||
|
||
function _validateAddresses(address[] memory addresses) internal pure { | ||
for (uint256 i = 0; i < addresses.length; i++) { | ||
vm.assume(addresses[i] != address(0)); | ||
vm.assume(addresses[i] != MORPHO_DAO); | ||
for (uint256 j = i + 1; j < addresses.length; j++) { | ||
vm.assume(addresses[i] != addresses[j]); | ||
} | ||
} | ||
} | ||
|
||
struct Signature { | ||
uint8 v; | ||
bytes32 r; | ||
bytes32 s; | ||
} | ||
} |
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)); | ||
} | ||
} |