@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
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
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-CTTh1ZPg.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, H as HireButton, s as HireButtonProps, t as HireCheckoutListing, u as HireCheckoutModal, v as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, w as ListingCardData, x as ListingCardProps, y as ListingGrid, z as ListingGridProps, M as Modal, F as ModalProps, J as ModerationBadge, K as ModerationBadgeProps, N as ModerationState, P as PoweredByAgenC, O as PoweredByAgenCProps, Q as ProviderCard, S as ProviderCardProps, T as ReadListingResult, U as ReferrerDisclosure, W as ReferrerDisclosureProps, X as ReviewPanel, Y as ReviewPanelProps, Z as Spinner, _ as SpinnerProps, $ as StateKind, a0 as StateMessage, a1 as StateMessageProps, a2 as StringCatalog, a3 as StringId, a4 as StringVars, a5 as TaskTimeline, a6 as TaskTimelineProps, a7 as ThemableProps, a8 as TranslateOptions, a9 as UNVERIFIED, aa as UseAgentVerificationOptions, ab as UseAgentVerificationResult, ac as VerifiedBadge, ad as VerifiedBadgeProps, ae as agentVerificationReaderFromRpc, af as cx, ag as decodeListingCategory, ah as decodeListingName, ai as decodeListingTags, aj as elementClass, ak as evaluateAgentVerification, al as formatPriceSol, am as formatRate, an as formatSol, ao as moderationStateOf, ap as rootClass, aq as t, ar as tc, as as toHex, at as truncateAddress, au as useAgentVerification, av as useFocusTrap } from './index-CTTh1ZPg.cjs';
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-UxuvIlmD.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, H as HireButton, s as HireButtonProps, t as HireCheckoutListing, u as HireCheckoutModal, v as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, w as ListingCardData, x as ListingCardProps, y as ListingGrid, z as ListingGridProps, M as Modal, F as ModalProps, J as ModerationBadge, K as ModerationBadgeProps, N as ModerationState, P as PoweredByAgenC, O as PoweredByAgenCProps, Q as ProviderCard, S as ProviderCardProps, T as ReadListingResult, U as ReferrerDisclosure, W as ReferrerDisclosureProps, X as ReviewPanel, Y as ReviewPanelProps, Z as Spinner, _ as SpinnerProps, $ as StateKind, a0 as StateMessage, a1 as StateMessageProps, a2 as StringCatalog, a3 as StringId, a4 as StringVars, a5 as TaskTimeline, a6 as TaskTimelineProps, a7 as ThemableProps, a8 as TranslateOptions, a9 as UNVERIFIED, aa as UseAgentVerificationOptions, ab as UseAgentVerificationResult, ac as VerifiedBadge, ad as VerifiedBadgeProps, ae as agentVerificationReaderFromRpc, af as cx, ag as decodeListingCategory, ah as decodeListingName, ai as decodeListingTags, aj as elementClass, ak as evaluateAgentVerification, al as formatPriceSol, am as formatRate, an as formatSol, ao as moderationStateOf, ap as rootClass, aq as t, ar as tc, as as toHex, at as truncateAddress, au as useAgentVerification, av as useFocusTrap } from './index-UxuvIlmD.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';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
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-C9R3B80j.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, H as HireButton, s as HireButtonProps, t as HireCheckoutListing, u as HireCheckoutModal, v as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, w as ListingCardData, x as ListingCardProps, y as ListingGrid, z as ListingGridProps, M as Modal, F as ModalProps, J as ModerationBadge, K as ModerationBadgeProps, N as ModerationState, P as PoweredByAgenC, O as PoweredByAgenCProps, Q as ProviderCard, S as ProviderCardProps, T as ReadListingResult, U as ReferrerDisclosure, W as ReferrerDisclosureProps, X as ReviewPanel, Y as ReviewPanelProps, Z as Spinner, _ as SpinnerProps, $ as StateKind, a0 as StateMessage, a1 as StateMessageProps, a2 as StringCatalog, a3 as StringId, a4 as StringVars, a5 as TaskTimeline, a6 as TaskTimelineProps, a7 as ThemableProps, a8 as TranslateOptions, a9 as UNVERIFIED, aa as UseAgentVerificationOptions, ab as UseAgentVerificationResult, ac as VerifiedBadge, ad as VerifiedBadgeProps, ae as agentVerificationReaderFromRpc, af as cx, ag as decodeListingCategory, ah as decodeListingName, ai as decodeListingTags, aj as elementClass, ak as evaluateAgentVerification, al as formatPriceSol, am as formatRate, an as formatSol, ao as moderationStateOf, ap as rootClass, aq as t, ar as tc, as as toHex, at as truncateAddress, au as useAgentVerification, av as useFocusTrap } from './index-C9R3B80j.js';
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-DQ3Xovkq.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, H as HireButton, s as HireButtonProps, t as HireCheckoutListing, u as HireCheckoutModal, v as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, w as ListingCardData, x as ListingCardProps, y as ListingGrid, z as ListingGridProps, M as Modal, F as ModalProps, J as ModerationBadge, K as ModerationBadgeProps, N as ModerationState, P as PoweredByAgenC, O as PoweredByAgenCProps, Q as ProviderCard, S as ProviderCardProps, T as ReadListingResult, U as ReferrerDisclosure, W as ReferrerDisclosureProps, X as ReviewPanel, Y as ReviewPanelProps, Z as Spinner, _ as SpinnerProps, $ as StateKind, a0 as StateMessage, a1 as StateMessageProps, a2 as StringCatalog, a3 as StringId, a4 as StringVars, a5 as TaskTimeline, a6 as TaskTimelineProps, a7 as ThemableProps, a8 as TranslateOptions, a9 as UNVERIFIED, aa as UseAgentVerificationOptions, ab as UseAgentVerificationResult, ac as VerifiedBadge, ad as VerifiedBadgeProps, ae as agentVerificationReaderFromRpc, af as cx, ag as decodeListingCategory, ah as decodeListingName, ai as decodeListingTags, aj as elementClass, ak as evaluateAgentVerification, al as formatPriceSol, am as formatRate, an as formatSol, ao as moderationStateOf, ap as rootClass, aq as t, ar as tc, as as toHex, at as truncateAddress, au as useAgentVerification, av as useFocusTrap } from './index-DQ3Xovkq.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';
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { createReadTransport } from './chunk-D2TDU3TJ.js';
2
- export { ReadTransportUnsupportedError, createReadTransport } from './chunk-D2TDU3TJ.js';
3
- export { EN_SIGNER_STRINGS, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from './chunk-MNJ2EQDJ.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-WJUVTFJ7.js';
5
- import { AgencContext } from './chunk-FAIRTAIB.js';
6
- export { AgencContext, useAgencContext } from './chunk-FAIRTAIB.js';
7
- import { t } from './chunk-ECU7HGO3.js';
8
- export { EN_STRINGS, t } from './chunk-ECU7HGO3.js';
1
+ import { createReadTransport } from './chunk-AKPPKMQ2.js';
2
+ export { ReadTransportUnsupportedError, createReadTransport } from './chunk-AKPPKMQ2.js';
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-ZAMIL27X.js';
5
+ import { AgencContext } from './chunk-2Y6JN2VZ.js';
6
+ export { AgencContext, useAgencContext } from './chunk-2Y6JN2VZ.js';
7
+ import { t } from './chunk-H6PJIDQR.js';
8
+ export { EN_STRINGS, t } from './chunk-H6PJIDQR.js';
9
9
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
10
10
  import { createMarketplaceClient } from '@tetsuo-ai/marketplace-sdk';
11
11
  import { useState, useMemo } from 'react';
@@ -115,10 +115,17 @@ function AgencProvider(props) {
115
115
  const referrer = config.referrer ? validateReferrerConfig(config.referrer) : null;
116
116
  const read = buildReadTransport(config);
117
117
  const client = buildWriteClient(config, network);
118
+ const { rpcUrl } = resolveEndpoints(
119
+ network,
120
+ config.rpcUrl,
121
+ config.rpcSubscriptionsUrl
122
+ );
118
123
  return {
119
124
  network,
120
125
  read,
121
126
  client,
127
+ rpcUrl: rpcUrl ?? null,
128
+ indexerBaseUrl: config.indexer?.baseUrl ?? null,
122
129
  signer: config.signer ?? null,
123
130
  referrer,
124
131
  resolveReferrerCapability: () => resolveReferrerCapability(referrer)
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/provider/network.ts","../src/provider/referrer.ts","../src/provider/AgencProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAcA,IAAM,qBAAA,GAA6D;AAAA,EACjE,QAAA,EAAU,uBAAA;AAAA,EACV,MAAA,EAAQ,+BAAA;AAAA;AAAA,EAER,OAAA,EAAS;AACX,CAAA;AAMA,IAAM,mBAAA,GAA2D;AAAA,EAC/D,QAAA,EAAU,qBAAA;AAAA,EACV,MAAA,EAAQ,6BAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAA;AAGO,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,IAAI,cAAA,CAAe,IAAA,CAAK,MAAM,CAAA,EAAG;AAC/B,IAAA,OAAO,CAAA,MAAA,EAAS,MAAA,CAAO,KAAA,CAAM,UAAA,CAAW,MAAM,CAAC,CAAA,CAAA;AAAA,EACjD;AACA,EAAA,IAAI,aAA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Q,QAAA,EAAS,GAAI,KAAA;AAI7B,EAAA,MAAM,CAAC,mBAAmB,CAAA,GAAI,QAAA;AAAA,IAC5B,MACE,KAAA,CAAM,WAAA,IACN,IAAI,WAAA,CAAY,KAAA,CAAM,qBAAqB,2BAA2B;AAAA,GAC1E;AACA,EAAA,MAAM,WAAA,GAAc,MAAM,WAAA,IAAe,mBAAA;AAEzC,EAAA,MAAM,KAAA,GAAQ,QAA2B,MAAM;AAC7C,IAAA,MAAM,OAAA,GAAwB,OAAO,OAAA,IAAW,SAAA;AAIhD,IAAA,MAAM,WAA2C,MAAA,CAAO,QAAA,GACpD,sBAAA,CAAuB,MAAA,CAAO,QAAQ,CAAA,GACtC,IAAA;AAEJ,IAAA,MAAM,IAAA,GAAO,mBAAmB,MAAM,CAAA;AACtC,IAAA,MAAM,MAAA,GAAS,gBAAA,CAAiB,MAAA,EAAQ,OAAO,CAAA;AAE/C,IAAA,OAAO;AAAA,MACL,OAAA;AAAA,MACA,IAAA;AAAA,MACA,MAAA;AAAA,MACA,MAAA,EAAQ,OAAO,MAAA,IAAU,IAAA;AAAA,MACzB,QAAA;AAAA,MACA,yBAAA,EAA2B,MAAM,yBAAA,CAA8B,QAAQ;AAAA,KACzE;AAAA,EAGF,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,uBACE,GAAA,CAAC,mBAAA,EAAA,EAAoB,MAAA,EAAQ,WAAA,EAC3B,QAAA,kBAAA,GAAA,CAAC,aAAa,QAAA,EAAb,EAAsB,KAAA,EAAe,QAAA,EAAS,CAAA,EACjD,CAAA;AAEJ","file":"index.js","sourcesContent":["/**\n * Network → endpoint defaults.\n *\n * Reuses the resolution philosophy of the SDK sandbox env seam\n * (`resolveSandboxEnvironment`): explicit config beats a per-network default,\n * and the WebSocket endpoint is derived from the HTTP one when not given. This\n * is intentionally a SMALL, synchronous, SSR-safe mirror — the provider needs\n * no `process`/`fs` access and the sandbox seam's async file-reading path.\n *\n * @module provider/network\n */\nimport type { AgencNetwork } from \"../types.js\";\n\n/** Per-network default HTTP RPC endpoints. `mainnet` has no public default. */\nconst NETWORK_HTTP_DEFAULTS: Record<AgencNetwork, string | null> = {\n localnet: \"http://127.0.0.1:8899\",\n devnet: \"https://api.devnet.solana.com\",\n // No public default: mainnet RPC is operator-supplied (rate/cost sensitive).\n mainnet: null,\n};\n\n/**\n * `solana-test-validator` serves PubSub on RPC port + 1 (8900), so localnet's\n * WS endpoint is NOT derivable from the HTTP URL by scheme swap alone.\n */\nconst NETWORK_WS_DEFAULTS: Record<AgencNetwork, string | null> = {\n localnet: \"ws://127.0.0.1:8900\",\n devnet: \"wss://api.devnet.solana.com\",\n mainnet: null,\n};\n\n/** Derive a ws(s) endpoint from an http(s) one (same host/port/path). */\nexport function deriveSubscriptionsUrl(rpcUrl: string): string {\n if (/^https:\\/\\//i.test(rpcUrl)) {\n return `wss://${rpcUrl.slice(\"https://\".length)}`;\n }\n if (/^http:\\/\\//i.test(rpcUrl)) {\n return `ws://${rpcUrl.slice(\"http://\".length)}`;\n }\n return rpcUrl;\n}\n\n/** A resolved pair of RPC endpoints (either may be `null` when unresolvable). */\nexport interface ResolvedEndpoints {\n rpcUrl: string | null;\n rpcSubscriptionsUrl: string | null;\n}\n\n/**\n * Resolve the HTTP + WS RPC endpoints for a network, honoring explicit\n * overrides. Returns `{ rpcUrl: null }` when neither an override nor a default\n * exists (mainnet with no `rpcUrl`) — the provider treats that as \"no write\n * client buildable from URLs\", not a throw, so a read-only/indexer-only or\n * `client`-override setup still works.\n */\nexport function resolveEndpoints(\n network: AgencNetwork,\n rpcUrl?: string,\n rpcSubscriptionsUrl?: string,\n): ResolvedEndpoints {\n const resolvedRpc = rpcUrl ?? NETWORK_HTTP_DEFAULTS[network];\n const resolvedWs =\n rpcSubscriptionsUrl ??\n (rpcUrl !== undefined\n ? deriveSubscriptionsUrl(rpcUrl)\n : NETWORK_WS_DEFAULTS[network]);\n return { rpcUrl: resolvedRpc, rpcSubscriptionsUrl: resolvedWs };\n}\n","/**\n * Referrer config validation + the live referral-settlement capability.\n *\n * ## REFERRER SETTLEMENT\n *\n * Referrer args + the 4th settlement leg are part of the full 84-instruction\n * surface. The SDK `facade.hireFromListing` and\n * `facade.hireFromListingHumanless` both accept referrer fields. This module:\n * - ACCEPTS + VALIDATES `referrer: { wallet, feeBps }` and stores the normalized\n * form (validation is real: bad base58 throws, out-of-range bps rejected);\n * - exposes {@link resolveReferrerCapability}, which reports live when a valid\n * referrer config is present.\n *\n * Aggregated earnings are separate from settlement. `useReferrerEarnings` still\n * remains indexer-gated and must not fabricate totals before that endpoint is\n * published.\n *\n * @module provider/referrer\n */\nimport { isAddress } from \"@solana/kit\";\nimport { t } from \"../strings/index.js\";\nimport type {\n Address,\n ReferrerCapability,\n ReferrerConfig,\n ValidatedReferrerConfig,\n} from \"../types.js\";\n\n/** Minimum referral fee, in basis points. */\nexport const REFERRER_FEE_BPS_MIN = 0;\n/**\n * Maximum referral fee, in basis points. Mirrors the on-chain per-leg cap\n * (`MAX_REFERRER_FEE_BPS = 2000`) so invalid provider config fails before the\n * user signs a transaction.\n */\nexport const REFERRER_FEE_BPS_MAX = 2_000;\n\n/**\n * Validate + normalize a raw {@link ReferrerConfig} into a\n * {@link ValidatedReferrerConfig}.\n *\n * @throws TypeError when `wallet` is not a valid base58 Solana address.\n * @throws RangeError when `feeBps` is not an integer in\n * `[REFERRER_FEE_BPS_MIN, REFERRER_FEE_BPS_MAX]`.\n */\nexport function validateReferrerConfig(\n config: ReferrerConfig,\n): ValidatedReferrerConfig {\n const { wallet, feeBps } = config;\n if (typeof wallet !== \"string\" || !isAddress(wallet)) {\n throw new TypeError(t(\"referrer.invalidWallet\", { wallet: String(wallet) }));\n }\n if (\n typeof feeBps !== \"number\" ||\n !Number.isInteger(feeBps) ||\n feeBps < REFERRER_FEE_BPS_MIN ||\n feeBps > REFERRER_FEE_BPS_MAX\n ) {\n throw new RangeError(\n t(\"referrer.invalidFeeBps\", {\n min: REFERRER_FEE_BPS_MIN,\n max: REFERRER_FEE_BPS_MAX,\n feeBps: String(feeBps),\n }),\n );\n }\n return { wallet: wallet as Address, feeBps };\n}\n\n/**\n * Resolve whether a referral fee can actually be charged by this provider.\n *\n * @param referrer - The validated referrer config under the provider, or null.\n * @returns A {@link ReferrerCapability}; live only when a referrer is configured.\n */\nexport function resolveReferrerCapability(\n referrer: ValidatedReferrerConfig | null,\n): ReferrerCapability {\n if (!referrer) {\n return {\n live: false,\n reason: t(\"referrer.notLiveReason\"),\n };\n }\n return {\n live: true,\n referrer,\n };\n}\n","/**\n * `<AgencProvider>` — the one context that wires reads, writes, and the\n * live referrer config for every AgenC hook/component beneath it.\n *\n * Wraps a bundled TanStack {@link QueryClientProvider} so hooks get\n * caching/refetch/optimistic states with no consumer config. The\n * {@link AgencProviderConfig.client} and {@link AgencProviderConfig.queryTransport}\n * slots are PUBLIC test seams: `startLocalMarketplace().client` plugs straight\n * into `client` for hook e2e, and a mock {@link ReadTransport} plugs into\n * `queryTransport`.\n *\n * SSR-safe: no `window`/`document` access at module scope or during render; all\n * resolution is pure. The provider memoizes the context value and the\n * QueryClient on config identity so SSR + hydration stay stable.\n *\n * @module provider/AgencProvider\n */\nimport {\n QueryClient,\n QueryClientProvider,\n type QueryClientConfig,\n} from \"@tanstack/react-query\";\nimport { createMarketplaceClient } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useMemo, useState, type ReactNode } from \"react\";\nimport { createReadTransport } from \"../transport/index.js\";\nimport type {\n AgencContextValue,\n AgencNetwork,\n AgencProviderConfig,\n MarketplaceClient,\n ReadTransport,\n ValidatedReferrerConfig,\n} from \"../types.js\";\nimport { AgencContext } from \"./context.js\";\nimport { resolveEndpoints } from \"./network.js\";\nimport {\n resolveReferrerCapability as resolveReferrerCapabilityImpl,\n validateReferrerConfig,\n} from \"./referrer.js\";\n\n/** Props for {@link AgencProvider}. */\nexport interface AgencProviderProps {\n /** Provider configuration. See {@link AgencProviderConfig}. */\n config: AgencProviderConfig;\n /**\n * Optional pre-built TanStack QueryClient. When omitted, the provider creates\n * one lazily (stable across renders). Pass your own to share a cache with the\n * rest of your app.\n */\n queryClient?: QueryClient;\n /** Override config for the lazily-created QueryClient (ignored if you pass one). */\n queryClientConfig?: QueryClientConfig;\n children: ReactNode;\n}\n\n/** Default QueryClient tuning for marketplace reads (sane, overridable). */\nconst DEFAULT_QUERY_CLIENT_CONFIG: QueryClientConfig = {\n defaultOptions: {\n queries: {\n // Marketplace listings change on-chain slowly relative to a UI session;\n // a short stale window avoids refetch storms while staying fresh.\n staleTime: 15_000,\n retry: 1,\n refetchOnWindowFocus: false,\n },\n },\n};\n\n/**\n * Build the read transport from config. The `queryTransport` override wins;\n * otherwise indexer-first (when `indexer.baseUrl` is set) with a gPA fallback\n * over the resolved RPC URL.\n *\n * NOTE: the gPA fallback needs a kit `Rpc<GetProgramAccountsApi>`, which we do\n * NOT build here from a bare URL — the SDK write client owns RPC construction.\n * When only a URL (no indexer, no queryTransport) is available, reads require\n * an indexer; the transport factory throws a descriptive error on first use.\n */\nfunction buildReadTransport(\n config: AgencProviderConfig,\n): ReadTransport {\n return createReadTransport({\n indexer: config.indexer,\n queryTransport: config.queryTransport,\n // The gPA read source is provided only via queryTransport in v1 (a kit RPC\n // or ProgramAccountsTransport). A future revision can derive a kit RPC from\n // the resolved rpcUrl; for now indexer-first is the supported read path and\n // queryTransport is the test/mocks seam.\n });\n}\n\n/**\n * Build the write client from config. The `client` override wins. Otherwise a\n * client is built only when BOTH a resolvable `rpcUrl` and a `signer` exist;\n * absent either, the provider exposes `client: null` and mutating hooks surface\n * a clear error (read-only / indexer-only setups are valid).\n */\nfunction buildWriteClient(\n config: AgencProviderConfig,\n network: AgencNetwork,\n): MarketplaceClient | null {\n if (config.client) return config.client;\n if (!config.signer) return null;\n const { rpcUrl, rpcSubscriptionsUrl } = resolveEndpoints(\n network,\n config.rpcUrl,\n config.rpcSubscriptionsUrl,\n );\n if (rpcUrl === null) return null;\n return createMarketplaceClient({\n rpcUrl,\n ...(rpcSubscriptionsUrl ? { rpcSubscriptionsUrl } : {}),\n signer: config.signer,\n });\n}\n\n/**\n * The AgenC provider. Place at the root of any tree that uses AgenC hooks or\n * components.\n *\n * @example\n * ```tsx\n * <AgencProvider config={{ network: \"devnet\", indexer: { baseUrl } }}>\n * <App />\n * </AgencProvider>\n * ```\n */\nexport function AgencProvider(props: AgencProviderProps): ReactNode {\n const { config, children } = props;\n\n // Lazily create (and keep stable) the QueryClient. useState initializer runs\n // once; passing your own `queryClient` overrides it.\n const [internalQueryClient] = useState<QueryClient>(\n () =>\n props.queryClient ??\n new QueryClient(props.queryClientConfig ?? DEFAULT_QUERY_CLIENT_CONFIG),\n );\n const queryClient = props.queryClient ?? internalQueryClient;\n\n const value = useMemo<AgencContextValue>(() => {\n const network: AgencNetwork = config.network ?? \"mainnet\";\n\n // Validate + normalize referrer at provider construction. A bad config\n // throws here, before any hire transaction can be built.\n const referrer: ValidatedReferrerConfig | null = config.referrer\n ? validateReferrerConfig(config.referrer)\n : null;\n\n const read = buildReadTransport(config);\n const client = buildWriteClient(config, network);\n\n return {\n network,\n read,\n client,\n signer: config.signer ?? null,\n referrer,\n resolveReferrerCapability: () => resolveReferrerCapabilityImpl(referrer),\n };\n // Re-resolve when any wiring input changes. Referrer object identity is\n // intentionally part of the deps (a new referrer config must re-validate).\n }, [config]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <AgencContext.Provider value={value}>{children}</AgencContext.Provider>\n </QueryClientProvider>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/provider/network.ts","../src/provider/referrer.ts","../src/provider/AgencProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAcA,IAAM,qBAAA,GAA6D;AAAA,EACjE,QAAA,EAAU,uBAAA;AAAA,EACV,MAAA,EAAQ,+BAAA;AAAA;AAAA,EAER,OAAA,EAAS;AACX,CAAA;AAMA,IAAM,mBAAA,GAA2D;AAAA,EAC/D,QAAA,EAAU,qBAAA;AAAA,EACV,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AAM,yBAAA,CAA8B,QAAQ;AAAA,KACzE;AAAA,EAGF,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,uBACE,GAAA,CAAC,mBAAA,EAAA,EAAoB,MAAA,EAAQ,WAAA,EAC3B,QAAA,kBAAA,GAAA,CAAC,aAAa,QAAA,EAAb,EAAsB,KAAA,EAAe,QAAA,EAAS,CAAA,EACjD,CAAA;AAEJ","file":"index.js","sourcesContent":["/**\n * Network → endpoint defaults.\n *\n * Reuses the resolution philosophy of the SDK sandbox env seam\n * (`resolveSandboxEnvironment`): explicit config beats a per-network default,\n * and the WebSocket endpoint is derived from the HTTP one when not given. This\n * is intentionally a SMALL, synchronous, SSR-safe mirror — the provider needs\n * no `process`/`fs` access and the sandbox seam's async file-reading path.\n *\n * @module provider/network\n */\nimport type { AgencNetwork } from \"../types.js\";\n\n/** Per-network default HTTP RPC endpoints. `mainnet` has no public default. */\nconst NETWORK_HTTP_DEFAULTS: Record<AgencNetwork, string | null> = {\n localnet: \"http://127.0.0.1:8899\",\n devnet: \"https://api.devnet.solana.com\",\n // No public default: mainnet RPC is operator-supplied (rate/cost sensitive).\n mainnet: null,\n};\n\n/**\n * `solana-test-validator` serves PubSub on RPC port + 1 (8900), so localnet's\n * WS endpoint is NOT derivable from the HTTP URL by scheme swap alone.\n */\nconst NETWORK_WS_DEFAULTS: Record<AgencNetwork, string | null> = {\n localnet: \"ws://127.0.0.1:8900\",\n devnet: \"wss://api.devnet.solana.com\",\n mainnet: null,\n};\n\n/** Derive a ws(s) endpoint from an http(s) one (same host/port/path). */\nexport function deriveSubscriptionsUrl(rpcUrl: string): string {\n if (/^https:\\/\\//i.test(rpcUrl)) {\n return `wss://${rpcUrl.slice(\"https://\".length)}`;\n }\n if (/^http:\\/\\//i.test(rpcUrl)) {\n return `ws://${rpcUrl.slice(\"http://\".length)}`;\n }\n return rpcUrl;\n}\n\n/** A resolved pair of RPC endpoints (either may be `null` when unresolvable). */\nexport interface ResolvedEndpoints {\n rpcUrl: string | null;\n rpcSubscriptionsUrl: string | null;\n}\n\n/**\n * Resolve the HTTP + WS RPC endpoints for a network, honoring explicit\n * overrides. Returns `{ rpcUrl: null }` when neither an override nor a default\n * exists (mainnet with no `rpcUrl`) — the provider treats that as \"no write\n * client buildable from URLs\", not a throw, so a read-only/indexer-only or\n * `client`-override setup still works.\n */\nexport function resolveEndpoints(\n network: AgencNetwork,\n rpcUrl?: string,\n rpcSubscriptionsUrl?: string,\n): ResolvedEndpoints {\n const resolvedRpc = rpcUrl ?? NETWORK_HTTP_DEFAULTS[network];\n const resolvedWs =\n rpcSubscriptionsUrl ??\n (rpcUrl !== undefined\n ? deriveSubscriptionsUrl(rpcUrl)\n : NETWORK_WS_DEFAULTS[network]);\n return { rpcUrl: resolvedRpc, rpcSubscriptionsUrl: resolvedWs };\n}\n","/**\n * Referrer config validation + the live referral-settlement capability.\n *\n * ## REFERRER SETTLEMENT\n *\n * Referrer args + the 4th settlement leg are part of the full 84-instruction\n * surface. The SDK `facade.hireFromListing` and\n * `facade.hireFromListingHumanless` both accept referrer fields. This module:\n * - ACCEPTS + VALIDATES `referrer: { wallet, feeBps }` and stores the normalized\n * form (validation is real: bad base58 throws, out-of-range bps rejected);\n * - exposes {@link resolveReferrerCapability}, which reports live when a valid\n * referrer config is present.\n *\n * Aggregated earnings are separate from settlement. `useReferrerEarnings` still\n * remains indexer-gated and must not fabricate totals before that endpoint is\n * published.\n *\n * @module provider/referrer\n */\nimport { isAddress } from \"@solana/kit\";\nimport { t } from \"../strings/index.js\";\nimport type {\n Address,\n ReferrerCapability,\n ReferrerConfig,\n ValidatedReferrerConfig,\n} from \"../types.js\";\n\n/** Minimum referral fee, in basis points. */\nexport const REFERRER_FEE_BPS_MIN = 0;\n/**\n * Maximum referral fee, in basis points. Mirrors the on-chain per-leg cap\n * (`MAX_REFERRER_FEE_BPS = 2000`) so invalid provider config fails before the\n * user signs a transaction.\n */\nexport const REFERRER_FEE_BPS_MAX = 2_000;\n\n/**\n * Validate + normalize a raw {@link ReferrerConfig} into a\n * {@link ValidatedReferrerConfig}.\n *\n * @throws TypeError when `wallet` is not a valid base58 Solana address.\n * @throws RangeError when `feeBps` is not an integer in\n * `[REFERRER_FEE_BPS_MIN, REFERRER_FEE_BPS_MAX]`.\n */\nexport function validateReferrerConfig(\n config: ReferrerConfig,\n): ValidatedReferrerConfig {\n const { wallet, feeBps } = config;\n if (typeof wallet !== \"string\" || !isAddress(wallet)) {\n throw new TypeError(t(\"referrer.invalidWallet\", { wallet: String(wallet) }));\n }\n if (\n typeof feeBps !== \"number\" ||\n !Number.isInteger(feeBps) ||\n feeBps < REFERRER_FEE_BPS_MIN ||\n feeBps > REFERRER_FEE_BPS_MAX\n ) {\n throw new RangeError(\n t(\"referrer.invalidFeeBps\", {\n min: REFERRER_FEE_BPS_MIN,\n max: REFERRER_FEE_BPS_MAX,\n feeBps: String(feeBps),\n }),\n );\n }\n return { wallet: wallet as Address, feeBps };\n}\n\n/**\n * Resolve whether a referral fee can actually be charged by this provider.\n *\n * @param referrer - The validated referrer config under the provider, or null.\n * @returns A {@link ReferrerCapability}; live only when a referrer is configured.\n */\nexport function resolveReferrerCapability(\n referrer: ValidatedReferrerConfig | null,\n): ReferrerCapability {\n if (!referrer) {\n return {\n live: false,\n reason: t(\"referrer.notLiveReason\"),\n };\n }\n return {\n live: true,\n referrer,\n };\n}\n","/**\n * `<AgencProvider>` — the one context that wires reads, writes, and the\n * live referrer config for every AgenC hook/component beneath it.\n *\n * Wraps a bundled TanStack {@link QueryClientProvider} so hooks get\n * caching/refetch/optimistic states with no consumer config. The\n * {@link AgencProviderConfig.client} and {@link AgencProviderConfig.queryTransport}\n * slots are PUBLIC test seams: `startLocalMarketplace().client` plugs straight\n * into `client` for hook e2e, and a mock {@link ReadTransport} plugs into\n * `queryTransport`.\n *\n * SSR-safe: no `window`/`document` access at module scope or during render; all\n * resolution is pure. The provider memoizes the context value and the\n * QueryClient on config identity so SSR + hydration stay stable.\n *\n * @module provider/AgencProvider\n */\nimport {\n QueryClient,\n QueryClientProvider,\n type QueryClientConfig,\n} from \"@tanstack/react-query\";\nimport { createMarketplaceClient } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useMemo, useState, type ReactNode } from \"react\";\nimport { createReadTransport } from \"../transport/index.js\";\nimport type {\n AgencContextValue,\n AgencNetwork,\n AgencProviderConfig,\n MarketplaceClient,\n ReadTransport,\n ValidatedReferrerConfig,\n} from \"../types.js\";\nimport { AgencContext } from \"./context.js\";\nimport { resolveEndpoints } from \"./network.js\";\nimport {\n resolveReferrerCapability as resolveReferrerCapabilityImpl,\n validateReferrerConfig,\n} from \"./referrer.js\";\n\n/** Props for {@link AgencProvider}. */\nexport interface AgencProviderProps {\n /** Provider configuration. See {@link AgencProviderConfig}. */\n config: AgencProviderConfig;\n /**\n * Optional pre-built TanStack QueryClient. When omitted, the provider creates\n * one lazily (stable across renders). Pass your own to share a cache with the\n * rest of your app.\n */\n queryClient?: QueryClient;\n /** Override config for the lazily-created QueryClient (ignored if you pass one). */\n queryClientConfig?: QueryClientConfig;\n children: ReactNode;\n}\n\n/** Default QueryClient tuning for marketplace reads (sane, overridable). */\nconst DEFAULT_QUERY_CLIENT_CONFIG: QueryClientConfig = {\n defaultOptions: {\n queries: {\n // Marketplace listings change on-chain slowly relative to a UI session;\n // a short stale window avoids refetch storms while staying fresh.\n staleTime: 15_000,\n retry: 1,\n refetchOnWindowFocus: false,\n },\n },\n};\n\n/**\n * Build the read transport from config. The `queryTransport` override wins;\n * otherwise indexer-first (when `indexer.baseUrl` is set) with a gPA fallback\n * over the resolved RPC URL.\n *\n * NOTE: the gPA fallback needs a kit `Rpc<GetProgramAccountsApi>`, which we do\n * NOT build here from a bare URL — the SDK write client owns RPC construction.\n * When only a URL (no indexer, no queryTransport) is available, reads require\n * an indexer; the transport factory throws a descriptive error on first use.\n */\nfunction buildReadTransport(\n config: AgencProviderConfig,\n): ReadTransport {\n return createReadTransport({\n indexer: config.indexer,\n queryTransport: config.queryTransport,\n // The gPA read source is provided only via queryTransport in v1 (a kit RPC\n // or ProgramAccountsTransport). A future revision can derive a kit RPC from\n // the resolved rpcUrl; for now indexer-first is the supported read path and\n // queryTransport is the test/mocks seam.\n });\n}\n\n/**\n * Build the write client from config. The `client` override wins. Otherwise a\n * client is built only when BOTH a resolvable `rpcUrl` and a `signer` exist;\n * absent either, the provider exposes `client: null` and mutating hooks surface\n * a clear error (read-only / indexer-only setups are valid).\n */\nfunction buildWriteClient(\n config: AgencProviderConfig,\n network: AgencNetwork,\n): MarketplaceClient | null {\n if (config.client) return config.client;\n if (!config.signer) return null;\n const { rpcUrl, rpcSubscriptionsUrl } = resolveEndpoints(\n network,\n config.rpcUrl,\n config.rpcSubscriptionsUrl,\n );\n if (rpcUrl === null) return null;\n return createMarketplaceClient({\n rpcUrl,\n ...(rpcSubscriptionsUrl ? { rpcSubscriptionsUrl } : {}),\n signer: config.signer,\n });\n}\n\n/**\n * The AgenC provider. Place at the root of any tree that uses AgenC hooks or\n * components.\n *\n * @example\n * ```tsx\n * <AgencProvider config={{ network: \"devnet\", indexer: { baseUrl } }}>\n * <App />\n * </AgencProvider>\n * ```\n */\nexport function AgencProvider(props: AgencProviderProps): ReactNode {\n const { config, children } = props;\n\n // Lazily create (and keep stable) the QueryClient. useState initializer runs\n // once; passing your own `queryClient` overrides it.\n const [internalQueryClient] = useState<QueryClient>(\n () =>\n props.queryClient ??\n new QueryClient(props.queryClientConfig ?? DEFAULT_QUERY_CLIENT_CONFIG),\n );\n const queryClient = props.queryClient ?? internalQueryClient;\n\n const value = useMemo<AgencContextValue>(() => {\n const network: AgencNetwork = config.network ?? \"mainnet\";\n\n // Validate + normalize referrer at provider construction. A bad config\n // throws here, before any hire transaction can be built.\n const referrer: ValidatedReferrerConfig | null = config.referrer\n ? validateReferrerConfig(config.referrer)\n : null;\n\n const read = buildReadTransport(config);\n const client = buildWriteClient(config, network);\n\n // The resolved HTTP RPC endpoint, exposed so hooks can make single-account\n // reads (e.g. resolving the WP-A1 roster-attestor account at activation)\n // without an indexer. Not a gPA source — the read transport owns list\n // queries.\n const { rpcUrl } = resolveEndpoints(\n network,\n config.rpcUrl,\n config.rpcSubscriptionsUrl,\n );\n\n return {\n network,\n read,\n client,\n rpcUrl: rpcUrl ?? null,\n indexerBaseUrl: config.indexer?.baseUrl ?? null,\n signer: config.signer ?? null,\n referrer,\n resolveReferrerCapability: () => resolveReferrerCapabilityImpl(referrer),\n };\n // Re-resolve when any wiring input changes. Referrer object identity is\n // intentionally part of the deps (a new referrer config must re-validate).\n }, [config]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <AgencContext.Provider value={value}>{children}</AgencContext.Provider>\n </QueryClientProvider>\n );\n}\n"]}
@@ -15,7 +15,8 @@ var EN_STRINGS = {
15
15
  "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
16
16
  "referrer.notLive": "Referral fee is not active for this hire.",
17
17
  "referrer.notLiveReason": "No referrer is configured for this provider.",
18
- "referrer.earningsNotLiveReason": "Referral settlement is live, but aggregated referrer earnings are not yet exposed by the indexer.",
18
+ "referrer.earningsNotLiveReason": "Referral settlement is live, but no earnings endpoint is available on this network (configure indexer.baseUrl).",
19
+ "referrer.earningsFetchFailed": "The referrer earnings endpoint could not be read.",
19
20
  // Read transport.
20
21
  "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
21
22
  // Generic loading / empty / error states (components extend these).
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/strings/index.ts","../../src/signers/strings.ts","../../src/signers/wallet-account.ts","../../src/signers/wallet-adapter.ts","../../src/signers/embedded-wallet.ts"],"names":["address","getTransactionEncoder","getTransactionDecoder"],"mappings":";;;;;;;AAkCO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,yBAAA,EACE,sDAAA;AAAA,EACF,6BAAA,EACE,uIAAA;AAAA,EACF,wBAAA,EACE,qFAAA;AAA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A,IACF;AAAA,GACF;AACF;AC5GO,SAAS,yBACd,UAAA,EACmB;AACnB,EAAA,MAAM,aAAA,GAAgBF,WAAAA,CAAQ,UAAA,CAAW,OAAO,CAAA;AAEhD,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,aAAA;AAAA,IACT,MAAM,iBAAiB,YAAA,EAAsC;AAC3D,MAAA,MAAM,UAAA,GACJ,MAAM,UAAA,CAAW,gBAAA,CAAiB,YAAY,CAAA;AAChD,MAAA,IAAI,UAAA,CAAW,MAAA,KAAW,YAAA,CAAa,MAAA,EAAQ;AAC7C,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,GAAG,+BAAA,EAAiC;AAAA,YAClC,UAAU,YAAA,CAAa,MAAA;AAAA,YACvB,KAAK,UAAA,CAAW;AAAA,WACjB;AAAA,SACH;AAAA,MACF;AACA,MAAA,OAAO,YAAA,CAAa,GAAA,CAAI,CAAC,CAAA,EAAG,CAAA,MAAO;AAAA,QACjC,CAAC,aAAa,GAAG,UAAA,CAAW,CAAC;AAAA,OAC/B,CAAE,CAAA;AAAA,IACJ;AAAA,GACF;AACF","file":"index.cjs","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","/**\n * Signer-adapter string catalog (the `signer.*` namespace).\n *\n * Kept local to `src/signers/**` so the adapters route every user-facing string\n * through the package's {@link t} resolver (the PLAN_2 Part A locale contract)\n * WITHOUT cross-editing the shared `src/strings` catalog owned by another\n * surface. A future locale can extend `EN_SIGNER_STRINGS` the same way.\n *\n * @module signers/strings\n */\nimport { t, type StringCatalog } from \"../strings/index.js\";\n\n/** English `signer.*` strings used by the wallet/embedded adapters. */\nexport const EN_SIGNER_STRINGS = {\n \"signer.walletNoSignFeature\":\n \"Wallet account {address} does not expose a solana:signTransaction feature. Pass options.signTransaction explicitly, or use a Wallet Standard account that supports transaction signing.\",\n \"signer.walletNoSignature\":\n \"The wallet returned no signature for account {address}. The wallet may have rejected or modified the transaction so the fee-payer signature is absent.\",\n \"signer.embeddedSignatureCount\":\n \"Embedded wallet returned {got} signatures for {expected} transactions; expected one per transaction.\",\n \"signer.walletAdapterDisconnected\":\n \"The wallet adapter is not connected (publicKey is null). Connect the wallet before creating a signer.\",\n \"signer.walletAdapterNoSign\":\n \"The wallet adapter does not expose signTransaction. Use a wallet that supports transaction signing, or migrate to the Wallet Standard path (signerFromWalletAccount).\",\n} as const satisfies StringCatalog;\n\n/** A `signer.*` message id. */\nexport type SignerStringId = keyof typeof EN_SIGNER_STRINGS;\n\n/**\n * `t()` bound to the signer catalog: resolves `signer.*` ids while preserving\n * the shared resolver's interpolation + verbatim-fallback behavior.\n */\nexport function ts(\n id: SignerStringId,\n vars?: Record<string, string | number | bigint>,\n): string {\n return t(id, vars, { catalog: EN_SIGNER_STRINGS });\n}\n","/**\n * Wallet Standard → kit `TransactionSigner` bridge (PLAN.md P4.1 / PLAN_2 D-1).\n *\n * Turns a connected browser wallet into the {@link TransactionSigner} the SDK's\n * `createMarketplaceClient` consumes. The SDK client signs via\n * `signTransactionMessageWithSigners(...)` and submits through its OWN transport\n * — so it needs a PARTIAL signer (one that returns signatures without sending),\n * NOT a `TransactionSendingSigner` (which `signTransactionMessageWithSigners`\n * deliberately ignores). This bridge therefore produces a\n * {@link TransactionPartialSigner}: it serializes each transaction, hands it to\n * the wallet's `solana:signTransaction` feature, and diffs the returned signed\n * transaction to recover THIS account's signature.\n *\n * @see {@link signerFromWalletAccount}\n * @module signers/wallet-account\n */\nimport {\n address,\n getTransactionDecoder,\n getTransactionEncoder,\n type Address,\n type SignatureBytes,\n type Transaction,\n} from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type {\n SignerFromWalletAccountOptions,\n TransactionSigner,\n WalletStandardAccountLike,\n WalletStandardSignTransaction,\n} from \"./types.js\";\n\nconst SOLANA_SIGN_TRANSACTION = \"solana:signTransaction\";\n\n/** Resolve the wallet's `solana:signTransaction` method from account/options. */\nfunction resolveSignTransaction(\n account: WalletStandardAccountLike,\n options: SignerFromWalletAccountOptions,\n): WalletStandardSignTransaction {\n if (options.signTransaction) return options.signTransaction;\n const feature = account.features?.[SOLANA_SIGN_TRANSACTION] as\n | { signTransaction?: WalletStandardSignTransaction }\n | undefined;\n if (feature?.signTransaction) return feature.signTransaction;\n throw new Error(ts(\"signer.walletNoSignFeature\", { address: account.address }));\n}\n\n/** Pick the CAIP-2 chain to forward to the wallet. */\nfunction resolveChain(\n account: WalletStandardAccountLike,\n options: SignerFromWalletAccountOptions,\n): string | undefined {\n if (options.chain) return options.chain;\n return account.chains?.find((c) => c.startsWith(\"solana:\"));\n}\n\n/**\n * Bridge a Wallet Standard account into a kit {@link TransactionSigner}.\n *\n * Accepts either a real `UiWalletAccount` (the `@solana/react` path — pass the\n * account and a `chain`, or pass the hook's feature via\n * {@link SignerFromWalletAccountOptions.signTransaction}) or any object exposing\n * the `solana:signTransaction` feature. The returned signer is a\n * {@link TransactionPartialSigner}, the exact shape the SDK client expects.\n *\n * Wallets may MODIFY a transaction before signing (priority fees, guard\n * instructions). We honor that by decoding the wallet's returned signed\n * transaction and extracting only THIS account's signature; the SDK client then\n * re-assembles and submits. (If a wallet rewrites the message such that the\n * fee-payer's own prior signing is invalidated, that is a wallet contract the\n * SDK's single-fee-payer flow already assumes won't happen for the payer.)\n *\n * SSR-safe: constructs no browser globals; the wallet round-trip only runs when\n * a transaction is actually signed.\n *\n * @param account - The connected Wallet Standard account (needs `address`).\n * @param options - Chain + an optional explicit `signTransaction` override.\n * @returns A kit {@link TransactionSigner} usable as `config.signer`.\n * @throws Error if no `solana:signTransaction` feature can be resolved.\n *\n * @example\n * ```ts\n * // With @solana/react (Wallet Standard):\n * const account = useSelectedWalletAccount(); // UiWalletAccount\n * const signer = signerFromWalletAccount(account, { chain: \"solana:devnet\" });\n * // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.\n * ```\n */\nexport function signerFromWalletAccount(\n account: WalletStandardAccountLike,\n options: SignerFromWalletAccountOptions = {},\n): TransactionSigner {\n const signerAddress: Address = address(account.address);\n const signTransaction = resolveSignTransaction(account, options);\n const chain = resolveChain(account, options);\n const encoder = getTransactionEncoder();\n const decoder = getTransactionDecoder();\n\n async function signOne(transaction: Transaction): Promise<SignatureBytes> {\n const wireBytes = new Uint8Array(encoder.encode(transaction));\n const [output] = await signTransaction({\n transaction: wireBytes,\n ...(chain ? { chain } : {}),\n });\n if (!output) {\n throw new Error(ts(\"signer.walletNoSignature\", { address: account.address }));\n }\n const signed = decoder.decode(output.signedTransaction);\n const signature = signed.signatures[signerAddress];\n if (!signature) {\n throw new Error(ts(\"signer.walletNoSignature\", { address: account.address }));\n }\n return signature as SignatureBytes;\n }\n\n return {\n address: signerAddress,\n async signTransactions(transactions) {\n // Sign in parallel — partial signers are order-independent (each returns a\n // single-entry SignatureDictionary the caller merges).\n return Promise.all(\n transactions.map(async (transaction) => ({\n [signerAddress]: await signOne(transaction),\n })),\n );\n },\n } satisfies TransactionSigner;\n}\n","/**\n * LEGACY `@solana/wallet-adapter` compatibility shim (PLAN.md P4.1).\n *\n * The supported, robust path for browser wallets is the Wallet Standard bridge\n * ({@link signerFromWalletAccount} via `@solana/react`): every modern wallet —\n * including all wallet-adapter wallets — registers as a Wallet Standard wallet,\n * so a wallet-adapter app can migrate by reading the selected account through\n * `@solana/react` and dropping it into `signerFromWalletAccount`. PREFER THAT.\n *\n * This shim exists for apps still holding a raw wallet-adapter\n * `WalletContextState` (web3.js v1 `signTransaction`). It bridges WITHOUT a hard\n * dependency on `@solana/wallet-adapter-*` OR `@solana/web3.js` (1.x): the\n * caller injects the web3.js `VersionedTransaction` class (the only piece we\n * cannot reconstruct), and we round-trip through the shared wire format — a kit\n * {@link Transaction} and a web3.js `VersionedTransaction` serialize to the SAME\n * bytes, so no semantic re-encoding is needed.\n *\n * SSR-safe: no browser globals at module scope.\n *\n * @module signers/wallet-adapter\n */\nimport {\n address,\n getTransactionDecoder,\n getTransactionEncoder,\n type SignatureBytes,\n type Transaction,\n} from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type { TransactionSigner } from \"./types.js\";\n\n/**\n * The web3.js v1 `VersionedTransaction` surface this shim needs: a static\n * `deserialize(bytes)` and an instance `serialize()`. Pass the real class from\n * `@solana/web3.js` — typed structurally so this module never imports it.\n */\nexport interface VersionedTransactionLike {\n serialize(): Uint8Array;\n}\n\n/** The static side of the injected `VersionedTransaction` class. */\nexport interface VersionedTransactionCtor {\n deserialize(bytes: Uint8Array): VersionedTransactionLike;\n}\n\n/**\n * The minimal slice of a wallet-adapter `WalletContextState` this shim consumes.\n * Both `publicKey` (anything with a base58 `toString()`/`toBase58()`) and the\n * v1 `signTransaction` are required; a connected adapter exposes both.\n */\nexport interface WalletAdapterLike {\n /** The connected account's public key (base58 via `toBase58()`/`toString()`). */\n readonly publicKey:\n | { toBase58(): string }\n | { toString(): string }\n | string\n | null;\n /** web3.js v1 sign — returns the same transaction type, signed. */\n signTransaction?: <T extends VersionedTransactionLike>(\n transaction: T,\n ) => Promise<T>;\n}\n\n/** Options for {@link signerFromWalletAdapter}. */\nexport interface SignerFromWalletAdapterOptions {\n /**\n * The web3.js `VersionedTransaction` class (`import { VersionedTransaction }\n * from \"@solana/web3.js\"`). Required — it is the one piece this no-dep shim\n * cannot supply itself.\n */\n VersionedTransaction: VersionedTransactionCtor;\n}\n\nfunction resolveAdapterAddress(adapter: WalletAdapterLike): string {\n const { publicKey } = adapter;\n if (publicKey == null) {\n throw new Error(ts(\"signer.walletAdapterDisconnected\"));\n }\n if (typeof publicKey === \"string\") return publicKey;\n if (\"toBase58\" in publicKey && typeof publicKey.toBase58 === \"function\") {\n return publicKey.toBase58();\n }\n return String(publicKey);\n}\n\n/**\n * Bridge a LEGACY `@solana/wallet-adapter` `WalletContextState` into a kit\n * {@link TransactionSigner}.\n *\n * Use only when you cannot reach the wallet through `@solana/react`. The result\n * is a {@link TransactionPartialSigner} (the SDK client owns submission), built\n * by serializing the kit transaction to wire bytes, rehydrating it as a web3.js\n * `VersionedTransaction`, handing THAT to the adapter's `signTransaction`, then\n * decoding the signed wire bytes back to a kit transaction to extract this\n * account's signature.\n *\n * @param adapter - A connected wallet-adapter state (`publicKey` + `signTransaction`).\n * @param options - Must inject the web3.js `VersionedTransaction` class.\n * @returns A kit {@link TransactionSigner} usable as `config.signer`.\n * @throws Error if the adapter is disconnected or lacks `signTransaction`.\n *\n * @example\n * ```ts\n * import { VersionedTransaction } from \"@solana/web3.js\";\n * import { useWallet } from \"@solana/wallet-adapter-react\";\n *\n * const wallet = useWallet();\n * const signer = signerFromWalletAdapter(wallet, { VersionedTransaction });\n * // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.\n * ```\n */\nexport function signerFromWalletAdapter(\n adapter: WalletAdapterLike,\n options: SignerFromWalletAdapterOptions,\n): TransactionSigner {\n const signerAddress = address(resolveAdapterAddress(adapter));\n const { signTransaction } = adapter;\n if (typeof signTransaction !== \"function\") {\n throw new Error(ts(\"signer.walletAdapterNoSign\"));\n }\n const { VersionedTransaction } = options;\n const encoder = getTransactionEncoder();\n const decoder = getTransactionDecoder();\n\n async function signOne(transaction: Transaction): Promise<SignatureBytes> {\n const wireBytes = new Uint8Array(encoder.encode(transaction));\n const legacyTx = VersionedTransaction.deserialize(wireBytes);\n const signed = await signTransaction!(legacyTx);\n const signedTx = decoder.decode(new Uint8Array(signed.serialize()));\n const signature = signedTx.signatures[signerAddress];\n if (!signature) {\n throw new Error(\n ts(\"signer.walletNoSignature\", { address: signerAddress }),\n );\n }\n return signature as SignatureBytes;\n }\n\n return {\n address: signerAddress,\n async signTransactions(transactions) {\n return Promise.all(\n transactions.map(async (transaction) => ({\n [signerAddress]: await signOne(transaction),\n })),\n );\n },\n } satisfies TransactionSigner;\n}\n","/**\n * Embedded / walletless → kit `TransactionSigner` bridge (PLAN_2 D-1).\n *\n * The \"no wallet, no SOL\" buyer path. A vendor-neutral\n * {@link EmbeddedWalletProvider} (Privy / Dynamic / Web3Auth — `[HUMAN]`-gated)\n * handles email/social login + key custody; this module lifts a live\n * {@link EmbeddedWalletConnection} into the kit {@link TransactionSigner} the SDK\n * client consumes. As with the Wallet Standard bridge, the result is a PARTIAL\n * signer — the vendor signs, the SDK client's transport broadcasts.\n *\n * @see {@link signerFromEmbeddedWallet}\n * @see {@link createMockEmbeddedWallet} — the local-keypair test adapter.\n * @module signers/embedded-wallet\n */\nimport { address, type SignatureBytes, type Transaction } from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type {\n EmbeddedWalletConnection,\n TransactionSigner,\n} from \"./types.js\";\n\n/**\n * Bridge a CONNECTED embedded-wallet connection into a kit\n * {@link TransactionSigner}.\n *\n * Call this AFTER `provider.connect()` resolves — it needs the live\n * {@link EmbeddedWalletConnection} (address + `signTransactions`). The hooks\n * layer (`useWalletSigner`) is expected to own the connect lifecycle and call\n * this once a connection exists.\n *\n * @param connection - A live embedded-wallet connection.\n * @returns A kit {@link TransactionSigner} usable as `config.signer`.\n *\n * @example\n * ```ts\n * const connection = await provider.connect(); // vendor login\n * const signer = signerFromEmbeddedWallet(connection);\n * // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.\n * ```\n */\nexport function signerFromEmbeddedWallet(\n connection: EmbeddedWalletConnection,\n): TransactionSigner {\n const signerAddress = address(connection.address);\n\n return {\n address: signerAddress,\n async signTransactions(transactions: readonly Transaction[]) {\n const signatures: readonly SignatureBytes[] =\n await connection.signTransactions(transactions);\n if (signatures.length !== transactions.length) {\n throw new Error(\n ts(\"signer.embeddedSignatureCount\", {\n expected: transactions.length,\n got: signatures.length,\n }),\n );\n }\n return transactions.map((_, i) => ({\n [signerAddress]: signatures[i] as SignatureBytes,\n }));\n },\n } satisfies TransactionSigner;\n}\n"]}
1
+ {"version":3,"sources":["../../src/strings/index.ts","../../src/signers/strings.ts","../../src/signers/wallet-account.ts","../../src/signers/wallet-adapter.ts","../../src/signers/embedded-wallet.ts"],"names":["address","getTransactionEncoder","getTransactionDecoder"],"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,iEAA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,IACF;AAAA,GACF;AACF;AC5GO,SAAS,yBACd,UAAA,EACmB;AACnB,EAAA,MAAM,aAAA,GAAgBF,WAAAA,CAAQ,UAAA,CAAW,OAAO,CAAA;AAEhD,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,aAAA;AAAA,IACT,MAAM,iBAAiB,YAAA,EAAsC;AAC3D,MAAA,MAAM,UAAA,GACJ,MAAM,UAAA,CAAW,gBAAA,CAAiB,YAAY,CAAA;AAChD,MAAA,IAAI,UAAA,CAAW,MAAA,KAAW,YAAA,CAAa,MAAA,EAAQ;AAC7C,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,GAAG,+BAAA,EAAiC;AAAA,YAClC,UAAU,YAAA,CAAa,MAAA;AAAA,YACvB,KAAK,UAAA,CAAW;AAAA,WACjB;AAAA,SACH;AAAA,MACF;AACA,MAAA,OAAO,YAAA,CAAa,GAAA,CAAI,CAAC,CAAA,EAAG,CAAA,MAAO;AAAA,QACjC,CAAC,aAAa,GAAG,UAAA,CAAW,CAAC;AAAA,OAC/B,CAAE,CAAA;AAAA,IACJ;AAAA,GACF;AACF","file":"index.cjs","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 no earnings endpoint is available on this network (configure indexer.baseUrl).\",\n \"referrer.earningsFetchFailed\":\n \"The referrer earnings endpoint could not be read.\",\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","/**\n * Signer-adapter string catalog (the `signer.*` namespace).\n *\n * Kept local to `src/signers/**` so the adapters route every user-facing string\n * through the package's {@link t} resolver (the PLAN_2 Part A locale contract)\n * WITHOUT cross-editing the shared `src/strings` catalog owned by another\n * surface. A future locale can extend `EN_SIGNER_STRINGS` the same way.\n *\n * @module signers/strings\n */\nimport { t, type StringCatalog } from \"../strings/index.js\";\n\n/** English `signer.*` strings used by the wallet/embedded adapters. */\nexport const EN_SIGNER_STRINGS = {\n \"signer.walletNoSignFeature\":\n \"Wallet account {address} does not expose a solana:signTransaction feature. Pass options.signTransaction explicitly, or use a Wallet Standard account that supports transaction signing.\",\n \"signer.walletNoSignature\":\n \"The wallet returned no signature for account {address}. The wallet may have rejected or modified the transaction so the fee-payer signature is absent.\",\n \"signer.embeddedSignatureCount\":\n \"Embedded wallet returned {got} signatures for {expected} transactions; expected one per transaction.\",\n \"signer.walletAdapterDisconnected\":\n \"The wallet adapter is not connected (publicKey is null). Connect the wallet before creating a signer.\",\n \"signer.walletAdapterNoSign\":\n \"The wallet adapter does not expose signTransaction. Use a wallet that supports transaction signing, or migrate to the Wallet Standard path (signerFromWalletAccount).\",\n} as const satisfies StringCatalog;\n\n/** A `signer.*` message id. */\nexport type SignerStringId = keyof typeof EN_SIGNER_STRINGS;\n\n/**\n * `t()` bound to the signer catalog: resolves `signer.*` ids while preserving\n * the shared resolver's interpolation + verbatim-fallback behavior.\n */\nexport function ts(\n id: SignerStringId,\n vars?: Record<string, string | number | bigint>,\n): string {\n return t(id, vars, { catalog: EN_SIGNER_STRINGS });\n}\n","/**\n * Wallet Standard → kit `TransactionSigner` bridge (PLAN.md P4.1 / PLAN_2 D-1).\n *\n * Turns a connected browser wallet into the {@link TransactionSigner} the SDK's\n * `createMarketplaceClient` consumes. The SDK client signs via\n * `signTransactionMessageWithSigners(...)` and submits through its OWN transport\n * — so it needs a PARTIAL signer (one that returns signatures without sending),\n * NOT a `TransactionSendingSigner` (which `signTransactionMessageWithSigners`\n * deliberately ignores). This bridge therefore produces a\n * {@link TransactionPartialSigner}: it serializes each transaction, hands it to\n * the wallet's `solana:signTransaction` feature, and diffs the returned signed\n * transaction to recover THIS account's signature.\n *\n * @see {@link signerFromWalletAccount}\n * @module signers/wallet-account\n */\nimport {\n address,\n getTransactionDecoder,\n getTransactionEncoder,\n type Address,\n type SignatureBytes,\n type Transaction,\n} from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type {\n SignerFromWalletAccountOptions,\n TransactionSigner,\n WalletStandardAccountLike,\n WalletStandardSignTransaction,\n} from \"./types.js\";\n\nconst SOLANA_SIGN_TRANSACTION = \"solana:signTransaction\";\n\n/** Resolve the wallet's `solana:signTransaction` method from account/options. */\nfunction resolveSignTransaction(\n account: WalletStandardAccountLike,\n options: SignerFromWalletAccountOptions,\n): WalletStandardSignTransaction {\n if (options.signTransaction) return options.signTransaction;\n const feature = account.features?.[SOLANA_SIGN_TRANSACTION] as\n | { signTransaction?: WalletStandardSignTransaction }\n | undefined;\n if (feature?.signTransaction) return feature.signTransaction;\n throw new Error(ts(\"signer.walletNoSignFeature\", { address: account.address }));\n}\n\n/** Pick the CAIP-2 chain to forward to the wallet. */\nfunction resolveChain(\n account: WalletStandardAccountLike,\n options: SignerFromWalletAccountOptions,\n): string | undefined {\n if (options.chain) return options.chain;\n return account.chains?.find((c) => c.startsWith(\"solana:\"));\n}\n\n/**\n * Bridge a Wallet Standard account into a kit {@link TransactionSigner}.\n *\n * Accepts either a real `UiWalletAccount` (the `@solana/react` path — pass the\n * account and a `chain`, or pass the hook's feature via\n * {@link SignerFromWalletAccountOptions.signTransaction}) or any object exposing\n * the `solana:signTransaction` feature. The returned signer is a\n * {@link TransactionPartialSigner}, the exact shape the SDK client expects.\n *\n * Wallets may MODIFY a transaction before signing (priority fees, guard\n * instructions). We honor that by decoding the wallet's returned signed\n * transaction and extracting only THIS account's signature; the SDK client then\n * re-assembles and submits. (If a wallet rewrites the message such that the\n * fee-payer's own prior signing is invalidated, that is a wallet contract the\n * SDK's single-fee-payer flow already assumes won't happen for the payer.)\n *\n * SSR-safe: constructs no browser globals; the wallet round-trip only runs when\n * a transaction is actually signed.\n *\n * @param account - The connected Wallet Standard account (needs `address`).\n * @param options - Chain + an optional explicit `signTransaction` override.\n * @returns A kit {@link TransactionSigner} usable as `config.signer`.\n * @throws Error if no `solana:signTransaction` feature can be resolved.\n *\n * @example\n * ```ts\n * // With @solana/react (Wallet Standard):\n * const account = useSelectedWalletAccount(); // UiWalletAccount\n * const signer = signerFromWalletAccount(account, { chain: \"solana:devnet\" });\n * // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.\n * ```\n */\nexport function signerFromWalletAccount(\n account: WalletStandardAccountLike,\n options: SignerFromWalletAccountOptions = {},\n): TransactionSigner {\n const signerAddress: Address = address(account.address);\n const signTransaction = resolveSignTransaction(account, options);\n const chain = resolveChain(account, options);\n const encoder = getTransactionEncoder();\n const decoder = getTransactionDecoder();\n\n async function signOne(transaction: Transaction): Promise<SignatureBytes> {\n const wireBytes = new Uint8Array(encoder.encode(transaction));\n const [output] = await signTransaction({\n transaction: wireBytes,\n ...(chain ? { chain } : {}),\n });\n if (!output) {\n throw new Error(ts(\"signer.walletNoSignature\", { address: account.address }));\n }\n const signed = decoder.decode(output.signedTransaction);\n const signature = signed.signatures[signerAddress];\n if (!signature) {\n throw new Error(ts(\"signer.walletNoSignature\", { address: account.address }));\n }\n return signature as SignatureBytes;\n }\n\n return {\n address: signerAddress,\n async signTransactions(transactions) {\n // Sign in parallel — partial signers are order-independent (each returns a\n // single-entry SignatureDictionary the caller merges).\n return Promise.all(\n transactions.map(async (transaction) => ({\n [signerAddress]: await signOne(transaction),\n })),\n );\n },\n } satisfies TransactionSigner;\n}\n","/**\n * LEGACY `@solana/wallet-adapter` compatibility shim (PLAN.md P4.1).\n *\n * The supported, robust path for browser wallets is the Wallet Standard bridge\n * ({@link signerFromWalletAccount} via `@solana/react`): every modern wallet —\n * including all wallet-adapter wallets — registers as a Wallet Standard wallet,\n * so a wallet-adapter app can migrate by reading the selected account through\n * `@solana/react` and dropping it into `signerFromWalletAccount`. PREFER THAT.\n *\n * This shim exists for apps still holding a raw wallet-adapter\n * `WalletContextState` (web3.js v1 `signTransaction`). It bridges WITHOUT a hard\n * dependency on `@solana/wallet-adapter-*` OR `@solana/web3.js` (1.x): the\n * caller injects the web3.js `VersionedTransaction` class (the only piece we\n * cannot reconstruct), and we round-trip through the shared wire format — a kit\n * {@link Transaction} and a web3.js `VersionedTransaction` serialize to the SAME\n * bytes, so no semantic re-encoding is needed.\n *\n * SSR-safe: no browser globals at module scope.\n *\n * @module signers/wallet-adapter\n */\nimport {\n address,\n getTransactionDecoder,\n getTransactionEncoder,\n type SignatureBytes,\n type Transaction,\n} from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type { TransactionSigner } from \"./types.js\";\n\n/**\n * The web3.js v1 `VersionedTransaction` surface this shim needs: a static\n * `deserialize(bytes)` and an instance `serialize()`. Pass the real class from\n * `@solana/web3.js` — typed structurally so this module never imports it.\n */\nexport interface VersionedTransactionLike {\n serialize(): Uint8Array;\n}\n\n/** The static side of the injected `VersionedTransaction` class. */\nexport interface VersionedTransactionCtor {\n deserialize(bytes: Uint8Array): VersionedTransactionLike;\n}\n\n/**\n * The minimal slice of a wallet-adapter `WalletContextState` this shim consumes.\n * Both `publicKey` (anything with a base58 `toString()`/`toBase58()`) and the\n * v1 `signTransaction` are required; a connected adapter exposes both.\n */\nexport interface WalletAdapterLike {\n /** The connected account's public key (base58 via `toBase58()`/`toString()`). */\n readonly publicKey:\n | { toBase58(): string }\n | { toString(): string }\n | string\n | null;\n /** web3.js v1 sign — returns the same transaction type, signed. */\n signTransaction?: <T extends VersionedTransactionLike>(\n transaction: T,\n ) => Promise<T>;\n}\n\n/** Options for {@link signerFromWalletAdapter}. */\nexport interface SignerFromWalletAdapterOptions {\n /**\n * The web3.js `VersionedTransaction` class (`import { VersionedTransaction }\n * from \"@solana/web3.js\"`). Required — it is the one piece this no-dep shim\n * cannot supply itself.\n */\n VersionedTransaction: VersionedTransactionCtor;\n}\n\nfunction resolveAdapterAddress(adapter: WalletAdapterLike): string {\n const { publicKey } = adapter;\n if (publicKey == null) {\n throw new Error(ts(\"signer.walletAdapterDisconnected\"));\n }\n if (typeof publicKey === \"string\") return publicKey;\n if (\"toBase58\" in publicKey && typeof publicKey.toBase58 === \"function\") {\n return publicKey.toBase58();\n }\n return String(publicKey);\n}\n\n/**\n * Bridge a LEGACY `@solana/wallet-adapter` `WalletContextState` into a kit\n * {@link TransactionSigner}.\n *\n * Use only when you cannot reach the wallet through `@solana/react`. The result\n * is a {@link TransactionPartialSigner} (the SDK client owns submission), built\n * by serializing the kit transaction to wire bytes, rehydrating it as a web3.js\n * `VersionedTransaction`, handing THAT to the adapter's `signTransaction`, then\n * decoding the signed wire bytes back to a kit transaction to extract this\n * account's signature.\n *\n * @param adapter - A connected wallet-adapter state (`publicKey` + `signTransaction`).\n * @param options - Must inject the web3.js `VersionedTransaction` class.\n * @returns A kit {@link TransactionSigner} usable as `config.signer`.\n * @throws Error if the adapter is disconnected or lacks `signTransaction`.\n *\n * @example\n * ```ts\n * import { VersionedTransaction } from \"@solana/web3.js\";\n * import { useWallet } from \"@solana/wallet-adapter-react\";\n *\n * const wallet = useWallet();\n * const signer = signerFromWalletAdapter(wallet, { VersionedTransaction });\n * // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.\n * ```\n */\nexport function signerFromWalletAdapter(\n adapter: WalletAdapterLike,\n options: SignerFromWalletAdapterOptions,\n): TransactionSigner {\n const signerAddress = address(resolveAdapterAddress(adapter));\n const { signTransaction } = adapter;\n if (typeof signTransaction !== \"function\") {\n throw new Error(ts(\"signer.walletAdapterNoSign\"));\n }\n const { VersionedTransaction } = options;\n const encoder = getTransactionEncoder();\n const decoder = getTransactionDecoder();\n\n async function signOne(transaction: Transaction): Promise<SignatureBytes> {\n const wireBytes = new Uint8Array(encoder.encode(transaction));\n const legacyTx = VersionedTransaction.deserialize(wireBytes);\n const signed = await signTransaction!(legacyTx);\n const signedTx = decoder.decode(new Uint8Array(signed.serialize()));\n const signature = signedTx.signatures[signerAddress];\n if (!signature) {\n throw new Error(\n ts(\"signer.walletNoSignature\", { address: signerAddress }),\n );\n }\n return signature as SignatureBytes;\n }\n\n return {\n address: signerAddress,\n async signTransactions(transactions) {\n return Promise.all(\n transactions.map(async (transaction) => ({\n [signerAddress]: await signOne(transaction),\n })),\n );\n },\n } satisfies TransactionSigner;\n}\n","/**\n * Embedded / walletless → kit `TransactionSigner` bridge (PLAN_2 D-1).\n *\n * The \"no wallet, no SOL\" buyer path. A vendor-neutral\n * {@link EmbeddedWalletProvider} (Privy / Dynamic / Web3Auth — `[HUMAN]`-gated)\n * handles email/social login + key custody; this module lifts a live\n * {@link EmbeddedWalletConnection} into the kit {@link TransactionSigner} the SDK\n * client consumes. As with the Wallet Standard bridge, the result is a PARTIAL\n * signer — the vendor signs, the SDK client's transport broadcasts.\n *\n * @see {@link signerFromEmbeddedWallet}\n * @see {@link createMockEmbeddedWallet} — the local-keypair test adapter.\n * @module signers/embedded-wallet\n */\nimport { address, type SignatureBytes, type Transaction } from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type {\n EmbeddedWalletConnection,\n TransactionSigner,\n} from \"./types.js\";\n\n/**\n * Bridge a CONNECTED embedded-wallet connection into a kit\n * {@link TransactionSigner}.\n *\n * Call this AFTER `provider.connect()` resolves — it needs the live\n * {@link EmbeddedWalletConnection} (address + `signTransactions`). The hooks\n * layer (`useWalletSigner`) is expected to own the connect lifecycle and call\n * this once a connection exists.\n *\n * @param connection - A live embedded-wallet connection.\n * @returns A kit {@link TransactionSigner} usable as `config.signer`.\n *\n * @example\n * ```ts\n * const connection = await provider.connect(); // vendor login\n * const signer = signerFromEmbeddedWallet(connection);\n * // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.\n * ```\n */\nexport function signerFromEmbeddedWallet(\n connection: EmbeddedWalletConnection,\n): TransactionSigner {\n const signerAddress = address(connection.address);\n\n return {\n address: signerAddress,\n async signTransactions(transactions: readonly Transaction[]) {\n const signatures: readonly SignatureBytes[] =\n await connection.signTransactions(transactions);\n if (signatures.length !== transactions.length) {\n throw new Error(\n ts(\"signer.embeddedSignatureCount\", {\n expected: transactions.length,\n got: signatures.length,\n }),\n );\n }\n return transactions.map((_, i) => ({\n [signerAddress]: signatures[i] as SignatureBytes,\n }));\n },\n } satisfies TransactionSigner;\n}\n"]}
@@ -1,4 +1,4 @@
1
- export { EN_SIGNER_STRINGS, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from '../chunk-MNJ2EQDJ.js';
2
- import '../chunk-ECU7HGO3.js';
1
+ export { EN_SIGNER_STRINGS, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from '../chunk-ON6XR4XO.js';
2
+ import '../chunk-H6PJIDQR.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tetsuo-ai/marketplace-react",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
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",
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Resolve the OPTIONAL `moderation_attestor` roster account for task
3
+ * activation (WP-A1).
4
+ *
5
+ * Post-A1 the on-chain publish gate (`set_task_job_spec`) accepts a task
6
+ * moderation authored by a registered roster `ModerationAttestor` — but ONLY
7
+ * when the transaction attaches that attestor's roster-entry PDA. Without it
8
+ * the gate falls back to requiring `task_moderation.moderator ==
9
+ * moderation_config.moderation_authority`, so a roster-attested task (the
10
+ * default when the activation backend uses the public attestation service)
11
+ * fails with `UNAUTHORIZED_TASK_MODERATOR` even though the attestation is
12
+ * valid.
13
+ *
14
+ * This helper reads the recorded `TaskModeration`, compares its stored
15
+ * moderator against the global moderation authority, and returns the roster
16
+ * PDA exactly when they differ. Any resolution failure returns `undefined`,
17
+ * degrading to the pre-resolution behavior — the program stays the
18
+ * enforcement point; a read hiccup must never make activation MORE broken
19
+ * than not resolving at all.
20
+ *
21
+ * @module hooks/moderation-attestor
22
+ */
23
+ import { createSolanaRpc } from "@solana/kit";
24
+ import {
25
+ fetchMaybeModerationConfig,
26
+ fetchMaybeTaskModeration,
27
+ findModerationAttestorPda,
28
+ findModerationConfigPda,
29
+ findTaskModerationPda,
30
+ } from "@tetsuo-ai/marketplace-sdk";
31
+ import type { Address } from "../types.js";
32
+
33
+ /** The account-read slice of a kit RPC that the resolver needs. */
34
+ type AccountReadRpc = Parameters<typeof fetchMaybeTaskModeration>[0];
35
+
36
+ /** The job-spec hash exactly as the TaskModeration PDA seeds accept it. */
37
+ type JobSpecHashSeed = Parameters<typeof findTaskModerationPda>[0]["jobSpecHash"];
38
+
39
+ /**
40
+ * Resolve the roster-attestor account to attach to `set_task_job_spec`, or
41
+ * `undefined` when none is needed (global-authority moderation, missing
42
+ * moderation record, or no read endpoint).
43
+ *
44
+ * @param input.rpcUrl - Resolved HTTP RPC endpoint (from provider context).
45
+ * @param input.task - The task PDA being activated.
46
+ * @param input.jobSpecHash - The 32-byte canonical job-spec hash (seeds the
47
+ * `TaskModeration` PDA together with `task`).
48
+ * @param input.rpc - Test seam: a pre-built account-read RPC wins over
49
+ * `rpcUrl`.
50
+ */
51
+ export async function resolveActivationModerationAttestor(input: {
52
+ rpcUrl: string | null;
53
+ task: Address;
54
+ jobSpecHash: JobSpecHashSeed;
55
+ rpc?: AccountReadRpc;
56
+ }): Promise<Address | undefined> {
57
+ try {
58
+ const rpc =
59
+ input.rpc ??
60
+ (input.rpcUrl
61
+ ? (createSolanaRpc(input.rpcUrl) as unknown as AccountReadRpc)
62
+ : null);
63
+ if (!rpc) return undefined;
64
+
65
+ const [taskModerationPda] = await findTaskModerationPda({
66
+ task: input.task,
67
+ jobSpecHash: input.jobSpecHash,
68
+ });
69
+ const taskModeration = await fetchMaybeTaskModeration(
70
+ rpc,
71
+ taskModerationPda,
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;
87
+ }
88
+
89
+ const [rosterPda] = await findModerationAttestorPda({
90
+ attestor: taskModeration.data.moderator,
91
+ });
92
+ return rosterPda;
93
+ } catch {
94
+ // Degrade to "no account attached" — never block activation on a read
95
+ // failure; the on-chain gate remains the enforcement point.
96
+ return undefined;
97
+ }
98
+ }
@@ -12,6 +12,7 @@ import {
12
12
  withoutReferrerArgs,
13
13
  type MutationStatus,
14
14
  } from "./internal.js";
15
+ import { resolveActivationModerationAttestor } from "./moderation-attestor.js";
15
16
  import type { HumanlessHireInput } from "./useHire.js";
16
17
  import type { TaskActivationInput } from "./useTaskActivation.js";
17
18
 
@@ -194,8 +195,19 @@ export function useHumanlessHireFlow<TJobSpec = unknown>(): UseHumanlessHireFlow
194
195
  }));
195
196
 
196
197
  setPhase("activating");
198
+ // WP-A1: attach the roster-attestor account when the moderation was
199
+ // authored by a roster attestor (e.g. the public attestation
200
+ // service) — without it the publish gate rejects the activation.
201
+ const moderationAttestor =
202
+ input.activation?.moderationAttestor ??
203
+ (await resolveActivationModerationAttestor({
204
+ rpcUrl: ctx.rpcUrl,
205
+ task: taskPda,
206
+ jobSpecHash,
207
+ }));
197
208
  const activationResult = await client.setTaskJobSpec({
198
209
  ...(input.activation ?? {}),
210
+ ...(moderationAttestor !== undefined ? { moderationAttestor } : {}),
199
211
  task: taskPda,
200
212
  creator,
201
213
  jobSpecHash,
@@ -1,32 +1,40 @@
1
1
  /**
2
- * `useReferrerEarnings(wallet)` — referrer earnings (indexer-gated).
2
+ * `useReferrerEarnings(wallet)` — aggregated referrer earnings (P3.8).
3
3
  *
4
- * ## EARNINGS INDEXER GATE
4
+ * ## Data source
5
5
  *
6
- * Referrer settlement is live in the protocol. Aggregated referrer earnings still
7
- * depend on the off-chain `GET /api/explorer/referrers/:wallet/hires` indexer
8
- * endpoint that sums paid referral events.
9
- *
10
- * That endpoint is not published yet. So this hook:
11
- * - resolves `resolveReferrerCapability()` from context;
12
- * - when the earnings indexer is not live: returns the documented not-live
13
- * state `{ live: false, totalLamports: 0n, hires: [] }` and makes NO network
14
- * request. It NEVER fabricates earnings and NEVER infers a non-zero total
15
- * from anything.
16
- * - the real fetch path is written but gated behind `EARNINGS_INDEXER_LIVE`, so
17
- * when the endpoint lands, only the gate flips — the surface does not change.
6
+ * `GET <earningsBase>/api/explorer/referrers/:wallet/hires` — the hosted
7
+ * explorer endpoint that sums the referrer leg over SETTLED hires with the
8
+ * program's own split math (shipped 2026-07-03; ground-truthed against the
9
+ * cross-node canary's on-chain legs). `earningsBase` resolves from
10
+ * `config.indexer.baseUrl` when set, else the per-network hosted default
11
+ * (mainnet only). When no base resolves (localnet/devnet without an indexer),
12
+ * the hook returns the documented not-live zero state and makes NO network
13
+ * request — it NEVER fabricates earnings; a fetch failure surfaces as
14
+ * `error` with zero totals, never invented numbers.
18
15
  *
19
16
  * @module hooks/useReferrerEarnings
20
17
  */
21
18
  import { useQuery } from "@tanstack/react-query";
22
19
  import { useAgencContext } from "../provider/context.js";
23
20
  import { t } from "../strings/index.js";
24
- import type { Address } from "../types.js";
21
+ import type { Address, AgencContextValue, AgencNetwork } from "../types.js";
25
22
  import { pdaKey, queryKeys } from "./internal.js";
26
23
 
27
- const EARNINGS_INDEXER_LIVE = false;
24
+ /**
25
+ * Hosted explorer bases serving the earnings endpoints, per network. Only
26
+ * mainnet has one today; an explicit `config.indexer.baseUrl` always wins.
27
+ */
28
+ const EARNINGS_INDEXER_DEFAULTS: Partial<Record<AgencNetwork, string>> = {
29
+ mainnet: "https://api.agenc.ag",
30
+ };
28
31
 
29
- /** A single referral-earning hire (shape defined now; populated once the earnings indexer ships). */
32
+ /** Resolve the earnings endpoint base, or `null` (not live) when none. */
33
+ function resolveEarningsBaseUrl(ctx: AgencContextValue): string | null {
34
+ return ctx.indexerBaseUrl ?? EARNINGS_INDEXER_DEFAULTS[ctx.network] ?? null;
35
+ }
36
+
37
+ /** A single referral-earning hire. */
30
38
  export interface ReferrerHire {
31
39
  /** The minted Task PDA of the referred hire. */
32
40
  taskPda: string;
@@ -34,7 +42,7 @@ export interface ReferrerHire {
34
42
  hireRecordPda: string;
35
43
  /** Referral fee earned on this hire, in lamports. */
36
44
  feeLamports: bigint;
37
- /** Transaction signature of the hire. */
45
+ /** Transaction signature of the hire (empty until event indexing lands). */
38
46
  signature: string;
39
47
  }
40
48
 
@@ -50,7 +58,7 @@ export interface UseReferrerEarningsResult {
50
58
  totalLamports: bigint;
51
59
  /** Per-hire earnings. `[]` while not live. */
52
60
  hires: ReferrerHire[];
53
- /** True while a fetch is in flight. Always false until the earnings indexer ships. */
61
+ /** True while a fetch is in flight. */
54
62
  isLoading: boolean;
55
63
  /** The fetch error, or null. */
56
64
  error: Error | null;
@@ -63,18 +71,27 @@ export interface UseReferrerEarningsResult {
63
71
  refetch: () => void;
64
72
  }
65
73
 
74
+ /** The endpoint's wire shape (lamports as decimal strings). */
75
+ interface EarningsWire {
76
+ totalLamports?: string;
77
+ hires?: Array<{
78
+ taskPda?: string;
79
+ hireRecordPda?: string;
80
+ feeLamports?: string;
81
+ signature?: string;
82
+ }>;
83
+ }
84
+
66
85
  /**
67
- * Read a referrer wallet's earnings.
86
+ * Read a referrer wallet's aggregated earnings from the hosted explorer.
68
87
  *
69
88
  * @param wallet - The referrer wallet (base58 / Address). Falsy disables the
70
- * (future) fetch; the not-live state is still returned.
71
- * @returns {@link UseReferrerEarningsResult} — the not-live zero state until
72
- * the earnings indexer ships.
89
+ * fetch; the not-live state is still returned.
90
+ * @returns {@link UseReferrerEarningsResult}
73
91
  *
74
92
  * @example
75
93
  * ```tsx
76
94
  * const { live, totalLamports, hires, reason } = useReferrerEarnings(myWallet);
77
- * // until the earnings indexer ships: live === false, totalLamports === 0n, hires === []
78
95
  * ```
79
96
  */
80
97
  export function useReferrerEarnings(
@@ -82,30 +99,49 @@ export function useReferrerEarnings(
82
99
  ): UseReferrerEarningsResult {
83
100
  const ctx = useAgencContext();
84
101
  const capability = ctx.resolveReferrerCapability();
102
+ const earningsBase = resolveEarningsBaseUrl(ctx);
85
103
 
86
- // THE GATE: settlement can be live while the aggregate earnings indexer is not.
87
- // Keep this false until the endpoint is published.
88
- const enabled = capability.live && EARNINGS_INDEXER_LIVE && Boolean(wallet);
104
+ // Live only when settlement capability holds AND an earnings endpoint base
105
+ // resolves. No base (localnet/devnet without an indexer) = the documented
106
+ // not-live zero state, zero network requests.
107
+ const enabled = capability.live && earningsBase !== null && Boolean(wallet);
89
108
 
90
109
  const query = useQuery<{ totalLamports: bigint; hires: ReferrerHire[] }, Error>(
91
110
  {
92
111
  queryKey: queryKeys.referrerEarnings(wallet ? pdaKey(wallet) : ""),
93
112
  enabled,
94
113
  queryFn: async () => {
95
- // TODO(indexer): once `GET /api/explorer/referrers/:wallet/hires` is
96
- // published, fetch + sum here. Returning fabricated numbers here would
97
- // violate the money-surface contract.
98
- throw new Error(
99
- "useReferrerEarnings: the referrer earnings indexer is not deployed; " +
100
- "this query must never run while EARNINGS_INDEXER_LIVE is false.",
101
- );
114
+ const url = `${earningsBase}/api/explorer/referrers/${encodeURIComponent(
115
+ String(wallet),
116
+ )}/hires`;
117
+ const response = await fetch(url, {
118
+ headers: { accept: "application/json" },
119
+ });
120
+ if (!response.ok) {
121
+ throw new Error(
122
+ t("referrer.earningsFetchFailed") + ` (HTTP ${response.status})`,
123
+ );
124
+ }
125
+ const body = (await response.json()) as EarningsWire;
126
+ // Lamports arrive as decimal strings; parse to bigint. Anything
127
+ // malformed throws (surfaces as `error`) — never silently coerced.
128
+ const hires: ReferrerHire[] = (body.hires ?? []).map((h) => ({
129
+ taskPda: String(h.taskPda ?? ""),
130
+ hireRecordPda: String(h.hireRecordPda ?? ""),
131
+ feeLamports: BigInt(h.feeLamports ?? "0"),
132
+ signature: String(h.signature ?? ""),
133
+ }));
134
+ return {
135
+ totalLamports: BigInt(body.totalLamports ?? "0"),
136
+ hires,
137
+ };
102
138
  },
103
139
  },
104
140
  );
105
141
 
106
- if (!capability.live || !EARNINGS_INDEXER_LIVE) {
107
- // The documented not-live state. Zeroes are HONEST (no data exists), not
108
- // fabricated, and no request was made.
142
+ if (!enabled) {
143
+ // The documented not-live state. Zeroes are HONEST (no data was read),
144
+ // not fabricated, and no request was made.
109
145
  return {
110
146
  live: false,
111
147
  totalLamports: 0n,
@@ -121,7 +157,6 @@ export function useReferrerEarnings(
121
157
  };
122
158
  }
123
159
 
124
- // --- Post-indexer path (currently unreachable; kept wired for the flip) ---
125
160
  return {
126
161
  live: true,
127
162
  totalLamports: query.data?.totalLamports ?? 0n,