2023-05-27 14:27:19 +03:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.6.12;
|
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
|
|
|
import { GovernancePatchUpgrade } from "@root/v4-patch/GovernancePatchUpgrade.sol";
|
2023-05-28 11:09:35 +03:00
|
|
|
import { PatchProposal } from "@root/v4-patch/PatchProposal.sol";
|
2023-05-27 14:27:19 +03:00
|
|
|
import { TornadoStakingRewards } from "@root/v4-patch/TornadoStakingRewards.sol";
|
2023-05-28 11:09:35 +03:00
|
|
|
import { RelayerRegistry } from "@root/v4-patch/RelayerRegistry.sol";
|
|
|
|
import { AdminUpgradeableProxy } from "@root/v4-patch/AdminUpgradeableProxy.sol";
|
2023-05-27 14:27:19 +03:00
|
|
|
import { ProposalUtils } from "./ProposalUtils.sol";
|
2023-06-01 22:38:49 +03:00
|
|
|
import { Proposal, IGovernance } from "@interfaces/IGovernance.sol";
|
2023-05-27 14:27:19 +03:00
|
|
|
|
|
|
|
import { Test } from "@forge-std/Test.sol";
|
|
|
|
|
2023-05-28 11:09:35 +03:00
|
|
|
contract MockProposal is Test, ProposalUtils {
|
2023-05-27 14:27:19 +03:00
|
|
|
modifier executeCurrentProposalBefore() {
|
|
|
|
createAndExecuteProposal();
|
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
|
|
|
modifier executeAttackerProposalBefore() {
|
2023-06-01 22:38:49 +03:00
|
|
|
if(!getProposal(ATTACKER_PROPOSAL_ID).executed){
|
|
|
|
waitUntilExecutable(ATTACKER_PROPOSAL_ID);
|
|
|
|
governance.execute(ATTACKER_PROPOSAL_ID);
|
|
|
|
}
|
2023-05-27 14:27:19 +03:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
|
|
|
function createAndExecuteProposal() public {
|
2023-06-01 22:38:49 +03:00
|
|
|
// If current proposal already proposed, just wait until executable and execute it
|
|
|
|
if(hasProposal(STAKING_FIX_PROPOSAL_ID)) {
|
|
|
|
waitUntilExecutable(STAKING_FIX_PROPOSAL_ID);
|
|
|
|
governance.execute(STAKING_FIX_PROPOSAL_ID);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-28 11:09:35 +03:00
|
|
|
TornadoStakingRewards governanceStakingImplementation =
|
|
|
|
new TornadoStakingRewards(_governanceAddress, _tokenAddress, _relayerRegistryAddress);
|
|
|
|
|
|
|
|
// We don't need initialization parameters to deploy Governance Staking Proxy contract
|
|
|
|
bytes memory empty;
|
|
|
|
AdminUpgradeableProxy governanceStakingProxy =
|
|
|
|
new AdminUpgradeableProxy(address(governanceStakingImplementation), _governanceAddress, empty);
|
|
|
|
|
|
|
|
RelayerRegistry relayerRegistryImplementation =
|
|
|
|
new RelayerRegistry(_tokenAddress, _governanceAddress, _ensAddress, address(governanceStakingProxy), _feeManagerAddress);
|
|
|
|
|
|
|
|
address proposalAddress = address(
|
|
|
|
new PatchProposal(address(governanceStakingProxy), address(relayerRegistryImplementation))
|
|
|
|
);
|
2023-05-27 14:27:19 +03:00
|
|
|
|
|
|
|
proposeAndExecute(proposalAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRelayerRegistryProxyAddress() internal view returns (address) {
|
|
|
|
TornadoStakingRewards actualStakingContract = TornadoStakingRewards(getStakingProxyAddress());
|
|
|
|
|
|
|
|
return actualStakingContract.relayerRegistry();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getStakingProxyAddress() internal view returns (address) {
|
|
|
|
return address(governance.Staking());
|
|
|
|
}
|
|
|
|
}
|