Skip to content

Commit

Permalink
Merge branch 'develop' into feature/upvote_3_merge
Browse files Browse the repository at this point in the history
  • Loading branch information
n13 committed Oct 26, 2023
2 parents 7056daf + 20d275a commit 2c2d4e7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/dao.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ namespace pricing {

ACTION remdoc(uint64_t doc_id);

ACTION cleandao(uint64_t dao_id);

ACTION createcalen(bool is_default);

ACTION initcalendar(uint64_t calendar_id, uint64_t next_period);
Expand Down
33 changes: 33 additions & 0 deletions src/dao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,39 @@ void dao::remedge(uint64_t from_node, uint64_t to_node, name edge_name)
Edge::get(get_self(), from_node, to_node, edge_name).erase();
}

void dao::cleandao(uint64_t dao_id)
{
//Remove DAO entries from 'daos' and 'tokentodao' tables
eosio::require_auth(get_self());

auto daoDoc = TypedDocument::withType(*this, dao_id, common::DAO);

auto cw = daoDoc.getContentWrapper();

auto name = cw.getOrFail(DETAILS, DAO_NAME)->getAs<eosio::name>();

remNameID<dao_table>(name);

token_to_dao_table tok_t(get_self(), get_self().value);

auto by_id = tok_t.get_index<"bydocid"_n>();
auto idIt = by_id.find(dao_id);

if (idIt != by_id.end()){
by_id.erase(idIt);
}

auto voiceContract = getSettingOrFail<eosio::name>(GOVERNANCE_TOKEN_CONTRACT);

//delete voice token, reward and peg tokens are not deletable ATM
eosio::action(
eosio::permission_level(get_self(), eosio::name("active")),
voiceContract,
eosio::name("del"),
std::make_tuple(name, asset{0, symbol{"VOICE", 2}})
).send();
}

void dao::remdoc(uint64_t doc_id)
{
eosio::require_auth(get_self());
Expand Down

0 comments on commit 2c2d4e7

Please sign in to comment.