@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/dist/index.js
ADDED
|
@@ -0,0 +1,1999 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
CiceroAccountModal: () => CiceroAccountModal,
|
|
34
|
+
CiceroConnectButton: () => CiceroConnectButton,
|
|
35
|
+
CiceroConnectModal: () => CiceroConnectModal,
|
|
36
|
+
CiceroProvider: () => CiceroProvider,
|
|
37
|
+
CiceroQRCode: () => CiceroQRCode,
|
|
38
|
+
ZucchiniWalletAdapter: () => ZucchiniWalletAdapter,
|
|
39
|
+
burnerWallet: () => burnerWallet,
|
|
40
|
+
decodeBase64Url: () => decodeBase64Url,
|
|
41
|
+
encodeBase64Url: () => encodeBase64Url,
|
|
42
|
+
generateZip321Uri: () => generateZip321Uri,
|
|
43
|
+
getAddressType: () => getAddressType,
|
|
44
|
+
getDefaultWallets: () => getDefaultWallets,
|
|
45
|
+
getWalletDeepLinks: () => getWalletDeepLinks,
|
|
46
|
+
isShieldedAddress: () => isShieldedAddress,
|
|
47
|
+
parseZip321Uri: () => parseZip321Uri,
|
|
48
|
+
truncateAddress: () => truncateAddress,
|
|
49
|
+
useAccount: () => useAccount,
|
|
50
|
+
useAccountModal: () => useAccountModal,
|
|
51
|
+
useBalance: () => useBalance,
|
|
52
|
+
useCicero: () => useCicero,
|
|
53
|
+
useConnectModal: () => useConnectModal,
|
|
54
|
+
useZcashPrice: () => useZcashPrice,
|
|
55
|
+
useZucchiniWallet: () => useZucchiniWallet,
|
|
56
|
+
validateMemoSupport: () => validateMemoSupport,
|
|
57
|
+
viewingKeyWallet: () => viewingKeyWallet,
|
|
58
|
+
ywallet: () => ywallet,
|
|
59
|
+
zashiWallet: () => zashiWallet,
|
|
60
|
+
zucchiniWallet: () => zucchiniWallet
|
|
61
|
+
});
|
|
62
|
+
module.exports = __toCommonJS(index_exports);
|
|
63
|
+
|
|
64
|
+
// src/context/CiceroContext.tsx
|
|
65
|
+
var import_react4 = require("react");
|
|
66
|
+
|
|
67
|
+
// src/utils/zip321.ts
|
|
68
|
+
function encodeBase64Url(str) {
|
|
69
|
+
try {
|
|
70
|
+
const bytes = new TextEncoder().encode(str);
|
|
71
|
+
let binary = "";
|
|
72
|
+
const len = bytes.byteLength;
|
|
73
|
+
for (let i = 0; i < len; i++) {
|
|
74
|
+
binary += String.fromCharCode(bytes[i]);
|
|
75
|
+
}
|
|
76
|
+
const base64 = btoa(binary);
|
|
77
|
+
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
78
|
+
} catch {
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function decodeBase64Url(base64url) {
|
|
83
|
+
try {
|
|
84
|
+
let base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
85
|
+
while (base64.length % 4) {
|
|
86
|
+
base64 += "=";
|
|
87
|
+
}
|
|
88
|
+
const binary = atob(base64);
|
|
89
|
+
const bytes = new Uint8Array(binary.length);
|
|
90
|
+
for (let i = 0; i < binary.length; i++) {
|
|
91
|
+
bytes[i] = binary.charCodeAt(i);
|
|
92
|
+
}
|
|
93
|
+
return new TextDecoder().decode(bytes);
|
|
94
|
+
} catch {
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function generateZip321Uri({
|
|
99
|
+
address,
|
|
100
|
+
amount,
|
|
101
|
+
memo,
|
|
102
|
+
message
|
|
103
|
+
}) {
|
|
104
|
+
const cleanAddress = address.trim();
|
|
105
|
+
const params = new URLSearchParams();
|
|
106
|
+
if (amount !== void 0 && amount !== null && amount !== "") {
|
|
107
|
+
const numAmount = typeof amount === "number" ? amount : parseFloat(amount);
|
|
108
|
+
if (!isNaN(numAmount) && numAmount > 0) {
|
|
109
|
+
params.append("amount", numAmount.toString());
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (memo && memo.trim().length > 0) {
|
|
113
|
+
const encodedMemo = encodeBase64Url(memo.trim());
|
|
114
|
+
if (encodedMemo) {
|
|
115
|
+
params.append("memo", encodedMemo);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (message && message.trim().length > 0) {
|
|
119
|
+
params.append("message", message.trim());
|
|
120
|
+
}
|
|
121
|
+
const queryString = params.toString();
|
|
122
|
+
return queryString ? `zcash:${cleanAddress}?${queryString}` : `zcash:${cleanAddress}`;
|
|
123
|
+
}
|
|
124
|
+
function parseZip321Uri(rawUri) {
|
|
125
|
+
const trimmed = rawUri.trim();
|
|
126
|
+
const withoutScheme = trimmed.startsWith("zcash:") ? trimmed.slice(6) : trimmed;
|
|
127
|
+
const [addressPart, queryPart] = withoutScheme.split("?");
|
|
128
|
+
const result = {
|
|
129
|
+
address: addressPart || "",
|
|
130
|
+
rawUri: trimmed
|
|
131
|
+
};
|
|
132
|
+
if (!queryPart) {
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
const searchParams = new URLSearchParams(queryPart);
|
|
136
|
+
const amount = searchParams.get("amount");
|
|
137
|
+
const memo = searchParams.get("memo");
|
|
138
|
+
const message = searchParams.get("message");
|
|
139
|
+
if (amount) result.amount = amount;
|
|
140
|
+
if (memo) result.memo = decodeBase64Url(memo);
|
|
141
|
+
if (message) result.message = message;
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
function getWalletDeepLinks(zip321Uri) {
|
|
145
|
+
return {
|
|
146
|
+
generic: zip321Uri,
|
|
147
|
+
zashi: zip321Uri,
|
|
148
|
+
// Zashi registers the native zcash: URI handler on iOS/Android
|
|
149
|
+
ywallet: zip321Uri
|
|
150
|
+
// Ywallet also natively handles zcash: protocol
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/wallet/zucchini.ts
|
|
155
|
+
var ZucchiniWalletAdapter = class _ZucchiniWalletAdapter {
|
|
156
|
+
client = null;
|
|
157
|
+
provider = null;
|
|
158
|
+
_connected = false;
|
|
159
|
+
_address = null;
|
|
160
|
+
_lastAccounts = [];
|
|
161
|
+
/**
|
|
162
|
+
* Checks whether the Zucchini Wallet extension is installed and its
|
|
163
|
+
* provider is available in the current browser environment.
|
|
164
|
+
*/
|
|
165
|
+
static isAvailable() {
|
|
166
|
+
if (typeof window === "undefined") return false;
|
|
167
|
+
const win = window;
|
|
168
|
+
if (win.zucchini && typeof win.zucchini.request === "function") {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
if (win.zcash) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
return !!win.zucchini;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Subscribes to wallet readiness. Fires callback immediately if already available,
|
|
178
|
+
* or listens for injection events / polls briefly for late extension initialization.
|
|
179
|
+
*/
|
|
180
|
+
static onReady(callback) {
|
|
181
|
+
if (typeof window === "undefined") return () => {
|
|
182
|
+
};
|
|
183
|
+
if (_ZucchiniWalletAdapter.isAvailable()) {
|
|
184
|
+
callback();
|
|
185
|
+
return () => {
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const handler = () => callback();
|
|
189
|
+
window.addEventListener("zucchini#initialized", handler);
|
|
190
|
+
window.addEventListener("zcash#initialized", handler);
|
|
191
|
+
const interval = setInterval(() => {
|
|
192
|
+
if (_ZucchiniWalletAdapter.isAvailable()) {
|
|
193
|
+
clearInterval(interval);
|
|
194
|
+
callback();
|
|
195
|
+
}
|
|
196
|
+
}, 150);
|
|
197
|
+
const timeout = setTimeout(() => {
|
|
198
|
+
clearInterval(interval);
|
|
199
|
+
}, 3500);
|
|
200
|
+
return () => {
|
|
201
|
+
window.removeEventListener("zucchini#initialized", handler);
|
|
202
|
+
window.removeEventListener("zcash#initialized", handler);
|
|
203
|
+
clearInterval(interval);
|
|
204
|
+
clearTimeout(timeout);
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Discovers and initializes the Zucchini Client using @zucchinifi/dapp-sdk/zcash
|
|
209
|
+
* with graceful fallback to raw window.zucchini / window.zcash globals.
|
|
210
|
+
*/
|
|
211
|
+
async getClient() {
|
|
212
|
+
if (this.client) return this.client;
|
|
213
|
+
if (typeof window === "undefined") {
|
|
214
|
+
throw new Error("Zucchini Wallet is only available in browser environments.");
|
|
215
|
+
}
|
|
216
|
+
const win = window;
|
|
217
|
+
let rawProvider = win.zucchini || win.zcash;
|
|
218
|
+
try {
|
|
219
|
+
const { discoverZucchiniProvider, createZucchiniClient } = await import("@zucchinifi/dapp-sdk/zcash");
|
|
220
|
+
const discovered = discoverZucchiniProvider() || rawProvider;
|
|
221
|
+
if (discovered) {
|
|
222
|
+
this.provider = discovered;
|
|
223
|
+
this.client = createZucchiniClient(discovered);
|
|
224
|
+
return this.client;
|
|
225
|
+
}
|
|
226
|
+
} catch {
|
|
227
|
+
}
|
|
228
|
+
if (rawProvider) {
|
|
229
|
+
this.provider = rawProvider;
|
|
230
|
+
this.client = {
|
|
231
|
+
async connect(req) {
|
|
232
|
+
if (typeof rawProvider.connect === "function") {
|
|
233
|
+
return rawProvider.connect(req?.permissions || ["view_addresses", "view_balance", "send_transaction"]);
|
|
234
|
+
}
|
|
235
|
+
if (typeof rawProvider.request === "function") {
|
|
236
|
+
return rawProvider.request({ method: "connect", params: req });
|
|
237
|
+
}
|
|
238
|
+
return { connected: true };
|
|
239
|
+
},
|
|
240
|
+
async disconnect() {
|
|
241
|
+
if (typeof rawProvider.disconnect === "function") {
|
|
242
|
+
return rawProvider.disconnect();
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
async requestPayment(uri) {
|
|
246
|
+
if (typeof rawProvider.request === "function") {
|
|
247
|
+
const res = await rawProvider.request({
|
|
248
|
+
method: "zcash_requestPayment",
|
|
249
|
+
params: { uri }
|
|
250
|
+
});
|
|
251
|
+
return { txid: res?.txid || res?.txId || res };
|
|
252
|
+
}
|
|
253
|
+
throw new Error("Direct ZIP-321 send not supported by provider");
|
|
254
|
+
},
|
|
255
|
+
async getAddresses() {
|
|
256
|
+
if (typeof rawProvider.request === "function") {
|
|
257
|
+
return rawProvider.request({ method: "getAddresses" });
|
|
258
|
+
}
|
|
259
|
+
return {};
|
|
260
|
+
},
|
|
261
|
+
on(event, listener) {
|
|
262
|
+
rawProvider.on?.(event, listener);
|
|
263
|
+
return () => rawProvider.off?.(event, listener);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
return this.client;
|
|
267
|
+
}
|
|
268
|
+
throw new Error(
|
|
269
|
+
"Zucchini Wallet extension not detected. Please install it from the Chrome Web Store or ensure the side-panel is open."
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Requests connection with view_addresses and send_transaction permissions.
|
|
274
|
+
* Resolves the user's active Shielded Unified Address.
|
|
275
|
+
*/
|
|
276
|
+
async connect() {
|
|
277
|
+
const client = await this.getClient();
|
|
278
|
+
const connection = await client.connect({
|
|
279
|
+
permissions: ["view_addresses", "view_balance", "send_transaction"]
|
|
280
|
+
});
|
|
281
|
+
let address = void 0;
|
|
282
|
+
if (connection?.accounts && connection.accounts.length > 0) {
|
|
283
|
+
address = connection.accounts[0].address;
|
|
284
|
+
}
|
|
285
|
+
if (!address && typeof client.getAddresses === "function") {
|
|
286
|
+
try {
|
|
287
|
+
const addresses = await client.getAddresses();
|
|
288
|
+
address = addresses?.unified || addresses?.orchard || addresses?.sapling || addresses?.transparent;
|
|
289
|
+
} catch {
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
this._lastAccounts = connection?.accounts || [];
|
|
293
|
+
const network = await this.getNetwork();
|
|
294
|
+
const balance = await this.getBalance({ address, network });
|
|
295
|
+
this._connected = true;
|
|
296
|
+
this._address = address || null;
|
|
297
|
+
return {
|
|
298
|
+
address,
|
|
299
|
+
connected: true,
|
|
300
|
+
network,
|
|
301
|
+
balance: balance ?? void 0
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Queries the active network of the Zucchini Wallet ('mainnet' | 'testnet').
|
|
306
|
+
*/
|
|
307
|
+
async getNetwork() {
|
|
308
|
+
try {
|
|
309
|
+
const client = await this.getClient();
|
|
310
|
+
if (typeof client.network === "function") {
|
|
311
|
+
const net = await client.network();
|
|
312
|
+
if (net === "mainnet" || net === "testnet") {
|
|
313
|
+
return net;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
} catch {
|
|
317
|
+
}
|
|
318
|
+
const raw = this.provider || (typeof window !== "undefined" ? window.zucchini || window.zcash : null);
|
|
319
|
+
if (raw && typeof raw.request === "function") {
|
|
320
|
+
try {
|
|
321
|
+
const res = await raw.request({ method: "getNetwork" });
|
|
322
|
+
if (res?.network === "main" || res === "main" || res === "mainnet") return "mainnet";
|
|
323
|
+
if (res?.network === "test" || res === "test" || res === "testnet") return "testnet";
|
|
324
|
+
} catch {
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (this._address) {
|
|
328
|
+
if (this._address.startsWith("utest1") || this._address.startsWith("ztestsapling") || this._address.startsWith("tm")) {
|
|
329
|
+
return "testnet";
|
|
330
|
+
}
|
|
331
|
+
if (this._address.startsWith("u1") || this._address.startsWith("zs1") || this._address.startsWith("t1")) {
|
|
332
|
+
return "mainnet";
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return "mainnet";
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Requests a network change. If the extension does not support programmatic
|
|
339
|
+
* switching, informs the application that manual user toggle is needed.
|
|
340
|
+
*/
|
|
341
|
+
async switchNetwork(targetNetwork) {
|
|
342
|
+
const current = await this.getNetwork();
|
|
343
|
+
if (current === targetNetwork) {
|
|
344
|
+
return { success: true, currentNetwork: current };
|
|
345
|
+
}
|
|
346
|
+
const raw = this.provider || (typeof window !== "undefined" ? window.zucchini || window.zcash : null);
|
|
347
|
+
if (raw && typeof raw.request === "function") {
|
|
348
|
+
try {
|
|
349
|
+
await raw.request({
|
|
350
|
+
method: "switchNetwork",
|
|
351
|
+
params: { network: targetNetwork === "mainnet" ? "main" : "test" }
|
|
352
|
+
});
|
|
353
|
+
const updated = await this.getNetwork();
|
|
354
|
+
return { success: updated === targetNetwork, currentNetwork: updated };
|
|
355
|
+
} catch {
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
success: false,
|
|
360
|
+
requiresManualSwitch: true,
|
|
361
|
+
currentNetwork: current
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Subscribes to network change events from the wallet extension.
|
|
366
|
+
*/
|
|
367
|
+
onNetworkChanged(listener) {
|
|
368
|
+
const raw = this.provider || (typeof window !== "undefined" ? window.zucchini || window.zcash : null);
|
|
369
|
+
const handler = async () => {
|
|
370
|
+
const net = await this.getNetwork();
|
|
371
|
+
listener(net);
|
|
372
|
+
};
|
|
373
|
+
if (raw?.on) {
|
|
374
|
+
raw.on("networkChanged", handler);
|
|
375
|
+
raw.on("chainChanged", handler);
|
|
376
|
+
raw.on("accountsChanged", handler);
|
|
377
|
+
return () => {
|
|
378
|
+
raw.off?.("networkChanged", handler);
|
|
379
|
+
raw.off?.("chainChanged", handler);
|
|
380
|
+
raw.off?.("accountsChanged", handler);
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
return () => {
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Helper to normalize raw balance formats (e.g. number, string, zatoshis, or pool totals).
|
|
388
|
+
*/
|
|
389
|
+
parseBalancePayload(payload) {
|
|
390
|
+
if (payload === void 0 || payload === null) return null;
|
|
391
|
+
if (typeof payload === "number") {
|
|
392
|
+
return payload > 1e6 ? payload / 1e8 : payload;
|
|
393
|
+
}
|
|
394
|
+
if (typeof payload === "string") {
|
|
395
|
+
const parsed = parseFloat(payload);
|
|
396
|
+
if (!isNaN(parsed)) {
|
|
397
|
+
return parsed > 1e6 ? parsed / 1e8 : parsed;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (typeof payload === "object") {
|
|
401
|
+
const cand = payload.total ?? payload.balance ?? payload.amount ?? payload.zec ?? payload.value ?? payload.zatoshis;
|
|
402
|
+
if (cand !== void 0 && cand !== null) {
|
|
403
|
+
return this.parseBalancePayload(cand);
|
|
404
|
+
}
|
|
405
|
+
let sum = 0;
|
|
406
|
+
let hasPool = false;
|
|
407
|
+
for (const pool of ["orchard", "sapling", "transparent", "shielded", "unshielded"]) {
|
|
408
|
+
if (payload[pool] !== void 0) {
|
|
409
|
+
const v = this.parseBalancePayload(payload[pool]);
|
|
410
|
+
if (v !== null) {
|
|
411
|
+
sum += v;
|
|
412
|
+
hasPool = true;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (hasPool) return sum;
|
|
417
|
+
}
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Reads real-time balance from Zucchini provider.
|
|
422
|
+
*/
|
|
423
|
+
async getBalance(options) {
|
|
424
|
+
const raw = this.provider || (typeof window !== "undefined" ? window.zucchini || window.zcash : null);
|
|
425
|
+
const methods = [
|
|
426
|
+
"getBalance",
|
|
427
|
+
"getBalances",
|
|
428
|
+
"zcash_getBalance",
|
|
429
|
+
"zcash_getBalances",
|
|
430
|
+
"view_balance",
|
|
431
|
+
"getBalanceSummary"
|
|
432
|
+
];
|
|
433
|
+
if (raw && typeof raw.request === "function") {
|
|
434
|
+
for (const method of methods) {
|
|
435
|
+
try {
|
|
436
|
+
const res = await raw.request({ method, params: options });
|
|
437
|
+
const parsed = this.parseBalancePayload(res);
|
|
438
|
+
if (parsed !== null) return parsed;
|
|
439
|
+
} catch {
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (this._lastAccounts && this._lastAccounts.length > 0) {
|
|
444
|
+
for (const acc of this._lastAccounts) {
|
|
445
|
+
const parsed = this.parseBalancePayload(acc);
|
|
446
|
+
if (parsed !== null) return parsed;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Sends payment via standard ZIP-321 URI requestPayment or transaction fallback.
|
|
453
|
+
*/
|
|
454
|
+
async requestPayment(params) {
|
|
455
|
+
if (!this._connected) {
|
|
456
|
+
await this.connect();
|
|
457
|
+
}
|
|
458
|
+
const client = await this.getClient();
|
|
459
|
+
const numAmount = typeof params.amount === "number" ? params.amount : parseFloat(params.amount);
|
|
460
|
+
if (isNaN(numAmount) || numAmount <= 0) {
|
|
461
|
+
throw new Error("Payment amount must be a positive number.");
|
|
462
|
+
}
|
|
463
|
+
const uri = generateZip321Uri({
|
|
464
|
+
address: params.recipient.trim(),
|
|
465
|
+
amount: numAmount,
|
|
466
|
+
memo: params.memo?.trim()
|
|
467
|
+
});
|
|
468
|
+
try {
|
|
469
|
+
if (typeof client.requestPayment === "function") {
|
|
470
|
+
const res = await client.requestPayment(uri);
|
|
471
|
+
const txId = res?.txid || res?.txId || "";
|
|
472
|
+
return { txId, submitted: true };
|
|
473
|
+
}
|
|
474
|
+
} catch (e) {
|
|
475
|
+
}
|
|
476
|
+
if (typeof client.requestTransaction === "function") {
|
|
477
|
+
const zatoshis = BigInt(Math.round(numAmount * 1e8));
|
|
478
|
+
const res = await client.requestTransaction({
|
|
479
|
+
amountZatoshis: zatoshis,
|
|
480
|
+
recipient: params.recipient.trim(),
|
|
481
|
+
memo: params.memo?.trim()
|
|
482
|
+
});
|
|
483
|
+
return { txId: res?.txid || "", submitted: true };
|
|
484
|
+
}
|
|
485
|
+
throw new Error("Zucchini Wallet does not support payment dispatch.");
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Subscribes to accountsChanged events.
|
|
489
|
+
*/
|
|
490
|
+
onAccountsChanged(listener) {
|
|
491
|
+
if (this.client?.on) {
|
|
492
|
+
return this.client.on("accountsChanged", listener);
|
|
493
|
+
}
|
|
494
|
+
if (this.provider?.on) {
|
|
495
|
+
this.provider.on("accountsChanged", listener);
|
|
496
|
+
return () => this.provider?.off?.("accountsChanged", listener);
|
|
497
|
+
}
|
|
498
|
+
return () => {
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Subscribes to disconnect events.
|
|
503
|
+
*/
|
|
504
|
+
onDisconnect(listener) {
|
|
505
|
+
if (this.client?.on) {
|
|
506
|
+
return this.client.on("disconnect", listener);
|
|
507
|
+
}
|
|
508
|
+
if (this.provider?.on) {
|
|
509
|
+
this.provider.on("disconnect", listener);
|
|
510
|
+
return () => this.provider?.off?.("disconnect", listener);
|
|
511
|
+
}
|
|
512
|
+
return () => {
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Disconnects the current session.
|
|
517
|
+
*/
|
|
518
|
+
async disconnect() {
|
|
519
|
+
try {
|
|
520
|
+
if (this.client?.disconnect) {
|
|
521
|
+
await this.client.disconnect();
|
|
522
|
+
} else if (this.provider?.disconnect) {
|
|
523
|
+
await this.provider.disconnect();
|
|
524
|
+
}
|
|
525
|
+
} catch {
|
|
526
|
+
}
|
|
527
|
+
this._connected = false;
|
|
528
|
+
this._address = null;
|
|
529
|
+
}
|
|
530
|
+
get isConnected() {
|
|
531
|
+
return this._connected;
|
|
532
|
+
}
|
|
533
|
+
get address() {
|
|
534
|
+
return this._address;
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
// src/wallets/zucchini.ts
|
|
539
|
+
var adapter = new ZucchiniWalletAdapter();
|
|
540
|
+
var zucchiniWallet = {
|
|
541
|
+
id: "zucchini",
|
|
542
|
+
name: "Zucchini Wallet",
|
|
543
|
+
icon: "\u{1F952}",
|
|
544
|
+
description: "In-browser Chrome extension with 1-click side-panel approvals",
|
|
545
|
+
category: "extension",
|
|
546
|
+
downloadUrl: "https://chromewebstore.google.com/detail/zucchini-wallet",
|
|
547
|
+
isAvailable: () => ZucchiniWalletAdapter.isAvailable(),
|
|
548
|
+
connect: async (options) => {
|
|
549
|
+
const session = await adapter.connect();
|
|
550
|
+
return {
|
|
551
|
+
address: session.address,
|
|
552
|
+
connected: true,
|
|
553
|
+
network: session.network || options?.network || "mainnet",
|
|
554
|
+
walletId: "zucchini",
|
|
555
|
+
balance: session.balance
|
|
556
|
+
};
|
|
557
|
+
},
|
|
558
|
+
disconnect: async () => {
|
|
559
|
+
await adapter.disconnect();
|
|
560
|
+
},
|
|
561
|
+
getBalance: async (options) => {
|
|
562
|
+
return adapter.getBalance(options);
|
|
563
|
+
},
|
|
564
|
+
getNetwork: async () => {
|
|
565
|
+
return adapter.getNetwork();
|
|
566
|
+
},
|
|
567
|
+
switchNetwork: async (network) => {
|
|
568
|
+
return adapter.switchNetwork(network);
|
|
569
|
+
},
|
|
570
|
+
sendPayment: async (params) => {
|
|
571
|
+
const res = await adapter.requestPayment({
|
|
572
|
+
recipient: params.recipient,
|
|
573
|
+
amount: params.amount,
|
|
574
|
+
memo: params.memo
|
|
575
|
+
});
|
|
576
|
+
return {
|
|
577
|
+
txId: res.txId,
|
|
578
|
+
submitted: res.submitted
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
// src/wallets/zashi.ts
|
|
584
|
+
var zashiWallet = {
|
|
585
|
+
id: "zashi",
|
|
586
|
+
name: "Zashi by ECC",
|
|
587
|
+
icon: "\u{1F6E1}\uFE0F",
|
|
588
|
+
description: "Official zero-knowledge mobile wallet by Electric Coin Co.",
|
|
589
|
+
category: "mobile",
|
|
590
|
+
downloadUrl: "https://electriccoin.co/zashi/",
|
|
591
|
+
isAvailable: () => true,
|
|
592
|
+
// Available via mobile QR or deep link
|
|
593
|
+
connect: async (options) => {
|
|
594
|
+
return {
|
|
595
|
+
connected: true,
|
|
596
|
+
network: options?.network || "mainnet",
|
|
597
|
+
walletId: "zashi"
|
|
598
|
+
};
|
|
599
|
+
},
|
|
600
|
+
sendPayment: async (params) => {
|
|
601
|
+
const rawUri = generateZip321Uri({
|
|
602
|
+
address: params.recipient,
|
|
603
|
+
amount: params.amount,
|
|
604
|
+
memo: params.memo,
|
|
605
|
+
message: params.message
|
|
606
|
+
});
|
|
607
|
+
if (typeof window !== "undefined") {
|
|
608
|
+
window.location.href = rawUri;
|
|
609
|
+
}
|
|
610
|
+
return {
|
|
611
|
+
txId: "",
|
|
612
|
+
submitted: false,
|
|
613
|
+
rawUri
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
// src/wallets/ywallet.ts
|
|
619
|
+
var ywallet = {
|
|
620
|
+
id: "ywallet",
|
|
621
|
+
name: "Ywallet",
|
|
622
|
+
icon: "\u26A1",
|
|
623
|
+
description: "Fast-syncing multi-platform shielded wallet for mobile & desktop",
|
|
624
|
+
category: "mobile",
|
|
625
|
+
downloadUrl: "https://ywallet.app/",
|
|
626
|
+
isAvailable: () => true,
|
|
627
|
+
connect: async (options) => {
|
|
628
|
+
return {
|
|
629
|
+
connected: true,
|
|
630
|
+
network: options?.network || "mainnet",
|
|
631
|
+
walletId: "ywallet"
|
|
632
|
+
};
|
|
633
|
+
},
|
|
634
|
+
sendPayment: async (params) => {
|
|
635
|
+
const rawUri = generateZip321Uri({
|
|
636
|
+
address: params.recipient,
|
|
637
|
+
amount: params.amount,
|
|
638
|
+
memo: params.memo,
|
|
639
|
+
message: params.message
|
|
640
|
+
});
|
|
641
|
+
if (typeof window !== "undefined") {
|
|
642
|
+
window.location.href = rawUri;
|
|
643
|
+
}
|
|
644
|
+
return {
|
|
645
|
+
txId: "",
|
|
646
|
+
submitted: false,
|
|
647
|
+
rawUri
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
// src/wallets/viewingKey.ts
|
|
653
|
+
var viewingKeyWallet = {
|
|
654
|
+
id: "viewing-key",
|
|
655
|
+
name: "Viewing Key / Auditor",
|
|
656
|
+
icon: "\u{1F441}\uFE0F",
|
|
657
|
+
description: "Connect with a Unified Address or Viewing Key for read-only audit mode",
|
|
658
|
+
category: "read-only",
|
|
659
|
+
isAvailable: () => true,
|
|
660
|
+
connect: async (options) => {
|
|
661
|
+
return {
|
|
662
|
+
connected: true,
|
|
663
|
+
network: options?.network || "mainnet",
|
|
664
|
+
walletId: "viewing-key"
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
// src/wallets/burner.ts
|
|
670
|
+
var MOCK_BURNER_ADDR = "u1qwe829xkps9482mzsll049281kz8471hzkas093847zkd09472619as8361048293710293847102938471029384710";
|
|
671
|
+
var burnerWallet = {
|
|
672
|
+
id: "burner",
|
|
673
|
+
name: "Dev Session Wallet",
|
|
674
|
+
icon: "\u{1F9EA}",
|
|
675
|
+
description: "Instant ephemeral shielded test wallet for rapid local testing",
|
|
676
|
+
category: "developer",
|
|
677
|
+
isAvailable: () => true,
|
|
678
|
+
connect: async (options) => {
|
|
679
|
+
return {
|
|
680
|
+
address: MOCK_BURNER_ADDR,
|
|
681
|
+
connected: true,
|
|
682
|
+
network: options?.network || "testnet",
|
|
683
|
+
walletId: "burner"
|
|
684
|
+
};
|
|
685
|
+
},
|
|
686
|
+
sendPayment: async (_params) => {
|
|
687
|
+
const mockTxId = `0x${Array.from(
|
|
688
|
+
{ length: 64 },
|
|
689
|
+
() => Math.floor(Math.random() * 16).toString(16)
|
|
690
|
+
).join("")}`;
|
|
691
|
+
return {
|
|
692
|
+
txId: mockTxId,
|
|
693
|
+
submitted: true
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
// src/wallets/index.ts
|
|
699
|
+
function getDefaultWallets() {
|
|
700
|
+
return [
|
|
701
|
+
zucchiniWallet,
|
|
702
|
+
zashiWallet,
|
|
703
|
+
ywallet,
|
|
704
|
+
viewingKeyWallet,
|
|
705
|
+
burnerWallet
|
|
706
|
+
];
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// src/hooks/useZcashPrice.ts
|
|
710
|
+
var import_react = require("react");
|
|
711
|
+
var cachedPrice = null;
|
|
712
|
+
var lastFetchTime = 0;
|
|
713
|
+
var CACHE_DURATION_MS = 6e4;
|
|
714
|
+
function useZcashPrice(enabled = true) {
|
|
715
|
+
const [state, setState] = (0, import_react.useState)(() => ({
|
|
716
|
+
usdPrice: cachedPrice,
|
|
717
|
+
loading: !cachedPrice && enabled,
|
|
718
|
+
error: null,
|
|
719
|
+
lastUpdated: lastFetchTime || null
|
|
720
|
+
}));
|
|
721
|
+
(0, import_react.useEffect)(() => {
|
|
722
|
+
if (!enabled) return;
|
|
723
|
+
let isMounted = true;
|
|
724
|
+
const now = Date.now();
|
|
725
|
+
if (cachedPrice && now - lastFetchTime < CACHE_DURATION_MS) {
|
|
726
|
+
setState((prev) => {
|
|
727
|
+
if (prev.usdPrice === cachedPrice && !prev.loading) return prev;
|
|
728
|
+
return {
|
|
729
|
+
usdPrice: cachedPrice,
|
|
730
|
+
loading: false,
|
|
731
|
+
error: null,
|
|
732
|
+
lastUpdated: lastFetchTime
|
|
733
|
+
};
|
|
734
|
+
});
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
async function fetchPrice() {
|
|
738
|
+
try {
|
|
739
|
+
const res = await fetch(
|
|
740
|
+
"https://api.coingecko.com/api/v3/simple/price?ids=zcash&vs_currencies=usd",
|
|
741
|
+
{ signal: AbortSignal.timeout(4e3) }
|
|
742
|
+
);
|
|
743
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
744
|
+
const data = await res.json();
|
|
745
|
+
const price = data?.zcash?.usd;
|
|
746
|
+
if (typeof price === "number") {
|
|
747
|
+
cachedPrice = price;
|
|
748
|
+
lastFetchTime = Date.now();
|
|
749
|
+
if (isMounted) {
|
|
750
|
+
setState({
|
|
751
|
+
usdPrice: price,
|
|
752
|
+
loading: false,
|
|
753
|
+
error: null,
|
|
754
|
+
lastUpdated: lastFetchTime
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
throw new Error("Invalid price payload");
|
|
760
|
+
} catch (err) {
|
|
761
|
+
try {
|
|
762
|
+
const binanceRes = await fetch(
|
|
763
|
+
"https://api.binance.com/api/v3/ticker/price?symbol=ZECUSDT",
|
|
764
|
+
{ signal: AbortSignal.timeout(3e3) }
|
|
765
|
+
);
|
|
766
|
+
if (binanceRes.ok) {
|
|
767
|
+
const bData = await binanceRes.json();
|
|
768
|
+
const bPrice = parseFloat(bData.price);
|
|
769
|
+
if (!isNaN(bPrice) && bPrice > 0) {
|
|
770
|
+
cachedPrice = bPrice;
|
|
771
|
+
lastFetchTime = Date.now();
|
|
772
|
+
if (isMounted) {
|
|
773
|
+
setState({
|
|
774
|
+
usdPrice: bPrice,
|
|
775
|
+
loading: false,
|
|
776
|
+
error: null,
|
|
777
|
+
lastUpdated: lastFetchTime
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
} catch {
|
|
784
|
+
}
|
|
785
|
+
if (isMounted) {
|
|
786
|
+
const fallback = cachedPrice ?? 38.5;
|
|
787
|
+
setState({
|
|
788
|
+
usdPrice: fallback,
|
|
789
|
+
loading: false,
|
|
790
|
+
error: err instanceof Error ? err.message : "Price fetch error",
|
|
791
|
+
lastUpdated: Date.now()
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
fetchPrice();
|
|
797
|
+
return () => {
|
|
798
|
+
isMounted = false;
|
|
799
|
+
};
|
|
800
|
+
}, [enabled]);
|
|
801
|
+
const convertZecToUsd = (0, import_react.useCallback)(
|
|
802
|
+
(zecAmount) => {
|
|
803
|
+
const num = typeof zecAmount === "number" ? zecAmount : parseFloat(zecAmount);
|
|
804
|
+
if (isNaN(num) || state.usdPrice === null) return null;
|
|
805
|
+
return (num * state.usdPrice).toFixed(2);
|
|
806
|
+
},
|
|
807
|
+
[state.usdPrice]
|
|
808
|
+
);
|
|
809
|
+
return {
|
|
810
|
+
...state,
|
|
811
|
+
convertZecToUsd
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// src/components/CiceroConnectModal.tsx
|
|
816
|
+
var import_react2 = require("react");
|
|
817
|
+
var import_react_dom = require("react-dom");
|
|
818
|
+
var import_lucide_react = require("lucide-react");
|
|
819
|
+
|
|
820
|
+
// src/components/CiceroQRCode.tsx
|
|
821
|
+
var import_qrcode = require("qrcode.react");
|
|
822
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
823
|
+
var CiceroQRCode = ({
|
|
824
|
+
value,
|
|
825
|
+
size = 200,
|
|
826
|
+
className = "",
|
|
827
|
+
level = "M",
|
|
828
|
+
includeMargin = true
|
|
829
|
+
}) => {
|
|
830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
831
|
+
"div",
|
|
832
|
+
{
|
|
833
|
+
className: `inline-flex items-center justify-center p-3 bg-white rounded-lg border border-[#ededed] shadow-sm ${className}`,
|
|
834
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
835
|
+
import_qrcode.QRCodeSVG,
|
|
836
|
+
{
|
|
837
|
+
value,
|
|
838
|
+
size,
|
|
839
|
+
level,
|
|
840
|
+
includeMargin,
|
|
841
|
+
imageSettings: {
|
|
842
|
+
src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23171717'%3E%3Cpath d='M12 2L3 7v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7l-9-5zm0 4.5l5 2.5v4.5c0 3.3-2.1 6.3-5 7.2-2.9-.9-5-3.9-5-7.2V9l5-2.5z'/%3E%3Cpath d='M10 11h4l-3 4h3' stroke='%233ecf8e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E",
|
|
843
|
+
height: 28,
|
|
844
|
+
width: 28,
|
|
845
|
+
excavate: true
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
)
|
|
849
|
+
}
|
|
850
|
+
);
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
// src/components/CiceroConnectModal.tsx
|
|
854
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
855
|
+
var CiceroConnectModal = ({
|
|
856
|
+
isOpen: propIsOpen,
|
|
857
|
+
onClose: propOnClose
|
|
858
|
+
}) => {
|
|
859
|
+
const {
|
|
860
|
+
isConnectModalOpen,
|
|
861
|
+
closeConnectModal,
|
|
862
|
+
wallets,
|
|
863
|
+
connect,
|
|
864
|
+
network,
|
|
865
|
+
appName
|
|
866
|
+
} = useCicero();
|
|
867
|
+
const isOpen = propIsOpen !== void 0 ? propIsOpen : isConnectModalOpen;
|
|
868
|
+
const handleClose = propOnClose || closeConnectModal;
|
|
869
|
+
const [selectedWalletId, setSelectedWalletId] = (0, import_react2.useState)("zucchini");
|
|
870
|
+
const [customKeyInput, setCustomKeyInput] = (0, import_react2.useState)("");
|
|
871
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
872
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react2.useState)(false);
|
|
873
|
+
const [mounted, setMounted] = (0, import_react2.useState)(false);
|
|
874
|
+
const [, setAvailabilityTick] = (0, import_react2.useState)(0);
|
|
875
|
+
(0, import_react2.useEffect)(() => {
|
|
876
|
+
setMounted(true);
|
|
877
|
+
}, []);
|
|
878
|
+
(0, import_react2.useEffect)(() => {
|
|
879
|
+
if (!isOpen) return;
|
|
880
|
+
const cleanupReady = ZucchiniWalletAdapter.onReady(() => {
|
|
881
|
+
setAvailabilityTick((t) => t + 1);
|
|
882
|
+
});
|
|
883
|
+
const interval = setInterval(() => {
|
|
884
|
+
setAvailabilityTick((t) => t + 1);
|
|
885
|
+
}, 600);
|
|
886
|
+
return () => {
|
|
887
|
+
cleanupReady();
|
|
888
|
+
clearInterval(interval);
|
|
889
|
+
};
|
|
890
|
+
}, [isOpen]);
|
|
891
|
+
(0, import_react2.useEffect)(() => {
|
|
892
|
+
const handleKeyDown = (e) => {
|
|
893
|
+
if (e.key === "Escape" && isOpen) {
|
|
894
|
+
handleClose();
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
898
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
899
|
+
}, [isOpen, handleClose]);
|
|
900
|
+
if (!isOpen || !mounted) return null;
|
|
901
|
+
const selectedWallet = wallets.find((w) => w.id === selectedWalletId) || wallets[0];
|
|
902
|
+
const isAvailable = selectedWallet?.isAvailable();
|
|
903
|
+
const handleWalletSelect = (walletId) => {
|
|
904
|
+
setSelectedWalletId(walletId);
|
|
905
|
+
setError(null);
|
|
906
|
+
};
|
|
907
|
+
const handleConnectAction = async () => {
|
|
908
|
+
if (!selectedWallet) return;
|
|
909
|
+
setError(null);
|
|
910
|
+
setIsSubmitting(true);
|
|
911
|
+
try {
|
|
912
|
+
if (selectedWallet.id === "viewing-key") {
|
|
913
|
+
if (!customKeyInput.trim()) {
|
|
914
|
+
throw new Error("Please enter a valid Unified Address or Viewing Key.");
|
|
915
|
+
}
|
|
916
|
+
await connect(selectedWallet.id, customKeyInput.trim());
|
|
917
|
+
} else {
|
|
918
|
+
await connect(selectedWallet.id);
|
|
919
|
+
}
|
|
920
|
+
} catch (err) {
|
|
921
|
+
setError(err instanceof Error ? err.message : "Connection failed");
|
|
922
|
+
} finally {
|
|
923
|
+
setIsSubmitting(false);
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
return (0, import_react_dom.createPortal)(
|
|
927
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "fixed inset-0 z-[99999] flex items-center justify-center p-4 sm:p-6 overflow-y-auto font-sans", children: [
|
|
928
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
929
|
+
"div",
|
|
930
|
+
{
|
|
931
|
+
className: "fixed inset-0 bg-[#171717]/60 backdrop-blur-sm transition-opacity z-[99999]",
|
|
932
|
+
onClick: handleClose
|
|
933
|
+
}
|
|
934
|
+
),
|
|
935
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "relative w-full max-w-2xl bg-white rounded-xl border border-[#ededed] shadow-2xl overflow-hidden z-[100000] text-[#171717] animate-in fade-in zoom-in-95 duration-150", children: [
|
|
936
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center justify-between px-6 py-4 border-b border-[#ededed] bg-[#fafafa]", children: [
|
|
937
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-2.5", children: [
|
|
938
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "w-8 h-8 rounded-md bg-[#171717] flex items-center justify-center text-[#3ecf8e]", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Shield, { className: "w-4 h-4 fill-[#3ecf8e]" }) }),
|
|
939
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
940
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
941
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "font-semibold text-sm text-[#171717]", children: "Connect Zcash Wallet" }),
|
|
942
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-[10px] uppercase tracking-wider font-semibold px-2 py-0.5 rounded-full bg-[#3ecf8e]/15 text-[#24b47e] border border-[#3ecf8e]/30", children: network })
|
|
943
|
+
] }),
|
|
944
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-xs text-[#707070] mt-0.5", children: [
|
|
945
|
+
"Connect to ",
|
|
946
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { className: "text-[#171717]", children: appName }),
|
|
947
|
+
" with your preferred zero-knowledge wallet."
|
|
948
|
+
] })
|
|
949
|
+
] })
|
|
950
|
+
] }),
|
|
951
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
952
|
+
"button",
|
|
953
|
+
{
|
|
954
|
+
onClick: handleClose,
|
|
955
|
+
className: "p-1 rounded-md text-[#707070] hover:text-[#171717] hover:bg-[#ededed] transition-colors",
|
|
956
|
+
"aria-label": "Close modal",
|
|
957
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.X, { className: "w-4 h-4" })
|
|
958
|
+
}
|
|
959
|
+
)
|
|
960
|
+
] }),
|
|
961
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "grid grid-cols-1 md:grid-cols-12 min-h-[380px]", children: [
|
|
962
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "md:col-span-5 p-3 bg-[#fafafa] border-r border-[#ededed] space-y-1", children: [
|
|
963
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "px-3 py-2 text-[11px] font-mono uppercase tracking-wider text-[#707070]", children: "Available Wallets" }),
|
|
964
|
+
wallets.map((w) => {
|
|
965
|
+
const active = w.id === selectedWalletId;
|
|
966
|
+
const available = w.isAvailable();
|
|
967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
968
|
+
"button",
|
|
969
|
+
{
|
|
970
|
+
onClick: () => handleWalletSelect(w.id),
|
|
971
|
+
className: `w-full flex items-center justify-between p-3 rounded-lg text-left text-xs transition-all ${active ? "bg-white shadow-sm border border-[#dfdfdf] text-[#171717] font-medium" : "hover:bg-white/60 text-[#707070] hover:text-[#171717] border border-transparent"}`,
|
|
972
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-2.5", children: [
|
|
973
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-base", children: w.icon }),
|
|
974
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
975
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
976
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-sm text-[#171717] font-medium", children: w.name }),
|
|
977
|
+
w.id === "zucchini" && available && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-[9px] uppercase font-mono px-1.5 py-0.2 rounded bg-emerald-100 text-emerald-800 font-bold", children: "Detected" })
|
|
978
|
+
] }),
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-[11px] text-[#9a9a9a] line-clamp-1", children: w.category === "extension" ? "Browser Extension" : w.category === "mobile" ? "Mobile / QR" : w.category === "read-only" ? "Auditor View" : "Dev Session" })
|
|
980
|
+
] })
|
|
981
|
+
] })
|
|
982
|
+
},
|
|
983
|
+
w.id
|
|
984
|
+
);
|
|
985
|
+
})
|
|
986
|
+
] }),
|
|
987
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "md:col-span-7 p-6 flex flex-col justify-between bg-white", children: [
|
|
988
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "space-y-4", children: [
|
|
989
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex items-start justify-between pb-4 border-b border-[#ededed]", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-2.5", children: [
|
|
990
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-2xl", children: selectedWallet.icon }),
|
|
991
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
992
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h4", { className: "text-base font-semibold text-[#171717]", children: selectedWallet.name }),
|
|
993
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-xs text-[#707070] mt-0.5", children: selectedWallet.description })
|
|
994
|
+
] })
|
|
995
|
+
] }) }),
|
|
996
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "p-3 rounded-md bg-rose-50 border border-rose-200 text-rose-800 text-xs flex items-start gap-2", children: [
|
|
997
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.AlertCircle, { className: "w-4 h-4 text-rose-600 flex-shrink-0 mt-0.5" }),
|
|
998
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: error })
|
|
999
|
+
] }),
|
|
1000
|
+
selectedWallet.id === "zucchini" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "space-y-4 py-2", children: isAvailable ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "p-4 rounded-lg bg-emerald-50 border border-emerald-200 text-xs text-emerald-950 space-y-2", children: [
|
|
1001
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-2 font-semibold", children: [
|
|
1002
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Sparkles, { className: "w-4 h-4 text-[#24b47e]" }),
|
|
1003
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Extension Detected & Ready" })
|
|
1004
|
+
] }),
|
|
1005
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-emerald-800 leading-relaxed", children: "Clicking connect will prompt your Zucchini Wallet side-panel to authorize access." })
|
|
1006
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "p-4 rounded-lg bg-[#fafafa] border border-[#ededed] text-xs text-[#707070] space-y-3", children: [
|
|
1007
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "Zucchini Wallet extension was not detected in this browser. Install it to enable 1-click in-browser approvals." }),
|
|
1008
|
+
selectedWallet.downloadUrl && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1009
|
+
"a",
|
|
1010
|
+
{
|
|
1011
|
+
href: selectedWallet.downloadUrl,
|
|
1012
|
+
target: "_blank",
|
|
1013
|
+
rel: "noopener noreferrer",
|
|
1014
|
+
className: "inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[#171717] text-white text-xs font-medium hover:bg-[#212121]",
|
|
1015
|
+
children: [
|
|
1016
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Install from Chrome Web Store" }),
|
|
1017
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ExternalLink, { className: "w-3.5 h-3.5" })
|
|
1018
|
+
]
|
|
1019
|
+
}
|
|
1020
|
+
)
|
|
1021
|
+
] }) }),
|
|
1022
|
+
(selectedWallet.id === "zashi" || selectedWallet.id === "ywallet") && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "text-center space-y-3 py-1", children: [
|
|
1023
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1024
|
+
CiceroQRCode,
|
|
1025
|
+
{
|
|
1026
|
+
value: `zcash:u1demo?message=Connect%20to%20${encodeURIComponent(appName || "Cicero App")}`,
|
|
1027
|
+
size: 150
|
|
1028
|
+
}
|
|
1029
|
+
) }),
|
|
1030
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
1031
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-xs font-medium text-[#171717]", children: [
|
|
1032
|
+
"Scan with ",
|
|
1033
|
+
selectedWallet.name,
|
|
1034
|
+
" app"
|
|
1035
|
+
] }),
|
|
1036
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-[11px] text-[#707070] mt-0.5", children: [
|
|
1037
|
+
"Open ",
|
|
1038
|
+
selectedWallet.name,
|
|
1039
|
+
" on iOS/Android and scan this QR code to authenticate."
|
|
1040
|
+
] })
|
|
1041
|
+
] })
|
|
1042
|
+
] }),
|
|
1043
|
+
selectedWallet.id === "viewing-key" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "space-y-3 py-2 text-xs", children: [
|
|
1044
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
1045
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "font-medium text-[#171717] block mb-1", children: "Unified Address or Viewing Key" }),
|
|
1046
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1047
|
+
"textarea",
|
|
1048
|
+
{
|
|
1049
|
+
rows: 3,
|
|
1050
|
+
value: customKeyInput,
|
|
1051
|
+
onChange: (e) => setCustomKeyInput(e.target.value),
|
|
1052
|
+
placeholder: "Paste u1... address, zxviews... or uview... key",
|
|
1053
|
+
className: "w-full p-2.5 rounded-md bg-white border border-[#dfdfdf] font-mono text-xs text-[#171717] focus:outline-none focus:border-[#3ecf8e]"
|
|
1054
|
+
}
|
|
1055
|
+
)
|
|
1056
|
+
] }),
|
|
1057
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-[11px] text-[#707070]", children: "Read-only connection for tax calculation, accounting reconciliation, or proof-of-reserves." })
|
|
1058
|
+
] }),
|
|
1059
|
+
selectedWallet.id === "burner" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "space-y-3 py-2 text-xs", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "p-3.5 rounded-lg bg-[#fafafa] border border-[#ededed] space-y-1.5", children: [
|
|
1060
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "font-semibold text-[#171717]", children: "Ephemeral Shielded Test Wallet" }),
|
|
1061
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-[#707070] leading-relaxed", children: "Instantly creates an in-memory session wallet pre-funded with simulated testnet ZEC. Perfect for testing dApps without needing external extensions." })
|
|
1062
|
+
] }) })
|
|
1063
|
+
] }),
|
|
1064
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "pt-4 border-t border-[#ededed] mt-4 flex items-center justify-between", children: [
|
|
1065
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-[11px] text-[#9a9a9a]", children: "End-to-End Encrypted" }),
|
|
1066
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1067
|
+
"button",
|
|
1068
|
+
{
|
|
1069
|
+
onClick: handleConnectAction,
|
|
1070
|
+
disabled: isSubmitting,
|
|
1071
|
+
className: "inline-flex items-center gap-2 px-5 py-2.5 rounded-md bg-[#3ecf8e] text-[#171717] font-semibold text-xs hover:bg-[#24b47e] transition-colors disabled:opacity-50 shadow-sm",
|
|
1072
|
+
children: isSubmitting ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1073
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "w-3.5 h-3.5 border-2 border-[#171717]/30 border-t-[#171717] rounded-full animate-spin" }),
|
|
1074
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Connecting..." })
|
|
1075
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1076
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: selectedWallet.id === "viewing-key" ? "Connect Read-Only" : selectedWallet.id === "burner" ? "Launch Dev Session" : `Connect ${selectedWallet.name}` }),
|
|
1077
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ArrowRight, { className: "w-3.5 h-3.5" })
|
|
1078
|
+
] })
|
|
1079
|
+
}
|
|
1080
|
+
)
|
|
1081
|
+
] })
|
|
1082
|
+
] })
|
|
1083
|
+
] })
|
|
1084
|
+
] })
|
|
1085
|
+
] }),
|
|
1086
|
+
document.body
|
|
1087
|
+
);
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
// src/components/CiceroAccountModal.tsx
|
|
1091
|
+
var import_react3 = require("react");
|
|
1092
|
+
var import_react_dom2 = require("react-dom");
|
|
1093
|
+
var import_lucide_react2 = require("lucide-react");
|
|
1094
|
+
|
|
1095
|
+
// src/utils/address.ts
|
|
1096
|
+
function getAddressType(address) {
|
|
1097
|
+
if (!address || typeof address !== "string") {
|
|
1098
|
+
return "unknown";
|
|
1099
|
+
}
|
|
1100
|
+
const clean = address.trim();
|
|
1101
|
+
if (clean.startsWith("u1") || clean.startsWith("utest1")) {
|
|
1102
|
+
return "unified";
|
|
1103
|
+
}
|
|
1104
|
+
if (clean.startsWith("zs1") || clean.startsWith("ztestsapling1")) {
|
|
1105
|
+
return "sapling";
|
|
1106
|
+
}
|
|
1107
|
+
if (clean.startsWith("t1") || clean.startsWith("t3") || clean.startsWith("tm")) {
|
|
1108
|
+
return "transparent";
|
|
1109
|
+
}
|
|
1110
|
+
return "unknown";
|
|
1111
|
+
}
|
|
1112
|
+
function isShieldedAddress(address) {
|
|
1113
|
+
const type = getAddressType(address);
|
|
1114
|
+
return type === "unified" || type === "sapling";
|
|
1115
|
+
}
|
|
1116
|
+
function truncateAddress(address, start = 8, end = 8) {
|
|
1117
|
+
if (!address) return "";
|
|
1118
|
+
const clean = address.trim();
|
|
1119
|
+
if (clean.length <= start + end + 3) {
|
|
1120
|
+
return clean;
|
|
1121
|
+
}
|
|
1122
|
+
return `${clean.slice(0, start)}...${clean.slice(-end)}`;
|
|
1123
|
+
}
|
|
1124
|
+
function validateMemoSupport(address, memo) {
|
|
1125
|
+
const byteLength = memo ? new TextEncoder().encode(memo).length : 0;
|
|
1126
|
+
const isAddressShielded = isShieldedAddress(address);
|
|
1127
|
+
if (byteLength > 512) {
|
|
1128
|
+
return {
|
|
1129
|
+
valid: false,
|
|
1130
|
+
warning: `Memo exceeds Zcash protocol limit of 512 bytes (current: ${byteLength} bytes).`,
|
|
1131
|
+
byteLength
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
if (memo && !isAddressShielded) {
|
|
1135
|
+
return {
|
|
1136
|
+
valid: true,
|
|
1137
|
+
warning: "Warning: Transparent addresses (t-addr) do not support shielded encrypted memos. Use a Unified (u1) or Sapling (zs1) address to protect your memo.",
|
|
1138
|
+
byteLength
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
return {
|
|
1142
|
+
valid: true,
|
|
1143
|
+
byteLength
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
// src/components/CiceroAccountModal.tsx
|
|
1148
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1149
|
+
var CiceroAccountModal = ({
|
|
1150
|
+
isOpen: propIsOpen,
|
|
1151
|
+
onClose: propOnClose
|
|
1152
|
+
}) => {
|
|
1153
|
+
const {
|
|
1154
|
+
isAccountModalOpen,
|
|
1155
|
+
closeAccountModal,
|
|
1156
|
+
address,
|
|
1157
|
+
wallet,
|
|
1158
|
+
network,
|
|
1159
|
+
switchNetwork,
|
|
1160
|
+
balance,
|
|
1161
|
+
refetchBalance,
|
|
1162
|
+
disconnect
|
|
1163
|
+
} = useCicero();
|
|
1164
|
+
const isOpen = propIsOpen !== void 0 ? propIsOpen : isAccountModalOpen;
|
|
1165
|
+
const handleClose = propOnClose || closeAccountModal;
|
|
1166
|
+
const [copied, setCopied] = (0, import_react3.useState)(false);
|
|
1167
|
+
const [showQr, setShowQr] = (0, import_react3.useState)(false);
|
|
1168
|
+
const [mounted, setMounted] = (0, import_react3.useState)(false);
|
|
1169
|
+
const [manualNotice, setManualNotice] = (0, import_react3.useState)(null);
|
|
1170
|
+
(0, import_react3.useEffect)(() => {
|
|
1171
|
+
setMounted(true);
|
|
1172
|
+
}, []);
|
|
1173
|
+
(0, import_react3.useEffect)(() => {
|
|
1174
|
+
setManualNotice(null);
|
|
1175
|
+
}, [network, isOpen]);
|
|
1176
|
+
const handleNetworkChange = async (targetNet) => {
|
|
1177
|
+
if (targetNet === network) {
|
|
1178
|
+
setManualNotice(null);
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
const res = await switchNetwork(targetNet);
|
|
1182
|
+
if (res?.requiresManualSwitch) {
|
|
1183
|
+
setManualNotice(
|
|
1184
|
+
`Wallet is currently active on ${network === "mainnet" ? "Mainnet" : "Testnet"}. Switch network inside your extension settings (Settings \u2192 Network) and Cicero will automatically update your balance.`
|
|
1185
|
+
);
|
|
1186
|
+
} else {
|
|
1187
|
+
setManualNotice(null);
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
(0, import_react3.useEffect)(() => {
|
|
1191
|
+
const handleKeyDown = (e) => {
|
|
1192
|
+
if (e.key === "Escape" && isOpen) {
|
|
1193
|
+
handleClose();
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
1197
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1198
|
+
}, [isOpen, handleClose]);
|
|
1199
|
+
if (!isOpen || !mounted) return null;
|
|
1200
|
+
const copyAddress = async () => {
|
|
1201
|
+
if (!address) return;
|
|
1202
|
+
try {
|
|
1203
|
+
await navigator.clipboard.writeText(address);
|
|
1204
|
+
setCopied(true);
|
|
1205
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
1206
|
+
} catch {
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
return (0, import_react_dom2.createPortal)(
|
|
1210
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "fixed inset-0 z-[99999] flex items-center justify-center p-4 sm:p-6 overflow-y-auto font-sans", children: [
|
|
1211
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1212
|
+
"div",
|
|
1213
|
+
{
|
|
1214
|
+
className: "fixed inset-0 bg-[#171717]/60 backdrop-blur-sm transition-opacity z-[99999]",
|
|
1215
|
+
onClick: handleClose
|
|
1216
|
+
}
|
|
1217
|
+
),
|
|
1218
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative w-full max-w-md bg-white rounded-xl border border-[#ededed] shadow-2xl overflow-hidden z-[100000] text-[#171717] animate-in fade-in zoom-in-95 duration-150", children: [
|
|
1219
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center justify-between px-6 py-4 border-b border-[#ededed] bg-[#fafafa]", children: [
|
|
1220
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1221
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-xl", children: wallet?.icon || "\u{1F6E1}\uFE0F" }),
|
|
1222
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
1223
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "font-semibold text-sm text-[#171717]", children: wallet?.name || "Zcash Wallet" }),
|
|
1224
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1.5 text-[11px] text-[#707070]", children: [
|
|
1225
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "w-1.5 h-1.5 rounded-full bg-[#24b47e]" }),
|
|
1226
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Connected" })
|
|
1227
|
+
] })
|
|
1228
|
+
] })
|
|
1229
|
+
] }),
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1231
|
+
"button",
|
|
1232
|
+
{
|
|
1233
|
+
onClick: handleClose,
|
|
1234
|
+
className: "p-1 rounded-md text-[#707070] hover:text-[#171717] hover:bg-[#ededed] transition-colors",
|
|
1235
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.X, { className: "w-4 h-4" })
|
|
1236
|
+
}
|
|
1237
|
+
)
|
|
1238
|
+
] }),
|
|
1239
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "p-6 space-y-5", children: [
|
|
1240
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "p-4 rounded-lg bg-[#fafafa] border border-[#ededed] text-center space-y-1", children: [
|
|
1241
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center justify-center gap-1.5 text-xs text-[#707070]", children: [
|
|
1242
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Shielded Balance" }),
|
|
1243
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1244
|
+
"button",
|
|
1245
|
+
{
|
|
1246
|
+
onClick: () => refetchBalance(),
|
|
1247
|
+
className: "hover:text-[#171717] p-0.5",
|
|
1248
|
+
title: "Refresh balance",
|
|
1249
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1250
|
+
import_lucide_react2.RefreshCw,
|
|
1251
|
+
{
|
|
1252
|
+
className: `w-3 h-3 ${balance.isLoading ? "animate-spin text-[#3ecf8e]" : ""}`
|
|
1253
|
+
}
|
|
1254
|
+
)
|
|
1255
|
+
}
|
|
1256
|
+
)
|
|
1257
|
+
] }),
|
|
1258
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-baseline justify-center gap-1.5", children: [
|
|
1259
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-3xl font-bold font-mono text-[#171717] tracking-tight", children: balance.zec }),
|
|
1260
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-sm font-medium text-[#707070]", children: "ZEC" })
|
|
1261
|
+
] }),
|
|
1262
|
+
balance.usd && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "text-xs text-[#707070] font-mono", children: [
|
|
1263
|
+
"\u2248 $",
|
|
1264
|
+
balance.usd,
|
|
1265
|
+
" USD"
|
|
1266
|
+
] })
|
|
1267
|
+
] }),
|
|
1268
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "space-y-2 text-xs", children: [
|
|
1269
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center justify-between text-[#707070]", children: [
|
|
1270
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Your Shielded Address" }),
|
|
1271
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1272
|
+
"button",
|
|
1273
|
+
{
|
|
1274
|
+
onClick: () => setShowQr(!showQr),
|
|
1275
|
+
className: "flex items-center gap-1 text-[#24b47e] hover:underline",
|
|
1276
|
+
children: [
|
|
1277
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.QrCode, { className: "w-3.5 h-3.5" }),
|
|
1278
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: showQr ? "Hide QR" : "Show QR" })
|
|
1279
|
+
]
|
|
1280
|
+
}
|
|
1281
|
+
)
|
|
1282
|
+
] }),
|
|
1283
|
+
address ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "p-3 bg-[#fafafa] rounded-md border border-[#ededed] font-mono text-xs text-[#171717] break-all select-all flex items-center justify-between gap-2", children: [
|
|
1284
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "truncate", children: truncateAddress(address, 16, 12) }),
|
|
1285
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1286
|
+
"button",
|
|
1287
|
+
{
|
|
1288
|
+
onClick: copyAddress,
|
|
1289
|
+
className: "p-1 rounded hover:bg-white text-[#707070] hover:text-[#171717] transition-colors flex-shrink-0",
|
|
1290
|
+
title: "Copy full address",
|
|
1291
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Check, { className: "w-3.5 h-3.5 text-[#24b47e]" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Copy, { className: "w-3.5 h-3.5" })
|
|
1292
|
+
}
|
|
1293
|
+
)
|
|
1294
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "p-3 bg-[#fafafa] rounded-md border border-[#ededed] text-xs text-[#707070]", children: "Connected in Read-Only Mode" }),
|
|
1295
|
+
showQr && address && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "pt-2 flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CiceroQRCode, { value: `zcash:${address}`, size: 160 }) }),
|
|
1296
|
+
address && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center justify-between text-[11px] pt-1", children: [
|
|
1297
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "flex items-center gap-1 text-[#707070]", children: [
|
|
1298
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Shield, { className: "w-3 h-3 text-[#3ecf8e]" }),
|
|
1299
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "zk-Shielded Address" })
|
|
1300
|
+
] }),
|
|
1301
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1302
|
+
"a",
|
|
1303
|
+
{
|
|
1304
|
+
href: network === "testnet" ? `https://blockexplorer.one/zcash/testnet/address/${address}` : `https://blockchair.com/zcash/address/${address}`,
|
|
1305
|
+
target: "_blank",
|
|
1306
|
+
rel: "noopener noreferrer",
|
|
1307
|
+
className: "flex items-center gap-1 text-[#24b47e] hover:underline",
|
|
1308
|
+
children: [
|
|
1309
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "View on Explorer" }),
|
|
1310
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.ExternalLink, { className: "w-3 h-3" })
|
|
1311
|
+
]
|
|
1312
|
+
}
|
|
1313
|
+
)
|
|
1314
|
+
] })
|
|
1315
|
+
] }),
|
|
1316
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "space-y-2", children: [
|
|
1317
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center justify-between p-3 rounded-lg border border-[#ededed] bg-white text-xs", children: [
|
|
1318
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1319
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.ArrowRightLeft, { className: "w-4 h-4 text-[#707070]" }),
|
|
1320
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-[#171717] font-medium", children: "Active Network" })
|
|
1321
|
+
] }),
|
|
1322
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1 p-0.5 rounded bg-[#fafafa] border border-[#dfdfdf]", children: [
|
|
1323
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1324
|
+
"button",
|
|
1325
|
+
{
|
|
1326
|
+
type: "button",
|
|
1327
|
+
onClick: () => handleNetworkChange("mainnet"),
|
|
1328
|
+
className: `px-2 py-1 rounded text-[11px] font-medium transition-colors ${network === "mainnet" ? "bg-white shadow-sm text-[#24b47e] font-semibold" : "text-[#707070] hover:text-[#171717]"}`,
|
|
1329
|
+
children: "Mainnet"
|
|
1330
|
+
}
|
|
1331
|
+
),
|
|
1332
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1333
|
+
"button",
|
|
1334
|
+
{
|
|
1335
|
+
type: "button",
|
|
1336
|
+
onClick: () => handleNetworkChange("testnet"),
|
|
1337
|
+
className: `px-2 py-1 rounded text-[11px] font-medium transition-colors ${network === "testnet" ? "bg-white shadow-sm text-amber-700 font-semibold" : "text-[#707070] hover:text-[#171717]"}`,
|
|
1338
|
+
children: "Testnet"
|
|
1339
|
+
}
|
|
1340
|
+
)
|
|
1341
|
+
] })
|
|
1342
|
+
] }),
|
|
1343
|
+
manualNotice && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "p-2.5 rounded-md bg-amber-50 border border-amber-200 text-amber-800 text-[11px] leading-relaxed animate-in fade-in", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: manualNotice }) })
|
|
1344
|
+
] })
|
|
1345
|
+
] }),
|
|
1346
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "px-6 py-3.5 bg-[#fafafa] border-t border-[#ededed] flex items-center justify-between", children: [
|
|
1347
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1348
|
+
"button",
|
|
1349
|
+
{
|
|
1350
|
+
onClick: disconnect,
|
|
1351
|
+
className: "flex items-center gap-1.5 text-xs text-rose-600 hover:text-rose-700 font-medium transition-colors",
|
|
1352
|
+
children: [
|
|
1353
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.LogOut, { className: "w-3.5 h-3.5" }),
|
|
1354
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Disconnect Wallet" })
|
|
1355
|
+
]
|
|
1356
|
+
}
|
|
1357
|
+
),
|
|
1358
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1359
|
+
"button",
|
|
1360
|
+
{
|
|
1361
|
+
onClick: handleClose,
|
|
1362
|
+
className: "px-3.5 py-1.5 rounded-md border border-[#dfdfdf] bg-white hover:bg-[#fafafa] text-xs font-medium text-[#171717] transition-colors",
|
|
1363
|
+
children: "Done"
|
|
1364
|
+
}
|
|
1365
|
+
)
|
|
1366
|
+
] })
|
|
1367
|
+
] })
|
|
1368
|
+
] }),
|
|
1369
|
+
document.body
|
|
1370
|
+
);
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
// src/context/CiceroContext.tsx
|
|
1374
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1375
|
+
var CiceroContext = (0, import_react4.createContext)(null);
|
|
1376
|
+
var CiceroProvider = ({
|
|
1377
|
+
children,
|
|
1378
|
+
initialNetwork = "mainnet",
|
|
1379
|
+
wallets = getDefaultWallets(),
|
|
1380
|
+
appName = "Zcash App",
|
|
1381
|
+
appLogo,
|
|
1382
|
+
autoConnect = true
|
|
1383
|
+
}) => {
|
|
1384
|
+
const [network, setNetwork] = (0, import_react4.useState)(initialNetwork);
|
|
1385
|
+
const [account, setAccount] = (0, import_react4.useState)({
|
|
1386
|
+
address: null,
|
|
1387
|
+
viewingKey: null,
|
|
1388
|
+
isConnected: false,
|
|
1389
|
+
isConnecting: false,
|
|
1390
|
+
status: "disconnected",
|
|
1391
|
+
wallet: null,
|
|
1392
|
+
error: null
|
|
1393
|
+
});
|
|
1394
|
+
const [balance, setBalance] = (0, import_react4.useState)({
|
|
1395
|
+
zec: 0,
|
|
1396
|
+
usd: null,
|
|
1397
|
+
isLoading: false
|
|
1398
|
+
});
|
|
1399
|
+
const [isConnectModalOpen, setIsConnectModalOpen] = (0, import_react4.useState)(false);
|
|
1400
|
+
const [isAccountModalOpen, setIsAccountModalOpen] = (0, import_react4.useState)(false);
|
|
1401
|
+
const { convertZecToUsd } = useZcashPrice(true);
|
|
1402
|
+
const convertZecToUsdRef = (0, import_react4.useRef)(convertZecToUsd);
|
|
1403
|
+
convertZecToUsdRef.current = convertZecToUsd;
|
|
1404
|
+
const walletsRef = (0, import_react4.useRef)(wallets);
|
|
1405
|
+
walletsRef.current = wallets;
|
|
1406
|
+
(0, import_react4.useEffect)(() => {
|
|
1407
|
+
if (typeof window === "undefined") return;
|
|
1408
|
+
const savedWalletId = localStorage.getItem("cicero_wallet_id");
|
|
1409
|
+
const savedAddress = localStorage.getItem("cicero_address");
|
|
1410
|
+
const savedNetwork = localStorage.getItem("cicero_network");
|
|
1411
|
+
if (savedNetwork) {
|
|
1412
|
+
setNetwork(savedNetwork);
|
|
1413
|
+
}
|
|
1414
|
+
if (autoConnect && savedWalletId) {
|
|
1415
|
+
const targetWallet = walletsRef.current.find((w) => w.id === savedWalletId);
|
|
1416
|
+
if (targetWallet && (savedAddress || targetWallet.isAvailable())) {
|
|
1417
|
+
const savedBal = localStorage.getItem("cicero_balance");
|
|
1418
|
+
const parsedBal = savedBal ? parseFloat(savedBal) : null;
|
|
1419
|
+
const activeZec = parsedBal !== null && !isNaN(parsedBal) ? parsedBal : 0;
|
|
1420
|
+
const initialUsd = convertZecToUsdRef.current(activeZec);
|
|
1421
|
+
setAccount({
|
|
1422
|
+
address: savedAddress || null,
|
|
1423
|
+
viewingKey: null,
|
|
1424
|
+
isConnected: true,
|
|
1425
|
+
isConnecting: false,
|
|
1426
|
+
status: "connected",
|
|
1427
|
+
wallet: targetWallet,
|
|
1428
|
+
error: null
|
|
1429
|
+
});
|
|
1430
|
+
setBalance({
|
|
1431
|
+
zec: activeZec,
|
|
1432
|
+
usd: initialUsd,
|
|
1433
|
+
isLoading: false
|
|
1434
|
+
});
|
|
1435
|
+
if (targetWallet.getBalance) {
|
|
1436
|
+
targetWallet.getBalance({ address: savedAddress || void 0, network }).then((freshBal) => {
|
|
1437
|
+
if (freshBal !== null && !isNaN(freshBal)) {
|
|
1438
|
+
setBalance({
|
|
1439
|
+
zec: freshBal,
|
|
1440
|
+
usd: convertZecToUsdRef.current(freshBal),
|
|
1441
|
+
isLoading: false
|
|
1442
|
+
});
|
|
1443
|
+
localStorage.setItem("cicero_balance", freshBal.toString());
|
|
1444
|
+
}
|
|
1445
|
+
}).catch(() => {
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
}, [autoConnect]);
|
|
1451
|
+
(0, import_react4.useEffect)(() => {
|
|
1452
|
+
if (typeof window === "undefined") return;
|
|
1453
|
+
const cleanupReady = ZucchiniWalletAdapter.onReady(() => {
|
|
1454
|
+
const savedWalletId = localStorage.getItem("cicero_wallet_id");
|
|
1455
|
+
const savedAddress = localStorage.getItem("cicero_address");
|
|
1456
|
+
if (savedWalletId === "zucchini" && autoConnect) {
|
|
1457
|
+
const zucchini = walletsRef.current.find((w) => w.id === "zucchini");
|
|
1458
|
+
if (zucchini) {
|
|
1459
|
+
setAccount((prev) => {
|
|
1460
|
+
if (prev.isConnected && prev.wallet?.id === "zucchini") return prev;
|
|
1461
|
+
return {
|
|
1462
|
+
address: savedAddress || null,
|
|
1463
|
+
viewingKey: null,
|
|
1464
|
+
isConnected: true,
|
|
1465
|
+
isConnecting: false,
|
|
1466
|
+
status: "connected",
|
|
1467
|
+
wallet: zucchini,
|
|
1468
|
+
error: null
|
|
1469
|
+
};
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
return () => {
|
|
1475
|
+
cleanupReady();
|
|
1476
|
+
};
|
|
1477
|
+
}, [autoConnect]);
|
|
1478
|
+
(0, import_react4.useEffect)(() => {
|
|
1479
|
+
if (typeof window === "undefined") return;
|
|
1480
|
+
const adapter2 = new ZucchiniWalletAdapter();
|
|
1481
|
+
const cleanup = adapter2.onNetworkChanged(async (detectedNet) => {
|
|
1482
|
+
setNetwork(detectedNet);
|
|
1483
|
+
localStorage.setItem("cicero_network", detectedNet);
|
|
1484
|
+
if (account.wallet?.id === "zucchini") {
|
|
1485
|
+
setBalance((prev) => ({ ...prev, isLoading: true }));
|
|
1486
|
+
try {
|
|
1487
|
+
const freshBal = await adapter2.getBalance({
|
|
1488
|
+
address: account.address || void 0,
|
|
1489
|
+
network: detectedNet
|
|
1490
|
+
});
|
|
1491
|
+
const activeZec = freshBal !== null && !isNaN(freshBal) ? freshBal : 0;
|
|
1492
|
+
setBalance({
|
|
1493
|
+
zec: activeZec,
|
|
1494
|
+
usd: convertZecToUsdRef.current(activeZec),
|
|
1495
|
+
isLoading: false
|
|
1496
|
+
});
|
|
1497
|
+
localStorage.setItem("cicero_balance", activeZec.toString());
|
|
1498
|
+
localStorage.setItem(`cicero_balance_${detectedNet}`, activeZec.toString());
|
|
1499
|
+
} catch {
|
|
1500
|
+
setBalance((prev) => ({ ...prev, isLoading: false }));
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
});
|
|
1504
|
+
return () => {
|
|
1505
|
+
cleanup();
|
|
1506
|
+
};
|
|
1507
|
+
}, [account.wallet?.id, account.address]);
|
|
1508
|
+
(0, import_react4.useEffect)(() => {
|
|
1509
|
+
if (account.isConnected) {
|
|
1510
|
+
setBalance((prev) => {
|
|
1511
|
+
const newUsd = convertZecToUsd(prev.zec);
|
|
1512
|
+
if (prev.usd === newUsd) return prev;
|
|
1513
|
+
return {
|
|
1514
|
+
...prev,
|
|
1515
|
+
usd: newUsd
|
|
1516
|
+
};
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
}, [account.isConnected, balance.zec, convertZecToUsd]);
|
|
1520
|
+
const switchNetwork = (0, import_react4.useCallback)(
|
|
1521
|
+
async (newNet) => {
|
|
1522
|
+
if (account.wallet?.switchNetwork) {
|
|
1523
|
+
try {
|
|
1524
|
+
const switchRes = await account.wallet.switchNetwork(newNet);
|
|
1525
|
+
if (switchRes && switchRes.requiresManualSwitch) {
|
|
1526
|
+
const currentNet = switchRes.currentNetwork || (account.wallet.getNetwork ? await account.wallet.getNetwork() : network);
|
|
1527
|
+
setNetwork(currentNet);
|
|
1528
|
+
if (typeof window !== "undefined") {
|
|
1529
|
+
localStorage.setItem("cicero_network", currentNet);
|
|
1530
|
+
}
|
|
1531
|
+
return {
|
|
1532
|
+
success: false,
|
|
1533
|
+
requiresManualSwitch: true,
|
|
1534
|
+
currentNetwork: currentNet
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
} catch {
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
setNetwork(newNet);
|
|
1541
|
+
if (typeof window !== "undefined") {
|
|
1542
|
+
localStorage.setItem("cicero_network", newNet);
|
|
1543
|
+
}
|
|
1544
|
+
if (account.wallet?.getBalance) {
|
|
1545
|
+
setBalance((prev) => ({ ...prev, isLoading: true }));
|
|
1546
|
+
try {
|
|
1547
|
+
const freshBal = await account.wallet.getBalance({
|
|
1548
|
+
address: account.address || void 0,
|
|
1549
|
+
network: newNet
|
|
1550
|
+
});
|
|
1551
|
+
const activeZec = freshBal !== null && !isNaN(freshBal) ? freshBal : 0;
|
|
1552
|
+
setBalance({
|
|
1553
|
+
zec: activeZec,
|
|
1554
|
+
usd: convertZecToUsdRef.current(activeZec),
|
|
1555
|
+
isLoading: false
|
|
1556
|
+
});
|
|
1557
|
+
if (typeof window !== "undefined" && freshBal !== null) {
|
|
1558
|
+
localStorage.setItem(`cicero_balance_${newNet}`, freshBal.toString());
|
|
1559
|
+
localStorage.setItem("cicero_balance", freshBal.toString());
|
|
1560
|
+
}
|
|
1561
|
+
} catch {
|
|
1562
|
+
setBalance((prev) => ({ ...prev, isLoading: false }));
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
return { success: true, currentNetwork: newNet };
|
|
1566
|
+
},
|
|
1567
|
+
[account.wallet, account.address, network]
|
|
1568
|
+
);
|
|
1569
|
+
const connect = (0, import_react4.useCallback)(
|
|
1570
|
+
async (walletId, customAddressOrKey) => {
|
|
1571
|
+
const targetWallet = wallets.find((w) => w.id === walletId);
|
|
1572
|
+
if (!targetWallet) {
|
|
1573
|
+
throw new Error(`Wallet ${walletId} not found in registered wallets`);
|
|
1574
|
+
}
|
|
1575
|
+
setAccount((prev) => ({
|
|
1576
|
+
...prev,
|
|
1577
|
+
isConnecting: true,
|
|
1578
|
+
status: "connecting",
|
|
1579
|
+
error: null
|
|
1580
|
+
}));
|
|
1581
|
+
try {
|
|
1582
|
+
let session;
|
|
1583
|
+
if (walletId === "viewing-key" && customAddressOrKey) {
|
|
1584
|
+
session = {
|
|
1585
|
+
address: customAddressOrKey,
|
|
1586
|
+
viewingKey: customAddressOrKey.startsWith("zx") || customAddressOrKey.startsWith("uview") ? customAddressOrKey : void 0,
|
|
1587
|
+
connected: true,
|
|
1588
|
+
network,
|
|
1589
|
+
walletId: "viewing-key"
|
|
1590
|
+
};
|
|
1591
|
+
} else {
|
|
1592
|
+
session = await targetWallet.connect({ network });
|
|
1593
|
+
}
|
|
1594
|
+
const resolvedAddress = session.address || customAddressOrKey || null;
|
|
1595
|
+
const walletNetwork = session.network || (targetWallet.getNetwork ? await targetWallet.getNetwork() : network);
|
|
1596
|
+
if (walletNetwork && walletNetwork !== network) {
|
|
1597
|
+
setNetwork(walletNetwork);
|
|
1598
|
+
if (typeof window !== "undefined") {
|
|
1599
|
+
localStorage.setItem("cicero_network", walletNetwork);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
setAccount({
|
|
1603
|
+
address: resolvedAddress,
|
|
1604
|
+
viewingKey: session.viewingKey || null,
|
|
1605
|
+
isConnected: true,
|
|
1606
|
+
isConnecting: false,
|
|
1607
|
+
status: "connected",
|
|
1608
|
+
wallet: targetWallet,
|
|
1609
|
+
error: null
|
|
1610
|
+
});
|
|
1611
|
+
let resolvedZec = session.balance ?? null;
|
|
1612
|
+
if (resolvedZec === null && targetWallet.getBalance) {
|
|
1613
|
+
try {
|
|
1614
|
+
resolvedZec = await targetWallet.getBalance({
|
|
1615
|
+
address: resolvedAddress || void 0,
|
|
1616
|
+
network
|
|
1617
|
+
});
|
|
1618
|
+
} catch {
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
if (resolvedZec === null && typeof window !== "undefined") {
|
|
1622
|
+
const cached = localStorage.getItem("cicero_balance");
|
|
1623
|
+
if (cached && !isNaN(parseFloat(cached))) {
|
|
1624
|
+
resolvedZec = parseFloat(cached);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
const activeZec = resolvedZec !== null && !isNaN(resolvedZec) ? resolvedZec : 0;
|
|
1628
|
+
setBalance({
|
|
1629
|
+
zec: activeZec,
|
|
1630
|
+
usd: convertZecToUsd(activeZec),
|
|
1631
|
+
isLoading: false
|
|
1632
|
+
});
|
|
1633
|
+
if (typeof window !== "undefined" && resolvedZec !== null) {
|
|
1634
|
+
localStorage.setItem("cicero_balance", resolvedZec.toString());
|
|
1635
|
+
}
|
|
1636
|
+
if (typeof window !== "undefined") {
|
|
1637
|
+
localStorage.setItem("cicero_wallet_id", walletId);
|
|
1638
|
+
if (resolvedAddress) {
|
|
1639
|
+
localStorage.setItem("cicero_address", resolvedAddress);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
setIsConnectModalOpen(false);
|
|
1643
|
+
} catch (err) {
|
|
1644
|
+
const msg = err instanceof Error ? err.message : "Connection failed";
|
|
1645
|
+
setAccount((prev) => ({
|
|
1646
|
+
...prev,
|
|
1647
|
+
isConnecting: false,
|
|
1648
|
+
status: "error",
|
|
1649
|
+
error: msg
|
|
1650
|
+
}));
|
|
1651
|
+
throw err;
|
|
1652
|
+
}
|
|
1653
|
+
},
|
|
1654
|
+
[wallets, network, convertZecToUsd]
|
|
1655
|
+
);
|
|
1656
|
+
const disconnect = (0, import_react4.useCallback)(async () => {
|
|
1657
|
+
if (account.wallet?.disconnect) {
|
|
1658
|
+
try {
|
|
1659
|
+
await account.wallet.disconnect();
|
|
1660
|
+
} catch {
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
setAccount({
|
|
1664
|
+
address: null,
|
|
1665
|
+
viewingKey: null,
|
|
1666
|
+
isConnected: false,
|
|
1667
|
+
isConnecting: false,
|
|
1668
|
+
status: "disconnected",
|
|
1669
|
+
wallet: null,
|
|
1670
|
+
error: null
|
|
1671
|
+
});
|
|
1672
|
+
setBalance({
|
|
1673
|
+
zec: 0,
|
|
1674
|
+
usd: null,
|
|
1675
|
+
isLoading: false
|
|
1676
|
+
});
|
|
1677
|
+
if (typeof window !== "undefined") {
|
|
1678
|
+
localStorage.removeItem("cicero_wallet_id");
|
|
1679
|
+
localStorage.removeItem("cicero_address");
|
|
1680
|
+
localStorage.removeItem("cicero_balance");
|
|
1681
|
+
}
|
|
1682
|
+
setIsAccountModalOpen(false);
|
|
1683
|
+
}, [account.wallet]);
|
|
1684
|
+
const sendPayment = (0, import_react4.useCallback)(
|
|
1685
|
+
async (params) => {
|
|
1686
|
+
if (!account.wallet) {
|
|
1687
|
+
throw new Error("No wallet connected. Please connect a Zcash wallet first.");
|
|
1688
|
+
}
|
|
1689
|
+
if (account.wallet.sendPayment) {
|
|
1690
|
+
return account.wallet.sendPayment(params);
|
|
1691
|
+
}
|
|
1692
|
+
throw new Error(`Wallet ${account.wallet.name} does not support programmatic send.`);
|
|
1693
|
+
},
|
|
1694
|
+
[account.wallet]
|
|
1695
|
+
);
|
|
1696
|
+
const refetchBalance = (0, import_react4.useCallback)(async () => {
|
|
1697
|
+
if (!account.wallet) return;
|
|
1698
|
+
setBalance((prev) => ({ ...prev, isLoading: true }));
|
|
1699
|
+
try {
|
|
1700
|
+
let freshZec = null;
|
|
1701
|
+
if (account.wallet.getBalance) {
|
|
1702
|
+
freshZec = await account.wallet.getBalance({
|
|
1703
|
+
address: account.address || void 0,
|
|
1704
|
+
network
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
if (freshZec !== null && !isNaN(freshZec)) {
|
|
1708
|
+
setBalance({
|
|
1709
|
+
zec: freshZec,
|
|
1710
|
+
usd: convertZecToUsd(freshZec),
|
|
1711
|
+
isLoading: false
|
|
1712
|
+
});
|
|
1713
|
+
if (typeof window !== "undefined") {
|
|
1714
|
+
localStorage.setItem("cicero_balance", freshZec.toString());
|
|
1715
|
+
}
|
|
1716
|
+
return;
|
|
1717
|
+
}
|
|
1718
|
+
} catch {
|
|
1719
|
+
}
|
|
1720
|
+
setBalance((prev) => ({
|
|
1721
|
+
...prev,
|
|
1722
|
+
isLoading: false,
|
|
1723
|
+
usd: convertZecToUsd(prev.zec)
|
|
1724
|
+
}));
|
|
1725
|
+
}, [account.wallet, account.address, network, convertZecToUsd]);
|
|
1726
|
+
const openConnectModal = (0, import_react4.useCallback)(() => setIsConnectModalOpen(true), []);
|
|
1727
|
+
const closeConnectModal = (0, import_react4.useCallback)(() => setIsConnectModalOpen(false), []);
|
|
1728
|
+
const openAccountModal = (0, import_react4.useCallback)(() => setIsAccountModalOpen(true), []);
|
|
1729
|
+
const closeAccountModal = (0, import_react4.useCallback)(() => setIsAccountModalOpen(false), []);
|
|
1730
|
+
const value = (0, import_react4.useMemo)(
|
|
1731
|
+
() => ({
|
|
1732
|
+
account,
|
|
1733
|
+
address: account.address,
|
|
1734
|
+
isConnected: account.isConnected,
|
|
1735
|
+
isConnecting: account.isConnecting,
|
|
1736
|
+
wallet: account.wallet,
|
|
1737
|
+
network,
|
|
1738
|
+
switchNetwork,
|
|
1739
|
+
balance,
|
|
1740
|
+
refetchBalance,
|
|
1741
|
+
connect,
|
|
1742
|
+
disconnect,
|
|
1743
|
+
sendPayment,
|
|
1744
|
+
isConnectModalOpen,
|
|
1745
|
+
openConnectModal,
|
|
1746
|
+
closeConnectModal,
|
|
1747
|
+
isAccountModalOpen,
|
|
1748
|
+
openAccountModal,
|
|
1749
|
+
closeAccountModal,
|
|
1750
|
+
wallets,
|
|
1751
|
+
appName,
|
|
1752
|
+
appLogo
|
|
1753
|
+
}),
|
|
1754
|
+
[
|
|
1755
|
+
account,
|
|
1756
|
+
network,
|
|
1757
|
+
switchNetwork,
|
|
1758
|
+
balance,
|
|
1759
|
+
refetchBalance,
|
|
1760
|
+
connect,
|
|
1761
|
+
disconnect,
|
|
1762
|
+
sendPayment,
|
|
1763
|
+
isConnectModalOpen,
|
|
1764
|
+
openConnectModal,
|
|
1765
|
+
closeConnectModal,
|
|
1766
|
+
isAccountModalOpen,
|
|
1767
|
+
openAccountModal,
|
|
1768
|
+
closeAccountModal,
|
|
1769
|
+
wallets,
|
|
1770
|
+
appName,
|
|
1771
|
+
appLogo
|
|
1772
|
+
]
|
|
1773
|
+
);
|
|
1774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(CiceroContext.Provider, { value, children: [
|
|
1775
|
+
children,
|
|
1776
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CiceroConnectModal, {}),
|
|
1777
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CiceroAccountModal, {})
|
|
1778
|
+
] });
|
|
1779
|
+
};
|
|
1780
|
+
function useCicero() {
|
|
1781
|
+
const ctx = (0, import_react4.useContext)(CiceroContext);
|
|
1782
|
+
if (!ctx) {
|
|
1783
|
+
throw new Error("useCicero must be used within a <CiceroProvider>");
|
|
1784
|
+
}
|
|
1785
|
+
return ctx;
|
|
1786
|
+
}
|
|
1787
|
+
var useAccount = () => {
|
|
1788
|
+
const { account, address, isConnected, isConnecting, wallet, disconnect } = useCicero();
|
|
1789
|
+
return { ...account, address, isConnected, isConnecting, wallet, disconnect };
|
|
1790
|
+
};
|
|
1791
|
+
var useBalance = () => {
|
|
1792
|
+
const { balance, refetchBalance } = useCicero();
|
|
1793
|
+
return { ...balance, refetch: refetchBalance };
|
|
1794
|
+
};
|
|
1795
|
+
var useConnectModal = () => {
|
|
1796
|
+
const { isConnectModalOpen, openConnectModal, closeConnectModal } = useCicero();
|
|
1797
|
+
return {
|
|
1798
|
+
isOpen: isConnectModalOpen,
|
|
1799
|
+
openConnectModal,
|
|
1800
|
+
closeConnectModal
|
|
1801
|
+
};
|
|
1802
|
+
};
|
|
1803
|
+
var useAccountModal = () => {
|
|
1804
|
+
const { isAccountModalOpen, openAccountModal, closeAccountModal } = useCicero();
|
|
1805
|
+
return {
|
|
1806
|
+
isOpen: isAccountModalOpen,
|
|
1807
|
+
openAccountModal,
|
|
1808
|
+
closeAccountModal
|
|
1809
|
+
};
|
|
1810
|
+
};
|
|
1811
|
+
|
|
1812
|
+
// src/components/CiceroConnectButton.tsx
|
|
1813
|
+
var import_lucide_react3 = require("lucide-react");
|
|
1814
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1815
|
+
var CiceroConnectButton = ({
|
|
1816
|
+
label = "Connect Zcash Wallet",
|
|
1817
|
+
variant = "primary",
|
|
1818
|
+
size = "md",
|
|
1819
|
+
showBalance = true,
|
|
1820
|
+
showNetwork = true,
|
|
1821
|
+
className = ""
|
|
1822
|
+
}) => {
|
|
1823
|
+
const {
|
|
1824
|
+
account,
|
|
1825
|
+
address,
|
|
1826
|
+
isConnected,
|
|
1827
|
+
isConnecting,
|
|
1828
|
+
network,
|
|
1829
|
+
balance,
|
|
1830
|
+
openConnectModal,
|
|
1831
|
+
openAccountModal
|
|
1832
|
+
} = useCicero();
|
|
1833
|
+
const sizeClasses = {
|
|
1834
|
+
sm: "text-xs px-2.5 py-1.5 gap-1.5",
|
|
1835
|
+
md: "text-sm px-3.5 py-2 gap-2",
|
|
1836
|
+
lg: "text-base px-4.5 py-2.5 gap-2.5"
|
|
1837
|
+
}[size];
|
|
1838
|
+
const variantClasses = {
|
|
1839
|
+
primary: "bg-[#3ecf8e] text-[#171717] hover:bg-[#24b47e] font-semibold shadow-sm",
|
|
1840
|
+
outline: "bg-white text-[#171717] border border-[#dfdfdf] hover:border-[#c7c7c7] hover:bg-[#fafafa] font-medium shadow-sm",
|
|
1841
|
+
dark: "bg-[#1c1c1c] text-white hover:bg-[#242424] font-medium shadow-sm"
|
|
1842
|
+
}[variant];
|
|
1843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: !isConnected ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1844
|
+
"button",
|
|
1845
|
+
{
|
|
1846
|
+
type: "button",
|
|
1847
|
+
onClick: openConnectModal,
|
|
1848
|
+
disabled: isConnecting,
|
|
1849
|
+
className: `inline-flex items-center justify-center rounded-[6px] transition-all select-none ${sizeClasses} ${variantClasses} ${className}`,
|
|
1850
|
+
children: [
|
|
1851
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1852
|
+
import_lucide_react3.Shield,
|
|
1853
|
+
{
|
|
1854
|
+
className: `flex-shrink-0 ${size === "sm" ? "w-3.5 h-3.5" : size === "lg" ? "w-5 h-5" : "w-4 h-4"} ${variant === "primary" ? "fill-[#171717]/20" : "text-[#3ecf8e]"}`
|
|
1855
|
+
}
|
|
1856
|
+
),
|
|
1857
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: isConnecting ? "Connecting..." : label })
|
|
1858
|
+
]
|
|
1859
|
+
}
|
|
1860
|
+
) : (
|
|
1861
|
+
/* Connected State Pill (RainbowKit style) */
|
|
1862
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `inline-flex items-center rounded-[6px] border border-[#dfdfdf] bg-white p-0.5 shadow-sm text-xs ${className}`, children: [
|
|
1863
|
+
showNetwork && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-1.5 px-2.5 py-1 text-[11px] font-medium text-[#707070] border-r border-[#ededed]", children: [
|
|
1864
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1865
|
+
"span",
|
|
1866
|
+
{
|
|
1867
|
+
className: `w-2 h-2 rounded-full ${network === "mainnet" ? "bg-[#3ecf8e]" : "bg-amber-400"}`
|
|
1868
|
+
}
|
|
1869
|
+
),
|
|
1870
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "capitalize", children: network })
|
|
1871
|
+
] }),
|
|
1872
|
+
showBalance && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "px-2.5 py-1 font-mono font-medium text-[#171717] border-r border-[#ededed]", children: [
|
|
1873
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: balance.zec }),
|
|
1874
|
+
" ",
|
|
1875
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[#707070] font-normal", children: "ZEC" })
|
|
1876
|
+
] }),
|
|
1877
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1878
|
+
"button",
|
|
1879
|
+
{
|
|
1880
|
+
type: "button",
|
|
1881
|
+
onClick: openAccountModal,
|
|
1882
|
+
className: "flex items-center gap-1.5 px-2.5 py-1 rounded-[4px] hover:bg-[#fafafa] text-[#171717] font-medium transition-colors",
|
|
1883
|
+
children: [
|
|
1884
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-sm", children: account.wallet?.icon || "\u{1F6E1}\uFE0F" }),
|
|
1885
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-mono text-[11px]", children: address ? truncateAddress(address, 6, 4) : "Connected" }),
|
|
1886
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.ChevronDown, { className: "w-3 h-3 text-[#707070]" })
|
|
1887
|
+
]
|
|
1888
|
+
}
|
|
1889
|
+
)
|
|
1890
|
+
] })
|
|
1891
|
+
) });
|
|
1892
|
+
};
|
|
1893
|
+
|
|
1894
|
+
// src/hooks/useZucchiniWallet.ts
|
|
1895
|
+
var import_react5 = require("react");
|
|
1896
|
+
function useZucchiniWallet(options = {}) {
|
|
1897
|
+
const { autoConnect = false } = options;
|
|
1898
|
+
const [adapter2] = (0, import_react5.useState)(() => new ZucchiniWalletAdapter());
|
|
1899
|
+
const [isAvailable, setIsAvailable] = (0, import_react5.useState)(false);
|
|
1900
|
+
const [connectionStatus, setConnectionStatus] = (0, import_react5.useState)("disconnected");
|
|
1901
|
+
const [paymentStatus, setPaymentStatus] = (0, import_react5.useState)("idle");
|
|
1902
|
+
const [session, setSession] = (0, import_react5.useState)(null);
|
|
1903
|
+
const [error, setError] = (0, import_react5.useState)(null);
|
|
1904
|
+
(0, import_react5.useEffect)(() => {
|
|
1905
|
+
const detected = ZucchiniWalletAdapter.isAvailable();
|
|
1906
|
+
setIsAvailable(detected);
|
|
1907
|
+
if (detected && autoConnect) {
|
|
1908
|
+
connect();
|
|
1909
|
+
}
|
|
1910
|
+
}, []);
|
|
1911
|
+
const connect = (0, import_react5.useCallback)(async () => {
|
|
1912
|
+
setConnectionStatus("connecting");
|
|
1913
|
+
setError(null);
|
|
1914
|
+
try {
|
|
1915
|
+
const sess = await adapter2.connect();
|
|
1916
|
+
setSession(sess);
|
|
1917
|
+
setConnectionStatus("connected");
|
|
1918
|
+
return sess;
|
|
1919
|
+
} catch (err) {
|
|
1920
|
+
const msg = err instanceof Error ? err.message : "Failed to connect to Zucchini Wallet";
|
|
1921
|
+
setError(msg);
|
|
1922
|
+
setConnectionStatus("error");
|
|
1923
|
+
throw err;
|
|
1924
|
+
}
|
|
1925
|
+
}, [adapter2]);
|
|
1926
|
+
const requestPayment = (0, import_react5.useCallback)(
|
|
1927
|
+
async (params) => {
|
|
1928
|
+
setPaymentStatus("requesting");
|
|
1929
|
+
setError(null);
|
|
1930
|
+
try {
|
|
1931
|
+
const result = await adapter2.requestPayment(params);
|
|
1932
|
+
setPaymentStatus("submitted");
|
|
1933
|
+
return result;
|
|
1934
|
+
} catch (err) {
|
|
1935
|
+
const msg = err instanceof Error ? err.message : "Payment request failed";
|
|
1936
|
+
setError(msg);
|
|
1937
|
+
setPaymentStatus("error");
|
|
1938
|
+
throw err;
|
|
1939
|
+
}
|
|
1940
|
+
},
|
|
1941
|
+
[adapter2]
|
|
1942
|
+
);
|
|
1943
|
+
const disconnect = (0, import_react5.useCallback)(async () => {
|
|
1944
|
+
await adapter2.disconnect();
|
|
1945
|
+
setSession(null);
|
|
1946
|
+
setConnectionStatus("disconnected");
|
|
1947
|
+
setPaymentStatus("idle");
|
|
1948
|
+
}, [adapter2]);
|
|
1949
|
+
return {
|
|
1950
|
+
/** Whether the Zucchini extension is installed in this browser */
|
|
1951
|
+
isAvailable,
|
|
1952
|
+
/** Current wallet connection lifecycle state */
|
|
1953
|
+
connectionStatus,
|
|
1954
|
+
/** Current payment request lifecycle state */
|
|
1955
|
+
paymentStatus,
|
|
1956
|
+
/** Active session info (address, etc.) */
|
|
1957
|
+
session,
|
|
1958
|
+
/** Last error message (if any) */
|
|
1959
|
+
error,
|
|
1960
|
+
/** Prompt the user to connect their Zucchini Wallet */
|
|
1961
|
+
connect,
|
|
1962
|
+
/** Send a ZIP-321 payment request for user review & approval */
|
|
1963
|
+
requestPayment,
|
|
1964
|
+
/** Disconnect the current session */
|
|
1965
|
+
disconnect
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1969
|
+
0 && (module.exports = {
|
|
1970
|
+
CiceroAccountModal,
|
|
1971
|
+
CiceroConnectButton,
|
|
1972
|
+
CiceroConnectModal,
|
|
1973
|
+
CiceroProvider,
|
|
1974
|
+
CiceroQRCode,
|
|
1975
|
+
ZucchiniWalletAdapter,
|
|
1976
|
+
burnerWallet,
|
|
1977
|
+
decodeBase64Url,
|
|
1978
|
+
encodeBase64Url,
|
|
1979
|
+
generateZip321Uri,
|
|
1980
|
+
getAddressType,
|
|
1981
|
+
getDefaultWallets,
|
|
1982
|
+
getWalletDeepLinks,
|
|
1983
|
+
isShieldedAddress,
|
|
1984
|
+
parseZip321Uri,
|
|
1985
|
+
truncateAddress,
|
|
1986
|
+
useAccount,
|
|
1987
|
+
useAccountModal,
|
|
1988
|
+
useBalance,
|
|
1989
|
+
useCicero,
|
|
1990
|
+
useConnectModal,
|
|
1991
|
+
useZcashPrice,
|
|
1992
|
+
useZucchiniWallet,
|
|
1993
|
+
validateMemoSupport,
|
|
1994
|
+
viewingKeyWallet,
|
|
1995
|
+
ywallet,
|
|
1996
|
+
zashiWallet,
|
|
1997
|
+
zucchiniWallet
|
|
1998
|
+
});
|
|
1999
|
+
//# sourceMappingURL=index.js.map
|