@tetsuo-ai/marketplace-react 0.3.2 → 0.4.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 +22 -0
- package/dist/{chunk-ZAMIL27X.js → chunk-BNILOX3O.js} +3 -3
- package/dist/{chunk-ZAMIL27X.js.map → chunk-BNILOX3O.js.map} +1 -1
- package/dist/{chunk-2Y6JN2VZ.js → chunk-BTAVED7S.js} +87 -4
- package/dist/chunk-BTAVED7S.js.map +1 -0
- package/dist/components/index.cjs +55 -0
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +2 -2
- package/dist/hooks/index.cjs +117 -40
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +14 -1
- package/dist/hooks/index.d.ts +14 -1
- package/dist/hooks/index.js +38 -44
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +54 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/package.json +2 -2
- package/src/hooks/moderation-attestor.ts +176 -57
- package/src/hooks/useHire.ts +27 -0
- package/src/hooks/useHumanlessHireFlow.ts +74 -17
- package/src/hooks/useTaskActivation.ts +19 -13
- package/dist/chunk-2Y6JN2VZ.js.map +0 -1
package/dist/hooks/index.d.cts
CHANGED
|
@@ -214,13 +214,26 @@ declare function useTaskActivation(taskPda: Parameters<typeof facade.setTaskJobS
|
|
|
214
214
|
type HumanlessHireFlowPhase = "idle" | "hiring" | "moderating" | "activating" | "activated" | "error";
|
|
215
215
|
type HumanlessHireFlowStatus = MutationStatus;
|
|
216
216
|
type HumanlessHireFlowHireInput = Omit<HumanlessHireInput, "humanless" | "creator" | "referrer" | "referrerFeeBps">;
|
|
217
|
-
type HumanlessHireFlowActivationInput = Omit<TaskActivationInput, "creator" | "jobSpecHash" | "jobSpecUri"
|
|
217
|
+
type HumanlessHireFlowActivationInput = Omit<TaskActivationInput, "creator" | "jobSpecHash" | "jobSpecUri" | "moderator"> & {
|
|
218
|
+
/**
|
|
219
|
+
* Override the activation `moderator` (P1.2). Defaults to the `moderator`
|
|
220
|
+
* returned by `hostAndModerateJobSpec` — the attestation service that
|
|
221
|
+
* signed the task moderation is whose record the publish gate consumes.
|
|
222
|
+
*/
|
|
223
|
+
moderator?: TaskActivationInput["moderator"];
|
|
224
|
+
};
|
|
218
225
|
type HumanlessHireFlowCreator = HumanlessHireInput["creator"];
|
|
219
226
|
type HumanlessHireFlowJobSpecHash = Parameters<typeof facade.setTaskJobSpec>[0]["jobSpecHash"];
|
|
220
227
|
interface HumanlessHireFlowModerationResult {
|
|
221
228
|
jobSpecHash: HumanlessHireFlowJobSpecHash;
|
|
222
229
|
jobSpecUri: string;
|
|
223
230
|
moderationAttested: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* The pubkey that signed/recorded the task attestation (P1.2) — the
|
|
233
|
+
* attestation service's signer (e.g. attest.agenc.ag `GET /v1/info` →
|
|
234
|
+
* `moderator`). Names whose record the publish gate consumes.
|
|
235
|
+
*/
|
|
236
|
+
moderator: Address;
|
|
224
237
|
moderation?: unknown;
|
|
225
238
|
}
|
|
226
239
|
interface HumanlessHireFlowHostInput<TJobSpec> {
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -214,13 +214,26 @@ declare function useTaskActivation(taskPda: Parameters<typeof facade.setTaskJobS
|
|
|
214
214
|
type HumanlessHireFlowPhase = "idle" | "hiring" | "moderating" | "activating" | "activated" | "error";
|
|
215
215
|
type HumanlessHireFlowStatus = MutationStatus;
|
|
216
216
|
type HumanlessHireFlowHireInput = Omit<HumanlessHireInput, "humanless" | "creator" | "referrer" | "referrerFeeBps">;
|
|
217
|
-
type HumanlessHireFlowActivationInput = Omit<TaskActivationInput, "creator" | "jobSpecHash" | "jobSpecUri"
|
|
217
|
+
type HumanlessHireFlowActivationInput = Omit<TaskActivationInput, "creator" | "jobSpecHash" | "jobSpecUri" | "moderator"> & {
|
|
218
|
+
/**
|
|
219
|
+
* Override the activation `moderator` (P1.2). Defaults to the `moderator`
|
|
220
|
+
* returned by `hostAndModerateJobSpec` — the attestation service that
|
|
221
|
+
* signed the task moderation is whose record the publish gate consumes.
|
|
222
|
+
*/
|
|
223
|
+
moderator?: TaskActivationInput["moderator"];
|
|
224
|
+
};
|
|
218
225
|
type HumanlessHireFlowCreator = HumanlessHireInput["creator"];
|
|
219
226
|
type HumanlessHireFlowJobSpecHash = Parameters<typeof facade.setTaskJobSpec>[0]["jobSpecHash"];
|
|
220
227
|
interface HumanlessHireFlowModerationResult {
|
|
221
228
|
jobSpecHash: HumanlessHireFlowJobSpecHash;
|
|
222
229
|
jobSpecUri: string;
|
|
223
230
|
moderationAttested: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* The pubkey that signed/recorded the task attestation (P1.2) — the
|
|
233
|
+
* attestation service's signer (e.g. attest.agenc.ag `GET /v1/info` →
|
|
234
|
+
* `moderator`). Names whose record the publish gate consumes.
|
|
235
|
+
*/
|
|
236
|
+
moderator: Address;
|
|
224
237
|
moderation?: unknown;
|
|
225
238
|
}
|
|
226
239
|
interface HumanlessHireFlowHostInput<TJobSpec> {
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ReadTransportUnsupportedError } from '../chunk-AKPPKMQ2.js';
|
|
2
|
-
import { useAgencContext, queryKeys, pdaKey, requireClient, mutationStatusOf, resolveReferrerArgs, withoutReferrerArgs, signerAddress } from '../chunk-
|
|
3
|
-
export { QUERY_KEY_ROOT, queryKeys, useHire, useWalletSigner } from '../chunk-
|
|
2
|
+
import { useAgencContext, queryKeys, pdaKey, requireClient, resolveActivationModerationAccounts, mutationStatusOf, resolveReferrerArgs, withoutReferrerArgs, resolveHireListingModerationAccounts, signerAddress } from '../chunk-BTAVED7S.js';
|
|
3
|
+
export { QUERY_KEY_ROOT, queryKeys, useHire, useWalletSigner } from '../chunk-BTAVED7S.js';
|
|
4
4
|
import { t } from '../chunk-H6PJIDQR.js';
|
|
5
5
|
import { useQuery, useMutation } from '@tanstack/react-query';
|
|
6
6
|
import { useState, useMemo, useCallback, useRef, useEffect } from 'react';
|
|
7
|
-
import { TaskStatus, facade, findTaskPda
|
|
8
|
-
import { createSolanaRpc } from '@solana/kit';
|
|
7
|
+
import { TaskStatus, facade, findTaskPda } from '@tetsuo-ai/marketplace-sdk';
|
|
9
8
|
|
|
10
9
|
var DEFAULT_PAGE_SIZE = 12;
|
|
11
10
|
function useListings(filter, options) {
|
|
@@ -261,50 +260,21 @@ function useSubmissionReview(taskPda) {
|
|
|
261
260
|
}
|
|
262
261
|
};
|
|
263
262
|
}
|
|
264
|
-
async function resolveActivationModerationAttestor(input) {
|
|
265
|
-
try {
|
|
266
|
-
const rpc = input.rpc ?? (input.rpcUrl ? createSolanaRpc(input.rpcUrl) : null);
|
|
267
|
-
if (!rpc) return void 0;
|
|
268
|
-
const [taskModerationPda] = await findTaskModerationPda({
|
|
269
|
-
task: input.task,
|
|
270
|
-
jobSpecHash: input.jobSpecHash
|
|
271
|
-
});
|
|
272
|
-
const taskModeration = await fetchMaybeTaskModeration(
|
|
273
|
-
rpc,
|
|
274
|
-
taskModerationPda
|
|
275
|
-
);
|
|
276
|
-
if (!taskModeration.exists) return void 0;
|
|
277
|
-
const [moderationConfigPda] = await findModerationConfigPda();
|
|
278
|
-
const moderationConfig = await fetchMaybeModerationConfig(
|
|
279
|
-
rpc,
|
|
280
|
-
moderationConfigPda
|
|
281
|
-
);
|
|
282
|
-
if (moderationConfig.exists && taskModeration.data.moderator === moderationConfig.data.moderationAuthority) {
|
|
283
|
-
return void 0;
|
|
284
|
-
}
|
|
285
|
-
const [rosterPda] = await findModerationAttestorPda({
|
|
286
|
-
attestor: taskModeration.data.moderator
|
|
287
|
-
});
|
|
288
|
-
return rosterPda;
|
|
289
|
-
} catch {
|
|
290
|
-
return void 0;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// src/hooks/useTaskActivation.ts
|
|
295
263
|
function useTaskActivation(taskPda) {
|
|
296
264
|
const ctx = useAgencContext();
|
|
297
265
|
const mutation = useMutation({
|
|
298
266
|
mutationFn: async (input) => {
|
|
299
267
|
const client = requireClient(ctx.client);
|
|
300
|
-
const
|
|
268
|
+
const callerResolved = input.moderationAttestor !== void 0 || input.moderatorIsAttestor !== void 0 || input.taskModeration !== void 0;
|
|
269
|
+
const resolved = callerResolved ? {} : await resolveActivationModerationAccounts({
|
|
301
270
|
rpcUrl: ctx.rpcUrl,
|
|
302
271
|
task: taskPda,
|
|
303
|
-
jobSpecHash: input.jobSpecHash
|
|
272
|
+
jobSpecHash: input.jobSpecHash,
|
|
273
|
+
moderator: input.moderator
|
|
304
274
|
});
|
|
305
275
|
const { signature } = await client.setTaskJobSpec({
|
|
306
276
|
...input,
|
|
307
|
-
...
|
|
277
|
+
...resolved,
|
|
308
278
|
task: taskPda,
|
|
309
279
|
creator: input.creator ?? client.signer
|
|
310
280
|
});
|
|
@@ -351,7 +321,16 @@ function validateModerationResult(result) {
|
|
|
351
321
|
"Task moderation returned an empty jobSpecUri; activation was not signed."
|
|
352
322
|
);
|
|
353
323
|
}
|
|
354
|
-
|
|
324
|
+
if (typeof result.moderator !== "string" || !result.moderator.trim()) {
|
|
325
|
+
throw new Error(
|
|
326
|
+
"Task moderation returned no moderator pubkey; activation was not signed."
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
jobSpecHash: result.jobSpecHash,
|
|
331
|
+
jobSpecUri,
|
|
332
|
+
moderator: result.moderator
|
|
333
|
+
};
|
|
355
334
|
}
|
|
356
335
|
function useHumanlessHireFlow() {
|
|
357
336
|
const ctx = useAgencContext();
|
|
@@ -367,8 +346,19 @@ function useHumanlessHireFlow() {
|
|
|
367
346
|
setPhase("hiring");
|
|
368
347
|
setProgress(emptyProgress());
|
|
369
348
|
try {
|
|
349
|
+
const hireListingSpecHash = input.hire.listingSpecHash;
|
|
350
|
+
let hireModerationArgs = {};
|
|
351
|
+
if (input.hire.moderationAttestor === void 0 && input.hire.moderatorIsAttestor === void 0 && input.hire.listingModeration === void 0 && hireListingSpecHash !== void 0) {
|
|
352
|
+
hireModerationArgs = await resolveHireListingModerationAccounts({
|
|
353
|
+
rpcUrl: ctx.rpcUrl,
|
|
354
|
+
listing: input.hire.listing,
|
|
355
|
+
listingSpecHash: hireListingSpecHash,
|
|
356
|
+
moderator: input.hire.moderator
|
|
357
|
+
});
|
|
358
|
+
}
|
|
370
359
|
const hireResult = await client.hireFromListingHumanless({
|
|
371
360
|
...hireInput,
|
|
361
|
+
...hireModerationArgs,
|
|
372
362
|
creator,
|
|
373
363
|
...referrerArgs
|
|
374
364
|
});
|
|
@@ -391,25 +381,29 @@ function useHumanlessHireFlow() {
|
|
|
391
381
|
hireSignature: hireResult.signature,
|
|
392
382
|
referrerInjected
|
|
393
383
|
});
|
|
394
|
-
const { jobSpecHash, jobSpecUri } = validateModerationResult(moderation);
|
|
384
|
+
const { jobSpecHash, jobSpecUri, moderator } = validateModerationResult(moderation);
|
|
395
385
|
setProgress((current) => ({
|
|
396
386
|
...current,
|
|
397
387
|
jobSpecHash,
|
|
398
388
|
jobSpecUri
|
|
399
389
|
}));
|
|
400
390
|
setPhase("activating");
|
|
401
|
-
const
|
|
391
|
+
const activationModerator = input.activation?.moderator ?? moderator;
|
|
392
|
+
const activationCallerResolved = input.activation?.moderationAttestor !== void 0 || input.activation?.moderatorIsAttestor !== void 0 || input.activation?.taskModeration !== void 0;
|
|
393
|
+
const activationModerationArgs = activationCallerResolved ? {} : await resolveActivationModerationAccounts({
|
|
402
394
|
rpcUrl: ctx.rpcUrl,
|
|
403
395
|
task: taskPda,
|
|
404
|
-
jobSpecHash
|
|
396
|
+
jobSpecHash,
|
|
397
|
+
moderator: activationModerator
|
|
405
398
|
});
|
|
406
399
|
const activationResult = await client.setTaskJobSpec({
|
|
407
400
|
...input.activation ?? {},
|
|
408
|
-
...
|
|
401
|
+
...activationModerationArgs,
|
|
409
402
|
task: taskPda,
|
|
410
403
|
creator,
|
|
411
404
|
jobSpecHash,
|
|
412
|
-
jobSpecUri
|
|
405
|
+
jobSpecUri,
|
|
406
|
+
moderator: activationModerator
|
|
413
407
|
});
|
|
414
408
|
const result = {
|
|
415
409
|
taskPda,
|