@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.
- package/CHANGELOG.md +56 -0
- package/README.md +93 -47
- 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 +6 -3
- 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/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { QueryClient, QueryClientConfig } from '@tanstack/react-query';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { A as AgencProviderConfig, a as AgencContextValue, V as ValidatedReferrerConfig, R as ReferrerCapability, b as ReferrerConfig, c as AgencNetwork, C as CreateReadTransportConfig, d as ReadTransport } from './index-
|
|
5
|
-
export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, r as EN_STRINGS, G as GpaReadSource, s as GuaranteedBadge, t as GuaranteedBadgeProps, H as HireButton, u as HireButtonProps, v as HireCheckoutListing, w as HireCheckoutModal, x as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, y as ListingCardData, z as ListingCardProps, F as ListingGrid, J as ListingGridProps, M as Modal, K as ModalProps, N as ModerationBadge, O as ModerationBadgeProps, P as ModerationState, Q as PoweredByAgenC, S as PoweredByAgenCProps, T as ProviderCard, U as ProviderCardProps, W as ReadListingResult, X as ReferrerDisclosure, Y as ReferrerDisclosureProps, Z as ReviewPanel, _ as ReviewPanelProps, $ as Spinner, a0 as SpinnerProps, a1 as StateKind, a2 as StateMessage, a3 as StateMessageProps, a4 as StringCatalog, a5 as StringId, a6 as StringVars, a7 as TaskTimeline, a8 as TaskTimelineProps, a9 as ThemableProps, aa as TranslateOptions, ab as UNVERIFIED, ac as UseAgentVerificationOptions, ad as UseAgentVerificationResult, ae as VerifiedBadge, af as VerifiedBadgeProps, ag as agentVerificationReaderFromRpc, ah as cx, ai as decodeListingCategory, aj as decodeListingName, ak as decodeListingTags, al as elementClass, am as evaluateAgentVerification, an as formatPriceSol, ao as formatRate, ap as formatSol, aq as moderationStateOf, ar as rootClass, as as t, at as tc, au as toHex, av as truncateAddress, aw as useAgentVerification, ax as useFocusTrap } from './index-
|
|
6
|
-
export { EN_SIGNER_STRINGS, SignerFromWalletAdapterOptions, SignerStringId, VersionedTransactionCtor, VersionedTransactionLike, WalletAdapterLike, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from './signers/index.cjs';
|
|
7
|
-
export { E as EmbeddedWalletConnection, a as EmbeddedWalletProvider, S as SignerFromWalletAccountOptions, W as WalletStandardAccountLike,
|
|
4
|
+
import { A as AgencProviderConfig, a as AgencContextValue, V as ValidatedReferrerConfig, R as ReferrerCapability, b as ReferrerConfig, c as AgencNetwork, C as CreateReadTransportConfig, d as ReadTransport } from './index-C20NVU7_.cjs';
|
|
5
|
+
export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, r as EN_STRINGS, G as GpaReadSource, s as GuaranteedBadge, t as GuaranteedBadgeProps, H as HireButton, u as HireButtonProps, v as HireCheckoutListing, w as HireCheckoutModal, x as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, y as ListingCardData, z as ListingCardProps, F as ListingGrid, J as ListingGridProps, M as Modal, K as ModalProps, N as ModerationBadge, O as ModerationBadgeProps, P as ModerationState, Q as PoweredByAgenC, S as PoweredByAgenCProps, T as ProviderCard, U as ProviderCardProps, W as ReadListingResult, X as ReferrerDisclosure, Y as ReferrerDisclosureProps, Z as ReviewPanel, _ as ReviewPanelProps, $ as Spinner, a0 as SpinnerProps, a1 as StateKind, a2 as StateMessage, a3 as StateMessageProps, a4 as StringCatalog, a5 as StringId, a6 as StringVars, a7 as TaskTimeline, a8 as TaskTimelineProps, a9 as ThemableProps, aa as TranslateOptions, ab as UNVERIFIED, ac as UseAgentVerificationOptions, ad as UseAgentVerificationResult, ae as VerifiedBadge, af as VerifiedBadgeProps, ag as agentVerificationReaderFromRpc, ah as cx, ai as decodeListingCategory, aj as decodeListingName, ak as decodeListingTags, al as elementClass, am as evaluateAgentVerification, an as formatPriceSol, ao as formatRate, ap as formatSol, aq as moderationStateOf, ar as rootClass, as as t, at as tc, au as toHex, av as truncateAddress, aw as useAgentVerification, ax as useFocusTrap } from './index-C20NVU7_.cjs';
|
|
6
|
+
export { EN_SIGNER_STRINGS, SignerFromWalletAdapterOptions, SignerStringId, VersionedTransactionCtor, VersionedTransactionLike, WalletAdapterLike, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter, walletStandardChainForNetwork } from './signers/index.cjs';
|
|
7
|
+
export { C as ChainBoundTransactionSigner, E as EmbeddedWalletConnection, a as EmbeddedWalletProvider, S as SignerFromWalletAccountOptions, b as SolanaWalletNetwork, W as WalletStandardAccountLike, c as WalletStandardSignTransaction } from './types-B10rndEI.cjs';
|
|
8
8
|
export { Address, TransactionSigner } from '@solana/kit';
|
|
9
9
|
export { DecodedProgramAccount, IndexerAgentTrackRecord, IndexerHire, IndexerListing, ListActiveListingsOptions, MarketplaceClient, ServiceListing } from '@tetsuo-ai/marketplace-sdk';
|
|
10
|
-
import './useAgentTrackRecord-
|
|
10
|
+
import './useAgentTrackRecord-Ch7gHTFj.cjs';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* `<AgencProvider>` — the one context that wires reads, writes, and the
|
|
@@ -20,9 +20,8 @@ import './useAgentTrackRecord-DPt3SfYz.cjs';
|
|
|
20
20
|
* into `client` for hook e2e, and a mock {@link ReadTransport} plugs into
|
|
21
21
|
* `queryTransport`.
|
|
22
22
|
*
|
|
23
|
-
* SSR-safe: no `window`/`document` access at module scope or during render
|
|
24
|
-
*
|
|
25
|
-
* QueryClient on config identity so SSR + hydration stay stable.
|
|
23
|
+
* SSR-safe: no `window`/`document` access at module scope or during render. The
|
|
24
|
+
* provider memoizes the context value and QueryClient on config identity.
|
|
26
25
|
*
|
|
27
26
|
* @module provider/AgencProvider
|
|
28
27
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { QueryClient, QueryClientConfig } from '@tanstack/react-query';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { A as AgencProviderConfig, a as AgencContextValue, V as ValidatedReferrerConfig, R as ReferrerCapability, b as ReferrerConfig, c as AgencNetwork, C as CreateReadTransportConfig, d as ReadTransport } from './index-
|
|
5
|
-
export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, r as EN_STRINGS, G as GpaReadSource, s as GuaranteedBadge, t as GuaranteedBadgeProps, H as HireButton, u as HireButtonProps, v as HireCheckoutListing, w as HireCheckoutModal, x as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, y as ListingCardData, z as ListingCardProps, F as ListingGrid, J as ListingGridProps, M as Modal, K as ModalProps, N as ModerationBadge, O as ModerationBadgeProps, P as ModerationState, Q as PoweredByAgenC, S as PoweredByAgenCProps, T as ProviderCard, U as ProviderCardProps, W as ReadListingResult, X as ReferrerDisclosure, Y as ReferrerDisclosureProps, Z as ReviewPanel, _ as ReviewPanelProps, $ as Spinner, a0 as SpinnerProps, a1 as StateKind, a2 as StateMessage, a3 as StateMessageProps, a4 as StringCatalog, a5 as StringId, a6 as StringVars, a7 as TaskTimeline, a8 as TaskTimelineProps, a9 as ThemableProps, aa as TranslateOptions, ab as UNVERIFIED, ac as UseAgentVerificationOptions, ad as UseAgentVerificationResult, ae as VerifiedBadge, af as VerifiedBadgeProps, ag as agentVerificationReaderFromRpc, ah as cx, ai as decodeListingCategory, aj as decodeListingName, ak as decodeListingTags, al as elementClass, am as evaluateAgentVerification, an as formatPriceSol, ao as formatRate, ap as formatSol, aq as moderationStateOf, ar as rootClass, as as t, at as tc, au as toHex, av as truncateAddress, aw as useAgentVerification, ax as useFocusTrap } from './index-
|
|
6
|
-
export { EN_SIGNER_STRINGS, SignerFromWalletAdapterOptions, SignerStringId, VersionedTransactionCtor, VersionedTransactionLike, WalletAdapterLike, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter } from './signers/index.js';
|
|
7
|
-
export { E as EmbeddedWalletConnection, a as EmbeddedWalletProvider, S as SignerFromWalletAccountOptions, W as WalletStandardAccountLike,
|
|
4
|
+
import { A as AgencProviderConfig, a as AgencContextValue, V as ValidatedReferrerConfig, R as ReferrerCapability, b as ReferrerConfig, c as AgencNetwork, C as CreateReadTransportConfig, d as ReadTransport } from './index-BAyr1ODZ.js';
|
|
5
|
+
export { e as AgentVerificationReader, f as AgentVerificationReaderOptions, g as AgentVerificationResult, h as AgentVerificationRpc, B as Badge, i as BadgeProps, j as BadgeTone, k as Button, l as ButtonProps, m as ButtonVariant, n as COMPONENT_CATALOG, o as ComponentStringId, D as DEFAULT_TRUST_HREF, p as DisputeBanner, q as DisputeBannerProps, E as EN_COMPONENT_STRINGS, r as EN_STRINGS, G as GpaReadSource, s as GuaranteedBadge, t as GuaranteedBadgeProps, H as HireButton, u as HireButtonProps, v as HireCheckoutListing, w as HireCheckoutModal, x as HireCheckoutModalProps, I as IndexerConfig, L as ListingCard, y as ListingCardData, z as ListingCardProps, F as ListingGrid, J as ListingGridProps, M as Modal, K as ModalProps, N as ModerationBadge, O as ModerationBadgeProps, P as ModerationState, Q as PoweredByAgenC, S as PoweredByAgenCProps, T as ProviderCard, U as ProviderCardProps, W as ReadListingResult, X as ReferrerDisclosure, Y as ReferrerDisclosureProps, Z as ReviewPanel, _ as ReviewPanelProps, $ as Spinner, a0 as SpinnerProps, a1 as StateKind, a2 as StateMessage, a3 as StateMessageProps, a4 as StringCatalog, a5 as StringId, a6 as StringVars, a7 as TaskTimeline, a8 as TaskTimelineProps, a9 as ThemableProps, aa as TranslateOptions, ab as UNVERIFIED, ac as UseAgentVerificationOptions, ad as UseAgentVerificationResult, ae as VerifiedBadge, af as VerifiedBadgeProps, ag as agentVerificationReaderFromRpc, ah as cx, ai as decodeListingCategory, aj as decodeListingName, ak as decodeListingTags, al as elementClass, am as evaluateAgentVerification, an as formatPriceSol, ao as formatRate, ap as formatSol, aq as moderationStateOf, ar as rootClass, as as t, at as tc, au as toHex, av as truncateAddress, aw as useAgentVerification, ax as useFocusTrap } from './index-BAyr1ODZ.js';
|
|
6
|
+
export { EN_SIGNER_STRINGS, SignerFromWalletAdapterOptions, SignerStringId, VersionedTransactionCtor, VersionedTransactionLike, WalletAdapterLike, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter, walletStandardChainForNetwork } from './signers/index.js';
|
|
7
|
+
export { C as ChainBoundTransactionSigner, E as EmbeddedWalletConnection, a as EmbeddedWalletProvider, S as SignerFromWalletAccountOptions, b as SolanaWalletNetwork, W as WalletStandardAccountLike, c as WalletStandardSignTransaction } from './types-B10rndEI.js';
|
|
8
8
|
export { Address, TransactionSigner } from '@solana/kit';
|
|
9
9
|
export { DecodedProgramAccount, IndexerAgentTrackRecord, IndexerHire, IndexerListing, ListActiveListingsOptions, MarketplaceClient, ServiceListing } from '@tetsuo-ai/marketplace-sdk';
|
|
10
|
-
import './useAgentTrackRecord-
|
|
10
|
+
import './useAgentTrackRecord-Ch7gHTFj.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* `<AgencProvider>` — the one context that wires reads, writes, and the
|
|
@@ -20,9 +20,8 @@ import './useAgentTrackRecord-DPt3SfYz.js';
|
|
|
20
20
|
* into `client` for hook e2e, and a mock {@link ReadTransport} plugs into
|
|
21
21
|
* `queryTransport`.
|
|
22
22
|
*
|
|
23
|
-
* SSR-safe: no `window`/`document` access at module scope or during render
|
|
24
|
-
*
|
|
25
|
-
* QueryClient on config identity so SSR + hydration stay stable.
|
|
23
|
+
* SSR-safe: no `window`/`document` access at module scope or during render. The
|
|
24
|
+
* provider memoizes the context value and QueryClient on config identity.
|
|
26
25
|
*
|
|
27
26
|
* @module provider/AgencProvider
|
|
28
27
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createReadTransport } from './chunk-AKPPKMQ2.js';
|
|
2
2
|
export { ReadTransportUnsupportedError, createReadTransport } from './chunk-AKPPKMQ2.js';
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { walletStandardChainForNetwork } from './chunk-7NKRSPPN.js';
|
|
4
|
+
export { EN_SIGNER_STRINGS, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter, walletStandardChainForNetwork } from './chunk-7NKRSPPN.js';
|
|
5
|
+
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 } from './chunk-CDDHUFMG.js';
|
|
6
|
+
import { AgencContext } from './chunk-RG5JZ6JL.js';
|
|
7
|
+
export { AgencContext, useAgencContext } from './chunk-RG5JZ6JL.js';
|
|
7
8
|
import { t } from './chunk-H6PJIDQR.js';
|
|
8
9
|
export { EN_STRINGS, t } from './chunk-H6PJIDQR.js';
|
|
9
10
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
@@ -79,6 +80,40 @@ var DEFAULT_QUERY_CLIENT_CONFIG = {
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
};
|
|
83
|
+
var OPAQUE_DEPLOYMENT_IDS = /* @__PURE__ */ new WeakMap();
|
|
84
|
+
var nextOpaqueDeploymentId = 1;
|
|
85
|
+
function opaqueDeploymentId(value) {
|
|
86
|
+
if (value === void 0) return null;
|
|
87
|
+
const existing = OPAQUE_DEPLOYMENT_IDS.get(value);
|
|
88
|
+
if (existing !== void 0) return existing;
|
|
89
|
+
const allocated = nextOpaqueDeploymentId++;
|
|
90
|
+
OPAQUE_DEPLOYMENT_IDS.set(value, allocated);
|
|
91
|
+
return allocated;
|
|
92
|
+
}
|
|
93
|
+
function cacheFingerprint(value) {
|
|
94
|
+
if (value == null) return null;
|
|
95
|
+
let hash = 0xcbf29ce484222325n;
|
|
96
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
97
|
+
hash ^= BigInt(value.charCodeAt(index));
|
|
98
|
+
hash = BigInt.asUintN(64, hash * 0x100000001b3n);
|
|
99
|
+
}
|
|
100
|
+
return hash.toString(16).padStart(16, "0");
|
|
101
|
+
}
|
|
102
|
+
function resolveCacheNamespace(config, network, rpcUrl) {
|
|
103
|
+
const explicit = config.cacheNamespace?.trim();
|
|
104
|
+
if (config.cacheNamespace !== void 0 && !explicit) {
|
|
105
|
+
throw new TypeError("AgencProvider cacheNamespace must not be empty.");
|
|
106
|
+
}
|
|
107
|
+
return JSON.stringify({
|
|
108
|
+
version: 1,
|
|
109
|
+
network,
|
|
110
|
+
rpc: cacheFingerprint(rpcUrl),
|
|
111
|
+
indexer: cacheFingerprint(config.indexer?.baseUrl),
|
|
112
|
+
custom: cacheFingerprint(explicit),
|
|
113
|
+
queryTransport: explicit === void 0 ? opaqueDeploymentId(config.queryTransport) : null,
|
|
114
|
+
client: explicit === void 0 ? opaqueDeploymentId(config.client) : null
|
|
115
|
+
});
|
|
116
|
+
}
|
|
82
117
|
function buildReadTransport(config) {
|
|
83
118
|
return createReadTransport({
|
|
84
119
|
indexer: config.indexer,
|
|
@@ -104,6 +139,16 @@ function buildWriteClient(config, network) {
|
|
|
104
139
|
signer: config.signer
|
|
105
140
|
});
|
|
106
141
|
}
|
|
142
|
+
function assertSignerMatchesNetwork(signer, network, source) {
|
|
143
|
+
const chain = typeof signer === "object" && signer !== null && "chain" in signer ? signer.chain : void 0;
|
|
144
|
+
if (typeof chain !== "string") return;
|
|
145
|
+
const expected = walletStandardChainForNetwork(network);
|
|
146
|
+
if (chain !== expected) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`${source} is bound to ${chain}, but AgencProvider network ${network} requires ${expected}.`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
107
152
|
function AgencProvider(props) {
|
|
108
153
|
const { config, children } = props;
|
|
109
154
|
const [internalQueryClient] = useState(
|
|
@@ -112,6 +157,12 @@ function AgencProvider(props) {
|
|
|
112
157
|
const queryClient = props.queryClient ?? internalQueryClient;
|
|
113
158
|
const value = useMemo(() => {
|
|
114
159
|
const network = config.network ?? "mainnet";
|
|
160
|
+
assertSignerMatchesNetwork(config.signer, network, "config.signer");
|
|
161
|
+
assertSignerMatchesNetwork(
|
|
162
|
+
config.client?.signer,
|
|
163
|
+
network,
|
|
164
|
+
"config.client.signer"
|
|
165
|
+
);
|
|
115
166
|
const referrer = config.referrer ? validateReferrerConfig(config.referrer) : null;
|
|
116
167
|
const read = buildReadTransport(config);
|
|
117
168
|
const client = buildWriteClient(config, network);
|
|
@@ -120,11 +171,20 @@ function AgencProvider(props) {
|
|
|
120
171
|
config.rpcUrl,
|
|
121
172
|
config.rpcSubscriptionsUrl
|
|
122
173
|
);
|
|
174
|
+
const orchestrationRpcUrl = config.orchestrationRpc !== void 0 ? null : config.client !== void 0 ? config.rpcUrl ?? null : rpcUrl ?? null;
|
|
175
|
+
const cacheNamespace = resolveCacheNamespace(
|
|
176
|
+
config,
|
|
177
|
+
network,
|
|
178
|
+
rpcUrl ?? null
|
|
179
|
+
);
|
|
123
180
|
return {
|
|
124
181
|
network,
|
|
182
|
+
cacheNamespace,
|
|
125
183
|
read,
|
|
126
184
|
client,
|
|
127
185
|
rpcUrl: rpcUrl ?? null,
|
|
186
|
+
orchestrationRpc: config.orchestrationRpc ?? null,
|
|
187
|
+
orchestrationRpcUrl,
|
|
128
188
|
indexerBaseUrl: config.indexer?.baseUrl ?? null,
|
|
129
189
|
signer: config.signer ?? null,
|
|
130
190
|
referrer,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider/network.ts","../src/provider/referrer.ts","../src/provider/AgencProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAcA,IAAM,qBAAA,GAA6D;AAAA,EACjE,QAAA,EAAU,uBAAA;AAAA,EACV,MAAA,EAAQ,+BAAA;AAAA;AAAA,EAER,OAAA,EAAS;AACX,CAAA;AAMA,IAAM,mBAAA,GAA2D;AAAA,EAC/D,QAAA,EAAU,qBAAA;AAAA,EACV,MAAA,EAAQ,6BAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAA;AAGO,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,IAAI,cAAA,CAAe,IAAA,CAAK,MAAM,CAAA,EAAG;AAC/B,IAAA,OAAO,CAAA,MAAA,EAAS,MAAA,CAAO,KAAA,CAAM,UAAA,CAAW,MAAM,CAAC,CAAA,CAAA;AAAA,EACjD;A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J","file":"index.js","sourcesContent":["/**\n * Network → endpoint defaults.\n *\n * Reuses the resolution philosophy of the SDK sandbox env seam\n * (`resolveSandboxEnvironment`): explicit config beats a per-network default,\n * and the WebSocket endpoint is derived from the HTTP one when not given. This\n * is intentionally a SMALL, synchronous, SSR-safe mirror — the provider needs\n * no `process`/`fs` access and the sandbox seam's async file-reading path.\n *\n * @module provider/network\n */\nimport type { AgencNetwork } from \"../types.js\";\n\n/** Per-network default HTTP RPC endpoints. `mainnet` has no public default. */\nconst NETWORK_HTTP_DEFAULTS: Record<AgencNetwork, string | null> = {\n localnet: \"http://127.0.0.1:8899\",\n devnet: \"https://api.devnet.solana.com\",\n // No public default: mainnet RPC is operator-supplied (rate/cost sensitive).\n mainnet: null,\n};\n\n/**\n * `solana-test-validator` serves PubSub on RPC port + 1 (8900), so localnet's\n * WS endpoint is NOT derivable from the HTTP URL by scheme swap alone.\n */\nconst NETWORK_WS_DEFAULTS: Record<AgencNetwork, string | null> = {\n localnet: \"ws://127.0.0.1:8900\",\n devnet: \"wss://api.devnet.solana.com\",\n mainnet: null,\n};\n\n/** Derive a ws(s) endpoint from an http(s) one (same host/port/path). */\nexport function deriveSubscriptionsUrl(rpcUrl: string): string {\n if (/^https:\\/\\//i.test(rpcUrl)) {\n return `wss://${rpcUrl.slice(\"https://\".length)}`;\n }\n if (/^http:\\/\\//i.test(rpcUrl)) {\n return `ws://${rpcUrl.slice(\"http://\".length)}`;\n }\n return rpcUrl;\n}\n\n/** A resolved pair of RPC endpoints (either may be `null` when unresolvable). */\nexport interface ResolvedEndpoints {\n rpcUrl: string | null;\n rpcSubscriptionsUrl: string | null;\n}\n\n/**\n * Resolve the HTTP + WS RPC endpoints for a network, honoring explicit\n * overrides. Returns `{ rpcUrl: null }` when neither an override nor a default\n * exists (mainnet with no `rpcUrl`) — the provider treats that as \"no write\n * client buildable from URLs\", not a throw, so a read-only/indexer-only or\n * `client`-override setup still works.\n */\nexport function resolveEndpoints(\n network: AgencNetwork,\n rpcUrl?: string,\n rpcSubscriptionsUrl?: string,\n): ResolvedEndpoints {\n const resolvedRpc = rpcUrl ?? NETWORK_HTTP_DEFAULTS[network];\n const resolvedWs =\n rpcSubscriptionsUrl ??\n (rpcUrl !== undefined\n ? deriveSubscriptionsUrl(rpcUrl)\n : NETWORK_WS_DEFAULTS[network]);\n return { rpcUrl: resolvedRpc, rpcSubscriptionsUrl: resolvedWs };\n}\n","/**\n * Referrer config validation + the live referral-settlement capability.\n *\n * ## REFERRER SETTLEMENT\n *\n * Referrer args + the 4th settlement leg are part of the full 84-instruction\n * surface. The SDK `facade.hireFromListing` and\n * `facade.hireFromListingHumanless` both accept referrer fields. This module:\n * - ACCEPTS + VALIDATES `referrer: { wallet, feeBps }` and stores the normalized\n * form (validation is real: bad base58 throws, out-of-range bps rejected);\n * - exposes {@link resolveReferrerCapability}, which reports live when a valid\n * referrer config is present.\n *\n * Aggregated earnings are separate from settlement. `useReferrerEarnings` still\n * remains indexer-gated and must not fabricate totals before that endpoint is\n * published.\n *\n * @module provider/referrer\n */\nimport { isAddress } from \"@solana/kit\";\nimport { t } from \"../strings/index.js\";\nimport type {\n Address,\n ReferrerCapability,\n ReferrerConfig,\n ValidatedReferrerConfig,\n} from \"../types.js\";\n\n/** Minimum referral fee, in basis points. */\nexport const REFERRER_FEE_BPS_MIN = 0;\n/**\n * Maximum referral fee, in basis points. Mirrors the on-chain per-leg cap\n * (`MAX_REFERRER_FEE_BPS = 2000`) so invalid provider config fails before the\n * user signs a transaction.\n */\nexport const REFERRER_FEE_BPS_MAX = 2_000;\n\n/**\n * Validate + normalize a raw {@link ReferrerConfig} into a\n * {@link ValidatedReferrerConfig}.\n *\n * @throws TypeError when `wallet` is not a valid base58 Solana address.\n * @throws RangeError when `feeBps` is not an integer in\n * `[REFERRER_FEE_BPS_MIN, REFERRER_FEE_BPS_MAX]`.\n */\nexport function validateReferrerConfig(\n config: ReferrerConfig,\n): ValidatedReferrerConfig {\n const { wallet, feeBps } = config;\n if (typeof wallet !== \"string\" || !isAddress(wallet)) {\n throw new TypeError(t(\"referrer.invalidWallet\", { wallet: String(wallet) }));\n }\n if (\n typeof feeBps !== \"number\" ||\n !Number.isInteger(feeBps) ||\n feeBps < REFERRER_FEE_BPS_MIN ||\n feeBps > REFERRER_FEE_BPS_MAX\n ) {\n throw new RangeError(\n t(\"referrer.invalidFeeBps\", {\n min: REFERRER_FEE_BPS_MIN,\n max: REFERRER_FEE_BPS_MAX,\n feeBps: String(feeBps),\n }),\n );\n }\n return { wallet: wallet as Address, feeBps };\n}\n\n/**\n * Resolve whether a referral fee can actually be charged by this provider.\n *\n * @param referrer - The validated referrer config under the provider, or null.\n * @returns A {@link ReferrerCapability}; live only when a referrer is configured.\n */\nexport function resolveReferrerCapability(\n referrer: ValidatedReferrerConfig | null,\n): ReferrerCapability {\n if (!referrer) {\n return {\n live: false,\n reason: t(\"referrer.notLiveReason\"),\n };\n }\n return {\n live: true,\n referrer,\n };\n}\n","/**\n * `<AgencProvider>` — the one context that wires reads, writes, and the\n * live referrer config for every AgenC hook/component beneath it.\n *\n * Wraps a bundled TanStack {@link QueryClientProvider} so hooks get\n * caching/refetch/optimistic states with no consumer config. The\n * {@link AgencProviderConfig.client} and {@link AgencProviderConfig.queryTransport}\n * slots are PUBLIC test seams: `startLocalMarketplace().client` plugs straight\n * into `client` for hook e2e, and a mock {@link ReadTransport} plugs into\n * `queryTransport`.\n *\n * SSR-safe: no `window`/`document` access at module scope or during render; all\n * resolution is pure. The provider memoizes the context value and the\n * QueryClient on config identity so SSR + hydration stay stable.\n *\n * @module provider/AgencProvider\n */\nimport {\n QueryClient,\n QueryClientProvider,\n type QueryClientConfig,\n} from \"@tanstack/react-query\";\nimport { createMarketplaceClient } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useMemo, useState, type ReactNode } from \"react\";\nimport { createReadTransport } from \"../transport/index.js\";\nimport type {\n AgencContextValue,\n AgencNetwork,\n AgencProviderConfig,\n MarketplaceClient,\n ReadTransport,\n ValidatedReferrerConfig,\n} from \"../types.js\";\nimport { AgencContext } from \"./context.js\";\nimport { resolveEndpoints } from \"./network.js\";\nimport {\n resolveReferrerCapability as resolveReferrerCapabilityImpl,\n validateReferrerConfig,\n} from \"./referrer.js\";\n\n/** Props for {@link AgencProvider}. */\nexport interface AgencProviderProps {\n /** Provider configuration. See {@link AgencProviderConfig}. */\n config: AgencProviderConfig;\n /**\n * Optional pre-built TanStack QueryClient. When omitted, the provider creates\n * one lazily (stable across renders). Pass your own to share a cache with the\n * rest of your app.\n */\n queryClient?: QueryClient;\n /** Override config for the lazily-created QueryClient (ignored if you pass one). */\n queryClientConfig?: QueryClientConfig;\n children: ReactNode;\n}\n\n/** Default QueryClient tuning for marketplace reads (sane, overridable). */\nconst DEFAULT_QUERY_CLIENT_CONFIG: QueryClientConfig = {\n defaultOptions: {\n queries: {\n // Marketplace listings change on-chain slowly relative to a UI session;\n // a short stale window avoids refetch storms while staying fresh.\n staleTime: 15_000,\n retry: 1,\n refetchOnWindowFocus: false,\n },\n },\n};\n\n/**\n * Build the read transport from config. The `queryTransport` override wins;\n * otherwise indexer-first (when `indexer.baseUrl` is set) with a gPA fallback\n * over the resolved RPC URL.\n *\n * NOTE: the gPA fallback needs a kit `Rpc<GetProgramAccountsApi>`, which we do\n * NOT build here from a bare URL — the SDK write client owns RPC construction.\n * When only a URL (no indexer, no queryTransport) is available, reads require\n * an indexer; the transport factory throws a descriptive error on first use.\n */\nfunction buildReadTransport(\n config: AgencProviderConfig,\n): ReadTransport {\n return createReadTransport({\n indexer: config.indexer,\n queryTransport: config.queryTransport,\n // The gPA read source is provided only via queryTransport in v1 (a kit RPC\n // or ProgramAccountsTransport). A future revision can derive a kit RPC from\n // the resolved rpcUrl; for now indexer-first is the supported read path and\n // queryTransport is the test/mocks seam.\n });\n}\n\n/**\n * Build the write client from config. The `client` override wins. Otherwise a\n * client is built only when BOTH a resolvable `rpcUrl` and a `signer` exist;\n * absent either, the provider exposes `client: null` and mutating hooks surface\n * a clear error (read-only / indexer-only setups are valid).\n */\nfunction buildWriteClient(\n config: AgencProviderConfig,\n network: AgencNetwork,\n): MarketplaceClient | null {\n if (config.client) return config.client;\n if (!config.signer) return null;\n const { rpcUrl, rpcSubscriptionsUrl } = resolveEndpoints(\n network,\n config.rpcUrl,\n config.rpcSubscriptionsUrl,\n );\n if (rpcUrl === null) return null;\n return createMarketplaceClient({\n rpcUrl,\n ...(rpcSubscriptionsUrl ? { rpcSubscriptionsUrl } : {}),\n signer: config.signer,\n });\n}\n\n/**\n * The AgenC provider. Place at the root of any tree that uses AgenC hooks or\n * components.\n *\n * @example\n * ```tsx\n * <AgencProvider config={{ network: \"devnet\", indexer: { baseUrl } }}>\n * <App />\n * </AgencProvider>\n * ```\n */\nexport function AgencProvider(props: AgencProviderProps): ReactNode {\n const { config, children } = props;\n\n // Lazily create (and keep stable) the QueryClient. useState initializer runs\n // once; passing your own `queryClient` overrides it.\n const [internalQueryClient] = useState<QueryClient>(\n () =>\n props.queryClient ??\n new QueryClient(props.queryClientConfig ?? DEFAULT_QUERY_CLIENT_CONFIG),\n );\n const queryClient = props.queryClient ?? internalQueryClient;\n\n const value = useMemo<AgencContextValue>(() => {\n const network: AgencNetwork = config.network ?? \"mainnet\";\n\n // Validate + normalize referrer at provider construction. A bad config\n // throws here, before any hire transaction can be built.\n const referrer: ValidatedReferrerConfig | null = config.referrer\n ? validateReferrerConfig(config.referrer)\n : null;\n\n const read = buildReadTransport(config);\n const client = buildWriteClient(config, network);\n\n // The resolved HTTP RPC endpoint, exposed so hooks can make single-account\n // reads (e.g. resolving the WP-A1 roster-attestor account at activation)\n // without an indexer. Not a gPA source — the read transport owns list\n // queries.\n const { rpcUrl } = resolveEndpoints(\n network,\n config.rpcUrl,\n config.rpcSubscriptionsUrl,\n );\n\n return {\n network,\n read,\n client,\n rpcUrl: rpcUrl ?? null,\n indexerBaseUrl: config.indexer?.baseUrl ?? null,\n signer: config.signer ?? null,\n referrer,\n resolveReferrerCapability: () => resolveReferrerCapabilityImpl(referrer),\n };\n // Re-resolve when any wiring input changes. Referrer object identity is\n // intentionally part of the deps (a new referrer config must re-validate).\n }, [config]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <AgencContext.Provider value={value}>{children}</AgencContext.Provider>\n </QueryClientProvider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/provider/network.ts","../src/provider/referrer.ts","../src/provider/AgencProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAcA,IAAM,qBAAA,GAA6D;AAAA,EACjE,QAAA,EAAU,uBAAA;AAAA,EACV,MAAA,EAAQ,+BAAA;AAAA;AAAA,EAER,OAAA,EAAS;AACX,CAAA;AAMA,IAAM,mBAAA,GAA2D;AAAA,EAC/D,QAAA,EAAU,qBAAA;AAAA,EACV,MAAA,EAAQ,6BAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAA;AAGO,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,IAAI,cAAA,CAAe,IAAA,CAAK,MAAM,CAAA,EAAG;AAC/B,IAAA,OAAO,CAAA,MAAA,EAAS,MAAA,CAAO,KAAA,CAAM,UAAA,CAAW,MAAM,CAAC,CAAA,CAAA;AAAA,EACjD;AACA,EAAA,IAAI,aAAA,CAAc,IAAA,CAAK,MAAM,CAAA,EAAG;AAC9B,IAAA,OAAO,CAAA,KAAA,EAAQ,MAAA,CAAO,KAAA,CAAM,SAAA,CAAU,MAAM,CAAC,CAAA,CAAA;AAAA,EAC/C;AACA,EAAA,OAAO,MAAA;AACT;AAeO,SAAS,gBAAA,CACd,OAAA,EACA,MAAA,EACA,mBAAA,EACmB;AACnB,EAAA,MAAM,WAAA,GAAc,MAAA,IAAU,qBAAA,CAAsB,OAAO,CAAA;AAC3D,EAAA,MAAM,UAAA,GACJ,wBACC,MAAA,KAAW,MAAA,GACR,uBAAuB,MAAM,CAAA,GAC7B,oBAAoB,OAAO,CAAA,CAAA;AACjC,EAAA,OAAO,EAAE,MAAA,EAAQ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AAAA,KACT;AAMA,IAAA,MAAM,mBAAA,GACJ,MAAA,CAAO,gBAAA,KAAqB,MAAA,GACxB,IAAA,GACA,MAAA,CAAO,MAAA,KAAW,MAAA,GACf,MAAA,CAAO,MAAA,IAAU,IAAA,GACjB,MAAA,IAAU,IAAA;AACnB,IAAA,MAAM,cAAA,GAAiB,qBAAA;AAAA,MACrB,MAAA;AAAA,MACA,OAAA;AAAA,MACA,MAAA,IAAU;AAAA,KACZ;AAEA,IAAA,OAAO;AAAA,MACL,OAAA;AAAA,MACA,cAAA;AAAA,MACA,IAAA;AAAA,MACA,MAAA;AAAA,MACA,QAAQ,MAAA,IAAU,IAAA;AAAA,MAClB,gBAAA,EAAkB,OAAO,gBAAA,IAAoB,IAAA;AAAA,MAC7C,mBAAA;AAAA,MACA,cAAA,EAAgB,MAAA,CAAO,OAAA,EAAS,OAAA,IAAW,IAAA;AAAA,MAC3C,MAAA,EAAQ,OAAO,MAAA,IAAU,IAAA;AAAA,MACzB,QAAA;AAAA,MACA,yBAAA,EAA2B,MAAM,yBAAA,CAA8B,QAAQ;AAAA,KACzE;AAAA,EAGF,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,uBACE,GAAA,CAAC,mBAAA,EAAA,EAAoB,MAAA,EAAQ,WAAA,EAC3B,QAAA,kBAAA,GAAA,CAAC,aAAa,QAAA,EAAb,EAAsB,KAAA,EAAe,QAAA,EAAS,CAAA,EACjD,CAAA;AAEJ","file":"index.js","sourcesContent":["/**\n * Network → endpoint defaults.\n *\n * Reuses the resolution philosophy of the SDK sandbox env seam\n * (`resolveSandboxEnvironment`): explicit config beats a per-network default,\n * and the WebSocket endpoint is derived from the HTTP one when not given. This\n * is intentionally a SMALL, synchronous, SSR-safe mirror — the provider needs\n * no `process`/`fs` access and the sandbox seam's async file-reading path.\n *\n * @module provider/network\n */\nimport type { AgencNetwork } from \"../types.js\";\n\n/** Per-network default HTTP RPC endpoints. `mainnet` has no public default. */\nconst NETWORK_HTTP_DEFAULTS: Record<AgencNetwork, string | null> = {\n localnet: \"http://127.0.0.1:8899\",\n devnet: \"https://api.devnet.solana.com\",\n // No public default: mainnet RPC is operator-supplied (rate/cost sensitive).\n mainnet: null,\n};\n\n/**\n * `solana-test-validator` serves PubSub on RPC port + 1 (8900), so localnet's\n * WS endpoint is NOT derivable from the HTTP URL by scheme swap alone.\n */\nconst NETWORK_WS_DEFAULTS: Record<AgencNetwork, string | null> = {\n localnet: \"ws://127.0.0.1:8900\",\n devnet: \"wss://api.devnet.solana.com\",\n mainnet: null,\n};\n\n/** Derive a ws(s) endpoint from an http(s) one (same host/port/path). */\nexport function deriveSubscriptionsUrl(rpcUrl: string): string {\n if (/^https:\\/\\//i.test(rpcUrl)) {\n return `wss://${rpcUrl.slice(\"https://\".length)}`;\n }\n if (/^http:\\/\\//i.test(rpcUrl)) {\n return `ws://${rpcUrl.slice(\"http://\".length)}`;\n }\n return rpcUrl;\n}\n\n/** A resolved pair of RPC endpoints (either may be `null` when unresolvable). */\nexport interface ResolvedEndpoints {\n rpcUrl: string | null;\n rpcSubscriptionsUrl: string | null;\n}\n\n/**\n * Resolve the HTTP + WS RPC endpoints for a network, honoring explicit\n * overrides. Returns `{ rpcUrl: null }` when neither an override nor a default\n * exists (mainnet with no `rpcUrl`) — the provider treats that as \"no write\n * client buildable from URLs\", not a throw, so a read-only/indexer-only or\n * `client`-override setup still works.\n */\nexport function resolveEndpoints(\n network: AgencNetwork,\n rpcUrl?: string,\n rpcSubscriptionsUrl?: string,\n): ResolvedEndpoints {\n const resolvedRpc = rpcUrl ?? NETWORK_HTTP_DEFAULTS[network];\n const resolvedWs =\n rpcSubscriptionsUrl ??\n (rpcUrl !== undefined\n ? deriveSubscriptionsUrl(rpcUrl)\n : NETWORK_WS_DEFAULTS[network]);\n return { rpcUrl: resolvedRpc, rpcSubscriptionsUrl: resolvedWs };\n}\n","/**\n * Referrer config validation + the live referral-settlement capability.\n *\n * ## REFERRER SETTLEMENT\n *\n * Referrer args + the 4th settlement leg are part of the full\n * surface. The SDK `facade.hireFromListing` and\n * `facade.hireFromListingHumanless` both accept referrer fields. This module:\n * - ACCEPTS + VALIDATES `referrer: { wallet, feeBps }` and stores the normalized\n * form (validation is real: bad base58 throws, out-of-range bps rejected);\n * - exposes {@link resolveReferrerCapability}, which reports live when a valid\n * referrer config is present.\n *\n * Aggregated earnings are separate from settlement. `useReferrerEarnings` still\n * remains indexer-gated and must not fabricate totals before that endpoint is\n * published.\n *\n * @module provider/referrer\n */\nimport { isAddress } from \"@solana/kit\";\nimport { t } from \"../strings/index.js\";\nimport type {\n Address,\n ReferrerCapability,\n ReferrerConfig,\n ValidatedReferrerConfig,\n} from \"../types.js\";\n\n/** Minimum referral fee, in basis points. */\nexport const REFERRER_FEE_BPS_MIN = 0;\n/**\n * Maximum referral fee, in basis points. Mirrors the on-chain per-leg cap\n * (`MAX_REFERRER_FEE_BPS = 2000`) so invalid provider config fails before the\n * user signs a transaction.\n */\nexport const REFERRER_FEE_BPS_MAX = 2_000;\n\n/**\n * Validate + normalize a raw {@link ReferrerConfig} into a\n * {@link ValidatedReferrerConfig}.\n *\n * @throws TypeError when `wallet` is not a valid base58 Solana address.\n * @throws RangeError when `feeBps` is not an integer in\n * `[REFERRER_FEE_BPS_MIN, REFERRER_FEE_BPS_MAX]`.\n */\nexport function validateReferrerConfig(\n config: ReferrerConfig,\n): ValidatedReferrerConfig {\n const { wallet, feeBps } = config;\n if (typeof wallet !== \"string\" || !isAddress(wallet)) {\n throw new TypeError(t(\"referrer.invalidWallet\", { wallet: String(wallet) }));\n }\n if (\n typeof feeBps !== \"number\" ||\n !Number.isInteger(feeBps) ||\n feeBps < REFERRER_FEE_BPS_MIN ||\n feeBps > REFERRER_FEE_BPS_MAX\n ) {\n throw new RangeError(\n t(\"referrer.invalidFeeBps\", {\n min: REFERRER_FEE_BPS_MIN,\n max: REFERRER_FEE_BPS_MAX,\n feeBps: String(feeBps),\n }),\n );\n }\n return { wallet: wallet as Address, feeBps };\n}\n\n/**\n * Resolve whether a referral fee can actually be charged by this provider.\n *\n * @param referrer - The validated referrer config under the provider, or null.\n * @returns A {@link ReferrerCapability}; live only when a referrer is configured.\n */\nexport function resolveReferrerCapability(\n referrer: ValidatedReferrerConfig | null,\n): ReferrerCapability {\n if (!referrer) {\n return {\n live: false,\n reason: t(\"referrer.notLiveReason\"),\n };\n }\n return {\n live: true,\n referrer,\n };\n}\n","/**\n * `<AgencProvider>` — the one context that wires reads, writes, and the\n * live referrer config for every AgenC hook/component beneath it.\n *\n * Wraps a bundled TanStack {@link QueryClientProvider} so hooks get\n * caching/refetch/optimistic states with no consumer config. The\n * {@link AgencProviderConfig.client} and {@link AgencProviderConfig.queryTransport}\n * slots are PUBLIC test seams: `startLocalMarketplace().client` plugs straight\n * into `client` for hook e2e, and a mock {@link ReadTransport} plugs into\n * `queryTransport`.\n *\n * SSR-safe: no `window`/`document` access at module scope or during render. The\n * provider memoizes the context value and QueryClient on config identity.\n *\n * @module provider/AgencProvider\n */\nimport {\n QueryClient,\n QueryClientProvider,\n type QueryClientConfig,\n} from \"@tanstack/react-query\";\nimport { createMarketplaceClient } from \"@tetsuo-ai/marketplace-sdk\";\nimport { useMemo, useState, type ReactNode } from \"react\";\nimport { walletStandardChainForNetwork } from \"../signers/wallet-account.js\";\nimport { createReadTransport } from \"../transport/index.js\";\nimport type {\n AgencContextValue,\n AgencNetwork,\n AgencProviderConfig,\n MarketplaceClient,\n ReadTransport,\n ValidatedReferrerConfig,\n} from \"../types.js\";\nimport { AgencContext } from \"./context.js\";\nimport { resolveEndpoints } from \"./network.js\";\nimport {\n resolveReferrerCapability as resolveReferrerCapabilityImpl,\n validateReferrerConfig,\n} from \"./referrer.js\";\n\n/** Props for {@link AgencProvider}. */\nexport interface AgencProviderProps {\n /** Provider configuration. See {@link AgencProviderConfig}. */\n config: AgencProviderConfig;\n /**\n * Optional pre-built TanStack QueryClient. When omitted, the provider creates\n * one lazily (stable across renders). Pass your own to share a cache with the\n * rest of your app.\n */\n queryClient?: QueryClient;\n /** Override config for the lazily-created QueryClient (ignored if you pass one). */\n queryClientConfig?: QueryClientConfig;\n children: ReactNode;\n}\n\n/** Default QueryClient tuning for marketplace reads (sane, overridable). */\nconst DEFAULT_QUERY_CLIENT_CONFIG: QueryClientConfig = {\n defaultOptions: {\n queries: {\n // Marketplace listings change on-chain slowly relative to a UI session;\n // a short stale window avoids refetch storms while staying fresh.\n staleTime: 15_000,\n retry: 1,\n refetchOnWindowFocus: false,\n },\n },\n};\n\n// Opaque override objects do not expose a deployment id. Give each one a\n// process-local identity so switching objects is cache-safe. Persisted/SSR\n// caches should use config.cacheNamespace for a stable cross-runtime id.\nconst OPAQUE_DEPLOYMENT_IDS = new WeakMap<object, number>();\nlet nextOpaqueDeploymentId = 1;\n\nfunction opaqueDeploymentId(value: object | undefined): number | null {\n if (value === undefined) return null;\n const existing = OPAQUE_DEPLOYMENT_IDS.get(value);\n if (existing !== undefined) return existing;\n const allocated = nextOpaqueDeploymentId++;\n OPAQUE_DEPLOYMENT_IDS.set(value, allocated);\n return allocated;\n}\n\n/** Keep credentials/private labels out of query keys (identity use only). */\nfunction cacheFingerprint(value: string | null | undefined): string | null {\n if (value == null) return null;\n let hash = 0xcbf29ce484222325n;\n for (let index = 0; index < value.length; index += 1) {\n hash ^= BigInt(value.charCodeAt(index));\n hash = BigInt.asUintN(64, hash * 0x100000001b3n);\n }\n return hash.toString(16).padStart(16, \"0\");\n}\n\nfunction resolveCacheNamespace(\n config: AgencProviderConfig,\n network: AgencNetwork,\n rpcUrl: string | null,\n): string {\n const explicit = config.cacheNamespace?.trim();\n if (config.cacheNamespace !== undefined && !explicit) {\n throw new TypeError(\"AgencProvider cacheNamespace must not be empty.\");\n }\n return JSON.stringify({\n version: 1,\n network,\n rpc: cacheFingerprint(rpcUrl),\n indexer: cacheFingerprint(config.indexer?.baseUrl),\n custom: cacheFingerprint(explicit),\n queryTransport:\n explicit === undefined ? opaqueDeploymentId(config.queryTransport) : null,\n client: explicit === undefined ? opaqueDeploymentId(config.client) : null,\n });\n}\n\n/**\n * Build the read transport from config. The `queryTransport` override wins;\n * otherwise indexer-first (when `indexer.baseUrl` is set) with a gPA fallback\n * over the resolved RPC URL.\n *\n * NOTE: the gPA fallback needs a kit `Rpc<GetProgramAccountsApi>`, which we do\n * NOT build here from a bare URL — the SDK write client owns RPC construction.\n * When only a URL (no indexer, no queryTransport) is available, reads require\n * an indexer; the transport factory throws a descriptive error on first use.\n */\nfunction buildReadTransport(\n config: AgencProviderConfig,\n): ReadTransport {\n return createReadTransport({\n indexer: config.indexer,\n queryTransport: config.queryTransport,\n // The gPA read source is provided only via queryTransport in v1 (a kit RPC\n // or ProgramAccountsTransport). A future revision can derive a kit RPC from\n // the resolved rpcUrl; for now indexer-first is the supported read path and\n // queryTransport is the test/mocks seam.\n });\n}\n\n/**\n * Build the write client from config. The `client` override wins. Otherwise a\n * client is built only when BOTH a resolvable `rpcUrl` and a `signer` exist;\n * absent either, the provider exposes `client: null` and mutating hooks surface\n * a clear error (read-only / indexer-only setups are valid).\n */\nfunction buildWriteClient(\n config: AgencProviderConfig,\n network: AgencNetwork,\n): MarketplaceClient | null {\n if (config.client) return config.client;\n if (!config.signer) return null;\n const { rpcUrl, rpcSubscriptionsUrl } = resolveEndpoints(\n network,\n config.rpcUrl,\n config.rpcSubscriptionsUrl,\n );\n if (rpcUrl === null) return null;\n return createMarketplaceClient({\n rpcUrl,\n ...(rpcSubscriptionsUrl ? { rpcSubscriptionsUrl } : {}),\n signer: config.signer,\n });\n}\n\n/** Validate wallet-bridge signers with chain metadata; generic signers are opaque. */\nfunction assertSignerMatchesNetwork(\n signer: unknown,\n network: AgencNetwork,\n source: string,\n): void {\n const chain =\n typeof signer === \"object\" && signer !== null && \"chain\" in signer\n ? (signer as { readonly chain?: unknown }).chain\n : undefined;\n if (typeof chain !== \"string\") return;\n const expected = walletStandardChainForNetwork(network);\n if (chain !== expected) {\n throw new Error(\n `${source} is bound to ${chain}, but AgencProvider network ${network} requires ${expected}.`,\n );\n }\n}\n\n/**\n * The AgenC provider. Place at the root of any tree that uses AgenC hooks or\n * components.\n *\n * @example\n * ```tsx\n * <AgencProvider config={{ network: \"devnet\", indexer: { baseUrl } }}>\n * <App />\n * </AgencProvider>\n * ```\n */\nexport function AgencProvider(props: AgencProviderProps): ReactNode {\n const { config, children } = props;\n\n // Lazily create (and keep stable) the QueryClient. useState initializer runs\n // once; passing your own `queryClient` overrides it.\n const [internalQueryClient] = useState<QueryClient>(\n () =>\n props.queryClient ??\n new QueryClient(props.queryClientConfig ?? DEFAULT_QUERY_CLIENT_CONFIG),\n );\n const queryClient = props.queryClient ?? internalQueryClient;\n\n const value = useMemo<AgencContextValue>(() => {\n const network: AgencNetwork = config.network ?? \"mainnet\";\n\n assertSignerMatchesNetwork(config.signer, network, \"config.signer\");\n assertSignerMatchesNetwork(\n config.client?.signer,\n network,\n \"config.client.signer\",\n );\n\n // Validate + normalize referrer at provider construction. A bad config\n // throws here, before any hire transaction can be built.\n const referrer: ValidatedReferrerConfig | null = config.referrer\n ? validateReferrerConfig(config.referrer)\n : null;\n\n const read = buildReadTransport(config);\n const client = buildWriteClient(config, network);\n\n // The resolved HTTP RPC endpoint, exposed so hooks can make single-account\n // reads (e.g. resolving the WP-A1 roster-attestor account at activation)\n // without an indexer. Not a gPA source — the read transport owns list\n // queries.\n const { rpcUrl } = resolveEndpoints(\n network,\n config.rpcUrl,\n config.rpcSubscriptionsUrl,\n );\n // A custom write client is an opaque deployment seam. Never couple it to\n // the selected network's implicit endpoint: reconciliation against the\n // wrong cluster can block a valid local/custom transaction or, worse,\n // produce misleading state evidence. An explicitly supplied URL remains\n // opt-in; an injected RPC wins over either URL path.\n const orchestrationRpcUrl =\n config.orchestrationRpc !== undefined\n ? null\n : config.client !== undefined\n ? (config.rpcUrl ?? null)\n : (rpcUrl ?? null);\n const cacheNamespace = resolveCacheNamespace(\n config,\n network,\n rpcUrl ?? null,\n );\n\n return {\n network,\n cacheNamespace,\n read,\n client,\n rpcUrl: rpcUrl ?? null,\n orchestrationRpc: config.orchestrationRpc ?? null,\n orchestrationRpcUrl,\n indexerBaseUrl: config.indexer?.baseUrl ?? null,\n signer: config.signer ?? null,\n referrer,\n resolveReferrerCapability: () => resolveReferrerCapabilityImpl(referrer),\n };\n // Re-resolve when any wiring input changes. Referrer object identity is\n // intentionally part of the deps (a new referrer config must re-validate).\n }, [config]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <AgencContext.Provider value={value}>{children}</AgencContext.Provider>\n </QueryClientProvider>\n );\n}\n"]}
|
package/dist/signers/index.cjs
CHANGED
|
@@ -1,168 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkR76EUYDI_cjs = require('../chunk-R76EUYDI.cjs');
|
|
4
|
+
require('../chunk-FIDFPM5A.cjs');
|
|
4
5
|
|
|
5
|
-
// src/signers/wallet-account.ts
|
|
6
6
|
|
|
7
|
-
// src/strings/index.ts
|
|
8
|
-
var EN_STRINGS = {
|
|
9
|
-
// Provider / context wiring errors (developer-facing, but routed for parity).
|
|
10
|
-
"provider.missingContext": "useAgencContext must be used within <AgencProvider>.",
|
|
11
|
-
"provider.missingWriteClient": "No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.",
|
|
12
|
-
"provider.missingSigner": "No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.",
|
|
13
|
-
// Referrer config validation / capability surface.
|
|
14
|
-
"referrer.invalidWallet": "Referrer wallet is not a valid base58 Solana address: {wallet}.",
|
|
15
|
-
"referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.",
|
|
16
|
-
"referrer.notLive": "Referral fee is not active for this hire.",
|
|
17
|
-
"referrer.notLiveReason": "No referrer is configured for this provider.",
|
|
18
|
-
"referrer.earningsNotLiveReason": "Referral settlement is live, but no earnings endpoint is available on this network (configure indexer.baseUrl).",
|
|
19
|
-
"referrer.earningsFetchFailed": "The referrer earnings endpoint could not be read.",
|
|
20
|
-
// Read transport.
|
|
21
|
-
"transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().",
|
|
22
|
-
// Generic loading / empty / error states (components extend these).
|
|
23
|
-
"state.loading": "Loading\u2026",
|
|
24
|
-
"state.empty": "Nothing to show yet.",
|
|
25
|
-
"state.error": "Something went wrong.",
|
|
26
|
-
// Hire flow shells (components fill out the rest).
|
|
27
|
-
"hire.cta": "Hire",
|
|
28
|
-
"hire.pending": "Confirming\u2026",
|
|
29
|
-
"hire.funded": "Escrow funded."
|
|
30
|
-
};
|
|
31
|
-
function t(id, vars, options) {
|
|
32
|
-
const catalog = options?.catalog ?? EN_STRINGS;
|
|
33
|
-
const template = catalog[id] ?? id;
|
|
34
|
-
if (vars === void 0) return template;
|
|
35
|
-
return template.replace(/\{(\w+)\}/g, (match, key) => {
|
|
36
|
-
const value = vars[key];
|
|
37
|
-
return value === void 0 ? match : String(value);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
7
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
function resolveChain(account, options) {
|
|
62
|
-
if (options.chain) return options.chain;
|
|
63
|
-
return account.chains?.find((c) => c.startsWith("solana:"));
|
|
64
|
-
}
|
|
65
|
-
function signerFromWalletAccount(account, options = {}) {
|
|
66
|
-
const signerAddress = kit.address(account.address);
|
|
67
|
-
const signTransaction = resolveSignTransaction(account, options);
|
|
68
|
-
const chain = resolveChain(account, options);
|
|
69
|
-
const encoder = kit.getTransactionEncoder();
|
|
70
|
-
const decoder = kit.getTransactionDecoder();
|
|
71
|
-
async function signOne(transaction) {
|
|
72
|
-
const wireBytes = new Uint8Array(encoder.encode(transaction));
|
|
73
|
-
const [output] = await signTransaction({
|
|
74
|
-
transaction: wireBytes,
|
|
75
|
-
...chain ? { chain } : {}
|
|
76
|
-
});
|
|
77
|
-
if (!output) {
|
|
78
|
-
throw new Error(ts("signer.walletNoSignature", { address: account.address }));
|
|
79
|
-
}
|
|
80
|
-
const signed = decoder.decode(output.signedTransaction);
|
|
81
|
-
const signature = signed.signatures[signerAddress];
|
|
82
|
-
if (!signature) {
|
|
83
|
-
throw new Error(ts("signer.walletNoSignature", { address: account.address }));
|
|
84
|
-
}
|
|
85
|
-
return signature;
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
address: signerAddress,
|
|
89
|
-
async signTransactions(transactions) {
|
|
90
|
-
return Promise.all(
|
|
91
|
-
transactions.map(async (transaction) => ({
|
|
92
|
-
[signerAddress]: await signOne(transaction)
|
|
93
|
-
}))
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function resolveAdapterAddress(adapter) {
|
|
99
|
-
const { publicKey } = adapter;
|
|
100
|
-
if (publicKey == null) {
|
|
101
|
-
throw new Error(ts("signer.walletAdapterDisconnected"));
|
|
102
|
-
}
|
|
103
|
-
if (typeof publicKey === "string") return publicKey;
|
|
104
|
-
if ("toBase58" in publicKey && typeof publicKey.toBase58 === "function") {
|
|
105
|
-
return publicKey.toBase58();
|
|
106
|
-
}
|
|
107
|
-
return String(publicKey);
|
|
108
|
-
}
|
|
109
|
-
function signerFromWalletAdapter(adapter, options) {
|
|
110
|
-
const signerAddress = kit.address(resolveAdapterAddress(adapter));
|
|
111
|
-
const { signTransaction } = adapter;
|
|
112
|
-
if (typeof signTransaction !== "function") {
|
|
113
|
-
throw new Error(ts("signer.walletAdapterNoSign"));
|
|
114
|
-
}
|
|
115
|
-
const { VersionedTransaction } = options;
|
|
116
|
-
const encoder = kit.getTransactionEncoder();
|
|
117
|
-
const decoder = kit.getTransactionDecoder();
|
|
118
|
-
async function signOne(transaction) {
|
|
119
|
-
const wireBytes = new Uint8Array(encoder.encode(transaction));
|
|
120
|
-
const legacyTx = VersionedTransaction.deserialize(wireBytes);
|
|
121
|
-
const signed = await signTransaction(legacyTx);
|
|
122
|
-
const signedTx = decoder.decode(new Uint8Array(signed.serialize()));
|
|
123
|
-
const signature = signedTx.signatures[signerAddress];
|
|
124
|
-
if (!signature) {
|
|
125
|
-
throw new Error(
|
|
126
|
-
ts("signer.walletNoSignature", { address: signerAddress })
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
return signature;
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
address: signerAddress,
|
|
133
|
-
async signTransactions(transactions) {
|
|
134
|
-
return Promise.all(
|
|
135
|
-
transactions.map(async (transaction) => ({
|
|
136
|
-
[signerAddress]: await signOne(transaction)
|
|
137
|
-
}))
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function signerFromEmbeddedWallet(connection) {
|
|
143
|
-
const signerAddress = kit.address(connection.address);
|
|
144
|
-
return {
|
|
145
|
-
address: signerAddress,
|
|
146
|
-
async signTransactions(transactions) {
|
|
147
|
-
const signatures = await connection.signTransactions(transactions);
|
|
148
|
-
if (signatures.length !== transactions.length) {
|
|
149
|
-
throw new Error(
|
|
150
|
-
ts("signer.embeddedSignatureCount", {
|
|
151
|
-
expected: transactions.length,
|
|
152
|
-
got: signatures.length
|
|
153
|
-
})
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
return transactions.map((_, i) => ({
|
|
157
|
-
[signerAddress]: signatures[i]
|
|
158
|
-
}));
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
exports.EN_SIGNER_STRINGS = EN_SIGNER_STRINGS;
|
|
164
|
-
exports.signerFromEmbeddedWallet = signerFromEmbeddedWallet;
|
|
165
|
-
exports.signerFromWalletAccount = signerFromWalletAccount;
|
|
166
|
-
exports.signerFromWalletAdapter = signerFromWalletAdapter;
|
|
8
|
+
Object.defineProperty(exports, "EN_SIGNER_STRINGS", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkR76EUYDI_cjs.EN_SIGNER_STRINGS; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "signerFromEmbeddedWallet", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkR76EUYDI_cjs.signerFromEmbeddedWallet; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "signerFromWalletAccount", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkR76EUYDI_cjs.signerFromWalletAccount; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "signerFromWalletAdapter", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkR76EUYDI_cjs.signerFromWalletAdapter; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "walletStandardChainForNetwork", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunkR76EUYDI_cjs.walletStandardChainForNetwork; }
|
|
27
|
+
});
|
|
167
28
|
//# sourceMappingURL=index.cjs.map
|
|
168
29
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/strings/index.ts","../../src/signers/strings.ts","../../src/signers/wallet-account.ts","../../src/signers/wallet-adapter.ts","../../src/signers/embedded-wallet.ts"],"names":["address","getTransactionEncoder","getTransactionDecoder"],"mappings":";;;;;;;AAkCO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,yBAAA,EACE,sDAAA;AAAA,EACF,6BAAA,EACE,uIAAA;AAAA,EACF,wBAAA,EACE,qFAAA;AAAA;AAAA,EAGF,wBAAA,EACE,iEAAA;AAAA,EACF,wBAA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ACF;AC5GO,SAAS,yBACd,UAAA,EACmB;AACnB,EAAA,MAAM,aAAA,GAAgBF,WAAAA,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":"index.cjs","sourcesContent":["/**\n * Minimal English string catalog + a `t(id, vars?)` resolver.\n *\n * Every user-facing string in this package and its downstream hooks/components\n * routes through this module so a future `{ locale }` can resolve translations\n * **without an API break** (PLAN_2 Part A design constraint). v1 ships English\n * only; the resolver signature is already locale-shaped.\n *\n * ## Why a catalog and not inline literals\n *\n * Components published to third parties cannot assume the host's language. By\n * keying every literal here:\n * - adding a locale is a data change (a new {@link StringCatalog}), not a code\n * change to every component;\n * - the message ids are a stable contract the components agent binds to;\n * - `{var}` interpolation is centralized and SSR-safe (pure string ops, no\n * `Intl` global assumptions at module scope).\n *\n * @module strings\n */\n\n/**\n * The catalog shape: every message id maps to an English template. `{name}`\n * placeholders are filled by {@link t} from the `vars` argument.\n */\nexport interface StringCatalog {\n readonly [id: string]: string;\n}\n\n/**\n * Default English catalog. Keep ids namespaced by surface\n * (`provider.*`, `referrer.*`, `transport.*`, `hire.*`, ...) so the components\n * agent can extend it without collisions.\n */\nexport const EN_STRINGS = {\n // Provider / context wiring errors (developer-facing, but routed for parity).\n \"provider.missingContext\":\n \"useAgencContext must be used within <AgencProvider>.\",\n \"provider.missingWriteClient\":\n \"No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.\",\n \"provider.missingSigner\":\n \"No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.\",\n\n // Referrer config validation / capability surface.\n \"referrer.invalidWallet\":\n \"Referrer wallet is not a valid base58 Solana address: {wallet}.\",\n \"referrer.invalidFeeBps\":\n \"Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.\",\n \"referrer.notLive\":\n \"Referral fee is not active for this hire.\",\n \"referrer.notLiveReason\":\n \"No referrer is configured for this provider.\",\n \"referrer.earningsNotLiveReason\":\n \"Referral settlement is live, but no earnings endpoint is available on this network (configure indexer.baseUrl).\",\n \"referrer.earningsFetchFailed\":\n \"The referrer earnings endpoint could not be read.\",\n\n // Read transport.\n \"transport.noReadSource\":\n \"No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().\",\n\n // Generic loading / empty / error states (components extend these).\n \"state.loading\": \"Loading…\",\n \"state.empty\": \"Nothing to show yet.\",\n \"state.error\": \"Something went wrong.\",\n\n // Hire flow shells (components fill out the rest).\n \"hire.cta\": \"Hire\",\n \"hire.pending\": \"Confirming…\",\n \"hire.funded\": \"Escrow funded.\",\n} as const satisfies StringCatalog;\n\n/** A message id present in the default English catalog. */\nexport type StringId = keyof typeof EN_STRINGS;\n\n/** Interpolation variables for {@link t}: `{name}` → `vars.name`. */\nexport type StringVars = Record<string, string | number | bigint>;\n\n/**\n * Options for {@link t}. `locale` is accepted today (English-only) so adding\n * real locales later does not break the call signature; `catalog` lets a host\n * inject an override/extension catalog.\n */\nexport interface TranslateOptions {\n /** BCP-47 locale tag. v1 resolves everything to English regardless. */\n locale?: string;\n /** Override catalog (e.g. a future locale, or host-supplied copy). */\n catalog?: StringCatalog;\n}\n\n/**\n * Resolve a message id to its localized string with `{var}` interpolation.\n *\n * Unknown ids and unmatched placeholders are returned verbatim (the id itself,\n * or the `{placeholder}` left intact) rather than throwing — a missing string\n * must never crash a money-handling UI.\n *\n * @param id - The message id (a {@link StringId}, or any string for host\n * catalogs).\n * @param vars - Values for `{name}` placeholders in the template.\n * @param options - Optional `locale` (forward-compatible) and `catalog`\n * override.\n * @returns The interpolated string.\n *\n * @example\n * ```ts\n * t(\"referrer.invalidFeeBps\", { min: 0, max: 10000, feeBps: 99999 });\n * // -> \"Referrer feeBps must be an integer between 0 and 10000 ...; got 99999.\"\n * ```\n */\nexport function t(\n id: StringId | (string & {}),\n vars?: StringVars,\n options?: TranslateOptions,\n): string {\n const catalog: StringCatalog = options?.catalog ?? EN_STRINGS;\n const template = catalog[id] ?? id;\n if (vars === undefined) return template;\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => {\n const value = vars[key];\n return value === undefined ? match : String(value);\n });\n}\n","/**\n * Signer-adapter string catalog (the `signer.*` namespace).\n *\n * Kept local to `src/signers/**` so the adapters route every user-facing string\n * through the package's {@link t} resolver (the PLAN_2 Part A locale contract)\n * WITHOUT cross-editing the shared `src/strings` catalog owned by another\n * surface. A future locale can extend `EN_SIGNER_STRINGS` the same way.\n *\n * @module signers/strings\n */\nimport { t, type StringCatalog } from \"../strings/index.js\";\n\n/** English `signer.*` strings used by the wallet/embedded adapters. */\nexport const EN_SIGNER_STRINGS = {\n \"signer.walletNoSignFeature\":\n \"Wallet account {address} does not expose a solana:signTransaction feature. Pass options.signTransaction explicitly, or use a Wallet Standard account that supports transaction signing.\",\n \"signer.walletNoSignature\":\n \"The wallet returned no signature for account {address}. The wallet may have rejected or modified the transaction so the fee-payer signature is absent.\",\n \"signer.embeddedSignatureCount\":\n \"Embedded wallet returned {got} signatures for {expected} transactions; expected one per transaction.\",\n \"signer.walletAdapterDisconnected\":\n \"The wallet adapter is not connected (publicKey is null). Connect the wallet before creating a signer.\",\n \"signer.walletAdapterNoSign\":\n \"The wallet adapter does not expose signTransaction. Use a wallet that supports transaction signing, or migrate to the Wallet Standard path (signerFromWalletAccount).\",\n} as const satisfies StringCatalog;\n\n/** A `signer.*` message id. */\nexport type SignerStringId = keyof typeof EN_SIGNER_STRINGS;\n\n/**\n * `t()` bound to the signer catalog: resolves `signer.*` ids while preserving\n * the shared resolver's interpolation + verbatim-fallback behavior.\n */\nexport function ts(\n id: SignerStringId,\n vars?: Record<string, string | number | bigint>,\n): string {\n return t(id, vars, { catalog: EN_SIGNER_STRINGS });\n}\n","/**\n * Wallet Standard → kit `TransactionSigner` bridge (PLAN.md P4.1 / PLAN_2 D-1).\n *\n * Turns a connected browser wallet into the {@link TransactionSigner} the SDK's\n * `createMarketplaceClient` consumes. The SDK client signs via\n * `signTransactionMessageWithSigners(...)` and submits through its OWN transport\n * — so it needs a PARTIAL signer (one that returns signatures without sending),\n * NOT a `TransactionSendingSigner` (which `signTransactionMessageWithSigners`\n * deliberately ignores). This bridge therefore produces a\n * {@link TransactionPartialSigner}: it serializes each transaction, hands it to\n * the wallet's `solana:signTransaction` feature, and diffs the returned signed\n * transaction to recover THIS account's signature.\n *\n * @see {@link signerFromWalletAccount}\n * @module signers/wallet-account\n */\nimport {\n address,\n getTransactionDecoder,\n getTransactionEncoder,\n type Address,\n type SignatureBytes,\n type Transaction,\n} from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type {\n SignerFromWalletAccountOptions,\n TransactionSigner,\n WalletStandardAccountLike,\n WalletStandardSignTransaction,\n} from \"./types.js\";\n\nconst SOLANA_SIGN_TRANSACTION = \"solana:signTransaction\";\n\n/** Resolve the wallet's `solana:signTransaction` method from account/options. */\nfunction resolveSignTransaction(\n account: WalletStandardAccountLike,\n options: SignerFromWalletAccountOptions,\n): WalletStandardSignTransaction {\n if (options.signTransaction) return options.signTransaction;\n const feature = account.features?.[SOLANA_SIGN_TRANSACTION] as\n | { signTransaction?: WalletStandardSignTransaction }\n | undefined;\n if (feature?.signTransaction) return feature.signTransaction;\n throw new Error(ts(\"signer.walletNoSignFeature\", { address: account.address }));\n}\n\n/** Pick the CAIP-2 chain to forward to the wallet. */\nfunction resolveChain(\n account: WalletStandardAccountLike,\n options: SignerFromWalletAccountOptions,\n): string | undefined {\n if (options.chain) return options.chain;\n return account.chains?.find((c) => c.startsWith(\"solana:\"));\n}\n\n/**\n * Bridge a Wallet Standard account into a kit {@link TransactionSigner}.\n *\n * Accepts either a real `UiWalletAccount` (the `@solana/react` path — pass the\n * account and a `chain`, or pass the hook's feature via\n * {@link SignerFromWalletAccountOptions.signTransaction}) or any object exposing\n * the `solana:signTransaction` feature. The returned signer is a\n * {@link TransactionPartialSigner}, the exact shape the SDK client expects.\n *\n * Wallets may MODIFY a transaction before signing (priority fees, guard\n * instructions). We honor that by decoding the wallet's returned signed\n * transaction and extracting only THIS account's signature; the SDK client then\n * re-assembles and submits. (If a wallet rewrites the message such that the\n * fee-payer's own prior signing is invalidated, that is a wallet contract the\n * SDK's single-fee-payer flow already assumes won't happen for the payer.)\n *\n * SSR-safe: constructs no browser globals; the wallet round-trip only runs when\n * a transaction is actually signed.\n *\n * @param account - The connected Wallet Standard account (needs `address`).\n * @param options - Chain + an optional explicit `signTransaction` override.\n * @returns A kit {@link TransactionSigner} usable as `config.signer`.\n * @throws Error if no `solana:signTransaction` feature can be resolved.\n *\n * @example\n * ```ts\n * // With @solana/react (Wallet Standard):\n * const account = useSelectedWalletAccount(); // UiWalletAccount\n * const signer = signerFromWalletAccount(account, { chain: \"solana:devnet\" });\n * // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.\n * ```\n */\nexport function signerFromWalletAccount(\n account: WalletStandardAccountLike,\n options: SignerFromWalletAccountOptions = {},\n): TransactionSigner {\n const signerAddress: Address = address(account.address);\n const signTransaction = resolveSignTransaction(account, options);\n const chain = resolveChain(account, options);\n const encoder = getTransactionEncoder();\n const decoder = getTransactionDecoder();\n\n async function signOne(transaction: Transaction): Promise<SignatureBytes> {\n const wireBytes = new Uint8Array(encoder.encode(transaction));\n const [output] = await signTransaction({\n transaction: wireBytes,\n ...(chain ? { chain } : {}),\n });\n if (!output) {\n throw new Error(ts(\"signer.walletNoSignature\", { address: account.address }));\n }\n const signed = decoder.decode(output.signedTransaction);\n const signature = signed.signatures[signerAddress];\n if (!signature) {\n throw new Error(ts(\"signer.walletNoSignature\", { address: account.address }));\n }\n return signature as SignatureBytes;\n }\n\n return {\n address: signerAddress,\n async signTransactions(transactions) {\n // Sign in parallel — partial signers are order-independent (each returns a\n // single-entry SignatureDictionary the caller merges).\n return Promise.all(\n transactions.map(async (transaction) => ({\n [signerAddress]: await signOne(transaction),\n })),\n );\n },\n } satisfies TransactionSigner;\n}\n","/**\n * LEGACY `@solana/wallet-adapter` compatibility shim (PLAN.md P4.1).\n *\n * The supported, robust path for browser wallets is the Wallet Standard bridge\n * ({@link signerFromWalletAccount} via `@solana/react`): every modern wallet —\n * including all wallet-adapter wallets — registers as a Wallet Standard wallet,\n * so a wallet-adapter app can migrate by reading the selected account through\n * `@solana/react` and dropping it into `signerFromWalletAccount`. PREFER THAT.\n *\n * This shim exists for apps still holding a raw wallet-adapter\n * `WalletContextState` (web3.js v1 `signTransaction`). It bridges WITHOUT a hard\n * dependency on `@solana/wallet-adapter-*` OR `@solana/web3.js` (1.x): the\n * caller injects the web3.js `VersionedTransaction` class (the only piece we\n * cannot reconstruct), and we round-trip through the shared wire format — a kit\n * {@link Transaction} and a web3.js `VersionedTransaction` serialize to the SAME\n * bytes, so no semantic re-encoding is needed.\n *\n * SSR-safe: no browser globals at module scope.\n *\n * @module signers/wallet-adapter\n */\nimport {\n address,\n getTransactionDecoder,\n getTransactionEncoder,\n type SignatureBytes,\n type Transaction,\n} from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type { TransactionSigner } from \"./types.js\";\n\n/**\n * The web3.js v1 `VersionedTransaction` surface this shim needs: a static\n * `deserialize(bytes)` and an instance `serialize()`. Pass the real class from\n * `@solana/web3.js` — typed structurally so this module never imports it.\n */\nexport interface VersionedTransactionLike {\n serialize(): Uint8Array;\n}\n\n/** The static side of the injected `VersionedTransaction` class. */\nexport interface VersionedTransactionCtor {\n deserialize(bytes: Uint8Array): VersionedTransactionLike;\n}\n\n/**\n * The minimal slice of a wallet-adapter `WalletContextState` this shim consumes.\n * Both `publicKey` (anything with a base58 `toString()`/`toBase58()`) and the\n * v1 `signTransaction` are required; a connected adapter exposes both.\n */\nexport interface WalletAdapterLike {\n /** The connected account's public key (base58 via `toBase58()`/`toString()`). */\n readonly publicKey:\n | { toBase58(): string }\n | { toString(): string }\n | string\n | null;\n /** web3.js v1 sign — returns the same transaction type, signed. */\n signTransaction?: <T extends VersionedTransactionLike>(\n transaction: T,\n ) => Promise<T>;\n}\n\n/** Options for {@link signerFromWalletAdapter}. */\nexport interface SignerFromWalletAdapterOptions {\n /**\n * The web3.js `VersionedTransaction` class (`import { VersionedTransaction }\n * from \"@solana/web3.js\"`). Required — it is the one piece this no-dep shim\n * cannot supply itself.\n */\n VersionedTransaction: VersionedTransactionCtor;\n}\n\nfunction resolveAdapterAddress(adapter: WalletAdapterLike): string {\n const { publicKey } = adapter;\n if (publicKey == null) {\n throw new Error(ts(\"signer.walletAdapterDisconnected\"));\n }\n if (typeof publicKey === \"string\") return publicKey;\n if (\"toBase58\" in publicKey && typeof publicKey.toBase58 === \"function\") {\n return publicKey.toBase58();\n }\n return String(publicKey);\n}\n\n/**\n * Bridge a LEGACY `@solana/wallet-adapter` `WalletContextState` into a kit\n * {@link TransactionSigner}.\n *\n * Use only when you cannot reach the wallet through `@solana/react`. The result\n * is a {@link TransactionPartialSigner} (the SDK client owns submission), built\n * by serializing the kit transaction to wire bytes, rehydrating it as a web3.js\n * `VersionedTransaction`, handing THAT to the adapter's `signTransaction`, then\n * decoding the signed wire bytes back to a kit transaction to extract this\n * account's signature.\n *\n * @param adapter - A connected wallet-adapter state (`publicKey` + `signTransaction`).\n * @param options - Must inject the web3.js `VersionedTransaction` class.\n * @returns A kit {@link TransactionSigner} usable as `config.signer`.\n * @throws Error if the adapter is disconnected or lacks `signTransaction`.\n *\n * @example\n * ```ts\n * import { VersionedTransaction } from \"@solana/web3.js\";\n * import { useWallet } from \"@solana/wallet-adapter-react\";\n *\n * const wallet = useWallet();\n * const signer = signerFromWalletAdapter(wallet, { VersionedTransaction });\n * // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.\n * ```\n */\nexport function signerFromWalletAdapter(\n adapter: WalletAdapterLike,\n options: SignerFromWalletAdapterOptions,\n): TransactionSigner {\n const signerAddress = address(resolveAdapterAddress(adapter));\n const { signTransaction } = adapter;\n if (typeof signTransaction !== \"function\") {\n throw new Error(ts(\"signer.walletAdapterNoSign\"));\n }\n const { VersionedTransaction } = options;\n const encoder = getTransactionEncoder();\n const decoder = getTransactionDecoder();\n\n async function signOne(transaction: Transaction): Promise<SignatureBytes> {\n const wireBytes = new Uint8Array(encoder.encode(transaction));\n const legacyTx = VersionedTransaction.deserialize(wireBytes);\n const signed = await signTransaction!(legacyTx);\n const signedTx = decoder.decode(new Uint8Array(signed.serialize()));\n const signature = signedTx.signatures[signerAddress];\n if (!signature) {\n throw new Error(\n ts(\"signer.walletNoSignature\", { address: signerAddress }),\n );\n }\n return signature as SignatureBytes;\n }\n\n return {\n address: signerAddress,\n async signTransactions(transactions) {\n return Promise.all(\n transactions.map(async (transaction) => ({\n [signerAddress]: await signOne(transaction),\n })),\n );\n },\n } satisfies TransactionSigner;\n}\n","/**\n * Embedded / walletless → kit `TransactionSigner` bridge (PLAN_2 D-1).\n *\n * The \"no wallet, no SOL\" buyer path. A vendor-neutral\n * {@link EmbeddedWalletProvider} (Privy / Dynamic / Web3Auth — `[HUMAN]`-gated)\n * handles email/social login + key custody; this module lifts a live\n * {@link EmbeddedWalletConnection} into the kit {@link TransactionSigner} the SDK\n * client consumes. As with the Wallet Standard bridge, the result is a PARTIAL\n * signer — the vendor signs, the SDK client's transport broadcasts.\n *\n * @see {@link signerFromEmbeddedWallet}\n * @see {@link createMockEmbeddedWallet} — the local-keypair test adapter.\n * @module signers/embedded-wallet\n */\nimport { address, type SignatureBytes, type Transaction } from \"@solana/kit\";\nimport { ts } from \"./strings.js\";\nimport type {\n EmbeddedWalletConnection,\n TransactionSigner,\n} from \"./types.js\";\n\n/**\n * Bridge a CONNECTED embedded-wallet connection into a kit\n * {@link TransactionSigner}.\n *\n * Call this AFTER `provider.connect()` resolves — it needs the live\n * {@link EmbeddedWalletConnection} (address + `signTransactions`). The hooks\n * layer (`useWalletSigner`) is expected to own the connect lifecycle and call\n * this once a connection exists.\n *\n * @param connection - A live embedded-wallet connection.\n * @returns A kit {@link TransactionSigner} usable as `config.signer`.\n *\n * @example\n * ```ts\n * const connection = await provider.connect(); // vendor login\n * const signer = signerFromEmbeddedWallet(connection);\n * // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.\n * ```\n */\nexport function signerFromEmbeddedWallet(\n connection: EmbeddedWalletConnection,\n): TransactionSigner {\n const signerAddress = address(connection.address);\n\n return {\n address: signerAddress,\n async signTransactions(transactions: readonly Transaction[]) {\n const signatures: readonly SignatureBytes[] =\n await connection.signTransactions(transactions);\n if (signatures.length !== transactions.length) {\n throw new Error(\n ts(\"signer.embeddedSignatureCount\", {\n expected: transactions.length,\n got: signatures.length,\n }),\n );\n }\n return transactions.map((_, i) => ({\n [signerAddress]: signatures[i] as SignatureBytes,\n }));\n },\n } satisfies TransactionSigner;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/signers/index.d.cts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { W as WalletStandardAccountLike, S as SignerFromWalletAccountOptions, E as EmbeddedWalletConnection } from '../types-
|
|
2
|
-
export { a as EmbeddedWalletProvider,
|
|
1
|
+
import { W as WalletStandardAccountLike, S as SignerFromWalletAccountOptions, C as ChainBoundTransactionSigner, b as SolanaWalletNetwork, E as EmbeddedWalletConnection } from '../types-B10rndEI.cjs';
|
|
2
|
+
export { a as EmbeddedWalletProvider, c as WalletStandardSignTransaction } from '../types-B10rndEI.cjs';
|
|
3
3
|
import { TransactionSigner } from '@solana/kit';
|
|
4
4
|
export { TransactionSigner } from '@solana/kit';
|
|
5
5
|
|
|
6
|
+
/** Map an AgenC provider network to the Wallet Standard chain identifier. */
|
|
7
|
+
declare function walletStandardChainForNetwork(network: SolanaWalletNetwork): string;
|
|
6
8
|
/**
|
|
7
9
|
* Bridge a Wallet Standard account into a kit {@link TransactionSigner}.
|
|
8
10
|
*
|
|
@@ -12,12 +14,9 @@ export { TransactionSigner } from '@solana/kit';
|
|
|
12
14
|
* the `solana:signTransaction` feature. The returned signer is a
|
|
13
15
|
* {@link TransactionPartialSigner}, the exact shape the SDK client expects.
|
|
14
16
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* re-assembles and submits. (If a wallet rewrites the message such that the
|
|
19
|
-
* fee-payer's own prior signing is invalidated, that is a wallet contract the
|
|
20
|
-
* SDK's single-fee-payer flow already assumes won't happen for the payer.)
|
|
17
|
+
* The SDK client re-assembles and submits the ORIGINAL transaction. This bridge
|
|
18
|
+
* therefore accepts only byte-identical returned message bytes and verifies the
|
|
19
|
+
* extracted signature over them.
|
|
21
20
|
*
|
|
22
21
|
* SSR-safe: constructs no browser globals; the wallet round-trip only runs when
|
|
23
22
|
* a transaction is actually signed.
|
|
@@ -35,7 +34,7 @@ export { TransactionSigner } from '@solana/kit';
|
|
|
35
34
|
* // -> pass `signer` to <AgencProvider config={{ signer, rpcUrl }}>.
|
|
36
35
|
* ```
|
|
37
36
|
*/
|
|
38
|
-
declare function signerFromWalletAccount(account: WalletStandardAccountLike, options?: SignerFromWalletAccountOptions):
|
|
37
|
+
declare function signerFromWalletAccount(account: WalletStandardAccountLike, options?: SignerFromWalletAccountOptions): ChainBoundTransactionSigner;
|
|
39
38
|
|
|
40
39
|
/**
|
|
41
40
|
* The web3.js v1 `VersionedTransaction` surface this shim needs: a static
|
|
@@ -125,7 +124,13 @@ declare function signerFromEmbeddedWallet(connection: EmbeddedWalletConnection):
|
|
|
125
124
|
/** English `signer.*` strings used by the wallet/embedded adapters. */
|
|
126
125
|
declare const EN_SIGNER_STRINGS: {
|
|
127
126
|
readonly "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.";
|
|
128
|
-
readonly "signer.walletNoSignature": "The wallet returned no signature for account {address}. The wallet may have rejected
|
|
127
|
+
readonly "signer.walletNoSignature": "The wallet returned no signature for account {address}. The wallet may have rejected the signing request.";
|
|
128
|
+
readonly "signer.walletResponseCount": "Wallet returned {got} signed transactions; expected {expected} ordered outputs, one per input.";
|
|
129
|
+
readonly "signer.walletModifiedTransaction": "Wallet modified the transaction message for account {address}. AgenC cannot attach a signature over different bytes to the original transaction.";
|
|
130
|
+
readonly "signer.walletInvalidSignature": "Wallet returned an invalid signature for account {address} over the requested transaction message.";
|
|
131
|
+
readonly "signer.walletChainRequired": "Wallet account {address} exposes {count} Solana chains. Select exactly one with options.chain or options.network.";
|
|
132
|
+
readonly "signer.walletChainUnsupported": "Wallet account {address} does not support requested chain {chain}.";
|
|
133
|
+
readonly "signer.walletChainNetworkMismatch": "Requested chain {chain} does not match options.network {network} ({expected}).";
|
|
129
134
|
readonly "signer.embeddedSignatureCount": "Embedded wallet returned {got} signatures for {expected} transactions; expected one per transaction.";
|
|
130
135
|
readonly "signer.walletAdapterDisconnected": "The wallet adapter is not connected (publicKey is null). Connect the wallet before creating a signer.";
|
|
131
136
|
readonly "signer.walletAdapterNoSign": "The wallet adapter does not expose signTransaction. Use a wallet that supports transaction signing, or migrate to the Wallet Standard path (signerFromWalletAccount).";
|
|
@@ -133,4 +138,4 @@ declare const EN_SIGNER_STRINGS: {
|
|
|
133
138
|
/** A `signer.*` message id. */
|
|
134
139
|
type SignerStringId = keyof typeof EN_SIGNER_STRINGS;
|
|
135
140
|
|
|
136
|
-
export { EN_SIGNER_STRINGS, EmbeddedWalletConnection, SignerFromWalletAccountOptions, type SignerFromWalletAdapterOptions, type SignerStringId, type VersionedTransactionCtor, type VersionedTransactionLike, type WalletAdapterLike, WalletStandardAccountLike, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter };
|
|
141
|
+
export { ChainBoundTransactionSigner, EN_SIGNER_STRINGS, EmbeddedWalletConnection, SignerFromWalletAccountOptions, type SignerFromWalletAdapterOptions, type SignerStringId, SolanaWalletNetwork, type VersionedTransactionCtor, type VersionedTransactionLike, type WalletAdapterLike, WalletStandardAccountLike, signerFromEmbeddedWallet, signerFromWalletAccount, signerFromWalletAdapter, walletStandardChainForNetwork };
|