@tetsuo-ai/marketplace-react 0.3.2 → 0.4.1
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.
- package/CHANGELOG.md +44 -0
- package/dist/{chunk-ZAMIL27X.js → chunk-JVXGNW3Q.js} +35 -4
- package/dist/chunk-JVXGNW3Q.js.map +1 -0
- package/dist/chunk-XLA7DARS.js +255 -0
- package/dist/chunk-XLA7DARS.js.map +1 -0
- package/dist/components/index.cjs +179 -43
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +2 -2
- package/dist/hooks/index.cjs +206 -40
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +64 -4
- package/dist/hooks/index.d.ts +64 -4
- package/dist/hooks/index.js +98 -46
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-DQ3Xovkq.d.ts → index-CmVz0OOm.d.ts} +50 -5
- package/dist/{index-UxuvIlmD.d.cts → index-DAZzhuO4.d.cts} +50 -5
- package/dist/index.cjs +168 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{useAgentTrackRecord-BCvRHYM2.d.cts → useAgentTrackRecord-DPt3SfYz.d.cts} +39 -2
- package/dist/{useAgentTrackRecord-BCvRHYM2.d.ts → useAgentTrackRecord-DPt3SfYz.d.ts} +39 -2
- package/package.json +2 -2
- package/src/components/GuaranteedBadge.tsx +73 -0
- package/src/components/index.ts +4 -0
- package/src/components/strings.ts +8 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/internal.ts +3 -0
- package/src/hooks/moderation-attestor.ts +176 -57
- package/src/hooks/useCompletionBond.ts +156 -0
- package/src/hooks/useHire.ts +27 -0
- package/src/hooks/useHumanlessHireFlow.ts +74 -17
- package/src/hooks/useTaskActivation.ts +19 -13
- package/src/hooks/useTaskGuarantee.ts +120 -0
- package/src/index.ts +2 -0
- package/src/types.ts +5 -2
- package/dist/chunk-2Y6JN2VZ.js +0 -143
- package/dist/chunk-2Y6JN2VZ.js.map +0 -1
- package/dist/chunk-ZAMIL27X.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { QueryClient, QueryClientConfig } from '@tanstack/react-query';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { A as AgencProviderConfig, a as AgencContextValue, V as ValidatedReferrerConfig, R as ReferrerCapability, b as ReferrerConfig, c as AgencNetwork, C as CreateReadTransportConfig, d as ReadTransport } from './index-
|
|
5
|
-
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, r as EN_STRINGS, G as GpaReadSource, H as HireButton,
|
|
4
|
+
import { A as AgencProviderConfig, a as AgencContextValue, V as ValidatedReferrerConfig, R as ReferrerCapability, b as ReferrerConfig, c as AgencNetwork, C as CreateReadTransportConfig, d as ReadTransport } from './index-DAZzhuO4.cjs';
|
|
5
|
+
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, r as EN_STRINGS, G as GpaReadSource, s as GuaranteedBadge, t as GuaranteedBadgeProps, H as HireButton, u as HireButtonProps, v as HireCheckoutListing, w as HireCheckoutModal, x as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, y as ListingCardData, z as ListingCardProps, F as ListingGrid, J as ListingGridProps, M as Modal, K as ModalProps, N as ModerationBadge, O as ModerationBadgeProps, P as ModerationState, Q as PoweredByAgenC, S as PoweredByAgenCProps, T as ProviderCard, U as ProviderCardProps, W as ReadListingResult, X as ReferrerDisclosure, Y as ReferrerDisclosureProps, Z as ReviewPanel, _ as ReviewPanelProps, $ as Spinner, a0 as SpinnerProps, a1 as StateKind, a2 as StateMessage, a3 as StateMessageProps, a4 as StringCatalog, a5 as StringId, a6 as StringVars, a7 as TaskTimeline, a8 as TaskTimelineProps, a9 as ThemableProps, aa as TranslateOptions, ab as UNVERIFIED, ac as UseAgentVerificationOptions, ad as UseAgentVerificationResult, ae as VerifiedBadge, af as VerifiedBadgeProps, ag as agentVerificationReaderFromRpc, ah as cx, ai as decodeListingCategory, aj as decodeListingName, ak as decodeListingTags, al as elementClass, am as evaluateAgentVerification, an as formatPriceSol, ao as formatRate, ap as formatSol, aq as moderationStateOf, ar as rootClass, as as t, at as tc, au as toHex, av as truncateAddress, aw as useAgentVerification, ax as useFocusTrap } from './index-DAZzhuO4.cjs';
|
|
6
6
|
export { EN_SIGNER_STRINGS, SignerFromWalletAdapterOptions, SignerStringId, VersionedTransactionCtor, VersionedTransactionLike, WalletAdapterLike, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from './signers/index.cjs';
|
|
7
7
|
export { E as EmbeddedWalletConnection, a as EmbeddedWalletProvider, S as SignerFromWalletAccountOptions, W as WalletStandardAccountLike, b as WalletStandardSignTransaction } from './types-jvISR6bc.cjs';
|
|
8
8
|
export { Address, TransactionSigner } from '@solana/kit';
|
|
9
9
|
export { DecodedProgramAccount, IndexerAgentTrackRecord, IndexerHire, IndexerListing, ListActiveListingsOptions, MarketplaceClient, ServiceListing } from '@tetsuo-ai/marketplace-sdk';
|
|
10
|
-
import './useAgentTrackRecord-
|
|
10
|
+
import './useAgentTrackRecord-DPt3SfYz.cjs';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* `<AgencProvider>` — the one context that wires reads, writes, and the
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { QueryClient, QueryClientConfig } from '@tanstack/react-query';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { A as AgencProviderConfig, a as AgencContextValue, V as ValidatedReferrerConfig, R as ReferrerCapability, b as ReferrerConfig, c as AgencNetwork, C as CreateReadTransportConfig, d as ReadTransport } from './index-
|
|
5
|
-
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, r as EN_STRINGS, G as GpaReadSource, H as HireButton,
|
|
4
|
+
import { A as AgencProviderConfig, a as AgencContextValue, V as ValidatedReferrerConfig, R as ReferrerCapability, b as ReferrerConfig, c as AgencNetwork, C as CreateReadTransportConfig, d as ReadTransport } from './index-CmVz0OOm.js';
|
|
5
|
+
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, r as EN_STRINGS, G as GpaReadSource, s as GuaranteedBadge, t as GuaranteedBadgeProps, H as HireButton, u as HireButtonProps, v as HireCheckoutListing, w as HireCheckoutModal, x as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, y as ListingCardData, z as ListingCardProps, F as ListingGrid, J as ListingGridProps, M as Modal, K as ModalProps, N as ModerationBadge, O as ModerationBadgeProps, P as ModerationState, Q as PoweredByAgenC, S as PoweredByAgenCProps, T as ProviderCard, U as ProviderCardProps, W as ReadListingResult, X as ReferrerDisclosure, Y as ReferrerDisclosureProps, Z as ReviewPanel, _ as ReviewPanelProps, $ as Spinner, a0 as SpinnerProps, a1 as StateKind, a2 as StateMessage, a3 as StateMessageProps, a4 as StringCatalog, a5 as StringId, a6 as StringVars, a7 as TaskTimeline, a8 as TaskTimelineProps, a9 as ThemableProps, aa as TranslateOptions, ab as UNVERIFIED, ac as UseAgentVerificationOptions, ad as UseAgentVerificationResult, ae as VerifiedBadge, af as VerifiedBadgeProps, ag as agentVerificationReaderFromRpc, ah as cx, ai as decodeListingCategory, aj as decodeListingName, ak as decodeListingTags, al as elementClass, am as evaluateAgentVerification, an as formatPriceSol, ao as formatRate, ap as formatSol, aq as moderationStateOf, ar as rootClass, as as t, at as tc, au as toHex, av as truncateAddress, aw as useAgentVerification, ax as useFocusTrap } from './index-CmVz0OOm.js';
|
|
6
6
|
export { EN_SIGNER_STRINGS, SignerFromWalletAdapterOptions, SignerStringId, VersionedTransactionCtor, VersionedTransactionLike, WalletAdapterLike, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from './signers/index.js';
|
|
7
7
|
export { E as EmbeddedWalletConnection, a as EmbeddedWalletProvider, S as SignerFromWalletAccountOptions, W as WalletStandardAccountLike, b as WalletStandardSignTransaction } from './types-jvISR6bc.js';
|
|
8
8
|
export { Address, TransactionSigner } from '@solana/kit';
|
|
9
9
|
export { DecodedProgramAccount, IndexerAgentTrackRecord, IndexerHire, IndexerListing, ListActiveListingsOptions, MarketplaceClient, ServiceListing } from '@tetsuo-ai/marketplace-sdk';
|
|
10
|
-
import './useAgentTrackRecord-
|
|
10
|
+
import './useAgentTrackRecord-DPt3SfYz.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* `<AgencProvider>` — the one context that wires reads, writes, and the
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createReadTransport } from './chunk-AKPPKMQ2.js';
|
|
2
2
|
export { ReadTransportUnsupportedError, createReadTransport } from './chunk-AKPPKMQ2.js';
|
|
3
3
|
export { EN_SIGNER_STRINGS, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from './chunk-ON6XR4XO.js';
|
|
4
|
-
export { AGENC_THEME_CLASS, AGENC_TOKENS_CSS_PATH, 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, agencThemeStyleTag, agentVerificationReaderFromRpc, cx, decodeListingCategory, decodeListingName, decodeListingTags, elementClass, evaluateAgentVerification, formatPriceSol, formatRate, formatSol, moderationStateOf, resolveThemeClassName, rootClass, tc, toHex, truncateAddress, useAgentVerification, useFocusTrap } from './chunk-
|
|
5
|
-
import { AgencContext } from './chunk-
|
|
6
|
-
export { AgencContext, useAgencContext } from './chunk-
|
|
4
|
+
export { AGENC_THEME_CLASS, AGENC_TOKENS_CSS_PATH, Badge, Button, COMPONENT_CATALOG, DEFAULT_TRUST_HREF, DisputeBanner, EN_COMPONENT_STRINGS, GuaranteedBadge, HireButton, HireCheckoutModal, ListingCard, ListingGrid, Modal, ModerationBadge, PoweredByAgenC, ProviderCard, ReferrerDisclosure, ReviewPanel, Spinner, StateMessage, TaskTimeline, UNVERIFIED, VerifiedBadge, agencThemeStyleTag, agentVerificationReaderFromRpc, cx, decodeListingCategory, decodeListingName, decodeListingTags, elementClass, evaluateAgentVerification, formatPriceSol, formatRate, formatSol, moderationStateOf, resolveThemeClassName, rootClass, tc, toHex, truncateAddress, useAgentVerification, useFocusTrap } from './chunk-JVXGNW3Q.js';
|
|
5
|
+
import { AgencContext } from './chunk-XLA7DARS.js';
|
|
6
|
+
export { AgencContext, useAgencContext } from './chunk-XLA7DARS.js';
|
|
7
7
|
import { t } from './chunk-H6PJIDQR.js';
|
|
8
8
|
export { EN_STRINGS, t } from './chunk-H6PJIDQR.js';
|
|
9
9
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
@@ -1,6 +1,43 @@
|
|
|
1
|
-
import { facade, Dispute, IndexerAgentTrackRecord } from '@tetsuo-ai/marketplace-sdk';
|
|
1
|
+
import { TaskGuarantee, facade, Dispute, IndexerAgentTrackRecord } from '@tetsuo-ai/marketplace-sdk';
|
|
2
2
|
import { Address } from '@solana/kit';
|
|
3
3
|
|
|
4
|
+
/** Reads a task's {@link TaskGuarantee} (the SDK `fetchTaskGuarantee` shape). */
|
|
5
|
+
type TaskGuaranteeReader = (taskPda: Address | string) => Promise<TaskGuarantee>;
|
|
6
|
+
/** Options for {@link useTaskGuarantee}. */
|
|
7
|
+
interface UseTaskGuaranteeOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Injected reader seam (wins over the provider `rpcUrl` default). Wire it
|
|
10
|
+
* from litesvm/gpa-sim in tests or from your own transport.
|
|
11
|
+
*/
|
|
12
|
+
guaranteeReader?: TaskGuaranteeReader;
|
|
13
|
+
/** Disable the read. Default `true` when `taskPda` + a read source exist. */
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Return value of {@link useTaskGuarantee}. */
|
|
17
|
+
interface UseTaskGuaranteeResult {
|
|
18
|
+
/** The full bond state (worker/creator bonds + flag), or null until read. */
|
|
19
|
+
guarantee: TaskGuarantee | null;
|
|
20
|
+
/**
|
|
21
|
+
* Convenience: `guarantee?.guaranteed ?? false` — `true` iff the worker
|
|
22
|
+
* bond is live (posted and unresolved).
|
|
23
|
+
*/
|
|
24
|
+
guaranteed: boolean;
|
|
25
|
+
/** True while the first read is in flight. */
|
|
26
|
+
isLoading: boolean;
|
|
27
|
+
/** The read error, or null. */
|
|
28
|
+
error: Error | null;
|
|
29
|
+
/** Force a refetch (e.g. after posting/reclaiming a bond). */
|
|
30
|
+
refetch: () => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read a task's Guaranteed Hire state.
|
|
34
|
+
*
|
|
35
|
+
* @param taskPda - The Task PDA (falsy disables the read).
|
|
36
|
+
* @param options - Reader seam + enabled.
|
|
37
|
+
* @returns {@link UseTaskGuaranteeResult}.
|
|
38
|
+
*/
|
|
39
|
+
declare function useTaskGuarantee(taskPda: Address | string | undefined | null, options?: UseTaskGuaranteeOptions): UseTaskGuaranteeResult;
|
|
40
|
+
|
|
4
41
|
/**
|
|
5
42
|
* Input to a standard `hire(...)` — a buyer that has a registered marketplace
|
|
6
43
|
* agent (`creatorAgent`). This task settles on the HIRE COMPLETION path (the
|
|
@@ -246,4 +283,4 @@ declare function projectTrackRecord(raw: IndexerAgentTrackRecord): AgentTrackRec
|
|
|
246
283
|
*/
|
|
247
284
|
declare function useAgentTrackRecord(agentPda: Address | string | undefined | null, options?: UseAgentTrackRecordOptions): UseAgentTrackRecordResult;
|
|
248
285
|
|
|
249
|
-
export { type AcceptInput as A, type DisputeReader as D, type HumanlessHireInput as H, type InitiateDisputeInput as I, type RejectInput as R, type
|
|
286
|
+
export { type AcceptInput as A, type DisputeReader as D, type HumanlessHireInput as H, type InitiateDisputeInput as I, type RejectInput as R, type TaskGuaranteeReader as T, type UseAgentTrackRecordOptions as U, type AgentTrackRecord as a, type AnyHireInput as b, type DisputeStatus as c, type HireInput as d, type HireResult as e, type HireStatus as f, type RequestChangesInput as g, type ReviewAction as h, type ReviewStatus as i, type TrackRecordOutcome as j, type UseAgentTrackRecordResult as k, type UseDisputeOptions as l, type UseDisputeResult as m, type UseHireResult as n, type UseSubmissionReviewResult as o, type UseTaskGuaranteeOptions as p, type UseTaskGuaranteeResult as q, projectTrackRecord as r, useDispute as s, useHire as t, useAgentTrackRecord as u, useSubmissionReview as v, useTaskGuarantee as w };
|
|
@@ -1,6 +1,43 @@
|
|
|
1
|
-
import { facade, Dispute, IndexerAgentTrackRecord } from '@tetsuo-ai/marketplace-sdk';
|
|
1
|
+
import { TaskGuarantee, facade, Dispute, IndexerAgentTrackRecord } from '@tetsuo-ai/marketplace-sdk';
|
|
2
2
|
import { Address } from '@solana/kit';
|
|
3
3
|
|
|
4
|
+
/** Reads a task's {@link TaskGuarantee} (the SDK `fetchTaskGuarantee` shape). */
|
|
5
|
+
type TaskGuaranteeReader = (taskPda: Address | string) => Promise<TaskGuarantee>;
|
|
6
|
+
/** Options for {@link useTaskGuarantee}. */
|
|
7
|
+
interface UseTaskGuaranteeOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Injected reader seam (wins over the provider `rpcUrl` default). Wire it
|
|
10
|
+
* from litesvm/gpa-sim in tests or from your own transport.
|
|
11
|
+
*/
|
|
12
|
+
guaranteeReader?: TaskGuaranteeReader;
|
|
13
|
+
/** Disable the read. Default `true` when `taskPda` + a read source exist. */
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Return value of {@link useTaskGuarantee}. */
|
|
17
|
+
interface UseTaskGuaranteeResult {
|
|
18
|
+
/** The full bond state (worker/creator bonds + flag), or null until read. */
|
|
19
|
+
guarantee: TaskGuarantee | null;
|
|
20
|
+
/**
|
|
21
|
+
* Convenience: `guarantee?.guaranteed ?? false` — `true` iff the worker
|
|
22
|
+
* bond is live (posted and unresolved).
|
|
23
|
+
*/
|
|
24
|
+
guaranteed: boolean;
|
|
25
|
+
/** True while the first read is in flight. */
|
|
26
|
+
isLoading: boolean;
|
|
27
|
+
/** The read error, or null. */
|
|
28
|
+
error: Error | null;
|
|
29
|
+
/** Force a refetch (e.g. after posting/reclaiming a bond). */
|
|
30
|
+
refetch: () => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read a task's Guaranteed Hire state.
|
|
34
|
+
*
|
|
35
|
+
* @param taskPda - The Task PDA (falsy disables the read).
|
|
36
|
+
* @param options - Reader seam + enabled.
|
|
37
|
+
* @returns {@link UseTaskGuaranteeResult}.
|
|
38
|
+
*/
|
|
39
|
+
declare function useTaskGuarantee(taskPda: Address | string | undefined | null, options?: UseTaskGuaranteeOptions): UseTaskGuaranteeResult;
|
|
40
|
+
|
|
4
41
|
/**
|
|
5
42
|
* Input to a standard `hire(...)` — a buyer that has a registered marketplace
|
|
6
43
|
* agent (`creatorAgent`). This task settles on the HIRE COMPLETION path (the
|
|
@@ -246,4 +283,4 @@ declare function projectTrackRecord(raw: IndexerAgentTrackRecord): AgentTrackRec
|
|
|
246
283
|
*/
|
|
247
284
|
declare function useAgentTrackRecord(agentPda: Address | string | undefined | null, options?: UseAgentTrackRecordOptions): UseAgentTrackRecordResult;
|
|
248
285
|
|
|
249
|
-
export { type AcceptInput as A, type DisputeReader as D, type HumanlessHireInput as H, type InitiateDisputeInput as I, type RejectInput as R, type
|
|
286
|
+
export { type AcceptInput as A, type DisputeReader as D, type HumanlessHireInput as H, type InitiateDisputeInput as I, type RejectInput as R, type TaskGuaranteeReader as T, type UseAgentTrackRecordOptions as U, type AgentTrackRecord as a, type AnyHireInput as b, type DisputeStatus as c, type HireInput as d, type HireResult as e, type HireStatus as f, type RequestChangesInput as g, type ReviewAction as h, type ReviewStatus as i, type TrackRecordOutcome as j, type UseAgentTrackRecordResult as k, type UseDisputeOptions as l, type UseDisputeResult as m, type UseHireResult as n, type UseSubmissionReviewResult as o, type UseTaskGuaranteeOptions as p, type UseTaskGuaranteeResult as q, projectTrackRecord as r, useDispute as s, useHire as t, useAgentTrackRecord as u, useSubmissionReview as v, useTaskGuarantee as w };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tetsuo-ai/marketplace-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Headless React hooks + themable components for the AgenC marketplace — provider, indexer-first read transport, and live referrer config",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"@solana/kit": "^6.9.0",
|
|
89
89
|
"@solana/program-client-core": "^6.4.0",
|
|
90
|
-
"@tetsuo-ai/marketplace-sdk": "^0.
|
|
90
|
+
"@tetsuo-ai/marketplace-sdk": "^0.8.0",
|
|
91
91
|
"react": ">=18"
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<GuaranteedBadge task={...} />` — the Guaranteed Hire badge (WP-H3).
|
|
3
|
+
*
|
|
4
|
+
* Renders NOTHING unless the task is guaranteed (a live worker completion
|
|
5
|
+
* bond: the worker staked 25% of the reward on passing review). When it is,
|
|
6
|
+
* shows a small success-tone badge with plain-English copy; the full detail
|
|
7
|
+
* sentence rides on `title`/`aria-label`.
|
|
8
|
+
*
|
|
9
|
+
* Connected by default: given `task`, it reads through {@link useTaskGuarantee}
|
|
10
|
+
* (provider `rpcUrl` gPA read, or the `guaranteeReader` seam). Pass a
|
|
11
|
+
* pre-resolved `guarantee` to use it presentationally (no read at all) — an
|
|
12
|
+
* explicit `guarantee` (including `null`) wins over the `task` read.
|
|
13
|
+
*
|
|
14
|
+
* HONEST BOUNDARY (phase 1): the copy says the buyer is refunded and the
|
|
15
|
+
* worker FORFEITS the bond — it deliberately does NOT promise the buyer the
|
|
16
|
+
* bond itself, because a forfeited bond pays the protocol treasury until
|
|
17
|
+
* phase 2 redirects it to the harmed party. Keep host copy within that line.
|
|
18
|
+
*
|
|
19
|
+
* @module components/GuaranteedBadge
|
|
20
|
+
*/
|
|
21
|
+
import type { ReactNode } from "react";
|
|
22
|
+
import type { TaskGuarantee } from "@tetsuo-ai/marketplace-sdk";
|
|
23
|
+
import {
|
|
24
|
+
useTaskGuarantee,
|
|
25
|
+
type TaskGuaranteeReader,
|
|
26
|
+
} from "../hooks/useTaskGuarantee.js";
|
|
27
|
+
import type { Address } from "../types.js";
|
|
28
|
+
import { tc } from "./format.js";
|
|
29
|
+
import { Badge, type ThemableProps } from "./primitives.js";
|
|
30
|
+
|
|
31
|
+
/** Props for {@link GuaranteedBadge}. */
|
|
32
|
+
export interface GuaranteedBadgeProps extends ThemableProps {
|
|
33
|
+
/** The Task PDA to read the guarantee for (connected mode). */
|
|
34
|
+
task?: Address | string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Pre-resolved guarantee state (presentational mode — overrides the `task`
|
|
37
|
+
* read entirely; pass `null` for a known-unguaranteed task).
|
|
38
|
+
*/
|
|
39
|
+
guarantee?: TaskGuarantee | null;
|
|
40
|
+
/** Injected reader seam forwarded to {@link useTaskGuarantee} (tests/litesvm). */
|
|
41
|
+
guaranteeReader?: TaskGuaranteeReader;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Show that a task's result is backed by the worker's 25% completion bond.
|
|
46
|
+
* Renders nothing while loading, on read errors, and for unguaranteed tasks —
|
|
47
|
+
* the badge only ever ASSERTS a live guarantee, never its absence.
|
|
48
|
+
*/
|
|
49
|
+
export function GuaranteedBadge({
|
|
50
|
+
task,
|
|
51
|
+
guarantee,
|
|
52
|
+
guaranteeReader,
|
|
53
|
+
unstyled,
|
|
54
|
+
className,
|
|
55
|
+
}: GuaranteedBadgeProps): ReactNode {
|
|
56
|
+
const overridden = guarantee !== undefined;
|
|
57
|
+
const read = useTaskGuarantee(overridden ? null : task, {
|
|
58
|
+
guaranteeReader,
|
|
59
|
+
enabled: !overridden,
|
|
60
|
+
});
|
|
61
|
+
const resolved = overridden ? guarantee : read.guarantee;
|
|
62
|
+
if (!resolved?.guaranteed) return null;
|
|
63
|
+
return (
|
|
64
|
+
<Badge
|
|
65
|
+
tone="success"
|
|
66
|
+
unstyled={unstyled}
|
|
67
|
+
className={className}
|
|
68
|
+
label={tc("components.guarantee.detail")}
|
|
69
|
+
>
|
|
70
|
+
{tc("components.guarantee.badge")}
|
|
71
|
+
</Badge>
|
|
72
|
+
);
|
|
73
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -45,6 +45,10 @@ export {
|
|
|
45
45
|
type ModerationState,
|
|
46
46
|
type VerifiedBadgeProps,
|
|
47
47
|
} from "./badges.js";
|
|
48
|
+
export {
|
|
49
|
+
GuaranteedBadge,
|
|
50
|
+
type GuaranteedBadgeProps,
|
|
51
|
+
} from "./GuaranteedBadge.js";
|
|
48
52
|
|
|
49
53
|
// Presentational formatting helpers + the component string resolver.
|
|
50
54
|
export {
|
|
@@ -120,6 +120,14 @@ export const EN_COMPONENT_STRINGS = {
|
|
|
120
120
|
"components.provider.claimedDomainLabel":
|
|
121
121
|
"Claimed domain {domain} (not verified on-chain)",
|
|
122
122
|
|
|
123
|
+
// GuaranteedBadge (WP-H3 Guaranteed Hire). The detail copy is deliberately
|
|
124
|
+
// phase-1-honest: the buyer is refunded (escrow) and the worker FORFEITS the
|
|
125
|
+
// bond — it does NOT say the buyer receives the bond, because a forfeited
|
|
126
|
+
// bond pays the protocol treasury until phase 2 redirects it.
|
|
127
|
+
"components.guarantee.badge": "Guaranteed — worker has 25% at stake",
|
|
128
|
+
"components.guarantee.detail":
|
|
129
|
+
"Worker has 25% at stake — if the result fails review you're refunded and the worker forfeits the bond.",
|
|
130
|
+
|
|
123
131
|
// PoweredByAgenC.
|
|
124
132
|
"components.poweredBy.label": "Powered by AgenC",
|
|
125
133
|
"components.poweredBy.trustLink": "Learn how this works",
|
package/src/hooks/index.ts
CHANGED
|
@@ -42,6 +42,12 @@ export {
|
|
|
42
42
|
type UseTaskStatusOptions,
|
|
43
43
|
type UseTaskStatusResult,
|
|
44
44
|
} from "./useTaskStatus.js";
|
|
45
|
+
export {
|
|
46
|
+
useTaskGuarantee,
|
|
47
|
+
type TaskGuaranteeReader,
|
|
48
|
+
type UseTaskGuaranteeOptions,
|
|
49
|
+
type UseTaskGuaranteeResult,
|
|
50
|
+
} from "./useTaskGuarantee.js";
|
|
45
51
|
|
|
46
52
|
// Writes
|
|
47
53
|
export {
|
|
@@ -113,6 +119,13 @@ export {
|
|
|
113
119
|
type UseDisputeOptions,
|
|
114
120
|
type UseDisputeResult,
|
|
115
121
|
} from "./useDispute.js";
|
|
122
|
+
export {
|
|
123
|
+
useCompletionBond,
|
|
124
|
+
type CompletionBondStatus,
|
|
125
|
+
type PostCompletionBondInput,
|
|
126
|
+
type ReclaimCompletionBondInput,
|
|
127
|
+
type UseCompletionBondResult,
|
|
128
|
+
} from "./useCompletionBond.js";
|
|
116
129
|
|
|
117
130
|
// Wallet bridge
|
|
118
131
|
export {
|
package/src/hooks/internal.ts
CHANGED
|
@@ -45,6 +45,9 @@ export const queryKeys = {
|
|
|
45
45
|
[QUERY_KEY_ROOT, "taskStatus", taskPda] as const,
|
|
46
46
|
/** One task's dispute record. */
|
|
47
47
|
dispute: (taskPda: string) => [QUERY_KEY_ROOT, "dispute", taskPda] as const,
|
|
48
|
+
/** One task's completion-bond ("Guaranteed Hire") state. */
|
|
49
|
+
taskGuarantee: (taskPda: string) =>
|
|
50
|
+
[QUERY_KEY_ROOT, "taskGuarantee", taskPda] as const,
|
|
48
51
|
/** One referrer wallet's earnings (indexer-gated; see useReferrerEarnings). */
|
|
49
52
|
referrerEarnings: (wallet: string) =>
|
|
50
53
|
[QUERY_KEY_ROOT, "referrerEarnings", wallet] as const,
|
|
@@ -1,98 +1,217 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolve the
|
|
3
|
-
* activation (WP-A1).
|
|
2
|
+
* Resolve the P1.2 moderation accounts a consumption gate needs.
|
|
4
3
|
*
|
|
5
|
-
* Post-
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
4
|
+
* Post-P1.2 (open roster) every consumption gate — `set_task_job_spec` for
|
|
5
|
+
* activation, `hire_from_listing`/`hire_from_listing_humanless` for hires —
|
|
6
|
+
* names an explicit `moderator` whose attestation it consumes, and the
|
|
7
|
+
* moderation record lives at the v2 moderator-keyed seeds
|
|
8
|
+
* (`["task_moderation_v2", task, hash, moderator]` / the listing mirror). The
|
|
9
|
+
* caller supplies WHO to trust (the `moderator` — reading it from their
|
|
10
|
+
* attestation service, e.g. attest.agenc.ag `GET /v1/info`); these helpers
|
|
11
|
+
* resolve the MECHANICS:
|
|
13
12
|
*
|
|
14
|
-
*
|
|
15
|
-
* moderator
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
13
|
+
* - the roster-entry PDA (`["moderation_attestor", moderator]`) the gate
|
|
14
|
+
* requires whenever the moderator is a registered attestor rather than the
|
|
15
|
+
* global `moderation_authority`;
|
|
16
|
+
* - the legacy grace window: when no v2 record exists but a PRE-upgrade record
|
|
17
|
+
* authored by the SAME moderator sits at the frozen legacy seeds, the gate
|
|
18
|
+
* still accepts it if the transaction points at it explicitly — so the
|
|
19
|
+
* resolver returns that record override.
|
|
20
|
+
*
|
|
21
|
+
* Any resolution failure degrades to "no overrides" — the program stays the
|
|
22
|
+
* enforcement point; a read hiccup must never make the flow MORE broken than
|
|
23
|
+
* not resolving at all.
|
|
20
24
|
*
|
|
21
25
|
* @module hooks/moderation-attestor
|
|
22
26
|
*/
|
|
23
27
|
import { createSolanaRpc } from "@solana/kit";
|
|
24
28
|
import {
|
|
29
|
+
facade,
|
|
30
|
+
fetchMaybeListingModeration,
|
|
31
|
+
fetchMaybeModerationAttestor,
|
|
25
32
|
fetchMaybeModerationConfig,
|
|
26
33
|
fetchMaybeTaskModeration,
|
|
34
|
+
findListingModerationPda,
|
|
27
35
|
findModerationAttestorPda,
|
|
28
36
|
findModerationConfigPda,
|
|
29
37
|
findTaskModerationPda,
|
|
30
38
|
} from "@tetsuo-ai/marketplace-sdk";
|
|
31
39
|
import type { Address } from "../types.js";
|
|
32
40
|
|
|
33
|
-
/** The account-read slice of a kit RPC that the
|
|
41
|
+
/** The account-read slice of a kit RPC that the resolvers need. */
|
|
34
42
|
type AccountReadRpc = Parameters<typeof fetchMaybeTaskModeration>[0];
|
|
35
43
|
|
|
36
|
-
/** The job-spec hash exactly as the
|
|
44
|
+
/** The job-spec hash exactly as the moderation-record PDA seeds accept it. */
|
|
37
45
|
type JobSpecHashSeed = Parameters<typeof findTaskModerationPda>[0]["jobSpecHash"];
|
|
38
46
|
|
|
47
|
+
/** Moderation accounts resolved for a task activation (`set_task_job_spec`). */
|
|
48
|
+
export interface ActivationModerationAccounts {
|
|
49
|
+
/** Roster-entry PDA to attach, absent on the global-authority path. */
|
|
50
|
+
moderationAttestor?: Address;
|
|
51
|
+
/**
|
|
52
|
+
* Explicit record override — set only when the attestation predates the
|
|
53
|
+
* P1.2 upgrade and lives at the frozen legacy seeds (grace window).
|
|
54
|
+
*/
|
|
55
|
+
taskModeration?: Address;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Moderation accounts resolved for a hire (`hire_from_listing*`). */
|
|
59
|
+
export interface HireListingModerationAccounts {
|
|
60
|
+
/** Roster-entry PDA to attach, absent on the global-authority path. */
|
|
61
|
+
moderationAttestor?: Address;
|
|
62
|
+
/**
|
|
63
|
+
* Explicit record override — set only when the attestation predates the
|
|
64
|
+
* P1.2 upgrade and lives at the frozen legacy seeds (grace window).
|
|
65
|
+
*/
|
|
66
|
+
listingModeration?: Address;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function readRpc(input: {
|
|
70
|
+
rpcUrl: string | null;
|
|
71
|
+
rpc?: AccountReadRpc;
|
|
72
|
+
}): AccountReadRpc | null {
|
|
73
|
+
return (
|
|
74
|
+
input.rpc ??
|
|
75
|
+
(input.rpcUrl
|
|
76
|
+
? (createSolanaRpc(input.rpcUrl) as unknown as AccountReadRpc)
|
|
77
|
+
: null)
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
39
81
|
/**
|
|
40
|
-
*
|
|
41
|
-
* `undefined` when
|
|
42
|
-
* moderation
|
|
82
|
+
* Roster vs global-authority: return the `["moderation_attestor", moderator]`
|
|
83
|
+
* roster PDA to attach, or `undefined` when the moderator IS the global
|
|
84
|
+
* moderation authority (the gate's authority branch needs no roster account).
|
|
85
|
+
*
|
|
86
|
+
* The roster PDA is attached ONLY when the entry verifiably exists on-chain:
|
|
87
|
+
* a set-but-uninitialized optional account fails the gate harder than
|
|
88
|
+
* attaching nothing (`AccountNotInitialized` vs the authority branch), so an
|
|
89
|
+
* unreadable/absent entry degrades to "no account" — callers on an exotic
|
|
90
|
+
* setup can still force the roster path with `moderatorIsAttestor`.
|
|
91
|
+
*/
|
|
92
|
+
async function resolveRosterEntry(
|
|
93
|
+
rpc: AccountReadRpc,
|
|
94
|
+
moderator: Address,
|
|
95
|
+
): Promise<Address | undefined> {
|
|
96
|
+
const [moderationConfigPda] = await findModerationConfigPda();
|
|
97
|
+
const moderationConfig = await fetchMaybeModerationConfig(
|
|
98
|
+
rpc,
|
|
99
|
+
moderationConfigPda,
|
|
100
|
+
);
|
|
101
|
+
if (
|
|
102
|
+
moderationConfig.exists &&
|
|
103
|
+
moderationConfig.data.moderationAuthority === moderator
|
|
104
|
+
) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
const [rosterPda] = await findModerationAttestorPda({ attestor: moderator });
|
|
108
|
+
const roster = await fetchMaybeModerationAttestor(rpc, rosterPda);
|
|
109
|
+
return roster.exists ? rosterPda : undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Resolve the moderation accounts to attach to `set_task_job_spec`, given the
|
|
114
|
+
* `moderator` whose attestation the activation consumes.
|
|
43
115
|
*
|
|
44
116
|
* @param input.rpcUrl - Resolved HTTP RPC endpoint (from provider context).
|
|
45
117
|
* @param input.task - The task PDA being activated.
|
|
46
|
-
* @param input.jobSpecHash - The 32-byte canonical job-spec hash
|
|
47
|
-
*
|
|
118
|
+
* @param input.jobSpecHash - The 32-byte canonical job-spec hash.
|
|
119
|
+
* @param input.moderator - The attestation signer the gate should consume
|
|
120
|
+
* (e.g. the attestation service's `moderator` from `GET /v1/info`).
|
|
48
121
|
* @param input.rpc - Test seam: a pre-built account-read RPC wins over
|
|
49
122
|
* `rpcUrl`.
|
|
50
123
|
*/
|
|
51
|
-
export async function
|
|
124
|
+
export async function resolveActivationModerationAccounts(input: {
|
|
52
125
|
rpcUrl: string | null;
|
|
53
126
|
task: Address;
|
|
54
127
|
jobSpecHash: JobSpecHashSeed;
|
|
128
|
+
moderator: Address;
|
|
55
129
|
rpc?: AccountReadRpc;
|
|
56
|
-
}): Promise<
|
|
130
|
+
}): Promise<ActivationModerationAccounts> {
|
|
57
131
|
try {
|
|
58
|
-
const rpc =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
132
|
+
const rpc = readRpc(input);
|
|
133
|
+
if (!rpc) return {};
|
|
134
|
+
|
|
135
|
+
const moderationAttestor = await resolveRosterEntry(rpc, input.moderator);
|
|
136
|
+
const attestorPart =
|
|
137
|
+
moderationAttestor !== undefined ? { moderationAttestor } : {};
|
|
138
|
+
|
|
139
|
+
// Prefer the v2 moderator-keyed record (what recordTaskModeration writes
|
|
140
|
+
// post-upgrade); the facade derives it by default, so no override needed.
|
|
141
|
+
const [v2Pda] = await findTaskModerationPda({
|
|
142
|
+
task: input.task,
|
|
143
|
+
jobSpecHash: input.jobSpecHash,
|
|
144
|
+
moderator: input.moderator,
|
|
145
|
+
});
|
|
146
|
+
const v2 = await fetchMaybeTaskModeration(rpc, v2Pda);
|
|
147
|
+
if (v2.exists) return attestorPart;
|
|
148
|
+
|
|
149
|
+
// Grace window: a pre-upgrade record at the frozen legacy seeds is still
|
|
150
|
+
// consumable when the transaction points at it explicitly AND it was
|
|
151
|
+
// authored by the same moderator the gate is told to consume.
|
|
152
|
+
const [legacyPda] = await facade.findLegacyTaskModerationPda({
|
|
66
153
|
task: input.task,
|
|
67
154
|
jobSpecHash: input.jobSpecHash,
|
|
68
155
|
});
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
);
|
|
73
|
-
if (!taskModeration.exists) return undefined;
|
|
74
|
-
|
|
75
|
-
const [moderationConfigPda] = await findModerationConfigPda();
|
|
76
|
-
const moderationConfig = await fetchMaybeModerationConfig(
|
|
77
|
-
rpc,
|
|
78
|
-
moderationConfigPda,
|
|
79
|
-
);
|
|
80
|
-
if (
|
|
81
|
-
moderationConfig.exists &&
|
|
82
|
-
taskModeration.data.moderator ===
|
|
83
|
-
moderationConfig.data.moderationAuthority
|
|
84
|
-
) {
|
|
85
|
-
// Global-authority moderation: the gate needs no roster account.
|
|
86
|
-
return undefined;
|
|
156
|
+
const legacy = await fetchMaybeTaskModeration(rpc, legacyPda);
|
|
157
|
+
if (legacy.exists && legacy.data.moderator === input.moderator) {
|
|
158
|
+
return { ...attestorPart, taskModeration: legacyPda };
|
|
87
159
|
}
|
|
88
160
|
|
|
89
|
-
|
|
90
|
-
|
|
161
|
+
return attestorPart;
|
|
162
|
+
} catch {
|
|
163
|
+
// Degrade to "no overrides" — never block the flow on a read failure.
|
|
164
|
+
return {};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Resolve the moderation accounts to attach to a hire
|
|
170
|
+
* (`hire_from_listing` / `hire_from_listing_humanless`), given the
|
|
171
|
+
* `moderator` whose listing attestation the hire gate should consume.
|
|
172
|
+
*
|
|
173
|
+
* @param input.rpcUrl - Resolved HTTP RPC endpoint (from provider context).
|
|
174
|
+
* @param input.listing - The ServiceListing PDA being hired.
|
|
175
|
+
* @param input.listingSpecHash - The listing's pinned 32-byte `spec_hash`.
|
|
176
|
+
* @param input.moderator - The attestation signer the gate should consume.
|
|
177
|
+
* @param input.rpc - Test seam: a pre-built account-read RPC wins over
|
|
178
|
+
* `rpcUrl`.
|
|
179
|
+
*/
|
|
180
|
+
export async function resolveHireListingModerationAccounts(input: {
|
|
181
|
+
rpcUrl: string | null;
|
|
182
|
+
listing: Address;
|
|
183
|
+
listingSpecHash: JobSpecHashSeed;
|
|
184
|
+
moderator: Address;
|
|
185
|
+
rpc?: AccountReadRpc;
|
|
186
|
+
}): Promise<HireListingModerationAccounts> {
|
|
187
|
+
try {
|
|
188
|
+
const rpc = readRpc(input);
|
|
189
|
+
if (!rpc) return {};
|
|
190
|
+
|
|
191
|
+
const moderationAttestor = await resolveRosterEntry(rpc, input.moderator);
|
|
192
|
+
const attestorPart =
|
|
193
|
+
moderationAttestor !== undefined ? { moderationAttestor } : {};
|
|
194
|
+
|
|
195
|
+
const [v2Pda] = await findListingModerationPda({
|
|
196
|
+
listing: input.listing,
|
|
197
|
+
jobSpecHash: input.listingSpecHash,
|
|
198
|
+
moderator: input.moderator,
|
|
91
199
|
});
|
|
92
|
-
|
|
200
|
+
const v2 = await fetchMaybeListingModeration(rpc, v2Pda);
|
|
201
|
+
if (v2.exists) return attestorPart;
|
|
202
|
+
|
|
203
|
+
const [legacyPda] = await facade.findLegacyListingModerationPda({
|
|
204
|
+
listing: input.listing,
|
|
205
|
+
jobSpecHash: input.listingSpecHash,
|
|
206
|
+
});
|
|
207
|
+
const legacy = await fetchMaybeListingModeration(rpc, legacyPda);
|
|
208
|
+
if (legacy.exists && legacy.data.moderator === input.moderator) {
|
|
209
|
+
return { ...attestorPart, listingModeration: legacyPda };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return attestorPart;
|
|
93
213
|
} catch {
|
|
94
|
-
// Degrade to "no
|
|
95
|
-
|
|
96
|
-
return undefined;
|
|
214
|
+
// Degrade to "no overrides" — never block the flow on a read failure.
|
|
215
|
+
return {};
|
|
97
216
|
}
|
|
98
217
|
}
|