@cicero-zcash/react 0.0.0-stage โ 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/README.md +198 -2
- package/dist/index.d.mts +374 -0
- package/dist/index.d.ts +374 -0
- package/dist/index.js +1999 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1960 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +69 -4
package/README.md
CHANGED
|
@@ -1,3 +1,199 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# ๐ก๏ธ Cicero
|
|
4
|
+
|
|
5
|
+
### The RainbowKit for Shielded Zcash
|
|
6
|
+
|
|
7
|
+
**Universal wallet connection, bi-directional network synchronization, and multi-wallet state management for React and Next.js applications.**
|
|
8
|
+
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
[](https://www.npmjs.com/package/@cicero-zcash/react)
|
|
11
|
+
[](https://z.cash)
|
|
12
|
+
[](./DESIGN.md)
|
|
13
|
+
|
|
14
|
+
[Quickstart](#-quickstart) โข [React Hooks](#-react-hooks) โข [Wallets Supported](#-supported-wallets) โข [Components](#-components)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
## ๐ What is Cicero?
|
|
21
|
+
|
|
22
|
+
**Cicero** is the **"RainbowKit of Zcash"**. It provides a drop-in, zero-knowledge native wallet connection suite:
|
|
23
|
+
|
|
24
|
+
- ๐ฅ **Zucchini Chrome Extension:** 1-click in-browser connection and shielded account detection.
|
|
25
|
+
- ๐ฑ **Mobile & Desktop Wallets:** Zashi (Electric Coin Co.) and Ywallet QR handoff.
|
|
26
|
+
- ๐ **Viewing Key Mode:** Audit and read-only treasury dashboard connection.
|
|
27
|
+
- ๐ **Bi-Directional Network Sync:** Automatically detects Mainnet vs Testnet from wallet address prefixes and listens to extension network change events.
|
|
28
|
+
- ๐ฐ **Per-Network Balance Segregation:** Independent balance caching for Mainnet and Testnet with live USD conversion.
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { CiceroProvider, CiceroConnectButton, useAccount, useBalance } from '@cicero-zcash/react';
|
|
32
|
+
|
|
33
|
+
export default function App() {
|
|
34
|
+
return (
|
|
35
|
+
<CiceroProvider initialNetwork="mainnet">
|
|
36
|
+
<nav className="flex justify-between p-4 border-b">
|
|
37
|
+
<span>My Zcash dApp</span>
|
|
38
|
+
<CiceroConnectButton variant="primary" size="md" />
|
|
39
|
+
</nav>
|
|
40
|
+
<Dashboard />
|
|
41
|
+
</CiceroProvider>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function Dashboard() {
|
|
46
|
+
const { address, isConnected, wallet } = useAccount();
|
|
47
|
+
const { zec, usd } = useBalance();
|
|
48
|
+
|
|
49
|
+
if (!isConnected) return <p>Please connect your Zcash wallet.</p>;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div>
|
|
53
|
+
<p>Connected to {wallet?.name}</p>
|
|
54
|
+
<p>Address: {address}</p>
|
|
55
|
+
<p>Balance: {zec} ZEC (~${usd} USD)</p>
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## โก Features
|
|
64
|
+
|
|
65
|
+
- **๐ก๏ธ Shielded-First Architecture:** Built specifically for Zcash's Unified Address standard (ZIP-316), Sapling (`zs1`), and Transparent (`t1`) pools.
|
|
66
|
+
- **๐ Live Network & Chain Synchronization:** Listens to wallet extension events (`networkChanged`, `accountsChanged`). Switching between Mainnet and Testnet inside Zucchini immediately updates Cicero and queries the new balance.
|
|
67
|
+
- **๐ผ RainbowKit-Style Connected Pill:** Displays active network indicator (green/amber dot), current ZEC balance, and truncated address. Clicking opens an account drawer with address copying, QR code receive view, and network switch assistance.
|
|
68
|
+
- **๐จ Supabase Design Language:** Styled with Supabase tokens (`#3ecf8e` emerald accents, `#171717` ink typography, 6px button radii, clean border tokens).
|
|
69
|
+
- **๐ช Live Fiat Conversions:** `useZcashPrice()` hook provides cached, rate-limited ZEC/USD pricing with automatic fallback.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## ๐ Quickstart
|
|
74
|
+
|
|
75
|
+
### 1. Install
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pnpm add @cicero-zcash/react
|
|
79
|
+
# or
|
|
80
|
+
npm install @cicero-zcash/react
|
|
81
|
+
# or
|
|
82
|
+
yarn add @cicero-zcash/react
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 2. Wrap your app in `<CiceroProvider>`
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { CiceroProvider } from '@cicero-zcash/react';
|
|
89
|
+
|
|
90
|
+
export function RootLayout({ children }: { children: React.ReactNode }) {
|
|
91
|
+
return (
|
|
92
|
+
<CiceroProvider initialNetwork="mainnet" appName="My Zcash dApp">
|
|
93
|
+
{children}
|
|
94
|
+
</CiceroProvider>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 3. Add the `<CiceroConnectButton />`
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { CiceroConnectButton } from '@cicero-zcash/react';
|
|
103
|
+
|
|
104
|
+
export function Header() {
|
|
105
|
+
return (
|
|
106
|
+
<header className="flex justify-between items-center p-4">
|
|
107
|
+
<h1>Zcash Portal</h1>
|
|
108
|
+
<CiceroConnectButton variant="primary" size="md" />
|
|
109
|
+
</header>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## ๐ช React Hooks
|
|
117
|
+
|
|
118
|
+
Cicero exports familiar, ergonomic hooks modeled after RainbowKit and wagmi:
|
|
119
|
+
|
|
120
|
+
### `useAccount()`
|
|
121
|
+
```tsx
|
|
122
|
+
const {
|
|
123
|
+
address, // string | null - Active shielded or transparent address
|
|
124
|
+
isConnected, // boolean - Whether a wallet is connected
|
|
125
|
+
isConnecting, // boolean - True during connection handshake
|
|
126
|
+
wallet, // ZcashWallet | null - Active wallet adapter metadata
|
|
127
|
+
disconnect, // () => Promise<void> - Disconnect handler
|
|
128
|
+
} = useAccount();
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### `useBalance()`
|
|
132
|
+
```tsx
|
|
133
|
+
const {
|
|
134
|
+
zec, // number - Shielded balance in ZEC
|
|
135
|
+
usd, // string | null - Estimated USD equivalent
|
|
136
|
+
isLoading, // boolean - True when querying balance
|
|
137
|
+
refetch, // () => Promise<void> - Re-queries balance from wallet/RPC
|
|
138
|
+
} = useBalance();
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### `useCicero()`
|
|
142
|
+
Full context access including network state, modal controls, and raw wallet methods:
|
|
143
|
+
```tsx
|
|
144
|
+
const {
|
|
145
|
+
account,
|
|
146
|
+
network, // 'mainnet' | 'testnet'
|
|
147
|
+
switchNetwork, // (net: 'mainnet' | 'testnet') => Promise<SwitchResult>
|
|
148
|
+
openConnectModal,
|
|
149
|
+
closeConnectModal,
|
|
150
|
+
openAccountModal,
|
|
151
|
+
closeAccountModal,
|
|
152
|
+
} = useCicero();
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### `useZucchiniWallet()`
|
|
156
|
+
Direct low-level hook for interacting with the Zucchini browser extension:
|
|
157
|
+
```tsx
|
|
158
|
+
const {
|
|
159
|
+
isAvailable, // boolean - True if Zucchini Chrome extension is installed
|
|
160
|
+
isConnected, // boolean
|
|
161
|
+
connect, // () => Promise<WalletSession>
|
|
162
|
+
address, // string | null
|
|
163
|
+
network, // 'mainnet' | 'testnet'
|
|
164
|
+
getBalance, // () => Promise<number | null>
|
|
165
|
+
} = useZucchiniWallet();
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## ๐ Supported Wallets
|
|
171
|
+
|
|
172
|
+
| Wallet | Type | Support | Features |
|
|
173
|
+
|---|---|---|---|
|
|
174
|
+
| **Zucchini** | Chrome Extension | Direct in-browser | 1-click connect, live network sync, shielded balance |
|
|
175
|
+
| **Zashi** | Mobile (iOS/Android) | QR Handoff | Electric Coin Co. official wallet |
|
|
176
|
+
| **Ywallet** | Desktop & Mobile | QR Handoff | Multi-platform shielded wallet |
|
|
177
|
+
| **Viewing Key** | Read-Only | Manual Input | Auditor compliance, treasury dashboards |
|
|
178
|
+
| **Burner Wallet**| Dev / Sandbox | Ephemeral | Instant testing in development |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## ๐งฉ Components
|
|
183
|
+
|
|
184
|
+
### `<CiceroConnectButton />`
|
|
185
|
+
|
|
186
|
+
| Prop | Type | Default | Description |
|
|
187
|
+
|---|---|---|---|
|
|
188
|
+
| `variant` | `'primary' \| 'outline' \| 'dark'` | `'primary'` | Visual style token |
|
|
189
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Button dimensions |
|
|
190
|
+
| `showBalance` | `boolean` | `true` | Show balance in connected pill |
|
|
191
|
+
| `showNetwork` | `boolean` | `true` | Show network indicator dot |
|
|
192
|
+
| `label` | `string` | `'Connect Zcash Wallet'` | Custom disconnect trigger text |
|
|
193
|
+
| `className` | `string` | `''` | Custom CSS class names |
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## ๐ License
|
|
198
|
+
|
|
199
|
+
MIT ยฉ [Kaycee276](https://github.com/Kaycee276)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type ZcashAddressType = 'unified' | 'sapling' | 'transparent' | 'unknown';
|
|
4
|
+
type ZcashNetwork = 'mainnet' | 'testnet';
|
|
5
|
+
type CiceroTheme = 'supabase' | 'emerald' | 'dark' | 'light';
|
|
6
|
+
interface Zip321PaymentRequest {
|
|
7
|
+
address: string;
|
|
8
|
+
amount?: string;
|
|
9
|
+
memo?: string;
|
|
10
|
+
message?: string;
|
|
11
|
+
rawUri: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type WalletCategory = 'extension' | 'mobile' | 'desktop' | 'read-only' | 'developer';
|
|
15
|
+
interface WalletSession$1 {
|
|
16
|
+
address?: string;
|
|
17
|
+
viewingKey?: string;
|
|
18
|
+
network?: ZcashNetwork;
|
|
19
|
+
connected: boolean;
|
|
20
|
+
walletId: string;
|
|
21
|
+
balance?: number;
|
|
22
|
+
}
|
|
23
|
+
interface SendPaymentParams {
|
|
24
|
+
recipient: string;
|
|
25
|
+
amount: number | string;
|
|
26
|
+
memo?: string;
|
|
27
|
+
message?: string;
|
|
28
|
+
}
|
|
29
|
+
interface SendPaymentResult {
|
|
30
|
+
txId: string;
|
|
31
|
+
submitted: boolean;
|
|
32
|
+
rawUri?: string;
|
|
33
|
+
}
|
|
34
|
+
interface ZcashWallet {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
icon: string;
|
|
38
|
+
description: string;
|
|
39
|
+
category: WalletCategory;
|
|
40
|
+
downloadUrl?: string;
|
|
41
|
+
isAvailable: () => boolean;
|
|
42
|
+
connect: (options?: {
|
|
43
|
+
network?: ZcashNetwork;
|
|
44
|
+
}) => Promise<WalletSession$1>;
|
|
45
|
+
disconnect?: () => Promise<void>;
|
|
46
|
+
getBalance?: (options?: {
|
|
47
|
+
address?: string;
|
|
48
|
+
network?: ZcashNetwork;
|
|
49
|
+
}) => Promise<number | null>;
|
|
50
|
+
getNetwork?: () => Promise<ZcashNetwork>;
|
|
51
|
+
switchNetwork?: (network: ZcashNetwork) => Promise<{
|
|
52
|
+
success: boolean;
|
|
53
|
+
requiresManualSwitch?: boolean;
|
|
54
|
+
currentNetwork?: ZcashNetwork;
|
|
55
|
+
}>;
|
|
56
|
+
sendPayment?: (params: SendPaymentParams) => Promise<SendPaymentResult>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare const zucchiniWallet: ZcashWallet;
|
|
60
|
+
|
|
61
|
+
declare const zashiWallet: ZcashWallet;
|
|
62
|
+
|
|
63
|
+
declare const ywallet: ZcashWallet;
|
|
64
|
+
|
|
65
|
+
declare const viewingKeyWallet: ZcashWallet;
|
|
66
|
+
|
|
67
|
+
declare const burnerWallet: ZcashWallet;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns the default suite of supported Zcash wallets.
|
|
71
|
+
* Zucchini will be marked as available if the browser extension is detected.
|
|
72
|
+
*/
|
|
73
|
+
declare function getDefaultWallets(): ZcashWallet[];
|
|
74
|
+
|
|
75
|
+
interface AccountState {
|
|
76
|
+
address: string | null;
|
|
77
|
+
viewingKey: string | null;
|
|
78
|
+
isConnected: boolean;
|
|
79
|
+
isConnecting: boolean;
|
|
80
|
+
status: 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
81
|
+
wallet: ZcashWallet | null;
|
|
82
|
+
error: string | null;
|
|
83
|
+
}
|
|
84
|
+
interface BalanceState {
|
|
85
|
+
zec: number;
|
|
86
|
+
usd: string | null;
|
|
87
|
+
isLoading: boolean;
|
|
88
|
+
}
|
|
89
|
+
interface CiceroContextType {
|
|
90
|
+
account: AccountState;
|
|
91
|
+
address: string | null;
|
|
92
|
+
isConnected: boolean;
|
|
93
|
+
isConnecting: boolean;
|
|
94
|
+
wallet: ZcashWallet | null;
|
|
95
|
+
network: ZcashNetwork;
|
|
96
|
+
switchNetwork: (net: ZcashNetwork) => Promise<{
|
|
97
|
+
success: boolean;
|
|
98
|
+
requiresManualSwitch?: boolean;
|
|
99
|
+
currentNetwork?: ZcashNetwork;
|
|
100
|
+
}>;
|
|
101
|
+
balance: BalanceState;
|
|
102
|
+
refetchBalance: () => Promise<void>;
|
|
103
|
+
connect: (walletId: string, customAddressOrKey?: string) => Promise<void>;
|
|
104
|
+
disconnect: () => Promise<void>;
|
|
105
|
+
sendPayment: (params: SendPaymentParams) => Promise<SendPaymentResult>;
|
|
106
|
+
isConnectModalOpen: boolean;
|
|
107
|
+
openConnectModal: () => void;
|
|
108
|
+
closeConnectModal: () => void;
|
|
109
|
+
isAccountModalOpen: boolean;
|
|
110
|
+
openAccountModal: () => void;
|
|
111
|
+
closeAccountModal: () => void;
|
|
112
|
+
wallets: ZcashWallet[];
|
|
113
|
+
appName?: string;
|
|
114
|
+
appLogo?: string;
|
|
115
|
+
}
|
|
116
|
+
interface CiceroProviderProps {
|
|
117
|
+
children: React.ReactNode;
|
|
118
|
+
initialNetwork?: ZcashNetwork;
|
|
119
|
+
wallets?: ZcashWallet[];
|
|
120
|
+
appName?: string;
|
|
121
|
+
appLogo?: string;
|
|
122
|
+
autoConnect?: boolean;
|
|
123
|
+
}
|
|
124
|
+
declare const CiceroProvider: React.FC<CiceroProviderProps>;
|
|
125
|
+
declare function useCicero(): CiceroContextType;
|
|
126
|
+
declare const useAccount: () => {
|
|
127
|
+
address: string | null;
|
|
128
|
+
isConnected: boolean;
|
|
129
|
+
isConnecting: boolean;
|
|
130
|
+
wallet: ZcashWallet | null;
|
|
131
|
+
disconnect: () => Promise<void>;
|
|
132
|
+
viewingKey: string | null;
|
|
133
|
+
status: "disconnected" | "connecting" | "connected" | "error";
|
|
134
|
+
error: string | null;
|
|
135
|
+
};
|
|
136
|
+
declare const useBalance: () => {
|
|
137
|
+
refetch: () => Promise<void>;
|
|
138
|
+
zec: number;
|
|
139
|
+
usd: string | null;
|
|
140
|
+
isLoading: boolean;
|
|
141
|
+
};
|
|
142
|
+
declare const useConnectModal: () => {
|
|
143
|
+
isOpen: boolean;
|
|
144
|
+
openConnectModal: () => void;
|
|
145
|
+
closeConnectModal: () => void;
|
|
146
|
+
};
|
|
147
|
+
declare const useAccountModal: () => {
|
|
148
|
+
isOpen: boolean;
|
|
149
|
+
openAccountModal: () => void;
|
|
150
|
+
closeAccountModal: () => void;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
interface CiceroConnectButtonProps {
|
|
154
|
+
label?: string;
|
|
155
|
+
variant?: 'primary' | 'outline' | 'dark';
|
|
156
|
+
size?: 'sm' | 'md' | 'lg';
|
|
157
|
+
showBalance?: boolean;
|
|
158
|
+
showNetwork?: boolean;
|
|
159
|
+
className?: string;
|
|
160
|
+
}
|
|
161
|
+
declare const CiceroConnectButton: React.FC<CiceroConnectButtonProps>;
|
|
162
|
+
|
|
163
|
+
interface CiceroConnectModalProps {
|
|
164
|
+
isOpen?: boolean;
|
|
165
|
+
onClose?: () => void;
|
|
166
|
+
}
|
|
167
|
+
declare const CiceroConnectModal: React.FC<CiceroConnectModalProps>;
|
|
168
|
+
|
|
169
|
+
interface CiceroAccountModalProps {
|
|
170
|
+
isOpen?: boolean;
|
|
171
|
+
onClose?: () => void;
|
|
172
|
+
}
|
|
173
|
+
declare const CiceroAccountModal: React.FC<CiceroAccountModalProps>;
|
|
174
|
+
|
|
175
|
+
interface CiceroQRCodeProps {
|
|
176
|
+
value: string;
|
|
177
|
+
size?: number;
|
|
178
|
+
className?: string;
|
|
179
|
+
level?: 'L' | 'M' | 'Q' | 'H';
|
|
180
|
+
includeMargin?: boolean;
|
|
181
|
+
}
|
|
182
|
+
declare const CiceroQRCode: React.FC<CiceroQRCodeProps>;
|
|
183
|
+
|
|
184
|
+
declare function useZcashPrice(enabled?: boolean): {
|
|
185
|
+
convertZecToUsd: (zecAmount: number | string) => string | null;
|
|
186
|
+
usdPrice: number | null;
|
|
187
|
+
loading: boolean;
|
|
188
|
+
error: string | null;
|
|
189
|
+
lastUpdated: number | null;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
type WalletConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
193
|
+
type WalletPaymentStatus = 'idle' | 'requesting' | 'submitted' | 'error';
|
|
194
|
+
interface WalletSession {
|
|
195
|
+
address?: string;
|
|
196
|
+
connected: boolean;
|
|
197
|
+
network?: ZcashNetwork;
|
|
198
|
+
balance?: number;
|
|
199
|
+
}
|
|
200
|
+
interface WalletPaymentResult {
|
|
201
|
+
txId: string;
|
|
202
|
+
submitted: boolean;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Adapter for the Zucchini Wallet browser extension.
|
|
206
|
+
*
|
|
207
|
+
* Zucchini injects a provider onto window.zucchini (or window.zcash) and implements
|
|
208
|
+
* the typed @zucchinifi/dapp-sdk Zcash contract.
|
|
209
|
+
*/
|
|
210
|
+
declare class ZucchiniWalletAdapter {
|
|
211
|
+
private client;
|
|
212
|
+
private provider;
|
|
213
|
+
private _connected;
|
|
214
|
+
private _address;
|
|
215
|
+
private _lastAccounts;
|
|
216
|
+
/**
|
|
217
|
+
* Checks whether the Zucchini Wallet extension is installed and its
|
|
218
|
+
* provider is available in the current browser environment.
|
|
219
|
+
*/
|
|
220
|
+
static isAvailable(): boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Subscribes to wallet readiness. Fires callback immediately if already available,
|
|
223
|
+
* or listens for injection events / polls briefly for late extension initialization.
|
|
224
|
+
*/
|
|
225
|
+
static onReady(callback: () => void): () => void;
|
|
226
|
+
/**
|
|
227
|
+
* Discovers and initializes the Zucchini Client using @zucchinifi/dapp-sdk/zcash
|
|
228
|
+
* with graceful fallback to raw window.zucchini / window.zcash globals.
|
|
229
|
+
*/
|
|
230
|
+
private getClient;
|
|
231
|
+
/**
|
|
232
|
+
* Requests connection with view_addresses and send_transaction permissions.
|
|
233
|
+
* Resolves the user's active Shielded Unified Address.
|
|
234
|
+
*/
|
|
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;
|
|
253
|
+
/**
|
|
254
|
+
* Helper to normalize raw balance formats (e.g. number, string, zatoshis, or pool totals).
|
|
255
|
+
*/
|
|
256
|
+
private parseBalancePayload;
|
|
257
|
+
/**
|
|
258
|
+
* Reads real-time balance from Zucchini provider.
|
|
259
|
+
*/
|
|
260
|
+
getBalance(options?: {
|
|
261
|
+
address?: string;
|
|
262
|
+
network?: string;
|
|
263
|
+
}): Promise<number | null>;
|
|
264
|
+
/**
|
|
265
|
+
* Sends payment via standard ZIP-321 URI requestPayment or transaction fallback.
|
|
266
|
+
*/
|
|
267
|
+
requestPayment(params: {
|
|
268
|
+
recipient: string;
|
|
269
|
+
amount: number | string;
|
|
270
|
+
memo?: string;
|
|
271
|
+
}): Promise<WalletPaymentResult>;
|
|
272
|
+
/**
|
|
273
|
+
* Subscribes to accountsChanged events.
|
|
274
|
+
*/
|
|
275
|
+
onAccountsChanged(listener: (accounts: any) => void): () => void;
|
|
276
|
+
/**
|
|
277
|
+
* Subscribes to disconnect events.
|
|
278
|
+
*/
|
|
279
|
+
onDisconnect(listener: () => void): () => void;
|
|
280
|
+
/**
|
|
281
|
+
* Disconnects the current session.
|
|
282
|
+
*/
|
|
283
|
+
disconnect(): Promise<void>;
|
|
284
|
+
get isConnected(): boolean;
|
|
285
|
+
get address(): string | null;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
interface UseZucchiniWalletOptions {
|
|
289
|
+
/** Auto-connect on mount when extension is detected */
|
|
290
|
+
autoConnect?: boolean;
|
|
291
|
+
}
|
|
292
|
+
declare function useZucchiniWallet(options?: UseZucchiniWalletOptions): {
|
|
293
|
+
/** Whether the Zucchini extension is installed in this browser */
|
|
294
|
+
isAvailable: boolean;
|
|
295
|
+
/** Current wallet connection lifecycle state */
|
|
296
|
+
connectionStatus: WalletConnectionStatus;
|
|
297
|
+
/** Current payment request lifecycle state */
|
|
298
|
+
paymentStatus: WalletPaymentStatus;
|
|
299
|
+
/** Active session info (address, etc.) */
|
|
300
|
+
session: WalletSession | null;
|
|
301
|
+
/** Last error message (if any) */
|
|
302
|
+
error: string | null;
|
|
303
|
+
/** Prompt the user to connect their Zucchini Wallet */
|
|
304
|
+
connect: () => Promise<WalletSession>;
|
|
305
|
+
/** Send a ZIP-321 payment request for user review & approval */
|
|
306
|
+
requestPayment: (params: {
|
|
307
|
+
recipient: string;
|
|
308
|
+
amount: number | string;
|
|
309
|
+
memo?: string;
|
|
310
|
+
}) => Promise<WalletPaymentResult>;
|
|
311
|
+
/** Disconnect the current session */
|
|
312
|
+
disconnect: () => Promise<void>;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Detects the type of a Zcash address.
|
|
317
|
+
*/
|
|
318
|
+
declare function getAddressType(address: string): ZcashAddressType;
|
|
319
|
+
/**
|
|
320
|
+
* Checks whether an address supports zero-knowledge shielded encryption (Unified or Sapling).
|
|
321
|
+
*/
|
|
322
|
+
declare function isShieldedAddress(address: string): boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Truncates a long address for display purposes.
|
|
325
|
+
* e.g., u1abcdef...987654
|
|
326
|
+
*/
|
|
327
|
+
declare function truncateAddress(address: string, start?: number, end?: number): string;
|
|
328
|
+
/**
|
|
329
|
+
* Validates whether the address supports encrypted memos.
|
|
330
|
+
* Memos in Zcash are strictly for shielded receivers (Sapling & Orchard).
|
|
331
|
+
* Transparent addresses do not support on-chain encrypted memos.
|
|
332
|
+
*/
|
|
333
|
+
declare function validateMemoSupport(address: string, memo?: string): {
|
|
334
|
+
valid: boolean;
|
|
335
|
+
warning?: string;
|
|
336
|
+
byteLength: number;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Encodes a string to Base64URL without padding per RFC 4648 ยง5 / ZIP-321 specification.
|
|
341
|
+
*/
|
|
342
|
+
declare function encodeBase64Url(str: string): string;
|
|
343
|
+
/**
|
|
344
|
+
* Decodes a Base64URL string without padding per ZIP-321 specification.
|
|
345
|
+
*/
|
|
346
|
+
declare function decodeBase64Url(base64url: string): string;
|
|
347
|
+
interface BuildZip321Params {
|
|
348
|
+
address: string;
|
|
349
|
+
amount?: number | string;
|
|
350
|
+
memo?: string;
|
|
351
|
+
message?: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Generates an RFC-compliant ZIP-321 Payment Request URI.
|
|
355
|
+
* Example output:
|
|
356
|
+
* zcash:u1xyz...?amount=0.05&memo=T3JkZXIgIzEwNDI&message=Payment%20for%20order
|
|
357
|
+
*/
|
|
358
|
+
declare function generateZip321Uri({ address, amount, memo, message, }: BuildZip321Params): string;
|
|
359
|
+
/**
|
|
360
|
+
* Parses a ZIP-321 URI back into its component parts.
|
|
361
|
+
*/
|
|
362
|
+
declare function parseZip321Uri(rawUri: string): Zip321PaymentRequest;
|
|
363
|
+
/**
|
|
364
|
+
* Generates deep link URLs for major mobile Zcash wallets:
|
|
365
|
+
* - Zashi (Electric Coin Co.)
|
|
366
|
+
* - Ywallet
|
|
367
|
+
*/
|
|
368
|
+
declare function getWalletDeepLinks(zip321Uri: string): {
|
|
369
|
+
generic: string;
|
|
370
|
+
zashi: string;
|
|
371
|
+
ywallet: string;
|
|
372
|
+
};
|
|
373
|
+
|
|
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 };
|