@partylayer/react 0.2.5 → 0.2.6

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 CantonConnect
3
+ Copyright (c) 2024 PartyLayer
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -391,9 +391,9 @@ export default function App() {
391
391
 
392
392
  ## Links
393
393
 
394
- - [GitHub Repository](https://github.com/cayvox/PartyLayer)
395
- - [Documentation](https://github.com/cayvox/PartyLayer#readme)
396
- - [Report Issues](https://github.com/cayvox/PartyLayer/issues)
394
+ - [GitHub Repository](https://github.com/PartyLayer/PartyLayer)
395
+ - [Documentation](https://github.com/PartyLayer/PartyLayer#readme)
396
+ - [Report Issues](https://github.com/PartyLayer/PartyLayer/issues)
397
397
  - [Canton Network](https://www.canton.network/)
398
398
 
399
399
  ---
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _partylayer_sdk from '@partylayer/sdk';
3
- import { PartyLayerClient, Session, WalletInfo, ConnectOptions, RegistryStatus, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt } from '@partylayer/sdk';
3
+ import { PartyLayerClient, Session, WalletInfo, ConnectOptions, RegistryStatus, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, WalletAdapter, AdapterClass, WalletId, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, PartyId, AdapterConnectResult, DiscoveredProvider } from '@partylayer/sdk';
4
4
  import * as _partylayer_core from '@partylayer/core';
5
5
  export { RegistryStatus } from '@partylayer/registry-client';
6
6
 
@@ -15,8 +15,10 @@ declare function usePartyLayerContext(): PartyLayerContextValue;
15
15
  interface PartyLayerProviderProps {
16
16
  client: PartyLayerClient;
17
17
  children: React.ReactNode;
18
+ /** Network identifier for native CIP-0103 wallet discovery */
19
+ network?: string;
18
20
  }
19
- declare function PartyLayerProvider({ client, children, }: PartyLayerProviderProps): react_jsx_runtime.JSX.Element;
21
+ declare function PartyLayerProvider({ client, children, network, }: PartyLayerProviderProps): react_jsx_runtime.JSX.Element;
20
22
 
21
23
  /**
22
24
  * Hook to access PartyLayer client
@@ -48,6 +50,7 @@ declare function useConnect(): {
48
50
  connect: (options?: ConnectOptions) => Promise<Session | null>;
49
51
  isConnecting: boolean;
50
52
  error: Error | null;
53
+ reset: () => void;
51
54
  };
52
55
  /**
53
56
  * Hook to disconnect from a wallet
@@ -83,13 +86,154 @@ declare function useSubmitTransaction(): {
83
86
  };
84
87
 
85
88
  /**
86
- * Wallet selection modal component
89
+ * Lightweight theme system for PartyLayer UI components.
90
+ * No external CSS-in-JS dependency — just a token object + React context.
87
91
  */
92
+ interface PartyLayerTheme {
93
+ mode: 'light' | 'dark';
94
+ colors: {
95
+ primary: string;
96
+ primaryHover: string;
97
+ background: string;
98
+ surface: string;
99
+ text: string;
100
+ textSecondary: string;
101
+ border: string;
102
+ success: string;
103
+ successBg: string;
104
+ error: string;
105
+ errorBg: string;
106
+ warning: string;
107
+ warningBg: string;
108
+ overlay: string;
109
+ };
110
+ borderRadius: string;
111
+ fontFamily: string;
112
+ }
113
+ declare const lightTheme: PartyLayerTheme;
114
+ declare const darkTheme: PartyLayerTheme;
115
+ /**
116
+ * Access the current PartyLayer theme.
117
+ * Falls back to lightTheme if no ThemeProvider is present (backward-compatible).
118
+ */
119
+ declare function useTheme(): PartyLayerTheme;
120
+ interface ThemeProviderProps {
121
+ theme: 'light' | 'dark' | 'auto' | PartyLayerTheme;
122
+ children: React.ReactNode;
123
+ }
124
+ declare function ThemeProvider({ theme, children }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
125
+
126
+ /** Map of walletId → icon URL for custom wallet logos */
127
+ type WalletIconMap = Record<string, string>;
128
+ /** Access wallet icon overrides from PartyLayerKit */
129
+ declare function useWalletIcons(): WalletIconMap;
130
+ /**
131
+ * Resolve icon URL for a wallet. Priority:
132
+ * 1. walletIcons map (exact match or fuzzy)
133
+ * 2. wallet.icons.sm from registry
134
+ * 3. null (caller renders fallback)
135
+ */
136
+ declare function resolveWalletIcon(walletId: string, walletIcons: WalletIconMap, registryIconUrl?: string): string | null;
137
+ interface PartyLayerKitProps {
138
+ /** Canton network to connect to */
139
+ network: 'devnet' | 'testnet' | 'mainnet';
140
+ /** Application name shown to wallets during connection */
141
+ appName: string;
142
+ children: React.ReactNode;
143
+ /** Registry URL override (default: https://registry.partylayer.xyz) */
144
+ registryUrl?: string;
145
+ /** Registry channel (default: 'stable') */
146
+ channel?: 'stable' | 'beta';
147
+ /**
148
+ * Custom wallet adapters. If not provided, uses built-in adapters:
149
+ * Console Wallet, 5N Loop, Cantor8.
150
+ *
151
+ * For Bron (enterprise OAuth), pass explicitly:
152
+ * adapters={[...getBuiltinAdapters(), new BronAdapter(config)]}
153
+ */
154
+ adapters?: (WalletAdapter | AdapterClass)[];
155
+ /** Theme preset or custom theme object (default: 'light') */
156
+ theme?: 'light' | 'dark' | 'auto' | PartyLayerTheme;
157
+ /** Custom wallet icon URLs by walletId */
158
+ walletIcons?: WalletIconMap;
159
+ }
160
+ declare function PartyLayerKit({ network, appName, children, registryUrl, channel, adapters, theme, walletIcons, }: PartyLayerKitProps): react_jsx_runtime.JSX.Element;
161
+
88
162
  interface WalletModalProps {
89
163
  isOpen: boolean;
90
164
  onClose: () => void;
91
165
  onConnect: (sessionId: string) => void;
166
+ /** Custom wallet icon URLs (merged with PartyLayerKit context) */
167
+ walletIcons?: WalletIconMap;
168
+ }
169
+ declare function WalletModal({ isOpen, onClose, onConnect, walletIcons: propIcons, }: WalletModalProps): react_jsx_runtime.JSX.Element | null;
170
+
171
+ /**
172
+ * ConnectButton — Premium wallet connection button for Canton dApps.
173
+ *
174
+ * Manages the full lifecycle: disconnect → connect (via WalletModal) → connected state.
175
+ * Uses existing hooks (useSession, useConnect, useDisconnect) under the hood.
176
+ *
177
+ * Designed for dApp developers to embed directly — brand-aligned, accessible,
178
+ * and polished across light/dark themes.
179
+ */
180
+ interface ConnectButtonProps {
181
+ /** Button label when disconnected (default: "Connect Wallet") */
182
+ label?: string;
183
+ /** What to show when connected: partyId address, wallet name, or custom */
184
+ connectedLabel?: 'address' | 'wallet' | 'custom';
185
+ /** Custom formatter for connected display (requires connectedLabel='custom') */
186
+ formatAddress?: (partyId: string) => string;
187
+ /** Additional CSS class name */
188
+ className?: string;
189
+ /** Additional inline styles */
190
+ style?: React.CSSProperties;
191
+ /** Show disconnect option in dropdown (default: true) */
192
+ showDisconnect?: boolean;
193
+ }
194
+ /**
195
+ * Truncate a partyId for display: "party-abc123def456" → "party-abc...456"
196
+ */
197
+ declare function truncatePartyId(id: string, chars?: number): string;
198
+ declare function ConnectButton({ label, connectedLabel, formatAddress, className, style, showDisconnect, }: ConnectButtonProps): react_jsx_runtime.JSX.Element;
199
+
200
+ /**
201
+ * Native CIP-0103 Adapter
202
+ *
203
+ * Wraps a discovered CIP-0103 Provider into the PartyLayer WalletAdapter interface.
204
+ * This allows native CIP-0103 wallets (injected at window.canton.* etc.) to be used
205
+ * through the standard SDK connect flow alongside registry-based adapters.
206
+ */
207
+
208
+ /**
209
+ * A WalletAdapter that delegates to a native CIP-0103 Provider.
210
+ *
211
+ * Created dynamically when a CIP-0103 provider is discovered at runtime.
212
+ * Routes all SDK operations through the provider's `request()` method.
213
+ */
214
+ declare class NativeCIP0103Adapter implements WalletAdapter {
215
+ readonly walletId: WalletId;
216
+ readonly name: string;
217
+ private provider;
218
+ constructor(id: string, name: string, provider: CIP0103Provider);
219
+ getCapabilities(): CapabilityKey[];
220
+ detectInstalled(): Promise<AdapterDetectResult>;
221
+ connect(_ctx: AdapterContext, _opts?: {
222
+ timeoutMs?: number;
223
+ partyId?: PartyId;
224
+ }): Promise<AdapterConnectResult>;
225
+ disconnect(_ctx: AdapterContext, _session: Session): Promise<void>;
226
+ signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
227
+ signTransaction(_ctx: AdapterContext, _session: Session, params: SignTransactionParams): Promise<SignedTransaction>;
228
+ submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
92
229
  }
93
- declare function WalletModal({ isOpen, onClose, onConnect, }: WalletModalProps): react_jsx_runtime.JSX.Element | null;
230
+ /**
231
+ * Create a WalletAdapter from a discovered CIP-0103 provider.
232
+ */
233
+ declare function createNativeAdapter(discovered: DiscoveredProvider): NativeCIP0103Adapter;
234
+ /**
235
+ * Create a synthetic WalletInfo for a discovered native CIP-0103 provider.
236
+ */
237
+ declare function createSyntheticWalletInfo(discovered: DiscoveredProvider, network: string): WalletInfo;
94
238
 
95
- export { PartyLayerProvider as CantonConnectProvider, PartyLayerProvider, WalletModal, usePartyLayer as useCantonConnect, useConnect, useDisconnect, usePartyLayer, usePartyLayerContext, useRegistryStatus, useSession, useSignMessage, useSignTransaction, useSubmitTransaction, useWallets };
239
+ export { PartyLayerProvider as CantonConnectProvider, ConnectButton, type ConnectButtonProps, NativeCIP0103Adapter, PartyLayerKit, type PartyLayerKitProps, PartyLayerProvider, type PartyLayerTheme, ThemeProvider, type WalletIconMap, WalletModal, type WalletModalProps, createNativeAdapter, createSyntheticWalletInfo, darkTheme, lightTheme, resolveWalletIcon, truncatePartyId, usePartyLayer as useCantonConnect, useConnect, useDisconnect, usePartyLayer, usePartyLayerContext, useRegistryStatus, useSession, useSignMessage, useSignTransaction, useSubmitTransaction, useTheme, useWalletIcons, useWallets };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _partylayer_sdk from '@partylayer/sdk';
3
- import { PartyLayerClient, Session, WalletInfo, ConnectOptions, RegistryStatus, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt } from '@partylayer/sdk';
3
+ import { PartyLayerClient, Session, WalletInfo, ConnectOptions, RegistryStatus, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, WalletAdapter, AdapterClass, WalletId, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, PartyId, AdapterConnectResult, DiscoveredProvider } from '@partylayer/sdk';
4
4
  import * as _partylayer_core from '@partylayer/core';
5
5
  export { RegistryStatus } from '@partylayer/registry-client';
6
6
 
@@ -15,8 +15,10 @@ declare function usePartyLayerContext(): PartyLayerContextValue;
15
15
  interface PartyLayerProviderProps {
16
16
  client: PartyLayerClient;
17
17
  children: React.ReactNode;
18
+ /** Network identifier for native CIP-0103 wallet discovery */
19
+ network?: string;
18
20
  }
19
- declare function PartyLayerProvider({ client, children, }: PartyLayerProviderProps): react_jsx_runtime.JSX.Element;
21
+ declare function PartyLayerProvider({ client, children, network, }: PartyLayerProviderProps): react_jsx_runtime.JSX.Element;
20
22
 
21
23
  /**
22
24
  * Hook to access PartyLayer client
@@ -48,6 +50,7 @@ declare function useConnect(): {
48
50
  connect: (options?: ConnectOptions) => Promise<Session | null>;
49
51
  isConnecting: boolean;
50
52
  error: Error | null;
53
+ reset: () => void;
51
54
  };
52
55
  /**
53
56
  * Hook to disconnect from a wallet
@@ -83,13 +86,154 @@ declare function useSubmitTransaction(): {
83
86
  };
84
87
 
85
88
  /**
86
- * Wallet selection modal component
89
+ * Lightweight theme system for PartyLayer UI components.
90
+ * No external CSS-in-JS dependency — just a token object + React context.
87
91
  */
92
+ interface PartyLayerTheme {
93
+ mode: 'light' | 'dark';
94
+ colors: {
95
+ primary: string;
96
+ primaryHover: string;
97
+ background: string;
98
+ surface: string;
99
+ text: string;
100
+ textSecondary: string;
101
+ border: string;
102
+ success: string;
103
+ successBg: string;
104
+ error: string;
105
+ errorBg: string;
106
+ warning: string;
107
+ warningBg: string;
108
+ overlay: string;
109
+ };
110
+ borderRadius: string;
111
+ fontFamily: string;
112
+ }
113
+ declare const lightTheme: PartyLayerTheme;
114
+ declare const darkTheme: PartyLayerTheme;
115
+ /**
116
+ * Access the current PartyLayer theme.
117
+ * Falls back to lightTheme if no ThemeProvider is present (backward-compatible).
118
+ */
119
+ declare function useTheme(): PartyLayerTheme;
120
+ interface ThemeProviderProps {
121
+ theme: 'light' | 'dark' | 'auto' | PartyLayerTheme;
122
+ children: React.ReactNode;
123
+ }
124
+ declare function ThemeProvider({ theme, children }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
125
+
126
+ /** Map of walletId → icon URL for custom wallet logos */
127
+ type WalletIconMap = Record<string, string>;
128
+ /** Access wallet icon overrides from PartyLayerKit */
129
+ declare function useWalletIcons(): WalletIconMap;
130
+ /**
131
+ * Resolve icon URL for a wallet. Priority:
132
+ * 1. walletIcons map (exact match or fuzzy)
133
+ * 2. wallet.icons.sm from registry
134
+ * 3. null (caller renders fallback)
135
+ */
136
+ declare function resolveWalletIcon(walletId: string, walletIcons: WalletIconMap, registryIconUrl?: string): string | null;
137
+ interface PartyLayerKitProps {
138
+ /** Canton network to connect to */
139
+ network: 'devnet' | 'testnet' | 'mainnet';
140
+ /** Application name shown to wallets during connection */
141
+ appName: string;
142
+ children: React.ReactNode;
143
+ /** Registry URL override (default: https://registry.partylayer.xyz) */
144
+ registryUrl?: string;
145
+ /** Registry channel (default: 'stable') */
146
+ channel?: 'stable' | 'beta';
147
+ /**
148
+ * Custom wallet adapters. If not provided, uses built-in adapters:
149
+ * Console Wallet, 5N Loop, Cantor8.
150
+ *
151
+ * For Bron (enterprise OAuth), pass explicitly:
152
+ * adapters={[...getBuiltinAdapters(), new BronAdapter(config)]}
153
+ */
154
+ adapters?: (WalletAdapter | AdapterClass)[];
155
+ /** Theme preset or custom theme object (default: 'light') */
156
+ theme?: 'light' | 'dark' | 'auto' | PartyLayerTheme;
157
+ /** Custom wallet icon URLs by walletId */
158
+ walletIcons?: WalletIconMap;
159
+ }
160
+ declare function PartyLayerKit({ network, appName, children, registryUrl, channel, adapters, theme, walletIcons, }: PartyLayerKitProps): react_jsx_runtime.JSX.Element;
161
+
88
162
  interface WalletModalProps {
89
163
  isOpen: boolean;
90
164
  onClose: () => void;
91
165
  onConnect: (sessionId: string) => void;
166
+ /** Custom wallet icon URLs (merged with PartyLayerKit context) */
167
+ walletIcons?: WalletIconMap;
168
+ }
169
+ declare function WalletModal({ isOpen, onClose, onConnect, walletIcons: propIcons, }: WalletModalProps): react_jsx_runtime.JSX.Element | null;
170
+
171
+ /**
172
+ * ConnectButton — Premium wallet connection button for Canton dApps.
173
+ *
174
+ * Manages the full lifecycle: disconnect → connect (via WalletModal) → connected state.
175
+ * Uses existing hooks (useSession, useConnect, useDisconnect) under the hood.
176
+ *
177
+ * Designed for dApp developers to embed directly — brand-aligned, accessible,
178
+ * and polished across light/dark themes.
179
+ */
180
+ interface ConnectButtonProps {
181
+ /** Button label when disconnected (default: "Connect Wallet") */
182
+ label?: string;
183
+ /** What to show when connected: partyId address, wallet name, or custom */
184
+ connectedLabel?: 'address' | 'wallet' | 'custom';
185
+ /** Custom formatter for connected display (requires connectedLabel='custom') */
186
+ formatAddress?: (partyId: string) => string;
187
+ /** Additional CSS class name */
188
+ className?: string;
189
+ /** Additional inline styles */
190
+ style?: React.CSSProperties;
191
+ /** Show disconnect option in dropdown (default: true) */
192
+ showDisconnect?: boolean;
193
+ }
194
+ /**
195
+ * Truncate a partyId for display: "party-abc123def456" → "party-abc...456"
196
+ */
197
+ declare function truncatePartyId(id: string, chars?: number): string;
198
+ declare function ConnectButton({ label, connectedLabel, formatAddress, className, style, showDisconnect, }: ConnectButtonProps): react_jsx_runtime.JSX.Element;
199
+
200
+ /**
201
+ * Native CIP-0103 Adapter
202
+ *
203
+ * Wraps a discovered CIP-0103 Provider into the PartyLayer WalletAdapter interface.
204
+ * This allows native CIP-0103 wallets (injected at window.canton.* etc.) to be used
205
+ * through the standard SDK connect flow alongside registry-based adapters.
206
+ */
207
+
208
+ /**
209
+ * A WalletAdapter that delegates to a native CIP-0103 Provider.
210
+ *
211
+ * Created dynamically when a CIP-0103 provider is discovered at runtime.
212
+ * Routes all SDK operations through the provider's `request()` method.
213
+ */
214
+ declare class NativeCIP0103Adapter implements WalletAdapter {
215
+ readonly walletId: WalletId;
216
+ readonly name: string;
217
+ private provider;
218
+ constructor(id: string, name: string, provider: CIP0103Provider);
219
+ getCapabilities(): CapabilityKey[];
220
+ detectInstalled(): Promise<AdapterDetectResult>;
221
+ connect(_ctx: AdapterContext, _opts?: {
222
+ timeoutMs?: number;
223
+ partyId?: PartyId;
224
+ }): Promise<AdapterConnectResult>;
225
+ disconnect(_ctx: AdapterContext, _session: Session): Promise<void>;
226
+ signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
227
+ signTransaction(_ctx: AdapterContext, _session: Session, params: SignTransactionParams): Promise<SignedTransaction>;
228
+ submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
92
229
  }
93
- declare function WalletModal({ isOpen, onClose, onConnect, }: WalletModalProps): react_jsx_runtime.JSX.Element | null;
230
+ /**
231
+ * Create a WalletAdapter from a discovered CIP-0103 provider.
232
+ */
233
+ declare function createNativeAdapter(discovered: DiscoveredProvider): NativeCIP0103Adapter;
234
+ /**
235
+ * Create a synthetic WalletInfo for a discovered native CIP-0103 provider.
236
+ */
237
+ declare function createSyntheticWalletInfo(discovered: DiscoveredProvider, network: string): WalletInfo;
94
238
 
95
- export { PartyLayerProvider as CantonConnectProvider, PartyLayerProvider, WalletModal, usePartyLayer as useCantonConnect, useConnect, useDisconnect, usePartyLayer, usePartyLayerContext, useRegistryStatus, useSession, useSignMessage, useSignTransaction, useSubmitTransaction, useWallets };
239
+ export { PartyLayerProvider as CantonConnectProvider, ConnectButton, type ConnectButtonProps, NativeCIP0103Adapter, PartyLayerKit, type PartyLayerKitProps, PartyLayerProvider, type PartyLayerTheme, ThemeProvider, type WalletIconMap, WalletModal, type WalletModalProps, createNativeAdapter, createSyntheticWalletInfo, darkTheme, lightTheme, resolveWalletIcon, truncatePartyId, usePartyLayer as useCantonConnect, useConnect, useDisconnect, usePartyLayer, usePartyLayerContext, useRegistryStatus, useSession, useSignMessage, useSignTransaction, useSubmitTransaction, useTheme, useWalletIcons, useWallets };