Skip to content

Commit

Permalink
added L1 and L2 badges
Browse files Browse the repository at this point in the history
  • Loading branch information
n13 committed Oct 24, 2023
1 parent 141d589 commit 63739a7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
4 changes: 4 additions & 0 deletions include/badges/badges.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ bool hasHeadDelegateBadge(dao& dao, uint64_t daoID, uint64_t memberID);

bool hasChiefDelegateBadge(dao& dao, uint64_t daoID, uint64_t memberID);

bool hasL1DelegateBadge(dao& dao, uint64_t daoID, uint64_t memberID);

bool hasL2DelegateBadge(dao& dao, uint64_t daoID, uint64_t memberID);

void checkHoldsBadge(dao& dao, Document& badge, uint64_t daoID, uint64_t memberID);

//bool isPeriodBased(Document& badge);
Expand Down
4 changes: 4 additions & 0 deletions include/badges/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ enum class SystemBadgeType
ChiefDelegate,
HeadDelegate,
None,
L1Delegate,
L2Delegate, // note only append to this list
};

namespace items {
Expand All @@ -37,6 +39,8 @@ namespace links {
inline constexpr auto DELEGATE = eosio::name("delegate");
inline constexpr auto HEAD_DELEGATE = eosio::name("headdelegate");
inline constexpr auto CHIEF_DELEGATE = eosio::name("chiefdelegate");
inline constexpr auto L1_DELEGATE = eosio::name("l1.delegate");
inline constexpr auto L2_DELEGATE = eosio::name("l2.delegate");
}

}
26 changes: 25 additions & 1 deletion src/badges/badges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ void onBadgeActivated(dao& dao, RecurringActivity& badgeAssign)
case SystemBadgeType::ChiefDelegate: {
createLink(badges_links::CHIEF_DELEGATE);
} break;
case SystemBadgeType::L1Delegate: {
createLink(badges_links::L1_DELEGATE);
} break;
case SystemBadgeType::L2Delegate: {
createLink(badges_links::L2_DELEGATE);
} break;
default:
EOS_CHECK(false, "Invalid system badge type");
break;
Expand Down Expand Up @@ -213,6 +219,12 @@ void onBadgeArchived(dao& dao, RecurringActivity& badgeAssign)
case SystemBadgeType::ChiefDelegate: {
removeLink(badges_links::CHIEF_DELEGATE);
} break;
case SystemBadgeType::L1Delegate: {
removeLink(badges_links::L1_DELEGATE);
} break;
case SystemBadgeType::L2Delegate: {
removeLink(badges_links::L2_DELEGATE);
} break;
default:
EOS_CHECK(false, "Invalid system badge type");
break;
Expand Down Expand Up @@ -271,6 +283,16 @@ bool hasChiefDelegateBadge(dao& dao, uint64_t daoID, uint64_t memberID)
return Edge::exists(dao.get_self(), daoID, memberID, badges_links::CHIEF_DELEGATE);
}

bool hasL1DelegateBadge(dao& dao, uint64_t daoID, uint64_t memberID)
{
return Edge::exists(dao.get_self(), daoID, memberID, badges_links::L1_DELEGATE);
}

bool hasL2DelegateBadge(dao& dao, uint64_t daoID, uint64_t memberID)
{
return Edge::exists(dao.get_self(), daoID, memberID, badges_links::L2_DELEGATE);
}

bool isSelfApproveBadge(SystemBadgeType systemType)
{

Expand Down Expand Up @@ -303,7 +325,9 @@ void checkHoldsBadge(dao& dao, Document& badge, uint64_t daoID, uint64_t memberI
{ SystemBadgeType::Voter, hasVoterBadge },
{ SystemBadgeType::Delegate, hasDelegateBadge },
{ SystemBadgeType::HeadDelegate, hasHeadDelegateBadge },
{ SystemBadgeType::ChiefDelegate, hasChiefDelegateBadge }
{ SystemBadgeType::ChiefDelegate, hasChiefDelegateBadge },
{ SystemBadgeType::L1Delegate, hasL1DelegateBadge },
{ SystemBadgeType::L2Delegate, hasL2DelegateBadge }
};

EOS_CHECK(
Expand Down
12 changes: 9 additions & 3 deletions src/dao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,11 +1367,13 @@ void dao::initSysBadges() {

createSystemBadge(badges::common::links::ADMIN_BADGE, "Admin Badge", "https://assets.hypha.earth/badges/badge_admin.png");
createSystemBadge(badges::common::links::ENROLLER_BADGE, "Enroller Badge", "https://assets.hypha.earth/badges/badge_enroller.png");
createSystemBadge(badges::common::links::TREASURY_BADGE, "Treasurer Badge", "https://assets.hypha.earth/badges/badge_treasurer.png");
createSystemBadge(badges::common::links::NORTH_STAR_BADGE, "North Star Badge", "https://assets.hypha.earth/badges/badge_north_star.png");
createSystemBadge(badges::common::links::DELEGATE, "Upvote Delegate Badge", "");
createSystemBadge(badges::common::links::CHIEF_DELEGATE, "Chief Delegate Badge", "");
createSystemBadge(badges::common::links::HEAD_DELEGATE, "Head Delegate Badge", "");
createSystemBadge(badges::common::links::TREASURY_BADGE, "Treasurer Badge", "https://assets.hypha.earth/badges/badge_treasurer.png");
createSystemBadge(badges::common::links::NORTH_STAR_BADGE, "North Star Badge", "https://assets.hypha.earth/badges/badge_north_star.png");
createSystemBadge(badges::common::links::L1_DELEGATE, "L1 Delegate Badge", "");
createSystemBadge(badges::common::links::L2_DELEGATE, "L2 Delegate Badge", "");

}

Expand All @@ -1392,6 +1394,10 @@ void dao::createSystemBadge(name badge_edge, string label, string icon) {
systemBadgeType = badges::SystemBadgeType::ChiefDelegate;
} else if (badge_edge == badges::common::links::HEAD_DELEGATE) {
systemBadgeType = badges::SystemBadgeType::HeadDelegate;
} else if (badge_edge == badges::common::links::L1_DELEGATE) {
systemBadgeType = badges::SystemBadgeType::L1Delegate;
} else if (badge_edge == badges::common::links::L2_DELEGATE) {
systemBadgeType = badges::SystemBadgeType::L2Delegate;
} else {
eosio::check(false, "unknown system type");
}
Expand Down Expand Up @@ -3512,7 +3518,7 @@ void dao::readDaoSettings(uint64_t daoID, const name& dao, ContentWrapper config

void dao::reset() {

eosio::check(false, "reset is only for testing");
// eosio::check(false, "reset is only for testing");

require_auth(_self);

Expand Down

0 comments on commit 63739a7

Please sign in to comment.