Skip to content

Commit

Permalink
wip: Create API binding for set_featured_communities
Browse files Browse the repository at this point in the history
  • Loading branch information
carina-akaia committed Oct 31, 2023
1 parent 16f9a7d commit b66ed9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/core/adapter/devhub-contract.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ function getFeaturedCommunities() {
);
}

const setFeaturedCommunities = ({ handles }) =>
Near.call(devHubAccountId, "set_featured_communities", { handles });

function getAccountCommunityPermissions({ account_id, community_handle }) {
return (
Near.view("${REPL_DEVHUB_CONTRACT}", "get_account_community_permissions", {
Expand Down Expand Up @@ -237,6 +240,7 @@ return {
createCommunity,
getCommunity,
getFeaturedCommunities,
setFeaturedCommunities,
getAccountCommunityPermissions,
updateCommunity,
deleteCommunity,
Expand Down
6 changes: 3 additions & 3 deletions src/devhub/page/admin.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { useQuery, hasModerator } = VM.require(
const { useQuery, hasModerator, setFeaturedCommunities } = VM.require(
"${REPL_DEVHUB}/widget/core.adapter.devhub-contract"
);

Expand Down Expand Up @@ -56,12 +56,12 @@ const featuredCommunityHandles = featuredCommunityList.map(
);

const addFeaturedCommunity = ({ handle }) =>
Near.call(devHubAccountId, "set_featured_communities", {
setFeaturedCommunities({
handles: Array.from(new Set(featuredCommunityHandles).add(handle).values()),
});

const removeFeaturedCommunity = ({ handle: input }) =>
Near.call(devHubAccountId, "set_featured_communities", {
setFeaturedCommunities({
handles: featuredCommunityHandles.filter((handle) => handle !== input),
});

Expand Down

0 comments on commit b66ed9e

Please sign in to comment.