@tetsuo-ai/marketplace-react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE +21 -0
  3. package/README.md +172 -0
  4. package/dist/chunk-5OTKSRHM.js +128 -0
  5. package/dist/chunk-5OTKSRHM.js.map +1 -0
  6. package/dist/chunk-ABS77JB2.js +94 -0
  7. package/dist/chunk-ABS77JB2.js.map +1 -0
  8. package/dist/chunk-GN5DYVN5.js +35 -0
  9. package/dist/chunk-GN5DYVN5.js.map +1 -0
  10. package/dist/chunk-KJMR6OGC.js +1198 -0
  11. package/dist/chunk-KJMR6OGC.js.map +1 -0
  12. package/dist/chunk-YORZNYZZ.js +107 -0
  13. package/dist/chunk-YORZNYZZ.js.map +1 -0
  14. package/dist/components/agenc-components.css +570 -0
  15. package/dist/components/index.cjs +1335 -0
  16. package/dist/components/index.cjs.map +1 -0
  17. package/dist/components/index.d.cts +5 -0
  18. package/dist/components/index.d.ts +5 -0
  19. package/dist/components/index.js +5 -0
  20. package/dist/components/index.js.map +1 -0
  21. package/dist/hooks/index.cjs +493 -0
  22. package/dist/hooks/index.cjs.map +1 -0
  23. package/dist/hooks/index.d.cts +294 -0
  24. package/dist/hooks/index.d.ts +294 -0
  25. package/dist/hooks/index.js +339 -0
  26. package/dist/hooks/index.js.map +1 -0
  27. package/dist/index-BLrlBVj-.d.cts +1129 -0
  28. package/dist/index-CKTYsNPH.d.ts +1129 -0
  29. package/dist/index.cjs +1690 -0
  30. package/dist/index.cjs.map +1 -0
  31. package/dist/index.d.cts +235 -0
  32. package/dist/index.d.ts +235 -0
  33. package/dist/index.js +127 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/signers/index.cjs +166 -0
  36. package/dist/signers/index.cjs.map +1 -0
  37. package/dist/signers/index.d.cts +136 -0
  38. package/dist/signers/index.d.ts +136 -0
  39. package/dist/signers/index.js +4 -0
  40. package/dist/signers/index.js.map +1 -0
  41. package/dist/testing/index.cjs +62 -0
  42. package/dist/testing/index.cjs.map +1 -0
  43. package/dist/testing/index.d.cts +71 -0
  44. package/dist/testing/index.d.ts +71 -0
  45. package/dist/testing/index.js +60 -0
  46. package/dist/testing/index.js.map +1 -0
  47. package/dist/theme/agenc-tailwind-preset.cjs +184 -0
  48. package/dist/theme/agenc-tokens.css +132 -0
  49. package/dist/types-jvISR6bc.d.cts +135 -0
  50. package/dist/types-jvISR6bc.d.ts +135 -0
  51. package/dist/useAgentTrackRecord-BLf1nrbu.d.cts +249 -0
  52. package/dist/useAgentTrackRecord-BLf1nrbu.d.ts +249 -0
  53. package/package.json +139 -0
  54. package/src/components/DisputeBanner.stories.tsx +39 -0
  55. package/src/components/DisputeBanner.tsx +110 -0
  56. package/src/components/HireButton.stories.tsx +72 -0
  57. package/src/components/HireButton.tsx +151 -0
  58. package/src/components/HireCheckoutModal.stories.tsx +107 -0
  59. package/src/components/HireCheckoutModal.tsx +284 -0
  60. package/src/components/ListingCard.stories.tsx +55 -0
  61. package/src/components/ListingCard.tsx +148 -0
  62. package/src/components/ListingGrid.stories.tsx +44 -0
  63. package/src/components/ListingGrid.tsx +137 -0
  64. package/src/components/Modal.tsx +121 -0
  65. package/src/components/PoweredByAgenC.tsx +85 -0
  66. package/src/components/ProviderCard.stories.tsx +61 -0
  67. package/src/components/ProviderCard.tsx +154 -0
  68. package/src/components/ReferrerDisclosure.tsx +67 -0
  69. package/src/components/ReviewPanel.stories.tsx +65 -0
  70. package/src/components/ReviewPanel.tsx +141 -0
  71. package/src/components/TaskTimeline.stories.tsx +43 -0
  72. package/src/components/TaskTimeline.tsx +156 -0
  73. package/src/components/__fixtures__/index.tsx +173 -0
  74. package/src/components/agenc-components.css +570 -0
  75. package/src/components/badges.tsx +115 -0
  76. package/src/components/format.ts +150 -0
  77. package/src/components/index.ts +102 -0
  78. package/src/components/primitives.tsx +236 -0
  79. package/src/components/strings.ts +131 -0
  80. package/src/components/useFocusTrap.ts +122 -0
  81. package/src/hooks/index.ts +90 -0
  82. package/src/hooks/internal.ts +70 -0
  83. package/src/hooks/useAgentTrackRecord.ts +166 -0
  84. package/src/hooks/useDispute.ts +130 -0
  85. package/src/hooks/useHire.ts +198 -0
  86. package/src/hooks/useListing.ts +138 -0
  87. package/src/hooks/useListings.ts +133 -0
  88. package/src/hooks/useReferrerEarnings.ts +134 -0
  89. package/src/hooks/useSubmissionReview.ts +179 -0
  90. package/src/hooks/useTaskStatus.ts +192 -0
  91. package/src/hooks/useWalletSigner.ts +99 -0
  92. package/src/index.ts +170 -0
  93. package/src/provider/AgencProvider.tsx +169 -0
  94. package/src/provider/context.ts +35 -0
  95. package/src/provider/index.ts +17 -0
  96. package/src/provider/network.ts +68 -0
  97. package/src/provider/referrer.ts +97 -0
  98. package/src/signers/README.md +130 -0
  99. package/src/signers/embedded-wallet-mock.ts +158 -0
  100. package/src/signers/embedded-wallet.ts +64 -0
  101. package/src/signers/index.ts +48 -0
  102. package/src/signers/strings.ts +39 -0
  103. package/src/signers/types.ts +158 -0
  104. package/src/signers/wallet-account.ts +128 -0
  105. package/src/signers/wallet-adapter.ts +149 -0
  106. package/src/strings/index.ts +119 -0
  107. package/src/testing/index.ts +24 -0
  108. package/src/theme/agenc-tailwind-preset.cjs +184 -0
  109. package/src/theme/agenc-tokens.css +132 -0
  110. package/src/theme/index.ts +94 -0
  111. package/src/transport/index.ts +164 -0
  112. package/src/types.ts +224 -0
@@ -0,0 +1,493 @@
1
+ 'use strict';
2
+
3
+ var reactQuery = require('@tanstack/react-query');
4
+ var react = require('react');
5
+ require('@solana/kit');
6
+ var marketplaceSdk = require('@tetsuo-ai/marketplace-sdk');
7
+
8
+ // src/hooks/useListings.ts
9
+
10
+ // src/strings/index.ts
11
+ var EN_STRINGS = {
12
+ // Provider / context wiring errors (developer-facing, but routed for parity).
13
+ "provider.missingContext": "useAgencContext must be used within <AgencProvider>.",
14
+ "provider.missingWriteClient": "No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.",
15
+ "provider.missingSigner": "No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.",
16
+ // Referrer config validation (the P6.2 gate surface).
17
+ "referrer.invalidWallet": "Referrer wallet is not a valid base58 Solana address: {wallet}.",
18
+ "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
19
+ "referrer.notLive": "This site earns a referral fee (pending protocol support).",
20
+ "referrer.notLiveReason": "Referral settlement is not yet deployed on this cluster (PLAN.md P6.2). Referrer config is accepted and validated but not injected into hires.",
21
+ // Read transport.
22
+ "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
23
+ // Generic loading / empty / error states (components extend these).
24
+ "state.loading": "Loading\u2026",
25
+ "state.empty": "Nothing to show yet.",
26
+ "state.error": "Something went wrong.",
27
+ // Hire flow shells (components fill out the rest).
28
+ "hire.cta": "Hire",
29
+ "hire.pending": "Confirming\u2026",
30
+ "hire.funded": "Escrow funded."
31
+ };
32
+ function t(id, vars, options) {
33
+ const catalog = options?.catalog ?? EN_STRINGS;
34
+ const template = catalog[id] ?? id;
35
+ return template;
36
+ }
37
+
38
+ // src/provider/context.ts
39
+ var AgencContext = react.createContext(null);
40
+ AgencContext.displayName = "AgencContext";
41
+ function useAgencContext() {
42
+ const ctx = react.useContext(AgencContext);
43
+ if (ctx === null) {
44
+ throw new Error(t("provider.missingContext"));
45
+ }
46
+ return ctx;
47
+ }
48
+
49
+ // src/hooks/internal.ts
50
+ var QUERY_KEY_ROOT = "agenc";
51
+ var queryKeys = {
52
+ /** All listings list queries (with their filter object as the leaf). */
53
+ listings: (filter) => [QUERY_KEY_ROOT, "listings", filter ?? null],
54
+ /** One listing + its joined provider/track-record/moderation. */
55
+ listing: (pda) => [QUERY_KEY_ROOT, "listing", pda],
56
+ /** One agent's indexer track record. */
57
+ agentTrackRecord: (agentPda) => [QUERY_KEY_ROOT, "agentTrackRecord", agentPda],
58
+ /** One task's status (read via transport / svm decode). */
59
+ taskStatus: (taskPda) => [QUERY_KEY_ROOT, "taskStatus", taskPda],
60
+ /** One task's dispute record. */
61
+ dispute: (taskPda) => [QUERY_KEY_ROOT, "dispute", taskPda],
62
+ /** One referrer wallet's earnings (P6.2-gated; see useReferrerEarnings). */
63
+ referrerEarnings: (wallet) => [QUERY_KEY_ROOT, "referrerEarnings", wallet]
64
+ };
65
+ function requireClient(client) {
66
+ if (client === null) {
67
+ throw new Error(t("provider.missingWriteClient"));
68
+ }
69
+ return client;
70
+ }
71
+ function pdaKey(pda) {
72
+ return String(pda);
73
+ }
74
+
75
+ // src/hooks/useListings.ts
76
+ var DEFAULT_PAGE_SIZE = 12;
77
+ function useListings(filter, options) {
78
+ const { read } = useAgencContext();
79
+ const pageSize = options?.pageSize ?? DEFAULT_PAGE_SIZE;
80
+ const enabled = options?.enabled ?? true;
81
+ const query = reactQuery.useQuery({
82
+ queryKey: queryKeys.listings(filter),
83
+ queryFn: () => read.listActiveListings(filter),
84
+ enabled
85
+ });
86
+ const [visible, setVisible] = react.useState(pageSize);
87
+ const all = query.data ?? [];
88
+ const windowSize = Math.min(Math.max(visible, pageSize), all.length);
89
+ const listings = react.useMemo(
90
+ () => all.slice(0, windowSize),
91
+ [all, windowSize]
92
+ );
93
+ const fetchMore = react.useCallback(() => {
94
+ setVisible((current) => current + pageSize);
95
+ }, [pageSize]);
96
+ const refetch = react.useCallback(() => {
97
+ setVisible(pageSize);
98
+ void query.refetch();
99
+ }, [pageSize, query]);
100
+ return {
101
+ listings,
102
+ total: all.length,
103
+ isLoading: query.isLoading,
104
+ error: query.error ?? null,
105
+ hasMore: windowSize < all.length,
106
+ fetchMore,
107
+ refetch
108
+ };
109
+ }
110
+ var ReadTransportUnsupportedError = class extends Error {
111
+ /** The unsupported operation name. */
112
+ operation;
113
+ constructor(operation) {
114
+ super(
115
+ `Read operation "${operation}" requires the indexer backend; the gPA fallback has no trustless equivalent. Configure an indexer baseUrl on <AgencProvider> to use it.`
116
+ );
117
+ this.name = "ReadTransportUnsupportedError";
118
+ this.operation = operation;
119
+ }
120
+ };
121
+
122
+ // src/hooks/useListing.ts
123
+ function useListing(pda, options) {
124
+ const { read } = useAgencContext();
125
+ const enabled = (options?.enabled ?? true) && Boolean(pda);
126
+ const query = reactQuery.useQuery({
127
+ queryKey: queryKeys.listing(pda ? pdaKey(pda) : ""),
128
+ enabled,
129
+ queryFn: async () => {
130
+ const result = await read.getListing(pda);
131
+ const provider = result.account.providerAgent;
132
+ let trackRecord = null;
133
+ try {
134
+ trackRecord = await read.agentTrackRecord(provider);
135
+ } catch (err) {
136
+ if (!(err instanceof ReadTransportUnsupportedError)) throw err;
137
+ }
138
+ return {
139
+ address: result.address,
140
+ listing: result.account,
141
+ provider,
142
+ trackRecord,
143
+ moderation: result.indexer ?? null
144
+ };
145
+ }
146
+ });
147
+ const detail = query.data ?? null;
148
+ return {
149
+ detail,
150
+ listing: detail?.listing ?? null,
151
+ provider: detail?.provider ?? null,
152
+ trackRecord: detail?.trackRecord ?? null,
153
+ moderation: detail?.moderation ?? null,
154
+ isLoading: query.isLoading,
155
+ error: query.error ?? null,
156
+ refetch: () => void query.refetch()
157
+ };
158
+ }
159
+ function projectTrackRecord(raw) {
160
+ const completions = raw.completions;
161
+ const disputesLost = raw.disputesLost;
162
+ const settledKnown = completions + disputesLost;
163
+ const completionRate = settledKnown > 0 ? completions / settledKnown : null;
164
+ const disputeRate = settledKnown > 0 ? disputesLost / settledKnown : null;
165
+ return {
166
+ agent: raw.agent,
167
+ completions,
168
+ disputesInitiated: raw.disputesInitiated,
169
+ disputesLost,
170
+ completionRate,
171
+ disputeRate,
172
+ slashHistory: raw.slashHistory,
173
+ recentOutcomes: raw.slashHistory.map((event) => ({
174
+ kind: "slash",
175
+ event
176
+ })),
177
+ // Always partial in v1: every rate is a proxy until P6.6 lands the real
178
+ // denominators and outcome feed.
179
+ partial: true
180
+ };
181
+ }
182
+ function useAgentTrackRecord(agentPda, options) {
183
+ const { read } = useAgencContext();
184
+ const enabled = (options?.enabled ?? true) && Boolean(agentPda);
185
+ const query = reactQuery.useQuery({
186
+ queryKey: queryKeys.agentTrackRecord(agentPda ? pdaKey(agentPda) : ""),
187
+ enabled,
188
+ queryFn: async () => {
189
+ const raw = await read.agentTrackRecord(agentPda);
190
+ return projectTrackRecord(raw);
191
+ }
192
+ });
193
+ const tr = query.data ?? null;
194
+ return {
195
+ trackRecord: tr,
196
+ completionRate: tr?.completionRate ?? null,
197
+ disputeRate: tr?.disputeRate ?? null,
198
+ slashHistory: tr?.slashHistory ?? [],
199
+ recentOutcomes: tr?.recentOutcomes ?? [],
200
+ isLoading: query.isLoading,
201
+ error: query.error ?? null,
202
+ refetch: () => void query.refetch()
203
+ };
204
+ }
205
+ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
206
+ marketplaceSdk.TaskStatus.Completed,
207
+ marketplaceSdk.TaskStatus.Cancelled,
208
+ marketplaceSdk.TaskStatus.RejectFrozen
209
+ ]);
210
+ function hasResult(task) {
211
+ return task !== null && task.result.length > 0 && task.result.some((b) => b !== 0);
212
+ }
213
+ function useTaskStatus(taskPda, options) {
214
+ useAgencContext();
215
+ const reader = options?.taskReader;
216
+ const enabled = (options?.enabled ?? true) && Boolean(taskPda) && Boolean(reader);
217
+ const pollIntervalMs = options?.pollIntervalMs ?? 2e3;
218
+ const [events, setEvents] = react.useState([]);
219
+ const query = reactQuery.useQuery({
220
+ queryKey: queryKeys.taskStatus(taskPda ? pdaKey(taskPda) : ""),
221
+ enabled,
222
+ queryFn: () => reader(taskPda),
223
+ // Poll until terminal / target reached; then stop (return `false`).
224
+ refetchInterval: (q) => {
225
+ const task2 = q.state.data ?? null;
226
+ if (task2 === null) return pollIntervalMs;
227
+ if (TERMINAL_STATUSES.has(task2.status)) return false;
228
+ if (options?.targetStatus !== void 0 && task2.status === options.targetStatus) {
229
+ return false;
230
+ }
231
+ return pollIntervalMs;
232
+ }
233
+ });
234
+ const refetchRef = react.useRef(query.refetch);
235
+ refetchRef.current = query.refetch;
236
+ const eventsSource = options?.events;
237
+ react.useEffect(() => {
238
+ if (!eventsSource) return;
239
+ let cancelled = false;
240
+ (async () => {
241
+ try {
242
+ for await (const ev of eventsSource) {
243
+ if (cancelled) break;
244
+ setEvents((prev) => [...prev, ev]);
245
+ void refetchRef.current();
246
+ }
247
+ } catch {
248
+ }
249
+ })();
250
+ return () => {
251
+ cancelled = true;
252
+ };
253
+ }, [eventsSource]);
254
+ const task = query.data ?? null;
255
+ return {
256
+ task,
257
+ status: task?.status ?? null,
258
+ submission: hasResult(task) ? Uint8Array.from(task.result) : null,
259
+ events,
260
+ isLoading: query.isLoading,
261
+ error: query.error ?? null,
262
+ refetch: () => void query.refetch()
263
+ };
264
+ }
265
+ function useHire() {
266
+ const ctx = useAgencContext();
267
+ const mutation = reactQuery.useMutation({
268
+ mutationFn: async (input) => {
269
+ const client = requireClient(ctx.client);
270
+ const capability = ctx.resolveReferrerCapability();
271
+ const referrerInjected = capability.live && ctx.referrer !== null;
272
+ const creator = input.creator ?? client.signer;
273
+ let signature;
274
+ if (input.humanless === true) {
275
+ const ix = await marketplaceSdk.facade.hireFromListingHumanless({
276
+ ...input,
277
+ creator
278
+ // NOTE: P6.2 referrer fields would spread here under capability.live.
279
+ });
280
+ ({ signature } = await client.send([ix]));
281
+ } else {
282
+ const authority = input.authority ?? client.signer;
283
+ const result = await client.hireFromListing({
284
+ ...input,
285
+ authority,
286
+ creator
287
+ // NOTE: P6.2 referrer fields would spread here under capability.live.
288
+ });
289
+ signature = result.signature;
290
+ }
291
+ const [taskPda] = await marketplaceSdk.findTaskPda({
292
+ creator: typeof creator === "object" && creator !== null && "address" in creator ? creator.address : creator,
293
+ taskId: input.taskId
294
+ });
295
+ return { signature, taskPda, referrerInjected };
296
+ }
297
+ });
298
+ const hire = react.useCallback(
299
+ (input) => mutation.mutateAsync(input),
300
+ [mutation]
301
+ );
302
+ const status = react.useMemo(() => {
303
+ if (mutation.isPending) return "pending";
304
+ if (mutation.isError) return "error";
305
+ if (mutation.isSuccess) return "success";
306
+ return "idle";
307
+ }, [mutation.isPending, mutation.isError, mutation.isSuccess]);
308
+ return {
309
+ hire,
310
+ status,
311
+ taskPda: mutation.data?.taskPda ?? null,
312
+ signature: mutation.data?.signature ?? null,
313
+ error: mutation.error ?? null,
314
+ isPending: mutation.isPending,
315
+ reset: mutation.reset
316
+ };
317
+ }
318
+ function statusOf(m) {
319
+ if (m.isPending) return "pending";
320
+ if (m.isError) return "error";
321
+ if (m.isSuccess) return "success";
322
+ return "idle";
323
+ }
324
+ function useSubmissionReview(taskPda) {
325
+ const ctx = useAgencContext();
326
+ const acceptMut = reactQuery.useMutation({
327
+ mutationFn: async (input) => {
328
+ const client = requireClient(ctx.client);
329
+ const { signature: signature2 } = await client.acceptTaskResult({
330
+ ...input,
331
+ task: taskPda,
332
+ creator: input.creator ?? client.signer
333
+ });
334
+ return signature2;
335
+ }
336
+ });
337
+ const rejectMut = reactQuery.useMutation({
338
+ mutationFn: async (input) => {
339
+ const client = requireClient(ctx.client);
340
+ const ix = await marketplaceSdk.facade.rejectTaskResult({
341
+ ...input,
342
+ task: taskPda,
343
+ creator: input.creator ?? client.signer
344
+ });
345
+ const { signature: signature2 } = await client.send([ix]);
346
+ return signature2;
347
+ }
348
+ });
349
+ const requestChangesMut = reactQuery.useMutation({
350
+ mutationFn: async (input) => {
351
+ const client = requireClient(ctx.client);
352
+ const ix = await marketplaceSdk.facade.requestChanges({
353
+ ...input,
354
+ task: taskPda,
355
+ creator: input.creator ?? client.signer
356
+ });
357
+ const { signature: signature2 } = await client.send([ix]);
358
+ return signature2;
359
+ }
360
+ });
361
+ const accept = react.useCallback(
362
+ (input) => acceptMut.mutateAsync(input),
363
+ [acceptMut]
364
+ );
365
+ const reject = react.useCallback(
366
+ (input) => rejectMut.mutateAsync(input),
367
+ [rejectMut]
368
+ );
369
+ const requestChanges = react.useCallback(
370
+ (input) => requestChangesMut.mutateAsync(input),
371
+ [requestChangesMut]
372
+ );
373
+ const anyPending = acceptMut.isPending || rejectMut.isPending || requestChangesMut.isPending;
374
+ const status = anyPending ? "pending" : statusOf(
375
+ // Surface the most recently-touched verb's terminal state.
376
+ [acceptMut, rejectMut, requestChangesMut].find(
377
+ (m) => m.isError || m.isSuccess
378
+ ) ?? acceptMut
379
+ );
380
+ const error = acceptMut.error ?? rejectMut.error ?? requestChangesMut.error ?? null;
381
+ const signature = acceptMut.data ?? rejectMut.data ?? requestChangesMut.data ?? null;
382
+ return {
383
+ accept,
384
+ reject,
385
+ requestChanges,
386
+ status,
387
+ error,
388
+ signature,
389
+ reset: () => {
390
+ acceptMut.reset();
391
+ rejectMut.reset();
392
+ requestChangesMut.reset();
393
+ }
394
+ };
395
+ }
396
+ function useDispute(taskPda, options) {
397
+ const ctx = useAgencContext();
398
+ const reader = options?.disputeReader;
399
+ const enabled = (options?.enabled ?? true) && Boolean(taskPda) && Boolean(reader);
400
+ const read = reactQuery.useQuery({
401
+ queryKey: queryKeys.dispute(taskPda ? pdaKey(taskPda) : ""),
402
+ enabled,
403
+ queryFn: () => reader(taskPda)
404
+ });
405
+ const mutation = reactQuery.useMutation({
406
+ mutationFn: async (input) => {
407
+ const client = requireClient(ctx.client);
408
+ const { signature } = await client.initiateDispute({
409
+ ...input,
410
+ task: taskPda,
411
+ authority: input.authority ?? client.signer
412
+ });
413
+ void read.refetch();
414
+ return signature;
415
+ }
416
+ });
417
+ const initiate = react.useCallback(
418
+ (input) => mutation.mutateAsync(input),
419
+ [mutation]
420
+ );
421
+ const status = mutation.isPending ? "pending" : mutation.isError ? "error" : mutation.isSuccess ? "success" : "idle";
422
+ return {
423
+ dispute: read.data ?? null,
424
+ initiate,
425
+ status,
426
+ signature: mutation.data ?? null,
427
+ error: mutation.error ?? read.error ?? null,
428
+ isLoading: read.isLoading,
429
+ refetch: () => void read.refetch(),
430
+ reset: mutation.reset
431
+ };
432
+ }
433
+ function useWalletSigner(options) {
434
+ const ctx = useAgencContext();
435
+ const adapter = options?.adapter;
436
+ const signer = adapter?.signer ?? ctx.signer ?? null;
437
+ const connected = adapter !== void 0 ? adapter.connected ?? adapter.signer !== null : ctx.signer !== null;
438
+ const connect = react.useCallback(() => {
439
+ return adapter?.connect ? adapter.connect() : void 0;
440
+ }, [adapter]);
441
+ return { signer, connected, connect };
442
+ }
443
+ function useReferrerEarnings(wallet) {
444
+ const ctx = useAgencContext();
445
+ const capability = ctx.resolveReferrerCapability();
446
+ const enabled = capability.live && Boolean(wallet);
447
+ const query = reactQuery.useQuery(
448
+ {
449
+ queryKey: queryKeys.referrerEarnings(wallet ? pdaKey(wallet) : ""),
450
+ enabled,
451
+ queryFn: async () => {
452
+ throw new Error(
453
+ "useReferrerEarnings: the P6.2 referrer earnings path is not deployed; this query must never run while capability.live is false."
454
+ );
455
+ }
456
+ }
457
+ );
458
+ if (!capability.live) {
459
+ return {
460
+ live: false,
461
+ totalLamports: 0n,
462
+ hires: [],
463
+ isLoading: false,
464
+ error: null,
465
+ reason: capability.reason ?? t("referrer.notLiveReason"),
466
+ refetch: () => {
467
+ }
468
+ };
469
+ }
470
+ return {
471
+ live: true,
472
+ totalLamports: query.data?.totalLamports ?? 0n,
473
+ hires: query.data?.hires ?? [],
474
+ isLoading: query.isLoading,
475
+ error: query.error ?? null,
476
+ refetch: () => void query.refetch()
477
+ };
478
+ }
479
+
480
+ exports.QUERY_KEY_ROOT = QUERY_KEY_ROOT;
481
+ exports.projectTrackRecord = projectTrackRecord;
482
+ exports.queryKeys = queryKeys;
483
+ exports.useAgentTrackRecord = useAgentTrackRecord;
484
+ exports.useDispute = useDispute;
485
+ exports.useHire = useHire;
486
+ exports.useListing = useListing;
487
+ exports.useListings = useListings;
488
+ exports.useReferrerEarnings = useReferrerEarnings;
489
+ exports.useSubmissionReview = useSubmissionReview;
490
+ exports.useTaskStatus = useTaskStatus;
491
+ exports.useWalletSigner = useWalletSigner;
492
+ //# sourceMappingURL=index.cjs.map
493
+ //# sourceMappingURL=index.cjs.map