@tetsuo-ai/marketplace-react 0.3.1 → 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.
- package/CHANGELOG.md +13 -0
- package/dist/{chunk-FAIRTAIB.js → chunk-2Y6JN2VZ.js} +3 -3
- package/dist/{chunk-FAIRTAIB.js.map → chunk-2Y6JN2VZ.js.map} +1 -1
- package/dist/{chunk-D2TDU3TJ.js → chunk-AKPPKMQ2.js} +3 -3
- package/dist/{chunk-D2TDU3TJ.js.map → chunk-AKPPKMQ2.js.map} +1 -1
- package/dist/{chunk-ECU7HGO3.js → chunk-H6PJIDQR.js} +4 -3
- package/dist/chunk-H6PJIDQR.js.map +1 -0
- package/dist/{chunk-MNJ2EQDJ.js → chunk-ON6XR4XO.js} +3 -3
- package/dist/{chunk-MNJ2EQDJ.js.map → chunk-ON6XR4XO.js.map} +1 -1
- package/dist/{chunk-WJUVTFJ7.js → chunk-ZAMIL27X.js} +4 -4
- package/dist/{chunk-WJUVTFJ7.js.map → chunk-ZAMIL27X.js.map} +1 -1
- package/dist/components/index.cjs +2 -1
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +3 -3
- package/dist/hooks/index.cjs +42 -8
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +6 -8
- package/dist/hooks/index.d.ts +6 -8
- package/dist/hooks/index.js +44 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-DGq7M4mo.d.ts → index-DQ3Xovkq.d.ts} +8 -1
- package/dist/{index-CrEAPlme.d.cts → index-UxuvIlmD.d.cts} +8 -1
- package/dist/index.cjs +3 -1
- 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 +9 -8
- package/dist/index.js.map +1 -1
- package/dist/signers/index.cjs +2 -1
- package/dist/signers/index.cjs.map +1 -1
- package/dist/signers/index.js +2 -2
- package/package.json +1 -1
- package/src/hooks/useReferrerEarnings.ts +73 -38
- package/src/provider/AgencProvider.tsx +1 -0
- package/src/strings/index.ts +3 -1
- package/src/types.ts +6 -0
- package/dist/chunk-ECU7HGO3.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @tetsuo-ai/marketplace-react
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `useReferrerEarnings` is LIVE: it now fetches the deployed P3.8 explorer
|
|
8
|
+
endpoint (`GET /api/explorer/referrers/:wallet/hires`) instead of returning
|
|
9
|
+
the gated zero state. The endpoint base resolves from
|
|
10
|
+
`config.indexer.baseUrl`, else the hosted per-network default (mainnet:
|
|
11
|
+
`https://api.agenc.ag`); when no base resolves the documented not-live zero
|
|
12
|
+
state is returned with no network request, and a failed fetch surfaces as
|
|
13
|
+
`error` with zero totals — earnings are never fabricated. The provider
|
|
14
|
+
context now also exposes `indexerBaseUrl`.
|
|
15
|
+
|
|
3
16
|
## 0.3.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t } from './chunk-
|
|
1
|
+
import { t } from './chunk-H6PJIDQR.js';
|
|
2
2
|
import { createContext, useContext, useCallback, useMemo } from 'react';
|
|
3
3
|
import { useMutation } from '@tanstack/react-query';
|
|
4
4
|
import { findTaskPda } from '@tetsuo-ai/marketplace-sdk';
|
|
@@ -139,5 +139,5 @@ function useWalletSigner(options) {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
export { AgencContext, QUERY_KEY_ROOT, mutationStatusOf, pdaKey, queryKeys, requireClient, resolveReferrerArgs, signerAddress, useAgencContext, useHire, useWalletSigner, withoutReferrerArgs };
|
|
142
|
-
//# sourceMappingURL=chunk-
|
|
143
|
-
//# sourceMappingURL=chunk-
|
|
142
|
+
//# sourceMappingURL=chunk-2Y6JN2VZ.js.map
|
|
143
|
+
//# sourceMappingURL=chunk-2Y6JN2VZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider/context.ts","../src/hooks/internal.ts","../src/hooks/useHire.ts","../src/hooks/useWalletSigner.ts"],"names":["useCallback"],"mappings":";;;;;AAkBO,IAAM,YAAA,GAAe,cAAwC,IAAI;AACxE,YAAA,CAAa,WAAA,GAAc,cAAA;AASpB,SAAS,eAAA,GAAqC;AACnD,EAAA,MAAM,GAAA,GAAM,WAAW,YAAY,CAAA;AACnC,EAAA,IAAI,QAAQ,IAAA,EAAM;AAChB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,CAAE,yBAAyB,CAAC,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,GAAA;AACT;;;ACZO,IAAM,cAAA,GAAiB;AAWvB,IAAM,SAAA,GAAY;AAAA;AAAA,EAEvB,UAAU,CAAC,MAAA,KACT,CAAC,cAAA,EAAgB,UAAA,EAAY,UAAU,IAAI,CAAA;AAAA;AAAA,EAE7C,SAAS,CAAC,GAAA,KAAgB,CAAC,cAAA,EAAgB,WAAW,GAAG,CAAA;AAAA;AAAA,EAEzD,kBAAkB,CAAC,QAAA,KACjB,CAAC,cAAA,EAAgB,oBAAoB,QAAQ,CAAA;AAAA;AAAA,EAE/C,YAAY,CAAC,OAAA,KACX,CAAC,cAAA,EAAgB,cAAc,OAAO,CAAA;AAAA;AAAA,EAExC,SAAS,CAAC,OAAA,KAAoB,CAAC,cAAA,EAAgB,WAAW,OAAO,CAAA;AAAA;AAAA,EAEjE,kBAAkB,CAAC,MAAA,KACjB,CAAC,cAAA,EAAgB,oBAAoB,MAAM;AAC/C;AAYO,SAAS,cACd,MAAA,EACmB;AACnB,EAAA,IAAI,WAAW,IAAA,EAAM;AACnB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,CAAE,6BAA6B,CAAC,CAAA;AAAA,EAClD;AACA,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AA,EAChD,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAA,OAAO,EAAE,MAAA,EAAQ,SAAA,EAAW,OAAA,EAAQ;AACtC","file":"chunk-FAIRTAIB.js","sourcesContent":["/**\n * The React context object + the internal `useAgencContext()` hook.\n *\n * Split from the component file so the context identity is stable and so hooks\n * can import the context without pulling the JSX provider into their module\n * graph. SSR-safe: this module only calls `createContext` at import time, never\n * touches `window`.\n *\n * @module provider/context\n */\nimport { createContext, useContext } from \"react\";\nimport { t } from \"../strings/index.js\";\nimport type { AgencContextValue } from \"../types.js\";\n\n/**\n * The AgenC context. `null` until a `<AgencProvider>` mounts above the consumer\n * — {@link useAgencContext} turns that into a clear developer error.\n */\nexport const AgencContext = createContext<AgencContextValue | null>(null);\nAgencContext.displayName = \"AgencContext\";\n\n/**\n * Read the AgenC context. INTERNAL hook the package's own hooks build on; also\n * exported from the package root so downstream hooks (components agent) can\n * reach the resolved transport/client/referrer.\n *\n * @throws Error when called outside a `<AgencProvider>`.\n */\nexport function useAgencContext(): AgencContextValue {\n const ctx = useContext(AgencContext);\n if (ctx === null) {\n throw new Error(t(\"provider.missingContext\"));\n }\n return ctx;\n}\n","/**\n * Internal helpers shared by the headless hooks.\n *\n * - A namespaced TanStack Query key factory so every hook's cache entries are\n * stable, collision-free, and individually invalidatable.\n * - Tiny guards that turn a missing write client / signer into a clear,\n * catalog-routed error (never a `null.method()` crash) BEFORE a mutation runs.\n *\n * SSR-safe: pure functions, no `window`/`document`, no module-scope side\n * effects.\n *\n * @module hooks/internal\n */\nimport { t } from \"../strings/index.js\";\nimport type {\n Address,\n AgencContextValue,\n MarketplaceClient,\n TransactionSigner,\n} from \"../types.js\";\n\n/** Root namespace for every cache key this package writes. */\nexport const QUERY_KEY_ROOT = \"agenc\" as const;\n\n/**\n * Stable, hierarchical TanStack Query keys. Hooks build their keys ONLY through\n * this factory so a consumer (or a hook) can invalidate a whole sub-tree\n * (`[\"agenc\", \"listings\"]`) or one entity (`[\"agenc\", \"listing\", pda]`).\n *\n * `JSON.stringify` is intentionally NOT used — TanStack compares keys\n * structurally, so passing the raw filter object keeps equality correct for\n * `bigint`/`Address` values without a serialization step.\n */\nexport const queryKeys = {\n /** All listings list queries (with their filter object as the leaf). */\n listings: (filter?: unknown) =>\n [QUERY_KEY_ROOT, \"listings\", filter ?? null] as const,\n /** One listing + its joined provider/track-record/moderation. */\n listing: (pda: string) => [QUERY_KEY_ROOT, \"listing\", pda] as const,\n /** One agent's indexer track record. */\n agentTrackRecord: (agentPda: string) =>\n [QUERY_KEY_ROOT, \"agentTrackRecord\", agentPda] as const,\n /** One task's status (read via transport / svm decode). */\n taskStatus: (taskPda: string) =>\n [QUERY_KEY_ROOT, \"taskStatus\", taskPda] as const,\n /** One task's dispute record. */\n dispute: (taskPda: string) => [QUERY_KEY_ROOT, \"dispute\", taskPda] as const,\n /** One referrer wallet's earnings (indexer-gated; see useReferrerEarnings). */\n referrerEarnings: (wallet: string) =>\n [QUERY_KEY_ROOT, \"referrerEarnings\", wallet] as const,\n} as const;\n\n/**\n * Assert a write client exists, returning it narrowed to non-null. Throws a\n * clear, catalog-routed error when the provider was configured read-only (no\n * `client` and no resolvable `rpcUrl` + `signer`).\n *\n * Mutating hooks call this at the top of their `mutationFn` so the failure is a\n * descriptive Error in the mutation's `error` channel — never a crash.\n *\n * @throws Error (`provider.missingWriteClient`) when `client` is null.\n */\nexport function requireClient(\n client: MarketplaceClient | null,\n): MarketplaceClient {\n if (client === null) {\n throw new Error(t(\"provider.missingWriteClient\"));\n }\n return client;\n}\n\nexport type MutationStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\nexport function mutationStatusOf(mutation: {\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n}): MutationStatus {\n if (mutation.isPending) return \"pending\";\n if (mutation.isError) return \"error\";\n if (mutation.isSuccess) return \"success\";\n return \"idle\";\n}\n\n/** Coerce an `Address | string` to its string form for use as a cache key. */\nexport function pdaKey(pda: Address | string): string {\n return String(pda);\n}\n\nexport interface ReferrerArgs {\n referrer?: Address;\n referrerFeeBps?: number;\n}\n\nexport interface ResolvedReferrerArgs {\n referrerArgs: ReferrerArgs;\n referrerInjected: boolean;\n}\n\nexport function resolveReferrerArgs(\n ctx: Pick<AgencContextValue, \"resolveReferrerCapability\">,\n): ResolvedReferrerArgs {\n const capability = ctx.resolveReferrerCapability();\n if (!capability.live || !capability.referrer) {\n return { referrerArgs: {}, referrerInjected: false };\n }\n return {\n referrerArgs: {\n referrer: capability.referrer.wallet,\n referrerFeeBps: capability.referrer.feeBps,\n },\n referrerInjected: true,\n };\n}\n\nexport type SignerOrAddress = TransactionSigner | Address;\n\nexport function signerAddress(signerOrAddress: SignerOrAddress): Address {\n if (typeof signerOrAddress === \"string\") {\n return signerOrAddress;\n }\n if (\n typeof signerOrAddress === \"object\" &&\n signerOrAddress !== null &&\n \"address\" in signerOrAddress &&\n typeof signerOrAddress.address === \"string\"\n ) {\n return signerOrAddress.address;\n }\n throw new Error(\"Expected a TransactionSigner or Address with an address field.\");\n}\n\nexport function withoutReferrerArgs<T extends object>(\n input: T,\n): Omit<T, \"referrer\" | \"referrerFeeBps\"> {\n const {\n referrer: _referrer,\n referrerFeeBps: _referrerFeeBps,\n ...rest\n } = input as T & { referrer?: unknown; referrerFeeBps?: unknown };\n return rest;\n}\n","/**\n * `useHire()` — the hire mutation hook (the embeddable money path).\n *\n * Drives `client.hireFromListing(...)` through the provider's write client and\n * surfaces the resulting transaction signature + minted Task PDA. Typed\n * `AgencError`s from the runtime client are surfaced UNTOUCHED in `error`.\n *\n * ## REFERRER SETTLEMENT\n *\n * The full 84-instruction protocol supports a demand-side referrer leg. This hook:\n * - reads `resolveReferrerCapability()` from context BEFORE building the hire;\n * - when `live === true`, spreads the validated provider referrer into the hire\n * input for both standard and humanless hires;\n * - the `referrerInjected` flag in the result is the audit signal. We never set\n * it true unless the transaction input included the referrer fields.\n *\n * @module hooks/useHire\n */\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useCallback, useMemo } from \"react\";\nimport { findTaskPda } from \"@tetsuo-ai/marketplace-sdk\";\nimport type { facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address } from \"../types.js\";\nimport {\n requireClient,\n resolveReferrerArgs,\n signerAddress,\n withoutReferrerArgs,\n} from \"./internal.js\";\n\n/**\n * Input to a standard `hire(...)` — a buyer that has a registered marketplace\n * agent (`creatorAgent`). This task settles on the HIRE COMPLETION path (the\n * worker calls `complete_task`). This is the SDK `facade.hireFromListing` input\n * MINUS the fee-payer signers, which default to the provider's write-client\n * signer (authority == creator == buyer). Pass them only to override.\n *\n * NOTE: deliberately NO referrer field — the referrer is provider-level config\n * and is injected only when `resolveReferrerCapability()` is live.\n */\nexport type HireInput = Omit<\n Parameters<typeof facadeNs.hireFromListing>[0],\n \"authority\" | \"creator\" | \"referrer\" | \"referrerFeeBps\"\n> & {\n /** Standard hire (default). */\n humanless?: false;\n /** Override the buyer authority signer (defaults to the client signer). */\n authority?: Parameters<typeof facadeNs.hireFromListing>[0][\"authority\"];\n /** Override the buyer/creator signer (defaults to the client signer). */\n creator?: Parameters<typeof facadeNs.hireFromListing>[0][\"creator\"];\n};\n\n/**\n * Input to a HUMANLESS `hire(...)` — a plain-wallet buyer with NO registered\n * agent (the storefront-visitor path). The task is pinned to CreatorReview, so\n * it settles via the BUYER REVIEW path (`useSubmissionReview` accept/reject) —\n * the human reviews before funds release. This is the SDK\n * `facade.hireFromListingHumanless` input minus the `creator` signer (defaulted\n * to the client signer).\n */\nexport type HumanlessHireInput = Omit<\n Parameters<typeof facadeNs.hireFromListingHumanless>[0],\n \"creator\" | \"referrer\" | \"referrerFeeBps\"\n> & {\n /** Discriminates the humanless storefront-visitor hire. */\n humanless: true;\n /** Override the buyer/creator signer (defaults to the client signer). */\n creator?: Parameters<typeof facadeNs.hireFromListingHumanless>[0][\"creator\"];\n};\n\n/** The union of standard and humanless hire inputs. */\nexport type AnyHireInput = HireInput | HumanlessHireInput;\n\n/** Lifecycle status of the hire mutation. */\nexport type HireStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Result of a settled hire. */\nexport interface HireResult {\n /** The confirmed transaction signature. */\n signature: string;\n /** The minted Task PDA (derived from creator + taskId). */\n taskPda: Address;\n /**\n * Whether a referrer fee leg was injected into THIS hire. Audit signal —\n * never fabricated.\n */\n referrerInjected: boolean;\n}\n\n/** Return value of {@link useHire}. */\nexport interface UseHireResult {\n /** Execute a hire. Resolves to {@link HireResult}; rejects with `AgencError`. */\n hire: (input: AnyHireInput) => Promise<HireResult>;\n /** Current mutation status. */\n status: HireStatus;\n /** The minted Task PDA from the last successful hire, or null. */\n taskPda: Address | null;\n /** The signature from the last successful hire, or null. */\n signature: string | null;\n /** The error from the last hire (typed `AgencError` untouched), or null. */\n error: Error | null;\n /** Whether a hire is currently in flight. */\n isPending: boolean;\n /** Reset the mutation back to idle. */\n reset: () => void;\n}\n\n/**\n * The hire hook.\n *\n * @returns {@link UseHireResult}.\n *\n * @example\n * ```tsx\n * const { hire, status, taskPda, error } = useHire();\n * await hire({\n * listing, creatorAgent, taskId, expectedPrice: price, expectedVersion: 1n,\n * listingSpecHash,\n * });\n * ```\n */\nexport function useHire(): UseHireResult {\n const ctx = useAgencContext();\n\n const mutation = useMutation<HireResult, Error, AnyHireInput>({\n mutationFn: async (input: AnyHireInput): Promise<HireResult> => {\n const client = requireClient(ctx.client);\n\n // Resolve fresh per hire so a provider referrer config change cannot leak\n // stale referral terms into a new transaction.\n const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);\n const hireInput = withoutReferrerArgs(input);\n\n const creator = input.creator ?? client.signer;\n let signature: string;\n\n if (input.humanless === true) {\n // Storefront-visitor hire: no creator agent; CreatorReview-pinned, so\n // it settles via the buyer review path (useSubmissionReview).\n const result = await client.hireFromListingHumanless({\n ...hireInput,\n creator,\n ...referrerArgs,\n } as Parameters<typeof facadeNs.hireFromListingHumanless>[0]);\n signature = result.signature;\n } else {\n // Standard hire: authority == creator == buyer (the buyer has an agent).\n const authority = input.authority ?? client.signer;\n const result = await client.hireFromListing({\n ...hireInput,\n authority,\n creator,\n ...referrerArgs,\n } as Parameters<typeof facadeNs.hireFromListing>[0]);\n signature = result.signature;\n }\n\n // Derive the minted Task PDA from (creator, taskId).\n const [taskPda] = await findTaskPda({\n creator: signerAddress(creator),\n taskId: input.taskId,\n });\n\n return { signature, taskPda, referrerInjected };\n },\n });\n\n const hire = useCallback(\n (input: AnyHireInput) => mutation.mutateAsync(input),\n [mutation],\n );\n\n const status: HireStatus = useMemo(() => {\n if (mutation.isPending) return \"pending\";\n if (mutation.isError) return \"error\";\n if (mutation.isSuccess) return \"success\";\n return \"idle\";\n }, [mutation.isPending, mutation.isError, mutation.isSuccess]);\n\n return {\n hire,\n status,\n taskPda: mutation.data?.taskPda ?? null,\n signature: mutation.data?.signature ?? null,\n error: mutation.error ?? null,\n isPending: mutation.isPending,\n reset: mutation.reset,\n };\n}\n","/**\n * `useWalletSigner()` — bridges a browser wallet into the kit `TransactionSigner`\n * the SDK write client expects.\n *\n * ## Adapter seam (the signer-adapters package is not built yet)\n *\n * The dedicated `@tetsuo-ai/signer-adapters` package (the signers agent, PLAN.md\n * P4.1) — which wraps `@solana/react`'s\n * `useWalletAccountTransactionSendingSigner` (Wallet Standard) and the legacy\n * `@solana/wallet-adapter` shim into a kit `TransactionSigner` — does not exist\n * at this hook's build time. So this hook is defined against a **documented\n * adapter interface** ({@link WalletSignerAdapter}) rather than importing that\n * package. A caller passes an adapter (today: a thin wrapper they write, or the\n * signer-adapters hook once it ships) and this hook normalizes it to the\n * `{ signer, connected, connect() }` contract every other hook expects.\n *\n * With NO adapter passed, the hook falls back to the provider's configured\n * `signer` (the `AgencProvider config.signer` slot), so a server-supplied or\n * test signer just works and `connect()` is a no-op.\n *\n * SSR-safe: no `window`/`document`; the adapter (which may touch wallet globals)\n * is the caller's responsibility to gate to the client. This hook only reads\n * what the adapter already resolved.\n *\n * @module hooks/useWalletSigner\n */\nimport { useCallback } from \"react\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { TransactionSigner } from \"../types.js\";\n\n/**\n * The minimal adapter shape this hook bridges. The forthcoming\n * `@tetsuo-ai/signer-adapters` hook is expected to return exactly this shape\n * (its `signerFromWalletAccount(...)` resolves the `signer`); until it ships,\n * any object matching this interface works.\n */\nexport interface WalletSignerAdapter {\n /** The resolved kit signer, or null when no wallet is connected. */\n signer: TransactionSigner | null;\n /** Whether a wallet is currently connected. */\n connected?: boolean;\n /** Trigger the wallet connect flow (browser-only). Optional. */\n connect?: () => void | Promise<void>;\n}\n\n/** Options for {@link useWalletSigner}. */\nexport interface UseWalletSignerOptions {\n /**\n * A wallet adapter (e.g. the signer-adapters hook's result). When omitted the\n * hook falls back to the provider's `config.signer`.\n */\n adapter?: WalletSignerAdapter;\n}\n\n/** Return value of {@link useWalletSigner}. */\nexport interface UseWalletSignerResult {\n /** The resolved kit `TransactionSigner`, or null. */\n signer: TransactionSigner | null;\n /** Whether a signer is available (adapter-connected or provider-configured). */\n connected: boolean;\n /** Trigger the wallet connect flow. No-op when no adapter `connect` exists. */\n connect: () => void | Promise<void>;\n}\n\n/**\n * Resolve the active signer for write operations.\n *\n * @param options - Optional wallet adapter; falls back to the provider signer.\n * @returns {@link UseWalletSignerResult}.\n *\n * @example\n * ```tsx\n * // Once @tetsuo-ai/signer-adapters ships:\n * const adapter = useWalletStandardSigner(); // returns WalletSignerAdapter\n * const { signer, connected, connect } = useWalletSigner({ adapter });\n * ```\n */\nexport function useWalletSigner(\n options?: UseWalletSignerOptions,\n): UseWalletSignerResult {\n const ctx = useAgencContext();\n const adapter = options?.adapter;\n\n // Adapter wins when present; otherwise the provider's configured signer.\n const signer: TransactionSigner | null =\n adapter?.signer ?? ctx.signer ?? null;\n const connected =\n adapter !== undefined\n ? (adapter.connected ?? adapter.signer !== null)\n : ctx.signer !== null;\n\n const connect = useCallback(() => {\n // No adapter (or no connect on it) => provider-supplied signer is already\n // \"connected\"; connecting is a no-op rather than an error.\n return adapter?.connect ? adapter.connect() : undefined;\n }, [adapter]);\n\n return { signer, connected, connect };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/provider/context.ts","../src/hooks/internal.ts","../src/hooks/useHire.ts","../src/hooks/useWalletSigner.ts"],"names":["useCallback"],"mappings":";;;;;AAkBO,IAAM,YAAA,GAAe,cAAwC,IAAI;AACxE,YAAA,CAAa,WAAA,GAAc,cAAA;AASpB,SAAS,eAAA,GAAqC;AACnD,EAAA,MAAM,GAAA,GAAM,WAAW,YAAY,CAAA;AACnC,EAAA,IAAI,QAAQ,IAAA,EAAM;AAChB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,CAAE,yBAAyB,CAAC,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,GAAA;AACT;;;ACZO,IAAM,cAAA,GAAiB;AAWvB,IAAM,SAAA,GAAY;AAAA;AAAA,EAEvB,UAAU,CAAC,MAAA,KACT,CAAC,cAAA,EAAgB,UAAA,EAAY,UAAU,IAAI,CAAA;AAAA;AAAA,EAE7C,SAAS,CAAC,GAAA,KAAgB,CAAC,cAAA,EAAgB,WAAW,GAAG,CAAA;AAAA;AAAA,EAEzD,kBAAkB,CAAC,QAAA,KACjB,CAAC,cAAA,EAAgB,oBAAoB,QAAQ,CAAA;AAAA;AAAA,EAE/C,YAAY,CAAC,OAAA,KACX,CAAC,cAAA,EAAgB,cAAc,OAAO,CAAA;AAAA;AAAA,EAExC,SAAS,CAAC,OAAA,KAAoB,CAAC,cAAA,EAAgB,WAAW,OAAO,CAAA;AAAA;AAAA,EAEjE,kBAAkB,CAAC,MAAA,KACjB,CAAC,cAAA,EAAgB,oBAAoB,MAAM;AAC/C;AAYO,SAAS,cACd,MAAA,EACmB;AACnB,EAAA,IAAI,WAAW,IAAA,EAAM;AACnB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,CAAE,6BAA6B,CAAC,CAAA;A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,GAAI,MAAA;AAAA,EAChD,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAA,OAAO,EAAE,MAAA,EAAQ,SAAA,EAAW,OAAA,EAAQ;AACtC","file":"chunk-2Y6JN2VZ.js","sourcesContent":["/**\n * The React context object + the internal `useAgencContext()` hook.\n *\n * Split from the component file so the context identity is stable and so hooks\n * can import the context without pulling the JSX provider into their module\n * graph. SSR-safe: this module only calls `createContext` at import time, never\n * touches `window`.\n *\n * @module provider/context\n */\nimport { createContext, useContext } from \"react\";\nimport { t } from \"../strings/index.js\";\nimport type { AgencContextValue } from \"../types.js\";\n\n/**\n * The AgenC context. `null` until a `<AgencProvider>` mounts above the consumer\n * — {@link useAgencContext} turns that into a clear developer error.\n */\nexport const AgencContext = createContext<AgencContextValue | null>(null);\nAgencContext.displayName = \"AgencContext\";\n\n/**\n * Read the AgenC context. INTERNAL hook the package's own hooks build on; also\n * exported from the package root so downstream hooks (components agent) can\n * reach the resolved transport/client/referrer.\n *\n * @throws Error when called outside a `<AgencProvider>`.\n */\nexport function useAgencContext(): AgencContextValue {\n const ctx = useContext(AgencContext);\n if (ctx === null) {\n throw new Error(t(\"provider.missingContext\"));\n }\n return ctx;\n}\n","/**\n * Internal helpers shared by the headless hooks.\n *\n * - A namespaced TanStack Query key factory so every hook's cache entries are\n * stable, collision-free, and individually invalidatable.\n * - Tiny guards that turn a missing write client / signer into a clear,\n * catalog-routed error (never a `null.method()` crash) BEFORE a mutation runs.\n *\n * SSR-safe: pure functions, no `window`/`document`, no module-scope side\n * effects.\n *\n * @module hooks/internal\n */\nimport { t } from \"../strings/index.js\";\nimport type {\n Address,\n AgencContextValue,\n MarketplaceClient,\n TransactionSigner,\n} from \"../types.js\";\n\n/** Root namespace for every cache key this package writes. */\nexport const QUERY_KEY_ROOT = \"agenc\" as const;\n\n/**\n * Stable, hierarchical TanStack Query keys. Hooks build their keys ONLY through\n * this factory so a consumer (or a hook) can invalidate a whole sub-tree\n * (`[\"agenc\", \"listings\"]`) or one entity (`[\"agenc\", \"listing\", pda]`).\n *\n * `JSON.stringify` is intentionally NOT used — TanStack compares keys\n * structurally, so passing the raw filter object keeps equality correct for\n * `bigint`/`Address` values without a serialization step.\n */\nexport const queryKeys = {\n /** All listings list queries (with their filter object as the leaf). */\n listings: (filter?: unknown) =>\n [QUERY_KEY_ROOT, \"listings\", filter ?? null] as const,\n /** One listing + its joined provider/track-record/moderation. */\n listing: (pda: string) => [QUERY_KEY_ROOT, \"listing\", pda] as const,\n /** One agent's indexer track record. */\n agentTrackRecord: (agentPda: string) =>\n [QUERY_KEY_ROOT, \"agentTrackRecord\", agentPda] as const,\n /** One task's status (read via transport / svm decode). */\n taskStatus: (taskPda: string) =>\n [QUERY_KEY_ROOT, \"taskStatus\", taskPda] as const,\n /** One task's dispute record. */\n dispute: (taskPda: string) => [QUERY_KEY_ROOT, \"dispute\", taskPda] as const,\n /** One referrer wallet's earnings (indexer-gated; see useReferrerEarnings). */\n referrerEarnings: (wallet: string) =>\n [QUERY_KEY_ROOT, \"referrerEarnings\", wallet] as const,\n} as const;\n\n/**\n * Assert a write client exists, returning it narrowed to non-null. Throws a\n * clear, catalog-routed error when the provider was configured read-only (no\n * `client` and no resolvable `rpcUrl` + `signer`).\n *\n * Mutating hooks call this at the top of their `mutationFn` so the failure is a\n * descriptive Error in the mutation's `error` channel — never a crash.\n *\n * @throws Error (`provider.missingWriteClient`) when `client` is null.\n */\nexport function requireClient(\n client: MarketplaceClient | null,\n): MarketplaceClient {\n if (client === null) {\n throw new Error(t(\"provider.missingWriteClient\"));\n }\n return client;\n}\n\nexport type MutationStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\nexport function mutationStatusOf(mutation: {\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n}): MutationStatus {\n if (mutation.isPending) return \"pending\";\n if (mutation.isError) return \"error\";\n if (mutation.isSuccess) return \"success\";\n return \"idle\";\n}\n\n/** Coerce an `Address | string` to its string form for use as a cache key. */\nexport function pdaKey(pda: Address | string): string {\n return String(pda);\n}\n\nexport interface ReferrerArgs {\n referrer?: Address;\n referrerFeeBps?: number;\n}\n\nexport interface ResolvedReferrerArgs {\n referrerArgs: ReferrerArgs;\n referrerInjected: boolean;\n}\n\nexport function resolveReferrerArgs(\n ctx: Pick<AgencContextValue, \"resolveReferrerCapability\">,\n): ResolvedReferrerArgs {\n const capability = ctx.resolveReferrerCapability();\n if (!capability.live || !capability.referrer) {\n return { referrerArgs: {}, referrerInjected: false };\n }\n return {\n referrerArgs: {\n referrer: capability.referrer.wallet,\n referrerFeeBps: capability.referrer.feeBps,\n },\n referrerInjected: true,\n };\n}\n\nexport type SignerOrAddress = TransactionSigner | Address;\n\nexport function signerAddress(signerOrAddress: SignerOrAddress): Address {\n if (typeof signerOrAddress === \"string\") {\n return signerOrAddress;\n }\n if (\n typeof signerOrAddress === \"object\" &&\n signerOrAddress !== null &&\n \"address\" in signerOrAddress &&\n typeof signerOrAddress.address === \"string\"\n ) {\n return signerOrAddress.address;\n }\n throw new Error(\"Expected a TransactionSigner or Address with an address field.\");\n}\n\nexport function withoutReferrerArgs<T extends object>(\n input: T,\n): Omit<T, \"referrer\" | \"referrerFeeBps\"> {\n const {\n referrer: _referrer,\n referrerFeeBps: _referrerFeeBps,\n ...rest\n } = input as T & { referrer?: unknown; referrerFeeBps?: unknown };\n return rest;\n}\n","/**\n * `useHire()` — the hire mutation hook (the embeddable money path).\n *\n * Drives `client.hireFromListing(...)` through the provider's write client and\n * surfaces the resulting transaction signature + minted Task PDA. Typed\n * `AgencError`s from the runtime client are surfaced UNTOUCHED in `error`.\n *\n * ## REFERRER SETTLEMENT\n *\n * The full 84-instruction protocol supports a demand-side referrer leg. This hook:\n * - reads `resolveReferrerCapability()` from context BEFORE building the hire;\n * - when `live === true`, spreads the validated provider referrer into the hire\n * input for both standard and humanless hires;\n * - the `referrerInjected` flag in the result is the audit signal. We never set\n * it true unless the transaction input included the referrer fields.\n *\n * @module hooks/useHire\n */\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useCallback, useMemo } from \"react\";\nimport { findTaskPda } from \"@tetsuo-ai/marketplace-sdk\";\nimport type { facade as facadeNs } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { Address } from \"../types.js\";\nimport {\n requireClient,\n resolveReferrerArgs,\n signerAddress,\n withoutReferrerArgs,\n} from \"./internal.js\";\n\n/**\n * Input to a standard `hire(...)` — a buyer that has a registered marketplace\n * agent (`creatorAgent`). This task settles on the HIRE COMPLETION path (the\n * worker calls `complete_task`). This is the SDK `facade.hireFromListing` input\n * MINUS the fee-payer signers, which default to the provider's write-client\n * signer (authority == creator == buyer). Pass them only to override.\n *\n * NOTE: deliberately NO referrer field — the referrer is provider-level config\n * and is injected only when `resolveReferrerCapability()` is live.\n */\nexport type HireInput = Omit<\n Parameters<typeof facadeNs.hireFromListing>[0],\n \"authority\" | \"creator\" | \"referrer\" | \"referrerFeeBps\"\n> & {\n /** Standard hire (default). */\n humanless?: false;\n /** Override the buyer authority signer (defaults to the client signer). */\n authority?: Parameters<typeof facadeNs.hireFromListing>[0][\"authority\"];\n /** Override the buyer/creator signer (defaults to the client signer). */\n creator?: Parameters<typeof facadeNs.hireFromListing>[0][\"creator\"];\n};\n\n/**\n * Input to a HUMANLESS `hire(...)` — a plain-wallet buyer with NO registered\n * agent (the storefront-visitor path). The task is pinned to CreatorReview, so\n * it settles via the BUYER REVIEW path (`useSubmissionReview` accept/reject) —\n * the human reviews before funds release. This is the SDK\n * `facade.hireFromListingHumanless` input minus the `creator` signer (defaulted\n * to the client signer).\n */\nexport type HumanlessHireInput = Omit<\n Parameters<typeof facadeNs.hireFromListingHumanless>[0],\n \"creator\" | \"referrer\" | \"referrerFeeBps\"\n> & {\n /** Discriminates the humanless storefront-visitor hire. */\n humanless: true;\n /** Override the buyer/creator signer (defaults to the client signer). */\n creator?: Parameters<typeof facadeNs.hireFromListingHumanless>[0][\"creator\"];\n};\n\n/** The union of standard and humanless hire inputs. */\nexport type AnyHireInput = HireInput | HumanlessHireInput;\n\n/** Lifecycle status of the hire mutation. */\nexport type HireStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\n/** Result of a settled hire. */\nexport interface HireResult {\n /** The confirmed transaction signature. */\n signature: string;\n /** The minted Task PDA (derived from creator + taskId). */\n taskPda: Address;\n /**\n * Whether a referrer fee leg was injected into THIS hire. Audit signal —\n * never fabricated.\n */\n referrerInjected: boolean;\n}\n\n/** Return value of {@link useHire}. */\nexport interface UseHireResult {\n /** Execute a hire. Resolves to {@link HireResult}; rejects with `AgencError`. */\n hire: (input: AnyHireInput) => Promise<HireResult>;\n /** Current mutation status. */\n status: HireStatus;\n /** The minted Task PDA from the last successful hire, or null. */\n taskPda: Address | null;\n /** The signature from the last successful hire, or null. */\n signature: string | null;\n /** The error from the last hire (typed `AgencError` untouched), or null. */\n error: Error | null;\n /** Whether a hire is currently in flight. */\n isPending: boolean;\n /** Reset the mutation back to idle. */\n reset: () => void;\n}\n\n/**\n * The hire hook.\n *\n * @returns {@link UseHireResult}.\n *\n * @example\n * ```tsx\n * const { hire, status, taskPda, error } = useHire();\n * await hire({\n * listing, creatorAgent, taskId, expectedPrice: price, expectedVersion: 1n,\n * listingSpecHash,\n * });\n * ```\n */\nexport function useHire(): UseHireResult {\n const ctx = useAgencContext();\n\n const mutation = useMutation<HireResult, Error, AnyHireInput>({\n mutationFn: async (input: AnyHireInput): Promise<HireResult> => {\n const client = requireClient(ctx.client);\n\n // Resolve fresh per hire so a provider referrer config change cannot leak\n // stale referral terms into a new transaction.\n const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);\n const hireInput = withoutReferrerArgs(input);\n\n const creator = input.creator ?? client.signer;\n let signature: string;\n\n if (input.humanless === true) {\n // Storefront-visitor hire: no creator agent; CreatorReview-pinned, so\n // it settles via the buyer review path (useSubmissionReview).\n const result = await client.hireFromListingHumanless({\n ...hireInput,\n creator,\n ...referrerArgs,\n } as Parameters<typeof facadeNs.hireFromListingHumanless>[0]);\n signature = result.signature;\n } else {\n // Standard hire: authority == creator == buyer (the buyer has an agent).\n const authority = input.authority ?? client.signer;\n const result = await client.hireFromListing({\n ...hireInput,\n authority,\n creator,\n ...referrerArgs,\n } as Parameters<typeof facadeNs.hireFromListing>[0]);\n signature = result.signature;\n }\n\n // Derive the minted Task PDA from (creator, taskId).\n const [taskPda] = await findTaskPda({\n creator: signerAddress(creator),\n taskId: input.taskId,\n });\n\n return { signature, taskPda, referrerInjected };\n },\n });\n\n const hire = useCallback(\n (input: AnyHireInput) => mutation.mutateAsync(input),\n [mutation],\n );\n\n const status: HireStatus = useMemo(() => {\n if (mutation.isPending) return \"pending\";\n if (mutation.isError) return \"error\";\n if (mutation.isSuccess) return \"success\";\n return \"idle\";\n }, [mutation.isPending, mutation.isError, mutation.isSuccess]);\n\n return {\n hire,\n status,\n taskPda: mutation.data?.taskPda ?? null,\n signature: mutation.data?.signature ?? null,\n error: mutation.error ?? null,\n isPending: mutation.isPending,\n reset: mutation.reset,\n };\n}\n","/**\n * `useWalletSigner()` — bridges a browser wallet into the kit `TransactionSigner`\n * the SDK write client expects.\n *\n * ## Adapter seam (the signer-adapters package is not built yet)\n *\n * The dedicated `@tetsuo-ai/signer-adapters` package (the signers agent, PLAN.md\n * P4.1) — which wraps `@solana/react`'s\n * `useWalletAccountTransactionSendingSigner` (Wallet Standard) and the legacy\n * `@solana/wallet-adapter` shim into a kit `TransactionSigner` — does not exist\n * at this hook's build time. So this hook is defined against a **documented\n * adapter interface** ({@link WalletSignerAdapter}) rather than importing that\n * package. A caller passes an adapter (today: a thin wrapper they write, or the\n * signer-adapters hook once it ships) and this hook normalizes it to the\n * `{ signer, connected, connect() }` contract every other hook expects.\n *\n * With NO adapter passed, the hook falls back to the provider's configured\n * `signer` (the `AgencProvider config.signer` slot), so a server-supplied or\n * test signer just works and `connect()` is a no-op.\n *\n * SSR-safe: no `window`/`document`; the adapter (which may touch wallet globals)\n * is the caller's responsibility to gate to the client. This hook only reads\n * what the adapter already resolved.\n *\n * @module hooks/useWalletSigner\n */\nimport { useCallback } from \"react\";\nimport { useAgencContext } from \"../provider/context.js\";\nimport type { TransactionSigner } from \"../types.js\";\n\n/**\n * The minimal adapter shape this hook bridges. The forthcoming\n * `@tetsuo-ai/signer-adapters` hook is expected to return exactly this shape\n * (its `signerFromWalletAccount(...)` resolves the `signer`); until it ships,\n * any object matching this interface works.\n */\nexport interface WalletSignerAdapter {\n /** The resolved kit signer, or null when no wallet is connected. */\n signer: TransactionSigner | null;\n /** Whether a wallet is currently connected. */\n connected?: boolean;\n /** Trigger the wallet connect flow (browser-only). Optional. */\n connect?: () => void | Promise<void>;\n}\n\n/** Options for {@link useWalletSigner}. */\nexport interface UseWalletSignerOptions {\n /**\n * A wallet adapter (e.g. the signer-adapters hook's result). When omitted the\n * hook falls back to the provider's `config.signer`.\n */\n adapter?: WalletSignerAdapter;\n}\n\n/** Return value of {@link useWalletSigner}. */\nexport interface UseWalletSignerResult {\n /** The resolved kit `TransactionSigner`, or null. */\n signer: TransactionSigner | null;\n /** Whether a signer is available (adapter-connected or provider-configured). */\n connected: boolean;\n /** Trigger the wallet connect flow. No-op when no adapter `connect` exists. */\n connect: () => void | Promise<void>;\n}\n\n/**\n * Resolve the active signer for write operations.\n *\n * @param options - Optional wallet adapter; falls back to the provider signer.\n * @returns {@link UseWalletSignerResult}.\n *\n * @example\n * ```tsx\n * // Once @tetsuo-ai/signer-adapters ships:\n * const adapter = useWalletStandardSigner(); // returns WalletSignerAdapter\n * const { signer, connected, connect } = useWalletSigner({ adapter });\n * ```\n */\nexport function useWalletSigner(\n options?: UseWalletSignerOptions,\n): UseWalletSignerResult {\n const ctx = useAgencContext();\n const adapter = options?.adapter;\n\n // Adapter wins when present; otherwise the provider's configured signer.\n const signer: TransactionSigner | null =\n adapter?.signer ?? ctx.signer ?? null;\n const connected =\n adapter !== undefined\n ? (adapter.connected ?? adapter.signer !== null)\n : ctx.signer !== null;\n\n const connect = useCallback(() => {\n // No adapter (or no connect on it) => provider-supplied signer is already\n // \"connected\"; connecting is a no-op rather than an error.\n return adapter?.connect ? adapter.connect() : undefined;\n }, [adapter]);\n\n return { signer, connected, connect };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t } from './chunk-
|
|
1
|
+
import { t } from './chunk-H6PJIDQR.js';
|
|
2
2
|
import { isAddress, address } from '@solana/kit';
|
|
3
3
|
import { createIndexerClient, getServiceListingDecoder, listActiveListings } from '@tetsuo-ai/marketplace-sdk';
|
|
4
4
|
|
|
@@ -90,5 +90,5 @@ function createReadTransport(config) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export { ReadTransportUnsupportedError, createReadTransport };
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-AKPPKMQ2.js.map
|
|
94
|
+
//# sourceMappingURL=chunk-AKPPKMQ2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transport/index.ts"],"names":["gpaListActiveListings"],"mappings":";;;;AAwCO,IAAM,6BAAA,GAAN,cAA4C,KAAA,CAAM;AAAA;AAAA,EAE9C,SAAA;AAAA,EACT,YAAY,SAAA,EAAmB;AAC7B,IAAA,KAAA;AAAA,MACE,mBAAmB,SAAS,CAAA,wIAAA;AAAA,KAG9B;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,+BAAA;AACZ,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA;AAAA,EACnB;AACF;AAGA,SAAS,UAAU,GAAA,EAAgC;AACjD,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,EAAU,OAAO,GAAA;AACpC,EAAA,IAAI,CAAC,SAAA,CAAU,GAAG,CAAA,EAAG;AACnB,IAAA,MAAM,IAAI,SAAA,CAAU,CAAA,mCAAA,EAAsC,GAAG,CAAA,CAAE,CAAA;AAAA,EACjE;AACA,EAAA,O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,IACzE,CAAA;AAAA,IACA,gBAAA,GAAmB;AACjB,MAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,QACb,IAAI,8BAA8B,kBAAkB;AAAA,OACtD;AAAA,IACF;AAAA,GACF;AACF;AAGA,SAAS,cAAc,GAAA,EAAyB;AAC9C,EAAA,IAAI,OAAO,SAAS,UAAA,EAAY;AAC9B,IAAA,MAAM,MAAA,GAAS,KAAK,GAAG,CAAA;AACvB,IAAA,MAAM,KAAA,GAAQ,IAAI,UAAA,CAAW,MAAA,CAAO,MAAM,CAAA;AAC1C,IAAA,KAAA,IAAS,IAAI,CAAA,EAAG,CAAA,GAAI,MAAA,CAAO,MAAA,EAAQ,KAAK,CAAA,EAAG;AACzC,MAAA,KAAA,CAAM,CAAC,CAAA,GAAI,MAAA,CAAO,UAAA,CAAW,CAAC,CAAA;AAAA,IAChC;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,WAAW,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,GAAA,EAAK,QAAQ,CAAC,CAAA;AACnD;AAeO,SAAS,oBACd,MAAA,EACe;AACf,EAAA,IAAI,MAAA,CAAO,cAAA,EAAgB,OAAO,MAAA,CAAO,cAAA;AACzC,EAAA,IAAI,MAAA,CAAO,SAAS,OAAA,EAAS;AAC3B,IAAA,OAAO,oBAAA,CAAqB,MAAA,CAAO,OAAA,EAAS,MAAA,CAAO,oBAAoB,CAAA;AAAA,EACzE;AACA,EAAA,IAAI,MAAA,CAAO,GAAA,EAAK,OAAO,gBAAA,CAAiB,OAAO,GAAG,CAAA;AAClD,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,CAAE,wBAAwB,CAAC,CAAA;AAC7C","file":"chunk-AKPPKMQ2.js","sourcesContent":["/**\n * The read-transport abstraction — indexer-first with RPC/gPA fallback.\n *\n * `createReadTransport({ indexer?, rpc?, queryTransport? })` returns one\n * {@link ReadTransport}. When an indexer `baseUrl` is set it routes through the\n * SDK's `createIndexerClient` (the scale path); otherwise it falls back to the\n * SDK's gPA `listActiveListings` / account fetch (the trustless path). The two\n * backends return parity shapes BY SDK DESIGN, so callers never branch on which\n * one is live.\n *\n * `queryTransport` is a full override slot — pass a mock/pre-built transport\n * (tests, SSR fixtures) and it is used verbatim.\n *\n * SSR-safe: no `window`/`document` and no Node built-ins at module scope; the\n * SDK's indexer client is browser-safe (fetch + kit codecs only).\n *\n * @module transport\n */\nimport { address, isAddress } from \"@solana/kit\";\nimport {\n createIndexerClient,\n getServiceListingDecoder,\n listActiveListings as gpaListActiveListings,\n type IndexerClient,\n} from \"@tetsuo-ai/marketplace-sdk\";\nimport { t } from \"../strings/index.js\";\nimport type {\n Address,\n CreateReadTransportConfig,\n GpaReadSource,\n IndexerConfig,\n ReadListingResult,\n ReadTransport,\n} from \"../types.js\";\nimport type { CreateIndexerClientOptions } from \"@tetsuo-ai/marketplace-sdk\";\n\n/**\n * Thrown when a gPA-fallback transport is asked for an indexer-only capability\n * (aggregated hires / track record have no trustless gPA equivalent).\n */\nexport class ReadTransportUnsupportedError extends Error {\n /** The unsupported operation name. */\n readonly operation: string;\n constructor(operation: string) {\n super(\n `Read operation \"${operation}\" requires the indexer backend; the gPA ` +\n `fallback has no trustless equivalent. Configure an indexer baseUrl on ` +\n `<AgencProvider> to use it.`,\n );\n this.name = \"ReadTransportUnsupportedError\";\n this.operation = operation;\n }\n}\n\n/** Coerce a string|Address PDA into a kit Address (validates base58). */\nfunction toAddress(pda: Address | string): Address {\n if (typeof pda !== \"string\") return pda;\n if (!isAddress(pda)) {\n throw new TypeError(`Not a valid base58 Solana address: ${pda}`);\n }\n return address(pda);\n}\n\n/** Build the indexer-backed read transport. */\nfunction indexerReadTransport(\n config: IndexerConfig,\n indexerClientOptions?: Partial<CreateIndexerClientOptions>,\n): ReadTransport {\n const client: IndexerClient = createIndexerClient({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n ...(indexerClientOptions ?? {}),\n });\n return {\n kind: \"indexer\",\n listActiveListings: (options) => client.listActiveListings(options),\n async getListing(pda): Promise<ReadListingResult> {\n const listing = await client.getListing(pda);\n const account = getServiceListingDecoder().decode(\n base64ToBytes(listing.accountData),\n );\n return {\n address: toAddress(listing.pda),\n account,\n indexer: listing,\n };\n },\n listingHires: (pda) => client.listingHires(pda),\n agentTrackRecord: (pda) => client.agentTrackRecord(pda),\n };\n}\n\n/** Build the gPA-fallback read transport over a kit RPC / ProgramAccountsTransport. */\nfunction gpaReadTransport(rpc: GpaReadSource): ReadTransport {\n return {\n kind: \"gpa\",\n listActiveListings: (options) => gpaListActiveListings(rpc, options),\n async getListing(pda): Promise<ReadListingResult> {\n // No single-account decode helper crosses the transport seam here, so we\n // scope the active-listings query down to the one PDA. (The indexer path\n // is the efficient one; this fallback is the trustless escape hatch.)\n const target = toAddress(pda);\n const all = await gpaListActiveListings(rpc, {});\n const hit = all.find((entry) => entry.address === target);\n if (hit === undefined) {\n throw new Error(\n `Listing ${pda} not found among active listings via the gPA ` +\n `fallback (it may be inactive, or your RPC restricts ` +\n `getProgramAccounts — use an indexer baseUrl for single-listing ` +\n `lookups).`,\n );\n }\n return { address: hit.address, account: hit.account };\n },\n listingHires() {\n return Promise.reject(new ReadTransportUnsupportedError(\"listingHires\"));\n },\n agentTrackRecord() {\n return Promise.reject(\n new ReadTransportUnsupportedError(\"agentTrackRecord\"),\n );\n },\n };\n}\n\n/** Browser-safe base64 → bytes (atob in browsers, Buffer in Node). */\nfunction base64ToBytes(b64: string): Uint8Array {\n if (typeof atob === \"function\") {\n const binary = atob(b64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i += 1) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n }\n // Node fallback — Buffer is always present there.\n return Uint8Array.from(Buffer.from(b64, \"base64\"));\n}\n\n/**\n * Create the unified read transport.\n *\n * Resolution order:\n * 1. `queryTransport` override (wins — tests/mocks/SSR fixtures);\n * 2. `indexer.baseUrl` present → indexer-first transport;\n * 3. `rpc` present → gPA fallback transport;\n * 4. nothing configured → throws a descriptive error.\n *\n * @param config - See {@link CreateReadTransportConfig}.\n * @returns A {@link ReadTransport}.\n * @throws Error when no read source is configured.\n */\nexport function createReadTransport(\n config: CreateReadTransportConfig,\n): ReadTransport {\n if (config.queryTransport) return config.queryTransport;\n if (config.indexer?.baseUrl) {\n return indexerReadTransport(config.indexer, config.indexerClientOptions);\n }\n if (config.rpc) return gpaReadTransport(config.rpc);\n throw new Error(t(\"transport.noReadSource\"));\n}\n\nexport type { ReadTransport } from \"../types.js\";\n"]}
|
|
@@ -9,7 +9,8 @@ var EN_STRINGS = {
|
|
|
9
9
|
"referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
|
|
10
10
|
"referrer.notLive": "Referral fee is not active for this hire.",
|
|
11
11
|
"referrer.notLiveReason": "No referrer is configured for this provider.",
|
|
12
|
-
"referrer.earningsNotLiveReason": "Referral settlement is live, but
|
|
12
|
+
"referrer.earningsNotLiveReason": "Referral settlement is live, but no earnings endpoint is available on this network (configure indexer.baseUrl).",
|
|
13
|
+
"referrer.earningsFetchFailed": "The referrer earnings endpoint could not be read.",
|
|
13
14
|
// Read transport.
|
|
14
15
|
"transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
|
|
15
16
|
// Generic loading / empty / error states (components extend these).
|
|
@@ -32,5 +33,5 @@ function t(id, vars, options) {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export { EN_STRINGS, t };
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
36
|
+
//# sourceMappingURL=chunk-H6PJIDQR.js.map
|
|
37
|
+
//# sourceMappingURL=chunk-H6PJIDQR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/strings/index.ts"],"names":[],"mappings":";AAkCO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,yBAAA,EACE,sDAAA;AAAA,EACF,6BAAA,EACE,uIAAA;AAAA,EACF,wBAAA,EACE,qFAAA;AAAA;AAAA,EAGF,wBAAA,EACE,iEAAA;AAAA,EACF,wBAAA,EACE,0FAAA;AAAA,EACF,kBAAA,EACE,2CAAA;AAAA,EACF,wBAAA,EACE,8CAAA;AAAA,EACF,gCAAA,EACE,iHAAA;AAAA,EACF,8BAAA,EACE,mDAAA;AAAA;AAAA,EAGF,wBAAA,EACE,4HAAA;AAAA;AAAA,EAGF,eAAA,EAAiB,eAAA;AAAA,EACjB,aAAA,EAAe,sBAAA;AAAA,EACf,aAAA,EAAe,uBAAA;AAAA;AAAA,EAGf,UAAA,EAAY,MAAA;AAAA,EACZ,cAAA,EAAgB,kBAAA;AAAA,EAChB,aAAA,EAAe;AACjB;AAwCO,SAAS,CAAA,CACd,EAAA,EACA,IAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,OAAA,GAAyB,SAAS,OAAA,IAAW,UAAA;AACnD,EAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,EAAE,CAAA,IAAK,EAAA;AAChC,EAAA,IAAI,IAAA,KAAS,QAAW,OAAO,QAAA;AAC/B,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,YAAA,EAAc,CAAC,OAAO,GAAA,KAAgB;AAC5D,IAAA,MAAM,KAAA,GAAQ,KAAK,GAAG,CAAA;AACtB,IAAA,OAAO,KAAA,KAAU,MAAA,GAAY,KAAA,GAAQ,MAAA,CAAO,KAAK,CAAA;AAAA,EACnD,CAAC,CAAA;AACH","file":"chunk-H6PJIDQR.js","sourcesContent":["/**\n * Minimal English string catalog + a `t(id, vars?)` resolver.\n *\n * Every user-facing string in this package and its downstream hooks/components\n * routes through this module so a future `{ locale }` can resolve translations\n * **without an API break** (PLAN_2 Part A design constraint). v1 ships English\n * only; the resolver signature is already locale-shaped.\n *\n * ## Why a catalog and not inline literals\n *\n * Components published to third parties cannot assume the host's language. By\n * keying every literal here:\n * - adding a locale is a data change (a new {@link StringCatalog}), not a code\n * change to every component;\n * - the message ids are a stable contract the components agent binds to;\n * - `{var}` interpolation is centralized and SSR-safe (pure string ops, no\n * `Intl` global assumptions at module scope).\n *\n * @module strings\n */\n\n/**\n * The catalog shape: every message id maps to an English template. `{name}`\n * placeholders are filled by {@link t} from the `vars` argument.\n */\nexport interface StringCatalog {\n readonly [id: string]: string;\n}\n\n/**\n * Default English catalog. Keep ids namespaced by surface\n * (`provider.*`, `referrer.*`, `transport.*`, `hire.*`, ...) so the components\n * agent can extend it without collisions.\n */\nexport const EN_STRINGS = {\n // Provider / context wiring errors (developer-facing, but routed for parity).\n \"provider.missingContext\":\n \"useAgencContext must be used within <AgencProvider>.\",\n \"provider.missingWriteClient\":\n \"No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.\",\n \"provider.missingSigner\":\n \"No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.\",\n\n // Referrer config validation / capability surface.\n \"referrer.invalidWallet\":\n \"Referrer wallet is not a valid base58 Solana address: {wallet}.\",\n \"referrer.invalidFeeBps\":\n \"Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.\",\n \"referrer.notLive\":\n \"Referral fee is not active for this hire.\",\n \"referrer.notLiveReason\":\n \"No referrer is configured for this provider.\",\n \"referrer.earningsNotLiveReason\":\n \"Referral settlement is live, but 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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t } from './chunk-
|
|
1
|
+
import { t } from './chunk-H6PJIDQR.js';
|
|
2
2
|
import { address, getTransactionEncoder, getTransactionDecoder } from '@solana/kit';
|
|
3
3
|
|
|
4
4
|
// src/signers/strings.ts
|
|
@@ -124,5 +124,5 @@ function signerFromEmbeddedWallet(connection) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
export { EN_SIGNER_STRINGS, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter };
|
|
127
|
-
//# sourceMappingURL=chunk-
|
|
128
|
-
//# sourceMappingURL=chunk-
|
|
127
|
+
//# sourceMappingURL=chunk-ON6XR4XO.js.map
|
|
128
|
+
//# sourceMappingURL=chunk-ON6XR4XO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/signers/strings.ts","../src/signers/wallet-account.ts","../src/signers/wallet-adapter.ts","../src/signers/embedded-wallet.ts"],"names":["address","getTransactionEncoder","getTransactionDecoder"],"mappings":";;;;AAaO,IAAM,iBAAA,GAAoB;AAAA,EAC/B,4BAAA,EACE,yLAAA;AAAA,EACF,0BAAA,EACE,wJAAA;AAAA,EACF,+BAAA,EACE,sGAAA;AAAA,EACF,kCAAA,EACE,uGAAA;AAAA,EACF,4BAAA,EACE;AACJ;AASO,SAAS,EAAA,CACd,IACA,IAAA,EACQ;AACR,EAAA,OAAO,EAAE,EAAA,EAAI,IAAA,EAAM,EAAE,OAAA,EAAS,mBAAmB,CAAA;AACnD;;;ACNA,IAAM,uBAAA,GAA0B,wBAAA;AAGhC,SAAS,sBAAA,CACP,SACA,OAAA,EAC+B;AAC/B,EAAA,IAAI,OAAA,CAAQ,eAAA,EAAiB,OAAO,OAAA,CAAQ,eAAA;AAC5C,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,QAAA,GAAW,uBAAuB,CAAA;AAG1D,EAAA,IAAI,OAAA,EAAS,eAAA,EAAiB,OAAO,OAAA,CAAQ,eAAA;AAC7C,EAAA,MAAM,IAAI,MAAM,EAAA,CAAG,4BAAA,EAA8B,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,CAAC,CAAA;AAChF;AAGA,SAAS,YAAA,CACP,SACA,OAAA,EACoB;AACpB,EAAA,IAAI,OAAA,CAAQ,KAAA,EAAO,OAAO,OAAA,CAAQ,KAAA;AAClC,EAAA,OAAO,OAAA,CAAQ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A,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":"chunk-MNJ2EQDJ.js","sourcesContent":["/**\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/signers/strings.ts","../src/signers/wallet-account.ts","../src/signers/wallet-adapter.ts","../src/signers/embedded-wallet.ts"],"names":["address","getTransactionEncoder","getTransactionDecoder"],"mappings":";;;;AAaO,IAAM,iBAAA,GAAoB;AAAA,EAC/B,4BAAA,EACE,yLAAA;AAAA,EACF,0BAAA,EACE,wJAAA;AAAA,EACF,+BAAA,EACE,sGAAA;AAAA,EACF,kCAAA,EACE,uGAAA;AAAA,EACF,4BAAA,EACE;AACJ;AASO,SAAS,EAAA,CACd,IACA,IAAA,EACQ;AACR,EAAA,OAAO,EAAE,EAAA,EAAI,IAAA,EAAM,EAAE,OAAA,EAAS,mBAAmB,CAAA;AACnD;;;ACNA,IAAM,uBAAA,GAA0B,wBAAA;AAGhC,SAAS,sBAAA,CACP,SACA,OAAA,EAC+B;AAC/B,EAAA,IAAI,OAAA,CAAQ,eAAA,EAAiB,OAAO,OAAA,CAAQ,eAAA;AAC5C,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,QAAA,GAAW,uBAAuB,CAAA;AAG1D,EAAA,IAAI,OA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,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":"chunk-ON6XR4XO.js","sourcesContent":["/**\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,5 +1,5 @@
|
|
|
1
|
-
import { useAgencContext, useHire, useWalletSigner } from './chunk-
|
|
2
|
-
import { EN_STRINGS, t } from './chunk-
|
|
1
|
+
import { useAgencContext, useHire, useWalletSigner } from './chunk-2Y6JN2VZ.js';
|
|
2
|
+
import { EN_STRINGS, t } from './chunk-H6PJIDQR.js';
|
|
3
3
|
import { TaskStatus, values, findAgentVerificationPda, fetchMaybeAgentVerification } from '@tetsuo-ai/marketplace-sdk';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { useEffect, useRef, useId, useState, useCallback } from 'react';
|
|
@@ -1290,5 +1290,5 @@ function PoweredByAgenC({
|
|
|
1290
1290
|
}
|
|
1291
1291
|
|
|
1292
1292
|
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 };
|
|
1293
|
-
//# sourceMappingURL=chunk-
|
|
1294
|
-
//# sourceMappingURL=chunk-
|
|
1293
|
+
//# sourceMappingURL=chunk-ZAMIL27X.js.map
|
|
1294
|
+
//# sourceMappingURL=chunk-ZAMIL27X.js.map
|