Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Refactor SubDao (#219)
Browse files Browse the repository at this point in the history
* Inherit ISubDao

* Fix mismatch between impl. and interface in SubDao

* Add missing validation in initializeSubDao

* Use Validator where possible in SubDao

* Rename registerContract -> registerContracts

* Add back owner check in updateConfig
  • Loading branch information
Nenad Misic authored Jul 24, 2023
1 parent ab7a0a6 commit 163c087
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
3 changes: 1 addition & 2 deletions contracts/normalized_endowment/subdao/ISubDao.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ interface ISubDao {
) external;

function createPoll(
address proposer,
uint256 depositamount,
string memory title,
string memory description,
string memory link,
SubDaoStorage.ExecuteData memory executeMsgs
) external;
) external returns (uint256);

function endPoll(uint256 pollid) external;

Expand Down
29 changes: 16 additions & 13 deletions contracts/normalized_endowment/subdao/SubDao.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import {SubDaoTokenMessage} from "./../subdao-token/message.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {ISubDaoEmitter} from "./ISubDaoEmitter.sol";
import {ISubDao} from "./ISubDao.sol";
import "./Token/ERC20.sol";
import "./storage.sol";

contract SubDao is Storage, ReentrancyGuard, Initializable {
contract SubDao is ISubDao, Storage, ReentrancyGuard, Initializable {
address emitterAddress;
address accountAddress;

Expand All @@ -31,7 +32,7 @@ contract SubDao is Storage, ReentrancyGuard, Initializable {
SubDaoMessages.InstantiateMsg memory details,
address _emitterAddress
) public initializer {
require(Validator.addressChecker(_emitterAddress), "InvalidEmitterAddress");
require(Validator.addressChecker(_emitterAddress), "Invalid emitter address");
require(Validator.addressChecker(details.registrarContract), "Invalid registrarContract");
require(Validator.addressChecker(details.owner), "Invalid owner");

Expand Down Expand Up @@ -121,7 +122,10 @@ contract SubDao is Storage, ReentrancyGuard, Initializable {
details.token.token == SubDaoLib.TokenType.VeBonding &&
details.endowType == LibAccounts.EndowmentType.Charity
) {
require(registrar_config.haloToken != address(0), "Registrar's HALO token address is empty");
require(
Validator.addressChecker(registrar_config.haloToken),
"Registrar's HALO token address is empty"
);

SubDaoTokenMessage.InstantiateMsg memory temp = SubDaoTokenMessage.InstantiateMsg({
name: details.token.data.veBondingName,
Expand Down Expand Up @@ -163,19 +167,18 @@ contract SubDao is Storage, ReentrancyGuard, Initializable {
}

/**
* @notice function used to register the contract address
* @dev Register the contract address
* @param vetoken The address of the ve token contract
* @param swapfactory The address of the swap factory contract
* @notice function used to register the ve bonding token and swap factory contract addresses
* @param veToken The address of the ve bonding token contract
* @param swapFactory The address of the swap factory contract
*/
function registerContract(address vetoken, address swapfactory) external {
function registerContracts(address veToken, address swapFactory) external {
require(config.owner == msg.sender, "Unauthorized");

require(vetoken != address(0), "Invalid input");
require(swapfactory != address(0), "Invalid input");
require(Validator.addressChecker(veToken), "Invalid veToken");
require(Validator.addressChecker(swapFactory), "Invalid swapFactory");

config.veToken = vetoken;
config.swapFactory = swapfactory;
config.veToken = veToken;
config.swapFactory = swapFactory;
ISubDaoEmitter(emitterAddress).updateSubDaoConfig();
}

Expand Down Expand Up @@ -203,7 +206,7 @@ contract SubDao is Storage, ReentrancyGuard, Initializable {
) external {
require(config.owner == msg.sender, "Unauthorized");

if (owner != address(0)) {
if (Validator.addressChecker(owner)) {
config.owner = owner;
}

Expand Down

0 comments on commit 163c087

Please sign in to comment.