@tetsuo-ai/marketplace-react 0.4.1 → 0.6.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.
- package/CHANGELOG.md +65 -0
- package/README.md +97 -51
- package/dist/chunk-7NKRSPPN.js +227 -0
- package/dist/chunk-7NKRSPPN.js.map +1 -0
- package/dist/{chunk-JVXGNW3Q.js → chunk-CDDHUFMG.js} +6 -5
- package/dist/chunk-CDDHUFMG.js.map +1 -0
- package/dist/chunk-FIDFPM5A.cjs +40 -0
- package/dist/chunk-FIDFPM5A.cjs.map +1 -0
- package/dist/chunk-IJKWKY4H.cjs +1370 -0
- package/dist/chunk-IJKWKY4H.cjs.map +1 -0
- package/dist/chunk-JTSG5FGC.cjs +397 -0
- package/dist/chunk-JTSG5FGC.cjs.map +1 -0
- package/dist/chunk-ONC6L3IX.cjs +97 -0
- package/dist/chunk-ONC6L3IX.cjs.map +1 -0
- package/dist/chunk-R76EUYDI.cjs +233 -0
- package/dist/chunk-R76EUYDI.cjs.map +1 -0
- package/dist/{chunk-XLA7DARS.js → chunk-RG5JZ6JL.js} +159 -36
- package/dist/chunk-RG5JZ6JL.js.map +1 -0
- package/dist/components/index.cjs +158 -1594
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +2 -2
- package/dist/hooks/index.cjs +656 -509
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +63 -29
- package/dist/hooks/index.d.ts +63 -29
- package/dist/hooks/index.js +619 -196
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-CmVz0OOm.d.ts → index-BAyr1ODZ.d.ts} +28 -3
- package/dist/{index-DAZzhuO4.d.cts → index-C20NVU7_.d.cts} +28 -3
- package/dist/index.cjs +284 -1833
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +64 -4
- package/dist/index.js.map +1 -1
- package/dist/signers/index.cjs +22 -161
- package/dist/signers/index.cjs.map +1 -1
- package/dist/signers/index.d.cts +16 -11
- package/dist/signers/index.d.ts +16 -11
- package/dist/signers/index.js +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/theme/agenc-tailwind-preset.cjs +134 -108
- package/dist/{types-jvISR6bc.d.cts → types-B10rndEI.d.cts} +16 -7
- package/dist/{types-jvISR6bc.d.ts → types-B10rndEI.d.ts} +16 -7
- package/dist/{useAgentTrackRecord-DPt3SfYz.d.cts → useAgentTrackRecord-Ch7gHTFj.d.cts} +1 -1
- package/dist/{useAgentTrackRecord-DPt3SfYz.d.ts → useAgentTrackRecord-Ch7gHTFj.d.ts} +1 -1
- package/package.json +7 -4
- package/src/components/HireCheckoutModal.tsx +5 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/internal.ts +178 -24
- package/src/hooks/useAgentTrackRecord.ts +5 -2
- package/src/hooks/useCompletionBond.ts +56 -21
- package/src/hooks/useDispute.ts +46 -9
- package/src/hooks/useHire.ts +113 -23
- package/src/hooks/useHumanlessHireFlow.ts +335 -115
- package/src/hooks/useListing.ts +2 -2
- package/src/hooks/useListings.ts +2 -2
- package/src/hooks/useRateHire.ts +32 -5
- package/src/hooks/useReferrerEarnings.ts +4 -1
- package/src/hooks/useSubmissionReview.ts +95 -32
- package/src/hooks/useTaskActivation.ts +51 -9
- package/src/hooks/useTaskGuarantee.ts +4 -1
- package/src/hooks/useTaskLifecycle.ts +104 -24
- package/src/hooks/useTaskStatus.ts +121 -26
- package/src/hooks/useTaskWork.ts +76 -12
- package/src/hooks/useWalletSigner.ts +11 -16
- package/src/index.ts +3 -0
- package/src/provider/AgencProvider.tsx +95 -3
- package/src/provider/referrer.ts +1 -1
- package/src/signers/README.md +13 -7
- package/src/signers/index.ts +6 -1
- package/src/signers/strings.ts +13 -1
- package/src/signers/types.ts +16 -5
- package/src/signers/wallet-account.ts +115 -29
- package/src/signers/wallet-adapter.ts +38 -4
- package/src/theme/agenc-tailwind-preset.cjs +134 -108
- package/src/types.ts +27 -1
- package/dist/chunk-JVXGNW3Q.js.map +0 -1
- package/dist/chunk-ON6XR4XO.js +0 -128
- package/dist/chunk-ON6XR4XO.js.map +0 -1
- package/dist/chunk-XLA7DARS.js.map +0 -1
package/src/hooks/useHire.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ## REFERRER SETTLEMENT
|
|
9
9
|
*
|
|
10
|
-
* The full
|
|
10
|
+
* The full protocol surface supports a demand-side referrer leg. This hook:
|
|
11
11
|
* - reads `resolveReferrerCapability()` from context BEFORE building the hire;
|
|
12
12
|
* - when `live === true`, spreads the validated provider referrer into the hire
|
|
13
13
|
* input for both standard and humanless hires;
|
|
@@ -25,7 +25,8 @@ import type { Address } from "../types.js";
|
|
|
25
25
|
import {
|
|
26
26
|
requireClient,
|
|
27
27
|
resolveReferrerArgs,
|
|
28
|
-
|
|
28
|
+
snapshotFixedBytes32,
|
|
29
|
+
stabilizeSelectedTransactionSigner,
|
|
29
30
|
withoutReferrerArgs,
|
|
30
31
|
} from "./internal.js";
|
|
31
32
|
import {
|
|
@@ -110,6 +111,26 @@ export interface UseHireResult {
|
|
|
110
111
|
reset: () => void;
|
|
111
112
|
}
|
|
112
113
|
|
|
114
|
+
type HireCreator = Parameters<
|
|
115
|
+
typeof facadeNs.hireFromListingHumanless
|
|
116
|
+
>[0]["creator"];
|
|
117
|
+
type HireAuthority = Parameters<
|
|
118
|
+
typeof facadeNs.hireFromListing
|
|
119
|
+
>[0]["authority"];
|
|
120
|
+
|
|
121
|
+
interface HireMutationVariables {
|
|
122
|
+
client: ReturnType<typeof requireClient>;
|
|
123
|
+
input: AnyHireInput;
|
|
124
|
+
creator: HireCreator;
|
|
125
|
+
creatorAddress: Address;
|
|
126
|
+
authority?: HireAuthority;
|
|
127
|
+
orchestrationRpcUrl: ReturnType<
|
|
128
|
+
typeof useAgencContext
|
|
129
|
+
>["orchestrationRpcUrl"];
|
|
130
|
+
orchestrationRpc: ReturnType<typeof useAgencContext>["orchestrationRpc"];
|
|
131
|
+
referral: ReturnType<typeof resolveReferrerArgs>;
|
|
132
|
+
}
|
|
133
|
+
|
|
113
134
|
/**
|
|
114
135
|
* The hire hook.
|
|
115
136
|
*
|
|
@@ -120,21 +141,32 @@ export interface UseHireResult {
|
|
|
120
141
|
* const { hire, status, taskPda, error } = useHire();
|
|
121
142
|
* await hire({
|
|
122
143
|
* listing, creatorAgent, taskId, expectedPrice: price, expectedVersion: 1n,
|
|
123
|
-
* listingSpecHash,
|
|
144
|
+
* listingSpecHash, taskJobSpecHash,
|
|
124
145
|
* });
|
|
125
146
|
* ```
|
|
126
147
|
*/
|
|
127
148
|
export function useHire(): UseHireResult {
|
|
128
149
|
const ctx = useAgencContext();
|
|
129
150
|
|
|
130
|
-
const mutation = useMutation<HireResult, Error,
|
|
131
|
-
mutationFn: async (
|
|
132
|
-
|
|
151
|
+
const mutation = useMutation<HireResult, Error, HireMutationVariables>({
|
|
152
|
+
mutationFn: async ({
|
|
153
|
+
client,
|
|
154
|
+
input,
|
|
155
|
+
creator,
|
|
156
|
+
creatorAddress,
|
|
157
|
+
authority,
|
|
158
|
+
orchestrationRpcUrl,
|
|
159
|
+
orchestrationRpc,
|
|
160
|
+
referral,
|
|
161
|
+
}): Promise<HireResult> => {
|
|
162
|
+
const { referrerArgs, referrerInjected } = referral;
|
|
133
163
|
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
const
|
|
137
|
-
|
|
164
|
+
// Derive exactly once from the synchronously captured signer identity and
|
|
165
|
+
// detached task id. The same PDA is returned after the funded await.
|
|
166
|
+
const [taskPda] = await findTaskPda({
|
|
167
|
+
creator: creatorAddress,
|
|
168
|
+
taskId: input.taskId,
|
|
169
|
+
});
|
|
138
170
|
|
|
139
171
|
// P1.2: the hire gate names an explicit `moderator` (the caller's trust
|
|
140
172
|
// decision) and needs the roster-entry PDA when that moderator is a
|
|
@@ -150,21 +182,21 @@ export function useHire(): UseHireResult {
|
|
|
150
182
|
listingSpecHash !== undefined
|
|
151
183
|
) {
|
|
152
184
|
moderationArgs = await resolveHireListingModerationAccounts({
|
|
153
|
-
rpcUrl:
|
|
185
|
+
rpcUrl: orchestrationRpcUrl,
|
|
186
|
+
...(orchestrationRpc === null ? {} : { rpc: orchestrationRpc }),
|
|
154
187
|
listing: input.listing,
|
|
155
188
|
listingSpecHash,
|
|
156
189
|
moderator: input.moderator,
|
|
157
190
|
});
|
|
158
191
|
}
|
|
159
192
|
|
|
160
|
-
const creator = input.creator ?? client.signer;
|
|
161
193
|
let signature: string;
|
|
162
194
|
|
|
163
195
|
if (input.humanless === true) {
|
|
164
196
|
// Storefront-visitor hire: no creator agent; CreatorReview-pinned, so
|
|
165
197
|
// it settles via the buyer review path (useSubmissionReview).
|
|
166
198
|
const result = await client.hireFromListingHumanless({
|
|
167
|
-
...
|
|
199
|
+
...input,
|
|
168
200
|
...moderationArgs,
|
|
169
201
|
creator,
|
|
170
202
|
...referrerArgs,
|
|
@@ -172,9 +204,11 @@ export function useHire(): UseHireResult {
|
|
|
172
204
|
signature = result.signature;
|
|
173
205
|
} else {
|
|
174
206
|
// Standard hire: authority == creator == buyer (the buyer has an agent).
|
|
175
|
-
|
|
207
|
+
if (authority === undefined) {
|
|
208
|
+
throw new Error("useHire: missing snapshotted authority");
|
|
209
|
+
}
|
|
176
210
|
const result = await client.hireFromListing({
|
|
177
|
-
...
|
|
211
|
+
...input,
|
|
178
212
|
...moderationArgs,
|
|
179
213
|
authority,
|
|
180
214
|
creator,
|
|
@@ -183,19 +217,75 @@ export function useHire(): UseHireResult {
|
|
|
183
217
|
signature = result.signature;
|
|
184
218
|
}
|
|
185
219
|
|
|
186
|
-
// Derive the minted Task PDA from (creator, taskId).
|
|
187
|
-
const [taskPda] = await findTaskPda({
|
|
188
|
-
creator: signerAddress(creator),
|
|
189
|
-
taskId: input.taskId,
|
|
190
|
-
});
|
|
191
|
-
|
|
192
220
|
return { signature, taskPda, referrerInjected };
|
|
193
221
|
},
|
|
194
222
|
});
|
|
195
223
|
|
|
196
224
|
const hire = useCallback(
|
|
197
|
-
(input: AnyHireInput) =>
|
|
198
|
-
|
|
225
|
+
async (input: AnyHireInput) => {
|
|
226
|
+
const client = requireClient(ctx.client);
|
|
227
|
+
const detachedInput = withoutReferrerArgs(input) as AnyHireInput;
|
|
228
|
+
const snapshottedInput = {
|
|
229
|
+
...detachedInput,
|
|
230
|
+
taskId: snapshotFixedBytes32(detachedInput.taskId, "useHire: taskId"),
|
|
231
|
+
...(detachedInput.listingSpecHash === undefined
|
|
232
|
+
? {}
|
|
233
|
+
: {
|
|
234
|
+
listingSpecHash: snapshotFixedBytes32(
|
|
235
|
+
detachedInput.listingSpecHash,
|
|
236
|
+
"useHire: listingSpecHash",
|
|
237
|
+
),
|
|
238
|
+
}),
|
|
239
|
+
...(detachedInput.taskJobSpecHash === undefined
|
|
240
|
+
? {}
|
|
241
|
+
: {
|
|
242
|
+
taskJobSpecHash: snapshotFixedBytes32(
|
|
243
|
+
detachedInput.taskJobSpecHash,
|
|
244
|
+
"useHire: taskJobSpecHash",
|
|
245
|
+
),
|
|
246
|
+
}),
|
|
247
|
+
} as unknown as AnyHireInput;
|
|
248
|
+
|
|
249
|
+
// Stabilize the same signer objects the SDK will place in the
|
|
250
|
+
// instruction. The SDK helper canonicalizes and permanently locks the
|
|
251
|
+
// address while preserving Kit's fee-payer/signer object identity and
|
|
252
|
+
// any unrelated stateful wallet/session fields.
|
|
253
|
+
const clientSigner = stabilizeSelectedTransactionSigner(client.signer);
|
|
254
|
+
const creator = stabilizeSelectedTransactionSigner(
|
|
255
|
+
clientSigner,
|
|
256
|
+
detachedInput.creator,
|
|
257
|
+
);
|
|
258
|
+
const creatorAddress = creator.address;
|
|
259
|
+
let authority: HireAuthority | undefined;
|
|
260
|
+
if (detachedInput.humanless !== true) {
|
|
261
|
+
const selectedAuthority = stabilizeSelectedTransactionSigner(
|
|
262
|
+
clientSigner,
|
|
263
|
+
detachedInput.authority,
|
|
264
|
+
);
|
|
265
|
+
// Creator and authority may be two wallet-adapter wrappers for the
|
|
266
|
+
// same non-fee-payer account. Kit requires one object identity per
|
|
267
|
+
// address across every signer role, so make creator the canonical
|
|
268
|
+
// representative for that address while preserving distinct signers.
|
|
269
|
+
authority = stabilizeSelectedTransactionSigner(
|
|
270
|
+
creator,
|
|
271
|
+
selectedAuthority,
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return mutation.mutateAsync({
|
|
276
|
+
client,
|
|
277
|
+
input: snapshottedInput,
|
|
278
|
+
creator,
|
|
279
|
+
creatorAddress,
|
|
280
|
+
...(authority === undefined ? {} : { authority }),
|
|
281
|
+
orchestrationRpcUrl: ctx.orchestrationRpcUrl,
|
|
282
|
+
orchestrationRpc: ctx.orchestrationRpc,
|
|
283
|
+
// Resolve fresh at this synchronous enqueue boundary so provider
|
|
284
|
+
// changes cannot alter an already accepted hire intent.
|
|
285
|
+
referral: resolveReferrerArgs(ctx),
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
[ctx, mutation],
|
|
199
289
|
);
|
|
200
290
|
|
|
201
291
|
const status: HireStatus = useMemo(() => {
|