@tetsuo-ai/marketplace-react 0.1.1 → 0.3.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 +33 -3
- package/README.md +50 -20
- package/dist/{chunk-ABS77JB2.js → chunk-D2TDU3TJ.js} +3 -3
- package/dist/{chunk-ABS77JB2.js.map → chunk-D2TDU3TJ.js.map} +1 -1
- package/dist/{chunk-GN5DYVN5.js → chunk-ECU7HGO3.js} +6 -5
- package/dist/chunk-ECU7HGO3.js.map +1 -0
- package/dist/{chunk-YORZNYZZ.js → chunk-FAIRTAIB.js} +53 -17
- package/dist/chunk-FAIRTAIB.js.map +1 -0
- package/dist/{chunk-5OTKSRHM.js → chunk-MNJ2EQDJ.js} +3 -3
- package/dist/{chunk-5OTKSRHM.js.map → chunk-MNJ2EQDJ.js.map} +1 -1
- package/dist/{chunk-A7ETZFNH.js → chunk-WJUVTFJ7.js} +6 -6
- package/dist/chunk-WJUVTFJ7.js.map +1 -0
- package/dist/components/index.cjs +47 -16
- 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 +3 -3
- package/dist/hooks/index.cjs +350 -28
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +160 -36
- package/dist/hooks/index.d.ts +160 -36
- package/dist/hooks/index.js +299 -19
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-zLJX8XdK.d.ts → index-C9R3B80j.d.ts} +29 -37
- package/dist/{index-DUsGVhDz.d.cts → index-CTTh1ZPg.d.cts} +29 -37
- package/dist/index.cjs +68 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -19
- package/dist/index.d.ts +10 -19
- package/dist/index.js +17 -12
- package/dist/index.js.map +1 -1
- package/dist/signers/index.cjs +4 -3
- package/dist/signers/index.cjs.map +1 -1
- package/dist/signers/index.js +2 -2
- package/dist/{useAgentTrackRecord-BLf1nrbu.d.cts → useAgentTrackRecord-BCvRHYM2.d.cts} +7 -7
- package/dist/{useAgentTrackRecord-BLf1nrbu.d.ts → useAgentTrackRecord-BCvRHYM2.d.ts} +7 -7
- package/package.json +4 -3
- package/src/components/HireButton.tsx +1 -2
- package/src/components/HireCheckoutModal.tsx +8 -9
- package/src/components/ReferrerDisclosure.tsx +8 -12
- package/src/components/strings.ts +2 -2
- package/src/hooks/index.ts +47 -4
- package/src/hooks/internal.ts +74 -2
- package/src/hooks/useHire.ts +30 -38
- package/src/hooks/useHumanlessHireFlow.ts +259 -0
- package/src/hooks/useRateHire.ts +52 -0
- package/src/hooks/useReferrerEarnings.ts +32 -33
- package/src/hooks/useTaskActivation.ts +58 -0
- package/src/hooks/useTaskLifecycle.ts +110 -0
- package/src/hooks/useTaskWork.ts +76 -0
- package/src/index.ts +2 -2
- package/src/provider/AgencProvider.tsx +3 -3
- package/src/provider/referrer.ts +24 -32
- package/src/strings/index.ts +5 -3
- package/src/types.ts +7 -10
- package/dist/chunk-A7ETZFNH.js.map +0 -1
- package/dist/chunk-GN5DYVN5.js.map +0 -1
- package/dist/chunk-YORZNYZZ.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode, ButtonHTMLAttributes, HTMLAttributes, RefObject } from 'react';
|
|
2
2
|
import { ListActiveListingsOptions, DecodedProgramAccount, ServiceListing, IndexerListing, IndexerHire, IndexerAgentTrackRecord, MarketplaceClient, ProgramAccountsTransport, CreateIndexerClientOptions, TaskStatus, fetchMaybeAgentVerification, AgentVerification } from '@tetsuo-ai/marketplace-sdk';
|
|
3
3
|
import { Address, TransactionSigner, Rpc, GetProgramAccountsApi } from '@solana/kit';
|
|
4
|
-
import {
|
|
4
|
+
import { f as HireStatus, b as AnyHireInput, i as ReviewStatus, c as DisputeStatus, a as AgentTrackRecord } from './useAgentTrackRecord-BCvRHYM2.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Shared types for `@tetsuo-ai/marketplace-react`.
|
|
@@ -88,8 +88,8 @@ interface CreateReadTransportConfig {
|
|
|
88
88
|
type AgencNetwork = "localnet" | "devnet" | "mainnet";
|
|
89
89
|
/**
|
|
90
90
|
* Referrer configuration. Accepted + validated + stored ALWAYS; injected into
|
|
91
|
-
* hires only when {@link ReferrerCapability.live} is true
|
|
92
|
-
*
|
|
91
|
+
* hires only when {@link ReferrerCapability.live} is true. See
|
|
92
|
+
* {@link resolveReferrerCapability}.
|
|
93
93
|
*/
|
|
94
94
|
interface ReferrerConfig {
|
|
95
95
|
/** Referrer wallet that earns the fee. Must be a valid base58 address. */
|
|
@@ -114,11 +114,9 @@ interface ValidatedReferrerConfig {
|
|
|
114
114
|
* The runtime answer to "can a referral fee actually be charged on this
|
|
115
115
|
* cluster?". Returned by `resolveReferrerCapability()`.
|
|
116
116
|
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* referrer is never injected, earnings hooks return a documented not-live
|
|
121
|
-
* state, and disclosure UI may still show the pending-support copy.
|
|
117
|
+
* Referrer settlement is live on the full 84-instruction surface. `live` is true
|
|
118
|
+
* when a validated provider referrer is configured. Aggregated earnings remain a
|
|
119
|
+
* separate indexer-gated read surface.
|
|
122
120
|
*/
|
|
123
121
|
interface ReferrerCapability {
|
|
124
122
|
/** Whether referral settlement is live on the target cluster. */
|
|
@@ -144,7 +142,7 @@ interface AgencProviderConfig {
|
|
|
144
142
|
rpcSubscriptionsUrl?: string;
|
|
145
143
|
/** Indexer connection — presence of `indexer.baseUrl` selects indexer-first. */
|
|
146
144
|
indexer?: IndexerConfig;
|
|
147
|
-
/** Referrer config (accepted + validated; injected
|
|
145
|
+
/** Referrer config (accepted + validated; injected into hire transactions). */
|
|
148
146
|
referrer?: ReferrerConfig;
|
|
149
147
|
/** Signer for write operations (the kit `TransactionSigner`). */
|
|
150
148
|
signer?: TransactionSigner;
|
|
@@ -179,8 +177,7 @@ interface AgencContextValue {
|
|
|
179
177
|
/** Validated referrer config, or `null` when none was supplied. */
|
|
180
178
|
referrer: ValidatedReferrerConfig | null;
|
|
181
179
|
/**
|
|
182
|
-
* Resolve whether
|
|
183
|
-
* gate). Today always `{ live: false, ... }`.
|
|
180
|
+
* Resolve whether this provider has a live referral-settlement config.
|
|
184
181
|
*/
|
|
185
182
|
resolveReferrerCapability(): ReferrerCapability;
|
|
186
183
|
}
|
|
@@ -223,8 +220,9 @@ declare const EN_STRINGS: {
|
|
|
223
220
|
readonly "provider.missingSigner": "No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.";
|
|
224
221
|
readonly "referrer.invalidWallet": "Referrer wallet is not a valid base58 Solana address: {wallet}.";
|
|
225
222
|
readonly "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.";
|
|
226
|
-
readonly "referrer.notLive": "
|
|
227
|
-
readonly "referrer.notLiveReason": "
|
|
223
|
+
readonly "referrer.notLive": "Referral fee is not active for this hire.";
|
|
224
|
+
readonly "referrer.notLiveReason": "No referrer is configured for this provider.";
|
|
225
|
+
readonly "referrer.earningsNotLiveReason": "Referral settlement is live, but aggregated referrer earnings are not yet exposed by the indexer.";
|
|
228
226
|
readonly "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().";
|
|
229
227
|
readonly "state.loading": "Loading…";
|
|
230
228
|
readonly "state.empty": "Nothing to show yet.";
|
|
@@ -481,7 +479,7 @@ declare const EN_COMPONENT_STRINGS: {
|
|
|
481
479
|
readonly "components.hire.moderationIssues": "Moderation issues found";
|
|
482
480
|
readonly "components.hire.notConnected": "Connect a wallet to hire.";
|
|
483
481
|
readonly "components.referrer.disclosure": "This site earns a referral fee.";
|
|
484
|
-
readonly "components.referrer.disclosurePending": "
|
|
482
|
+
readonly "components.referrer.disclosurePending": "Referral fee is not active for this hire.";
|
|
485
483
|
readonly "components.referrer.feeBps": "{bps} bps";
|
|
486
484
|
readonly "components.taskTimeline.title": "Task progress";
|
|
487
485
|
readonly "components.taskTimeline.empty": "No task to track yet.";
|
|
@@ -774,8 +772,8 @@ declare function ListingGrid({ listings, isLoading, error, hasMore, onLoadMore,
|
|
|
774
772
|
* `<HireCheckoutModal>` — the embeddable money path (PLAN_2 A3).
|
|
775
773
|
*
|
|
776
774
|
* The accessible, themable checkout dialog: it shows the price, the moderation
|
|
777
|
-
* attestation badge, the escrow-funding explanation, the referrer disclosure
|
|
778
|
-
*
|
|
775
|
+
* attestation badge, the escrow-funding explanation, the referrer disclosure,
|
|
776
|
+
* and walks the buyer through idle → confirming → funded /
|
|
779
777
|
* error confirmation states.
|
|
780
778
|
*
|
|
781
779
|
* ## Accessibility (STRUCTURAL — this is published to third parties)
|
|
@@ -785,12 +783,11 @@ declare function ListingGrid({ listings, isLoading, error, hasMore, onLoadMore,
|
|
|
785
783
|
* transaction), ARIA dialog roles, and live-region status announcements for
|
|
786
784
|
* the confirming/funded/error transitions.
|
|
787
785
|
*
|
|
788
|
-
* ##
|
|
786
|
+
* ## Referrer disclosure
|
|
789
787
|
*
|
|
790
|
-
* The disclosure renders when a `referrer` is configured
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
* only. Injection/earnings stay in the hooks, blocked on P6.2.
|
|
788
|
+
* The disclosure renders when a `referrer` is configured. The modal never
|
|
789
|
+
* computes earnings; injection lives in `useHire()` and aggregate earnings live
|
|
790
|
+
* in `useReferrerEarnings()`.
|
|
794
791
|
*
|
|
795
792
|
* ## Wiring
|
|
796
793
|
*
|
|
@@ -837,8 +834,8 @@ interface HireCheckoutModalProps {
|
|
|
837
834
|
*/
|
|
838
835
|
referrer?: ValidatedReferrerConfig | null;
|
|
839
836
|
/**
|
|
840
|
-
* Whether referral settlement is
|
|
841
|
-
*
|
|
837
|
+
* Whether referral settlement is active for this hire. Drives the disclosure
|
|
838
|
+
* copy only; never computes earnings.
|
|
842
839
|
*/
|
|
843
840
|
referrerLive?: boolean;
|
|
844
841
|
/** Whether a signer/wallet is connected (gates the confirm button). */
|
|
@@ -859,8 +856,7 @@ declare function HireCheckoutModal({ open, onClose, listing, onConfirm, status,
|
|
|
859
856
|
* This is the one component that binds the hooks directly: it renders a price-
|
|
860
857
|
* aware CTA that opens {@link HireCheckoutModal}, drives the hire through
|
|
861
858
|
* `useHire()`, resolves the signer via `useWalletSigner()`, and threads the
|
|
862
|
-
* provider's configured referrer +
|
|
863
|
-
* disclosure (never injecting a fee — the gate lives in `useHire`).
|
|
859
|
+
* provider's configured referrer + capability into the modal's disclosure.
|
|
864
860
|
*
|
|
865
861
|
* ## Why the caller supplies the hire input
|
|
866
862
|
*
|
|
@@ -917,14 +913,11 @@ declare function HireButton({ listing, buildHireInput, onHired, onViewTask, show
|
|
|
917
913
|
/**
|
|
918
914
|
* `<ReferrerDisclosure>` — the "this site earns a referral fee" notice.
|
|
919
915
|
*
|
|
920
|
-
* ##
|
|
916
|
+
* ## Referral disclosure
|
|
921
917
|
*
|
|
922
|
-
* Disclosure is
|
|
923
|
-
*
|
|
924
|
-
*
|
|
925
|
-
* informational and reads no earnings. The actual injection / earnings remain
|
|
926
|
-
* blocked on P6.2 (handled by the hooks, not here). This component only
|
|
927
|
-
* DISCLOSES the configured intent.
|
|
918
|
+
* Disclosure is informational and reads no earnings. When `live` is true it can
|
|
919
|
+
* use the present-tense fee copy. When `live` is false it shows neutral copy and
|
|
920
|
+
* does not imply a fee was charged.
|
|
928
921
|
*
|
|
929
922
|
* Render it only when a referrer is configured on the provider.
|
|
930
923
|
*
|
|
@@ -936,17 +929,16 @@ interface ReferrerDisclosureProps extends ThemableProps {
|
|
|
936
929
|
/** The validated referrer config (from the provider context). */
|
|
937
930
|
referrer: ValidatedReferrerConfig;
|
|
938
931
|
/**
|
|
939
|
-
* Whether the referral fee is
|
|
940
|
-
*
|
|
941
|
-
* no fee is implied as charged. Defaults to false.
|
|
932
|
+
* Whether the referral fee is active for this hire. When false, no fee is
|
|
933
|
+
* implied as charged. Defaults to false.
|
|
942
934
|
*/
|
|
943
935
|
live?: boolean;
|
|
944
936
|
/** Show the configured fee in bps alongside the disclosure. Default true. */
|
|
945
937
|
showFee?: boolean;
|
|
946
938
|
}
|
|
947
939
|
/**
|
|
948
|
-
* Disclose that the embedding site earns a referral fee
|
|
949
|
-
*
|
|
940
|
+
* Disclose that the embedding site earns a referral fee when referral settlement
|
|
941
|
+
* is active for the hire.
|
|
950
942
|
*/
|
|
951
943
|
declare function ReferrerDisclosure({ referrer, live, showFee, unstyled, className, }: ReferrerDisclosureProps): ReactNode;
|
|
952
944
|
|
package/dist/index.cjs
CHANGED
|
@@ -14,11 +14,12 @@ var EN_STRINGS = {
|
|
|
14
14
|
"provider.missingContext": "useAgencContext must be used within <AgencProvider>.",
|
|
15
15
|
"provider.missingWriteClient": "No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.",
|
|
16
16
|
"provider.missingSigner": "No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.",
|
|
17
|
-
// Referrer config validation
|
|
17
|
+
// Referrer config validation / capability surface.
|
|
18
18
|
"referrer.invalidWallet": "Referrer wallet is not a valid base58 Solana address: {wallet}.",
|
|
19
19
|
"referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
|
|
20
|
-
"referrer.notLive": "
|
|
21
|
-
"referrer.notLiveReason": "
|
|
20
|
+
"referrer.notLive": "Referral fee is not active for this hire.",
|
|
21
|
+
"referrer.notLiveReason": "No referrer is configured for this provider.",
|
|
22
|
+
"referrer.earningsNotLiveReason": "Referral settlement is live, but aggregated referrer earnings are not yet exposed by the indexer.",
|
|
22
23
|
// Read transport.
|
|
23
24
|
"transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
|
|
24
25
|
// Generic loading / empty / error states (components extend these).
|
|
@@ -164,7 +165,7 @@ function resolveEndpoints(network, rpcUrl, rpcSubscriptionsUrl) {
|
|
|
164
165
|
return { rpcUrl: resolvedRpc, rpcSubscriptionsUrl: resolvedWs };
|
|
165
166
|
}
|
|
166
167
|
var REFERRER_FEE_BPS_MIN = 0;
|
|
167
|
-
var REFERRER_FEE_BPS_MAX =
|
|
168
|
+
var REFERRER_FEE_BPS_MAX = 2e3;
|
|
168
169
|
function validateReferrerConfig(config) {
|
|
169
170
|
const { wallet, feeBps } = config;
|
|
170
171
|
if (typeof wallet !== "string" || !kit.isAddress(wallet)) {
|
|
@@ -182,10 +183,15 @@ function validateReferrerConfig(config) {
|
|
|
182
183
|
return { wallet, feeBps };
|
|
183
184
|
}
|
|
184
185
|
function resolveReferrerCapability(referrer) {
|
|
186
|
+
if (!referrer) {
|
|
187
|
+
return {
|
|
188
|
+
live: false,
|
|
189
|
+
reason: t("referrer.notLiveReason")
|
|
190
|
+
};
|
|
191
|
+
}
|
|
185
192
|
return {
|
|
186
|
-
live:
|
|
187
|
-
|
|
188
|
-
...referrer ? { referrer } : {}
|
|
193
|
+
live: true,
|
|
194
|
+
referrer
|
|
189
195
|
};
|
|
190
196
|
}
|
|
191
197
|
var DEFAULT_QUERY_CLIENT_CONFIG = {
|
|
@@ -286,7 +292,7 @@ function resolveChain(account, options) {
|
|
|
286
292
|
return account.chains?.find((c) => c.startsWith("solana:"));
|
|
287
293
|
}
|
|
288
294
|
function signerFromWalletAccount(account, options = {}) {
|
|
289
|
-
const
|
|
295
|
+
const signerAddress2 = kit.address(account.address);
|
|
290
296
|
const signTransaction = resolveSignTransaction(account, options);
|
|
291
297
|
const chain = resolveChain(account, options);
|
|
292
298
|
const encoder = kit.getTransactionEncoder();
|
|
@@ -301,18 +307,18 @@ function signerFromWalletAccount(account, options = {}) {
|
|
|
301
307
|
throw new Error(ts("signer.walletNoSignature", { address: account.address }));
|
|
302
308
|
}
|
|
303
309
|
const signed = decoder.decode(output.signedTransaction);
|
|
304
|
-
const signature = signed.signatures[
|
|
310
|
+
const signature = signed.signatures[signerAddress2];
|
|
305
311
|
if (!signature) {
|
|
306
312
|
throw new Error(ts("signer.walletNoSignature", { address: account.address }));
|
|
307
313
|
}
|
|
308
314
|
return signature;
|
|
309
315
|
}
|
|
310
316
|
return {
|
|
311
|
-
address:
|
|
317
|
+
address: signerAddress2,
|
|
312
318
|
async signTransactions(transactions) {
|
|
313
319
|
return Promise.all(
|
|
314
320
|
transactions.map(async (transaction) => ({
|
|
315
|
-
[
|
|
321
|
+
[signerAddress2]: await signOne(transaction)
|
|
316
322
|
}))
|
|
317
323
|
);
|
|
318
324
|
}
|
|
@@ -330,7 +336,7 @@ function resolveAdapterAddress(adapter) {
|
|
|
330
336
|
return String(publicKey);
|
|
331
337
|
}
|
|
332
338
|
function signerFromWalletAdapter(adapter, options) {
|
|
333
|
-
const
|
|
339
|
+
const signerAddress2 = kit.address(resolveAdapterAddress(adapter));
|
|
334
340
|
const { signTransaction } = adapter;
|
|
335
341
|
if (typeof signTransaction !== "function") {
|
|
336
342
|
throw new Error(ts("signer.walletAdapterNoSign"));
|
|
@@ -343,29 +349,29 @@ function signerFromWalletAdapter(adapter, options) {
|
|
|
343
349
|
const legacyTx = VersionedTransaction.deserialize(wireBytes);
|
|
344
350
|
const signed = await signTransaction(legacyTx);
|
|
345
351
|
const signedTx = decoder.decode(new Uint8Array(signed.serialize()));
|
|
346
|
-
const signature = signedTx.signatures[
|
|
352
|
+
const signature = signedTx.signatures[signerAddress2];
|
|
347
353
|
if (!signature) {
|
|
348
354
|
throw new Error(
|
|
349
|
-
ts("signer.walletNoSignature", { address:
|
|
355
|
+
ts("signer.walletNoSignature", { address: signerAddress2 })
|
|
350
356
|
);
|
|
351
357
|
}
|
|
352
358
|
return signature;
|
|
353
359
|
}
|
|
354
360
|
return {
|
|
355
|
-
address:
|
|
361
|
+
address: signerAddress2,
|
|
356
362
|
async signTransactions(transactions) {
|
|
357
363
|
return Promise.all(
|
|
358
364
|
transactions.map(async (transaction) => ({
|
|
359
|
-
[
|
|
365
|
+
[signerAddress2]: await signOne(transaction)
|
|
360
366
|
}))
|
|
361
367
|
);
|
|
362
368
|
}
|
|
363
369
|
};
|
|
364
370
|
}
|
|
365
371
|
function signerFromEmbeddedWallet(connection) {
|
|
366
|
-
const
|
|
372
|
+
const signerAddress2 = kit.address(connection.address);
|
|
367
373
|
return {
|
|
368
|
-
address:
|
|
374
|
+
address: signerAddress2,
|
|
369
375
|
async signTransactions(transactions) {
|
|
370
376
|
const signatures = await connection.signTransactions(transactions);
|
|
371
377
|
if (signatures.length !== transactions.length) {
|
|
@@ -377,7 +383,7 @@ function signerFromEmbeddedWallet(connection) {
|
|
|
377
383
|
);
|
|
378
384
|
}
|
|
379
385
|
return transactions.map((_, i) => ({
|
|
380
|
-
[
|
|
386
|
+
[signerAddress2]: signatures[i]
|
|
381
387
|
}));
|
|
382
388
|
}
|
|
383
389
|
};
|
|
@@ -422,9 +428,9 @@ var EN_COMPONENT_STRINGS = {
|
|
|
422
428
|
"components.hire.moderationPending": "Moderation pending",
|
|
423
429
|
"components.hire.moderationIssues": "Moderation issues found",
|
|
424
430
|
"components.hire.notConnected": "Connect a wallet to hire.",
|
|
425
|
-
// Referrer disclosure
|
|
431
|
+
// Referrer disclosure.
|
|
426
432
|
"components.referrer.disclosure": "This site earns a referral fee.",
|
|
427
|
-
"components.referrer.disclosurePending": "
|
|
433
|
+
"components.referrer.disclosurePending": "Referral fee is not active for this hire.",
|
|
428
434
|
"components.referrer.feeBps": "{bps} bps",
|
|
429
435
|
// TaskTimeline.
|
|
430
436
|
"components.taskTimeline.title": "Task progress",
|
|
@@ -970,6 +976,36 @@ function requireClient(client) {
|
|
|
970
976
|
}
|
|
971
977
|
return client;
|
|
972
978
|
}
|
|
979
|
+
function resolveReferrerArgs(ctx) {
|
|
980
|
+
const capability = ctx.resolveReferrerCapability();
|
|
981
|
+
if (!capability.live || !capability.referrer) {
|
|
982
|
+
return { referrerArgs: {}, referrerInjected: false };
|
|
983
|
+
}
|
|
984
|
+
return {
|
|
985
|
+
referrerArgs: {
|
|
986
|
+
referrer: capability.referrer.wallet,
|
|
987
|
+
referrerFeeBps: capability.referrer.feeBps
|
|
988
|
+
},
|
|
989
|
+
referrerInjected: true
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
function signerAddress(signerOrAddress) {
|
|
993
|
+
if (typeof signerOrAddress === "string") {
|
|
994
|
+
return signerOrAddress;
|
|
995
|
+
}
|
|
996
|
+
if (typeof signerOrAddress === "object" && signerOrAddress !== null && "address" in signerOrAddress && typeof signerOrAddress.address === "string") {
|
|
997
|
+
return signerOrAddress.address;
|
|
998
|
+
}
|
|
999
|
+
throw new Error("Expected a TransactionSigner or Address with an address field.");
|
|
1000
|
+
}
|
|
1001
|
+
function withoutReferrerArgs(input) {
|
|
1002
|
+
const {
|
|
1003
|
+
referrer: _referrer,
|
|
1004
|
+
referrerFeeBps: _referrerFeeBps,
|
|
1005
|
+
...rest
|
|
1006
|
+
} = input;
|
|
1007
|
+
return rest;
|
|
1008
|
+
}
|
|
973
1009
|
|
|
974
1010
|
// src/hooks/useHire.ts
|
|
975
1011
|
function useHire() {
|
|
@@ -977,29 +1013,29 @@ function useHire() {
|
|
|
977
1013
|
const mutation = reactQuery.useMutation({
|
|
978
1014
|
mutationFn: async (input) => {
|
|
979
1015
|
const client = requireClient(ctx.client);
|
|
980
|
-
const
|
|
981
|
-
const
|
|
1016
|
+
const { referrerArgs, referrerInjected } = resolveReferrerArgs(ctx);
|
|
1017
|
+
const hireInput = withoutReferrerArgs(input);
|
|
982
1018
|
const creator = input.creator ?? client.signer;
|
|
983
1019
|
let signature;
|
|
984
1020
|
if (input.humanless === true) {
|
|
985
|
-
const
|
|
986
|
-
...
|
|
987
|
-
creator
|
|
988
|
-
|
|
1021
|
+
const result = await client.hireFromListingHumanless({
|
|
1022
|
+
...hireInput,
|
|
1023
|
+
creator,
|
|
1024
|
+
...referrerArgs
|
|
989
1025
|
});
|
|
990
|
-
|
|
1026
|
+
signature = result.signature;
|
|
991
1027
|
} else {
|
|
992
1028
|
const authority = input.authority ?? client.signer;
|
|
993
1029
|
const result = await client.hireFromListing({
|
|
994
|
-
...
|
|
1030
|
+
...hireInput,
|
|
995
1031
|
authority,
|
|
996
|
-
creator
|
|
997
|
-
|
|
1032
|
+
creator,
|
|
1033
|
+
...referrerArgs
|
|
998
1034
|
});
|
|
999
1035
|
signature = result.signature;
|
|
1000
1036
|
}
|
|
1001
1037
|
const [taskPda] = await marketplaceSdk.findTaskPda({
|
|
1002
|
-
creator:
|
|
1038
|
+
creator: signerAddress(creator),
|
|
1003
1039
|
taskId: input.taskId
|
|
1004
1040
|
});
|
|
1005
1041
|
return { signature, taskPda, referrerInjected };
|