@tetsuo-ai/marketplace-react 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +93 -47
  3. package/dist/chunk-7NKRSPPN.js +227 -0
  4. package/dist/chunk-7NKRSPPN.js.map +1 -0
  5. package/dist/{chunk-JVXGNW3Q.js → chunk-CDDHUFMG.js} +6 -5
  6. package/dist/chunk-CDDHUFMG.js.map +1 -0
  7. package/dist/chunk-FIDFPM5A.cjs +40 -0
  8. package/dist/chunk-FIDFPM5A.cjs.map +1 -0
  9. package/dist/chunk-IJKWKY4H.cjs +1370 -0
  10. package/dist/chunk-IJKWKY4H.cjs.map +1 -0
  11. package/dist/chunk-JTSG5FGC.cjs +397 -0
  12. package/dist/chunk-JTSG5FGC.cjs.map +1 -0
  13. package/dist/chunk-ONC6L3IX.cjs +97 -0
  14. package/dist/chunk-ONC6L3IX.cjs.map +1 -0
  15. package/dist/chunk-R76EUYDI.cjs +233 -0
  16. package/dist/chunk-R76EUYDI.cjs.map +1 -0
  17. package/dist/{chunk-XLA7DARS.js → chunk-RG5JZ6JL.js} +159 -36
  18. package/dist/chunk-RG5JZ6JL.js.map +1 -0
  19. package/dist/components/index.cjs +158 -1594
  20. package/dist/components/index.cjs.map +1 -1
  21. package/dist/components/index.d.cts +2 -2
  22. package/dist/components/index.d.ts +2 -2
  23. package/dist/components/index.js +2 -2
  24. package/dist/hooks/index.cjs +656 -509
  25. package/dist/hooks/index.cjs.map +1 -1
  26. package/dist/hooks/index.d.cts +63 -29
  27. package/dist/hooks/index.d.ts +63 -29
  28. package/dist/hooks/index.js +619 -196
  29. package/dist/hooks/index.js.map +1 -1
  30. package/dist/{index-CmVz0OOm.d.ts → index-BAyr1ODZ.d.ts} +28 -3
  31. package/dist/{index-DAZzhuO4.d.cts → index-C20NVU7_.d.cts} +28 -3
  32. package/dist/index.cjs +284 -1833
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +7 -8
  35. package/dist/index.d.ts +7 -8
  36. package/dist/index.js +64 -4
  37. package/dist/index.js.map +1 -1
  38. package/dist/signers/index.cjs +22 -161
  39. package/dist/signers/index.cjs.map +1 -1
  40. package/dist/signers/index.d.cts +16 -11
  41. package/dist/signers/index.d.ts +16 -11
  42. package/dist/signers/index.js +1 -1
  43. package/dist/testing/index.d.cts +1 -1
  44. package/dist/testing/index.d.ts +1 -1
  45. package/dist/theme/agenc-tailwind-preset.cjs +134 -108
  46. package/dist/{types-jvISR6bc.d.cts → types-B10rndEI.d.cts} +16 -7
  47. package/dist/{types-jvISR6bc.d.ts → types-B10rndEI.d.ts} +16 -7
  48. package/dist/{useAgentTrackRecord-DPt3SfYz.d.cts → useAgentTrackRecord-Ch7gHTFj.d.cts} +1 -1
  49. package/dist/{useAgentTrackRecord-DPt3SfYz.d.ts → useAgentTrackRecord-Ch7gHTFj.d.ts} +1 -1
  50. package/package.json +6 -3
  51. package/src/components/HireCheckoutModal.tsx +5 -2
  52. package/src/hooks/index.ts +1 -0
  53. package/src/hooks/internal.ts +178 -24
  54. package/src/hooks/useAgentTrackRecord.ts +5 -2
  55. package/src/hooks/useCompletionBond.ts +56 -21
  56. package/src/hooks/useDispute.ts +46 -9
  57. package/src/hooks/useHire.ts +113 -23
  58. package/src/hooks/useHumanlessHireFlow.ts +335 -115
  59. package/src/hooks/useListing.ts +2 -2
  60. package/src/hooks/useListings.ts +2 -2
  61. package/src/hooks/useRateHire.ts +32 -5
  62. package/src/hooks/useReferrerEarnings.ts +4 -1
  63. package/src/hooks/useSubmissionReview.ts +95 -32
  64. package/src/hooks/useTaskActivation.ts +51 -9
  65. package/src/hooks/useTaskGuarantee.ts +4 -1
  66. package/src/hooks/useTaskLifecycle.ts +104 -24
  67. package/src/hooks/useTaskStatus.ts +121 -26
  68. package/src/hooks/useTaskWork.ts +76 -12
  69. package/src/hooks/useWalletSigner.ts +11 -16
  70. package/src/index.ts +3 -0
  71. package/src/provider/AgencProvider.tsx +95 -3
  72. package/src/provider/referrer.ts +1 -1
  73. package/src/signers/README.md +13 -7
  74. package/src/signers/index.ts +6 -1
  75. package/src/signers/strings.ts +13 -1
  76. package/src/signers/types.ts +16 -5
  77. package/src/signers/wallet-account.ts +115 -29
  78. package/src/signers/wallet-adapter.ts +38 -4
  79. package/src/theme/agenc-tailwind-preset.cjs +134 -108
  80. package/src/types.ts +27 -1
  81. package/dist/chunk-JVXGNW3Q.js.map +0 -1
  82. package/dist/chunk-ON6XR4XO.js +0 -128
  83. package/dist/chunk-ON6XR4XO.js.map +0 -1
  84. package/dist/chunk-XLA7DARS.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,61 @@
1
1
  # @tetsuo-ai/marketplace-react
2
2
 
3
+ ## 0.5.0 (unreleased candidate)
4
+
5
+ ### Breaking Changes
6
+
7
+ - Raise the runtime floor to Node 22.23.1 for the coordinated revision-5 train;
8
+ Node 20 is EOL.
9
+ - The optional `./tailwind-preset` export is now a dependency-free Tailwind v3
10
+ plugin descriptor. Importing the React package's advertised preset no longer
11
+ fails in clean consumers that do not otherwise install Tailwind; pinned
12
+ Tailwind compilation coverage verifies the descriptor and emitted utilities.
13
+ - Require the revision-5 SDK peer (`^0.12.0`) for the coordinated cutover.
14
+ `useHire` and the humanless flow now require the buyer's non-zero
15
+ `taskJobSpecHash` before they can fund escrow, and activation verifies that
16
+ the moderation callback returned that exact hash. This is an intentional API
17
+ and wire break; published 0.4.1 remains current while mainnet is revision 4.
18
+ - `useHumanlessHireFlow` now delegates to the SDK's non-resubmitting recovery
19
+ orchestration. Post-submission failures surface `HireAndActivateError`,
20
+ `progress.recovery` exposes its durable `hiring`/`moderating`/`activating`
21
+ token, and `resumeHireAndActivate(input, token)` resumes without issuing a
22
+ second funded hire. This intentionally replaces the old raw backend/send
23
+ error identity after a hire may have committed.
24
+ - Add an explicit `orchestrationRpc` provider seam and keep funded
25
+ reconciliation separate from ordinary read endpoints. Provider-built clients
26
+ use their resolved RPC; pre-built custom clients use only an explicitly
27
+ supplied `rpcUrl`/`orchestrationRpc` and never inherit a network default.
28
+ - Harden the marketplace starter's funded job contract across custom backend
29
+ seams. The task-bound normalized specification is detached and deeply frozen,
30
+ backends receive a separate clone, the local hash is rechecked before and
31
+ after hosting, and activation/state consume fresh copies of the originally
32
+ funded bytes rather than backend-owned mutable arrays.
33
+ - Preserve custom signer compatibility in `useHumanlessHireFlow`: React now
34
+ canonicalizes a same-address creator override to the client fee-payer object
35
+ and stabilizes a distinct-address signer at its enqueue boundary. This keeps
36
+ one signer object per address as Solana Kit requires without collapsing an
37
+ intentional separate signer.
38
+ - Close async intent races in the direct `useHire` and `useTaskActivation`
39
+ money paths. They synchronously detach `taskId`, `listingSpecHash`,
40
+ `taskJobSpecHash`, and `jobSpecHash` before enqueue, derive the Task PDA once
41
+ from the captured bytes/address, canonicalize same-address overrides to the
42
+ client signer, and preserve distinct-address signer identities before
43
+ moderation or funded-client awaits. Standard hires also use one object when
44
+ separate creator/authority wrappers expose the same non-client address.
45
+ - `useHumanlessHireFlow` now validates and detaches every 32-byte hire and
46
+ activating-recovery commitment at the public enqueue boundary. Exact
47
+ Uint8Arrays from another browser/worker realm are accepted, while wrong
48
+ widths, non-byte views, and SharedArrayBuffer-backed views fail before any
49
+ funded or resumed SDK work begins.
50
+ - Snapshot every caller-owned mutable input in `useTaskWork`,
51
+ `useSubmissionReview`, `useDispute`, `useCompletionBond`,
52
+ `useTaskLifecycle`, and `useRateHire` before TanStack enqueue. Fixed byte
53
+ fields accept exact `Uint8Array` views across JavaScript realms and preserve
54
+ raw, nullable, and explicit Solana `Option` representations. A signer
55
+ override for the client fee-payer address resolves to the canonical client
56
+ signer object, satisfying Solana Kit's one-signer-instance-per-address rule;
57
+ distinct-address overrides retain their identity.
58
+
3
59
  ## 0.4.1
4
60
 
5
61
  ### Patch Changes (additive — WP-H3 phase 1, Guaranteed Hire)
package/README.md CHANGED
@@ -34,10 +34,14 @@ export default function App() {
34
34
  config={{
35
35
  network: "devnet",
36
36
  // Indexer-first reads (the scale path). Omit to use a gPA transport.
37
- indexer: { baseUrl: "https://marketplace.agenc.tech" },
37
+ indexer: { baseUrl: "https://api.agenc.ag" },
38
38
  // Write client is built from rpcUrl + signer when both are present,
39
39
  // or pass a pre-built `client` (e.g. from startLocalMarketplace()).
40
40
  // rpcUrl, signer,
41
+ // A custom client never inherits the network's implicit RPC for funded
42
+ // recovery. Pair it with an explicit rpcUrl or orchestrationRpc when
43
+ // automatic finalized reconciliation/account resolution is required.
44
+ // orchestrationRpc,
41
45
  // Referrer config is accepted + validated, then injected into hires.
42
46
  // The earnings hook is still indexer-gated (see "Referrers" below).
43
47
  // referrer: { wallet: "<base58>", feeBps: 250 },
@@ -52,20 +56,28 @@ export default function App() {
52
56
  `<AgencProvider>` wraps a bundled TanStack `QueryClientProvider` and exposes one
53
57
  context (read it with `useAgencContext()`):
54
58
 
55
- | field | type | notes |
56
- |---|---|---|
57
- | `network` | `"localnet" \| "devnet" \| "mainnet"` | resolved target |
58
- | `read` | `ReadTransport` | indexer-first, gPA fallback |
59
- | `client` | `MarketplaceClient \| null` | write runtime; `null` if not configured |
60
- | `signer` | `TransactionSigner \| null` | the configured signer |
61
- | `referrer` | `ValidatedReferrerConfig \| null` | validated + stored |
62
- | `resolveReferrerCapability()` | `ReferrerCapability` | live when a valid referrer is configured |
59
+ | field | type | notes |
60
+ | ----------------------------- | ------------------------------------- | ----------------------------------------------------------------------- |
61
+ | `network` | `"localnet" \| "devnet" \| "mainnet"` | resolved target |
62
+ | `cacheNamespace` | `string` | credential-free deployment identity folded into query keys |
63
+ | `read` | `ReadTransport` | indexer-first, gPA fallback |
64
+ | `client` | `MarketplaceClient \| null` | write runtime; `null` if not configured |
65
+ | `rpcUrl` | `string \| null` | resolved general-purpose HTTP RPC |
66
+ | `orchestrationRpc` | `ModerationAccountReadRpc \| null` | explicitly injected funded-recovery/account-read seam |
67
+ | `orchestrationRpcUrl` | `string \| null` | funded orchestration URL; never an implicit default for a custom client |
68
+ | `indexerBaseUrl` | `string \| null` | explicitly configured hosted-indexer URL |
69
+ | `signer` | `TransactionSigner \| null` | the configured signer |
70
+ | `referrer` | `ValidatedReferrerConfig \| null` | validated + stored |
71
+ | `resolveReferrerCapability()` | `ReferrerCapability` | live when a valid referrer is configured |
63
72
 
64
73
  ### Override slots (test seams, public API)
65
74
 
66
75
  - `config.client` — a pre-built `MarketplaceClient`. `startLocalMarketplace().client`
67
76
  (from `@tetsuo-ai/marketplace-sdk/testing`) plugs straight in for hook e2e.
68
77
  - `config.queryTransport` — a pre-built `ReadTransport` (mocks / SSR fixtures).
78
+ - `config.orchestrationRpc` — an explicit account-read/finalized-recovery RPC.
79
+ It wins over `rpcUrl`; use it to pair an opaque custom client with the exact
80
+ deployment that client submits to.
69
81
 
70
82
  ## Read transport
71
83
 
@@ -82,26 +94,47 @@ them with a typed `ReadTransportUnsupportedError`.
82
94
 
83
95
  Hooks are imported from `@tetsuo-ai/marketplace-react/hooks`:
84
96
 
85
- | Hook | Kind | What it gives you |
86
- |---|---|---|
87
- | `useListings` / `useListing` | read | active listing discovery and listing detail |
88
- | `useAgentTrackRecord` | read | completion rate, dispute rate, and slash history |
89
- | `useTaskStatus` | read | task status with off-path terminal states |
90
- | `useHire` | write | registered-agent hire and humanless buyer hire; injects validated referrer terms when live |
91
- | `useHumanlessHireFlow` | write | humanless buyer hire, self-hosted job-spec moderation/hosting, and `set_task_job_spec` activation in one tracked flow |
92
- | `useTaskActivation` | write | `set_task_job_spec` activation after moderation |
93
- | `useTaskWork` | write | `claim_task_with_job_spec` and `submit_task_result` |
94
- | `useSubmissionReview` | write | CreatorReview accept/reject |
95
- | `useTaskLifecycle` | write | cancel, close, and caller-submitted auto-accept |
96
- | `useRateHire` | write | buyer rating for completed hires |
97
- | `useDispute` | advanced write | dispute read/initiate with a host-supplied dispute reader |
98
- | `useWalletSigner` | wallet | browser wallet to kit `TransactionSigner` bridge |
99
- | `useReferrerEarnings` | read | indexer-gated earnings status; no fabricated totals |
97
+ | Hook | Kind | What it gives you |
98
+ | ---------------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------- |
99
+ | `useListings` / `useListing` | read | active listing discovery and listing detail |
100
+ | `useAgentTrackRecord` | read | completion rate, dispute rate, and slash history |
101
+ | `useTaskStatus` | read | task status with off-path terminal states |
102
+ | `useHire` | write | registered-agent hire and humanless buyer hire; injects validated referrer terms when live |
103
+ | `useHumanlessHireFlow` | write | humanless buyer hire, self-hosted job-spec moderation/hosting, and `set_task_job_spec` activation in one tracked flow |
104
+ | `useTaskActivation` | write | `set_task_job_spec` activation after moderation |
105
+ | `useTaskWork` | write | `claim_task_with_job_spec` and `submit_task_result` |
106
+ | `useSubmissionReview` | write | CreatorReview accept/reject |
107
+ | `useTaskLifecycle` | write | cancel, close, and caller-submitted auto-accept |
108
+ | `useRateHire` | write | buyer rating for completed hires |
109
+ | `useDispute` | advanced write | dispute read/initiate with a host-supplied dispute reader |
110
+ | `useWalletSigner` | wallet | browser wallet to kit `TransactionSigner` bridge |
111
+ | `useReferrerEarnings` | read | indexer earnings (`GET /api/explorer/referrers/:wallet/hires`); no fabricated totals |
112
+ | `useTaskGuarantee` | read | Guaranteed Hire status for a task (0.4.1) |
113
+ | `useCompletionBond` | write | post/reclaim completion bonds for Guaranteed Hire (0.4.1) |
114
+
115
+ `useHire`, `useTaskActivation`, and `useHumanlessHireFlow` detach every
116
+ caller-owned 32-byte commitment synchronously, before TanStack can schedule the
117
+ mutation, and reuse those exact bytes across moderation, recovery, and funded
118
+ client awaits. Exact cross-realm Uint8Arrays are accepted; shared backing and
119
+ non-byte views fail before enqueue. A same-address signer override resolves to
120
+ the canonical client fee-payer object, while a distinct signer is canonicalized,
121
+ locked, and frozen in place. Standard hire creator/authority wrappers for the
122
+ same non-client address also resolve to one object. Create a new signer object
123
+ when a wallet changes accounts; do not mutate an enrolled signer's address.
124
+
125
+ The other multi-step write hooks (`useTaskWork`, `useSubmissionReview`,
126
+ `useDispute`, `useCompletionBond`, `useTaskLifecycle`, and `useRateHire`) also
127
+ detach known mutable records, account collections, and fixed byte views before
128
+ enqueue. Optional byte fields preserve raw bytes, `null`, explicit `Some` /
129
+ `None`, and omission. If an instruction override names the client's fee-payer
130
+ address, the hook uses the canonical client signer object; Solana Kit requires
131
+ one signer implementation per address. A distinct-address override remains the
132
+ selected signer.
100
133
 
101
134
  ## Referrers
102
135
 
103
- Referral settlement is live on the full 84-instruction protocol surface. When
104
- `referrer: { wallet, feeBps }` is configured:
136
+ Referral settlement is live on the full protocol surface (99 instructions as of
137
+ batch-4). When `referrer: { wallet, feeBps }` is configured:
105
138
 
106
139
  - the provider validates and stores it (bad base58 throws; out-of-range basis
107
140
  points are rejected);
@@ -115,30 +148,41 @@ the humanless hire first, then calls your `hostAndModerateJobSpec` backend seam
115
148
  with the derived `taskPda`, `taskId`, listing, job spec, hire signature, and
116
149
  referrer audit flag. It signs `set_task_job_spec` only when that backend returns
117
150
  `moderationAttested: true`, a 32-byte `Uint8Array` `jobSpecHash`, and a non-empty
118
- `jobSpecUri`. If hosting, moderation, or activation fails, `progress` preserves
119
- the completed phase data so the UI can recover or offer refund/activation
120
- options without pretending the task is claimable.
121
-
122
- Aggregated referrer earnings are a separate indexer feature. Until the indexer
123
- publishes `GET /api/explorer/referrers/:wallet/hires`, `useReferrerEarnings()`
124
- returns the documented not-live zero state and never fabricates totals.
151
+ `jobSpecUri`. The hook delegates funded execution and recovery to the SDK's
152
+ audited orchestration rail. If a hire send is ambiguous, or hosting, moderation,
153
+ or activation fails after funding, `progress.recovery` contains the exact SDK
154
+ resume token. Persist that token with a binary-safe store (for example
155
+ structured clone/IndexedDB), then call `resumeHireAndActivate(input, token)`
156
+ with the same intent. Resume never calls the funded hire instruction. An
157
+ ambiguous `hiring` token remains safely preserved and reconciliation-only when
158
+ no RPC is configured, but it cannot progress until the provider supplies an
159
+ explicit `rpcUrl` or `orchestrationRpc` that can prove the exact transaction at
160
+ finalized commitment. A pre-built custom `client` deliberately does not inherit
161
+ the selected network's implicit RPC endpoint: coupling an opaque client to the
162
+ wrong cluster would make recovery evidence unsafe.
163
+
164
+ Aggregated referrer earnings are an indexer feature. `useReferrerEarnings()`
165
+ fetches `GET /api/explorer/referrers/:wallet/hires` from the configured indexer
166
+ (default mainnet base `https://api.agenc.ag` since 0.3.2) and never fabricates
167
+ totals — missing/empty responses surface as the documented zero state.
125
168
 
126
169
  ## Components
127
170
 
128
171
  Prebuilt, themable components are exported from the root (and tree-shakeable via
129
172
  `@tetsuo-ai/marketplace-react/components`):
130
173
 
131
- | Component | What it renders | Wiring |
132
- |---|---|---|
133
- | `ListingCard` | one decoded listing (name, price, category, provider, moderation badge) | presentational (`ListingRow`) |
134
- | `ListingGrid` | a responsive grid of cards + loading/empty/error/load-more | takes `useListings()` fields |
135
- | `HireButton` | price-aware CTA that opens the checkout and runs the hire | **connected** (`useHire` + `useWalletSigner`) |
136
- | `HireCheckoutModal` | accessible money modal: price, moderation badge, escrow note, referrer disclosure, confirm/pending/funded/error | presentational (map `useHire()`) |
137
- | `TaskTimeline` | task lifecycle (Open→In progress→Pending review→Completed) + off-path terminals | takes `useTaskStatus().status` |
138
- | `ReviewPanel` | buyer accept / reject / request-changes | takes `useSubmissionReview()` |
139
- | `DisputeBanner` | open-dispute alert + initiate entry point | takes `useDispute()` |
140
- | `ProviderCard` | track record (provisional rates) + verified badge | takes `useAgentTrackRecord().trackRecord` |
141
- | `PoweredByAgenC` | optional attribution mark linking the trust page | standalone |
174
+ | Component | What it renders | Wiring |
175
+ | ------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
176
+ | `GuaranteedBadge` | Guaranteed Hire / completion-bond status badge (0.4.1) | presentational |
177
+ | `ListingCard` | one decoded listing (name, price, category, provider, moderation badge) | presentational (`ListingRow`) |
178
+ | `ListingGrid` | a responsive grid of cards + loading/empty/error/load-more | takes `useListings()` fields |
179
+ | `HireButton` | price-aware CTA that opens the checkout and runs the hire | **connected** (`useHire` + `useWalletSigner`) |
180
+ | `HireCheckoutModal` | accessible money modal: price, moderation badge, escrow note, referrer disclosure, confirm/pending/funded/error | presentational (map `useHire()`) |
181
+ | `TaskTimeline` | task lifecycle (Open→In progress→Pending review→Completed) + off-path terminals | takes `useTaskStatus().status` |
182
+ | `ReviewPanel` | buyer accept / reject / request-changes | takes `useSubmissionReview()` |
183
+ | `DisputeBanner` | open-dispute alert + initiate entry point | takes `useDispute()` |
184
+ | `ProviderCard` | track record (provisional rates) + verified badge | takes `useAgentTrackRecord().trackRecord` |
185
+ | `PoweredByAgenC` | optional attribution mark linking the trust page | standalone |
142
186
 
143
187
  Accessibility is structural: `HireCheckoutModal` ships a focus trap, full
144
188
  keyboard navigation, ARIA dialog roles, and live-region status — it is a money
@@ -182,12 +226,14 @@ Components style themselves through `--agenc-*` CSS custom properties. Load the
182
226
  default AgenC theme for the styled look:
183
227
 
184
228
  ```ts
185
- import "@tetsuo-ai/marketplace-react/theme.css"; // foundation tokens
186
- import "@tetsuo-ai/marketplace-react/components.css"; // component recipes
229
+ import "@tetsuo-ai/marketplace-react/theme.css"; // foundation tokens
230
+ import "@tetsuo-ai/marketplace-react/components.css"; // component recipes
187
231
  ```
188
232
 
189
233
  Override any token on an ancestor, or use the Tailwind preset at
190
- `@tetsuo-ai/marketplace-react/tailwind-preset` (requires Tailwind in your app).
234
+ `@tetsuo-ai/marketplace-react/tailwind-preset` with Tailwind v3. The preset is a
235
+ dependency-free descriptor, so merely importing it does not load Tailwind; your
236
+ app supplies Tailwind when compiling its CSS.
191
237
  There is no CSS-in-JS runtime, and the CSS is entirely optional: every component
192
238
  accepts an `unstyled` prop for full white-label (it then emits semantic markup +
193
239
  ARIA with no `--agenc-*` classes).
@@ -0,0 +1,227 @@
1
+ import { t } from './chunk-H6PJIDQR.js';
2
+ import { address, getTransactionEncoder, getTransactionDecoder, getPublicKeyFromAddress, verifySignature } from '@solana/kit';
3
+
4
+ // src/signers/strings.ts
5
+ var EN_SIGNER_STRINGS = {
6
+ "signer.walletNoSignFeature": "Wallet account {address} does not expose a solana:signTransaction feature. Pass options.signTransaction explicitly, or use a Wallet Standard account that supports transaction signing.",
7
+ "signer.walletNoSignature": "The wallet returned no signature for account {address}. The wallet may have rejected the signing request.",
8
+ "signer.walletResponseCount": "Wallet returned {got} signed transactions; expected {expected} ordered outputs, one per input.",
9
+ "signer.walletModifiedTransaction": "Wallet modified the transaction message for account {address}. AgenC cannot attach a signature over different bytes to the original transaction.",
10
+ "signer.walletInvalidSignature": "Wallet returned an invalid signature for account {address} over the requested transaction message.",
11
+ "signer.walletChainRequired": "Wallet account {address} exposes {count} Solana chains. Select exactly one with options.chain or options.network.",
12
+ "signer.walletChainUnsupported": "Wallet account {address} does not support requested chain {chain}.",
13
+ "signer.walletChainNetworkMismatch": "Requested chain {chain} does not match options.network {network} ({expected}).",
14
+ "signer.embeddedSignatureCount": "Embedded wallet returned {got} signatures for {expected} transactions; expected one per transaction.",
15
+ "signer.walletAdapterDisconnected": "The wallet adapter is not connected (publicKey is null). Connect the wallet before creating a signer.",
16
+ "signer.walletAdapterNoSign": "The wallet adapter does not expose signTransaction. Use a wallet that supports transaction signing, or migrate to the Wallet Standard path (signerFromWalletAccount)."
17
+ };
18
+ function ts(id, vars) {
19
+ return t(id, vars, { catalog: EN_SIGNER_STRINGS });
20
+ }
21
+
22
+ // src/signers/wallet-account.ts
23
+ var SOLANA_SIGN_TRANSACTION = "solana:signTransaction";
24
+ function resolveSignTransaction(account, options) {
25
+ if (options.signTransaction) return options.signTransaction;
26
+ const feature = account.features?.[SOLANA_SIGN_TRANSACTION];
27
+ if (feature?.signTransaction) return feature.signTransaction;
28
+ throw new Error(ts("signer.walletNoSignFeature", { address: account.address }));
29
+ }
30
+ function walletStandardChainForNetwork(network) {
31
+ return `solana:${network}`;
32
+ }
33
+ function resolveChain(account, options) {
34
+ const networkChain = options.network ? walletStandardChainForNetwork(options.network) : void 0;
35
+ if (options.chain && networkChain && options.chain !== networkChain) {
36
+ throw new Error(
37
+ ts("signer.walletChainNetworkMismatch", {
38
+ chain: options.chain,
39
+ network: options.network,
40
+ expected: networkChain
41
+ })
42
+ );
43
+ }
44
+ const solanaChains = account.chains?.filter((chain2) => chain2.startsWith("solana:")) ?? [];
45
+ const requested = options.chain ?? networkChain;
46
+ const chain = requested ?? (solanaChains.length === 1 ? solanaChains[0] : void 0);
47
+ if (!chain) {
48
+ throw new Error(
49
+ ts("signer.walletChainRequired", {
50
+ address: account.address,
51
+ count: solanaChains.length
52
+ })
53
+ );
54
+ }
55
+ if (!chain.startsWith("solana:") || account.chains !== void 0 && !account.chains.includes(chain)) {
56
+ throw new Error(
57
+ ts("signer.walletChainUnsupported", {
58
+ address: account.address,
59
+ chain
60
+ })
61
+ );
62
+ }
63
+ return chain;
64
+ }
65
+ function bytesEqual(left, right) {
66
+ if (left.length !== right.length) return false;
67
+ for (let index = 0; index < left.length; index += 1) {
68
+ if (left[index] !== right[index]) return false;
69
+ }
70
+ return true;
71
+ }
72
+ function signerFromWalletAccount(account, options = {}) {
73
+ const signerAddress = address(account.address);
74
+ const signTransaction = resolveSignTransaction(account, options);
75
+ const chain = resolveChain(account, options);
76
+ const encoder = getTransactionEncoder();
77
+ const decoder = getTransactionDecoder();
78
+ let publicKeyPromise;
79
+ async function extractSignature(transaction, signedTransaction) {
80
+ const signed = decoder.decode(signedTransaction);
81
+ if (!bytesEqual(transaction.messageBytes, signed.messageBytes)) {
82
+ throw new Error(
83
+ ts("signer.walletModifiedTransaction", { address: account.address })
84
+ );
85
+ }
86
+ const signature = signed.signatures[signerAddress];
87
+ if (!signature) {
88
+ throw new Error(ts("signer.walletNoSignature", { address: account.address }));
89
+ }
90
+ publicKeyPromise ??= getPublicKeyFromAddress(signerAddress);
91
+ const valid = await verifySignature(
92
+ await publicKeyPromise,
93
+ signature,
94
+ transaction.messageBytes
95
+ );
96
+ if (!valid) {
97
+ throw new Error(
98
+ ts("signer.walletInvalidSignature", { address: account.address })
99
+ );
100
+ }
101
+ return signature;
102
+ }
103
+ return {
104
+ address: signerAddress,
105
+ chain,
106
+ async signTransactions(transactions) {
107
+ if (transactions.length === 0) return [];
108
+ const outputs = await signTransaction(
109
+ ...transactions.map((transaction) => ({
110
+ account,
111
+ chain,
112
+ transaction: new Uint8Array(encoder.encode(transaction))
113
+ }))
114
+ );
115
+ if (outputs.length !== transactions.length) {
116
+ throw new Error(
117
+ ts("signer.walletResponseCount", {
118
+ got: outputs.length,
119
+ expected: transactions.length
120
+ })
121
+ );
122
+ }
123
+ return Promise.all(
124
+ outputs.map(async (output, index) => ({
125
+ [signerAddress]: await extractSignature(
126
+ transactions[index],
127
+ output.signedTransaction
128
+ )
129
+ }))
130
+ );
131
+ }
132
+ };
133
+ }
134
+ function resolveAdapterAddress(adapter) {
135
+ const { publicKey } = adapter;
136
+ if (publicKey == null) {
137
+ throw new Error(ts("signer.walletAdapterDisconnected"));
138
+ }
139
+ if (typeof publicKey === "string") return publicKey;
140
+ if ("toBase58" in publicKey && typeof publicKey.toBase58 === "function") {
141
+ return publicKey.toBase58();
142
+ }
143
+ return String(publicKey);
144
+ }
145
+ function bytesEqual2(left, right) {
146
+ if (left.length !== right.length) return false;
147
+ for (let index = 0; index < left.length; index += 1) {
148
+ if (left[index] !== right[index]) return false;
149
+ }
150
+ return true;
151
+ }
152
+ function signerFromWalletAdapter(adapter, options) {
153
+ const signerAddress = address(resolveAdapterAddress(adapter));
154
+ const { signTransaction } = adapter;
155
+ if (typeof signTransaction !== "function") {
156
+ throw new Error(ts("signer.walletAdapterNoSign"));
157
+ }
158
+ const { VersionedTransaction } = options;
159
+ const encoder = getTransactionEncoder();
160
+ const decoder = getTransactionDecoder();
161
+ let publicKeyPromise;
162
+ async function signOne(transaction) {
163
+ const wireBytes = new Uint8Array(encoder.encode(transaction));
164
+ const legacyTx = VersionedTransaction.deserialize(wireBytes);
165
+ const signed = await signTransaction(legacyTx);
166
+ const signedTx = decoder.decode(new Uint8Array(signed.serialize()));
167
+ if (!bytesEqual2(transaction.messageBytes, signedTx.messageBytes)) {
168
+ throw new Error(
169
+ ts("signer.walletModifiedTransaction", { address: signerAddress })
170
+ );
171
+ }
172
+ const signature = signedTx.signatures[signerAddress];
173
+ if (!signature) {
174
+ throw new Error(
175
+ ts("signer.walletNoSignature", { address: signerAddress })
176
+ );
177
+ }
178
+ publicKeyPromise ??= getPublicKeyFromAddress(signerAddress);
179
+ const valid = await verifySignature(
180
+ await publicKeyPromise,
181
+ signature,
182
+ transaction.messageBytes
183
+ );
184
+ if (!valid) {
185
+ throw new Error(
186
+ ts("signer.walletInvalidSignature", { address: signerAddress })
187
+ );
188
+ }
189
+ return signature;
190
+ }
191
+ return {
192
+ address: signerAddress,
193
+ async signTransactions(transactions) {
194
+ const signatures = [];
195
+ for (const transaction of transactions) {
196
+ signatures.push({
197
+ [signerAddress]: await signOne(transaction)
198
+ });
199
+ }
200
+ return signatures;
201
+ }
202
+ };
203
+ }
204
+ function signerFromEmbeddedWallet(connection) {
205
+ const signerAddress = address(connection.address);
206
+ return {
207
+ address: signerAddress,
208
+ async signTransactions(transactions) {
209
+ const signatures = await connection.signTransactions(transactions);
210
+ if (signatures.length !== transactions.length) {
211
+ throw new Error(
212
+ ts("signer.embeddedSignatureCount", {
213
+ expected: transactions.length,
214
+ got: signatures.length
215
+ })
216
+ );
217
+ }
218
+ return transactions.map((_, i) => ({
219
+ [signerAddress]: signatures[i]
220
+ }));
221
+ }
222
+ };
223
+ }
224
+
225
+ export { EN_SIGNER_STRINGS, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter, walletStandardChainForNetwork };
226
+ //# sourceMappingURL=chunk-7NKRSPPN.js.map
227
+ //# sourceMappingURL=chunk-7NKRSPPN.js.map
@@ -0,0 +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":["chain","bytesEqual","address","getTransactionEncoder","getT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MAAA,OAAO,UAAA;AAAA,IACT;AAAA,GACF;AACF;AC9IO,SAAS,yBACd,UAAA,EACmB;AACnB,EAAA,MAAM,aAAA,GAAgBJ,OAAAA,CAAQ,UAAA,CAAW,OAAO,CAAA;AAEhD,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,aAAA;AAAA,IACT,MAAM,iBAAiB,YAAA,EAAsC;AAC3D,MAAA,MAAM,UAAA,GACJ,MAAM,UAAA,CAAW,gBAAA,CAAiB,YAAY,CAAA;AAChD,MAAA,IAAI,UAAA,CAAW,MAAA,KAAW,YAAA,CAAa,MAAA,EAAQ;AAC7C,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,GAAG,+BAAA,EAAiC;AAAA,YAClC,UAAU,YAAA,CAAa,MAAA;AAAA,YACvB,KAAK,UAAA,CAAW;AAAA,WACjB;AAAA,SACH;AAAA,MACF;AACA,MAAA,OAAO,YAAA,CAAa,GAAA,CAAI,CAAC,CAAA,EAAG,CAAA,MAAO;AAAA,QACjC,CAAC,aAAa,GAAG,UAAA,CAAW,CAAC;AAAA,OAC/B,CAAE,CAAA;AAAA,IACJ;AAAA,GACF;AACF","file":"chunk-7NKRSPPN.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 the signing request.\",\n \"signer.walletResponseCount\":\n \"Wallet returned {got} signed transactions; expected {expected} ordered outputs, one per input.\",\n \"signer.walletModifiedTransaction\":\n \"Wallet modified the transaction message for account {address}. AgenC cannot attach a signature over different bytes to the original transaction.\",\n \"signer.walletInvalidSignature\":\n \"Wallet returned an invalid signature for account {address} over the requested transaction message.\",\n \"signer.walletChainRequired\":\n \"Wallet account {address} exposes {count} Solana chains. Select exactly one with options.chain or options.network.\",\n \"signer.walletChainUnsupported\":\n \"Wallet account {address} does not support requested chain {chain}.\",\n \"signer.walletChainNetworkMismatch\":\n \"Requested chain {chain} does not match options.network {network} ({expected}).\",\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 batches transactions through the\n * wallet's variadic `solana:signTransaction` feature, requires byte-identical\n * returned messages, and recovers THIS account's verified signatures.\n *\n * @see {@link signerFromWalletAccount}\n * @module signers/wallet-account\n */\nimport {\n address,\n getPublicKeyFromAddress,\n getTransactionDecoder,\n getTransactionEncoder,\n verifySignature,\n type Address,\n type SignatureBytes,\n type Transaction,\n} from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type {\n ChainBoundTransactionSigner,\n SignerFromWalletAccountOptions,\n SolanaWalletNetwork,\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/** Map an AgenC provider network to the Wallet Standard chain identifier. */\nexport function walletStandardChainForNetwork(\n network: SolanaWalletNetwork,\n): string {\n return `solana:${network}`;\n}\n\n/** Resolve and validate the CAIP-2 chain forwarded to the wallet. */\nfunction resolveChain(\n account: WalletStandardAccountLike,\n options: SignerFromWalletAccountOptions,\n): string {\n const networkChain = options.network\n ? walletStandardChainForNetwork(options.network)\n : undefined;\n if (options.chain && networkChain && options.chain !== networkChain) {\n throw new Error(\n ts(\"signer.walletChainNetworkMismatch\", {\n chain: options.chain,\n network: options.network!,\n expected: networkChain,\n }),\n );\n }\n\n const solanaChains =\n account.chains?.filter((chain) => chain.startsWith(\"solana:\")) ?? [];\n const requested = options.chain ?? networkChain;\n const chain =\n requested ?? (solanaChains.length === 1 ? solanaChains[0] : undefined);\n if (!chain) {\n throw new Error(\n ts(\"signer.walletChainRequired\", {\n address: account.address,\n count: solanaChains.length,\n }),\n );\n }\n if (\n !chain.startsWith(\"solana:\") ||\n (account.chains !== undefined && !account.chains.includes(chain))\n ) {\n throw new Error(\n ts(\"signer.walletChainUnsupported\", {\n address: account.address,\n chain,\n }),\n );\n }\n return chain;\n}\n\nfunction bytesEqual(\n left: ArrayLike<number>,\n right: ArrayLike<number>,\n): boolean {\n if (left.length !== right.length) return false;\n for (let index = 0; index < left.length; index += 1) {\n if (left[index] !== right[index]) return false;\n }\n return true;\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 * The SDK client re-assembles and submits the ORIGINAL transaction. This bridge\n * therefore accepts only byte-identical returned message bytes and verifies the\n * extracted signature over them.\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): ChainBoundTransactionSigner {\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 let publicKeyPromise: ReturnType<typeof getPublicKeyFromAddress> | undefined;\n\n async function extractSignature(\n transaction: Transaction,\n signedTransaction: Uint8Array,\n ): Promise<SignatureBytes> {\n const signed = decoder.decode(signedTransaction);\n if (!bytesEqual(transaction.messageBytes, signed.messageBytes)) {\n throw new Error(\n ts(\"signer.walletModifiedTransaction\", { address: account.address }),\n );\n }\n const signature = signed.signatures[signerAddress];\n if (!signature) {\n throw new Error(ts(\"signer.walletNoSignature\", { address: account.address }));\n }\n publicKeyPromise ??= getPublicKeyFromAddress(signerAddress);\n const valid = await verifySignature(\n await publicKeyPromise,\n signature,\n transaction.messageBytes,\n );\n if (!valid) {\n throw new Error(\n ts(\"signer.walletInvalidSignature\", { address: account.address }),\n );\n }\n return signature as SignatureBytes;\n }\n\n return {\n address: signerAddress,\n chain,\n async signTransactions(transactions) {\n if (transactions.length === 0) return [];\n // Wallet Standard is variadic: one call preserves single-flight approval\n // behavior and output ordering.\n const outputs = await signTransaction(\n ...transactions.map((transaction) => ({\n account,\n chain,\n transaction: new Uint8Array(encoder.encode(transaction)),\n })),\n );\n if (outputs.length !== transactions.length) {\n throw new Error(\n ts(\"signer.walletResponseCount\", {\n got: outputs.length,\n expected: transactions.length,\n }),\n );\n }\n return Promise.all(\n outputs.map(async (output, index) => ({\n [signerAddress]: await extractSignature(\n transactions[index]!,\n output.signedTransaction,\n ),\n })),\n );\n },\n } satisfies ChainBoundTransactionSigner;\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 getPublicKeyFromAddress,\n getTransactionDecoder,\n getTransactionEncoder,\n verifySignature,\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\nfunction bytesEqual(\n left: ArrayLike<number>,\n right: ArrayLike<number>,\n): boolean {\n if (left.length !== right.length) return false;\n for (let index = 0; index < left.length; index += 1) {\n if (left[index] !== right[index]) return false;\n }\n return true;\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 let publicKeyPromise: ReturnType<typeof getPublicKeyFromAddress> | undefined;\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 if (!bytesEqual(transaction.messageBytes, signedTx.messageBytes)) {\n throw new Error(\n ts(\"signer.walletModifiedTransaction\", { address: signerAddress }),\n );\n }\n const signature = signedTx.signatures[signerAddress];\n if (!signature) {\n throw new Error(\n ts(\"signer.walletNoSignature\", { address: signerAddress }),\n );\n }\n publicKeyPromise ??= getPublicKeyFromAddress(signerAddress);\n const valid = await verifySignature(\n await publicKeyPromise,\n signature,\n transaction.messageBytes,\n );\n if (!valid) {\n throw new Error(\n ts(\"signer.walletInvalidSignature\", { address: signerAddress }),\n );\n }\n return signature as SignatureBytes;\n }\n\n return {\n address: signerAddress,\n async signTransactions(transactions) {\n const signatures = [];\n // Legacy wallet-adapter is unary and many implementations are\n // single-flight. Serialize prompts in input order.\n for (const transaction of transactions) {\n signatures.push({\n [signerAddress]: await signOne(transaction),\n });\n }\n return signatures;\n },\n } satisfies TransactionSigner;\n}\n","/**\n * Embedded / walletless → kit `TransactionSigner` bridge (PLAN_2 D-1).\n *\n * The \"no wallet, no SOL\" buyer path. A vendor-neutral\n * {@link EmbeddedWalletProvider} (Privy / Dynamic / Web3Auth — `[HUMAN]`-gated)\n * handles email/social login + key custody; this module lifts a live\n * {@link EmbeddedWalletConnection} into the kit {@link TransactionSigner} the SDK\n * client consumes. As with the Wallet Standard bridge, the result is a PARTIAL\n * signer — the vendor signs, the SDK client's transport broadcasts.\n *\n * @see {@link signerFromEmbeddedWallet}\n * @see {@link createMockEmbeddedWallet} — the local-keypair test adapter.\n * @module signers/embedded-wallet\n */\nimport { address, type SignatureBytes, type Transaction } from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type {\n EmbeddedWalletConnection,\n TransactionSigner,\n} from \"./types.js\";\n\n/**\n * Bridge a CONNECTED embedded-wallet connection into a kit\n * {@link TransactionSigner}.\n *\n * Call this AFTER `provider.connect()` resolves — it needs the live\n * {@link EmbeddedWalletConnection} (address + `signTransactions`). The hooks\n * layer (`useWalletSigner`) is expected to own the connect lifecycle and call\n * this once a connection exists.\n *\n * @param connection - A live embedded-wallet connection.\n * @returns A kit {@link TransactionSigner} usable as `config.signer`.\n *\n * @example\n * ```ts\n * const connection = await provider.connect(); // vendor login\n * const signer = signerFromEmbeddedWallet(connection);\n * // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.\n * ```\n */\nexport function signerFromEmbeddedWallet(\n connection: EmbeddedWalletConnection,\n): TransactionSigner {\n const signerAddress = address(connection.address);\n\n return {\n address: signerAddress,\n async signTransactions(transactions: readonly Transaction[]) {\n const signatures: readonly SignatureBytes[] =\n await connection.signTransactions(transactions);\n if (signatures.length !== transactions.length) {\n throw new Error(\n ts(\"signer.embeddedSignatureCount\", {\n expected: transactions.length,\n got: signatures.length,\n }),\n );\n }\n return transactions.map((_, i) => ({\n [signerAddress]: signatures[i] as SignatureBytes,\n }));\n },\n } satisfies TransactionSigner;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { useTaskGuarantee, useAgencContext, useHire, useWalletSigner } from './chunk-XLA7DARS.js';
1
+ import { useTaskGuarantee, useAgencContext, useHire, useWalletSigner } from './chunk-RG5JZ6JL.js';
2
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';
@@ -692,10 +692,11 @@ function HireCheckoutModal({
692
692
  return;
693
693
  }
694
694
  if (result && typeof result.then === "function") {
695
- void result.finally(() => {
695
+ const releaseLatch = () => {
696
696
  submittingRef.current = false;
697
697
  setSubmitting(false);
698
- });
698
+ };
699
+ void Promise.resolve(result).then(releaseLatch, releaseLatch);
699
700
  }
700
701
  }, [onConfirm]);
701
702
  const confirmDisabled = !connected || pending || submitting;
@@ -1321,5 +1322,5 @@ function PoweredByAgenC({
1321
1322
  }
1322
1323
 
1323
1324
  export { AGENC_THEME_CLASS, AGENC_TOKENS_CSS_PATH, Badge, Button, COMPONENT_CATALOG, DEFAULT_TRUST_HREF, DisputeBanner, EN_COMPONENT_STRINGS, GuaranteedBadge, 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 };
1324
- //# sourceMappingURL=chunk-JVXGNW3Q.js.map
1325
- //# sourceMappingURL=chunk-JVXGNW3Q.js.map
1325
+ //# sourceMappingURL=chunk-CDDHUFMG.js.map
1326
+ //# sourceMappingURL=chunk-CDDHUFMG.js.map