@tetsuo-ai/marketplace-react 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/{chunk-FAIRTAIB.js → chunk-2Y6JN2VZ.js} +3 -3
  3. package/dist/{chunk-FAIRTAIB.js.map → chunk-2Y6JN2VZ.js.map} +1 -1
  4. package/dist/{chunk-D2TDU3TJ.js → chunk-AKPPKMQ2.js} +3 -3
  5. package/dist/{chunk-D2TDU3TJ.js.map → chunk-AKPPKMQ2.js.map} +1 -1
  6. package/dist/{chunk-ECU7HGO3.js → chunk-H6PJIDQR.js} +4 -3
  7. package/dist/chunk-H6PJIDQR.js.map +1 -0
  8. package/dist/{chunk-MNJ2EQDJ.js → chunk-ON6XR4XO.js} +3 -3
  9. package/dist/{chunk-MNJ2EQDJ.js.map → chunk-ON6XR4XO.js.map} +1 -1
  10. package/dist/{chunk-WJUVTFJ7.js → chunk-ZAMIL27X.js} +4 -4
  11. package/dist/{chunk-WJUVTFJ7.js.map → chunk-ZAMIL27X.js.map} +1 -1
  12. package/dist/components/index.cjs +2 -1
  13. package/dist/components/index.cjs.map +1 -1
  14. package/dist/components/index.d.cts +1 -1
  15. package/dist/components/index.d.ts +1 -1
  16. package/dist/components/index.js +3 -3
  17. package/dist/hooks/index.cjs +86 -9
  18. package/dist/hooks/index.cjs.map +1 -1
  19. package/dist/hooks/index.d.cts +6 -8
  20. package/dist/hooks/index.d.ts +6 -8
  21. package/dist/hooks/index.js +89 -12
  22. package/dist/hooks/index.js.map +1 -1
  23. package/dist/{index-C9R3B80j.d.ts → index-DQ3Xovkq.d.ts} +15 -1
  24. package/dist/{index-CTTh1ZPg.d.cts → index-UxuvIlmD.d.cts} +15 -1
  25. package/dist/index.cjs +9 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +2 -2
  28. package/dist/index.d.ts +2 -2
  29. package/dist/index.js +15 -8
  30. package/dist/index.js.map +1 -1
  31. package/dist/signers/index.cjs +2 -1
  32. package/dist/signers/index.cjs.map +1 -1
  33. package/dist/signers/index.js +2 -2
  34. package/package.json +1 -1
  35. package/src/hooks/moderation-attestor.ts +98 -0
  36. package/src/hooks/useHumanlessHireFlow.ts +12 -0
  37. package/src/hooks/useReferrerEarnings.ts +73 -38
  38. package/src/hooks/useTaskActivation.ts +13 -0
  39. package/src/provider/AgencProvider.tsx +12 -0
  40. package/src/strings/index.ts +3 -1
  41. package/src/types.ts +13 -0
  42. package/dist/chunk-ECU7HGO3.js.map +0 -1
@@ -7,6 +7,7 @@ import {
7
7
  requireClient,
8
8
  type MutationStatus,
9
9
  } from "./internal.js";
10
+ import { resolveActivationModerationAttestor } from "./moderation-attestor.js";
10
11
 
11
12
  export type TaskActivationInput = Omit<
12
13
  Parameters<typeof facadeNs.setTaskJobSpec>[0],
@@ -33,8 +34,20 @@ export function useTaskActivation(
33
34
  const mutation = useMutation<string, Error, TaskActivationInput>({
34
35
  mutationFn: async (input) => {
35
36
  const client = requireClient(ctx.client);
37
+ // WP-A1: when the task moderation was authored by a roster attestor
38
+ // (not the global authority), the publish gate only unlocks if the
39
+ // attestor's roster-entry PDA is attached. Resolve it automatically
40
+ // unless the caller supplied one.
41
+ const moderationAttestor =
42
+ input.moderationAttestor ??
43
+ (await resolveActivationModerationAttestor({
44
+ rpcUrl: ctx.rpcUrl,
45
+ task: taskPda,
46
+ jobSpecHash: input.jobSpecHash,
47
+ }));
36
48
  const { signature } = await client.setTaskJobSpec({
37
49
  ...input,
50
+ ...(moderationAttestor !== undefined ? { moderationAttestor } : {}),
38
51
  task: taskPda,
39
52
  creator: input.creator ?? client.signer,
40
53
  } as Parameters<typeof facadeNs.setTaskJobSpec>[0]);
@@ -149,10 +149,22 @@ export function AgencProvider(props: AgencProviderProps): ReactNode {
149
149
  const read = buildReadTransport(config);
150
150
  const client = buildWriteClient(config, network);
151
151
 
152
+ // The resolved HTTP RPC endpoint, exposed so hooks can make single-account
153
+ // reads (e.g. resolving the WP-A1 roster-attestor account at activation)
154
+ // without an indexer. Not a gPA source — the read transport owns list
155
+ // queries.
156
+ const { rpcUrl } = resolveEndpoints(
157
+ network,
158
+ config.rpcUrl,
159
+ config.rpcSubscriptionsUrl,
160
+ );
161
+
152
162
  return {
153
163
  network,
154
164
  read,
155
165
  client,
166
+ rpcUrl: rpcUrl ?? null,
167
+ indexerBaseUrl: config.indexer?.baseUrl ?? null,
156
168
  signer: config.signer ?? null,
157
169
  referrer,
158
170
  resolveReferrerCapability: () => resolveReferrerCapabilityImpl(referrer),
@@ -51,7 +51,9 @@ export const EN_STRINGS = {
51
51
  "referrer.notLiveReason":
52
52
  "No referrer is configured for this provider.",
53
53
  "referrer.earningsNotLiveReason":
54
- "Referral settlement is live, but aggregated referrer earnings are not yet exposed by the indexer.",
54
+ "Referral settlement is live, but no earnings endpoint is available on this network (configure indexer.baseUrl).",
55
+ "referrer.earningsFetchFailed":
56
+ "The referrer earnings endpoint could not be read.",
55
57
 
56
58
  // Read transport.
57
59
  "transport.noReadSource":
package/src/types.ts CHANGED
@@ -198,6 +198,19 @@ export interface AgencContextValue {
198
198
  * was supplied. Mutating hooks surface a clear error in that case.
199
199
  */
200
200
  client: MarketplaceClient | null;
201
+ /**
202
+ * The resolved HTTP RPC endpoint (config override or the network default),
203
+ * or `null` when none resolves. Hooks use it for single-account reads —
204
+ * e.g. resolving the WP-A1 `moderation_attestor` roster account during
205
+ * activation. NOT a gPA/list-query source; the read transport owns those.
206
+ */
207
+ rpcUrl: string | null;
208
+ /**
209
+ * The configured hosted-indexer base URL (`config.indexer.baseUrl`), or
210
+ * `null` when reads run over gPA/queryTransport. Earnings hooks prefer it
211
+ * over the per-network hosted default.
212
+ */
213
+ indexerBaseUrl: string | null;
201
214
  /** The configured signer, or `null`. */
202
215
  signer: TransactionSigner | null;
203
216
  /** Validated referrer config, or `null` when none was supplied. */
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/strings/index.ts"],"names":[],"mappings":";AAkCO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,yBAAA,EACE,sDAAA;AAAA,EACF,6BAAA,EACE,uIAAA;AAAA,EACF,wBAAA,EACE,qFAAA;AAAA;AAAA,EAGF,wBAAA,EACE,iEAAA;AAAA,EACF,wBAAA,EACE,0FAAA;AAAA,EACF,kBAAA,EACE,2CAAA;AAAA,EACF,wBAAA,EACE,8CAAA;AAAA,EACF,gCAAA,EACE,mGAAA;AAAA;AAAA,EAGF,wBAAA,EACE,4HAAA;AAAA;AAAA,EAGF,eAAA,EAAiB,eAAA;AAAA,EACjB,aAAA,EAAe,sBAAA;AAAA,EACf,aAAA,EAAe,uBAAA;AAAA;AAAA,EAGf,UAAA,EAAY,MAAA;AAAA,EACZ,cAAA,EAAgB,kBAAA;AAAA,EAChB,aAAA,EAAe;AACjB;AAwCO,SAAS,CAAA,CACd,EAAA,EACA,IAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,OAAA,GAAyB,SAAS,OAAA,IAAW,UAAA;AACnD,EAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,EAAE,CAAA,IAAK,EAAA;AAChC,EAAA,IAAI,IAAA,KAAS,QAAW,OAAO,QAAA;AAC/B,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,YAAA,EAAc,CAAC,OAAO,GAAA,KAAgB;AAC5D,IAAA,MAAM,KAAA,GAAQ,KAAK,GAAG,CAAA;AACtB,IAAA,OAAO,KAAA,KAAU,MAAA,GAAY,KAAA,GAAQ,MAAA,CAAO,KAAK,CAAA;AAAA,EACnD,CAAC,CAAA;AACH","file":"chunk-ECU7HGO3.js","sourcesContent":["/**\n * Minimal English string catalog + a `t(id, vars?)` resolver.\n *\n * Every user-facing string in this package and its downstream hooks/components\n * routes through this module so a future `{ locale }` can resolve translations\n * **without an API break** (PLAN_2 Part A design constraint). v1 ships English\n * only; the resolver signature is already locale-shaped.\n *\n * ## Why a catalog and not inline literals\n *\n * Components published to third parties cannot assume the host's language. By\n * keying every literal here:\n * - adding a locale is a data change (a new {@link StringCatalog}), not a code\n * change to every component;\n * - the message ids are a stable contract the components agent binds to;\n * - `{var}` interpolation is centralized and SSR-safe (pure string ops, no\n * `Intl` global assumptions at module scope).\n *\n * @module strings\n */\n\n/**\n * The catalog shape: every message id maps to an English template. `{name}`\n * placeholders are filled by {@link t} from the `vars` argument.\n */\nexport interface StringCatalog {\n readonly [id: string]: string;\n}\n\n/**\n * Default English catalog. Keep ids namespaced by surface\n * (`provider.*`, `referrer.*`, `transport.*`, `hire.*`, ...) so the components\n * agent can extend it without collisions.\n */\nexport const EN_STRINGS = {\n // Provider / context wiring errors (developer-facing, but routed for parity).\n \"provider.missingContext\":\n \"useAgencContext must be used within <AgencProvider>.\",\n \"provider.missingWriteClient\":\n \"No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.\",\n \"provider.missingSigner\":\n \"No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.\",\n\n // Referrer config validation / capability surface.\n \"referrer.invalidWallet\":\n \"Referrer wallet is not a valid base58 Solana address: {wallet}.\",\n \"referrer.invalidFeeBps\":\n \"Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.\",\n \"referrer.notLive\":\n \"Referral fee is not active for this hire.\",\n \"referrer.notLiveReason\":\n \"No referrer is configured for this provider.\",\n \"referrer.earningsNotLiveReason\":\n \"Referral settlement is live, but aggregated referrer earnings are not yet exposed by the indexer.\",\n\n // Read transport.\n \"transport.noReadSource\":\n \"No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().\",\n\n // Generic loading / empty / error states (components extend these).\n \"state.loading\": \"Loading…\",\n \"state.empty\": \"Nothing to show yet.\",\n \"state.error\": \"Something went wrong.\",\n\n // Hire flow shells (components fill out the rest).\n \"hire.cta\": \"Hire\",\n \"hire.pending\": \"Confirming…\",\n \"hire.funded\": \"Escrow funded.\",\n} as const satisfies StringCatalog;\n\n/** A message id present in the default English catalog. */\nexport type StringId = keyof typeof EN_STRINGS;\n\n/** Interpolation variables for {@link t}: `{name}` → `vars.name`. */\nexport type StringVars = Record<string, string | number | bigint>;\n\n/**\n * Options for {@link t}. `locale` is accepted today (English-only) so adding\n * real locales later does not break the call signature; `catalog` lets a host\n * inject an override/extension catalog.\n */\nexport interface TranslateOptions {\n /** BCP-47 locale tag. v1 resolves everything to English regardless. */\n locale?: string;\n /** Override catalog (e.g. a future locale, or host-supplied copy). */\n catalog?: StringCatalog;\n}\n\n/**\n * Resolve a message id to its localized string with `{var}` interpolation.\n *\n * Unknown ids and unmatched placeholders are returned verbatim (the id itself,\n * or the `{placeholder}` left intact) rather than throwing — a missing string\n * must never crash a money-handling UI.\n *\n * @param id - The message id (a {@link StringId}, or any string for host\n * catalogs).\n * @param vars - Values for `{name}` placeholders in the template.\n * @param options - Optional `locale` (forward-compatible) and `catalog`\n * override.\n * @returns The interpolated string.\n *\n * @example\n * ```ts\n * t(\"referrer.invalidFeeBps\", { min: 0, max: 10000, feeBps: 99999 });\n * // -> \"Referrer feeBps must be an integer between 0 and 10000 ...; got 99999.\"\n * ```\n */\nexport function t(\n id: StringId | (string & {}),\n vars?: StringVars,\n options?: TranslateOptions,\n): string {\n const catalog: StringCatalog = options?.catalog ?? EN_STRINGS;\n const template = catalog[id] ?? id;\n if (vars === undefined) return template;\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => {\n const value = vars[key];\n return value === undefined ? match : String(value);\n });\n}\n"]}