@tetsuo-ai/marketplace-react 0.1.0 → 0.2.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +29 -3
  2. package/README.md +50 -20
  3. package/dist/{chunk-ABS77JB2.js → chunk-D2TDU3TJ.js} +3 -3
  4. package/dist/{chunk-ABS77JB2.js.map → chunk-D2TDU3TJ.js.map} +1 -1
  5. package/dist/{chunk-GN5DYVN5.js → chunk-ECU7HGO3.js} +6 -5
  6. package/dist/chunk-ECU7HGO3.js.map +1 -0
  7. package/dist/{chunk-YORZNYZZ.js → chunk-FAIRTAIB.js} +53 -17
  8. package/dist/chunk-FAIRTAIB.js.map +1 -0
  9. package/dist/{chunk-5OTKSRHM.js → chunk-MNJ2EQDJ.js} +3 -3
  10. package/dist/{chunk-5OTKSRHM.js.map → chunk-MNJ2EQDJ.js.map} +1 -1
  11. package/dist/{chunk-KJMR6OGC.js → chunk-WJUVTFJ7.js} +105 -9
  12. package/dist/chunk-WJUVTFJ7.js.map +1 -0
  13. package/dist/components/agenc-components.css +20 -0
  14. package/dist/components/index.cjs +147 -17
  15. package/dist/components/index.cjs.map +1 -1
  16. package/dist/components/index.d.cts +2 -2
  17. package/dist/components/index.d.ts +2 -2
  18. package/dist/components/index.js +3 -3
  19. package/dist/hooks/index.cjs +350 -28
  20. package/dist/hooks/index.cjs.map +1 -1
  21. package/dist/hooks/index.d.cts +160 -36
  22. package/dist/hooks/index.d.ts +160 -36
  23. package/dist/hooks/index.js +299 -19
  24. package/dist/hooks/index.js.map +1 -1
  25. package/dist/{index-BLrlBVj-.d.cts → index-C9R3B80j.d.ts} +176 -47
  26. package/dist/{index-CKTYsNPH.d.ts → index-CTTh1ZPg.d.cts} +176 -47
  27. package/dist/index.cjs +168 -33
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +10 -19
  30. package/dist/index.d.ts +10 -19
  31. package/dist/index.js +17 -12
  32. package/dist/index.js.map +1 -1
  33. package/dist/signers/index.cjs +4 -3
  34. package/dist/signers/index.cjs.map +1 -1
  35. package/dist/signers/index.js +2 -2
  36. package/dist/{useAgentTrackRecord-BLf1nrbu.d.cts → useAgentTrackRecord-BCvRHYM2.d.cts} +7 -7
  37. package/dist/{useAgentTrackRecord-BLf1nrbu.d.ts → useAgentTrackRecord-BCvRHYM2.d.ts} +7 -7
  38. package/package.json +4 -3
  39. package/src/components/HireButton.tsx +1 -2
  40. package/src/components/HireCheckoutModal.tsx +8 -9
  41. package/src/components/ProviderCard.stories.tsx +54 -4
  42. package/src/components/ProviderCard.tsx +113 -9
  43. package/src/components/ReferrerDisclosure.tsx +8 -12
  44. package/src/components/__fixtures__/index.tsx +28 -0
  45. package/src/components/agenc-components.css +20 -0
  46. package/src/components/index.ts +12 -0
  47. package/src/components/strings.ts +10 -2
  48. package/src/components/useAgentVerification.ts +223 -0
  49. package/src/hooks/index.ts +47 -4
  50. package/src/hooks/internal.ts +74 -2
  51. package/src/hooks/useHire.ts +30 -38
  52. package/src/hooks/useHumanlessHireFlow.ts +259 -0
  53. package/src/hooks/useRateHire.ts +52 -0
  54. package/src/hooks/useReferrerEarnings.ts +32 -33
  55. package/src/hooks/useTaskActivation.ts +58 -0
  56. package/src/hooks/useTaskLifecycle.ts +110 -0
  57. package/src/hooks/useTaskWork.ts +76 -0
  58. package/src/index.ts +12 -2
  59. package/src/provider/AgencProvider.tsx +3 -3
  60. package/src/provider/referrer.ts +24 -32
  61. package/src/strings/index.ts +5 -3
  62. package/src/types.ts +7 -10
  63. package/dist/chunk-GN5DYVN5.js.map +0 -1
  64. package/dist/chunk-KJMR6OGC.js.map +0 -1
  65. package/dist/chunk-YORZNYZZ.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -14,11 +14,12 @@ var EN_STRINGS = {
14
14
  "provider.missingContext": "useAgencContext must be used within <AgencProvider>.",
15
15
  "provider.missingWriteClient": "No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.",
16
16
  "provider.missingSigner": "No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.",
17
- // Referrer config validation (the P6.2 gate surface).
17
+ // Referrer config validation / capability surface.
18
18
  "referrer.invalidWallet": "Referrer wallet is not a valid base58 Solana address: {wallet}.",
19
19
  "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
20
- "referrer.notLive": "This site earns a referral fee (pending protocol support).",
21
- "referrer.notLiveReason": "Referral settlement is not yet deployed on this cluster (PLAN.md P6.2). Referrer config is accepted and validated but not injected into hires.",
20
+ "referrer.notLive": "Referral fee is not active for this hire.",
21
+ "referrer.notLiveReason": "No referrer is configured for this provider.",
22
+ "referrer.earningsNotLiveReason": "Referral settlement is live, but aggregated referrer earnings are not yet exposed by the indexer.",
22
23
  // Read transport.
23
24
  "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
24
25
  // Generic loading / empty / error states (components extend these).
@@ -164,7 +165,7 @@ function resolveEndpoints(network, rpcUrl, rpcSubscriptionsUrl) {
164
165
  return { rpcUrl: resolvedRpc, rpcSubscriptionsUrl: resolvedWs };
165
166
  }
166
167
  var REFERRER_FEE_BPS_MIN = 0;
167
- var REFERRER_FEE_BPS_MAX = 1e4;
168
+ var REFERRER_FEE_BPS_MAX = 2e3;
168
169
  function validateReferrerConfig(config) {
169
170
  const { wallet, feeBps } = config;
170
171
  if (typeof wallet !== "string" || !kit.isAddress(wallet)) {
@@ -182,10 +183,15 @@ function validateReferrerConfig(config) {
182
183
  return { wallet, feeBps };
183
184
  }
184
185
  function resolveReferrerCapability(referrer) {
186
+ if (!referrer) {
187
+ return {
188
+ live: false,
189
+ reason: t("referrer.notLiveReason")
190
+ };
191
+ }
185
192
  return {
186
- live: false,
187
- reason: t("referrer.notLiveReason"),
188
- ...referrer ? { referrer } : {}
193
+ live: true,
194
+ referrer
189
195
  };
190
196
  }
191
197
  var DEFAULT_QUERY_CLIENT_CONFIG = {
@@ -286,7 +292,7 @@ function resolveChain(account, options) {
286
292
  return account.chains?.find((c) => c.startsWith("solana:"));
287
293
  }
288
294
  function signerFromWalletAccount(account, options = {}) {
289
- const signerAddress = kit.address(account.address);
295
+ const signerAddress2 = kit.address(account.address);
290
296
  const signTransaction = resolveSignTransaction(account, options);
291
297
  const chain = resolveChain(account, options);
292
298
  const encoder = kit.getTransactionEncoder();
@@ -301,18 +307,18 @@ function signerFromWalletAccount(account, options = {}) {
301
307
  throw new Error(ts("signer.walletNoSignature", { address: account.address }));
302
308
  }
303
309
  const signed = decoder.decode(output.signedTransaction);
304
- const signature = signed.signatures[signerAddress];
310
+ const signature = signed.signatures[signerAddress2];
305
311
  if (!signature) {
306
312
  throw new Error(ts("signer.walletNoSignature", { address: account.address }));
307
313
  }
308
314
  return signature;
309
315
  }
310
316
  return {
311
- address: signerAddress,
317
+ address: signerAddress2,
312
318
  async signTransactions(transactions) {
313
319
  return Promise.all(
314
320
  transactions.map(async (transaction) => ({
315
- [signerAddress]: await signOne(transaction)
321
+ [signerAddress2]: await signOne(transaction)
316
322
  }))
317
323
  );
318
324
  }
@@ -330,7 +336,7 @@ function resolveAdapterAddress(adapter) {
330
336
  return String(publicKey);
331
337
  }
332
338
  function signerFromWalletAdapter(adapter, options) {
333
- const signerAddress = kit.address(resolveAdapterAddress(adapter));
339
+ const signerAddress2 = kit.address(resolveAdapterAddress(adapter));
334
340
  const { signTransaction } = adapter;
335
341
  if (typeof signTransaction !== "function") {
336
342
  throw new Error(ts("signer.walletAdapterNoSign"));
@@ -343,29 +349,29 @@ function signerFromWalletAdapter(adapter, options) {
343
349
  const legacyTx = VersionedTransaction.deserialize(wireBytes);
344
350
  const signed = await signTransaction(legacyTx);
345
351
  const signedTx = decoder.decode(new Uint8Array(signed.serialize()));
346
- const signature = signedTx.signatures[signerAddress];
352
+ const signature = signedTx.signatures[signerAddress2];
347
353
  if (!signature) {
348
354
  throw new Error(
349
- ts("signer.walletNoSignature", { address: signerAddress })
355
+ ts("signer.walletNoSignature", { address: signerAddress2 })
350
356
  );
351
357
  }
352
358
  return signature;
353
359
  }
354
360
  return {
355
- address: signerAddress,
361
+ address: signerAddress2,
356
362
  async signTransactions(transactions) {
357
363
  return Promise.all(
358
364
  transactions.map(async (transaction) => ({
359
- [signerAddress]: await signOne(transaction)
365
+ [signerAddress2]: await signOne(transaction)
360
366
  }))
361
367
  );
362
368
  }
363
369
  };
364
370
  }
365
371
  function signerFromEmbeddedWallet(connection) {
366
- const signerAddress = kit.address(connection.address);
372
+ const signerAddress2 = kit.address(connection.address);
367
373
  return {
368
- address: signerAddress,
374
+ address: signerAddress2,
369
375
  async signTransactions(transactions) {
370
376
  const signatures = await connection.signTransactions(transactions);
371
377
  if (signatures.length !== transactions.length) {
@@ -377,7 +383,7 @@ function signerFromEmbeddedWallet(connection) {
377
383
  );
378
384
  }
379
385
  return transactions.map((_, i) => ({
380
- [signerAddress]: signatures[i]
386
+ [signerAddress2]: signatures[i]
381
387
  }));
382
388
  }
383
389
  };
@@ -422,9 +428,9 @@ var EN_COMPONENT_STRINGS = {
422
428
  "components.hire.moderationPending": "Moderation pending",
423
429
  "components.hire.moderationIssues": "Moderation issues found",
424
430
  "components.hire.notConnected": "Connect a wallet to hire.",
425
- // Referrer disclosure (P6.2 gate — never claims a live fee).
431
+ // Referrer disclosure.
426
432
  "components.referrer.disclosure": "This site earns a referral fee.",
427
- "components.referrer.disclosurePending": "This site earns a referral fee (pending protocol support).",
433
+ "components.referrer.disclosurePending": "Referral fee is not active for this hire.",
428
434
  "components.referrer.feeBps": "{bps} bps",
429
435
  // TaskTimeline.
430
436
  "components.taskTimeline.title": "Task progress",
@@ -464,6 +470,13 @@ var EN_COMPONENT_STRINGS = {
464
470
  "components.provider.provisional": "provisional",
465
471
  "components.provider.noData": "No track record yet.",
466
472
  "components.provider.unavailable": "Track record is unavailable on this read transport.",
473
+ // Domain trust (P7.3) — VERIFIED is an on-chain attestation; CLAIMED is the
474
+ // operator's self-reported metadata. The copy keeps them distinct so a buyer
475
+ // never reads an unverified claim as a proven one.
476
+ "components.provider.verifiedDomain": "Verified: {domain}",
477
+ "components.provider.verifiedDomainLabel": "Verified domain {domain}",
478
+ "components.provider.claimedDomain": "Claims: {domain}",
479
+ "components.provider.claimedDomainLabel": "Claimed domain {domain} (not verified on-chain)",
467
480
  // PoweredByAgenC.
468
481
  "components.poweredBy.label": "Powered by AgenC",
469
482
  "components.poweredBy.trustLink": "Learn how this works"
@@ -963,6 +976,36 @@ function requireClient(client) {
963
976
  }
964
977
  return client;
965
978
  }
979
+ function resolveReferrerArgs(ctx) {
980
+ const capability = ctx.resolveReferrerCapability();
981
+ if (!capability.live || !capability.referrer) {
982
+ return { referrerArgs: {}, referrerInjected: false };
983
+ }
984
+ return {
985
+ referrerArgs: {
986
+ referrer: capability.referrer.wallet,
987
+ referrerFeeBps: capability.referrer.feeBps
988
+ },
989
+ referrerInjected: true
990
+ };
991
+ }
992
+ function signerAddress(signerOrAddress) {
993
+ if (typeof signerOrAddress === "string") {
994
+ return signerOrAddress;
995
+ }
996
+ if (typeof signerOrAddress === "object" && signerOrAddress !== null && "address" in signerOrAddress && typeof signerOrAddress.address === "string") {
997
+ return signerOrAddress.address;
998
+ }
999
+ throw new Error("Expected a TransactionSigner or Address with an address field.");
1000
+ }
1001
+ function withoutReferrerArgs(input) {
1002
+ const {
1003
+ referrer: _referrer,
1004
+ referrerFeeBps: _referrerFeeBps,
1005
+ ...rest
1006
+ } = input;
1007
+ return rest;
1008
+ }
966
1009
 
967
1010
  // src/hooks/useHire.ts
968
1011
  function useHire() {
@@ -970,29 +1013,29 @@ function useHire() {
970
1013
  const mutation = reactQuery.useMutation({
971
1014
  mutationFn: async (input) => {
972
1015
  const client = requireClient(ctx.client);
973
- const capability = ctx.resolveReferrerCapability();
974
- const referrerInjected = capability.live && ctx.referrer !== null;
1016
+ const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);
1017
+ const hireInput = withoutReferrerArgs(input);
975
1018
  const creator = input.creator ?? client.signer;
976
1019
  let signature;
977
1020
  if (input.humanless === true) {
978
- const ix = await marketplaceSdk.facade.hireFromListingHumanless({
979
- ...input,
980
- creator
981
- // NOTE: P6.2 referrer fields would spread here under capability.live.
1021
+ const result = await client.hireFromListingHumanless({
1022
+ ...hireInput,
1023
+ creator,
1024
+ ...referrerArgs
982
1025
  });
983
- ({ signature } = await client.send([ix]));
1026
+ signature = result.signature;
984
1027
  } else {
985
1028
  const authority = input.authority ?? client.signer;
986
1029
  const result = await client.hireFromListing({
987
- ...input,
1030
+ ...hireInput,
988
1031
  authority,
989
- creator
990
- // NOTE: P6.2 referrer fields would spread here under capability.live.
1032
+ creator,
1033
+ ...referrerArgs
991
1034
  });
992
1035
  signature = result.signature;
993
1036
  }
994
1037
  const [taskPda] = await marketplaceSdk.findTaskPda({
995
- creator: typeof creator === "object" && creator !== null && "address" in creator ? creator.address : creator,
1038
+ creator: signerAddress(creator),
996
1039
  taskId: input.taskId
997
1040
  });
998
1041
  return { signature, taskPda, referrerInjected };
@@ -1508,9 +1551,90 @@ function DisputeBanner({
1508
1551
  ) : null
1509
1552
  ] });
1510
1553
  }
1554
+ var UNVERIFIED = Object.freeze({
1555
+ verified: false
1556
+ });
1557
+ function evaluateAgentVerification(account, nowSeconds) {
1558
+ if (!account) return UNVERIFIED;
1559
+ if (account.revoked) return UNVERIFIED;
1560
+ if (account.expiresAt !== 0n && nowSeconds >= account.expiresAt) {
1561
+ return UNVERIFIED;
1562
+ }
1563
+ return {
1564
+ verified: true,
1565
+ domain: account.verifiedDomain,
1566
+ method: account.method,
1567
+ verifiedBy: account.verifiedBy,
1568
+ verifiedAt: account.verifiedAt,
1569
+ expiresAt: account.expiresAt,
1570
+ revoked: false
1571
+ };
1572
+ }
1573
+ function defaultNow() {
1574
+ return BigInt(Math.floor(Date.now() / 1e3));
1575
+ }
1576
+ function agentVerificationReaderFromRpc(rpc, options) {
1577
+ const now = options?.now ?? defaultNow;
1578
+ return async (agentPda) => {
1579
+ const [pda] = await marketplaceSdk.findAgentVerificationPda({ agent: agentPda });
1580
+ const maybe = await marketplaceSdk.fetchMaybeAgentVerification(rpc, pda);
1581
+ return evaluateAgentVerification(maybe.exists ? maybe.data : null, now());
1582
+ };
1583
+ }
1584
+ function useAgentVerification(agentPda, options) {
1585
+ const reader = options?.reader;
1586
+ const enabled = (options?.enabled ?? true) && Boolean(agentPda) && Boolean(reader);
1587
+ const query = reactQuery.useQuery({
1588
+ queryKey: ["agenc", "agentVerification", agentPda ? String(agentPda) : ""],
1589
+ enabled,
1590
+ queryFn: async () => {
1591
+ return reader(agentPda);
1592
+ }
1593
+ });
1594
+ const verification = query.error ? UNVERIFIED : query.data ?? UNVERIFIED;
1595
+ return {
1596
+ verification,
1597
+ verified: verification.verified,
1598
+ isLoading: query.isLoading && enabled,
1599
+ error: query.error ?? null,
1600
+ refetch: () => void query.refetch()
1601
+ };
1602
+ }
1603
+ function VerifiedDomainBadge({
1604
+ domain,
1605
+ unstyled
1606
+ }) {
1607
+ return /* @__PURE__ */ jsxRuntime.jsx(
1608
+ Badge,
1609
+ {
1610
+ tone: "success",
1611
+ unstyled,
1612
+ className: unstyled ? void 0 : "agenc-provider__domain agenc-provider__domain--verified",
1613
+ label: tc("components.provider.verifiedDomainLabel", { domain }),
1614
+ children: tc("components.provider.verifiedDomain", { domain })
1615
+ }
1616
+ );
1617
+ }
1618
+ function ClaimedDomainBadge({
1619
+ domain,
1620
+ unstyled
1621
+ }) {
1622
+ return /* @__PURE__ */ jsxRuntime.jsx(
1623
+ Badge,
1624
+ {
1625
+ tone: "neutral",
1626
+ unstyled,
1627
+ className: unstyled ? void 0 : "agenc-provider__domain agenc-provider__domain--claimed",
1628
+ label: tc("components.provider.claimedDomainLabel", { domain }),
1629
+ children: tc("components.provider.claimedDomain", { domain })
1630
+ }
1631
+ );
1632
+ }
1511
1633
  function ProviderCard({
1512
1634
  agent,
1513
1635
  trackRecord,
1636
+ verification = UNVERIFIED,
1637
+ operatorDomain,
1514
1638
  verified = false,
1515
1639
  isLoading = false,
1516
1640
  error = null,
@@ -1519,12 +1643,19 @@ function ProviderCard({
1519
1643
  className
1520
1644
  }) {
1521
1645
  const cardClass = rootClass("agenc-provider", unstyled, className);
1646
+ const isVerified = verification.verified || verification === UNVERIFIED && verified;
1647
+ const verifiedDomain = verification.verified ? verification.domain : null;
1648
+ const claimed = typeof operatorDomain === "string" && operatorDomain.trim() !== "" ? operatorDomain.trim() : null;
1649
+ const domainBadge = verifiedDomain ? /* @__PURE__ */ jsxRuntime.jsx(VerifiedDomainBadge, { domain: verifiedDomain, unstyled }) : claimed ? /* @__PURE__ */ jsxRuntime.jsx(ClaimedDomainBadge, { domain: claimed, unstyled }) : null;
1522
1650
  const header = /* @__PURE__ */ jsxRuntime.jsxs("header", { className: unstyled ? void 0 : "agenc-provider__header", children: [
1523
1651
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__id", children: [
1524
1652
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-provider__label", children: tc("components.provider.title") }),
1525
1653
  agent ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-provider__pda", children: truncateAddress(agent) }) : null
1526
1654
  ] }),
1527
- /* @__PURE__ */ jsxRuntime.jsx(VerifiedBadge, { verified, unstyled })
1655
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__badges", children: [
1656
+ domainBadge,
1657
+ /* @__PURE__ */ jsxRuntime.jsx(VerifiedBadge, { verified: isVerified, unstyled })
1658
+ ] })
1528
1659
  ] });
1529
1660
  if (error) {
1530
1661
  return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
@@ -1659,8 +1790,10 @@ exports.ReviewPanel = ReviewPanel;
1659
1790
  exports.Spinner = Spinner;
1660
1791
  exports.StateMessage = StateMessage;
1661
1792
  exports.TaskTimeline = TaskTimeline;
1793
+ exports.UNVERIFIED = UNVERIFIED;
1662
1794
  exports.VerifiedBadge = VerifiedBadge;
1663
1795
  exports.agencThemeStyleTag = agencThemeStyleTag;
1796
+ exports.agentVerificationReaderFromRpc = agentVerificationReaderFromRpc;
1664
1797
  exports.createReadTransport = createReadTransport;
1665
1798
  exports.cx = cx;
1666
1799
  exports.decodeListingCategory = decodeListingCategory;
@@ -1668,6 +1801,7 @@ exports.decodeListingName = decodeListingName;
1668
1801
  exports.decodeListingTags = decodeListingTags;
1669
1802
  exports.deriveSubscriptionsUrl = deriveSubscriptionsUrl;
1670
1803
  exports.elementClass = elementClass;
1804
+ exports.evaluateAgentVerification = evaluateAgentVerification;
1671
1805
  exports.formatPriceSol = formatPriceSol;
1672
1806
  exports.formatRate = formatRate;
1673
1807
  exports.formatSol = formatSol;
@@ -1684,6 +1818,7 @@ exports.tc = tc;
1684
1818
  exports.toHex = toHex;
1685
1819
  exports.truncateAddress = truncateAddress;
1686
1820
  exports.useAgencContext = useAgencContext;
1821
+ exports.useAgentVerification = useAgentVerification;
1687
1822
  exports.useFocusTrap = useFocusTrap;
1688
1823
  exports.validateReferrerConfig = validateReferrerConfig;
1689
1824
  //# sourceMappingURL=index.cjs.map