Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
1import { createGuildClient, createSigner } from "@guildxyz/sdk";
2import { Status } from "@hey/data/enums";
3import { withPrefix } from "@hey/helpers/logger";
4import signer from "./signer";
5
6const guildClient = createGuildClient("heyxyz");
7const signerFunction = createSigner.custom(
8 (message) => signer.signMessage({ message }),
9 signer.account.address
10);
11const {
12 guild: {
13 role: { requirement: requirementClient }
14 }
15} = guildClient;
16
17const syncAddressesToGuild = async ({
18 addresses,
19 requirementId,
20 roleId
21}: {
22 addresses: string[];
23 requirementId: number;
24 roleId: number;
25}) => {
26 const log = withPrefix("[API]");
27 requirementClient
28 .update(
29 7465,
30 roleId,
31 requirementId,
32 { data: { addresses, hideAllowlist: true }, visibility: "PUBLIC" },
33 signerFunction
34 )
35 .then(() => {
36 log.info("Guild sync completed");
37 })
38 .catch((error) => {
39 log.error("Guild sync failed:", error);
40 });
41
42 return {
43 status: Status.Success,
44 total: addresses.length,
45 updatedAt: new Date().toISOString()
46 };
47};
48
49export default syncAddressesToGuild;