@cicero-zcash/react 0.1.0 → 0.2.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/dist/index.d.ts CHANGED
@@ -2,16 +2,7 @@ import React from 'react';
2
2
 
3
3
  type ZcashAddressType = 'unified' | 'sapling' | 'transparent' | 'unknown';
4
4
  type ZcashNetwork = 'mainnet' | 'testnet';
5
- type PaymentStatus = 'idle' | 'pending' | 'detected' | 'confirmed' | 'expired' | 'failed';
6
5
  type CiceroTheme = 'supabase' | 'emerald' | 'dark' | 'light';
7
- interface PaymentDetails {
8
- recipient: string;
9
- amount: number | string;
10
- memo?: string;
11
- message?: string;
12
- network?: ZcashNetwork;
13
- invoiceId?: string;
14
- }
15
6
  interface Zip321PaymentRequest {
16
7
  address: string;
17
8
  amount?: string;
@@ -19,52 +10,6 @@ interface Zip321PaymentRequest {
19
10
  message?: string;
20
11
  rawUri: string;
21
12
  }
22
- interface CiceroPayProps {
23
- /** Zcash recipient address (Unified, Sapling, or Transparent) */
24
- recipient: string;
25
- /** Amount in ZEC */
26
- amount: number | string;
27
- /** Optional encrypted memo (up to 512 bytes, supported on shielded addresses) */
28
- memo?: string;
29
- /** Optional human-readable message */
30
- message?: string;
31
- /** Button label text */
32
- label?: string;
33
- /** Zcash network (defaults to 'mainnet') */
34
- network?: ZcashNetwork;
35
- /** Visual theme */
36
- theme?: CiceroTheme;
37
- /** Button variant */
38
- variant?: 'primary' | 'outline' | 'dark';
39
- /** Button size */
40
- size?: 'sm' | 'md' | 'lg';
41
- /** Whether to show estimated USD value alongside ZEC */
42
- showUsd?: boolean;
43
- /** Custom modal title */
44
- modalTitle?: string;
45
- /** Custom modal subtitle */
46
- modalSubtitle?: string;
47
- /** Invoice expiration time in seconds (defaults to 900 = 15 mins) */
48
- expiresInSeconds?: number;
49
- /** Optional custom lightwalletd or indexer URL */
50
- customRpcUrl?: string;
51
- /** Optional unique invoice or order reference */
52
- invoiceId?: string;
53
- /** Callback fired when transaction confirmation is detected */
54
- onSuccess?: (tx: {
55
- txId: string;
56
- amount: number;
57
- memo?: string;
58
- }) => void;
59
- /** Callback fired on payment error */
60
- onError?: (error: Error) => void;
61
- /** Callback fired whenever the payment status transitions */
62
- onStatusChange?: (status: PaymentStatus) => void;
63
- /** Custom CSS classes for the trigger button */
64
- className?: string;
65
- /** Disable the button */
66
- disabled?: boolean;
67
- }
68
13
 
69
14
  type WalletCategory = 'extension' | 'mobile' | 'desktop' | 'read-only' | 'developer';
70
15
  interface WalletSession$1 {
@@ -102,6 +47,12 @@ interface ZcashWallet {
102
47
  address?: string;
103
48
  network?: ZcashNetwork;
104
49
  }) => Promise<number | null>;
50
+ getNetwork?: () => Promise<ZcashNetwork>;
51
+ switchNetwork?: (network: ZcashNetwork) => Promise<{
52
+ success: boolean;
53
+ requiresManualSwitch?: boolean;
54
+ currentNetwork?: ZcashNetwork;
55
+ }>;
105
56
  sendPayment?: (params: SendPaymentParams) => Promise<SendPaymentResult>;
106
57
  }
107
58
 
@@ -142,7 +93,11 @@ interface CiceroContextType {
142
93
  isConnecting: boolean;
143
94
  wallet: ZcashWallet | null;
144
95
  network: ZcashNetwork;
145
- switchNetwork: (net: ZcashNetwork) => void;
96
+ switchNetwork: (net: ZcashNetwork) => Promise<{
97
+ success: boolean;
98
+ requiresManualSwitch?: boolean;
99
+ currentNetwork?: ZcashNetwork;
100
+ }>;
146
101
  balance: BalanceState;
147
102
  refetchBalance: () => Promise<void>;
148
103
  connect: (walletId: string, customAddressOrKey?: string) => Promise<void>;
@@ -217,39 +172,6 @@ interface CiceroAccountModalProps {
217
172
  }
218
173
  declare const CiceroAccountModal: React.FC<CiceroAccountModalProps>;
219
174
 
220
- declare const CiceroPayButton: React.FC<CiceroPayProps>;
221
-
222
- interface CiceroModalProps {
223
- isOpen: boolean;
224
- onClose: () => void;
225
- recipient: string;
226
- amount: number | string;
227
- memo?: string;
228
- message?: string;
229
- network?: ZcashNetwork;
230
- status: PaymentStatus;
231
- txId: string | null;
232
- secondsRemaining: number;
233
- zip321Uri: string;
234
- addressType: string;
235
- isShielded: boolean;
236
- memoValidation: {
237
- valid: boolean;
238
- warning?: string;
239
- byteLength: number;
240
- };
241
- onSimulateDetection?: () => void;
242
- onResetPayment?: () => void;
243
- title?: string;
244
- subtitle?: string;
245
- showUsd?: boolean;
246
- /** Zucchini Wallet integration */
247
- zucchiniAvailable?: boolean;
248
- zucchiniPaying?: boolean;
249
- onPayWithZucchini?: () => void;
250
- }
251
- declare const CiceroModal: React.FC<CiceroModalProps>;
252
-
253
175
  interface CiceroQRCodeProps {
254
176
  value: string;
255
177
  size?: number;
@@ -259,56 +181,6 @@ interface CiceroQRCodeProps {
259
181
  }
260
182
  declare const CiceroQRCode: React.FC<CiceroQRCodeProps>;
261
183
 
262
- declare const CiceroInvoice: React.FC<CiceroPayProps>;
263
-
264
- interface UseCiceroPaymentOptions {
265
- recipient: string;
266
- amount: number | string;
267
- memo?: string;
268
- message?: string;
269
- network?: ZcashNetwork;
270
- expiresInSeconds?: number;
271
- invoiceId?: string;
272
- customRpcUrl?: string;
273
- onSuccess?: (tx: {
274
- txId: string;
275
- amount: number;
276
- memo?: string;
277
- }) => void;
278
- onError?: (error: Error) => void;
279
- onStatusChange?: (status: PaymentStatus) => void;
280
- }
281
- declare function useCiceroPayment({ recipient, amount, memo, message, network, expiresInSeconds, // 15 mins
282
- invoiceId, customRpcUrl, onSuccess, onError, onStatusChange, }: UseCiceroPaymentOptions): {
283
- status: PaymentStatus;
284
- txId: string | null;
285
- secondsRemaining: number;
286
- isModalOpen: boolean;
287
- openModal: () => void;
288
- closeModal: () => void;
289
- resetPayment: () => void;
290
- zip321Uri: string;
291
- deepLinks: {
292
- generic: string;
293
- zashi: string;
294
- ywallet: string;
295
- };
296
- addressType: ZcashAddressType;
297
- isShielded: boolean;
298
- memoValidation: {
299
- valid: boolean;
300
- warning?: string;
301
- byteLength: number;
302
- };
303
- simulateDetection: () => void;
304
- invoiceId: string | undefined;
305
- network: ZcashNetwork;
306
- customRpcUrl: string | undefined;
307
- zucchiniAvailable: boolean;
308
- zucchiniPaying: boolean;
309
- payWithZucchini: () => Promise<void>;
310
- };
311
-
312
184
  declare function useZcashPrice(enabled?: boolean): {
313
185
  convertZecToUsd: (zecAmount: number | string) => string | null;
314
186
  usdPrice: number | null;
@@ -322,6 +194,7 @@ type WalletPaymentStatus = 'idle' | 'requesting' | 'submitted' | 'error';
322
194
  interface WalletSession {
323
195
  address?: string;
324
196
  connected: boolean;
197
+ network?: ZcashNetwork;
325
198
  balance?: number;
326
199
  }
327
200
  interface WalletPaymentResult {
@@ -360,6 +233,23 @@ declare class ZucchiniWalletAdapter {
360
233
  * Resolves the user's active Shielded Unified Address.
361
234
  */
362
235
  connect(): Promise<WalletSession>;
236
+ /**
237
+ * Queries the active network of the Zucchini Wallet ('mainnet' | 'testnet').
238
+ */
239
+ getNetwork(): Promise<ZcashNetwork>;
240
+ /**
241
+ * Requests a network change. If the extension does not support programmatic
242
+ * switching, informs the application that manual user toggle is needed.
243
+ */
244
+ switchNetwork(targetNetwork: ZcashNetwork): Promise<{
245
+ success: boolean;
246
+ requiresManualSwitch?: boolean;
247
+ currentNetwork: ZcashNetwork;
248
+ }>;
249
+ /**
250
+ * Subscribes to network change events from the wallet extension.
251
+ */
252
+ onNetworkChanged(listener: (network: ZcashNetwork) => void): () => void;
363
253
  /**
364
254
  * Helper to normalize raw balance formats (e.g. number, string, zatoshis, or pool totals).
365
255
  */
@@ -481,4 +371,4 @@ declare function getWalletDeepLinks(zip321Uri: string): {
481
371
  ywallet: string;
482
372
  };
483
373
 
484
- export { type AccountState, type BalanceState, type BuildZip321Params, CiceroAccountModal, type CiceroAccountModalProps, CiceroConnectButton, type CiceroConnectButtonProps, CiceroConnectModal, type CiceroConnectModalProps, type CiceroContextType, CiceroInvoice, CiceroModal, CiceroPayButton, type CiceroPayProps, CiceroProvider, type CiceroProviderProps, CiceroQRCode, type CiceroTheme, type PaymentDetails, type PaymentStatus, type SendPaymentParams, type SendPaymentResult, type UseCiceroPaymentOptions, type UseZucchiniWalletOptions, type WalletCategory, type WalletSession$1 as WalletSession, type ZcashAddressType, type ZcashNetwork, type ZcashWallet, type Zip321PaymentRequest, ZucchiniWalletAdapter, burnerWallet, decodeBase64Url, encodeBase64Url, generateZip321Uri, getAddressType, getDefaultWallets, getWalletDeepLinks, isShieldedAddress, parseZip321Uri, truncateAddress, useAccount, useAccountModal, useBalance, useCicero, useCiceroPayment, useConnectModal, useZcashPrice, useZucchiniWallet, validateMemoSupport, viewingKeyWallet, ywallet, zashiWallet, zucchiniWallet };
374
+ export { type AccountState, type BalanceState, type BuildZip321Params, CiceroAccountModal, type CiceroAccountModalProps, CiceroConnectButton, type CiceroConnectButtonProps, CiceroConnectModal, type CiceroConnectModalProps, type CiceroContextType, CiceroProvider, type CiceroProviderProps, CiceroQRCode, type CiceroTheme, type SendPaymentParams, type SendPaymentResult, type UseZucchiniWalletOptions, type WalletCategory, type WalletSession$1 as WalletSession, type ZcashAddressType, type ZcashNetwork, type ZcashWallet, ZucchiniWalletAdapter, burnerWallet, decodeBase64Url, encodeBase64Url, generateZip321Uri, getAddressType, getDefaultWallets, getWalletDeepLinks, isShieldedAddress, parseZip321Uri, truncateAddress, useAccount, useAccountModal, useBalance, useCicero, useConnectModal, useZcashPrice, useZucchiniWallet, validateMemoSupport, viewingKeyWallet, ywallet, zashiWallet, zucchiniWallet };