@oasisprotocol/privana-sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,20 +1,14 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
+ var chunkRDMJGMI3_cjs = require('./chunk-RDMJGMI3.cjs');
4
5
  var react = require('react');
5
- var viem = require('viem');
6
- var siwe = require('viem/siwe');
7
- var wagmi = require('wagmi');
8
- var actions = require('wagmi/actions');
9
- var jsxRuntime = require('react/jsx-runtime');
10
6
  var reactQuery = require('@tanstack/react-query');
11
- var clsx = require('clsx');
12
- var tailwindMerge = require('tailwind-merge');
13
- var actions$1 = require('viem/actions');
14
- var reactSlot = require('@radix-ui/react-slot');
15
- var classVarianceAuthority = require('class-variance-authority');
7
+ var wagmi = require('wagmi');
8
+ var viem = require('viem');
16
9
  var DialogPrimitive = require('@radix-ui/react-dialog');
17
10
  var lucideReact = require('lucide-react');
11
+ var jsxRuntime = require('react/jsx-runtime');
18
12
  var sonner = require('sonner');
19
13
 
20
14
  function _interopNamespace(e) {
@@ -37,565 +31,6 @@ function _interopNamespace(e) {
37
31
 
38
32
  var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
39
33
 
40
- // ../../shared/config.json
41
- var config_default = {
42
- chains: [
43
- {
44
- id: 84532,
45
- name: "Base Sepolia",
46
- explorerUrl: "https://sepolia.basescan.org"
47
- }
48
- ],
49
- networks: {
50
- testnet: {
51
- chainId: 23295,
52
- name: "Sapphire Testnet",
53
- accountingContract: "0xaF8e5de153A584528B57DD4B9B0195956BBDF571",
54
- apiUrl: "https://testnet.privana.finance"
55
- },
56
- mainnet: {
57
- chainId: 23294,
58
- name: "Sapphire Mainnet",
59
- accountingContract: "0x0000000000000000000000000000000000000000",
60
- apiUrl: ""
61
- }
62
- }
63
- };
64
-
65
- // src/sdk/types/common.ts
66
- var NETWORK_CONFIG = {
67
- testnet: {
68
- ...config_default.networks.testnet,
69
- accountingContract: config_default.networks.testnet.accountingContract
70
- },
71
- mainnet: {
72
- ...config_default.networks.mainnet,
73
- accountingContract: config_default.networks.mainnet.accountingContract
74
- }
75
- };
76
- function getChainId(network) {
77
- return NETWORK_CONFIG[network].chainId;
78
- }
79
- function getAccountingContract(network) {
80
- return NETWORK_CONFIG[network].accountingContract;
81
- }
82
- function getApiUrl(network) {
83
- return NETWORK_CONFIG[network].apiUrl;
84
- }
85
- function normalizeHex(value) {
86
- const normalized = value.trim().toLowerCase();
87
- return normalized.startsWith("0x") ? normalized : `0x${normalized}`;
88
- }
89
- function normalizeAddress(value) {
90
- return normalizeHex(value);
91
- }
92
-
93
- // src/sdk/types/chains.ts
94
- var SUPPORTED_CHAINS = config_default.chains.map((chain) => ({
95
- id: chain.id,
96
- name: chain.name,
97
- explorerUrl: chain.explorerUrl
98
- }));
99
- function getChainById(chainId) {
100
- return SUPPORTED_CHAINS.find((c) => c.id === chainId);
101
- }
102
- function getExplorerAddressUrl(chainId, address) {
103
- const chain = getChainById(chainId);
104
- if (!chain) return void 0;
105
- return `${chain.explorerUrl}/address/${address}#tokentxns`;
106
- }
107
-
108
- // src/sdk/auth/hosted-auth.ts
109
- var HOSTED_AUTH_CLOCK_SKEW_MS = 3e4;
110
- var PKCE_CHARSET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
111
- var DEFAULT_RANDOM_LENGTH = 64;
112
- var HOSTED_AUTH_CALLBACK_QUERY_KEYS = ["code", "error", "error_description", "state"];
113
- function randomString(length) {
114
- const values = new Uint8Array(length);
115
- crypto.getRandomValues(values);
116
- let output = "";
117
- for (const value of values) {
118
- output += PKCE_CHARSET[value % PKCE_CHARSET.length];
119
- }
120
- return output;
121
- }
122
- function toBase64Url(bytes) {
123
- let binary = "";
124
- bytes.forEach((byte) => {
125
- binary += String.fromCharCode(byte);
126
- });
127
- return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
128
- }
129
- function createPkceVerifier(length = DEFAULT_RANDOM_LENGTH) {
130
- return randomString(length);
131
- }
132
- async function createPkceChallenge(verifier) {
133
- const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier));
134
- return toBase64Url(new Uint8Array(digest));
135
- }
136
- function createHostedAuthState(length = DEFAULT_RANDOM_LENGTH) {
137
- return randomString(length);
138
- }
139
- function createHostedAuthStorageKey(apiUrl, config) {
140
- const normalizedApiUrl = apiUrl.replace(/\/$/, "");
141
- return [
142
- "privana",
143
- "hosted-auth",
144
- normalizedApiUrl,
145
- config.clientId.trim(),
146
- config.redirectUri.trim()
147
- ].join(":");
148
- }
149
- function createHostedAuthPendingStorageKey(apiUrl, config) {
150
- return `${createHostedAuthStorageKey(apiUrl, config)}:pending`;
151
- }
152
- function persistHostedAuthPendingTransaction(storage, key, transaction) {
153
- storage.setItem(key, JSON.stringify(transaction));
154
- }
155
- function readHostedAuthPendingTransaction(storage, key) {
156
- const raw = storage.getItem(key);
157
- if (!raw) return null;
158
- try {
159
- const parsed = JSON.parse(raw);
160
- if (typeof parsed.codeVerifier !== "string" || typeof parsed.state !== "string") {
161
- return null;
162
- }
163
- return {
164
- codeVerifier: parsed.codeVerifier,
165
- state: parsed.state
166
- };
167
- } catch {
168
- return null;
169
- }
170
- }
171
- function clearHostedAuthPendingTransaction(storage, key) {
172
- storage.removeItem(key);
173
- }
174
- function parseHostedAuthCallback(url, redirectUri) {
175
- const expectedUrl = new URL(redirectUri);
176
- if (url.origin !== expectedUrl.origin || url.pathname !== expectedUrl.pathname) {
177
- return null;
178
- }
179
- const code = url.searchParams.get("code");
180
- if (code) {
181
- return {
182
- code,
183
- state: url.searchParams.get("state")
184
- };
185
- }
186
- const error = url.searchParams.get("error");
187
- if (error) {
188
- return {
189
- error,
190
- errorDescription: url.searchParams.get("error_description") ?? void 0,
191
- state: url.searchParams.get("state")
192
- };
193
- }
194
- return null;
195
- }
196
- function stripHostedAuthCallbackParams(url) {
197
- const nextUrl = new URL(url.toString());
198
- HOSTED_AUTH_CALLBACK_QUERY_KEYS.forEach((key) => {
199
- nextUrl.searchParams.delete(key);
200
- });
201
- return `${nextUrl.pathname}${nextUrl.search}${nextUrl.hash}`;
202
- }
203
- function buildHostedAuthSession(response, config, now = Date.now()) {
204
- return {
205
- accessToken: response.access_token,
206
- refreshToken: response.refresh_token,
207
- idToken: response.id_token,
208
- tokenType: response.token_type,
209
- address: response.address,
210
- clientId: config.clientId,
211
- redirectUri: config.redirectUri,
212
- expiresAt: now + response.expires_in * 1e3,
213
- refreshExpiresAt: now + response.refresh_expires_in * 1e3
214
- };
215
- }
216
- function applyRefreshResponse(session, response, now = Date.now()) {
217
- return {
218
- ...session,
219
- accessToken: response.token,
220
- refreshToken: response.refresh_token,
221
- expiresAt: now + response.expires_in * 1e3,
222
- refreshExpiresAt: now + response.refresh_expires_in * 1e3
223
- };
224
- }
225
- function isHostedAuthSessionActive(session, now = Date.now(), skewMs = HOSTED_AUTH_CLOCK_SKEW_MS) {
226
- return session.expiresAt > now + skewMs;
227
- }
228
- function isHostedAuthRefreshActive(session, now = Date.now(), skewMs = HOSTED_AUTH_CLOCK_SKEW_MS) {
229
- return session.refreshExpiresAt > now + skewMs;
230
- }
231
-
232
- // src/sdk/client/errors.ts
233
- var AccountingApiError = class _AccountingApiError extends Error {
234
- constructor(message, statusCode, detail) {
235
- super(message);
236
- this.statusCode = statusCode;
237
- this.detail = detail;
238
- this.name = "AccountingApiError";
239
- Object.setPrototypeOf(this, _AccountingApiError.prototype);
240
- }
241
- };
242
- var NetworkError = class _NetworkError extends Error {
243
- constructor(message, cause) {
244
- super(message);
245
- this.cause = cause;
246
- this.name = "NetworkError";
247
- Object.setPrototypeOf(this, _NetworkError.prototype);
248
- }
249
- };
250
- var ValidationError = class _ValidationError extends Error {
251
- constructor(message, field) {
252
- super(message);
253
- this.field = field;
254
- this.name = "ValidationError";
255
- Object.setPrototypeOf(this, _ValidationError.prototype);
256
- }
257
- };
258
- var HostedAuthError = class _HostedAuthError extends Error {
259
- constructor(message) {
260
- super(message);
261
- this.name = "HostedAuthError";
262
- Object.setPrototypeOf(this, _HostedAuthError.prototype);
263
- }
264
- };
265
- var HostedAuthRequiredError = class _HostedAuthRequiredError extends HostedAuthError {
266
- constructor(message = "Hosted redirect authentication is required. Start login with useHostedRedirectAuth().") {
267
- super(message);
268
- this.name = "HostedAuthRequiredError";
269
- Object.setPrototypeOf(this, _HostedAuthRequiredError.prototype);
270
- }
271
- };
272
- var HostedAuthStateMismatchError = class _HostedAuthStateMismatchError extends HostedAuthError {
273
- constructor(message = "Hosted authentication returned an invalid state value.") {
274
- super(message);
275
- this.name = "HostedAuthStateMismatchError";
276
- Object.setPrototypeOf(this, _HostedAuthStateMismatchError.prototype);
277
- }
278
- };
279
-
280
- // src/sdk/client/http-client.ts
281
- var HttpClient = class {
282
- constructor(config) {
283
- this.baseUrl = config.baseUrl.replace(/\/$/, "");
284
- this.timeout = config.timeout ?? 3e4;
285
- this.headers = {
286
- "Content-Type": "application/json",
287
- ...config.headers
288
- };
289
- }
290
- async get(path) {
291
- return this.request("GET", path);
292
- }
293
- async post(path, body) {
294
- return this.request("POST", path, body);
295
- }
296
- getBaseUrl() {
297
- return this.baseUrl;
298
- }
299
- setHeader(name, value) {
300
- this.headers[name] = value;
301
- }
302
- removeHeader(name) {
303
- delete this.headers[name];
304
- }
305
- getHeader(name) {
306
- return this.headers[name];
307
- }
308
- async request(method, path, body) {
309
- const url = `${this.baseUrl}${path}`;
310
- const controller = new AbortController();
311
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
312
- try {
313
- const response = await fetch(url, {
314
- method,
315
- headers: this.headers,
316
- body: body ? JSON.stringify(body) : void 0,
317
- signal: controller.signal
318
- });
319
- clearTimeout(timeoutId);
320
- if (!response.ok) {
321
- let detail;
322
- try {
323
- const errorBody = await response.json();
324
- detail = errorBody.detail || errorBody.error_description || errorBody.message;
325
- } catch {
326
- detail = await response.text().catch(() => void 0);
327
- }
328
- throw new AccountingApiError(
329
- `API request failed: ${response.status} ${response.statusText}`,
330
- response.status,
331
- detail
332
- );
333
- }
334
- return response.json();
335
- } catch (error) {
336
- clearTimeout(timeoutId);
337
- if (error instanceof AccountingApiError) {
338
- throw error;
339
- }
340
- if (error instanceof Error) {
341
- if (error.name === "AbortError") {
342
- throw new NetworkError(`Request timeout after ${this.timeout}ms`);
343
- }
344
- throw new NetworkError(`Network request failed: ${error.message}`, error);
345
- }
346
- throw new NetworkError("Unknown network error occurred");
347
- }
348
- }
349
- };
350
-
351
- // src/sdk/client/privana-client.ts
352
- var PRIVATE_READ_TOKEN_HEADER = "X-SIWE-Token";
353
- var MAX_BATCH_BALANCE_TOKEN_IDS = 100;
354
- var MAX_HISTORY_PAGE_SIZE = 100;
355
- var PrivanaClient = class {
356
- constructor(config) {
357
- this.http = new HttpClient(config);
358
- }
359
- getBaseUrl() {
360
- return this.http.getBaseUrl();
361
- }
362
- async getDepositAddress(request = {}) {
363
- return this.http.post("/v1/accounting/deposits/address", {
364
- chain_type: request.chain_type ?? "evm",
365
- version: request.version ?? 0
366
- });
367
- }
368
- async checkDeposit(request) {
369
- return this.http.post("/v1/accounting/deposits/check", {
370
- chain_type: request.chain_type ?? "evm",
371
- chain_id: request.chain_id,
372
- tx_hash: normalizeHex(request.tx_hash),
373
- amount: String(request.amount),
374
- log_index: request.log_index ?? 0,
375
- version: request.version ?? 0
376
- });
377
- }
378
- async getDepositStatus(depositId) {
379
- return this.http.get(`/v1/accounting/deposits/status/${depositId}`);
380
- }
381
- async getBalance(tokenId) {
382
- const token = normalizeHex(tokenId);
383
- return this.http.get(`/v1/accounting/balances/${token}`);
384
- }
385
- async getBatchBalances(request) {
386
- if (request.token_ids.length > MAX_BATCH_BALANCE_TOKEN_IDS) {
387
- throw new Error(
388
- `Batch balance requests support at most ${MAX_BATCH_BALANCE_TOKEN_IDS} token IDs`
389
- );
390
- }
391
- return this.http.post("/v1/accounting/balances/batch", {
392
- token_ids: request.token_ids.map((id) => normalizeHex(id))
393
- });
394
- }
395
- async getHistory(request = {}) {
396
- const offset = request.offset ?? -1;
397
- const limit = request.limit ?? 50;
398
- if (!Number.isSafeInteger(offset)) {
399
- throw new Error("History offset must be an integer");
400
- }
401
- if (!Number.isSafeInteger(limit)) {
402
- throw new Error("History limit must be an integer");
403
- }
404
- if (limit < 0 || limit > MAX_HISTORY_PAGE_SIZE) {
405
- throw new Error(`History requests support between 0 and ${MAX_HISTORY_PAGE_SIZE} entries`);
406
- }
407
- const params = new URLSearchParams({
408
- offset: String(offset),
409
- limit: String(limit)
410
- });
411
- return this.http.get(`/v1/accounting/history?${params.toString()}`);
412
- }
413
- async listTokens() {
414
- return this.http.get("/v1/accounting/tokens");
415
- }
416
- async getTokenInfo(tokenId) {
417
- const token = normalizeHex(tokenId);
418
- return this.http.get(`/v1/accounting/tokens/${token}`);
419
- }
420
- async lockFunds(request) {
421
- return this.http.post("/v1/accounting/funds/lock", {
422
- service_address: normalizeAddress(request.service_address),
423
- token_id: normalizeHex(request.token_id),
424
- amount: String(request.amount),
425
- expiry: String(request.expiry),
426
- nonce: String(request.nonce),
427
- signature: normalizeHex(request.signature)
428
- });
429
- }
430
- async modifyLock(request) {
431
- return this.http.post("/v1/accounting/funds/modify-lock", {
432
- lock_id: request.lock_id,
433
- amount: String(request.amount),
434
- new_expiry: String(request.new_expiry),
435
- nonce: String(request.nonce),
436
- signature: normalizeHex(request.signature)
437
- });
438
- }
439
- async unlockFunds(request) {
440
- return this.http.post("/v1/accounting/funds/unlock", {
441
- user_address: normalizeAddress(request.user_address),
442
- lock_id: request.lock_id
443
- });
444
- }
445
- async unlockAllExpired(request) {
446
- return this.http.post(
447
- "/v1/accounting/funds/unlock-all-expired",
448
- {
449
- user_address: normalizeAddress(request.user_address)
450
- }
451
- );
452
- }
453
- async getLockedFunds(serviceAddress) {
454
- const queryParams = serviceAddress ? `?service_address=${normalizeAddress(serviceAddress)}` : "";
455
- return this.http.get(`/v1/accounting/funds/locked${queryParams}`);
456
- }
457
- async getTotalLockedBalance(tokenId) {
458
- const token = normalizeHex(tokenId);
459
- return this.http.get(`/v1/accounting/funds/locked/total/${token}`);
460
- }
461
- async getExpiredLocks() {
462
- return this.http.get("/v1/accounting/funds/expired");
463
- }
464
- async transferFunds(request) {
465
- return this.http.post("/v1/accounting/funds/transfer", {
466
- to_address: normalizeAddress(request.to_address),
467
- token_id: normalizeHex(request.token_id),
468
- amount: String(request.amount),
469
- nonce: String(request.nonce),
470
- signature: normalizeHex(request.signature)
471
- });
472
- }
473
- async getTransferNonce(userAddress) {
474
- const user = normalizeAddress(userAddress);
475
- return this.http.get(`/v1/accounting/funds/transfer/nonce/${user}`);
476
- }
477
- async getLockNonce(userAddress) {
478
- const user = normalizeAddress(userAddress);
479
- return this.http.get(`/v1/accounting/funds/lock/nonce/${user}`);
480
- }
481
- async getModifyLockNonce(userAddress) {
482
- const user = normalizeAddress(userAddress);
483
- return this.http.get(`/v1/accounting/funds/modify-lock/nonce/${user}`);
484
- }
485
- async transferLockedFunds(request) {
486
- return this.http.post("/v1/accounting/funds/transfer-locked", {
487
- user_address: normalizeAddress(request.user_address),
488
- lock_id: request.lock_id,
489
- to_address: normalizeAddress(request.to_address),
490
- amount: String(request.amount),
491
- service_address: normalizeAddress(request.service_address),
492
- nonce: String(request.nonce),
493
- signature: normalizeHex(request.signature)
494
- });
495
- }
496
- async withdrawFromLock(request) {
497
- return this.http.post(
498
- "/v1/accounting/funds/withdraw-from-lock",
499
- {
500
- to_address: normalizeAddress(request.to_address),
501
- lock_id: request.lock_id,
502
- amount: String(request.amount),
503
- nonce: String(request.nonce),
504
- signature: normalizeHex(request.signature)
505
- }
506
- );
507
- }
508
- async requestWithdrawal(request) {
509
- return this.http.post("/v1/accounting/withdraw", {
510
- token_id: normalizeHex(request.token_id),
511
- amount: String(request.amount),
512
- nonce: String(request.nonce),
513
- signature: normalizeHex(request.signature)
514
- });
515
- }
516
- async getWithdrawalNonce(userAddress) {
517
- const user = normalizeAddress(userAddress);
518
- return this.http.get(`/v1/accounting/withdraw/nonce/${user}`);
519
- }
520
- async getTransferLockedNonce(serviceAddress) {
521
- const service = normalizeAddress(serviceAddress);
522
- return this.http.get(
523
- `/v1/accounting/funds/transfer-locked/nonce/${service}`
524
- );
525
- }
526
- async getPendingWithdrawals(userAddress) {
527
- const user = normalizeAddress(userAddress);
528
- return this.http.get(`/v1/accounting/withdraw/pending/${user}`);
529
- }
530
- async getWithdrawalInfo(index) {
531
- return this.http.get(`/v1/accounting/withdraw/${index}`);
532
- }
533
- async getSiweDomain() {
534
- return this.http.get("/v1/accounting/auth/domain");
535
- }
536
- async getSiweNonce(userAddress) {
537
- const user = normalizeAddress(userAddress);
538
- return this.http.get(`/v1/accounting/auth/nonce?address=${user}`);
539
- }
540
- async loginWithSiwe(request) {
541
- return this.http.post("/v1/accounting/auth/login", {
542
- siwe_message: request.siwe_message,
543
- signature: normalizeHex(request.signature)
544
- });
545
- }
546
- getHostedAuthAuthorizeUrl(request) {
547
- const url = new URL(
548
- "v1/accounting/auth/authorize",
549
- `${this.http.getBaseUrl().replace(/\/$/, "")}/`
550
- );
551
- url.searchParams.set("client_id", request.client_id);
552
- url.searchParams.set("redirect_uri", request.redirect_uri);
553
- url.searchParams.set("code_challenge", request.code_challenge);
554
- url.searchParams.set("state", request.state);
555
- url.searchParams.set("chain_id", String(request.chain_id));
556
- url.searchParams.set("response_mode", request.response_mode ?? "redirect");
557
- url.searchParams.set("code_challenge_method", request.code_challenge_method ?? "S256");
558
- return url.toString();
559
- }
560
- async exchangeHostedAuthCode(request) {
561
- return this.http.post("/v1/accounting/auth/token", {
562
- grant_type: request.grant_type ?? "authorization_code",
563
- code: request.code,
564
- code_verifier: request.code_verifier,
565
- client_id: request.client_id,
566
- redirect_uri: request.redirect_uri
567
- });
568
- }
569
- async refreshJwtSession(request) {
570
- return this.http.post("/v1/accounting/auth/jwt/refresh", {
571
- refresh_token: request.refresh_token
572
- });
573
- }
574
- async logoutJwtSession(request = {}) {
575
- return this.http.post("/v1/accounting/auth/jwt/logout", {
576
- refresh_token: request.refresh_token,
577
- revoke_all: request.revoke_all ?? false
578
- });
579
- }
580
- setPrivateReadToken(token) {
581
- this.http.removeHeader("Authorization");
582
- this.http.setHeader(PRIVATE_READ_TOKEN_HEADER, token);
583
- }
584
- getPrivateReadToken() {
585
- return this.http.getHeader(PRIVATE_READ_TOKEN_HEADER);
586
- }
587
- clearPrivateReadToken() {
588
- this.http.removeHeader(PRIVATE_READ_TOKEN_HEADER);
589
- }
590
- setBearerToken(token) {
591
- this.http.removeHeader(PRIVATE_READ_TOKEN_HEADER);
592
- this.http.setHeader("Authorization", `Bearer ${token}`);
593
- }
594
- clearBearerToken() {
595
- this.http.removeHeader("Authorization");
596
- }
597
- };
598
-
599
34
  // src/sdk/signatures/eip712-types.ts
600
35
  function createDomain(chainId, verifyingContract) {
601
36
  return {
@@ -791,553 +226,21 @@ async function signWithdrawFromLockMessage({
791
226
  });
792
227
  return signature;
793
228
  }
794
- var defaultResult = {
795
- address: void 0,
796
- isConnected: false,
797
- status: "disconnected"
798
- };
799
- function useSafeAccount() {
800
- const context = react.useContext(wagmi.WagmiContext);
801
- const cacheRef = react.useRef(defaultResult);
802
- const subscribe = react.useCallback(
803
- (onChange) => {
804
- if (!context) return () => {
805
- };
806
- return actions.watchAccount(context, { onChange });
807
- },
808
- [context]
809
- );
810
- const getSnapshot = react.useCallback(() => {
811
- if (!context) return defaultResult;
812
- const account = actions.getAccount(context);
813
- if (cacheRef.current.address !== account.address || cacheRef.current.isConnected !== account.isConnected || cacheRef.current.status !== account.status) {
814
- cacheRef.current = {
815
- address: account.address,
816
- isConnected: account.isConnected,
817
- status: account.status
818
- };
819
- }
820
- return cacheRef.current;
821
- }, [context]);
822
- const getServerSnapshot = react.useCallback(() => defaultResult, []);
823
- return react.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
824
- }
825
-
826
- // src/sdk/hooks/private-read-token-store.ts
827
- var AUTH_CLOCK_SKEW_MS = 3e4;
828
- var cache = /* @__PURE__ */ new Map();
829
- function createScopeKey(apiUrl, chainId, address) {
830
- return `${apiUrl.replace(/\/$/, "")}:${chainId}:${address.toLowerCase()}`;
831
- }
832
- function getCachedPrivateReadToken(scopeKey) {
833
- const cached = cache.get(scopeKey);
834
- if (!cached) return null;
835
- if (cached.expiresAt <= Date.now() + AUTH_CLOCK_SKEW_MS) {
836
- cache.delete(scopeKey);
837
- return null;
838
- }
839
- return cached.token;
840
- }
841
- function setCachedPrivateReadToken(scopeKey, token, expiresAt) {
842
- cache.set(scopeKey, { token, expiresAt });
843
- }
844
- function deleteCachedPrivateReadToken(scopeKey) {
845
- cache.delete(scopeKey);
846
- }
847
- var DEFAULT_SIWE_VALIDITY_MS = 24 * 60 * 60 * 1e3;
848
- var DEFAULT_STATEMENT = "Sign in to access your private account data.";
849
- var AUTH_REFRESH_SKEW_MS = 3e4;
850
- var SiweAuthContext = react.createContext(null);
851
- function SiweAuthProvider({
852
- children,
853
- client,
854
- networkConfig,
855
- autoLogin = true,
856
- statement
857
- }) {
858
- const wagmiContext = react.useContext(wagmi.WagmiContext);
859
- const { address, isConnected, status } = useSafeAccount();
860
- const [session, setSession] = react.useState(null);
861
- const [tokens, setTokens] = react.useState(null);
862
- const [isLoading, setIsLoading] = react.useState(false);
863
- const [error, setError] = react.useState(null);
864
- const [accessTokenExpiresAt, setAccessTokenExpiresAt] = react.useState(null);
865
- const loginInFlight = react.useRef(false);
866
- const autoAttemptedAddress = react.useRef(null);
867
- const refreshInFlight = react.useRef(false);
868
- const refreshDataRef = react.useRef(null);
869
- const clearSession = react.useCallback(() => {
870
- refreshDataRef.current = null;
871
- setAccessTokenExpiresAt(null);
872
- client.clearPrivateReadToken();
873
- client.clearBearerToken();
874
- setSession(null);
875
- setTokens(null);
876
- setError(null);
877
- autoAttemptedAddress.current = null;
878
- }, [client]);
879
- const logout = react.useCallback(async () => {
880
- setError(null);
881
- const refreshToken = refreshDataRef.current?.refreshToken;
882
- try {
883
- if (refreshToken) {
884
- await client.logoutJwtSession({ refresh_token: refreshToken });
885
- }
886
- } finally {
887
- clearSession();
888
- autoAttemptedAddress.current = address ?? null;
889
- }
890
- }, [clearSession, client, address]);
891
- const login = react.useCallback(async () => {
892
- if (!wagmiContext) throw new Error("WagmiProvider is required for SIWE auth");
893
- if (!address) throw new Error("No wallet connected");
894
- if (loginInFlight.current) return;
895
- loginInFlight.current = true;
896
- setIsLoading(true);
897
- setError(null);
898
- try {
899
- const walletClient = await actions.getWalletClient(wagmiContext);
900
- if (!walletClient) throw new Error("No wallet client available");
901
- const [{ domain }, nonceRes] = await Promise.all([
902
- client.getSiweDomain(),
903
- client.getSiweNonce(address)
904
- ]);
905
- const issuedAt = /* @__PURE__ */ new Date();
906
- const expirationTime = new Date(issuedAt.getTime() + DEFAULT_SIWE_VALIDITY_MS);
907
- const uri = typeof window !== "undefined" && window.location.origin ? window.location.origin : networkConfig.apiUrl;
908
- const message = siwe.createSiweMessage({
909
- address,
910
- chainId: networkConfig.chainId,
911
- domain,
912
- uri,
913
- version: "1",
914
- nonce: nonceRes.nonce,
915
- statement: statement ?? DEFAULT_STATEMENT,
916
- issuedAt,
917
- expirationTime
918
- });
919
- const signature = await walletClient.signMessage({
920
- account: walletClient.account ?? address,
921
- message
922
- });
923
- const res = await client.loginWithSiwe({ siwe_message: message, signature });
924
- const loggedInAt = Date.now();
925
- client.setPrivateReadToken(res.siwe_token);
926
- client.setBearerToken(res.jwt_access_token);
927
- refreshDataRef.current = {
928
- refreshToken: res.jwt_refresh_token,
929
- refreshExpiresAt: loggedInAt + res.jwt_refresh_expires_in * 1e3
930
- };
931
- setCachedPrivateReadToken(
932
- createScopeKey(networkConfig.apiUrl, networkConfig.chainId, address),
933
- res.siwe_token,
934
- expirationTime.getTime()
935
- );
936
- setSession({ address: res.address });
937
- setTokens({
938
- siwe_token: res.siwe_token,
939
- jwt_access_token: res.jwt_access_token,
940
- jwt_refresh_token: res.jwt_refresh_token,
941
- address: res.address
942
- });
943
- setAccessTokenExpiresAt(loggedInAt + res.jwt_expires_in * 1e3);
944
- } catch (err) {
945
- setError(err instanceof Error ? err : new Error("Sign-in failed"));
946
- throw err;
947
- } finally {
948
- setIsLoading(false);
949
- loginInFlight.current = false;
950
- }
951
- }, [wagmiContext, address, client, networkConfig.chainId, networkConfig.apiUrl, statement]);
952
- const refreshAccessToken = react.useCallback(async () => {
953
- const data = refreshDataRef.current;
954
- if (!data || refreshInFlight.current) return;
955
- if (Date.now() >= data.refreshExpiresAt - AUTH_REFRESH_SKEW_MS) {
956
- clearSession();
957
- return;
958
- }
959
- refreshInFlight.current = true;
960
- try {
961
- const res = await client.refreshJwtSession({ refresh_token: data.refreshToken });
962
- const refreshedAt = Date.now();
963
- client.setBearerToken(res.token);
964
- refreshDataRef.current = {
965
- refreshToken: res.refresh_token,
966
- refreshExpiresAt: refreshedAt + res.refresh_expires_in * 1e3
967
- };
968
- setTokens(
969
- (prev) => prev ? { ...prev, jwt_access_token: res.token, jwt_refresh_token: res.refresh_token } : prev
970
- );
971
- setAccessTokenExpiresAt(refreshedAt + res.expires_in * 1e3);
972
- } catch {
973
- clearSession();
974
- } finally {
975
- refreshInFlight.current = false;
976
- }
977
- }, [client, clearSession]);
978
- react.useEffect(() => {
979
- if (accessTokenExpiresAt == null) return;
980
- const delay = Math.max(accessTokenExpiresAt - AUTH_REFRESH_SKEW_MS - Date.now(), 0);
981
- const timer = setTimeout(() => {
982
- void refreshAccessToken();
983
- }, delay);
984
- return () => clearTimeout(timer);
985
- }, [accessTokenExpiresAt, refreshAccessToken]);
986
- react.useEffect(() => {
987
- if (!autoLogin) return;
988
- if (status === "connecting" || status === "reconnecting") return;
989
- if (!isConnected && session) {
990
- clearSession();
991
- return;
992
- }
993
- if (isConnected && address && session && address.toLowerCase() !== session.address.toLowerCase()) {
994
- clearSession();
995
- return;
996
- }
997
- if (isConnected && address && !session && !isLoading && autoAttemptedAddress.current !== address) {
998
- autoAttemptedAddress.current = address;
999
- void login().catch(() => {
1000
- });
1001
- }
1002
- }, [autoLogin, status, isConnected, address, session, isLoading, login, clearSession]);
1003
- const value = react.useMemo(
1004
- () => ({
1005
- isAuthenticated: !!session,
1006
- isLoading,
1007
- error,
1008
- session,
1009
- accessToken: tokens?.jwt_access_token,
1010
- tokens,
1011
- login,
1012
- logout
1013
- }),
1014
- [session, isLoading, error, tokens, login, logout]
1015
- );
1016
- return /* @__PURE__ */ jsxRuntime.jsx(SiweAuthContext.Provider, { value, children });
1017
- }
1018
- function useSiweAuth() {
1019
- const ctx = react.useContext(SiweAuthContext);
1020
- if (!ctx) throw new Error("useSiweAuth must be used within SiweAuthProvider");
1021
- return ctx;
1022
- }
1023
- var PrivanaContext = react.createContext(null);
1024
- function readStoredHostedAuthSession(storage, hostedAuthStorageKey, now = Date.now()) {
1025
- const raw = storage.getItem(hostedAuthStorageKey);
1026
- if (!raw) {
1027
- return null;
1028
- }
1029
- try {
1030
- const parsed = JSON.parse(raw);
1031
- if (!isHostedAuthRefreshActive(parsed, now, 0)) {
1032
- storage.removeItem(hostedAuthStorageKey);
1033
- return null;
1034
- }
1035
- return parsed;
1036
- } catch {
1037
- storage.removeItem(hostedAuthStorageKey);
1038
- return null;
1039
- }
1040
- }
1041
- function syncHostedAuthSessionToClient(client, hostedAuthConfig, hostedAuthSession) {
1042
- if (!hostedAuthConfig) {
1043
- client.clearBearerToken();
1044
- client.clearPrivateReadToken();
1045
- return;
1046
- }
1047
- if (hostedAuthSession && isHostedAuthSessionActive(hostedAuthSession)) {
1048
- client.setBearerToken(hostedAuthSession.accessToken);
1049
- client.clearPrivateReadToken();
1050
- return;
1051
- }
1052
- client.clearBearerToken();
1053
- client.clearPrivateReadToken();
1054
- }
1055
- var DEFAULT_NETWORK_CONFIG = NETWORK_CONFIG.testnet;
1056
- function PrivanaProvider({
1057
- children,
1058
- networkConfig: networkConfigOverride,
1059
- tokens,
1060
- chains,
1061
- pollingInterval = 1e4,
1062
- serviceAddress,
1063
- hostedAuth,
1064
- siweAuth
1065
- }) {
1066
- if (hostedAuth && siweAuth) {
1067
- throw new Error(
1068
- "PrivanaProvider: `hostedAuth` and `siweAuth` are mutually exclusive - provide only one. When both are set, private reads use hosted auth and the in-app SIWE login is ignored."
1069
- );
1070
- }
1071
- const networkConfig = react.useMemo(() => {
1072
- const config = {
1073
- ...DEFAULT_NETWORK_CONFIG,
1074
- ...networkConfigOverride
1075
- };
1076
- if (!config.chainId || config.chainId <= 0) {
1077
- throw new Error("PrivanaProvider: networkConfig.chainId must be a positive number");
1078
- }
1079
- if (!config.accountingContract || !config.accountingContract.startsWith("0x")) {
1080
- throw new Error("PrivanaProvider: networkConfig.accountingContract must be a valid address");
1081
- }
1082
- if (!config.apiUrl) {
1083
- throw new Error("PrivanaProvider: networkConfig.apiUrl must be provided");
1084
- }
1085
- return config;
1086
- }, [
1087
- networkConfigOverride?.chainId,
1088
- networkConfigOverride?.name,
1089
- networkConfigOverride?.accountingContract,
1090
- networkConfigOverride?.apiUrl
1091
- ]);
1092
- const resolvedChains = react.useMemo(() => {
1093
- if (chains && chains.length > 0) return chains;
1094
- return SUPPORTED_CHAINS;
1095
- }, [chains]);
1096
- const client = react.useMemo(
1097
- () => new PrivanaClient({ baseUrl: networkConfig.apiUrl }),
1098
- [networkConfig.apiUrl]
1099
- );
1100
- const [allTokens, setAllTokens] = react.useState([]);
1101
- const [tokensStatus, setTokensStatus] = react.useState("loading");
1102
- const [tokensError, setTokensError] = react.useState();
1103
- react.useEffect(() => {
1104
- setTokensStatus("loading");
1105
- setTokensError(void 0);
1106
- client.listTokens().then(({ tokens: list }) => {
1107
- setAllTokens(
1108
- list.map((t) => ({
1109
- id: t.token_id,
1110
- symbol: t.symbol,
1111
- decimals: t.decimals,
1112
- contract: t.token_address ?? viem.zeroAddress,
1113
- name: t.name,
1114
- chainId: t.chain_id
1115
- }))
1116
- );
1117
- setTokensStatus("ready");
1118
- }).catch((err) => {
1119
- setTokensError(err instanceof Error ? err : new Error(String(err)));
1120
- setTokensStatus("error");
1121
- });
1122
- }, [client]);
1123
- const enabledTokens = react.useMemo(() => {
1124
- if (tokens && tokens.length > 0) {
1125
- const allowed = new Set(tokens.map((id) => id.toLowerCase()));
1126
- return allTokens.filter((t) => allowed.has(t.id.toLowerCase()));
1127
- }
1128
- return allTokens;
1129
- }, [allTokens, tokens]);
1130
- const tokenById = react.useMemo(
1131
- () => Object.fromEntries(enabledTokens.map((t) => [t.id.toLowerCase(), t])),
1132
- [enabledTokens]
1133
- );
1134
- const getTokenById = react.useMemo(() => (id) => tokenById[id.toLowerCase()], [tokenById]);
1135
- const chainById = react.useMemo(
1136
- () => Object.fromEntries(resolvedChains.map((c) => [c.id, c])),
1137
- [resolvedChains]
1138
- );
1139
- const getChainById2 = react.useMemo(() => (id) => chainById[id], [chainById]);
1140
- const hostedAuthConfig = react.useMemo(() => {
1141
- if (!hostedAuth) return null;
1142
- const clientId = hostedAuth.clientId.trim();
1143
- const redirectUri = hostedAuth.redirectUri.trim();
1144
- if (!clientId) {
1145
- throw new Error(
1146
- "PrivanaProvider: hostedAuth.clientId must be provided when hostedAuth is enabled"
1147
- );
1148
- }
1149
- if (!redirectUri) {
1150
- throw new Error(
1151
- "PrivanaProvider: hostedAuth.redirectUri must be provided when hostedAuth is enabled"
1152
- );
1153
- }
1154
- return {
1155
- clientId,
1156
- redirectUri
1157
- };
1158
- }, [hostedAuth]);
1159
- const hostedAuthStorageKey = react.useMemo(
1160
- () => hostedAuthConfig ? createHostedAuthStorageKey(networkConfig.apiUrl, hostedAuthConfig) : null,
1161
- [hostedAuthConfig, networkConfig.apiUrl]
1162
- );
1163
- const [hostedAuthSession, setHostedAuthSessionState] = react.useState(null);
1164
- const hostedAuthSessionRef = react.useRef(null);
1165
- const hostedAuthStateVersionRef = react.useRef(0);
1166
- const hostedAuthRefreshInflight = react.useRef(null);
1167
- const clearHostedAuthSession = react.useCallback(() => {
1168
- hostedAuthStateVersionRef.current += 1;
1169
- hostedAuthSessionRef.current = null;
1170
- hostedAuthRefreshInflight.current = null;
1171
- setHostedAuthSessionState(null);
1172
- client.clearBearerToken();
1173
- client.clearPrivateReadToken();
1174
- if (hostedAuthStorageKey && typeof window !== "undefined") {
1175
- window.sessionStorage.removeItem(hostedAuthStorageKey);
1176
- }
1177
- }, [client, hostedAuthStorageKey]);
1178
- const setHostedAuthSession = react.useCallback(
1179
- (session) => {
1180
- if (!session) {
1181
- clearHostedAuthSession();
1182
- return;
1183
- }
1184
- hostedAuthStateVersionRef.current += 1;
1185
- hostedAuthSessionRef.current = session;
1186
- setHostedAuthSessionState(session);
1187
- if (isHostedAuthSessionActive(session)) {
1188
- client.setBearerToken(session.accessToken);
1189
- } else {
1190
- client.clearBearerToken();
1191
- }
1192
- client.clearPrivateReadToken();
1193
- if (hostedAuthStorageKey && typeof window !== "undefined") {
1194
- window.sessionStorage.setItem(hostedAuthStorageKey, JSON.stringify(session));
1195
- }
1196
- },
1197
- [clearHostedAuthSession, client, hostedAuthStorageKey]
1198
- );
1199
- const refreshHostedAuthSession = react.useCallback(async () => {
1200
- if (!hostedAuthConfig) {
1201
- throw new HostedAuthRequiredError(
1202
- "Hosted redirect authentication is not configured for this provider."
1203
- );
1204
- }
1205
- const currentSession = hostedAuthSessionRef.current;
1206
- if (!currentSession) {
1207
- throw new HostedAuthRequiredError();
1208
- }
1209
- if (!isHostedAuthRefreshActive(currentSession)) {
1210
- clearHostedAuthSession();
1211
- throw new HostedAuthRequiredError(
1212
- "Hosted redirect authentication has expired. Start login again."
1213
- );
1214
- }
1215
- if (hostedAuthRefreshInflight.current) {
1216
- return hostedAuthRefreshInflight.current;
1217
- }
1218
- const refreshPromise = (async () => {
1219
- const refreshVersion = hostedAuthStateVersionRef.current;
1220
- try {
1221
- const response = await client.refreshJwtSession({
1222
- refresh_token: currentSession.refreshToken
1223
- });
1224
- if (refreshVersion !== hostedAuthStateVersionRef.current) {
1225
- const latestSession = hostedAuthSessionRef.current;
1226
- if (latestSession) {
1227
- return latestSession;
1228
- }
1229
- throw new HostedAuthRequiredError(
1230
- "Hosted redirect authentication has changed. Start login again."
1231
- );
1232
- }
1233
- const nextSession = applyRefreshResponse(currentSession, response);
1234
- setHostedAuthSession(nextSession);
1235
- return nextSession;
1236
- } catch (error) {
1237
- if (refreshVersion === hostedAuthStateVersionRef.current) {
1238
- clearHostedAuthSession();
1239
- }
1240
- throw error;
1241
- } finally {
1242
- hostedAuthRefreshInflight.current = null;
1243
- }
1244
- })();
1245
- hostedAuthRefreshInflight.current = refreshPromise;
1246
- return refreshPromise;
1247
- }, [clearHostedAuthSession, client, hostedAuthConfig, setHostedAuthSession]);
1248
- react.useEffect(() => {
1249
- hostedAuthSessionRef.current = hostedAuthSession;
1250
- }, [hostedAuthSession]);
1251
- react.useEffect(() => {
1252
- if (!hostedAuthStorageKey || typeof window === "undefined") {
1253
- hostedAuthStateVersionRef.current += 1;
1254
- hostedAuthSessionRef.current = null;
1255
- hostedAuthRefreshInflight.current = null;
1256
- setHostedAuthSessionState(null);
1257
- return;
1258
- }
1259
- const restoredSession = readStoredHostedAuthSession(window.sessionStorage, hostedAuthStorageKey);
1260
- hostedAuthStateVersionRef.current += 1;
1261
- hostedAuthSessionRef.current = restoredSession;
1262
- hostedAuthRefreshInflight.current = null;
1263
- setHostedAuthSessionState(restoredSession);
1264
- }, [hostedAuthStorageKey]);
1265
- react.useEffect(() => {
1266
- syncHostedAuthSessionToClient(client, hostedAuthConfig, hostedAuthSession);
1267
- }, [client, hostedAuthConfig, hostedAuthSession]);
1268
- const value = react.useMemo(
1269
- () => ({
1270
- client,
1271
- networkConfig,
1272
- enabledTokens,
1273
- defaultToken: enabledTokens[0],
1274
- getTokenById,
1275
- getChainById: getChainById2,
1276
- chains: resolvedChains,
1277
- tokensStatus,
1278
- tokensError,
1279
- pollingInterval,
1280
- serviceAddress,
1281
- hostedAuthConfig,
1282
- hostedAuthSession,
1283
- setHostedAuthSession,
1284
- clearHostedAuthSession,
1285
- refreshHostedAuthSession
1286
- }),
1287
- [
1288
- client,
1289
- networkConfig,
1290
- enabledTokens,
1291
- getTokenById,
1292
- getChainById2,
1293
- resolvedChains,
1294
- tokensStatus,
1295
- tokensError,
1296
- pollingInterval,
1297
- serviceAddress,
1298
- hostedAuthConfig,
1299
- hostedAuthSession,
1300
- setHostedAuthSession,
1301
- clearHostedAuthSession,
1302
- refreshHostedAuthSession
1303
- ]
1304
- );
1305
- return /* @__PURE__ */ jsxRuntime.jsx(PrivanaContext.Provider, { value, children: siweAuth ? /* @__PURE__ */ jsxRuntime.jsx(
1306
- SiweAuthProvider,
1307
- {
1308
- client,
1309
- networkConfig,
1310
- autoLogin: siweAuth.autoLogin,
1311
- statement: siweAuth.statement,
1312
- children
1313
- }
1314
- ) : children });
1315
- }
1316
- function usePrivanaContext() {
1317
- const context = react.useContext(PrivanaContext);
1318
- if (!context) {
1319
- throw new Error("usePrivanaContext must be used within a PrivanaProvider");
1320
- }
1321
- return context;
1322
- }
1323
- function useSafePrivanaContext() {
1324
- return react.useContext(PrivanaContext);
1325
- }
1326
229
 
1327
230
  // src/sdk/hooks/use-privana-client.ts
1328
231
  function usePrivanaClient() {
1329
- const { client } = usePrivanaContext();
232
+ const { client } = chunkRDMJGMI3_cjs.usePrivanaContext();
1330
233
  return client;
1331
234
  }
1332
235
  var hostedAuthExchangeInflight = /* @__PURE__ */ new Map();
1333
236
  function normalizeHostedAuthError(error) {
1334
- if (error instanceof AccountingApiError && error.detail) {
1335
- return new HostedAuthError(error.detail);
237
+ if (error instanceof chunkRDMJGMI3_cjs.AccountingApiError && error.detail) {
238
+ return new chunkRDMJGMI3_cjs.HostedAuthError(error.detail);
1336
239
  }
1337
240
  if (error instanceof Error) {
1338
241
  return error;
1339
242
  }
1340
- return new HostedAuthError("Hosted authentication failed.");
243
+ return new chunkRDMJGMI3_cjs.HostedAuthError("Hosted authentication failed.");
1341
244
  }
1342
245
  function useHostedRedirectAuth() {
1343
246
  const {
@@ -1348,30 +251,30 @@ function useHostedRedirectAuth() {
1348
251
  setHostedAuthSession,
1349
252
  clearHostedAuthSession,
1350
253
  refreshHostedAuthSession
1351
- } = usePrivanaContext();
254
+ } = chunkRDMJGMI3_cjs.usePrivanaContext();
1352
255
  const [error, setError] = react.useState(null);
1353
256
  const [isLoading, setIsLoading] = react.useState(false);
1354
257
  const loginInflight = react.useRef(null);
1355
258
  const completionInflight = react.useRef(null);
1356
259
  const pendingStorageKey = react.useMemo(
1357
- () => hostedAuthConfig ? createHostedAuthPendingStorageKey(client.getBaseUrl(), hostedAuthConfig) : null,
260
+ () => hostedAuthConfig ? chunkRDMJGMI3_cjs.createHostedAuthPendingStorageKey(client.getBaseUrl(), hostedAuthConfig) : null,
1358
261
  [client, hostedAuthConfig]
1359
262
  );
1360
263
  const clearPendingLogin = react.useCallback(() => {
1361
264
  if (!pendingStorageKey || typeof window === "undefined") return;
1362
- clearHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
265
+ chunkRDMJGMI3_cjs.clearHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
1363
266
  }, [pendingStorageKey]);
1364
267
  const login = react.useCallback(async () => {
1365
268
  if (!hostedAuthConfig) {
1366
- throw new HostedAuthRequiredError(
269
+ throw new chunkRDMJGMI3_cjs.HostedAuthRequiredError(
1367
270
  "Hosted redirect authentication is not configured for this provider."
1368
271
  );
1369
272
  }
1370
273
  if (typeof window === "undefined") {
1371
- throw new HostedAuthError("Hosted redirect authentication requires a browser environment.");
274
+ throw new chunkRDMJGMI3_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
1372
275
  }
1373
276
  if (!pendingStorageKey) {
1374
- throw new HostedAuthError("Hosted redirect authentication storage is not configured.");
277
+ throw new chunkRDMJGMI3_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
1375
278
  }
1376
279
  if (loginInflight.current) {
1377
280
  return loginInflight.current;
@@ -1380,10 +283,10 @@ function useHostedRedirectAuth() {
1380
283
  setIsLoading(true);
1381
284
  setError(null);
1382
285
  try {
1383
- const verifier = createPkceVerifier();
1384
- const codeChallenge = await createPkceChallenge(verifier);
1385
- const state = createHostedAuthState();
1386
- persistHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey, {
286
+ const verifier = chunkRDMJGMI3_cjs.createPkceVerifier();
287
+ const codeChallenge = await chunkRDMJGMI3_cjs.createPkceChallenge(verifier);
288
+ const state = chunkRDMJGMI3_cjs.createHostedAuthState();
289
+ chunkRDMJGMI3_cjs.persistHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey, {
1387
290
  codeVerifier: verifier,
1388
291
  state
1389
292
  });
@@ -1412,15 +315,15 @@ function useHostedRedirectAuth() {
1412
315
  }, [clearPendingLogin, client, hostedAuthConfig, networkConfig.chainId, pendingStorageKey]);
1413
316
  const completeLogin = react.useCallback(async () => {
1414
317
  if (!hostedAuthConfig) {
1415
- throw new HostedAuthRequiredError(
318
+ throw new chunkRDMJGMI3_cjs.HostedAuthRequiredError(
1416
319
  "Hosted redirect authentication is not configured for this provider."
1417
320
  );
1418
321
  }
1419
322
  if (typeof window === "undefined") {
1420
- throw new HostedAuthError("Hosted redirect authentication requires a browser environment.");
323
+ throw new chunkRDMJGMI3_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
1421
324
  }
1422
325
  if (!pendingStorageKey) {
1423
- throw new HostedAuthError("Hosted redirect authentication storage is not configured.");
326
+ throw new chunkRDMJGMI3_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
1424
327
  }
1425
328
  if (completionInflight.current) {
1426
329
  return completionInflight.current;
@@ -1430,30 +333,30 @@ function useHostedRedirectAuth() {
1430
333
  setError(null);
1431
334
  const callbackUrl = new URL(window.location.href);
1432
335
  const cleanupCallbackUrl = () => {
1433
- window.history.replaceState(null, "", stripHostedAuthCallbackParams(callbackUrl));
336
+ window.history.replaceState(null, "", chunkRDMJGMI3_cjs.stripHostedAuthCallbackParams(callbackUrl));
1434
337
  };
1435
338
  try {
1436
- const callback = parseHostedAuthCallback(callbackUrl, hostedAuthConfig.redirectUri);
339
+ const callback = chunkRDMJGMI3_cjs.parseHostedAuthCallback(callbackUrl, hostedAuthConfig.redirectUri);
1437
340
  if (!callback) {
1438
341
  return null;
1439
342
  }
1440
- const pending = readHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
343
+ const pending = chunkRDMJGMI3_cjs.readHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
1441
344
  if (!pending) {
1442
345
  clearPendingLogin();
1443
346
  cleanupCallbackUrl();
1444
- throw new HostedAuthError(
347
+ throw new chunkRDMJGMI3_cjs.HostedAuthError(
1445
348
  "Hosted authentication response could not be matched to a pending login request."
1446
349
  );
1447
350
  }
1448
351
  if (!callback.state || callback.state !== pending.state) {
1449
352
  clearPendingLogin();
1450
353
  cleanupCallbackUrl();
1451
- throw new HostedAuthStateMismatchError();
354
+ throw new chunkRDMJGMI3_cjs.HostedAuthStateMismatchError();
1452
355
  }
1453
356
  if ("error" in callback) {
1454
357
  clearPendingLogin();
1455
358
  cleanupCallbackUrl();
1456
- throw new HostedAuthError(
359
+ throw new chunkRDMJGMI3_cjs.HostedAuthError(
1457
360
  callback.errorDescription || callback.error || "Hosted authentication failed."
1458
361
  );
1459
362
  }
@@ -1468,7 +371,7 @@ function useHostedRedirectAuth() {
1468
371
  client_id: hostedAuthConfig.clientId,
1469
372
  redirect_uri: hostedAuthConfig.redirectUri
1470
373
  });
1471
- const session = buildHostedAuthSession(response, hostedAuthConfig);
374
+ const session = chunkRDMJGMI3_cjs.buildHostedAuthSession(response, hostedAuthConfig);
1472
375
  setHostedAuthSession(session);
1473
376
  clearPendingLogin();
1474
377
  cleanupCallbackUrl();
@@ -1513,7 +416,7 @@ function useHostedRedirectAuth() {
1513
416
  try {
1514
417
  return await refreshHostedAuthSession();
1515
418
  } catch (refreshError) {
1516
- const normalizedError = refreshError instanceof Error ? refreshError : new HostedAuthError("Hosted authentication refresh failed.");
419
+ const normalizedError = refreshError instanceof Error ? refreshError : new chunkRDMJGMI3_cjs.HostedAuthError("Hosted authentication refresh failed.");
1517
420
  setError(normalizedError);
1518
421
  throw normalizedError;
1519
422
  } finally {
@@ -1531,243 +434,14 @@ function useHostedRedirectAuth() {
1531
434
  refresh
1532
435
  };
1533
436
  }
1534
- function cn(...inputs) {
1535
- return tailwindMerge.twMerge(clsx.clsx(inputs));
1536
- }
1537
- function formatTokenAmount(amount, decimals = 18) {
1538
- const value = typeof amount === "string" ? BigInt(amount) : amount;
1539
- const divisor = BigInt(10 ** decimals);
1540
- const integerPart = value / divisor;
1541
- const fractionalPart = value % divisor;
1542
- const fractionalStr = fractionalPart.toString().padStart(decimals, "0");
1543
- const twoDecimals = fractionalStr.slice(0, 2).padEnd(2, "0");
1544
- const integerWithSpaces = integerPart.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "\u2009");
1545
- return `${integerWithSpaces}.${twoDecimals}`;
1546
- }
1547
- function parseTokenAmount(amount, decimals = 18) {
1548
- const sanitized = amount.replace(/[\s\u2009]/g, "").replace(/,/g, ".");
1549
- const lastDot = sanitized.lastIndexOf(".");
1550
- const integerPart = lastDot === -1 ? sanitized : sanitized.slice(0, lastDot).replace(/\./g, "");
1551
- const fractionalPart = lastDot === -1 ? "" : sanitized.slice(lastDot + 1);
1552
- const paddedFractional = fractionalPart.padEnd(decimals, "0").slice(0, decimals);
1553
- return BigInt(integerPart + paddedFractional);
1554
- }
1555
- function shortenAddress(address, chars = 4) {
1556
- if (!address || address.length < chars * 2 + 2) return address;
1557
- return `${address.slice(0, chars + 2)}...${address.slice(-chars)}`;
1558
- }
1559
- function formatTimeRemaining(expiryTimestamp) {
1560
- const now = Math.floor(Date.now() / 1e3);
1561
- const diff = expiryTimestamp - now;
1562
- if (diff <= 0) return "Expired";
1563
- const days = Math.floor(diff / 86400);
1564
- const hours = Math.floor(diff % 86400 / 3600);
1565
- const minutes = Math.floor(diff % 3600 / 60);
1566
- if (days > 0) {
1567
- return hours > 0 ? `${days}d ${hours}h left` : `${days}d left`;
1568
- }
1569
- if (hours > 0) {
1570
- return minutes > 0 ? `${hours}h ${minutes}m left` : `${hours}h left`;
1571
- }
1572
- return `${minutes}m left`;
1573
- }
1574
- var INITIAL_AUTH_BACKOFF_MS = 5e3;
1575
- var MAX_AUTH_BACKOFF_MS = 6e4;
1576
- var DEFAULT_SIWE_AUTH_VALIDITY_MS = 24 * 60 * 60 * 1e3;
1577
- var PRIVATE_READ_STATEMENT = "Sign in to Privana to access private account data.";
1578
- var privateReadFailureCache = /* @__PURE__ */ new Map();
1579
- var privateReadInflight = /* @__PURE__ */ new Map();
1580
- async function executeHostedAuthPrivateReadRequest({
1581
- client,
1582
- hostedAuthSession,
1583
- refreshHostedAuthSession,
1584
- request
1585
- }) {
1586
- const ensureHostedAuth = async (forceRefresh) => {
1587
- if (!hostedAuthSession) {
1588
- throw new HostedAuthRequiredError();
1589
- }
1590
- if (!forceRefresh && isHostedAuthSessionActive(hostedAuthSession)) {
1591
- client.clearPrivateReadToken();
1592
- client.setBearerToken(hostedAuthSession.accessToken);
1593
- return hostedAuthSession.accessToken;
1594
- }
1595
- const refreshed = await refreshHostedAuthSession();
1596
- client.clearPrivateReadToken();
1597
- client.setBearerToken(refreshed.accessToken);
1598
- return refreshed.accessToken;
1599
- };
1600
- await ensureHostedAuth(false);
1601
- try {
1602
- return await request();
1603
- } catch (error) {
1604
- if (!(error instanceof AccountingApiError) || error.statusCode !== 401) {
1605
- throw error;
1606
- }
1607
- await ensureHostedAuth(true);
1608
- return request();
1609
- }
1610
- }
1611
- function clearPrivateReadScope(scopeKey, client) {
1612
- deleteCachedPrivateReadToken(scopeKey);
1613
- privateReadFailureCache.delete(scopeKey);
1614
- client.clearPrivateReadToken();
1615
- }
1616
- function recordPrivateReadFailure(scopeKey) {
1617
- const previous = privateReadFailureCache.get(scopeKey);
1618
- const backoffMs = Math.min(
1619
- previous ? previous.backoffMs * 2 : INITIAL_AUTH_BACKOFF_MS,
1620
- MAX_AUTH_BACKOFF_MS
1621
- );
1622
- privateReadFailureCache.set(scopeKey, {
1623
- backoffMs,
1624
- retryAt: Date.now() + backoffMs
1625
- });
1626
- }
1627
- function ensureFailureBackoff(scopeKey) {
1628
- const failure = privateReadFailureCache.get(scopeKey);
1629
- if (!failure) return;
1630
- if (failure.retryAt <= Date.now()) {
1631
- privateReadFailureCache.delete(scopeKey);
1632
- return;
1633
- }
1634
- throw new Error(
1635
- `Private-read authentication is temporarily paused after a recent failure. Retry in ${Math.ceil(
1636
- (failure.retryAt - Date.now()) / 1e3
1637
- )}s.`
1638
- );
1639
- }
1640
- function usePrivateReadRequest() {
1641
- const wagmiContext = react.useContext(wagmi.WagmiContext);
1642
- const { client, networkConfig, hostedAuthConfig, hostedAuthSession, refreshHostedAuthSession } = usePrivanaContext();
1643
- const { address: walletAddress } = useSafeAccount();
1644
- const privateReadAddress = hostedAuthConfig ? hostedAuthSession?.address ?? null : walletAddress ?? null;
1645
- const privateReadReady = hostedAuthConfig ? !!hostedAuthSession : !!walletAddress;
1646
- const executePrivateRead = react.useCallback(
1647
- async (request) => {
1648
- if (hostedAuthConfig) {
1649
- return executeHostedAuthPrivateReadRequest({
1650
- client,
1651
- hostedAuthSession,
1652
- refreshHostedAuthSession,
1653
- request
1654
- });
1655
- }
1656
- if (!wagmiContext) {
1657
- throw new Error("WagmiProvider is required for authenticated private reads");
1658
- }
1659
- if (!walletAddress) {
1660
- throw new Error("No wallet connected");
1661
- }
1662
- const walletClient = await actions.getWalletClient(wagmiContext);
1663
- if (!walletClient) {
1664
- throw new Error("No wallet client available");
1665
- }
1666
- const apiUrl = networkConfig.apiUrl;
1667
- const scopeKey = createScopeKey(apiUrl, networkConfig.chainId, walletAddress);
1668
- const getToken = async (forceRefresh) => {
1669
- const inflight = privateReadInflight.get(scopeKey);
1670
- if (inflight) {
1671
- const token = await inflight;
1672
- client.setPrivateReadToken(token);
1673
- return token;
1674
- }
1675
- if (!forceRefresh) {
1676
- const cached = getCachedPrivateReadToken(scopeKey);
1677
- if (cached) {
1678
- client.setPrivateReadToken(cached);
1679
- return cached;
1680
- }
1681
- }
1682
- ensureFailureBackoff(scopeKey);
1683
- const authPromise = (async () => {
1684
- try {
1685
- const [{ domain }, nonceResponse] = await Promise.all([
1686
- client.getSiweDomain(),
1687
- client.getSiweNonce(walletAddress)
1688
- ]);
1689
- const issuedAt = /* @__PURE__ */ new Date();
1690
- const expirationTime = new Date(issuedAt.getTime() + DEFAULT_SIWE_AUTH_VALIDITY_MS);
1691
- const uri = typeof window !== "undefined" && window.location.origin ? window.location.origin : apiUrl;
1692
- const message = siwe.createSiweMessage({
1693
- address: walletAddress,
1694
- chainId: walletClient.chain?.id ?? networkConfig.chainId,
1695
- domain,
1696
- expirationTime,
1697
- issuedAt,
1698
- nonce: nonceResponse.nonce,
1699
- statement: PRIVATE_READ_STATEMENT,
1700
- uri,
1701
- version: "1"
1702
- });
1703
- const signature = await walletClient.signMessage({
1704
- account: walletClient.account ?? walletAddress,
1705
- message
1706
- });
1707
- const login = await client.loginWithSiwe({
1708
- siwe_message: message,
1709
- signature
1710
- });
1711
- setCachedPrivateReadToken(scopeKey, login.siwe_token, expirationTime.getTime());
1712
- privateReadFailureCache.delete(scopeKey);
1713
- client.setPrivateReadToken(login.siwe_token);
1714
- return login.siwe_token;
1715
- } catch (error) {
1716
- const authError = error instanceof Error ? error : new Error("Failed to authenticate private reads");
1717
- clearPrivateReadScope(scopeKey, client);
1718
- recordPrivateReadFailure(scopeKey);
1719
- throw authError;
1720
- } finally {
1721
- privateReadInflight.delete(scopeKey);
1722
- }
1723
- })();
1724
- privateReadInflight.set(scopeKey, authPromise);
1725
- return authPromise;
1726
- };
1727
- await getToken(false);
1728
- try {
1729
- return await request();
1730
- } catch (error) {
1731
- if (!(error instanceof AccountingApiError) || error.statusCode !== 401) {
1732
- throw error;
1733
- }
1734
- clearPrivateReadScope(scopeKey, client);
1735
- await getToken(true);
1736
- return request();
1737
- }
1738
- },
1739
- [
1740
- client,
1741
- hostedAuthConfig,
1742
- hostedAuthSession,
1743
- networkConfig.apiUrl,
1744
- networkConfig.chainId,
1745
- refreshHostedAuthSession,
1746
- walletAddress,
1747
- wagmiContext
1748
- ]
1749
- );
1750
- const privateReadQueryScope = react.useMemo(
1751
- () => [networkConfig.apiUrl, networkConfig.chainId, privateReadAddress],
1752
- [networkConfig.apiUrl, networkConfig.chainId, privateReadAddress]
1753
- );
1754
- return {
1755
- executePrivateRead,
1756
- privateReadAddress,
1757
- privateReadReady,
1758
- privateReadQueryScope
1759
- };
1760
- }
1761
-
1762
- // src/sdk/hooks/use-balance.ts
1763
437
  function useBalance(options = {}) {
1764
438
  const queryClient = react.useContext(reactQuery.QueryClientContext);
1765
- const accountingContext = useSafePrivanaContext();
439
+ const accountingContext = chunkRDMJGMI3_cjs.useSafePrivanaContext();
1766
440
  const hasProviders = !!queryClient && !!accountingContext;
1767
441
  const client = accountingContext?.client;
1768
442
  const defaultToken = accountingContext?.defaultToken;
1769
443
  const pollingInterval = accountingContext?.pollingInterval ?? 1e4;
1770
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = usePrivateReadRequest();
444
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkRDMJGMI3_cjs.usePrivateReadRequest();
1771
445
  const tokenId = options.tokenId ?? defaultToken?.id;
1772
446
  const query = reactQuery.useQuery({
1773
447
  queryKey: ["accounting-balance", ...privateReadQueryScope, tokenId],
@@ -1784,7 +458,7 @@ function useBalance(options = {}) {
1784
458
  return {
1785
459
  balance: balanceWei,
1786
460
  balanceWei,
1787
- balanceFormatted: formatTokenAmount(balanceWei),
461
+ balanceFormatted: chunkRDMJGMI3_cjs.formatTokenAmount(balanceWei),
1788
462
  tokenSymbol: query.data?.token_symbol ?? "",
1789
463
  chainId: query.data?.chain_id ?? "",
1790
464
  isLoading: query.isPending || query.isLoading,
@@ -1794,8 +468,8 @@ function useBalance(options = {}) {
1794
468
  };
1795
469
  }
1796
470
  function useBatchBalances(options) {
1797
- const { client, pollingInterval } = usePrivanaContext();
1798
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = usePrivateReadRequest();
471
+ const { client, pollingInterval } = chunkRDMJGMI3_cjs.usePrivanaContext();
472
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkRDMJGMI3_cjs.usePrivateReadRequest();
1799
473
  const query = reactQuery.useQuery({
1800
474
  queryKey: ["accounting-batch-balances", ...privateReadQueryScope, options.tokenIds],
1801
475
  queryFn: async () => {
@@ -1813,55 +487,6 @@ function useBatchBalances(options) {
1813
487
  refetch: query.refetch
1814
488
  };
1815
489
  }
1816
-
1817
- // ../../node_modules/@wagmi/core/dist/esm/utils/getAction.js
1818
- function getAction(client, actionFn, name) {
1819
- const action_implicit = client[actionFn.name];
1820
- if (typeof action_implicit === "function")
1821
- return action_implicit;
1822
- const action_explicit = client[name];
1823
- if (typeof action_explicit === "function")
1824
- return action_explicit;
1825
- return (params) => actionFn(client, params);
1826
- }
1827
-
1828
- // ../../node_modules/@wagmi/core/dist/esm/actions/getChainId.js
1829
- function getChainId2(config) {
1830
- return config.state.chainId;
1831
- }
1832
- async function getTransactionReceipt(config, parameters) {
1833
- const { chainId, ...rest } = parameters;
1834
- const client = config.getClient({ chainId });
1835
- const action = getAction(client, actions$1.getTransactionReceipt, "getTransactionReceipt");
1836
- return action(rest);
1837
- }
1838
- async function waitForTransactionReceipt(config, parameters) {
1839
- const { chainId, timeout = 0, ...rest } = parameters;
1840
- const client = config.getClient({ chainId });
1841
- const action = getAction(client, actions$1.waitForTransactionReceipt, "waitForTransactionReceipt");
1842
- const receipt = await action({ ...rest, timeout });
1843
- if (receipt.status === "reverted") {
1844
- const action_getTransaction = getAction(client, actions$1.getTransaction, "getTransaction");
1845
- const { from: account, ...txn } = await action_getTransaction({
1846
- hash: receipt.transactionHash
1847
- });
1848
- const action_call = getAction(client, actions$1.call, "call");
1849
- const code = await action_call({
1850
- ...txn,
1851
- account,
1852
- data: txn.input,
1853
- gasPrice: txn.type !== "eip1559" ? txn.gasPrice : void 0,
1854
- maxFeePerGas: txn.type === "eip1559" ? txn.maxFeePerGas : void 0,
1855
- maxPriorityFeePerGas: txn.type === "eip1559" ? txn.maxPriorityFeePerGas : void 0
1856
- });
1857
- const reason = code?.data ? viem.hexToString(`0x${code.data.substring(138)}`) : "unknown reason";
1858
- throw new Error(reason);
1859
- }
1860
- return {
1861
- ...receipt,
1862
- chainId: client.chain.id
1863
- };
1864
- }
1865
490
  function useEnsureCorrectChain() {
1866
491
  const config = wagmi.useConfig();
1867
492
  const chainId = wagmi.useChainId();
@@ -1870,7 +495,7 @@ function useEnsureCorrectChain() {
1870
495
  async (expectedChainId, timeoutMs, pollIntervalMs = 250) => {
1871
496
  const startedAt = Date.now();
1872
497
  while (Date.now() - startedAt < timeoutMs) {
1873
- const currentChainId = getChainId2(config);
498
+ const currentChainId = chunkRDMJGMI3_cjs.getChainId2(config);
1874
499
  if (currentChainId === expectedChainId) return true;
1875
500
  await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
1876
501
  }
@@ -1880,7 +505,7 @@ function useEnsureCorrectChain() {
1880
505
  );
1881
506
  const ensureCorrectChain = react.useCallback(
1882
507
  async (targetChainId) => {
1883
- const currentChainId = getChainId2(config);
508
+ const currentChainId = chunkRDMJGMI3_cjs.getChainId2(config);
1884
509
  if (currentChainId === targetChainId) return false;
1885
510
  let switchErrorMessage;
1886
511
  try {
@@ -1947,24 +572,19 @@ function clearPendingDeposit(address) {
1947
572
  }
1948
573
  function useDeposit(options = {}) {
1949
574
  const { address } = wagmi.useAccount();
1950
- const { client, enabledTokens, getChainById: getChainById2 } = usePrivanaContext();
575
+ const { client, enabledTokens, getChainById: getChainById2 } = chunkRDMJGMI3_cjs.usePrivanaContext();
1951
576
  const { data: walletClient } = wagmi.useWalletClient();
1952
577
  const queryClient = reactQuery.useQueryClient();
1953
578
  const config = wagmi.useConfig();
1954
- const { executePrivateRead } = usePrivateReadRequest();
1955
- const pollInterval = options.pollInterval ?? 5e3;
1956
- const pollTimeout = options.pollTimeout ?? 18e4;
579
+ const { executePrivateRead } = chunkRDMJGMI3_cjs.usePrivateReadRequest();
1957
580
  const confirmations = options.confirmations ?? 15;
1958
581
  const [depositAddress, setDepositAddress] = react.useState(null);
1959
582
  const [txHash, setTxHash] = react.useState();
1960
583
  const [isSwitchingChain, setIsSwitchingChain] = react.useState(false);
1961
584
  const [isWaitingForConfirmation, setIsWaitingForConfirmation] = react.useState(false);
1962
- const [isWaitingForProcessing, setIsWaitingForProcessing] = react.useState(false);
1963
- const [didTimeout, setDidTimeout] = react.useState(false);
1964
- const [verificationFailed, setVerificationFailed] = react.useState(false);
585
+ const [receiptFailed, setReceiptFailed] = react.useState(false);
1965
586
  const [depositError, setDepositError] = react.useState(null);
1966
587
  const generationRef = react.useRef(0);
1967
- const pollIntervalRef = react.useRef(null);
1968
588
  const verificationContextRef = react.useRef(null);
1969
589
  const onDepositAddressReceivedRef = react.useRef(options.onDepositAddressReceived);
1970
590
  const onDepositSuccessRef = react.useRef(options.onDepositSuccess);
@@ -1984,6 +604,28 @@ function useDeposit(options = {}) {
1984
604
  options.onCheckTimeout,
1985
605
  options.onError
1986
606
  ]);
607
+ const {
608
+ isVerifying,
609
+ didTimeout,
610
+ verificationFailed: innerVerificationFailed,
611
+ error: verificationError,
612
+ verify,
613
+ reset: resetVerification
614
+ } = chunkRDMJGMI3_cjs.useDepositVerification({
615
+ pollInterval: options.pollInterval,
616
+ pollTimeout: options.pollTimeout,
617
+ onCredited: (hash, response) => {
618
+ verificationContextRef.current = null;
619
+ if (address) clearPendingDeposit(address);
620
+ onCreditedRef.current?.(hash, response);
621
+ },
622
+ onCheckTimeout: (hash) => {
623
+ onCheckTimeoutRef.current?.(hash);
624
+ },
625
+ onError: (err) => {
626
+ onErrorRef.current?.(err);
627
+ }
628
+ });
1987
629
  const addressMutation = reactQuery.useMutation({
1988
630
  mutationFn: async () => {
1989
631
  if (!address) throw new Error("No wallet connected");
@@ -2018,149 +660,24 @@ function useDeposit(options = {}) {
2018
660
  react.useEffect(() => {
2019
661
  return () => {
2020
662
  invalidateGeneration();
2021
- if (pollIntervalRef.current) {
2022
- clearTimeout(pollIntervalRef.current);
2023
- pollIntervalRef.current = null;
2024
- }
2025
663
  };
2026
664
  }, [invalidateGeneration]);
2027
665
  const resumedAddressRef = react.useRef(void 0);
2028
- const stopPolling = react.useCallback(() => {
2029
- if (pollIntervalRef.current) {
2030
- clearTimeout(pollIntervalRef.current);
2031
- pollIntervalRef.current = null;
2032
- }
2033
- }, []);
2034
666
  const reset = react.useCallback(() => {
2035
667
  generationRef.current++;
2036
- stopPolling();
668
+ resetVerification();
2037
669
  if (address) clearPendingDeposit(address);
2038
670
  verificationContextRef.current = null;
2039
671
  setDepositAddress(null);
2040
672
  setTxHash(void 0);
2041
673
  setIsSwitchingChain(false);
2042
674
  setIsWaitingForConfirmation(false);
2043
- setIsWaitingForProcessing(false);
2044
- setDidTimeout(false);
2045
- setVerificationFailed(false);
675
+ setReceiptFailed(false);
2046
676
  setDepositError(null);
2047
677
  addressMutation.reset();
2048
678
  resetWriteContract();
2049
679
  resetSendTransaction();
2050
- }, [address, addressMutation, resetWriteContract, resetSendTransaction, stopPolling]);
2051
- const runVerification = react.useCallback(
2052
- async (ctx, generation) => {
2053
- const isStale = () => generation !== generationRef.current;
2054
- const { hash, chainId, amount } = ctx;
2055
- setVerificationFailed(false);
2056
- setDepositError(null);
2057
- setDidTimeout(false);
2058
- setIsWaitingForProcessing(true);
2059
- const pollStartTime = Date.now();
2060
- const markVerificationFailed = (err) => {
2061
- setIsWaitingForProcessing(false);
2062
- setDepositError(err);
2063
- setVerificationFailed(true);
2064
- onErrorRef.current?.(err);
2065
- };
2066
- try {
2067
- const triggerResult = await executePrivateRead(
2068
- () => client.checkDeposit({
2069
- chain_id: chainId,
2070
- tx_hash: hash,
2071
- amount: amount.toString()
2072
- })
2073
- );
2074
- if (isStale()) return;
2075
- if (triggerResult.status === "credited") {
2076
- setIsWaitingForProcessing(false);
2077
- verificationContextRef.current = null;
2078
- if (address) clearPendingDeposit(address);
2079
- queryClient.invalidateQueries({ queryKey: ["accounting-balance"] });
2080
- queryClient.invalidateQueries({ queryKey: ["accounting-history"] });
2081
- onCreditedRef.current?.(hash, triggerResult);
2082
- return;
2083
- }
2084
- if (triggerResult.status === "error") {
2085
- markVerificationFailed(new Error(triggerResult.detail ?? "Deposit verification failed"));
2086
- return;
2087
- }
2088
- const depositId = triggerResult.deposit_id;
2089
- if (!depositId) {
2090
- markVerificationFailed(new Error("Deposit check did not return a deposit id"));
2091
- return;
2092
- }
2093
- let consecutiveFailures = 0;
2094
- const checkStatus = async () => {
2095
- if (isStale()) return true;
2096
- if (Date.now() - pollStartTime > pollTimeout) {
2097
- stopPolling();
2098
- setIsWaitingForProcessing(false);
2099
- setDidTimeout(true);
2100
- onCheckTimeoutRef.current?.(hash);
2101
- queryClient.invalidateQueries({ queryKey: ["accounting-balance"] });
2102
- return true;
2103
- }
2104
- try {
2105
- const result = await executePrivateRead(() => client.getDepositStatus(depositId));
2106
- if (isStale()) return true;
2107
- consecutiveFailures = 0;
2108
- if (result.status === "credited") {
2109
- stopPolling();
2110
- setIsWaitingForProcessing(false);
2111
- verificationContextRef.current = null;
2112
- if (address) clearPendingDeposit(address);
2113
- queryClient.invalidateQueries({ queryKey: ["accounting-balance"] });
2114
- queryClient.invalidateQueries({ queryKey: ["accounting-history"] });
2115
- onCreditedRef.current?.(hash, result);
2116
- return true;
2117
- }
2118
- if (result.status === "error") {
2119
- stopPolling();
2120
- markVerificationFailed(new Error(result.detail ?? "Deposit verification failed"));
2121
- return true;
2122
- }
2123
- } catch (err) {
2124
- if (isStale()) return true;
2125
- consecutiveFailures++;
2126
- console.warn("Error polling deposit status:", err);
2127
- if (consecutiveFailures >= 3) {
2128
- stopPolling();
2129
- markVerificationFailed(
2130
- err instanceof Error ? err : new Error("Deposit status polling failed")
2131
- );
2132
- return true;
2133
- }
2134
- }
2135
- return false;
2136
- };
2137
- const pollLoop = async () => {
2138
- const done = await checkStatus();
2139
- if (!done && !isStale() && pollIntervalRef.current !== null) {
2140
- pollIntervalRef.current = setTimeout(pollLoop, pollInterval);
2141
- }
2142
- };
2143
- pollIntervalRef.current = setTimeout(pollLoop, pollInterval);
2144
- } catch (err) {
2145
- if (isStale()) return;
2146
- stopPolling();
2147
- markVerificationFailed(
2148
- err instanceof Error ? err : new Error("Deposit verification failed")
2149
- );
2150
- }
2151
- },
2152
- [address, client, executePrivateRead, pollInterval, pollTimeout, queryClient, stopPolling]
2153
- );
2154
- const retryVerification = react.useCallback(async () => {
2155
- const ctx = verificationContextRef.current;
2156
- if (!ctx) {
2157
- throw new Error("No pending deposit to verify");
2158
- }
2159
- generationRef.current++;
2160
- stopPolling();
2161
- const generation = generationRef.current;
2162
- await runVerification(ctx, generation);
2163
- }, [runVerification, stopPolling]);
680
+ }, [address, addressMutation, resetWriteContract, resetSendTransaction, resetVerification]);
2164
681
  react.useEffect(() => {
2165
682
  if (!address || resumedAddressRef.current === address) return;
2166
683
  const persisted = loadPendingDeposit(address);
@@ -2182,12 +699,12 @@ function useDeposit(options = {}) {
2182
699
  try {
2183
700
  let confirmed = false;
2184
701
  try {
2185
- await getTransactionReceipt(config, { hash, chainId: persisted.chainId });
702
+ await chunkRDMJGMI3_cjs.getTransactionReceipt(config, { hash, chainId: persisted.chainId });
2186
703
  confirmed = true;
2187
704
  } catch {
2188
705
  }
2189
706
  if (!confirmed) {
2190
- await waitForTransactionReceipt(config, {
707
+ await chunkRDMJGMI3_cjs.waitForTransactionReceipt(config, {
2191
708
  hash,
2192
709
  chainId: persisted.chainId,
2193
710
  confirmations
@@ -2197,19 +714,17 @@ function useDeposit(options = {}) {
2197
714
  setIsWaitingForConfirmation(false);
2198
715
  onDepositSuccessRef.current?.(hash);
2199
716
  queryClient.invalidateQueries({ queryKey: ["readContract"] });
2200
- await runVerification(ctx, generation);
717
+ await verify(ctx);
2201
718
  } catch (err) {
2202
719
  if (isStale()) return;
2203
720
  setIsWaitingForConfirmation(false);
2204
- stopPolling();
2205
721
  const error2 = err instanceof Error ? err : new Error("Deposit verification failed");
2206
- setIsWaitingForProcessing(false);
2207
722
  setDepositError(error2);
2208
- setVerificationFailed(true);
723
+ setReceiptFailed(true);
2209
724
  onErrorRef.current?.(error2);
2210
725
  }
2211
726
  })();
2212
- }, [address, config, confirmations, queryClient, runVerification, stopPolling]);
727
+ }, [address, config, confirmations, queryClient, verify]);
2213
728
  const deposit = react.useCallback(
2214
729
  async (params) => {
2215
730
  if (verificationContextRef.current) {
@@ -2276,7 +791,7 @@ function useDeposit(options = {}) {
2276
791
  try {
2277
792
  setIsWaitingForConfirmation(true);
2278
793
  try {
2279
- await waitForTransactionReceipt(config, {
794
+ await chunkRDMJGMI3_cjs.waitForTransactionReceipt(config, {
2280
795
  hash,
2281
796
  chainId: sourceChain.id,
2282
797
  confirmations
@@ -2287,15 +802,13 @@ function useDeposit(options = {}) {
2287
802
  if (isStale()) return;
2288
803
  onDepositSuccessRef.current?.(hash);
2289
804
  queryClient.invalidateQueries({ queryKey: ["readContract"] });
2290
- await runVerification(ctx, generation);
805
+ await verify(ctx);
2291
806
  } catch (err) {
2292
807
  if (isStale()) return;
2293
808
  setIsWaitingForConfirmation(false);
2294
- stopPolling();
2295
809
  const error2 = err instanceof Error ? err : new Error("Deposit verification failed");
2296
- setIsWaitingForProcessing(false);
2297
810
  setDepositError(error2);
2298
- setVerificationFailed(true);
811
+ setReceiptFailed(true);
2299
812
  onErrorRef.current?.(error2);
2300
813
  }
2301
814
  } catch (err) {
@@ -2317,13 +830,21 @@ function useDeposit(options = {}) {
2317
830
  queryClient,
2318
831
  writeContractAsync,
2319
832
  sendTransactionAsync,
2320
- stopPolling,
2321
833
  reset,
2322
- runVerification
834
+ verify
2323
835
  ]
2324
836
  );
2325
- const isPending = addressMutation.isPending || isSwitchingChain || isSendingTx || isWaitingForConfirmation || isWaitingForProcessing;
2326
- const error = addressMutation.error || sendError || depositError;
837
+ const retryVerification = react.useCallback(async () => {
838
+ const ctx = verificationContextRef.current;
839
+ if (!ctx) {
840
+ throw new Error("No pending deposit to verify");
841
+ }
842
+ setReceiptFailed(false);
843
+ setDepositError(null);
844
+ await verify(ctx);
845
+ }, [verify]);
846
+ const isPending = addressMutation.isPending || isSwitchingChain || isSendingTx || isWaitingForConfirmation || isVerifying;
847
+ const error = addressMutation.error || sendError || depositError || verificationError;
2327
848
  return {
2328
849
  depositAddress,
2329
850
  txHash,
@@ -2331,9 +852,9 @@ function useDeposit(options = {}) {
2331
852
  isSwitchingChain,
2332
853
  isSendingTransaction: isSendingTx,
2333
854
  isWaitingForConfirmation,
2334
- isWaitingForProcessing,
855
+ isWaitingForProcessing: isVerifying,
2335
856
  didTimeout,
2336
- verificationFailed,
857
+ verificationFailed: innerVerificationFailed || receiptFailed,
2337
858
  isPending,
2338
859
  error,
2339
860
  deposit,
@@ -2344,7 +865,7 @@ function useDeposit(options = {}) {
2344
865
  function useWithdraw(options = {}) {
2345
866
  const { address } = wagmi.useAccount();
2346
867
  const { data: walletClient } = wagmi.useWalletClient();
2347
- const { client, networkConfig } = usePrivanaContext();
868
+ const { client, networkConfig } = chunkRDMJGMI3_cjs.usePrivanaContext();
2348
869
  const queryClient = reactQuery.useQueryClient();
2349
870
  const { chainId, ensureCorrectChain } = useEnsureCorrectChain();
2350
871
  const pollInterval = options.pollInterval ?? 3e3;
@@ -2543,7 +1064,7 @@ function useWithdraw(options = {}) {
2543
1064
  function useLockFunds(options = {}) {
2544
1065
  const { address } = wagmi.useAccount();
2545
1066
  const { data: walletClient } = wagmi.useWalletClient();
2546
- const { client, networkConfig, serviceAddress } = usePrivanaContext();
1067
+ const { client, networkConfig, serviceAddress } = chunkRDMJGMI3_cjs.usePrivanaContext();
2547
1068
  const queryClient = reactQuery.useQueryClient();
2548
1069
  const mutation = reactQuery.useMutation({
2549
1070
  mutationFn: async (params) => {
@@ -2602,7 +1123,7 @@ function useLockFunds(options = {}) {
2602
1123
  }
2603
1124
  function useUnlockFunds(options = {}) {
2604
1125
  const { address } = wagmi.useAccount();
2605
- const { client } = usePrivanaContext();
1126
+ const { client } = chunkRDMJGMI3_cjs.usePrivanaContext();
2606
1127
  const queryClient = reactQuery.useQueryClient();
2607
1128
  const unlockMutation = reactQuery.useMutation({
2608
1129
  mutationFn: async (params) => {
@@ -2670,7 +1191,7 @@ function useUnlockFunds(options = {}) {
2670
1191
  function useTransfer(options = {}) {
2671
1192
  const { address } = wagmi.useAccount();
2672
1193
  const { data: walletClient } = wagmi.useWalletClient();
2673
- const { client, networkConfig, serviceAddress } = usePrivanaContext();
1194
+ const { client, networkConfig, serviceAddress } = chunkRDMJGMI3_cjs.usePrivanaContext();
2674
1195
  const queryClient = reactQuery.useQueryClient();
2675
1196
  const transferMutation = reactQuery.useMutation({
2676
1197
  mutationFn: async (params) => {
@@ -2775,8 +1296,8 @@ function useTransfer(options = {}) {
2775
1296
  };
2776
1297
  }
2777
1298
  function useLockedFunds(options = {}) {
2778
- const { client, pollingInterval, serviceAddress } = usePrivanaContext();
2779
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = usePrivateReadRequest();
1299
+ const { client, pollingInterval, serviceAddress } = chunkRDMJGMI3_cjs.usePrivanaContext();
1300
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkRDMJGMI3_cjs.usePrivateReadRequest();
2780
1301
  const query = reactQuery.useQuery({
2781
1302
  queryKey: ["accounting-locked-funds", ...privateReadQueryScope, serviceAddress ?? null],
2782
1303
  queryFn: async () => {
@@ -2798,8 +1319,8 @@ function useLockedFunds(options = {}) {
2798
1319
  };
2799
1320
  }
2800
1321
  function useTotalLockedBalance(options = {}) {
2801
- const { client, pollingInterval, defaultToken } = usePrivanaContext();
2802
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = usePrivateReadRequest();
1322
+ const { client, pollingInterval, defaultToken } = chunkRDMJGMI3_cjs.usePrivanaContext();
1323
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkRDMJGMI3_cjs.usePrivateReadRequest();
2803
1324
  const tokenId = options.tokenId ?? defaultToken?.id;
2804
1325
  const query = reactQuery.useQuery({
2805
1326
  queryKey: ["accounting-total-locked-balance", ...privateReadQueryScope, tokenId],
@@ -2820,8 +1341,8 @@ function useTotalLockedBalance(options = {}) {
2820
1341
  };
2821
1342
  }
2822
1343
  function useExpiredLocks(options = {}) {
2823
- const { client, pollingInterval } = usePrivanaContext();
2824
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = usePrivateReadRequest();
1344
+ const { client, pollingInterval } = chunkRDMJGMI3_cjs.usePrivanaContext();
1345
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkRDMJGMI3_cjs.usePrivateReadRequest();
2825
1346
  const query = reactQuery.useQuery({
2826
1347
  queryKey: ["accounting-expired-locks", ...privateReadQueryScope],
2827
1348
  queryFn: async () => {
@@ -2843,7 +1364,7 @@ function useExpiredLocks(options = {}) {
2843
1364
  }
2844
1365
  function usePendingWithdrawals(options = {}) {
2845
1366
  const { address, isConnected } = wagmi.useAccount();
2846
- const { client, pollingInterval } = usePrivanaContext();
1367
+ const { client, pollingInterval } = chunkRDMJGMI3_cjs.usePrivanaContext();
2847
1368
  const query = reactQuery.useQuery({
2848
1369
  queryKey: ["accounting-pending-withdrawals", address],
2849
1370
  queryFn: async () => {
@@ -2879,8 +1400,8 @@ function usePendingWithdrawals(options = {}) {
2879
1400
  };
2880
1401
  }
2881
1402
  function useHistory(options = {}) {
2882
- const { client, pollingInterval } = usePrivanaContext();
2883
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = usePrivateReadRequest();
1403
+ const { client, pollingInterval } = chunkRDMJGMI3_cjs.usePrivanaContext();
1404
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkRDMJGMI3_cjs.usePrivateReadRequest();
2884
1405
  const offset = options.offset ?? -1;
2885
1406
  const limit = options.limit ?? 50;
2886
1407
  const query = reactQuery.useQuery({
@@ -2904,7 +1425,7 @@ function useHistory(options = {}) {
2904
1425
  };
2905
1426
  }
2906
1427
  function useTokenInfo(options = {}) {
2907
- const { client } = usePrivanaContext();
1428
+ const { client } = chunkRDMJGMI3_cjs.usePrivanaContext();
2908
1429
  const { tokenId } = options;
2909
1430
  const query = reactQuery.useQuery({
2910
1431
  queryKey: ["accounting-token-info", tokenId],
@@ -2924,7 +1445,7 @@ function useTokenInfo(options = {}) {
2924
1445
  };
2925
1446
  }
2926
1447
  function useTokenList(options = {}) {
2927
- const { client } = usePrivanaContext();
1448
+ const { client } = chunkRDMJGMI3_cjs.usePrivanaContext();
2928
1449
  const query = reactQuery.useQuery({
2929
1450
  queryKey: ["accounting-token-list"],
2930
1451
  queryFn: () => client.listTokens(),
@@ -2942,7 +1463,7 @@ function useTokenList(options = {}) {
2942
1463
  function useModifyLock(options = {}) {
2943
1464
  const { address } = wagmi.useAccount();
2944
1465
  const { data: walletClient } = wagmi.useWalletClient();
2945
- const { client, networkConfig } = usePrivanaContext();
1466
+ const { client, networkConfig } = chunkRDMJGMI3_cjs.usePrivanaContext();
2946
1467
  const queryClient = reactQuery.useQueryClient();
2947
1468
  const mutation = reactQuery.useMutation({
2948
1469
  mutationFn: async (params) => {
@@ -2993,52 +1514,6 @@ function useModifyLock(options = {}) {
2993
1514
  reset: mutation.reset
2994
1515
  };
2995
1516
  }
2996
- var buttonVariants = classVarianceAuthority.cva(
2997
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
2998
- {
2999
- variants: {
3000
- variant: {
3001
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
3002
- destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
3003
- outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
3004
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
3005
- ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
3006
- link: "text-primary underline-offset-4 hover:underline"
3007
- },
3008
- size: {
3009
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
3010
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
3011
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
3012
- icon: "size-9",
3013
- "icon-sm": "size-8",
3014
- "icon-lg": "size-10"
3015
- }
3016
- },
3017
- defaultVariants: {
3018
- variant: "default",
3019
- size: "default"
3020
- }
3021
- }
3022
- );
3023
- function Button({
3024
- className,
3025
- variant = "default",
3026
- size = "default",
3027
- asChild = false,
3028
- ...props
3029
- }) {
3030
- const Comp = asChild ? reactSlot.Slot : "button";
3031
- return /* @__PURE__ */ jsxRuntime.jsx(
3032
- Comp,
3033
- {
3034
- "data-slot": "button",
3035
- "data-variant": variant,
3036
- "data-size": size,
3037
- className: cn(buttonVariants({ variant, size, className })),
3038
- ...props
3039
- }
3040
- );
3041
- }
3042
1517
  function Dialog({ ...props }) {
3043
1518
  return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Root, { "data-slot": "dialog", ...props });
3044
1519
  }
@@ -3054,7 +1529,7 @@ function DialogOverlay({
3054
1529
  {
3055
1530
  "data-slot": "dialog-overlay",
3056
1531
  "data-privana": true,
3057
- className: cn(
1532
+ className: chunkRDMJGMI3_cjs.cn(
3058
1533
  "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
3059
1534
  className
3060
1535
  ),
@@ -3076,7 +1551,7 @@ function DialogContent({
3076
1551
  {
3077
1552
  "data-slot": "dialog-content",
3078
1553
  "data-privana": true,
3079
- className: cn(
1554
+ className: chunkRDMJGMI3_cjs.cn(
3080
1555
  "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
3081
1556
  className
3082
1557
  ),
@@ -3104,7 +1579,7 @@ function DialogHeader({ className, ...props }) {
3104
1579
  "div",
3105
1580
  {
3106
1581
  "data-slot": "dialog-header",
3107
- className: cn("flex flex-col gap-2 text-center sm:text-left", className),
1582
+ className: chunkRDMJGMI3_cjs.cn("flex flex-col gap-2 text-center sm:text-left", className),
3108
1583
  ...props
3109
1584
  }
3110
1585
  );
@@ -3114,7 +1589,7 @@ function DialogTitle({ className, ...props }) {
3114
1589
  DialogPrimitive__namespace.Title,
3115
1590
  {
3116
1591
  "data-slot": "dialog-title",
3117
- className: cn("text-lg leading-none font-semibold", className),
1592
+ className: chunkRDMJGMI3_cjs.cn("text-lg leading-none font-semibold", className),
3118
1593
  ...props
3119
1594
  }
3120
1595
  );
@@ -3127,7 +1602,7 @@ function DialogDescription({
3127
1602
  DialogPrimitive__namespace.Description,
3128
1603
  {
3129
1604
  "data-slot": "dialog-description",
3130
- className: cn("text-muted-foreground text-sm", className),
1605
+ className: chunkRDMJGMI3_cjs.cn("text-muted-foreground text-sm", className),
3131
1606
  ...props
3132
1607
  }
3133
1608
  );
@@ -3482,7 +1957,7 @@ function DepositForm({
3482
1957
  onSuccess
3483
1958
  }) {
3484
1959
  const { isConnected, address } = wagmi.useAccount();
3485
- const { chains, getChainById: getChainById2 } = usePrivanaContext();
1960
+ const { chains, getChainById: getChainById2 } = chunkRDMJGMI3_cjs.usePrivanaContext();
3486
1961
  const [amount, setAmount] = react.useState("");
3487
1962
  const [showSuccess, setShowSuccess] = react.useState(false);
3488
1963
  const [showTimeout, setShowTimeout] = react.useState(false);
@@ -3507,7 +1982,7 @@ function DepositForm({
3507
1982
  }
3508
1983
  });
3509
1984
  const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
3510
- const formattedWalletBalance = walletBalance ? formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
1985
+ const formattedWalletBalance = walletBalance ? chunkRDMJGMI3_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
3511
1986
  const handleMaxClick = () => {
3512
1987
  if (formattedWalletBalance && parseFloat(formattedWalletBalance) > 0) {
3513
1988
  setAmount(formattedWalletBalance.replace(/[\s\u2009]/g, ""));
@@ -3515,7 +1990,7 @@ function DepositForm({
3515
1990
  };
3516
1991
  const hasValidAmount = amount && parseFloat(amount) > 0;
3517
1992
  const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
3518
- const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null && parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
1993
+ const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null && chunkRDMJGMI3_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
3519
1994
  const {
3520
1995
  txHash,
3521
1996
  isGettingAddress,
@@ -3600,7 +2075,7 @@ function DepositForm({
3600
2075
  const handleSubmit = async () => {
3601
2076
  if (!amount || !selectedToken || exceedsBalance) return;
3602
2077
  setCancelled(false);
3603
- const amountInWei = parseTokenAmount(amount, selectedToken.decimals);
2078
+ const amountInWei = chunkRDMJGMI3_cjs.parseTokenAmount(amount, selectedToken.decimals);
3604
2079
  await deposit({
3605
2080
  tokenId: selectedToken.id,
3606
2081
  amount: amountInWei
@@ -3703,7 +2178,7 @@ function DepositForm({
3703
2178
  setAmount(value);
3704
2179
  }
3705
2180
  },
3706
- className: cn(
2181
+ className: chunkRDMJGMI3_cjs.cn(
3707
2182
  "text-foreground flex-1 bg-transparent text-sm outline-none",
3708
2183
  "placeholder:text-muted-foreground/50"
3709
2184
  )
@@ -3730,7 +2205,7 @@ function DepositForm({
3730
2205
  {
3731
2206
  onClick: handleSubmit,
3732
2207
  disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
3733
- className: cn(
2208
+ className: chunkRDMJGMI3_cjs.cn(
3734
2209
  "flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
3735
2210
  "bg-primary text-primary-foreground hover:bg-primary/90",
3736
2211
  "disabled:cursor-not-allowed disabled:opacity-50"
@@ -3747,7 +2222,7 @@ function WithdrawForm({
3747
2222
  onUnsafeToCloseChange
3748
2223
  }) {
3749
2224
  const { isConnected, address } = wagmi.useAccount();
3750
- const { chains, getChainById: getChainById2 } = usePrivanaContext();
2225
+ const { chains, getChainById: getChainById2 } = chunkRDMJGMI3_cjs.usePrivanaContext();
3751
2226
  const [amount, setAmount] = react.useState("");
3752
2227
  const [showSuccess, setShowSuccess] = react.useState(false);
3753
2228
  const [showTimeout, setShowTimeout] = react.useState(false);
@@ -3760,7 +2235,7 @@ function WithdrawForm({
3760
2235
  } = useBalance({
3761
2236
  tokenId: selectedToken.id
3762
2237
  });
3763
- const formattedBalance = formatTokenAmount(balanceWei, selectedToken.decimals);
2238
+ const formattedBalance = chunkRDMJGMI3_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
3764
2239
  const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
3765
2240
  onProcessingSuccess: () => {
3766
2241
  setAmount("");
@@ -3771,7 +2246,7 @@ function WithdrawForm({
3771
2246
  setShowTimeout(true);
3772
2247
  }
3773
2248
  });
3774
- const explorerUrl = address && targetChain ? getExplorerAddressUrl(targetChain.id, address) : void 0;
2249
+ const explorerUrl = address && targetChain ? chunkRDMJGMI3_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
3775
2250
  const getStepStatus = (step, after) => {
3776
2251
  if (currentStep === step) return "active";
3777
2252
  if (after.includes(currentStep)) return "completed";
@@ -3815,7 +2290,7 @@ function WithdrawForm({
3815
2290
  const handleWithdraw = async () => {
3816
2291
  if (!amount || !selectedToken || exceedsBalance) return;
3817
2292
  setCancelled(false);
3818
- const amountInWei = parseTokenAmount(amount, selectedToken.decimals);
2293
+ const amountInWei = chunkRDMJGMI3_cjs.parseTokenAmount(amount, selectedToken.decimals);
3819
2294
  await withdraw({
3820
2295
  tokenId: selectedToken.id,
3821
2296
  amount: amountInWei
@@ -3828,7 +2303,7 @@ function WithdrawForm({
3828
2303
  };
3829
2304
  const hasValidAmount = amount && parseFloat(amount) > 0;
3830
2305
  const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
3831
- const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError && parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
2306
+ const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError && chunkRDMJGMI3_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
3832
2307
  const getButtonText = () => {
3833
2308
  if (!isConnected) return "Connect Wallet";
3834
2309
  return "Withdraw";
@@ -3911,7 +2386,7 @@ function WithdrawForm({
3911
2386
  setAmount(value);
3912
2387
  }
3913
2388
  },
3914
- className: cn(
2389
+ className: chunkRDMJGMI3_cjs.cn(
3915
2390
  "text-foreground flex-1 bg-transparent text-sm outline-none",
3916
2391
  "placeholder:text-muted-foreground/50"
3917
2392
  )
@@ -3938,7 +2413,7 @@ function WithdrawForm({
3938
2413
  {
3939
2414
  onClick: handleWithdraw,
3940
2415
  disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
3941
- className: cn(
2416
+ className: chunkRDMJGMI3_cjs.cn(
3942
2417
  "flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
3943
2418
  "bg-primary text-primary-foreground hover:bg-primary/90",
3944
2419
  "disabled:cursor-not-allowed disabled:opacity-50"
@@ -3993,7 +2468,7 @@ function ChevronDown({ collapsed }) {
3993
2468
  width: "12",
3994
2469
  height: "6",
3995
2470
  viewBox: "0 0 12 6",
3996
- className: cn("transition-transform", collapsed && "-rotate-90"),
2471
+ className: chunkRDMJGMI3_cjs.cn("transition-transform", collapsed && "-rotate-90"),
3997
2472
  children: /* @__PURE__ */ jsxRuntime.jsx(
3998
2473
  "path",
3999
2474
  {
@@ -4019,15 +2494,15 @@ function BalanceCards({
4019
2494
  tokenId: selectedToken.id
4020
2495
  });
4021
2496
  const { totalLocked, isLoading: lockedLoading } = useLockedFunds({ enabled: showLockedFunds });
4022
- const formattedBalance = formatTokenAmount(balanceWei, selectedToken.decimals);
4023
- const formattedLocked = showLockedFunds ? formatTokenAmount(String(totalLocked), selectedToken.decimals) : "0.00";
4024
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex gap-2", disabled && "opacity-50"), children: [
2497
+ const formattedBalance = chunkRDMJGMI3_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
2498
+ const formattedLocked = showLockedFunds ? chunkRDMJGMI3_cjs.formatTokenAmount(String(totalLocked), selectedToken.decimals) : "0.00";
2499
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkRDMJGMI3_cjs.cn("flex gap-2", disabled && "opacity-50"), children: [
4025
2500
  /* @__PURE__ */ jsxRuntime.jsxs(
4026
2501
  "button",
4027
2502
  {
4028
2503
  onClick: onBalanceClick,
4029
2504
  disabled,
4030
- className: cn(
2505
+ className: chunkRDMJGMI3_cjs.cn(
4031
2506
  "bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
4032
2507
  disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
4033
2508
  ),
@@ -4048,7 +2523,7 @@ function BalanceCards({
4048
2523
  {
4049
2524
  onClick: onLockedFundsClick,
4050
2525
  disabled,
4051
- className: cn(
2526
+ className: chunkRDMJGMI3_cjs.cn(
4052
2527
  "bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
4053
2528
  disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
4054
2529
  ),
@@ -4074,7 +2549,7 @@ function Tabs({
4074
2549
  return /* @__PURE__ */ jsxRuntime.jsxs(
4075
2550
  "div",
4076
2551
  {
4077
- className: cn(
2552
+ className: chunkRDMJGMI3_cjs.cn(
4078
2553
  "bg-muted relative flex gap-2 overflow-hidden rounded-[10px] p-1",
4079
2554
  disabled && "opacity-50"
4080
2555
  ),
@@ -4082,7 +2557,7 @@ function Tabs({
4082
2557
  /* @__PURE__ */ jsxRuntime.jsx(
4083
2558
  "div",
4084
2559
  {
4085
- className: cn(
2560
+ className: chunkRDMJGMI3_cjs.cn(
4086
2561
  "bg-input absolute top-1 bottom-1 left-1 w-[calc(50%-8px)] rounded-md transition-transform duration-200",
4087
2562
  activeTab === "withdraw" && "translate-x-[calc(100%+8px)]"
4088
2563
  )
@@ -4093,7 +2568,7 @@ function Tabs({
4093
2568
  {
4094
2569
  onClick: () => !disabled && onTabChange("deposit"),
4095
2570
  disabled,
4096
- className: cn(
2571
+ className: chunkRDMJGMI3_cjs.cn(
4097
2572
  "relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
4098
2573
  activeTab === "deposit" ? "text-foreground" : "text-muted-foreground",
4099
2574
  disabled ? "cursor-not-allowed" : "cursor-pointer"
@@ -4106,7 +2581,7 @@ function Tabs({
4106
2581
  {
4107
2582
  onClick: () => !disabled && onTabChange("withdraw"),
4108
2583
  disabled,
4109
- className: cn(
2584
+ className: chunkRDMJGMI3_cjs.cn(
4110
2585
  "relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
4111
2586
  activeTab === "withdraw" ? "text-foreground" : "text-muted-foreground",
4112
2587
  disabled ? "cursor-not-allowed" : "cursor-pointer"
@@ -4119,14 +2594,14 @@ function Tabs({
4119
2594
  );
4120
2595
  }
4121
2596
  function LockedFundsView({ onBack }) {
4122
- const { getTokenById } = usePrivanaContext();
2597
+ const { getTokenById } = chunkRDMJGMI3_cjs.usePrivanaContext();
4123
2598
  const { locks, isLoading } = useLockedFunds();
4124
2599
  const { unlockFunds, unlockAllExpired, isPending } = useUnlockFunds();
4125
2600
  const [collapsedSections, setCollapsedSections] = react.useState({});
4126
2601
  const sections = react.useMemo(() => {
4127
2602
  const sectionMap = {};
4128
2603
  locks.forEach((lock) => {
4129
- const serviceName = shortenAddress(lock.service_address);
2604
+ const serviceName = chunkRDMJGMI3_cjs.shortenAddress(lock.service_address);
4130
2605
  if (!sectionMap[lock.service_address]) {
4131
2606
  sectionMap[lock.service_address] = {
4132
2607
  title: `Service ${serviceName}`,
@@ -4135,9 +2610,9 @@ function LockedFundsView({ onBack }) {
4135
2610
  }
4136
2611
  sectionMap[lock.service_address].items.push({
4137
2612
  lockId: lock.lock_id,
4138
- amount: formatTokenAmount(String(lock.amount), getTokenById(lock.token_id)?.decimals ?? 18),
2613
+ amount: chunkRDMJGMI3_cjs.formatTokenAmount(String(lock.amount), getTokenById(lock.token_id)?.decimals ?? 18),
4139
2614
  serviceAddress: lock.service_address,
4140
- time: lock.is_expired ? "Click to unlock" : formatTimeRemaining(lock.expiry),
2615
+ time: lock.is_expired ? "Click to unlock" : chunkRDMJGMI3_cjs.formatTimeRemaining(lock.expiry),
4141
2616
  isExpired: lock.is_expired
4142
2617
  });
4143
2618
  });
@@ -4184,7 +2659,7 @@ function LockedFundsView({ onBack }) {
4184
2659
  !collapsedSections[section.title] && section.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
4185
2660
  "div",
4186
2661
  {
4187
- className: cn(
2662
+ className: chunkRDMJGMI3_cjs.cn(
4188
2663
  "flex items-center justify-between gap-3 rounded-lg p-3",
4189
2664
  item.isExpired && "bg-secondary"
4190
2665
  ),
@@ -4198,7 +2673,7 @@ function LockedFundsView({ onBack }) {
4198
2673
  ] }),
4199
2674
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-xs", children: [
4200
2675
  "Service: ",
4201
- shortenAddress(item.serviceAddress)
2676
+ chunkRDMJGMI3_cjs.shortenAddress(item.serviceAddress)
4202
2677
  ] })
4203
2678
  ] })
4204
2679
  ] }),
@@ -4239,7 +2714,7 @@ function BalanceTokenRow({ token }) {
4239
2714
  const { balanceWei, isLoading } = useBalance({
4240
2715
  tokenId: token.id
4241
2716
  });
4242
- const formattedBalance = formatTokenAmount(balanceWei, token.decimals);
2717
+ const formattedBalance = chunkRDMJGMI3_cjs.formatTokenAmount(balanceWei, token.decimals);
4243
2718
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-2 rounded-lg px-3 py-2.5", children: [
4244
2719
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-[18px] w-[18px] overflow-hidden rounded-full", children: getTokenIcon(token.symbol, 18) }),
4245
2720
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground flex-1 text-sm", children: token.symbol }),
@@ -4247,7 +2722,7 @@ function BalanceTokenRow({ token }) {
4247
2722
  ] });
4248
2723
  }
4249
2724
  function BalanceDetailsView({ onBack }) {
4250
- const { enabledTokens, chains } = usePrivanaContext();
2725
+ const { enabledTokens, chains } = chunkRDMJGMI3_cjs.usePrivanaContext();
4251
2726
  const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
4252
2727
  const chainTokens = react.useMemo(() => {
4253
2728
  return enabledTokens.filter((t) => t.chainId === selectedChainId);
@@ -4273,7 +2748,7 @@ function BalanceDetailsView({ onBack }) {
4273
2748
  "button",
4274
2749
  {
4275
2750
  onClick: () => setSelectedChainId(chain.id),
4276
- className: cn(
2751
+ className: chunkRDMJGMI3_cjs.cn(
4277
2752
  "hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
4278
2753
  isSelected && "bg-secondary"
4279
2754
  ),
@@ -4314,12 +2789,12 @@ function TokenRow({
4314
2789
  query: { enabled: !!address && !isNative }
4315
2790
  });
4316
2791
  const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
4317
- const formattedBalance = walletBalance ? formatTokenAmount(walletBalance.toString(), token.decimals) : "0.00";
2792
+ const formattedBalance = walletBalance ? chunkRDMJGMI3_cjs.formatTokenAmount(walletBalance.toString(), token.decimals) : "0.00";
4318
2793
  return /* @__PURE__ */ jsxRuntime.jsxs(
4319
2794
  "button",
4320
2795
  {
4321
2796
  onClick,
4322
- className: cn(
2797
+ className: chunkRDMJGMI3_cjs.cn(
4323
2798
  "hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
4324
2799
  isSelected && "bg-secondary"
4325
2800
  ),
@@ -4336,7 +2811,7 @@ function TokenSelectorView({
4336
2811
  onSelect,
4337
2812
  selectedTokenId
4338
2813
  }) {
4339
- const { enabledTokens, chains } = usePrivanaContext();
2814
+ const { enabledTokens, chains } = chunkRDMJGMI3_cjs.usePrivanaContext();
4340
2815
  const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
4341
2816
  const chainTokens = react.useMemo(() => {
4342
2817
  return enabledTokens.filter((t) => t.chainId === selectedChainId);
@@ -4366,7 +2841,7 @@ function TokenSelectorView({
4366
2841
  "button",
4367
2842
  {
4368
2843
  onClick: () => setSelectedChainId(chain.id),
4369
- className: cn(
2844
+ className: chunkRDMJGMI3_cjs.cn(
4370
2845
  "hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
4371
2846
  isSelected && "bg-secondary"
4372
2847
  ),
@@ -4401,7 +2876,7 @@ function ModalBody({
4401
2876
  defaultTab = "deposit",
4402
2877
  onDepositSuccess
4403
2878
  }) {
4404
- const { defaultToken, tokensStatus } = usePrivanaContext();
2879
+ const { defaultToken, tokensStatus } = chunkRDMJGMI3_cjs.usePrivanaContext();
4405
2880
  const [selectedToken, setSelectedToken] = react.useState(defaultToken);
4406
2881
  const [activeTab, setActiveTab] = react.useState(defaultTab);
4407
2882
  const [currentView, setCurrentView] = react.useState("main");
@@ -4459,7 +2934,7 @@ function ModalBody({
4459
2934
  );
4460
2935
  }
4461
2936
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 pb-4", children: [
4462
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(
2937
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkRDMJGMI3_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(
4463
2938
  BalanceCards,
4464
2939
  {
4465
2940
  selectedToken,
@@ -4469,7 +2944,7 @@ function ModalBody({
4469
2944
  disabled: isInteractionPending
4470
2945
  }
4471
2946
  ) }),
4472
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(Tabs, { activeTab, onTabChange: setActiveTab, disabled: isInteractionPending }) }),
2947
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkRDMJGMI3_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(Tabs, { activeTab, onTabChange: setActiveTab, disabled: isInteractionPending }) }),
4473
2948
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted rounded-[10px] p-5", children: activeTab === "deposit" ? /* @__PURE__ */ jsxRuntime.jsx(
4474
2949
  DepositForm,
4475
2950
  {
@@ -4530,7 +3005,7 @@ function PrivanaModal({
4530
3005
  onClick: handleClose,
4531
3006
  disabled: isCloseBlocked,
4532
3007
  "aria-label": "Close",
4533
- className: cn(
3008
+ className: chunkRDMJGMI3_cjs.cn(
4534
3009
  "absolute top-6 right-5 z-20 flex h-6 w-6 items-center justify-center transition-colors",
4535
3010
  isCloseBlocked ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
4536
3011
  ),
@@ -4586,7 +3061,7 @@ function PrivanaInlineModal({
4586
3061
  "div",
4587
3062
  {
4588
3063
  "data-privana": true,
4589
- className: cn(
3064
+ className: chunkRDMJGMI3_cjs.cn(
4590
3065
  "bg-card flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
4591
3066
  className
4592
3067
  ),
@@ -4621,12 +3096,12 @@ function PrivanaButton({
4621
3096
  }
4622
3097
  const handleClick = () => setModalOpen(true);
4623
3098
  const buttonElement = renderButton ? renderButton({ onClick: handleClick, isOpen: modalOpen }) : /* @__PURE__ */ jsxRuntime.jsx(
4624
- Button,
3099
+ chunkRDMJGMI3_cjs.Button,
4625
3100
  {
4626
3101
  variant,
4627
3102
  size,
4628
3103
  asChild,
4629
- className: cn(className),
3104
+ className: chunkRDMJGMI3_cjs.cn(className),
4630
3105
  onClick: handleClick,
4631
3106
  disabled: !isConnected,
4632
3107
  ...buttonProps,
@@ -4652,70 +3127,204 @@ function Skeleton({ className, ...props }) {
4652
3127
  "div",
4653
3128
  {
4654
3129
  "data-slot": "skeleton",
4655
- className: cn("bg-accent animate-pulse rounded-md", className),
3130
+ className: chunkRDMJGMI3_cjs.cn("bg-accent animate-pulse rounded-md", className),
4656
3131
  ...props
4657
3132
  }
4658
3133
  );
4659
3134
  }
4660
3135
 
4661
- exports.AccountingApiError = AccountingApiError;
4662
- exports.Button = Button;
4663
- exports.HOSTED_AUTH_CLOCK_SKEW_MS = HOSTED_AUTH_CLOCK_SKEW_MS;
4664
- exports.HostedAuthError = HostedAuthError;
4665
- exports.HostedAuthRequiredError = HostedAuthRequiredError;
4666
- exports.HostedAuthStateMismatchError = HostedAuthStateMismatchError;
4667
- exports.HttpClient = HttpClient;
3136
+ Object.defineProperty(exports, "AccountingApiError", {
3137
+ enumerable: true,
3138
+ get: function () { return chunkRDMJGMI3_cjs.AccountingApiError; }
3139
+ });
3140
+ Object.defineProperty(exports, "Button", {
3141
+ enumerable: true,
3142
+ get: function () { return chunkRDMJGMI3_cjs.Button; }
3143
+ });
3144
+ Object.defineProperty(exports, "HOSTED_AUTH_CLOCK_SKEW_MS", {
3145
+ enumerable: true,
3146
+ get: function () { return chunkRDMJGMI3_cjs.HOSTED_AUTH_CLOCK_SKEW_MS; }
3147
+ });
3148
+ Object.defineProperty(exports, "HostedAuthError", {
3149
+ enumerable: true,
3150
+ get: function () { return chunkRDMJGMI3_cjs.HostedAuthError; }
3151
+ });
3152
+ Object.defineProperty(exports, "HostedAuthRequiredError", {
3153
+ enumerable: true,
3154
+ get: function () { return chunkRDMJGMI3_cjs.HostedAuthRequiredError; }
3155
+ });
3156
+ Object.defineProperty(exports, "HostedAuthStateMismatchError", {
3157
+ enumerable: true,
3158
+ get: function () { return chunkRDMJGMI3_cjs.HostedAuthStateMismatchError; }
3159
+ });
3160
+ Object.defineProperty(exports, "HttpClient", {
3161
+ enumerable: true,
3162
+ get: function () { return chunkRDMJGMI3_cjs.HttpClient; }
3163
+ });
3164
+ Object.defineProperty(exports, "NETWORK_CONFIG", {
3165
+ enumerable: true,
3166
+ get: function () { return chunkRDMJGMI3_cjs.NETWORK_CONFIG; }
3167
+ });
3168
+ Object.defineProperty(exports, "NetworkError", {
3169
+ enumerable: true,
3170
+ get: function () { return chunkRDMJGMI3_cjs.NetworkError; }
3171
+ });
3172
+ Object.defineProperty(exports, "PrivanaClient", {
3173
+ enumerable: true,
3174
+ get: function () { return chunkRDMJGMI3_cjs.PrivanaClient; }
3175
+ });
3176
+ Object.defineProperty(exports, "PrivanaProvider", {
3177
+ enumerable: true,
3178
+ get: function () { return chunkRDMJGMI3_cjs.PrivanaProvider; }
3179
+ });
3180
+ Object.defineProperty(exports, "SUPPORTED_CHAINS", {
3181
+ enumerable: true,
3182
+ get: function () { return chunkRDMJGMI3_cjs.SUPPORTED_CHAINS; }
3183
+ });
3184
+ Object.defineProperty(exports, "SiweAuthProvider", {
3185
+ enumerable: true,
3186
+ get: function () { return chunkRDMJGMI3_cjs.SiweAuthProvider; }
3187
+ });
3188
+ Object.defineProperty(exports, "ValidationError", {
3189
+ enumerable: true,
3190
+ get: function () { return chunkRDMJGMI3_cjs.ValidationError; }
3191
+ });
3192
+ Object.defineProperty(exports, "applyRefreshResponse", {
3193
+ enumerable: true,
3194
+ get: function () { return chunkRDMJGMI3_cjs.applyRefreshResponse; }
3195
+ });
3196
+ Object.defineProperty(exports, "buildHostedAuthSession", {
3197
+ enumerable: true,
3198
+ get: function () { return chunkRDMJGMI3_cjs.buildHostedAuthSession; }
3199
+ });
3200
+ Object.defineProperty(exports, "buttonVariants", {
3201
+ enumerable: true,
3202
+ get: function () { return chunkRDMJGMI3_cjs.buttonVariants; }
3203
+ });
3204
+ Object.defineProperty(exports, "clearHostedAuthPendingTransaction", {
3205
+ enumerable: true,
3206
+ get: function () { return chunkRDMJGMI3_cjs.clearHostedAuthPendingTransaction; }
3207
+ });
3208
+ Object.defineProperty(exports, "createHostedAuthPendingStorageKey", {
3209
+ enumerable: true,
3210
+ get: function () { return chunkRDMJGMI3_cjs.createHostedAuthPendingStorageKey; }
3211
+ });
3212
+ Object.defineProperty(exports, "createHostedAuthState", {
3213
+ enumerable: true,
3214
+ get: function () { return chunkRDMJGMI3_cjs.createHostedAuthState; }
3215
+ });
3216
+ Object.defineProperty(exports, "createHostedAuthStorageKey", {
3217
+ enumerable: true,
3218
+ get: function () { return chunkRDMJGMI3_cjs.createHostedAuthStorageKey; }
3219
+ });
3220
+ Object.defineProperty(exports, "createPkceChallenge", {
3221
+ enumerable: true,
3222
+ get: function () { return chunkRDMJGMI3_cjs.createPkceChallenge; }
3223
+ });
3224
+ Object.defineProperty(exports, "createPkceVerifier", {
3225
+ enumerable: true,
3226
+ get: function () { return chunkRDMJGMI3_cjs.createPkceVerifier; }
3227
+ });
3228
+ Object.defineProperty(exports, "getAccountingContract", {
3229
+ enumerable: true,
3230
+ get: function () { return chunkRDMJGMI3_cjs.getAccountingContract; }
3231
+ });
3232
+ Object.defineProperty(exports, "getApiUrl", {
3233
+ enumerable: true,
3234
+ get: function () { return chunkRDMJGMI3_cjs.getApiUrl; }
3235
+ });
3236
+ Object.defineProperty(exports, "getChainById", {
3237
+ enumerable: true,
3238
+ get: function () { return chunkRDMJGMI3_cjs.getChainById; }
3239
+ });
3240
+ Object.defineProperty(exports, "getChainId", {
3241
+ enumerable: true,
3242
+ get: function () { return chunkRDMJGMI3_cjs.getChainId; }
3243
+ });
3244
+ Object.defineProperty(exports, "getExplorerAddressUrl", {
3245
+ enumerable: true,
3246
+ get: function () { return chunkRDMJGMI3_cjs.getExplorerAddressUrl; }
3247
+ });
3248
+ Object.defineProperty(exports, "isHostedAuthRefreshActive", {
3249
+ enumerable: true,
3250
+ get: function () { return chunkRDMJGMI3_cjs.isHostedAuthRefreshActive; }
3251
+ });
3252
+ Object.defineProperty(exports, "isHostedAuthSessionActive", {
3253
+ enumerable: true,
3254
+ get: function () { return chunkRDMJGMI3_cjs.isHostedAuthSessionActive; }
3255
+ });
3256
+ Object.defineProperty(exports, "normalizeAddress", {
3257
+ enumerable: true,
3258
+ get: function () { return chunkRDMJGMI3_cjs.normalizeAddress; }
3259
+ });
3260
+ Object.defineProperty(exports, "normalizeHex", {
3261
+ enumerable: true,
3262
+ get: function () { return chunkRDMJGMI3_cjs.normalizeHex; }
3263
+ });
3264
+ Object.defineProperty(exports, "parseHostedAuthCallback", {
3265
+ enumerable: true,
3266
+ get: function () { return chunkRDMJGMI3_cjs.parseHostedAuthCallback; }
3267
+ });
3268
+ Object.defineProperty(exports, "persistHostedAuthPendingTransaction", {
3269
+ enumerable: true,
3270
+ get: function () { return chunkRDMJGMI3_cjs.persistHostedAuthPendingTransaction; }
3271
+ });
3272
+ Object.defineProperty(exports, "readHostedAuthPendingTransaction", {
3273
+ enumerable: true,
3274
+ get: function () { return chunkRDMJGMI3_cjs.readHostedAuthPendingTransaction; }
3275
+ });
3276
+ Object.defineProperty(exports, "readStoredHostedAuthSession", {
3277
+ enumerable: true,
3278
+ get: function () { return chunkRDMJGMI3_cjs.readStoredHostedAuthSession; }
3279
+ });
3280
+ Object.defineProperty(exports, "stripHostedAuthCallbackParams", {
3281
+ enumerable: true,
3282
+ get: function () { return chunkRDMJGMI3_cjs.stripHostedAuthCallbackParams; }
3283
+ });
3284
+ Object.defineProperty(exports, "syncHostedAuthSessionToClient", {
3285
+ enumerable: true,
3286
+ get: function () { return chunkRDMJGMI3_cjs.syncHostedAuthSessionToClient; }
3287
+ });
3288
+ Object.defineProperty(exports, "useDepositVerification", {
3289
+ enumerable: true,
3290
+ get: function () { return chunkRDMJGMI3_cjs.useDepositVerification; }
3291
+ });
3292
+ Object.defineProperty(exports, "usePrivanaContext", {
3293
+ enumerable: true,
3294
+ get: function () { return chunkRDMJGMI3_cjs.usePrivanaContext; }
3295
+ });
3296
+ Object.defineProperty(exports, "useSafeAccount", {
3297
+ enumerable: true,
3298
+ get: function () { return chunkRDMJGMI3_cjs.useSafeAccount; }
3299
+ });
3300
+ Object.defineProperty(exports, "useSafePrivanaContext", {
3301
+ enumerable: true,
3302
+ get: function () { return chunkRDMJGMI3_cjs.useSafePrivanaContext; }
3303
+ });
3304
+ Object.defineProperty(exports, "useSiweAuth", {
3305
+ enumerable: true,
3306
+ get: function () { return chunkRDMJGMI3_cjs.useSiweAuth; }
3307
+ });
4668
3308
  exports.LOCK_TYPES = LOCK_TYPES;
4669
3309
  exports.MODIFY_LOCK_TYPES = MODIFY_LOCK_TYPES;
4670
- exports.NETWORK_CONFIG = NETWORK_CONFIG;
4671
- exports.NetworkError = NetworkError;
4672
3310
  exports.PrivanaButton = PrivanaButton;
4673
- exports.PrivanaClient = PrivanaClient;
4674
3311
  exports.PrivanaInlineModal = PrivanaInlineModal;
4675
3312
  exports.PrivanaModal = PrivanaModal;
4676
- exports.PrivanaProvider = PrivanaProvider;
4677
- exports.SUPPORTED_CHAINS = SUPPORTED_CHAINS;
4678
- exports.SiweAuthProvider = SiweAuthProvider;
4679
3313
  exports.Skeleton = Skeleton;
4680
3314
  exports.TRANSFER_LOCKED_TYPES = TRANSFER_LOCKED_TYPES;
4681
3315
  exports.TRANSFER_TYPES = TRANSFER_TYPES;
4682
- exports.ValidationError = ValidationError;
4683
3316
  exports.WITHDRAW_FROM_LOCK_TYPES = WITHDRAW_FROM_LOCK_TYPES;
4684
3317
  exports.WITHDRAW_TYPES = WITHDRAW_TYPES;
4685
- exports.applyRefreshResponse = applyRefreshResponse;
4686
- exports.buildHostedAuthSession = buildHostedAuthSession;
4687
- exports.buttonVariants = buttonVariants;
4688
- exports.clearHostedAuthPendingTransaction = clearHostedAuthPendingTransaction;
4689
3318
  exports.createDomain = createDomain;
4690
- exports.createHostedAuthPendingStorageKey = createHostedAuthPendingStorageKey;
4691
- exports.createHostedAuthState = createHostedAuthState;
4692
- exports.createHostedAuthStorageKey = createHostedAuthStorageKey;
4693
3319
  exports.createLockExpiry = createLockExpiry;
4694
- exports.createPkceChallenge = createPkceChallenge;
4695
- exports.createPkceVerifier = createPkceVerifier;
4696
- exports.getAccountingContract = getAccountingContract;
4697
- exports.getApiUrl = getApiUrl;
4698
- exports.getChainById = getChainById;
4699
3320
  exports.getChainIcon = getChainIcon;
4700
- exports.getChainId = getChainId;
4701
- exports.getExplorerAddressUrl = getExplorerAddressUrl;
4702
3321
  exports.getTokenIcon = getTokenIcon;
4703
- exports.isHostedAuthRefreshActive = isHostedAuthRefreshActive;
4704
- exports.isHostedAuthSessionActive = isHostedAuthSessionActive;
4705
- exports.normalizeAddress = normalizeAddress;
4706
- exports.normalizeHex = normalizeHex;
4707
- exports.parseHostedAuthCallback = parseHostedAuthCallback;
4708
- exports.persistHostedAuthPendingTransaction = persistHostedAuthPendingTransaction;
4709
- exports.readHostedAuthPendingTransaction = readHostedAuthPendingTransaction;
4710
- exports.readStoredHostedAuthSession = readStoredHostedAuthSession;
4711
3322
  exports.signLockMessage = signLockMessage;
4712
3323
  exports.signModifyLockMessage = signModifyLockMessage;
4713
3324
  exports.signTransferLockedMessage = signTransferLockedMessage;
4714
3325
  exports.signTransferMessage = signTransferMessage;
4715
3326
  exports.signWithdrawFromLockMessage = signWithdrawFromLockMessage;
4716
3327
  exports.signWithdrawMessage = signWithdrawMessage;
4717
- exports.stripHostedAuthCallbackParams = stripHostedAuthCallbackParams;
4718
- exports.syncHostedAuthSessionToClient = syncHostedAuthSessionToClient;
4719
3328
  exports.useBalance = useBalance;
4720
3329
  exports.useBatchBalances = useBatchBalances;
4721
3330
  exports.useDeposit = useDeposit;
@@ -4727,10 +3336,6 @@ exports.useLockedFunds = useLockedFunds;
4727
3336
  exports.useModifyLock = useModifyLock;
4728
3337
  exports.usePendingWithdrawals = usePendingWithdrawals;
4729
3338
  exports.usePrivanaClient = usePrivanaClient;
4730
- exports.usePrivanaContext = usePrivanaContext;
4731
- exports.useSafeAccount = useSafeAccount;
4732
- exports.useSafePrivanaContext = useSafePrivanaContext;
4733
- exports.useSiweAuth = useSiweAuth;
4734
3339
  exports.useTokenInfo = useTokenInfo;
4735
3340
  exports.useTokenList = useTokenList;
4736
3341
  exports.useTotalLockedBalance = useTotalLockedBalance;