@tetsuo-ai/marketplace-react 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/hooks/index.cjs +44 -1
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.js +45 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-CTTh1ZPg.d.cts → index-CrEAPlme.d.cts} +7 -0
- package/dist/{index-C9R3B80j.d.ts → index-DGq7M4mo.d.ts} +7 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/hooks/moderation-attestor.ts +98 -0
- package/src/hooks/useHumanlessHireFlow.ts +12 -0
- package/src/hooks/useTaskActivation.ts +13 -0
- package/src/provider/AgencProvider.tsx +11 -0
- package/src/types.ts +7 -0
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-
|
|
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-
|
|
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-CrEAPlme.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-CrEAPlme.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-
|
|
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-
|
|
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-DGq7M4mo.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-DGq7M4mo.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
|
@@ -115,10 +115,16 @@ 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,
|
|
122
128
|
signer: config.signer ?? null,
|
|
123
129
|
referrer,
|
|
124
130
|
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,IAA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A,EAAQ,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,qBAA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,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 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tetsuo-ai/marketplace-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"@solana/kit": "^6.9.0",
|
|
89
89
|
"@solana/program-client-core": "^6.4.0",
|
|
90
|
-
"@tetsuo-ai/marketplace-sdk": "^0.
|
|
90
|
+
"@tetsuo-ai/marketplace-sdk": "^0.7.0",
|
|
91
91
|
"react": ">=18"
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
@@ -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,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
requireClient,
|
|
8
8
|
type MutationStatus,
|
|
9
9
|
} from "./internal.js";
|
|
10
|
+
import { resolveActivationModerationAttestor } from "./moderation-attestor.js";
|
|
10
11
|
|
|
11
12
|
export type TaskActivationInput = Omit<
|
|
12
13
|
Parameters<typeof facadeNs.setTaskJobSpec>[0],
|
|
@@ -33,8 +34,20 @@ export function useTaskActivation(
|
|
|
33
34
|
const mutation = useMutation<string, Error, TaskActivationInput>({
|
|
34
35
|
mutationFn: async (input) => {
|
|
35
36
|
const client = requireClient(ctx.client);
|
|
37
|
+
// WP-A1: when the task moderation was authored by a roster attestor
|
|
38
|
+
// (not the global authority), the publish gate only unlocks if the
|
|
39
|
+
// attestor's roster-entry PDA is attached. Resolve it automatically
|
|
40
|
+
// unless the caller supplied one.
|
|
41
|
+
const moderationAttestor =
|
|
42
|
+
input.moderationAttestor ??
|
|
43
|
+
(await resolveActivationModerationAttestor({
|
|
44
|
+
rpcUrl: ctx.rpcUrl,
|
|
45
|
+
task: taskPda,
|
|
46
|
+
jobSpecHash: input.jobSpecHash,
|
|
47
|
+
}));
|
|
36
48
|
const { signature } = await client.setTaskJobSpec({
|
|
37
49
|
...input,
|
|
50
|
+
...(moderationAttestor !== undefined ? { moderationAttestor } : {}),
|
|
38
51
|
task: taskPda,
|
|
39
52
|
creator: input.creator ?? client.signer,
|
|
40
53
|
} as Parameters<typeof facadeNs.setTaskJobSpec>[0]);
|
|
@@ -149,10 +149,21 @@ export function AgencProvider(props: AgencProviderProps): ReactNode {
|
|
|
149
149
|
const read = buildReadTransport(config);
|
|
150
150
|
const client = buildWriteClient(config, network);
|
|
151
151
|
|
|
152
|
+
// The resolved HTTP RPC endpoint, exposed so hooks can make single-account
|
|
153
|
+
// reads (e.g. resolving the WP-A1 roster-attestor account at activation)
|
|
154
|
+
// without an indexer. Not a gPA source — the read transport owns list
|
|
155
|
+
// queries.
|
|
156
|
+
const { rpcUrl } = resolveEndpoints(
|
|
157
|
+
network,
|
|
158
|
+
config.rpcUrl,
|
|
159
|
+
config.rpcSubscriptionsUrl,
|
|
160
|
+
);
|
|
161
|
+
|
|
152
162
|
return {
|
|
153
163
|
network,
|
|
154
164
|
read,
|
|
155
165
|
client,
|
|
166
|
+
rpcUrl: rpcUrl ?? null,
|
|
156
167
|
signer: config.signer ?? null,
|
|
157
168
|
referrer,
|
|
158
169
|
resolveReferrerCapability: () => resolveReferrerCapabilityImpl(referrer),
|
package/src/types.ts
CHANGED
|
@@ -198,6 +198,13 @@ export interface AgencContextValue {
|
|
|
198
198
|
* was supplied. Mutating hooks surface a clear error in that case.
|
|
199
199
|
*/
|
|
200
200
|
client: MarketplaceClient | null;
|
|
201
|
+
/**
|
|
202
|
+
* The resolved HTTP RPC endpoint (config override or the network default),
|
|
203
|
+
* or `null` when none resolves. Hooks use it for single-account reads —
|
|
204
|
+
* e.g. resolving the WP-A1 `moderation_attestor` roster account during
|
|
205
|
+
* activation. NOT a gPA/list-query source; the read transport owns those.
|
|
206
|
+
*/
|
|
207
|
+
rpcUrl: string | null;
|
|
201
208
|
/** The configured signer, or `null`. */
|
|
202
209
|
signer: TransactionSigner | null;
|
|
203
210
|
/** Validated referrer config, or `null` when none was supplied. */
|