MCPcopy Create free account
hub / github.com/dailydotdev/apps / squadWalletQueryOptions

Function squadWalletQueryOptions

packages/shared/src/graphql/squadWallet.ts:44–76  ·  view source on GitHub ↗
({
  user,
  sourceId,
}: {
  user?: Pick<LoggedUser, 'id'>;
  sourceId?: string;
})

Source from the content-addressed store, hash-verified

42}
43
44export const squadWalletQueryOptions = ({
45 user,
46 sourceId,
47}: {
48 user?: Pick<LoggedUser, 'id'>;
49 sourceId?: string;
50}) => ({
51 queryKey: generateQueryKey(RequestKey.SquadWallet, user, sourceId),
52 queryFn: async (): Promise<SquadWallet | null> => {
53 try {
54 const { source, squadSubscription } =
55 await gqlClient.request<SquadWalletData>(SQUAD_WALLET_QUERY, {
56 sourceId,
57 });
58
59 // only the paid seats of an active plan can spend it
60 if (!squadSubscription.plan || !source.currentMember?.seat) {
61 return null;
62 }
63
64 return {
65 sourceId: source.id,
66 name: source.name,
67 handle: source.handle,
68 balance: squadSubscription.coresBalance,
69 };
70 } catch {
71 // the subscription is only visible to squad admins and moderators
72 return null;
73 }
74 },
75 enabled: !!user?.id && !!sourceId,
76});

Callers 1

useBoostWalletFunction · 0.90

Calls 1

generateQueryKeyFunction · 0.90

Tested by

no test coverage detected