@tetsuo-ai/marketplace-react 0.3.0 → 0.3.2

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 (42) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/{chunk-FAIRTAIB.js → chunk-2Y6JN2VZ.js} +3 -3
  3. package/dist/{chunk-FAIRTAIB.js.map → chunk-2Y6JN2VZ.js.map} +1 -1
  4. package/dist/{chunk-D2TDU3TJ.js → chunk-AKPPKMQ2.js} +3 -3
  5. package/dist/{chunk-D2TDU3TJ.js.map → chunk-AKPPKMQ2.js.map} +1 -1
  6. package/dist/{chunk-ECU7HGO3.js → chunk-H6PJIDQR.js} +4 -3
  7. package/dist/chunk-H6PJIDQR.js.map +1 -0
  8. package/dist/{chunk-MNJ2EQDJ.js → chunk-ON6XR4XO.js} +3 -3
  9. package/dist/{chunk-MNJ2EQDJ.js.map → chunk-ON6XR4XO.js.map} +1 -1
  10. package/dist/{chunk-WJUVTFJ7.js → chunk-ZAMIL27X.js} +4 -4
  11. package/dist/{chunk-WJUVTFJ7.js.map → chunk-ZAMIL27X.js.map} +1 -1
  12. package/dist/components/index.cjs +2 -1
  13. package/dist/components/index.cjs.map +1 -1
  14. package/dist/components/index.d.cts +1 -1
  15. package/dist/components/index.d.ts +1 -1
  16. package/dist/components/index.js +3 -3
  17. package/dist/hooks/index.cjs +86 -9
  18. package/dist/hooks/index.cjs.map +1 -1
  19. package/dist/hooks/index.d.cts +6 -8
  20. package/dist/hooks/index.d.ts +6 -8
  21. package/dist/hooks/index.js +89 -12
  22. package/dist/hooks/index.js.map +1 -1
  23. package/dist/{index-C9R3B80j.d.ts → index-DQ3Xovkq.d.ts} +15 -1
  24. package/dist/{index-CTTh1ZPg.d.cts → index-UxuvIlmD.d.cts} +15 -1
  25. package/dist/index.cjs +9 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +2 -2
  28. package/dist/index.d.ts +2 -2
  29. package/dist/index.js +15 -8
  30. package/dist/index.js.map +1 -1
  31. package/dist/signers/index.cjs +2 -1
  32. package/dist/signers/index.cjs.map +1 -1
  33. package/dist/signers/index.js +2 -2
  34. package/package.json +1 -1
  35. package/src/hooks/moderation-attestor.ts +98 -0
  36. package/src/hooks/useHumanlessHireFlow.ts +12 -0
  37. package/src/hooks/useReferrerEarnings.ts +73 -38
  38. package/src/hooks/useTaskActivation.ts +13 -0
  39. package/src/provider/AgencProvider.tsx +12 -0
  40. package/src/strings/index.ts +3 -1
  41. package/src/types.ts +13 -0
  42. package/dist/chunk-ECU7HGO3.js.map +0 -1
@@ -1,4 +1,4 @@
1
- export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, H as HireButton, s as HireButtonProps, t as HireCheckoutListing, u as HireCheckoutModal, v as HireCheckoutModalProps, L as ListingCard, w as ListingCardData, x as ListingCardProps, y as ListingGrid, z as ListingGridProps, M as Modal, F as ModalProps, J as ModerationBadge, K as ModerationBadgeProps, N as ModerationState, P as PoweredByAgenC, O as PoweredByAgenCProps, Q as ProviderCard, S as ProviderCardProps, U as ReferrerDisclosure, W as ReferrerDisclosureProps, X as ReviewPanel, Y as ReviewPanelProps, Z as Spinner, _ as SpinnerProps, $ as StateKind, a0 as StateMessage, a1 as StateMessageProps, a5 as TaskTimeline, a6 as TaskTimelineProps, a7 as ThemableProps, a9 as UNVERIFIED, aa as UseAgentVerificationOptions, ab as UseAgentVerificationResult, ac as VerifiedBadge, ad as VerifiedBadgeProps, ae as agentVerificationReaderFromRpc, af as cx, ag as decodeListingCategory, ah as decodeListingName, ai as decodeListingTags, aj as elementClass, ak as evaluateAgentVerification, al as formatPriceSol, am as formatRate, an as formatSol, ao as moderationStateOf, ap as rootClass, ar as tc, as as toHex, at as truncateAddress, au as useAgentVerification, av as useFocusTrap } from '../index-CTTh1ZPg.cjs';
1
+ export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, H as HireButton, s as HireButtonProps, t as HireCheckoutListing, u as HireCheckoutModal, v as HireCheckoutModalProps, L as ListingCard, w as ListingCardData, x as ListingCardProps, y as ListingGrid, z as ListingGridProps, M as Modal, F as ModalProps, J as ModerationBadge, K as ModerationBadgeProps, N as ModerationState, P as PoweredByAgenC, O as PoweredByAgenCProps, Q as ProviderCard, S as ProviderCardProps, U as ReferrerDisclosure, W as ReferrerDisclosureProps, X as ReviewPanel, Y as ReviewPanelProps, Z as Spinner, _ as SpinnerProps, $ as StateKind, a0 as StateMessage, a1 as StateMessageProps, a5 as TaskTimeline, a6 as TaskTimelineProps, a7 as ThemableProps, a9 as UNVERIFIED, aa as UseAgentVerificationOptions, ab as UseAgentVerificationResult, ac as VerifiedBadge, ad as VerifiedBadgeProps, ae as agentVerificationReaderFromRpc, af as cx, ag as decodeListingCategory, ah as decodeListingName, ai as decodeListingTags, aj as elementClass, ak as evaluateAgentVerification, al as formatPriceSol, am as formatRate, an as formatSol, ao as moderationStateOf, ap as rootClass, ar as tc, as as toHex, at as truncateAddress, au as useAgentVerification, av as useFocusTrap } from '../index-UxuvIlmD.cjs';
2
2
  import 'react';
3
3
  import '@tetsuo-ai/marketplace-sdk';
4
4
  import '@solana/kit';
@@ -1,4 +1,4 @@
1
- export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, H as HireButton, s as HireButtonProps, t as HireCheckoutListing, u as HireCheckoutModal, v as HireCheckoutModalProps, L as ListingCard, w as ListingCardData, x as ListingCardProps, y as ListingGrid, z as ListingGridProps, M as Modal, F as ModalProps, J as ModerationBadge, K as ModerationBadgeProps, N as ModerationState, P as PoweredByAgenC, O as PoweredByAgenCProps, Q as ProviderCard, S as ProviderCardProps, U as ReferrerDisclosure, W as ReferrerDisclosureProps, X as ReviewPanel, Y as ReviewPanelProps, Z as Spinner, _ as SpinnerProps, $ as StateKind, a0 as StateMessage, a1 as StateMessageProps, a5 as TaskTimeline, a6 as TaskTimelineProps, a7 as ThemableProps, a9 as UNVERIFIED, aa as UseAgentVerificationOptions, ab as UseAgentVerificationResult, ac as VerifiedBadge, ad as VerifiedBadgeProps, ae as agentVerificationReaderFromRpc, af as cx, ag as decodeListingCategory, ah as decodeListingName, ai as decodeListingTags, aj as elementClass, ak as evaluateAgentVerification, al as formatPriceSol, am as formatRate, an as formatSol, ao as moderationStateOf, ap as rootClass, ar as tc, as as toHex, at as truncateAddress, au as useAgentVerification, av as useFocusTrap } from '../index-C9R3B80j.js';
1
+ export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, H as HireButton, s as HireButtonProps, t as HireCheckoutListing, u as HireCheckoutModal, v as HireCheckoutModalProps, L as ListingCard, w as ListingCardData, x as ListingCardProps, y as ListingGrid, z as ListingGridProps, M as Modal, F as ModalProps, J as ModerationBadge, K as ModerationBadgeProps, N as ModerationState, P as PoweredByAgenC, O as PoweredByAgenCProps, Q as ProviderCard, S as ProviderCardProps, U as ReferrerDisclosure, W as ReferrerDisclosureProps, X as ReviewPanel, Y as ReviewPanelProps, Z as Spinner, _ as SpinnerProps, $ as StateKind, a0 as StateMessage, a1 as StateMessageProps, a5 as TaskTimeline, a6 as TaskTimelineProps, a7 as ThemableProps, a9 as UNVERIFIED, aa as UseAgentVerificationOptions, ab as UseAgentVerificationResult, ac as VerifiedBadge, ad as VerifiedBadgeProps, ae as agentVerificationReaderFromRpc, af as cx, ag as decodeListingCategory, ah as decodeListingName, ai as decodeListingTags, aj as elementClass, ak as evaluateAgentVerification, al as formatPriceSol, am as formatRate, an as formatSol, ao as moderationStateOf, ap as rootClass, ar as tc, as as toHex, at as truncateAddress, au as useAgentVerification, av as useFocusTrap } from '../index-DQ3Xovkq.js';
2
2
  import 'react';
3
3
  import '@tetsuo-ai/marketplace-sdk';
4
4
  import '@solana/kit';
@@ -1,5 +1,5 @@
1
- export { Badge, Button, COMPONENT_CATALOG, DEFAULT_TRUST_HREF, DisputeBanner, EN_COMPONENT_STRINGS, HireButton, HireCheckoutModal, ListingCard, ListingGrid, Modal, ModerationBadge, PoweredByAgenC, ProviderCard, ReferrerDisclosure, ReviewPanel, Spinner, StateMessage, TaskTimeline, UNVERIFIED, VerifiedBadge, agentVerificationReaderFromRpc, cx, decodeListingCategory, decodeListingName, decodeListingTags, elementClass, evaluateAgentVerification, formatPriceSol, formatRate, formatSol, moderationStateOf, rootClass, tc, toHex, truncateAddress, useAgentVerification, useFocusTrap } from '../chunk-WJUVTFJ7.js';
2
- import '../chunk-FAIRTAIB.js';
3
- import '../chunk-ECU7HGO3.js';
1
+ export { Badge, Button, COMPONENT_CATALOG, DEFAULT_TRUST_HREF, DisputeBanner, EN_COMPONENT_STRINGS, HireButton, HireCheckoutModal, ListingCard, ListingGrid, Modal, ModerationBadge, PoweredByAgenC, ProviderCard, ReferrerDisclosure, ReviewPanel, Spinner, StateMessage, TaskTimeline, UNVERIFIED, VerifiedBadge, agentVerificationReaderFromRpc, cx, decodeListingCategory, decodeListingName, decodeListingTags, elementClass, evaluateAgentVerification, formatPriceSol, formatRate, formatSol, moderationStateOf, rootClass, tc, toHex, truncateAddress, useAgentVerification, useFocusTrap } from '../chunk-ZAMIL27X.js';
2
+ import '../chunk-2Y6JN2VZ.js';
3
+ import '../chunk-H6PJIDQR.js';
4
4
  //# sourceMappingURL=index.js.map
5
5
  //# sourceMappingURL=index.js.map
@@ -2,7 +2,7 @@
2
2
 
3
3
  var reactQuery = require('@tanstack/react-query');
4
4
  var react = require('react');
5
- require('@solana/kit');
5
+ var kit = require('@solana/kit');
6
6
  var marketplaceSdk = require('@tetsuo-ai/marketplace-sdk');
7
7
 
8
8
  // src/hooks/useListings.ts
@@ -18,7 +18,8 @@ var EN_STRINGS = {
18
18
  "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
19
19
  "referrer.notLive": "Referral fee is not active for this hire.",
20
20
  "referrer.notLiveReason": "No referrer is configured for this provider.",
21
- "referrer.earningsNotLiveReason": "Referral settlement is live, but aggregated referrer earnings are not yet exposed by the indexer.",
21
+ "referrer.earningsNotLiveReason": "Referral settlement is live, but no earnings endpoint is available on this network (configure indexer.baseUrl).",
22
+ "referrer.earningsFetchFailed": "The referrer earnings endpoint could not be read.",
22
23
  // Read transport.
23
24
  "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
24
25
  // Generic loading / empty / error states (components extend these).
@@ -430,13 +431,50 @@ function useSubmissionReview(taskPda) {
430
431
  }
431
432
  };
432
433
  }
434
+ async function resolveActivationModerationAttestor(input) {
435
+ try {
436
+ const rpc = input.rpc ?? (input.rpcUrl ? kit.createSolanaRpc(input.rpcUrl) : null);
437
+ if (!rpc) return void 0;
438
+ const [taskModerationPda] = await marketplaceSdk.findTaskModerationPda({
439
+ task: input.task,
440
+ jobSpecHash: input.jobSpecHash
441
+ });
442
+ const taskModeration = await marketplaceSdk.fetchMaybeTaskModeration(
443
+ rpc,
444
+ taskModerationPda
445
+ );
446
+ if (!taskModeration.exists) return void 0;
447
+ const [moderationConfigPda] = await marketplaceSdk.findModerationConfigPda();
448
+ const moderationConfig = await marketplaceSdk.fetchMaybeModerationConfig(
449
+ rpc,
450
+ moderationConfigPda
451
+ );
452
+ if (moderationConfig.exists && taskModeration.data.moderator === moderationConfig.data.moderationAuthority) {
453
+ return void 0;
454
+ }
455
+ const [rosterPda] = await marketplaceSdk.findModerationAttestorPda({
456
+ attestor: taskModeration.data.moderator
457
+ });
458
+ return rosterPda;
459
+ } catch {
460
+ return void 0;
461
+ }
462
+ }
463
+
464
+ // src/hooks/useTaskActivation.ts
433
465
  function useTaskActivation(taskPda) {
434
466
  const ctx = useAgencContext();
435
467
  const mutation = reactQuery.useMutation({
436
468
  mutationFn: async (input) => {
437
469
  const client = requireClient(ctx.client);
470
+ const moderationAttestor = input.moderationAttestor ?? await resolveActivationModerationAttestor({
471
+ rpcUrl: ctx.rpcUrl,
472
+ task: taskPda,
473
+ jobSpecHash: input.jobSpecHash
474
+ });
438
475
  const { signature } = await client.setTaskJobSpec({
439
476
  ...input,
477
+ ...moderationAttestor !== void 0 ? { moderationAttestor } : {},
440
478
  task: taskPda,
441
479
  creator: input.creator ?? client.signer
442
480
  });
@@ -530,8 +568,14 @@ function useHumanlessHireFlow() {
530
568
  jobSpecUri
531
569
  }));
532
570
  setPhase("activating");
571
+ const moderationAttestor = input.activation?.moderationAttestor ?? await resolveActivationModerationAttestor({
572
+ rpcUrl: ctx.rpcUrl,
573
+ task: taskPda,
574
+ jobSpecHash
575
+ });
533
576
  const activationResult = await client.setTaskJobSpec({
534
577
  ...input.activation ?? {},
578
+ ...moderationAttestor !== void 0 ? { moderationAttestor } : {},
535
579
  task: taskPda,
536
580
  creator,
537
581
  jobSpecHash,
@@ -764,23 +808,48 @@ function useWalletSigner(options) {
764
808
  }, [adapter]);
765
809
  return { signer, connected, connect };
766
810
  }
767
- var EARNINGS_INDEXER_LIVE = false;
811
+ var EARNINGS_INDEXER_DEFAULTS = {
812
+ mainnet: "https://api.agenc.ag"
813
+ };
814
+ function resolveEarningsBaseUrl(ctx) {
815
+ return ctx.indexerBaseUrl ?? EARNINGS_INDEXER_DEFAULTS[ctx.network] ?? null;
816
+ }
768
817
  function useReferrerEarnings(wallet) {
769
818
  const ctx = useAgencContext();
770
819
  const capability = ctx.resolveReferrerCapability();
771
- const enabled = capability.live && EARNINGS_INDEXER_LIVE;
772
- reactQuery.useQuery(
820
+ const earningsBase = resolveEarningsBaseUrl(ctx);
821
+ const enabled = capability.live && earningsBase !== null && Boolean(wallet);
822
+ const query = reactQuery.useQuery(
773
823
  {
774
824
  queryKey: queryKeys.referrerEarnings(wallet ? pdaKey(wallet) : ""),
775
825
  enabled,
776
826
  queryFn: async () => {
777
- throw new Error(
778
- "useReferrerEarnings: the referrer earnings indexer is not deployed; this query must never run while EARNINGS_INDEXER_LIVE is false."
779
- );
827
+ const url = `${earningsBase}/api/explorer/referrers/${encodeURIComponent(
828
+ String(wallet)
829
+ )}/hires`;
830
+ const response = await fetch(url, {
831
+ headers: { accept: "application/json" }
832
+ });
833
+ if (!response.ok) {
834
+ throw new Error(
835
+ t("referrer.earningsFetchFailed") + ` (HTTP ${response.status})`
836
+ );
837
+ }
838
+ const body = await response.json();
839
+ const hires = (body.hires ?? []).map((h) => ({
840
+ taskPda: String(h.taskPda ?? ""),
841
+ hireRecordPda: String(h.hireRecordPda ?? ""),
842
+ feeLamports: BigInt(h.feeLamports ?? "0"),
843
+ signature: String(h.signature ?? "")
844
+ }));
845
+ return {
846
+ totalLamports: BigInt(body.totalLamports ?? "0"),
847
+ hires
848
+ };
780
849
  }
781
850
  }
782
851
  );
783
- if (!capability.live || !EARNINGS_INDEXER_LIVE) {
852
+ if (!enabled) {
784
853
  return {
785
854
  live: false,
786
855
  totalLamports: 0n,
@@ -792,6 +861,14 @@ function useReferrerEarnings(wallet) {
792
861
  }
793
862
  };
794
863
  }
864
+ return {
865
+ live: true,
866
+ totalLamports: query.data?.totalLamports ?? 0n,
867
+ hires: query.data?.hires ?? [],
868
+ isLoading: query.isLoading,
869
+ error: query.error ?? null,
870
+ refetch: () => void query.refetch()
871
+ };
795
872
  }
796
873
 
797
874
  exports.QUERY_KEY_ROOT = QUERY_KEY_ROOT;