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

Refactor SubDao #219

Merged
merged 6 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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