@tetsuo-ai/marketplace-react 0.4.0 → 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 +22 -0
- package/dist/{chunk-BNILOX3O.js → chunk-JVXGNW3Q.js} +35 -4
- package/dist/chunk-JVXGNW3Q.js.map +1 -0
- package/dist/{chunk-BTAVED7S.js → chunk-XLA7DARS.js} +35 -6
- package/dist/chunk-XLA7DARS.js.map +1 -0
- package/dist/components/index.cjs +129 -48
- 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 +89 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +50 -3
- package/dist/hooks/index.d.ts +50 -3
- package/dist/hooks/index.js +62 -4
- 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 +119 -38
- 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 +1 -1
- 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/useCompletionBond.ts +156 -0
- package/src/hooks/useTaskGuarantee.ts +120 -0
- package/src/index.ts +2 -0
- package/src/types.ts +5 -2
- package/dist/chunk-BNILOX3O.js.map +0 -1
- package/dist/chunk-BTAVED7S.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode, ButtonHTMLAttributes, HTMLAttributes, RefObject } from 'react';
|
|
2
|
-
import { ListActiveListingsOptions, DecodedProgramAccount, ServiceListing, IndexerListing, IndexerHire, IndexerAgentTrackRecord, MarketplaceClient, ProgramAccountsTransport, CreateIndexerClientOptions, TaskStatus, fetchMaybeAgentVerification, AgentVerification } from '@tetsuo-ai/marketplace-sdk';
|
|
2
|
+
import { ListActiveListingsOptions, DecodedProgramAccount, ServiceListing, IndexerListing, IndexerHire, IndexerAgentTrackRecord, MarketplaceClient, ProgramAccountsTransport, CreateIndexerClientOptions, TaskGuarantee, TaskStatus, fetchMaybeAgentVerification, AgentVerification } from '@tetsuo-ai/marketplace-sdk';
|
|
3
|
+
import { T as TaskGuaranteeReader, f as HireStatus, b as AnyHireInput, i as ReviewStatus, c as DisputeStatus, a as AgentTrackRecord } from './useAgentTrackRecord-DPt3SfYz.cjs';
|
|
3
4
|
import { Address, TransactionSigner, Rpc, GetProgramAccountsApi } from '@solana/kit';
|
|
4
|
-
import { f as HireStatus, b as AnyHireInput, i as ReviewStatus, c as DisputeStatus, a as AgentTrackRecord } from './useAgentTrackRecord-BCvRHYM2.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Shared types for `@tetsuo-ai/marketplace-react`.
|
|
@@ -174,9 +174,12 @@ interface AgencContextValue {
|
|
|
174
174
|
client: MarketplaceClient | null;
|
|
175
175
|
/**
|
|
176
176
|
* The resolved HTTP RPC endpoint (config override or the network default),
|
|
177
|
-
* or `null` when none resolves. Hooks use it for
|
|
177
|
+
* or `null` when none resolves. Hooks use it for targeted per-task reads —
|
|
178
178
|
* e.g. resolving the WP-A1 `moderation_attestor` roster account during
|
|
179
|
-
* activation
|
|
179
|
+
* activation, and the `useTaskGuarantee` completion-bond read (a
|
|
180
|
+
* task-scoped `getProgramAccounts` with no single-account equivalent; the
|
|
181
|
+
* RPC must allow gPA, and an injected reader seam bypasses it). LIST
|
|
182
|
+
* queries stay with the read transport.
|
|
180
183
|
*/
|
|
181
184
|
rpcUrl: string | null;
|
|
182
185
|
/**
|
|
@@ -438,6 +441,46 @@ interface VerifiedBadgeProps extends ThemableProps {
|
|
|
438
441
|
*/
|
|
439
442
|
declare function VerifiedBadge({ verified, unstyled, className, }: VerifiedBadgeProps): ReactNode;
|
|
440
443
|
|
|
444
|
+
/**
|
|
445
|
+
* `<GuaranteedBadge task={...} />` — the Guaranteed Hire badge (WP-H3).
|
|
446
|
+
*
|
|
447
|
+
* Renders NOTHING unless the task is guaranteed (a live worker completion
|
|
448
|
+
* bond: the worker staked 25% of the reward on passing review). When it is,
|
|
449
|
+
* shows a small success-tone badge with plain-English copy; the full detail
|
|
450
|
+
* sentence rides on `title`/`aria-label`.
|
|
451
|
+
*
|
|
452
|
+
* Connected by default: given `task`, it reads through {@link useTaskGuarantee}
|
|
453
|
+
* (provider `rpcUrl` gPA read, or the `guaranteeReader` seam). Pass a
|
|
454
|
+
* pre-resolved `guarantee` to use it presentationally (no read at all) — an
|
|
455
|
+
* explicit `guarantee` (including `null`) wins over the `task` read.
|
|
456
|
+
*
|
|
457
|
+
* HONEST BOUNDARY (phase 1): the copy says the buyer is refunded and the
|
|
458
|
+
* worker FORFEITS the bond — it deliberately does NOT promise the buyer the
|
|
459
|
+
* bond itself, because a forfeited bond pays the protocol treasury until
|
|
460
|
+
* phase 2 redirects it to the harmed party. Keep host copy within that line.
|
|
461
|
+
*
|
|
462
|
+
* @module components/GuaranteedBadge
|
|
463
|
+
*/
|
|
464
|
+
|
|
465
|
+
/** Props for {@link GuaranteedBadge}. */
|
|
466
|
+
interface GuaranteedBadgeProps extends ThemableProps {
|
|
467
|
+
/** The Task PDA to read the guarantee for (connected mode). */
|
|
468
|
+
task?: Address | string | null;
|
|
469
|
+
/**
|
|
470
|
+
* Pre-resolved guarantee state (presentational mode — overrides the `task`
|
|
471
|
+
* read entirely; pass `null` for a known-unguaranteed task).
|
|
472
|
+
*/
|
|
473
|
+
guarantee?: TaskGuarantee | null;
|
|
474
|
+
/** Injected reader seam forwarded to {@link useTaskGuarantee} (tests/litesvm). */
|
|
475
|
+
guaranteeReader?: TaskGuaranteeReader;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Show that a task's result is backed by the worker's 25% completion bond.
|
|
479
|
+
* Renders nothing while loading, on read errors, and for unguaranteed tasks —
|
|
480
|
+
* the badge only ever ASSERTS a live guarantee, never its absence.
|
|
481
|
+
*/
|
|
482
|
+
declare function GuaranteedBadge({ task, guarantee, guaranteeReader, unstyled, className, }: GuaranteedBadgeProps): ReactNode;
|
|
483
|
+
|
|
441
484
|
/**
|
|
442
485
|
* Component-layer string catalog (PLAN_2 A3).
|
|
443
486
|
*
|
|
@@ -533,6 +576,8 @@ declare const EN_COMPONENT_STRINGS: {
|
|
|
533
576
|
readonly "components.provider.verifiedDomainLabel": "Verified domain {domain}";
|
|
534
577
|
readonly "components.provider.claimedDomain": "Claims: {domain}";
|
|
535
578
|
readonly "components.provider.claimedDomainLabel": "Claimed domain {domain} (not verified on-chain)";
|
|
579
|
+
readonly "components.guarantee.badge": "Guaranteed — worker has 25% at stake";
|
|
580
|
+
readonly "components.guarantee.detail": "Worker has 25% at stake — if the result fails review you're refunded and the worker forfeits the bond.";
|
|
536
581
|
readonly "components.poweredBy.label": "Powered by AgenC";
|
|
537
582
|
readonly "components.poweredBy.trustLink": "Learn how this works";
|
|
538
583
|
};
|
|
@@ -1269,4 +1314,4 @@ interface PoweredByAgenCProps extends ThemableProps {
|
|
|
1269
1314
|
*/
|
|
1270
1315
|
declare function PoweredByAgenC({ href, newTab, label, unstyled, className, }: PoweredByAgenCProps): ReactNode;
|
|
1271
1316
|
|
|
1272
|
-
export {
|
|
1317
|
+
export { Spinner as $, type AgencProviderConfig as A, Badge as B, type CreateReadTransportConfig as C, DEFAULT_TRUST_HREF as D, EN_COMPONENT_STRINGS as E, ListingGrid as F, type GpaReadSource as G, HireButton as H, type IndexerConfig as I, type ListingGridProps as J, type ModalProps as K, ListingCard as L, Modal as M, ModerationBadge as N, type ModerationBadgeProps as O, type ModerationState as P, PoweredByAgenC as Q, type ReferrerCapability as R, type PoweredByAgenCProps as S, ProviderCard as T, type ProviderCardProps as U, type ValidatedReferrerConfig as V, type ReadListingResult as W, ReferrerDisclosure as X, type ReferrerDisclosureProps as Y, ReviewPanel as Z, type ReviewPanelProps as _, type AgencContextValue as a, type SpinnerProps as a0, type StateKind as a1, StateMessage as a2, type StateMessageProps as a3, type StringCatalog as a4, type StringId as a5, type StringVars as a6, TaskTimeline as a7, type TaskTimelineProps as a8, type ThemableProps as a9, type TranslateOptions as aa, UNVERIFIED as ab, type UseAgentVerificationOptions as ac, type UseAgentVerificationResult as ad, VerifiedBadge as ae, type VerifiedBadgeProps as af, agentVerificationReaderFromRpc as ag, cx as ah, decodeListingCategory as ai, decodeListingName as aj, decodeListingTags as ak, elementClass as al, evaluateAgentVerification as am, formatPriceSol as an, formatRate as ao, formatSol as ap, moderationStateOf as aq, rootClass as ar, t as as, tc as at, toHex as au, truncateAddress as av, useAgentVerification as aw, useFocusTrap as ax, type ReferrerConfig as b, type AgencNetwork as c, type ReadTransport as d, type AgentVerificationReader as e, type AgentVerificationReaderOptions as f, type AgentVerificationResult as g, type AgentVerificationRpc as h, type BadgeProps as i, type BadgeTone as j, Button as k, type ButtonProps as l, type ButtonVariant as m, COMPONENT_CATALOG as n, type ComponentStringId as o, DisputeBanner as p, type DisputeBannerProps as q, EN_STRINGS as r, GuaranteedBadge as s, type GuaranteedBadgeProps as t, type HireButtonProps as u, type HireCheckoutListing as v, HireCheckoutModal as w, type HireCheckoutModalProps as x, type ListingCardData as y, type ListingCardProps as z };
|
package/dist/index.cjs
CHANGED
|
@@ -485,6 +485,12 @@ var EN_COMPONENT_STRINGS = {
|
|
|
485
485
|
"components.provider.verifiedDomainLabel": "Verified domain {domain}",
|
|
486
486
|
"components.provider.claimedDomain": "Claims: {domain}",
|
|
487
487
|
"components.provider.claimedDomainLabel": "Claimed domain {domain} (not verified on-chain)",
|
|
488
|
+
// GuaranteedBadge (WP-H3 Guaranteed Hire). The detail copy is deliberately
|
|
489
|
+
// phase-1-honest: the buyer is refunded (escrow) and the worker FORFEITS the
|
|
490
|
+
// bond — it does NOT say the buyer receives the bond, because a forfeited
|
|
491
|
+
// bond pays the protocol treasury until phase 2 redirects it.
|
|
492
|
+
"components.guarantee.badge": "Guaranteed \u2014 worker has 25% at stake",
|
|
493
|
+
"components.guarantee.detail": "Worker has 25% at stake \u2014 if the result fails review you're refunded and the worker forfeits the bond.",
|
|
488
494
|
// PoweredByAgenC.
|
|
489
495
|
"components.poweredBy.label": "Powered by AgenC",
|
|
490
496
|
"components.poweredBy.trustLink": "Learn how this works"
|
|
@@ -711,6 +717,118 @@ function VerifiedBadge({
|
|
|
711
717
|
}
|
|
712
718
|
);
|
|
713
719
|
}
|
|
720
|
+
|
|
721
|
+
// src/hooks/internal.ts
|
|
722
|
+
var QUERY_KEY_ROOT = "agenc";
|
|
723
|
+
var queryKeys = {
|
|
724
|
+
/** All listings list queries (with their filter object as the leaf). */
|
|
725
|
+
listings: (filter) => [QUERY_KEY_ROOT, "listings", filter ?? null],
|
|
726
|
+
/** One listing + its joined provider/track-record/moderation. */
|
|
727
|
+
listing: (pda) => [QUERY_KEY_ROOT, "listing", pda],
|
|
728
|
+
/** One agent's indexer track record. */
|
|
729
|
+
agentTrackRecord: (agentPda) => [QUERY_KEY_ROOT, "agentTrackRecord", agentPda],
|
|
730
|
+
/** One task's status (read via transport / svm decode). */
|
|
731
|
+
taskStatus: (taskPda) => [QUERY_KEY_ROOT, "taskStatus", taskPda],
|
|
732
|
+
/** One task's dispute record. */
|
|
733
|
+
dispute: (taskPda) => [QUERY_KEY_ROOT, "dispute", taskPda],
|
|
734
|
+
/** One task's completion-bond ("Guaranteed Hire") state. */
|
|
735
|
+
taskGuarantee: (taskPda) => [QUERY_KEY_ROOT, "taskGuarantee", taskPda],
|
|
736
|
+
/** One referrer wallet's earnings (indexer-gated; see useReferrerEarnings). */
|
|
737
|
+
referrerEarnings: (wallet) => [QUERY_KEY_ROOT, "referrerEarnings", wallet]
|
|
738
|
+
};
|
|
739
|
+
function requireClient(client) {
|
|
740
|
+
if (client === null) {
|
|
741
|
+
throw new Error(t("provider.missingWriteClient"));
|
|
742
|
+
}
|
|
743
|
+
return client;
|
|
744
|
+
}
|
|
745
|
+
function pdaKey(pda) {
|
|
746
|
+
return String(pda);
|
|
747
|
+
}
|
|
748
|
+
function resolveReferrerArgs(ctx) {
|
|
749
|
+
const capability = ctx.resolveReferrerCapability();
|
|
750
|
+
if (!capability.live || !capability.referrer) {
|
|
751
|
+
return { referrerArgs: {}, referrerInjected: false };
|
|
752
|
+
}
|
|
753
|
+
return {
|
|
754
|
+
referrerArgs: {
|
|
755
|
+
referrer: capability.referrer.wallet,
|
|
756
|
+
referrerFeeBps: capability.referrer.feeBps
|
|
757
|
+
},
|
|
758
|
+
referrerInjected: true
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
function signerAddress(signerOrAddress) {
|
|
762
|
+
if (typeof signerOrAddress === "string") {
|
|
763
|
+
return signerOrAddress;
|
|
764
|
+
}
|
|
765
|
+
if (typeof signerOrAddress === "object" && signerOrAddress !== null && "address" in signerOrAddress && typeof signerOrAddress.address === "string") {
|
|
766
|
+
return signerOrAddress.address;
|
|
767
|
+
}
|
|
768
|
+
throw new Error("Expected a TransactionSigner or Address with an address field.");
|
|
769
|
+
}
|
|
770
|
+
function withoutReferrerArgs(input) {
|
|
771
|
+
const {
|
|
772
|
+
referrer: _referrer,
|
|
773
|
+
referrerFeeBps: _referrerFeeBps,
|
|
774
|
+
...rest
|
|
775
|
+
} = input;
|
|
776
|
+
return rest;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// src/hooks/useTaskGuarantee.ts
|
|
780
|
+
function useTaskGuarantee(taskPda, options) {
|
|
781
|
+
const ctx = useAgencContext();
|
|
782
|
+
const injected = options?.guaranteeReader;
|
|
783
|
+
const rpcUrl = ctx.rpcUrl;
|
|
784
|
+
const reader = react.useMemo(() => {
|
|
785
|
+
if (injected) return injected;
|
|
786
|
+
if (!rpcUrl) return null;
|
|
787
|
+
return (pda) => marketplaceSdk.fetchTaskGuarantee(
|
|
788
|
+
kit.createSolanaRpc(rpcUrl),
|
|
789
|
+
pda
|
|
790
|
+
);
|
|
791
|
+
}, [injected, rpcUrl]);
|
|
792
|
+
const enabled = (options?.enabled ?? true) && Boolean(taskPda) && reader !== null;
|
|
793
|
+
const query = reactQuery.useQuery({
|
|
794
|
+
queryKey: queryKeys.taskGuarantee(taskPda ? pdaKey(taskPda) : ""),
|
|
795
|
+
enabled,
|
|
796
|
+
queryFn: () => reader(taskPda)
|
|
797
|
+
});
|
|
798
|
+
const guarantee = query.data ?? null;
|
|
799
|
+
return {
|
|
800
|
+
guarantee,
|
|
801
|
+
guaranteed: guarantee?.guaranteed ?? false,
|
|
802
|
+
isLoading: query.isLoading,
|
|
803
|
+
error: query.error ?? null,
|
|
804
|
+
refetch: () => void query.refetch()
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
function GuaranteedBadge({
|
|
808
|
+
task,
|
|
809
|
+
guarantee,
|
|
810
|
+
guaranteeReader,
|
|
811
|
+
unstyled,
|
|
812
|
+
className
|
|
813
|
+
}) {
|
|
814
|
+
const overridden = guarantee !== void 0;
|
|
815
|
+
const read = useTaskGuarantee(overridden ? null : task, {
|
|
816
|
+
guaranteeReader,
|
|
817
|
+
enabled: !overridden
|
|
818
|
+
});
|
|
819
|
+
const resolved = overridden ? guarantee : read.guarantee;
|
|
820
|
+
if (!resolved?.guaranteed) return null;
|
|
821
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
822
|
+
Badge,
|
|
823
|
+
{
|
|
824
|
+
tone: "success",
|
|
825
|
+
unstyled,
|
|
826
|
+
className,
|
|
827
|
+
label: tc("components.guarantee.detail"),
|
|
828
|
+
children: tc("components.guarantee.badge")
|
|
829
|
+
}
|
|
830
|
+
);
|
|
831
|
+
}
|
|
714
832
|
var FOCUSABLE_SELECTOR = [
|
|
715
833
|
"a[href]",
|
|
716
834
|
"button:not([disabled])",
|
|
@@ -976,44 +1094,6 @@ function ListingGrid({
|
|
|
976
1094
|
) }) : null
|
|
977
1095
|
] });
|
|
978
1096
|
}
|
|
979
|
-
|
|
980
|
-
// src/hooks/internal.ts
|
|
981
|
-
function requireClient(client) {
|
|
982
|
-
if (client === null) {
|
|
983
|
-
throw new Error(t("provider.missingWriteClient"));
|
|
984
|
-
}
|
|
985
|
-
return client;
|
|
986
|
-
}
|
|
987
|
-
function resolveReferrerArgs(ctx) {
|
|
988
|
-
const capability = ctx.resolveReferrerCapability();
|
|
989
|
-
if (!capability.live || !capability.referrer) {
|
|
990
|
-
return { referrerArgs: {}, referrerInjected: false };
|
|
991
|
-
}
|
|
992
|
-
return {
|
|
993
|
-
referrerArgs: {
|
|
994
|
-
referrer: capability.referrer.wallet,
|
|
995
|
-
referrerFeeBps: capability.referrer.feeBps
|
|
996
|
-
},
|
|
997
|
-
referrerInjected: true
|
|
998
|
-
};
|
|
999
|
-
}
|
|
1000
|
-
function signerAddress(signerOrAddress) {
|
|
1001
|
-
if (typeof signerOrAddress === "string") {
|
|
1002
|
-
return signerOrAddress;
|
|
1003
|
-
}
|
|
1004
|
-
if (typeof signerOrAddress === "object" && signerOrAddress !== null && "address" in signerOrAddress && typeof signerOrAddress.address === "string") {
|
|
1005
|
-
return signerOrAddress.address;
|
|
1006
|
-
}
|
|
1007
|
-
throw new Error("Expected a TransactionSigner or Address with an address field.");
|
|
1008
|
-
}
|
|
1009
|
-
function withoutReferrerArgs(input) {
|
|
1010
|
-
const {
|
|
1011
|
-
referrer: _referrer,
|
|
1012
|
-
referrerFeeBps: _referrerFeeBps,
|
|
1013
|
-
...rest
|
|
1014
|
-
} = input;
|
|
1015
|
-
return rest;
|
|
1016
|
-
}
|
|
1017
1097
|
function readRpc(input) {
|
|
1018
1098
|
return input.rpc ?? (input.rpcUrl ? kit.createSolanaRpc(input.rpcUrl) : null);
|
|
1019
1099
|
}
|
|
@@ -1836,6 +1916,7 @@ exports.DisputeBanner = DisputeBanner;
|
|
|
1836
1916
|
exports.EN_COMPONENT_STRINGS = EN_COMPONENT_STRINGS;
|
|
1837
1917
|
exports.EN_SIGNER_STRINGS = EN_SIGNER_STRINGS;
|
|
1838
1918
|
exports.EN_STRINGS = EN_STRINGS;
|
|
1919
|
+
exports.GuaranteedBadge = GuaranteedBadge;
|
|
1839
1920
|
exports.HireButton = HireButton;
|
|
1840
1921
|
exports.HireCheckoutModal = HireCheckoutModal;
|
|
1841
1922
|
exports.ListingCard = ListingCard;
|