Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
at main 36 lines 1.1 kB view raw
1import { PERMISSIONS } from "@hey/data/constants"; 2import type { Context } from "hono"; 3import handleApiError from "@/utils/handleApiError"; 4import lensPg from "@/utils/lensPg"; 5import syncAddressesToGuild from "@/utils/syncAddressesToGuild"; 6 7// Sync accounts that have current beta status 8const syncBetaMembersToGuild = async (ctx: Context) => { 9 try { 10 const accounts = (await lensPg.query( 11 ` 12 SELECT DISTINCT ksw.owned_by 13 FROM account.known_smart_wallet ksw 14 INNER JOIN "group"."member" AS member ON ksw.address = member.account 15 WHERE member."group" = $1; 16 `, 17 [`\\x${PERMISSIONS.BETA.replace("0x", "").toLowerCase()}`] 18 )) as Array<{ owned_by: Buffer }>; 19 20 const addresses = accounts.map((account) => 21 `0x${account.owned_by.toString("hex")}`.toLowerCase() 22 ); 23 24 const data = await syncAddressesToGuild({ 25 addresses, 26 requirementId: 479578, 27 roleId: 177898 28 }); 29 30 return ctx.json(data); 31 } catch (error) { 32 return handleApiError(ctx, error); 33 } 34}; 35 36export default syncBetaMembersToGuild;