@tetsuo-ai/marketplace-react 0.4.1 → 0.5.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.
- package/CHANGELOG.md +56 -0
- package/README.md +93 -47
- package/dist/chunk-7NKRSPPN.js +227 -0
- package/dist/chunk-7NKRSPPN.js.map +1 -0
- package/dist/{chunk-JVXGNW3Q.js → chunk-CDDHUFMG.js} +6 -5
- package/dist/chunk-CDDHUFMG.js.map +1 -0
- package/dist/chunk-FIDFPM5A.cjs +40 -0
- package/dist/chunk-FIDFPM5A.cjs.map +1 -0
- package/dist/chunk-IJKWKY4H.cjs +1370 -0
- package/dist/chunk-IJKWKY4H.cjs.map +1 -0
- package/dist/chunk-JTSG5FGC.cjs +397 -0
- package/dist/chunk-JTSG5FGC.cjs.map +1 -0
- package/dist/chunk-ONC6L3IX.cjs +97 -0
- package/dist/chunk-ONC6L3IX.cjs.map +1 -0
- package/dist/chunk-R76EUYDI.cjs +233 -0
- package/dist/chunk-R76EUYDI.cjs.map +1 -0
- package/dist/{chunk-XLA7DARS.js → chunk-RG5JZ6JL.js} +159 -36
- package/dist/chunk-RG5JZ6JL.js.map +1 -0
- package/dist/components/index.cjs +158 -1594
- 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 +656 -509
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +63 -29
- package/dist/hooks/index.d.ts +63 -29
- package/dist/hooks/index.js +619 -196
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-CmVz0OOm.d.ts → index-BAyr1ODZ.d.ts} +28 -3
- package/dist/{index-DAZzhuO4.d.cts → index-C20NVU7_.d.cts} +28 -3
- package/dist/index.cjs +284 -1833
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +64 -4
- package/dist/index.js.map +1 -1
- package/dist/signers/index.cjs +22 -161
- package/dist/signers/index.cjs.map +1 -1
- package/dist/signers/index.d.cts +16 -11
- package/dist/signers/index.d.ts +16 -11
- package/dist/signers/index.js +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/theme/agenc-tailwind-preset.cjs +134 -108
- package/dist/{types-jvISR6bc.d.cts → types-B10rndEI.d.cts} +16 -7
- package/dist/{types-jvISR6bc.d.ts → types-B10rndEI.d.ts} +16 -7
- package/dist/{useAgentTrackRecord-DPt3SfYz.d.cts → useAgentTrackRecord-Ch7gHTFj.d.cts} +1 -1
- package/dist/{useAgentTrackRecord-DPt3SfYz.d.ts → useAgentTrackRecord-Ch7gHTFj.d.ts} +1 -1
- package/package.json +6 -3
- package/src/components/HireCheckoutModal.tsx +5 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/internal.ts +178 -24
- package/src/hooks/useAgentTrackRecord.ts +5 -2
- package/src/hooks/useCompletionBond.ts +56 -21
- package/src/hooks/useDispute.ts +46 -9
- package/src/hooks/useHire.ts +113 -23
- package/src/hooks/useHumanlessHireFlow.ts +335 -115
- package/src/hooks/useListing.ts +2 -2
- package/src/hooks/useListings.ts +2 -2
- package/src/hooks/useRateHire.ts +32 -5
- package/src/hooks/useReferrerEarnings.ts +4 -1
- package/src/hooks/useSubmissionReview.ts +95 -32
- package/src/hooks/useTaskActivation.ts +51 -9
- package/src/hooks/useTaskGuarantee.ts +4 -1
- package/src/hooks/useTaskLifecycle.ts +104 -24
- package/src/hooks/useTaskStatus.ts +121 -26
- package/src/hooks/useTaskWork.ts +76 -12
- package/src/hooks/useWalletSigner.ts +11 -16
- package/src/index.ts +3 -0
- package/src/provider/AgencProvider.tsx +95 -3
- package/src/provider/referrer.ts +1 -1
- package/src/signers/README.md +13 -7
- package/src/signers/index.ts +6 -1
- package/src/signers/strings.ts +13 -1
- package/src/signers/types.ts +16 -5
- package/src/signers/wallet-account.ts +115 -29
- package/src/signers/wallet-adapter.ts +38 -4
- package/src/theme/agenc-tailwind-preset.cjs +134 -108
- package/src/types.ts +27 -1
- package/dist/chunk-JVXGNW3Q.js.map +0 -1
- package/dist/chunk-ON6XR4XO.js +0 -128
- package/dist/chunk-ON6XR4XO.js.map +0 -1
- package/dist/chunk-XLA7DARS.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider/context.ts","../src/hooks/internal.ts","../src/hooks/useTaskGuarantee.ts","../src/hooks/moderation-attestor.ts","../src/hooks/useHire.ts","../src/hooks/useWalletSigner.ts"],"names":["createSolanaRpc","useMemo","useCallback"],"mappings":";;;;;;AAkBO,IAAM,YAAA,GAAe,cAAwC,IAAI;AACxE,YAAA,CAAa,WAAA,GAAc,cAAA;AASpB,SAAS,eAAA,GAAqC;AACnD,EAAA,MAAM,GAAA,GAAM,WAAW,YAAY,CAAA;AACnC,EAAA,IAAI,QAAQ,IAAA,EAAM;AAChB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,CAAE,yBAAyB,CAAC,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,GAAA;AACT;;;ACZO,IAAM,cAAA,GAAiB;AAWvB,IAAM,SAAA,GAAY;AAAA;AAAA,EAEvB,UAAU,CAAC,MAAA,KACT,CAAC,cAAA,EAAgB,UAAA,EAAY,UAAU,IAAI,CAAA;AAAA;AAAA,EAE7C,SAAS,CAAC,GAAA,KAAgB,CAAC,cAAA,EAAgB,WAAW,GAAG,CAAA;AAAA;AAAA,EAEzD,kBAAkB,CAAC,QAAA,KACjB,CAAC,cAAA,EAAgB,oBAAoB,QAAQ,CAAA;AAAA;AAAA,EAE/C,YAAY,CAAC,OAAA,KACX,CAAC,cAAA,EAAgB,cAAc,OAAO,CAAA;AAAA;AAAA,EAExC,SAAS,CAAC,OAAA,KAAoB,CAAC,cAAA,EAAgB,WAAW,OAAO,CAAA;AAAA;AAAA,EAEjE,eAAe,CAAC,OAAA,KACd,CA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,WAAW,OAAO,SAAA;AAC/B,IAAA,IAAI,QAAA,CAAS,SAAS,OAAO,OAAA;AAC7B,IAAA,IAAI,QAAA,CAAS,WAAW,OAAO,SAAA;AAC/B,IAAA,OAAO,MAAA;AAAA,EACT,CAAA,EAAG,CAAC,QAAA,CAAS,SAAA,EAAW,SAAS,OAAA,EAAS,QAAA,CAAS,SAAS,CAAC,CAAA;AAE7D,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA,EAAS,QAAA,CAAS,IAAA,EAAM,OAAA,IAAW,IAAA;AAAA,IACnC,SAAA,EAAW,QAAA,CAAS,IAAA,EAAM,SAAA,IAAa,IAAA;AAAA,IACvC,KAAA,EAAO,SAAS,KAAA,IAAS,IAAA;AAAA,IACzB,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,OAAO,QAAA,CAAS;AAAA,GAClB;AACF;AC3IO,SAAS,gBACd,OAAA,EACuB;AACvB,EAAA,MAAM,MAAM,eAAA,EAAgB;AAC5B,EAAA,MAAM,UAAU,OAAA,EAAS,OAAA;AAGzB,EAAA,MAAM,MAAA,GACJ,OAAA,EAAS,MAAA,IAAU,GAAA,CAAI,MAAA,IAAU,IAAA;AACnC,EAAA,MAAM,SAAA,GACJ,YAAY,MAAA,GACP,OAAA,CAAQ,aAAa,OAAA,CAAQ,MAAA,KAAW,IAAA,GACzC,GAAA,CAAI,MAAA,KAAW,IAAA;AAErB,EAAA,MAAM,OAAA,GAAUC,YAAY,MAAM;AAGhC,IAAA,OAAO,OAAA,EAAS,OAAA,GAAU,OAAA,CAAQ,OAAA,EAAQ,GAAI,MAAA;AAAA,EAChD,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAA,OAAO,EAAE,MAAA,EAAQ,SAAA,EAAW,OAAA,EAAQ;AACtC","file":"chunk-XLA7DARS.js","sourcesContent":["/**\n * The React context object + the internal `useAgencContext()` hook.\n *\n * Split from the component file so the context identity is stable and so hooks\n * can import the context without pulling the JSX provider into their module\n * graph. SSR-safe: this module only calls `createContext` at import time, never\n * touches `window`.\n *\n * @module provider/context\n */\nimport { createContext, useContext } from \"react\";\nimport { t } from \"../strings/index.js\";\nimport type { AgencContextValue } from \"../types.js\";\n\n/**\n * The AgenC context. `null` until a `<AgencProvider>` mounts above the consumer\n * — {@link useAgencContext} turns that into a clear developer error.\n */\nexport const AgencContext = createContext<AgencContextValue | null>(null);\nAgencContext.displayName = \"AgencContext\";\n\n/**\n * Read the AgenC context. INTERNAL hook the package's own hooks build on; also\n * exported from the package root so downstream hooks (components agent) can\n * reach the resolved transport/client/referrer.\n *\n * @throws Error when called outside a `<AgencProvider>`.\n */\nexport function useAgencContext(): AgencContextValue {\n const ctx = useContext(AgencContext);\n if (ctx === null) {\n throw new Error(t(\"provider.missingContext\"));\n }\n return ctx;\n}\n","/**\n * Internal helpers shared by the headless hooks.\n *\n * - A namespaced TanStack Query key factory so every hook's cache entries are\n * stable, collision-free, and individually invalidatable.\n * - Tiny guards that turn a missing write client / signer into a clear,\n * catalog-routed error (never a `null.method()` crash) BEFORE a mutation runs.\n *\n * SSR-safe: pure functions, no `window`/`document`, no module-scope side\n * effects.\n *\n * @module hooks/internal\n */\nimport { t } from \"../strings/index.js\";\nimport type {\n Address,\n AgencContextValue,\n MarketplaceClient,\n TransactionSigner,\n} from \"../types.js\";\n\n/** Root namespace for every cache key this package writes. */\nexport const QUERY_KEY_ROOT = \"agenc\" as const;\n\n/**\n * Stable, hierarchical TanStack Query keys. Hooks build their keys ONLY through\n * this factory so a consumer (or a hook) can invalidate a whole sub-tree\n * (`[\"agenc\", \"listings\"]`) or one entity (`[\"agenc\", \"listing\", pda]`).\n *\n * `JSON.stringify` is intentionally NOT used — TanStack compares keys\n * structurally, so passing the raw filter object keeps equality correct for\n * `bigint`/`Address` values without a serialization step.\n */\nexport const queryKeys = {\n /** All listings list queries (with their filter object as the leaf). */\n listings: (filter?: unknown) =>\n [QUERY_KEY_ROOT, \"listings\", filter ?? null] as const,\n /** One listing + its joined provider/track-record/moderation. */\n listing: (pda: string) => [QUERY_KEY_ROOT, \"listing\", pda] as const,\n /** One agent's indexer track record. */\n agentTrackRecord: (agentPda: string) =>\n [QUERY_KEY_ROOT, \"agentTrackRecord\", agentPda] as const,\n /** One task's status (read via transport / svm decode). */\n taskStatus: (taskPda: string) =>\n [QUERY_KEY_ROOT, \"taskStatus\", taskPda] as const,\n /** One task's dispute record. */\n dispute: (taskPda: string) => [QUERY_KEY_ROOT, \"dispute\", taskPda] as const,\n /** One task's completion-bond (\"Guaranteed Hire\") state. */\n taskGuarantee: (taskPda: string) =>\n [QUERY_KEY_ROOT, \"taskGuarantee\", taskPda] as const,\n /** One referrer wallet's earnings (indexer-gated; see useReferrerEarnings). */\n referrerEarnings: (wallet: string) =>\n [QUERY_KEY_ROOT, \"referrerEarnings\", wallet] as const,\n} as const;\n\n/**\n * Assert a write client exists, returning it narrowed to non-null. Throws a\n * clear, catalog-routed error when the provider was configured read-only (no\n * `client` and no resolvable `rpcUrl` + `signer`).\n *\n * Mutating hooks call this at the top of their `mutationFn` so the failure is a\n * descriptive Error in the mutation's `error` channel — never a crash.\n *\n * @throws Error (`provider.missingWriteClient`) when `client` is null.\n */\nexport function requireClient(\n client: MarketplaceClient | null,\n): MarketplaceClient {\n if (client === null) {\n throw new Error(t(\"provider.missingWriteClient\"));\n }\n return client;\n}\n\nexport type MutationStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\nexport function mutationStatusOf(mutation: {\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n}): MutationStatus {\n if (mutation.isPending) return \"pending\";\n if (mutation.isError) return \"error\";\n if (mutation.isSuccess) return \"success\";\n return \"idle\";\n}\n\n/** Coerce an `Address | string` to its string form for use as a cache key. */\nexport function pdaKey(pda: Address | string): string {\n return String(pda);\n}\n\nexport interface ReferrerArgs {\n referrer?: Address;\n referrerFeeBps?: number;\n}\n\nexport interface ResolvedReferrerArgs {\n referrerArgs: ReferrerArgs;\n referrerInjected: boolean;\n}\n\nexport function resolveReferrerArgs(\n ctx: Pick<AgencContextValue, \"resolveReferrerCapability\">,\n): ResolvedReferrerArgs {\n const capability = ctx.resolveReferrerCapability();\n if (!capability.live || !capability.referrer) {\n return { referrerArgs: {}, referrerInjected: false };\n }\n return {\n referrerArgs: {\n referrer: capability.referrer.wallet,\n referrerFeeBps: capability.referrer.feeBps,\n },\n referrerInjected: true,\n };\n}\n\nexport type SignerOrAddress = TransactionSigner | Address;\n\nexport function signerAddress(signerOrAddress: SignerOrAddress): Address {\n if (typeof signerOrAddress === \"string\") {\n return signerOrAddress;\n }\n if (\n typeof signerOrAddress === \"object\" &&\n signerOrAddress !== null &&\n \"address\" in signerOrAddress &&\n typeof signerOrAddress.address === \"string\"\n ) {\n return signerOrAddress.address;\n }\n throw new Error(\"Expected a TransactionSigner or Address with an address field.\");\n}\n\nexport function withoutReferrerArgs<T extends object>(\n input: T,\n): Omit<T, \"referrer\" | \"referrerFeeBps\"> {\n const {\n referrer: _referrer,\n referrerFeeBps: _referrerFeeBps,\n ...rest\n } = input as T & { referrer?: unknown; referrerFeeBps?: unknown };\n return rest;\n}\n","/**\n * `useTaskGuarantee(taskPda)` — a task's completion-bond (\"Guaranteed Hire\")\n * state, read-only.\n *\n * Guaranteed Hire is the productized read of the LIVE completion-bond\n * machinery: a worker who posts a completion bond stakes 25% of the reward on\n * passing review, and forfeits it if the result is rejected or they lose a\n * dispute. `guaranteed` is `true` iff the worker bond is posted and unresolved\n * (bond PDAs are closed by every settlement exit, so live == unresolved).\n *\n * HONEST BOUNDARY (phase 1 — do not overclaim in UI copy): a FORFEITED bond\n * pays the protocol **treasury**, not the harmed party. The buyer's protection\n * today is the escrow refund on a failed review PLUS the worker's 25% skin in\n * the game — the buyer does not receive the bond itself. Phase 2 (batch-2\n * program work) redirects forfeiture to the harmed party.\n *\n * ## How it reads\n *\n * The bond accounts are keyed by (task, posting wallet) and the worker's\n * wallet is not derivable from the Task account alone, so this is a\n * `getProgramAccounts` read (`CompletionBond.task` memcmp) — the SDK's\n * `fetchTaskGuarantee`. Resolution order:\n * 1. `options.guaranteeReader` — an injected reader seam (tests, litesvm,\n * custom transports; same pattern as `useTaskStatus`/`useDispute`);\n * 2. the provider's resolved `rpcUrl` — a kit RPC is built for the read. NOTE:\n * the RPC must allow `getProgramAccounts` (many public providers restrict\n * it); a rejection surfaces in `error`, never a crash.\n * Without either, the hook stays idle.\n *\n * @module hooks/useTaskGuarantee\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useMemo } from \"react\";\nimport { createSolanaRpc } from \"@solana/kit\";\nimport {\n fetchTaskGuarantee,\n type ProgramAccountsSource,\n type TaskGuarantee,\n} from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address } from \"../types.js\";\nimport { pdaKey, queryKeys } from \"./internal.js\";\n\n/** Reads a task's {@link TaskGuarantee} (the SDK `fetchTaskGuarantee` shape). */\nexport type TaskGuaranteeReader = (\n taskPda: Address | string,\n) => Promise<TaskGuarantee>;\n\n/** Options for {@link useTaskGuarantee}. */\nexport interface UseTaskGuaranteeOptions {\n /**\n * Injected reader seam (wins over the provider `rpcUrl` default). Wire it\n * from litesvm/gpa-sim in tests or from your own transport.\n */\n guaranteeReader?: TaskGuaranteeReader;\n /** Disable the read. Default `true` when `taskPda` + a read source exist. */\n enabled?: boolean;\n}\n\n/** Return value of {@link useTaskGuarantee}. */\nexport interface UseTaskGuaranteeResult {\n /** The full bond state (worker/creator bonds + flag), or null until read. */\n guarantee: TaskGuarantee | null;\n /**\n * Convenience: `guarantee?.guaranteed ?? false` — `true` iff the worker\n * bond is live (posted and unresolved).\n */\n guaranteed: boolean;\n /** True while the first read is in flight. */\n isLoading: boolean;\n /** The read error, or null. */\n error: Error | null;\n /** Force a refetch (e.g. after posting/reclaiming a bond). */\n refetch: () => void;\n}\n\n/**\n * Read a task's Guaranteed Hire state.\n *\n * @param taskPda - The Task PDA (falsy disables the read).\n * @param options - Reader seam + enabled.\n * @returns {@link UseTaskGuaranteeResult}.\n */\nexport function useTaskGuarantee(\n taskPda: Address | string | undefined | null,\n options?: UseTaskGuaranteeOptions,\n): UseTaskGuaranteeResult {\n const ctx = useAgencContext();\n const injected = options?.guaranteeReader;\n const rpcUrl = ctx.rpcUrl;\n\n // Injected seam wins; else build a gPA read over the provider's rpcUrl.\n const reader = useMemo<TaskGuaranteeReader | null>(() => {\n if (injected) return injected;\n if (!rpcUrl) return null;\n return (pda) =>\n fetchTaskGuarantee(\n createSolanaRpc(rpcUrl) as unknown as ProgramAccountsSource,\n pda as Address,\n );\n }, [injected, rpcUrl]);\n\n const enabled =\n (options?.enabled ?? true) && Boolean(taskPda) && reader !== null;\n\n const query = useQuery<TaskGuarantee, Error>({\n queryKey: queryKeys.taskGuarantee(taskPda ? pdaKey(taskPda) : \"\"),\n enabled,\n queryFn: () => reader!(taskPda as Address | string),\n });\n\n const guarantee = query.data ?? null;\n return {\n guarantee,\n guaranteed: guarantee?.guaranteed ?? false,\n isLoading: query.isLoading,\n error: query.error ?? null,\n refetch: () => void query.refetch(),\n };\n}\n","/**\n * Resolve the P1.2 moderation accounts a consumption gate needs.\n *\n * Post-P1.2 (open roster) every consumption gate — `set_task_job_spec` for\n * activation, `hire_from_listing`/`hire_from_listing_humanless` for hires —\n * names an explicit `moderator` whose attestation it consumes, and the\n * moderation record lives at the v2 moderator-keyed seeds\n * (`[\"task_moderation_v2\", task, hash, moderator]` / the listing mirror). The\n * caller supplies WHO to trust (the `moderator` — reading it from their\n * attestation service, e.g. attest.agenc.ag `GET /v1/info`); these helpers\n * resolve the MECHANICS:\n *\n * - the roster-entry PDA (`[\"moderation_attestor\", moderator]`) the gate\n * requires whenever the moderator is a registered attestor rather than the\n * global `moderation_authority`;\n * - the legacy grace window: when no v2 record exists but a PRE-upgrade record\n * authored by the SAME moderator sits at the frozen legacy seeds, the gate\n * still accepts it if the transaction points at it explicitly — so the\n * resolver returns that record override.\n *\n * Any resolution failure degrades to \"no overrides\" — the program stays the\n * enforcement point; a read hiccup must never make the flow MORE broken than\n * not resolving at all.\n *\n * @module hooks/moderation-attestor\n */\nimport { createSolanaRpc } from \"@solana/kit\";\nimport {\n facade,\n fetchMaybeListingModeration,\n fetchMaybeModerationAttestor,\n fetchMaybeModerationConfig,\n fetchMaybeTaskModeration,\n findListingModerationPda,\n findModerationAttestorPda,\n findModerationConfigPda,\n findTaskModerationPda,\n} from \"@tetsuo-ai/marketplace-sdk\";\nimport type { Address } from \"../types.js\";\n\n/** The account-read slice of a kit RPC that the resolvers need. */\ntype AccountReadRpc = Parameters<typeof fetchMaybeTaskModeration>[0];\n\n/** The job-spec hash exactly as the moderation-record PDA seeds accept it. */\ntype JobSpecHashSeed = Parameters<typeof findTaskModerationPda>[0][\"jobSpecHash\"];\n\n/** Moderation accounts resolved for a task activation (`set_task_job_spec`). */\nexport interface ActivationModerationAccounts {\n /** Roster-entry PDA to attach, absent on the global-authority path. */\n moderationAttestor?: Address;\n /**\n * Explicit record override — set only when the attestation predates the\n * P1.2 upgrade and lives at the frozen legacy seeds (grace window).\n */\n taskModeration?: Address;\n}\n\n/** Moderation accounts resolved for a hire (`hire_from_listing*`). */\nexport interface HireListingModerationAccounts {\n /** Roster-entry PDA to attach, absent on the global-authority path. */\n moderationAttestor?: Address;\n /**\n * Explicit record override — set only when the attestation predates the\n * P1.2 upgrade and lives at the frozen legacy seeds (grace window).\n */\n listingModeration?: Address;\n}\n\nfunction readRpc(input: {\n rpcUrl: string | null;\n rpc?: AccountReadRpc;\n}): AccountReadRpc | null {\n return (\n input.rpc ??\n (input.rpcUrl\n ? (createSolanaRpc(input.rpcUrl) as unknown as AccountReadRpc)\n : null)\n );\n}\n\n/**\n * Roster vs global-authority: return the `[\"moderation_attestor\", moderator]`\n * roster PDA to attach, or `undefined` when the moderator IS the global\n * moderation authority (the gate's authority branch needs no roster account).\n *\n * The roster PDA is attached ONLY when the entry verifiably exists on-chain:\n * a set-but-uninitialized optional account fails the gate harder than\n * attaching nothing (`AccountNotInitialized` vs the authority branch), so an\n * unreadable/absent entry degrades to \"no account\" — callers on an exotic\n * setup can still force the roster path with `moderatorIsAttestor`.\n */\nasync function resolveRosterEntry(\n rpc: AccountReadRpc,\n moderator: Address,\n): Promise<Address | undefined> {\n const [moderationConfigPda] = await findModerationConfigPda();\n const moderationConfig = await fetchMaybeModerationConfig(\n rpc,\n moderationConfigPda,\n );\n if (\n moderationConfig.exists &&\n moderationConfig.data.moderationAuthority === moderator\n ) {\n return undefined;\n }\n const [rosterPda] = await findModerationAttestorPda({ attestor: moderator });\n const roster = await fetchMaybeModerationAttestor(rpc, rosterPda);\n return roster.exists ? rosterPda : undefined;\n}\n\n/**\n * Resolve the moderation accounts to attach to `set_task_job_spec`, given the\n * `moderator` whose attestation the activation consumes.\n *\n * @param input.rpcUrl - Resolved HTTP RPC endpoint (from provider context).\n * @param input.task - The task PDA being activated.\n * @param input.jobSpecHash - The 32-byte canonical job-spec hash.\n * @param input.moderator - The attestation signer the gate should consume\n * (e.g. the attestation service's `moderator` from `GET /v1/info`).\n * @param input.rpc - Test seam: a pre-built account-read RPC wins over\n * `rpcUrl`.\n */\nexport async function resolveActivationModerationAccounts(input: {\n rpcUrl: string | null;\n task: Address;\n jobSpecHash: JobSpecHashSeed;\n moderator: Address;\n rpc?: AccountReadRpc;\n}): Promise<ActivationModerationAccounts> {\n try {\n const rpc = readRpc(input);\n if (!rpc) return {};\n\n const moderationAttestor = await resolveRosterEntry(rpc, input.moderator);\n const attestorPart =\n moderationAttestor !== undefined ? { moderationAttestor } : {};\n\n // Prefer the v2 moderator-keyed record (what recordTaskModeration writes\n // post-upgrade); the facade derives it by default, so no override needed.\n const [v2Pda] = await findTaskModerationPda({\n task: input.task,\n jobSpecHash: input.jobSpecHash,\n moderator: input.moderator,\n });\n const v2 = await fetchMaybeTaskModeration(rpc, v2Pda);\n if (v2.exists) return attestorPart;\n\n // Grace window: a pre-upgrade record at the frozen legacy seeds is still\n // consumable when the transaction points at it explicitly AND it was\n // authored by the same moderator the gate is told to consume.\n const [legacyPda] = await facade.findLegacyTaskModerationPda({\n task: input.task,\n jobSpecHash: input.jobSpecHash,\n });\n const legacy = await fetchMaybeTaskModeration(rpc, legacyPda);\n if (legacy.exists && legacy.data.moderator === input.moderator) {\n return { ...attestorPart, taskModeration: legacyPda };\n }\n\n return attestorPart;\n } catch {\n // Degrade to \"no overrides\" — never block the flow on a read failure.\n return {};\n }\n}\n\n/**\n * Resolve the moderation accounts to attach to a hire\n * (`hire_from_listing` / `hire_from_listing_humanless`), given the\n * `moderator` whose listing attestation the hire gate should consume.\n *\n * @param input.rpcUrl - Resolved HTTP RPC endpoint (from provider context).\n * @param input.listing - The ServiceListing PDA being hired.\n * @param input.listingSpecHash - The listing's pinned 32-byte `spec_hash`.\n * @param input.moderator - The attestation signer the gate should consume.\n * @param input.rpc - Test seam: a pre-built account-read RPC wins over\n * `rpcUrl`.\n */\nexport async function resolveHireListingModerationAccounts(input: {\n rpcUrl: string | null;\n listing: Address;\n listingSpecHash: JobSpecHashSeed;\n moderator: Address;\n rpc?: AccountReadRpc;\n}): Promise<HireListingModerationAccounts> {\n try {\n const rpc = readRpc(input);\n if (!rpc) return {};\n\n const moderationAttestor = await resolveRosterEntry(rpc, input.moderator);\n const attestorPart =\n moderationAttestor !== undefined ? { moderationAttestor } : {};\n\n const [v2Pda] = await findListingModerationPda({\n listing: input.listing,\n jobSpecHash: input.listingSpecHash,\n moderator: input.moderator,\n });\n const v2 = await fetchMaybeListingModeration(rpc, v2Pda);\n if (v2.exists) return attestorPart;\n\n const [legacyPda] = await facade.findLegacyListingModerationPda({\n listing: input.listing,\n jobSpecHash: input.listingSpecHash,\n });\n const legacy = await fetchMaybeListingModeration(rpc, legacyPda);\n if (legacy.exists && legacy.data.moderator === input.moderator) {\n return { ...attestorPart, listingModeration: legacyPda };\n }\n\n return attestorPart;\n } catch {\n // Degrade to \"no overrides\" — never block the flow on a read failure.\n return {};\n }\n}\n","/**\n * `useHire()` — the hire mutation hook (the embeddable money path).\n *\n * Drives `client.hireFromListing(...)` through the provider's write client and\n * surfaces the resulting transaction signature + minted Task PDA. Typed\n * `AgencError`s from the runtime client are surfaced UNTOUCHED in `error`.\n *\n * ## REFERRER SETTLEMENT\n *\n * The full 84-instruction protocol supports a demand-side referrer leg. This hook:\n * - reads `resolveReferrerCapability()` from context BEFORE building the hire;\n * - when `live === true`, spreads the validated provider referrer into the hire\n * input for both standard and humanless hires;\n * - the `referrerInjected` flag in the result is the audit signal. We never set\n * it true unless the transaction input included the referrer fields.\n *\n * @module hooks/useHire\n */\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useCallback, useMemo } from \"react\";\nimport { findTaskPda } from \"@tetsuo-ai/marketplace-sdk\";\nimport type { facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address } from \"../types.js\";\nimport {\n requireClient,\n resolveReferrerArgs,\n signerAddress,\n withoutReferrerArgs,\n} from \"./internal.js\";\nimport {\n resolveHireListingModerationAccounts,\n type HireListingModerationAccounts,\n} from \"./moderation-attestor.js\";\n\n/**\n * Input to a standard `hire(...)` — a buyer that has a registered marketplace\n * agent (`creatorAgent`). This task settles on the HIRE COMPLETION path (the\n * worker calls `complete_task`). This is the SDK `facade.hireFromListing` input\n * MINUS the fee-payer signers, which default to the provider's write-client\n * signer (authority == creator == buyer). Pass them only to override.\n *\n * NOTE: deliberately NO referrer field — the referrer is provider-level config\n * and is injected only when `resolveReferrerCapability()` is live.\n */\nexport type HireInput = Omit<\n Parameters<typeof facadeNs.hireFromListing>[0],\n \"authority\" | \"creator\" | \"referrer\" | \"referrerFeeBps\"\n> & {\n /** Standard hire (default). */\n humanless?: false;\n /** Override the buyer authority signer (defaults to the client signer). */\n authority?: Parameters<typeof facadeNs.hireFromListing>[0][\"authority\"];\n /** Override the buyer/creator signer (defaults to the client signer). */\n creator?: Parameters<typeof facadeNs.hireFromListing>[0][\"creator\"];\n};\n\n/**\n * Input to a HUMANLESS `hire(...)` — a plain-wallet buyer with NO registered\n * agent (the storefront-visitor path). The task is pinned to CreatorReview, so\n * it settles via the BUYER REVIEW path (`useSubmissionReview` accept/reject) —\n * the human reviews before funds release. This is the SDK\n * `facade.hireFromListingHumanless` input minus the `creator` signer (defaulted\n * to the client signer).\n */\nexport type HumanlessHireInput = Omit<\n Parameters<typeof facadeNs.hireFromListingHumanless>[0],\n \"creator\" | \"referrer\" | \"referrerFeeBps\"\n> & {\n /** Discriminates the humanless storefront-visitor hire. */\n humanless: true;\n /** Override the buyer/creator signer (defaults to the client signer). */\n creator?: Parameters<typeof facadeNs.hireFromListingHumanless>[0][\"creator\"];\n};\n\n/** The union of standard and humanless hire inputs. */\nexport type AnyHireInput = HireInput | HumanlessHireInput;\n\n/** Lifecycle status of the hire mutation. */\nexport type HireStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Result of a settled hire. */\nexport interface HireResult {\n /** The confirmed transaction signature. */\n signature: string;\n /** The minted Task PDA (derived from creator + taskId). */\n taskPda: Address;\n /**\n * Whether a referrer fee leg was injected into THIS hire. Audit signal —\n * never fabricated.\n */\n referrerInjected: boolean;\n}\n\n/** Return value of {@link useHire}. */\nexport interface UseHireResult {\n /** Execute a hire. Resolves to {@link HireResult}; rejects with `AgencError`. */\n hire: (input: AnyHireInput) => Promise<HireResult>;\n /** Current mutation status. */\n status: HireStatus;\n /** The minted Task PDA from the last successful hire, or null. */\n taskPda: Address | null;\n /** The signature from the last successful hire, or null. */\n signature: string | null;\n /** The error from the last hire (typed `AgencError` untouched), or null. */\n error: Error | null;\n /** Whether a hire is currently in flight. */\n isPending: boolean;\n /** Reset the mutation back to idle. */\n reset: () => void;\n}\n\n/**\n * The hire hook.\n *\n * @returns {@link UseHireResult}.\n *\n * @example\n * ```tsx\n * const { hire, status, taskPda, error } = useHire();\n * await hire({\n * listing, creatorAgent, taskId, expectedPrice: price, expectedVersion: 1n,\n * listingSpecHash,\n * });\n * ```\n */\nexport function useHire(): UseHireResult {\n const ctx = useAgencContext();\n\n const mutation = useMutation<HireResult, Error, AnyHireInput>({\n mutationFn: async (input: AnyHireInput): Promise<HireResult> => {\n const client = requireClient(ctx.client);\n\n // Resolve fresh per hire so a provider referrer config change cannot leak\n // stale referral terms into a new transaction.\n const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);\n const hireInput = withoutReferrerArgs(input);\n\n // P1.2: the hire gate names an explicit `moderator` (the caller's trust\n // decision) and needs the roster-entry PDA when that moderator is a\n // registered attestor, plus a record override when the listing\n // attestation predates the upgrade (legacy grace window). Resolve the\n // mechanics automatically unless the caller supplied any of them.\n const listingSpecHash = input.listingSpecHash;\n let moderationArgs: HireListingModerationAccounts = {};\n if (\n input.moderationAttestor === undefined &&\n input.moderatorIsAttestor === undefined &&\n input.listingModeration === undefined &&\n listingSpecHash !== undefined\n ) {\n moderationArgs = await resolveHireListingModerationAccounts({\n rpcUrl: ctx.rpcUrl,\n listing: input.listing,\n listingSpecHash,\n moderator: input.moderator,\n });\n }\n\n const creator = input.creator ?? client.signer;\n let signature: string;\n\n if (input.humanless === true) {\n // Storefront-visitor hire: no creator agent; CreatorReview-pinned, so\n // it settles via the buyer review path (useSubmissionReview).\n const result = await client.hireFromListingHumanless({\n ...hireInput,\n ...moderationArgs,\n creator,\n ...referrerArgs,\n } as Parameters<typeof facadeNs.hireFromListingHumanless>[0]);\n signature = result.signature;\n } else {\n // Standard hire: authority == creator == buyer (the buyer has an agent).\n const authority = input.authority ?? client.signer;\n const result = await client.hireFromListing({\n ...hireInput,\n ...moderationArgs,\n authority,\n creator,\n ...referrerArgs,\n } as Parameters<typeof facadeNs.hireFromListing>[0]);\n signature = result.signature;\n }\n\n // Derive the minted Task PDA from (creator, taskId).\n const [taskPda] = await findTaskPda({\n creator: signerAddress(creator),\n taskId: input.taskId,\n });\n\n return { signature, taskPda, referrerInjected };\n },\n });\n\n const hire = useCallback(\n (input: AnyHireInput) => mutation.mutateAsync(input),\n [mutation],\n );\n\n const status: HireStatus = useMemo(() => {\n if (mutation.isPending) return \"pending\";\n if (mutation.isError) return \"error\";\n if (mutation.isSuccess) return \"success\";\n return \"idle\";\n }, [mutation.isPending, mutation.isError, mutation.isSuccess]);\n\n return {\n hire,\n status,\n taskPda: mutation.data?.taskPda ?? null,\n signature: mutation.data?.signature ?? null,\n error: mutation.error ?? null,\n isPending: mutation.isPending,\n reset: mutation.reset,\n };\n}\n","/**\n * `useWalletSigner()` — bridges a browser wallet into the kit `TransactionSigner`\n * the SDK write client expects.\n *\n * ## Adapter seam (the signer-adapters package is not built yet)\n *\n * The dedicated `@tetsuo-ai/signer-adapters` package (the signers agent, PLAN.md\n * P4.1) — which wraps `@solana/react`'s\n * `useWalletAccountTransactionSendingSigner` (Wallet Standard) and the legacy\n * `@solana/wallet-adapter` shim into a kit `TransactionSigner` — does not exist\n * at this hook's build time. So this hook is defined against a **documented\n * adapter interface** ({@link WalletSignerAdapter}) rather than importing that\n * package. A caller passes an adapter (today: a thin wrapper they write, or the\n * signer-adapters hook once it ships) and this hook normalizes it to the\n * `{ signer, connected, connect() }` contract every other hook expects.\n *\n * With NO adapter passed, the hook falls back to the provider's configured\n * `signer` (the `AgencProvider config.signer` slot), so a server-supplied or\n * test signer just works and `connect()` is a no-op.\n *\n * SSR-safe: no `window`/`document`; the adapter (which may touch wallet globals)\n * is the caller's responsibility to gate to the client. This hook only reads\n * what the adapter already resolved.\n *\n * @module hooks/useWalletSigner\n */\nimport { useCallback } from \"react\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { TransactionSigner } from \"../types.js\";\n\n/**\n * The minimal adapter shape this hook bridges. The forthcoming\n * `@tetsuo-ai/signer-adapters` hook is expected to return exactly this shape\n * (its `signerFromWalletAccount(...)` resolves the `signer`); until it ships,\n * any object matching this interface works.\n */\nexport interface WalletSignerAdapter {\n /** The resolved kit signer, or null when no wallet is connected. */\n signer: TransactionSigner | null;\n /** Whether a wallet is currently connected. */\n connected?: boolean;\n /** Trigger the wallet connect flow (browser-only). Optional. */\n connect?: () => void | Promise<void>;\n}\n\n/** Options for {@link useWalletSigner}. */\nexport interface UseWalletSignerOptions {\n /**\n * A wallet adapter (e.g. the signer-adapters hook's result). When omitted the\n * hook falls back to the provider's `config.signer`.\n */\n adapter?: WalletSignerAdapter;\n}\n\n/** Return value of {@link useWalletSigner}. */\nexport interface UseWalletSignerResult {\n /** The resolved kit `TransactionSigner`, or null. */\n signer: TransactionSigner | null;\n /** Whether a signer is available (adapter-connected or provider-configured). */\n connected: boolean;\n /** Trigger the wallet connect flow. No-op when no adapter `connect` exists. */\n connect: () => void | Promise<void>;\n}\n\n/**\n * Resolve the active signer for write operations.\n *\n * @param options - Optional wallet adapter; falls back to the provider signer.\n * @returns {@link UseWalletSignerResult}.\n *\n * @example\n * ```tsx\n * // Once @tetsuo-ai/signer-adapters ships:\n * const adapter = useWalletStandardSigner(); // returns WalletSignerAdapter\n * const { signer, connected, connect } = useWalletSigner({ adapter });\n * ```\n */\nexport function useWalletSigner(\n options?: UseWalletSignerOptions,\n): UseWalletSignerResult {\n const ctx = useAgencContext();\n const adapter = options?.adapter;\n\n // Adapter wins when present; otherwise the provider's configured signer.\n const signer: TransactionSigner | null =\n adapter?.signer ?? ctx.signer ?? null;\n const connected =\n adapter !== undefined\n ? (adapter.connected ?? adapter.signer !== null)\n : ctx.signer !== null;\n\n const connect = useCallback(() => {\n // No adapter (or no connect on it) => provider-supplied signer is already\n // \"connected\"; connecting is a no-op rather than an error.\n return adapter?.connect ? adapter.connect() : undefined;\n }, [adapter]);\n\n return { signer, connected, connect };\n}\n"]}
|