@oasisprotocol/privana-sdk 0.5.0 → 0.5.2

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,7 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkACLJPC75_cjs = require('./chunk-ACLJPC75.cjs');
4
+ var chunkUHXVYWTF_cjs = require('./chunk-UHXVYWTF.cjs');
5
5
  var react = require('react');
6
6
  var reactQuery = require('@tanstack/react-query');
7
7
  var wagmi = require('wagmi');
@@ -33,216 +33,20 @@ function _interopNamespace(e) {
33
33
 
34
34
  var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
35
35
 
36
- // src/sdk/signatures/eip712-types.ts
37
- function createDomain(chainId, verifyingContract) {
38
- return {
39
- name: "AccountingModule",
40
- version: "1",
41
- chainId,
42
- verifyingContract
43
- };
44
- }
45
- var LOCK_TYPES = {
46
- Lock: [
47
- { name: "serviceAddress", type: "address" },
48
- { name: "tokenId", type: "bytes32" },
49
- { name: "amount", type: "uint256" },
50
- { name: "expiry", type: "uint256" },
51
- { name: "nonce", type: "uint256" }
52
- ]
53
- };
54
- var TRANSFER_TYPES = {
55
- Transfer: [
56
- { name: "toAddress", type: "address" },
57
- { name: "tokenId", type: "bytes32" },
58
- { name: "amount", type: "uint256" },
59
- { name: "nonce", type: "uint256" }
60
- ]
61
- };
62
- var TRANSFER_LOCKED_TYPES = {
63
- TransferLocked: [
64
- { name: "userAddress", type: "address" },
65
- { name: "toAddress", type: "address" },
66
- { name: "lockId", type: "uint256" },
67
- { name: "amount", type: "uint256" },
68
- { name: "nonce", type: "uint256" },
69
- { name: "serviceAddress", type: "address" }
70
- ]
71
- };
72
- var WITHDRAW_TYPES = {
73
- Withdraw: [
74
- { name: "tokenId", type: "bytes32" },
75
- { name: "amount", type: "uint256" },
76
- { name: "nonce", type: "uint256" }
77
- ]
78
- };
79
- var MODIFY_LOCK_TYPES = {
80
- ModifyLock: [
81
- { name: "lockId", type: "uint256" },
82
- { name: "amount", type: "uint256" },
83
- { name: "newExpiry", type: "uint256" },
84
- { name: "nonce", type: "uint256" }
85
- ]
86
- };
87
- var WITHDRAW_FROM_LOCK_TYPES = {
88
- WithdrawFromLock: [
89
- { name: "userAddress", type: "address" },
90
- { name: "toAddress", type: "address" },
91
- { name: "lockId", type: "uint256" },
92
- { name: "amount", type: "uint256" },
93
- { name: "nonce", type: "uint256" }
94
- ]
95
- };
96
-
97
- // src/sdk/signatures/sign-lock.ts
98
- async function signLockMessage({
99
- walletClient,
100
- chainId,
101
- verifyingContract,
102
- message
103
- }) {
104
- const account = walletClient.account;
105
- if (!account) {
106
- throw new Error("No account connected to wallet client");
107
- }
108
- const domain = createDomain(chainId, verifyingContract);
109
- const signature = await walletClient.signTypedData({
110
- account,
111
- domain,
112
- types: LOCK_TYPES,
113
- primaryType: "Lock",
114
- message
115
- });
116
- return signature;
117
- }
118
- function createLockExpiry(minutesFromNow = 60) {
119
- return BigInt(Math.floor(Date.now() / 1e3) + minutesFromNow * 60);
120
- }
121
-
122
- // src/sdk/signatures/sign-modify-lock.ts
123
- async function signModifyLockMessage({
124
- walletClient,
125
- chainId,
126
- verifyingContract,
127
- message
128
- }) {
129
- const account = walletClient.account;
130
- if (!account) {
131
- throw new Error("No account connected to wallet client");
132
- }
133
- const domain = createDomain(chainId, verifyingContract);
134
- const signature = await walletClient.signTypedData({
135
- account,
136
- domain,
137
- types: MODIFY_LOCK_TYPES,
138
- primaryType: "ModifyLock",
139
- message
140
- });
141
- return signature;
142
- }
143
-
144
- // src/sdk/signatures/sign-transfer.ts
145
- async function signTransferMessage({
146
- walletClient,
147
- chainId,
148
- verifyingContract,
149
- message
150
- }) {
151
- const account = walletClient.account;
152
- if (!account) {
153
- throw new Error("No account connected to wallet client");
154
- }
155
- const domain = createDomain(chainId, verifyingContract);
156
- const signature = await walletClient.signTypedData({
157
- account,
158
- domain,
159
- types: TRANSFER_TYPES,
160
- primaryType: "Transfer",
161
- message
162
- });
163
- return signature;
164
- }
165
-
166
- // src/sdk/signatures/sign-transfer-locked.ts
167
- async function signTransferLockedMessage({
168
- walletClient,
169
- chainId,
170
- verifyingContract,
171
- message
172
- }) {
173
- const account = walletClient.account;
174
- if (!account) {
175
- throw new Error("No account connected to wallet client");
176
- }
177
- const domain = createDomain(chainId, verifyingContract);
178
- const signature = await walletClient.signTypedData({
179
- account,
180
- domain,
181
- types: TRANSFER_LOCKED_TYPES,
182
- primaryType: "TransferLocked",
183
- message
184
- });
185
- return signature;
186
- }
187
-
188
- // src/sdk/signatures/sign-withdraw.ts
189
- async function signWithdrawMessage({
190
- walletClient,
191
- chainId,
192
- verifyingContract,
193
- message
194
- }) {
195
- const account = walletClient.account;
196
- if (!account) {
197
- throw new Error("No account connected to wallet client");
198
- }
199
- const domain = createDomain(chainId, verifyingContract);
200
- const signature = await walletClient.signTypedData({
201
- account,
202
- domain,
203
- types: WITHDRAW_TYPES,
204
- primaryType: "Withdraw",
205
- message
206
- });
207
- return signature;
208
- }
209
-
210
- // src/sdk/signatures/sign-withdraw-from-lock.ts
211
- async function signWithdrawFromLockMessage({
212
- walletClient,
213
- chainId,
214
- verifyingContract,
215
- message
216
- }) {
217
- const account = walletClient.account;
218
- if (!account) {
219
- throw new Error("No account connected to wallet client");
220
- }
221
- const domain = createDomain(chainId, verifyingContract);
222
- const signature = await walletClient.signTypedData({
223
- account,
224
- domain,
225
- types: WITHDRAW_FROM_LOCK_TYPES,
226
- primaryType: "WithdrawFromLock",
227
- message
228
- });
229
- return signature;
230
- }
231
-
232
36
  // src/sdk/hooks/use-privana-client.ts
233
37
  function usePrivanaClient() {
234
- const { client } = chunkACLJPC75_cjs.usePrivanaContext();
38
+ const { client } = chunkUHXVYWTF_cjs.usePrivanaContext();
235
39
  return client;
236
40
  }
237
41
  var hostedAuthExchangeInflight = /* @__PURE__ */ new Map();
238
42
  function normalizeHostedAuthError(error) {
239
- if (error instanceof chunkACLJPC75_cjs.AccountingApiError && error.detail) {
240
- return new chunkACLJPC75_cjs.HostedAuthError(error.detail);
43
+ if (error instanceof chunkUHXVYWTF_cjs.AccountingApiError && error.detail) {
44
+ return new chunkUHXVYWTF_cjs.HostedAuthError(error.detail);
241
45
  }
242
46
  if (error instanceof Error) {
243
47
  return error;
244
48
  }
245
- return new chunkACLJPC75_cjs.HostedAuthError("Hosted authentication failed.");
49
+ return new chunkUHXVYWTF_cjs.HostedAuthError("Hosted authentication failed.");
246
50
  }
247
51
  function useHostedRedirectAuth() {
248
52
  const {
@@ -253,30 +57,30 @@ function useHostedRedirectAuth() {
253
57
  setHostedAuthSession,
254
58
  clearHostedAuthSession,
255
59
  refreshHostedAuthSession
256
- } = chunkACLJPC75_cjs.usePrivanaContext();
60
+ } = chunkUHXVYWTF_cjs.usePrivanaContext();
257
61
  const [error, setError] = react.useState(null);
258
62
  const [isLoading, setIsLoading] = react.useState(false);
259
63
  const loginInflight = react.useRef(null);
260
64
  const completionInflight = react.useRef(null);
261
65
  const pendingStorageKey = react.useMemo(
262
- () => hostedAuthConfig ? chunkACLJPC75_cjs.createHostedAuthPendingStorageKey(client.getBaseUrl(), hostedAuthConfig) : null,
66
+ () => hostedAuthConfig ? chunkUHXVYWTF_cjs.createHostedAuthPendingStorageKey(client.getBaseUrl(), hostedAuthConfig) : null,
263
67
  [client, hostedAuthConfig]
264
68
  );
265
69
  const clearPendingLogin = react.useCallback(() => {
266
70
  if (!pendingStorageKey || typeof window === "undefined") return;
267
- chunkACLJPC75_cjs.clearHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
71
+ chunkUHXVYWTF_cjs.clearHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
268
72
  }, [pendingStorageKey]);
269
73
  const login = react.useCallback(async () => {
270
74
  if (!hostedAuthConfig) {
271
- throw new chunkACLJPC75_cjs.HostedAuthRequiredError(
75
+ throw new chunkUHXVYWTF_cjs.HostedAuthRequiredError(
272
76
  "Hosted redirect authentication is not configured for this provider."
273
77
  );
274
78
  }
275
79
  if (typeof window === "undefined") {
276
- throw new chunkACLJPC75_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
80
+ throw new chunkUHXVYWTF_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
277
81
  }
278
82
  if (!pendingStorageKey) {
279
- throw new chunkACLJPC75_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
83
+ throw new chunkUHXVYWTF_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
280
84
  }
281
85
  if (loginInflight.current) {
282
86
  return loginInflight.current;
@@ -285,10 +89,10 @@ function useHostedRedirectAuth() {
285
89
  setIsLoading(true);
286
90
  setError(null);
287
91
  try {
288
- const verifier = chunkACLJPC75_cjs.createPkceVerifier();
289
- const codeChallenge = await chunkACLJPC75_cjs.createPkceChallenge(verifier);
290
- const state = chunkACLJPC75_cjs.createHostedAuthState();
291
- chunkACLJPC75_cjs.persistHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey, {
92
+ const verifier = chunkUHXVYWTF_cjs.createPkceVerifier();
93
+ const codeChallenge = await chunkUHXVYWTF_cjs.createPkceChallenge(verifier);
94
+ const state = chunkUHXVYWTF_cjs.createHostedAuthState();
95
+ chunkUHXVYWTF_cjs.persistHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey, {
292
96
  codeVerifier: verifier,
293
97
  state
294
98
  });
@@ -317,15 +121,15 @@ function useHostedRedirectAuth() {
317
121
  }, [clearPendingLogin, client, hostedAuthConfig, networkConfig.chainId, pendingStorageKey]);
318
122
  const completeLogin = react.useCallback(async () => {
319
123
  if (!hostedAuthConfig) {
320
- throw new chunkACLJPC75_cjs.HostedAuthRequiredError(
124
+ throw new chunkUHXVYWTF_cjs.HostedAuthRequiredError(
321
125
  "Hosted redirect authentication is not configured for this provider."
322
126
  );
323
127
  }
324
128
  if (typeof window === "undefined") {
325
- throw new chunkACLJPC75_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
129
+ throw new chunkUHXVYWTF_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
326
130
  }
327
131
  if (!pendingStorageKey) {
328
- throw new chunkACLJPC75_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
132
+ throw new chunkUHXVYWTF_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
329
133
  }
330
134
  if (completionInflight.current) {
331
135
  return completionInflight.current;
@@ -335,30 +139,30 @@ function useHostedRedirectAuth() {
335
139
  setError(null);
336
140
  const callbackUrl = new URL(window.location.href);
337
141
  const cleanupCallbackUrl = () => {
338
- window.history.replaceState(null, "", chunkACLJPC75_cjs.stripHostedAuthCallbackParams(callbackUrl));
142
+ window.history.replaceState(null, "", chunkUHXVYWTF_cjs.stripHostedAuthCallbackParams(callbackUrl));
339
143
  };
340
144
  try {
341
- const callback = chunkACLJPC75_cjs.parseHostedAuthCallback(callbackUrl, hostedAuthConfig.redirectUri);
145
+ const callback = chunkUHXVYWTF_cjs.parseHostedAuthCallback(callbackUrl, hostedAuthConfig.redirectUri);
342
146
  if (!callback) {
343
147
  return null;
344
148
  }
345
- const pending = chunkACLJPC75_cjs.readHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
149
+ const pending = chunkUHXVYWTF_cjs.readHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
346
150
  if (!pending) {
347
151
  clearPendingLogin();
348
152
  cleanupCallbackUrl();
349
- throw new chunkACLJPC75_cjs.HostedAuthError(
153
+ throw new chunkUHXVYWTF_cjs.HostedAuthError(
350
154
  "Hosted authentication response could not be matched to a pending login request."
351
155
  );
352
156
  }
353
157
  if (!callback.state || callback.state !== pending.state) {
354
158
  clearPendingLogin();
355
159
  cleanupCallbackUrl();
356
- throw new chunkACLJPC75_cjs.HostedAuthStateMismatchError();
160
+ throw new chunkUHXVYWTF_cjs.HostedAuthStateMismatchError();
357
161
  }
358
162
  if ("error" in callback) {
359
163
  clearPendingLogin();
360
164
  cleanupCallbackUrl();
361
- throw new chunkACLJPC75_cjs.HostedAuthError(
165
+ throw new chunkUHXVYWTF_cjs.HostedAuthError(
362
166
  callback.errorDescription || callback.error || "Hosted authentication failed."
363
167
  );
364
168
  }
@@ -373,7 +177,7 @@ function useHostedRedirectAuth() {
373
177
  client_id: hostedAuthConfig.clientId,
374
178
  redirect_uri: hostedAuthConfig.redirectUri
375
179
  });
376
- const session = chunkACLJPC75_cjs.buildHostedAuthSession(response, hostedAuthConfig);
180
+ const session = chunkUHXVYWTF_cjs.buildHostedAuthSession(response, hostedAuthConfig);
377
181
  setHostedAuthSession(session);
378
182
  clearPendingLogin();
379
183
  cleanupCallbackUrl();
@@ -418,7 +222,7 @@ function useHostedRedirectAuth() {
418
222
  try {
419
223
  return await refreshHostedAuthSession();
420
224
  } catch (refreshError) {
421
- const normalizedError = refreshError instanceof Error ? refreshError : new chunkACLJPC75_cjs.HostedAuthError("Hosted authentication refresh failed.");
225
+ const normalizedError = refreshError instanceof Error ? refreshError : new chunkUHXVYWTF_cjs.HostedAuthError("Hosted authentication refresh failed.");
422
226
  setError(normalizedError);
423
227
  throw normalizedError;
424
228
  } finally {
@@ -438,12 +242,12 @@ function useHostedRedirectAuth() {
438
242
  }
439
243
  function useBalance(options = {}) {
440
244
  const queryClient = react.useContext(reactQuery.QueryClientContext);
441
- const accountingContext = chunkACLJPC75_cjs.useSafePrivanaContext();
245
+ const accountingContext = chunkUHXVYWTF_cjs.useSafePrivanaContext();
442
246
  const hasProviders = !!queryClient && !!accountingContext;
443
247
  const client = accountingContext?.client;
444
248
  const defaultToken = accountingContext?.defaultToken;
445
249
  const pollingInterval = accountingContext?.pollingInterval ?? 1e4;
446
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
250
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkUHXVYWTF_cjs.usePrivateReadRequest();
447
251
  const tokenId = options.tokenId ?? defaultToken?.id;
448
252
  const query = reactQuery.useQuery({
449
253
  queryKey: ["accounting-balance", ...privateReadQueryScope, tokenId],
@@ -460,7 +264,7 @@ function useBalance(options = {}) {
460
264
  return {
461
265
  balance: balanceWei,
462
266
  balanceWei,
463
- balanceFormatted: chunkACLJPC75_cjs.formatTokenAmount(balanceWei),
267
+ balanceFormatted: chunkUHXVYWTF_cjs.formatTokenAmount(balanceWei),
464
268
  tokenSymbol: query.data?.token_symbol ?? "",
465
269
  chainId: query.data?.chain_id ?? "",
466
270
  isLoading: query.isPending || query.isLoading,
@@ -470,8 +274,8 @@ function useBalance(options = {}) {
470
274
  };
471
275
  }
472
276
  function useBatchBalances(options) {
473
- const { client, pollingInterval } = chunkACLJPC75_cjs.usePrivanaContext();
474
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
277
+ const { client, pollingInterval } = chunkUHXVYWTF_cjs.usePrivanaContext();
278
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkUHXVYWTF_cjs.usePrivateReadRequest();
475
279
  const query = reactQuery.useQuery({
476
280
  queryKey: ["accounting-batch-balances", ...privateReadQueryScope, options.tokenIds],
477
281
  queryFn: async () => {
@@ -489,75 +293,22 @@ function useBatchBalances(options) {
489
293
  refetch: query.refetch
490
294
  };
491
295
  }
492
- function useEnsureCorrectChain() {
493
- const config = wagmi.useConfig();
494
- const chainId = wagmi.useChainId();
495
- const { switchChainAsync } = wagmi.useSwitchChain();
496
- const waitUntilOnChain = react.useCallback(
497
- async (expectedChainId, timeoutMs, pollIntervalMs = 250) => {
498
- const startedAt = Date.now();
499
- while (Date.now() - startedAt < timeoutMs) {
500
- const currentChainId = chunkACLJPC75_cjs.getChainId2(config);
501
- if (currentChainId === expectedChainId) return true;
502
- await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
503
- }
504
- return false;
505
- },
506
- [config]
507
- );
508
- const ensureCorrectChain = react.useCallback(
509
- async (targetChainId) => {
510
- const currentChainId = chunkACLJPC75_cjs.getChainId2(config);
511
- if (currentChainId === targetChainId) return false;
512
- let switchErrorMessage;
513
- try {
514
- const timeoutPromise = new Promise((_, reject) => {
515
- setTimeout(() => reject(new Error("Chain switch timeout")), 3e3);
516
- });
517
- await Promise.race([switchChainAsync({ chainId: targetChainId }), timeoutPromise]);
518
- } catch (error) {
519
- if (error instanceof Error && error.message.includes("Unsupported Chain")) {
520
- console.warn("Got 'Unsupported Chain' error, chain may have switched anyway.");
521
- } else {
522
- switchErrorMessage = error instanceof Error ? error.message : "Unknown chain switch error";
523
- }
524
- }
525
- const settled = await waitUntilOnChain(targetChainId, 2e4);
526
- if (settled) return true;
527
- if (switchErrorMessage) {
528
- throw new Error(
529
- `Failed to switch to chain (Chain ID: ${targetChainId}): ${switchErrorMessage}`
530
- );
531
- }
532
- throw new Error(`Chain switch did not settle in time (expected ${targetChainId}).`);
533
- },
534
- [config, switchChainAsync, waitUntilOnChain]
535
- );
536
- const isOnChain = react.useCallback((targetChainId) => chainId === targetChainId, [chainId]);
537
- return {
538
- chainId,
539
- ensureCorrectChain,
540
- isOnChain
541
- };
542
- }
543
-
544
- // src/sdk/hooks/use-deposit.ts
545
296
  var STALE_MS = 30 * 60 * 1e3;
546
297
  function storageKey(address) {
547
298
  return `privana:pending-deposit:${address.toLowerCase()}`;
548
299
  }
549
300
  function savePendingDeposit(address, data) {
550
- try {
551
- sessionStorage.setItem(storageKey(address), JSON.stringify(data));
552
- } catch {
301
+ const stored = chunkUHXVYWTF_cjs.setBrowserStorageItem(storageKey(address), JSON.stringify(data));
302
+ if (!stored && data.signedLock) {
303
+ throw new Error("Unable to persist pending locked deposit for recovery");
553
304
  }
554
305
  }
555
306
  function loadPendingDeposit(address) {
556
307
  try {
557
- const raw = sessionStorage.getItem(storageKey(address));
308
+ const raw = chunkUHXVYWTF_cjs.getBrowserStorageItem(storageKey(address));
558
309
  if (!raw) return null;
559
310
  const data = JSON.parse(raw);
560
- if (Date.now() - data.savedAt > STALE_MS) {
311
+ if (Date.now() - data.savedAt > STALE_MS && !(data.signedLock && chunkUHXVYWTF_cjs.isSignedLockUsable(data.signedLock))) {
561
312
  clearPendingDeposit(address);
562
313
  return null;
563
314
  }
@@ -566,19 +317,24 @@ function loadPendingDeposit(address) {
566
317
  return null;
567
318
  }
568
319
  }
569
- function clearPendingDeposit(address) {
570
- try {
571
- sessionStorage.removeItem(storageKey(address));
572
- } catch {
320
+ function clearPendingDeposit(address, onlyForTxHash) {
321
+ if (onlyForTxHash) {
322
+ try {
323
+ const raw = chunkUHXVYWTF_cjs.getBrowserStorageItem(storageKey(address));
324
+ const recordTxHash = raw ? JSON.parse(raw).txHash : void 0;
325
+ if (recordTxHash && recordTxHash !== onlyForTxHash) return;
326
+ } catch {
327
+ }
573
328
  }
329
+ chunkUHXVYWTF_cjs.removeBrowserStorageItem(storageKey(address));
574
330
  }
575
331
  function useDeposit(options = {}) {
576
332
  const { address } = wagmi.useAccount();
577
- const { client, enabledTokens, getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
333
+ const { client, enabledTokens, getChainById: getChainById2, networkConfig, serviceAddress } = chunkUHXVYWTF_cjs.usePrivanaContext();
578
334
  const { data: walletClient } = wagmi.useWalletClient();
579
335
  const queryClient = reactQuery.useQueryClient();
580
336
  const config = wagmi.useConfig();
581
- const { executePrivateRead } = chunkACLJPC75_cjs.usePrivateReadRequest();
337
+ const { executePrivateRead } = chunkUHXVYWTF_cjs.usePrivateReadRequest();
582
338
  const confirmations = options.confirmations ?? 15;
583
339
  const [depositAddress, setDepositAddress] = react.useState(null);
584
340
  const [txHash, setTxHash] = react.useState();
@@ -591,21 +347,54 @@ function useDeposit(options = {}) {
591
347
  const onDepositAddressReceivedRef = react.useRef(options.onDepositAddressReceived);
592
348
  const onDepositSuccessRef = react.useRef(options.onDepositSuccess);
593
349
  const onCreditedRef = react.useRef(options.onCredited);
350
+ const onLockSubmittedRef = react.useRef(options.onLockSubmitted);
351
+ const onLockFailedRef = react.useRef(options.onLockFailed);
594
352
  const onCheckTimeoutRef = react.useRef(options.onCheckTimeout);
595
353
  const onErrorRef = react.useRef(options.onError);
596
354
  react.useEffect(() => {
597
355
  onDepositAddressReceivedRef.current = options.onDepositAddressReceived;
598
356
  onDepositSuccessRef.current = options.onDepositSuccess;
599
357
  onCreditedRef.current = options.onCredited;
358
+ onLockSubmittedRef.current = options.onLockSubmitted;
359
+ onLockFailedRef.current = options.onLockFailed;
600
360
  onCheckTimeoutRef.current = options.onCheckTimeout;
601
361
  onErrorRef.current = options.onError;
602
362
  }, [
603
363
  options.onDepositAddressReceived,
604
364
  options.onDepositSuccess,
605
365
  options.onCredited,
366
+ options.onLockSubmitted,
367
+ options.onLockFailed,
606
368
  options.onCheckTimeout,
607
369
  options.onError
608
370
  ]);
371
+ const pendingLockRef = react.useRef(null);
372
+ const submitPendingLockAfterCredit = react.useCallback(
373
+ async (signedLock, response) => {
374
+ try {
375
+ const result = await chunkUHXVYWTF_cjs.submitPendingLock({
376
+ client,
377
+ payload: signedLock,
378
+ creditedAmount: response.amount != null ? BigInt(response.amount) : void 0
379
+ });
380
+ queryClient.invalidateQueries({ queryKey: ["accounting-balance"] });
381
+ queryClient.invalidateQueries({ queryKey: ["accounting-locked-funds"] });
382
+ queryClient.invalidateQueries({ queryKey: ["accounting-total-locked-balance"] });
383
+ queryClient.invalidateQueries({ queryKey: ["accounting-history"] });
384
+ onLockSubmittedRef.current?.(result);
385
+ } catch (err) {
386
+ const error2 = err instanceof chunkUHXVYWTF_cjs.PostDepositLockError ? err : new chunkUHXVYWTF_cjs.PostDepositLockError(
387
+ err instanceof Error ? err.message : "Lock submission failed",
388
+ "submission-failed",
389
+ BigInt(signedLock.amount),
390
+ void 0,
391
+ { cause: err }
392
+ );
393
+ (onLockFailedRef.current ?? onErrorRef.current)?.(error2);
394
+ }
395
+ },
396
+ [client, queryClient]
397
+ );
609
398
  const {
610
399
  isVerifying,
611
400
  didTimeout,
@@ -613,13 +402,21 @@ function useDeposit(options = {}) {
613
402
  error: verificationError,
614
403
  verify,
615
404
  reset: resetVerification
616
- } = chunkACLJPC75_cjs.useDepositVerification({
405
+ } = chunkUHXVYWTF_cjs.useDepositVerification({
617
406
  pollInterval: options.pollInterval,
618
407
  pollTimeout: options.pollTimeout,
619
408
  onCredited: (hash, response) => {
620
409
  verificationContextRef.current = null;
621
- if (address) clearPendingDeposit(address);
622
- onCreditedRef.current?.(hash, response);
410
+ const signedLock = pendingLockRef.current;
411
+ pendingLockRef.current = null;
412
+ if (signedLock) {
413
+ void submitPendingLockAfterCredit(signedLock, response).finally(() => {
414
+ if (address) clearPendingDeposit(address, hash);
415
+ });
416
+ } else if (address) {
417
+ clearPendingDeposit(address);
418
+ }
419
+ onCreditedRef.current?.(hash, response, signedLock !== null);
623
420
  },
624
421
  onCheckTimeout: (hash) => {
625
422
  onCheckTimeoutRef.current?.(hash);
@@ -655,7 +452,7 @@ function useDeposit(options = {}) {
655
452
  } = wagmi.useSendTransaction();
656
453
  const isSendingTx = isWritingContract || isSendingNative;
657
454
  const sendError = writeError ?? sendNativeError;
658
- const { ensureCorrectChain } = useEnsureCorrectChain();
455
+ const { ensureCorrectChain } = chunkUHXVYWTF_cjs.useEnsureCorrectChain();
659
456
  const invalidateGeneration = react.useCallback(() => {
660
457
  generationRef.current++;
661
458
  }, []);
@@ -670,6 +467,7 @@ function useDeposit(options = {}) {
670
467
  resetVerification();
671
468
  if (address) clearPendingDeposit(address);
672
469
  verificationContextRef.current = null;
470
+ pendingLockRef.current = null;
673
471
  setDepositAddress(null);
674
472
  setTxHash(void 0);
675
473
  setIsSwitchingChain(false);
@@ -689,6 +487,7 @@ function useDeposit(options = {}) {
689
487
  setTxHash(hash);
690
488
  setDepositAddress(persisted.depositAddress);
691
489
  setIsWaitingForConfirmation(true);
490
+ pendingLockRef.current = persisted.signedLock ?? null;
692
491
  const ctx = {
693
492
  hash,
694
493
  chainId: persisted.chainId,
@@ -701,12 +500,16 @@ function useDeposit(options = {}) {
701
500
  try {
702
501
  let confirmed = false;
703
502
  try {
704
- await chunkACLJPC75_cjs.getTransactionReceipt(config, { hash, chainId: persisted.chainId });
705
- confirmed = true;
503
+ const receipt = await chunkUHXVYWTF_cjs.getTransactionReceipt(config, {
504
+ hash,
505
+ chainId: persisted.chainId
506
+ });
507
+ const blockNumber = await chunkUHXVYWTF_cjs.getBlockNumber(config, { chainId: persisted.chainId });
508
+ confirmed = blockNumber - receipt.blockNumber + 1n >= BigInt(confirmations);
706
509
  } catch {
707
510
  }
708
511
  if (!confirmed) {
709
- await chunkACLJPC75_cjs.waitForTransactionReceipt(config, {
512
+ await chunkUHXVYWTF_cjs.waitForTransactionReceipt(config, {
710
513
  hash,
711
514
  chainId: persisted.chainId,
712
515
  confirmations
@@ -745,13 +548,6 @@ function useDeposit(options = {}) {
745
548
  if (!sourceChain) throw new Error(`Chain ${token.chainId} not configured`);
746
549
  const addrResponse = await addressMutation.mutateAsync();
747
550
  if (isStale()) return;
748
- setIsSwitchingChain(true);
749
- try {
750
- await ensureCorrectChain(sourceChain.id);
751
- } finally {
752
- if (!isStale()) setIsSwitchingChain(false);
753
- }
754
- if (isStale()) return;
755
551
  const depositAddr = addrResponse.deposit_address;
756
552
  if (!depositAddr || depositAddr === viem.zeroAddress) {
757
553
  throw new Error("Invalid deposit address received from API");
@@ -764,6 +560,43 @@ function useDeposit(options = {}) {
764
560
  `Amount is below the minimum deposit (${minAmountStr}) for ${isNative ? "native" : "ERC-20"} on chain ${sourceChain.id}`
765
561
  );
766
562
  }
563
+ if (params.postDepositLock && !chunkUHXVYWTF_cjs.canUseBrowserStorage()) {
564
+ throw new Error("Browser storage is required for locked deposit recovery");
565
+ }
566
+ const lockAmount = chunkUHXVYWTF_cjs.clampLockAmount(params.amount, params.postDepositLock?.maxAmount);
567
+ let signedLock;
568
+ if (params.postDepositLock) {
569
+ setIsSwitchingChain(true);
570
+ try {
571
+ await ensureCorrectChain(networkConfig.chainId);
572
+ } finally {
573
+ if (!isStale()) setIsSwitchingChain(false);
574
+ }
575
+ if (isStale()) return;
576
+ const signingWalletClient = await chunkUHXVYWTF_cjs.getWalletClient(config, {
577
+ chainId: networkConfig.chainId
578
+ });
579
+ signedLock = await chunkUHXVYWTF_cjs.createSignedLockRequest({
580
+ client,
581
+ walletClient: signingWalletClient,
582
+ userAddress: address,
583
+ networkConfig,
584
+ serviceAddress: requireServiceAddress(
585
+ params.postDepositLock.serviceAddress ?? serviceAddress
586
+ ),
587
+ tokenId: params.tokenId,
588
+ amount: lockAmount,
589
+ lockDuration: params.postDepositLock.lockDuration
590
+ });
591
+ }
592
+ if (isStale()) return;
593
+ setIsSwitchingChain(true);
594
+ try {
595
+ await ensureCorrectChain(sourceChain.id);
596
+ } finally {
597
+ if (!isStale()) setIsSwitchingChain(false);
598
+ }
599
+ if (isStale()) return;
767
600
  const hash = token.contract === viem.zeroAddress ? await sendTransactionAsync({
768
601
  to: depositAddr,
769
602
  value: params.amount,
@@ -783,17 +616,23 @@ function useDeposit(options = {}) {
783
616
  amount: params.amount
784
617
  };
785
618
  verificationContextRef.current = ctx;
786
- savePendingDeposit(address, {
787
- txHash: hash,
788
- chainId: sourceChain.id,
789
- amount: params.amount.toString(),
790
- depositAddress: addrResponse,
791
- savedAt: Date.now()
792
- });
619
+ pendingLockRef.current = signedLock ?? null;
620
+ try {
621
+ savePendingDeposit(address, {
622
+ txHash: hash,
623
+ chainId: sourceChain.id,
624
+ amount: params.amount.toString(),
625
+ depositAddress: addrResponse,
626
+ signedLock,
627
+ savedAt: Date.now()
628
+ });
629
+ } catch (err) {
630
+ console.warn("Failed to persist pending deposit after transfer broadcast:", err);
631
+ }
793
632
  try {
794
633
  setIsWaitingForConfirmation(true);
795
634
  try {
796
- await chunkACLJPC75_cjs.waitForTransactionReceipt(config, {
635
+ await chunkUHXVYWTF_cjs.waitForTransactionReceipt(config, {
797
636
  hash,
798
637
  chainId: sourceChain.id,
799
638
  confirmations
@@ -824,12 +663,15 @@ function useDeposit(options = {}) {
824
663
  address,
825
664
  walletClient,
826
665
  addressMutation,
666
+ client,
827
667
  getChainById2,
828
668
  config,
829
669
  confirmations,
830
670
  enabledTokens,
831
671
  ensureCorrectChain,
672
+ networkConfig,
832
673
  queryClient,
674
+ serviceAddress,
833
675
  writeContractAsync,
834
676
  sendTransactionAsync,
835
677
  reset,
@@ -864,12 +706,18 @@ function useDeposit(options = {}) {
864
706
  reset
865
707
  };
866
708
  }
709
+ function requireServiceAddress(serviceAddress) {
710
+ if (!serviceAddress) {
711
+ throw new Error("Service address not configured");
712
+ }
713
+ return serviceAddress;
714
+ }
867
715
  function useDepositAddress(options = {}) {
868
716
  const queryClient = react.useContext(reactQuery.QueryClientContext);
869
- const accountingContext = chunkACLJPC75_cjs.useSafePrivanaContext();
717
+ const accountingContext = chunkUHXVYWTF_cjs.useSafePrivanaContext();
870
718
  const hasProviders = !!queryClient && !!accountingContext;
871
719
  const client = accountingContext?.client;
872
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
720
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkUHXVYWTF_cjs.usePrivateReadRequest();
873
721
  const isReady = hasProviders && privateReadReady && !!privateReadAddress && !!client;
874
722
  const query = reactQuery.useQuery({
875
723
  queryKey: ["accounting-deposit-address", ...privateReadQueryScope],
@@ -892,9 +740,9 @@ function useDepositAddress(options = {}) {
892
740
  function useWithdraw(options = {}) {
893
741
  const { address } = wagmi.useAccount();
894
742
  const { data: walletClient } = wagmi.useWalletClient();
895
- const { client, networkConfig } = chunkACLJPC75_cjs.usePrivanaContext();
743
+ const { client, networkConfig } = chunkUHXVYWTF_cjs.usePrivanaContext();
896
744
  const queryClient = reactQuery.useQueryClient();
897
- const { chainId, ensureCorrectChain } = useEnsureCorrectChain();
745
+ const { chainId, ensureCorrectChain } = chunkUHXVYWTF_cjs.useEnsureCorrectChain();
898
746
  const pollInterval = options.pollInterval ?? 3e3;
899
747
  const pollTimeout = options.pollTimeout ?? 18e4;
900
748
  const [currentStep, setCurrentStep] = react.useState("idle");
@@ -962,7 +810,7 @@ function useWithdraw(options = {}) {
962
810
  if (isStale()) return void 0;
963
811
  const nonce = BigInt(nonceResponse.nonce);
964
812
  setCurrentStep("signing");
965
- const signature = await signWithdrawMessage({
813
+ const signature = await chunkUHXVYWTF_cjs.signWithdrawMessage({
966
814
  walletClient,
967
815
  chainId: signingChainId,
968
816
  verifyingContract: networkConfig.accountingContract,
@@ -1091,7 +939,7 @@ function useWithdraw(options = {}) {
1091
939
  function useLockFunds(options = {}) {
1092
940
  const { address } = wagmi.useAccount();
1093
941
  const { data: walletClient } = wagmi.useWalletClient();
1094
- const { client, networkConfig, serviceAddress } = chunkACLJPC75_cjs.usePrivanaContext();
942
+ const { client, networkConfig, serviceAddress } = chunkUHXVYWTF_cjs.usePrivanaContext();
1095
943
  const queryClient = reactQuery.useQueryClient();
1096
944
  const mutation = reactQuery.useMutation({
1097
945
  mutationFn: async (params) => {
@@ -1102,7 +950,7 @@ function useLockFunds(options = {}) {
1102
950
  throw new Error("Service address not configured");
1103
951
  }
1104
952
  const { nonce } = await client.getLockNonce(address);
1105
- const signature = await signLockMessage({
953
+ const signature = await chunkUHXVYWTF_cjs.signLockMessage({
1106
954
  walletClient,
1107
955
  chainId: networkConfig.chainId,
1108
956
  verifyingContract: networkConfig.accountingContract,
@@ -1150,7 +998,7 @@ function useLockFunds(options = {}) {
1150
998
  }
1151
999
  function useUnlockFunds(options = {}) {
1152
1000
  const { address } = wagmi.useAccount();
1153
- const { client } = chunkACLJPC75_cjs.usePrivanaContext();
1001
+ const { client } = chunkUHXVYWTF_cjs.usePrivanaContext();
1154
1002
  const queryClient = reactQuery.useQueryClient();
1155
1003
  const unlockMutation = reactQuery.useMutation({
1156
1004
  mutationFn: async (params) => {
@@ -1220,7 +1068,7 @@ function useUnlockFunds(options = {}) {
1220
1068
  function useTransfer(options = {}) {
1221
1069
  const { address } = wagmi.useAccount();
1222
1070
  const { data: walletClient } = wagmi.useWalletClient();
1223
- const { client, networkConfig, serviceAddress } = chunkACLJPC75_cjs.usePrivanaContext();
1071
+ const { client, networkConfig, serviceAddress } = chunkUHXVYWTF_cjs.usePrivanaContext();
1224
1072
  const queryClient = reactQuery.useQueryClient();
1225
1073
  const transferMutation = reactQuery.useMutation({
1226
1074
  mutationFn: async (params) => {
@@ -1228,7 +1076,7 @@ function useTransfer(options = {}) {
1228
1076
  throw new Error("Wallet not connected");
1229
1077
  }
1230
1078
  const { nonce } = await client.getTransferNonce(address);
1231
- const signature = await signTransferMessage({
1079
+ const signature = await chunkUHXVYWTF_cjs.signTransferMessage({
1232
1080
  walletClient,
1233
1081
  chainId: networkConfig.chainId,
1234
1082
  verifyingContract: networkConfig.accountingContract,
@@ -1265,7 +1113,7 @@ function useTransfer(options = {}) {
1265
1113
  throw new Error("Service address not configured");
1266
1114
  }
1267
1115
  const { nonce } = await client.getTransferLockedNonce(serviceAddress);
1268
- const signature = await signTransferLockedMessage({
1116
+ const signature = await chunkUHXVYWTF_cjs.signTransferLockedMessage({
1269
1117
  walletClient,
1270
1118
  chainId: networkConfig.chainId,
1271
1119
  verifyingContract: networkConfig.accountingContract,
@@ -1325,8 +1173,8 @@ function useTransfer(options = {}) {
1325
1173
  };
1326
1174
  }
1327
1175
  function useLockedFunds(options = {}) {
1328
- const { client, pollingInterval, serviceAddress } = chunkACLJPC75_cjs.usePrivanaContext();
1329
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
1176
+ const { client, pollingInterval, serviceAddress } = chunkUHXVYWTF_cjs.usePrivanaContext();
1177
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkUHXVYWTF_cjs.usePrivateReadRequest();
1330
1178
  const query = reactQuery.useQuery({
1331
1179
  queryKey: ["accounting-locked-funds", ...privateReadQueryScope, serviceAddress ?? null],
1332
1180
  queryFn: async () => {
@@ -1348,8 +1196,8 @@ function useLockedFunds(options = {}) {
1348
1196
  };
1349
1197
  }
1350
1198
  function useTotalLockedBalance(options = {}) {
1351
- const { client, pollingInterval, defaultToken } = chunkACLJPC75_cjs.usePrivanaContext();
1352
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
1199
+ const { client, pollingInterval, defaultToken } = chunkUHXVYWTF_cjs.usePrivanaContext();
1200
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkUHXVYWTF_cjs.usePrivateReadRequest();
1353
1201
  const tokenId = options.tokenId ?? defaultToken?.id;
1354
1202
  const query = reactQuery.useQuery({
1355
1203
  queryKey: ["accounting-total-locked-balance", ...privateReadQueryScope, tokenId],
@@ -1370,8 +1218,8 @@ function useTotalLockedBalance(options = {}) {
1370
1218
  };
1371
1219
  }
1372
1220
  function useExpiredLocks(options = {}) {
1373
- const { client, pollingInterval } = chunkACLJPC75_cjs.usePrivanaContext();
1374
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
1221
+ const { client, pollingInterval } = chunkUHXVYWTF_cjs.usePrivanaContext();
1222
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkUHXVYWTF_cjs.usePrivateReadRequest();
1375
1223
  const query = reactQuery.useQuery({
1376
1224
  queryKey: ["accounting-expired-locks", ...privateReadQueryScope],
1377
1225
  queryFn: async () => {
@@ -1391,9 +1239,62 @@ function useExpiredLocks(options = {}) {
1391
1239
  refetch: query.refetch
1392
1240
  };
1393
1241
  }
1242
+ function statusCodeOf(error) {
1243
+ return error instanceof chunkUHXVYWTF_cjs.AccountingApiError ? error.statusCode : void 0;
1244
+ }
1245
+ function usePendingDeposits(options = {}) {
1246
+ const queryClient = react.useContext(reactQuery.QueryClientContext);
1247
+ const accountingContext = chunkUHXVYWTF_cjs.useSafePrivanaContext();
1248
+ const hasProviders = !!queryClient && !!accountingContext;
1249
+ const client = accountingContext?.client;
1250
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkUHXVYWTF_cjs.usePrivateReadRequest();
1251
+ const { chainId, tokenAddress, lookbackBlocks } = options;
1252
+ const query = reactQuery.useQuery({
1253
+ queryKey: ["accounting-pending-deposits", ...privateReadQueryScope, chainId, tokenAddress],
1254
+ queryFn: async () => {
1255
+ if (!privateReadAddress) throw new Error("No authenticated account available");
1256
+ if (!chainId) throw new Error("No chain ID provided");
1257
+ if (!client) throw new Error("No accounting client");
1258
+ try {
1259
+ return await executePrivateRead(
1260
+ () => client.getPendingDeposits({
1261
+ chain_id: chainId,
1262
+ token_address: tokenAddress,
1263
+ lookback_blocks: lookbackBlocks
1264
+ })
1265
+ );
1266
+ } catch (error) {
1267
+ if (statusCodeOf(error) === 404) {
1268
+ return { pending: [], scanned_from_block: 0, scanned_to_block: 0 };
1269
+ }
1270
+ throw error;
1271
+ }
1272
+ },
1273
+ enabled: hasProviders && (options.enabled ?? true) && privateReadReady && !!privateReadAddress && !!chainId && !!client,
1274
+ // A 503 means discovery is not configured for this chain server-side —
1275
+ // polling can't fix that, so stop until a manual refetch succeeds.
1276
+ refetchInterval: (query2) => statusCodeOf(query2.state.error) === 503 ? false : options.refetchInterval ?? 3e4,
1277
+ staleTime: 25e3,
1278
+ retry: (failureCount, error) => {
1279
+ const status = statusCodeOf(error);
1280
+ if (status === 429 || status === 404 || status === 503) return false;
1281
+ return failureCount < 2;
1282
+ }
1283
+ });
1284
+ return {
1285
+ pending: query.data?.pending ?? [],
1286
+ scannedToBlock: query.data?.scanned_to_block,
1287
+ isFetching: query.isFetching,
1288
+ isError: query.isError,
1289
+ error: query.error,
1290
+ isRateLimited: statusCodeOf(query.error) === 429,
1291
+ isUnavailable: statusCodeOf(query.error) === 503,
1292
+ refetch: async () => (await query.refetch()).data
1293
+ };
1294
+ }
1394
1295
  function usePendingWithdrawals(options = {}) {
1395
1296
  const { address, isConnected } = wagmi.useAccount();
1396
- const { client, pollingInterval } = chunkACLJPC75_cjs.usePrivanaContext();
1297
+ const { client, pollingInterval } = chunkUHXVYWTF_cjs.usePrivanaContext();
1397
1298
  const query = reactQuery.useQuery({
1398
1299
  queryKey: ["accounting-pending-withdrawals", address],
1399
1300
  queryFn: async () => {
@@ -1429,8 +1330,8 @@ function usePendingWithdrawals(options = {}) {
1429
1330
  };
1430
1331
  }
1431
1332
  function useHistory(options = {}) {
1432
- const { client, pollingInterval } = chunkACLJPC75_cjs.usePrivanaContext();
1433
- const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
1333
+ const { client, pollingInterval } = chunkUHXVYWTF_cjs.usePrivanaContext();
1334
+ const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkUHXVYWTF_cjs.usePrivateReadRequest();
1434
1335
  const offset = options.offset ?? -1;
1435
1336
  const limit = options.limit ?? 50;
1436
1337
  const query = reactQuery.useQuery({
@@ -1454,7 +1355,7 @@ function useHistory(options = {}) {
1454
1355
  };
1455
1356
  }
1456
1357
  function useTokenInfo(options = {}) {
1457
- const { client } = chunkACLJPC75_cjs.usePrivanaContext();
1358
+ const { client } = chunkUHXVYWTF_cjs.usePrivanaContext();
1458
1359
  const { tokenId } = options;
1459
1360
  const query = reactQuery.useQuery({
1460
1361
  queryKey: ["accounting-token-info", tokenId],
@@ -1474,7 +1375,7 @@ function useTokenInfo(options = {}) {
1474
1375
  };
1475
1376
  }
1476
1377
  function useTokenList(options = {}) {
1477
- const { client } = chunkACLJPC75_cjs.usePrivanaContext();
1378
+ const { client } = chunkUHXVYWTF_cjs.usePrivanaContext();
1478
1379
  const query = reactQuery.useQuery({
1479
1380
  queryKey: ["accounting-token-list"],
1480
1381
  queryFn: () => client.listTokens(),
@@ -1492,7 +1393,7 @@ function useTokenList(options = {}) {
1492
1393
  function useModifyLock(options = {}) {
1493
1394
  const { address } = wagmi.useAccount();
1494
1395
  const { data: walletClient } = wagmi.useWalletClient();
1495
- const { client, networkConfig } = chunkACLJPC75_cjs.usePrivanaContext();
1396
+ const { client, networkConfig } = chunkUHXVYWTF_cjs.usePrivanaContext();
1496
1397
  const queryClient = reactQuery.useQueryClient();
1497
1398
  const mutation = reactQuery.useMutation({
1498
1399
  mutationFn: async (params) => {
@@ -1500,7 +1401,7 @@ function useModifyLock(options = {}) {
1500
1401
  throw new Error("Wallet not connected");
1501
1402
  }
1502
1403
  const { nonce } = await client.getModifyLockNonce(address);
1503
- const signature = await signModifyLockMessage({
1404
+ const signature = await chunkUHXVYWTF_cjs.signModifyLockMessage({
1504
1405
  walletClient,
1505
1406
  chainId: networkConfig.chainId,
1506
1407
  verifyingContract: networkConfig.accountingContract,
@@ -1559,7 +1460,7 @@ function DialogOverlay({
1559
1460
  {
1560
1461
  "data-slot": "dialog-overlay",
1561
1462
  "data-privana": true,
1562
- className: chunkACLJPC75_cjs.cn(
1463
+ className: chunkUHXVYWTF_cjs.cn(
1563
1464
  "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",
1564
1465
  className
1565
1466
  ),
@@ -1581,7 +1482,7 @@ function DialogContent({
1581
1482
  {
1582
1483
  "data-slot": "dialog-content",
1583
1484
  "data-privana": true,
1584
- className: chunkACLJPC75_cjs.cn(
1485
+ className: chunkUHXVYWTF_cjs.cn(
1585
1486
  "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",
1586
1487
  className
1587
1488
  ),
@@ -1609,7 +1510,7 @@ function DialogHeader({ className, ...props }) {
1609
1510
  "div",
1610
1511
  {
1611
1512
  "data-slot": "dialog-header",
1612
- className: chunkACLJPC75_cjs.cn("flex flex-col gap-2 text-center sm:text-left", className),
1513
+ className: chunkUHXVYWTF_cjs.cn("flex flex-col gap-2 text-center sm:text-left", className),
1613
1514
  ...props
1614
1515
  }
1615
1516
  );
@@ -1619,7 +1520,7 @@ function DialogTitle({ className, ...props }) {
1619
1520
  DialogPrimitive__namespace.Title,
1620
1521
  {
1621
1522
  "data-slot": "dialog-title",
1622
- className: chunkACLJPC75_cjs.cn("text-lg leading-none font-semibold", className),
1523
+ className: chunkUHXVYWTF_cjs.cn("text-lg leading-none font-semibold", className),
1623
1524
  ...props
1624
1525
  }
1625
1526
  );
@@ -1632,7 +1533,7 @@ function DialogDescription({
1632
1533
  DialogPrimitive__namespace.Description,
1633
1534
  {
1634
1535
  "data-slot": "dialog-description",
1635
- className: chunkACLJPC75_cjs.cn("text-muted-foreground text-sm", className),
1536
+ className: chunkUHXVYWTF_cjs.cn("text-muted-foreground text-sm", className),
1636
1537
  ...props
1637
1538
  }
1638
1539
  );
@@ -1827,7 +1728,7 @@ function ChevronDownIcon({
1827
1728
  height: "16",
1828
1729
  viewBox: "0 0 16 16",
1829
1730
  fill: "none",
1830
- className: chunkACLJPC75_cjs.cn(
1731
+ className: chunkUHXVYWTF_cjs.cn(
1831
1732
  "transition-transform",
1832
1733
  direction === "right" && "-rotate-90",
1833
1734
  direction === "up" && "rotate-180",
@@ -2050,7 +1951,8 @@ function TransactionErrorView({
2050
1951
  explorerLabel,
2051
1952
  onRetry,
2052
1953
  onDismiss,
2053
- isRetrying
1954
+ isRetrying,
1955
+ retryLabel = "Retry Verification"
2054
1956
  }) {
2055
1957
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-col gap-4", children: [
2056
1958
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
@@ -2089,7 +1991,7 @@ function TransactionErrorView({
2089
1991
  onClick: onRetry,
2090
1992
  disabled: isRetrying,
2091
1993
  className: "bg-primary text-primary-foreground hover:bg-primary/90 flex h-10 flex-1 cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
2092
- children: isRetrying ? "Retrying..." : "Retry Verification"
1994
+ children: isRetrying ? "Retrying..." : retryLabel
2093
1995
  }
2094
1996
  )
2095
1997
  ] })
@@ -2103,7 +2005,7 @@ function DepositForm({
2103
2005
  onSuccess
2104
2006
  }) {
2105
2007
  const { isConnected, address } = wagmi.useAccount();
2106
- const { chains, getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
2008
+ const { chains, getChainById: getChainById2 } = chunkUHXVYWTF_cjs.usePrivanaContext();
2107
2009
  const [amount, setAmount] = react.useState("");
2108
2010
  const [showSuccess, setShowSuccess] = react.useState(false);
2109
2011
  const [showTimeout, setShowTimeout] = react.useState(false);
@@ -2128,7 +2030,7 @@ function DepositForm({
2128
2030
  }
2129
2031
  });
2130
2032
  const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
2131
- const formattedWalletBalance = walletBalance ? chunkACLJPC75_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
2033
+ const formattedWalletBalance = walletBalance ? chunkUHXVYWTF_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
2132
2034
  const handleMaxClick = () => {
2133
2035
  if (formattedWalletBalance && parseFloat(formattedWalletBalance) > 0) {
2134
2036
  setAmount(formattedWalletBalance.replace(/[\s\u2009]/g, ""));
@@ -2136,7 +2038,7 @@ function DepositForm({
2136
2038
  };
2137
2039
  const hasValidAmount = amount && parseFloat(amount) > 0;
2138
2040
  const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
2139
- const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null && chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
2041
+ const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null && chunkUHXVYWTF_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
2140
2042
  const {
2141
2043
  txHash,
2142
2044
  isGettingAddress,
@@ -2221,7 +2123,7 @@ function DepositForm({
2221
2123
  const handleSubmit = async () => {
2222
2124
  if (!amount || !selectedToken || exceedsBalance) return;
2223
2125
  setCancelled(false);
2224
- const amountInWei = chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals);
2126
+ const amountInWei = chunkUHXVYWTF_cjs.parseTokenAmount(amount, selectedToken.decimals);
2225
2127
  await deposit({
2226
2128
  tokenId: selectedToken.id,
2227
2129
  amount: amountInWei
@@ -2324,7 +2226,7 @@ function DepositForm({
2324
2226
  setAmount(value);
2325
2227
  }
2326
2228
  },
2327
- className: chunkACLJPC75_cjs.cn(
2229
+ className: chunkUHXVYWTF_cjs.cn(
2328
2230
  "text-foreground flex-1 bg-transparent text-sm outline-none",
2329
2231
  "placeholder:text-muted-foreground/50"
2330
2232
  )
@@ -2351,7 +2253,7 @@ function DepositForm({
2351
2253
  {
2352
2254
  onClick: handleSubmit,
2353
2255
  disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
2354
- className: chunkACLJPC75_cjs.cn(
2256
+ className: chunkUHXVYWTF_cjs.cn(
2355
2257
  "flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
2356
2258
  "bg-primary text-primary-foreground hover:bg-primary/90",
2357
2259
  "disabled:cursor-not-allowed disabled:opacity-50"
@@ -2368,7 +2270,7 @@ function WithdrawForm({
2368
2270
  onUnsafeToCloseChange
2369
2271
  }) {
2370
2272
  const { isConnected, address } = wagmi.useAccount();
2371
- const { chains, getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
2273
+ const { chains, getChainById: getChainById2 } = chunkUHXVYWTF_cjs.usePrivanaContext();
2372
2274
  const [amount, setAmount] = react.useState("");
2373
2275
  const [showSuccess, setShowSuccess] = react.useState(false);
2374
2276
  const [showTimeout, setShowTimeout] = react.useState(false);
@@ -2381,7 +2283,7 @@ function WithdrawForm({
2381
2283
  } = useBalance({
2382
2284
  tokenId: selectedToken.id
2383
2285
  });
2384
- const formattedBalance = chunkACLJPC75_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
2286
+ const formattedBalance = chunkUHXVYWTF_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
2385
2287
  const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
2386
2288
  onProcessingSuccess: () => {
2387
2289
  setAmount("");
@@ -2392,7 +2294,7 @@ function WithdrawForm({
2392
2294
  setShowTimeout(true);
2393
2295
  }
2394
2296
  });
2395
- const explorerUrl = address && targetChain ? chunkACLJPC75_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
2297
+ const explorerUrl = address && targetChain ? chunkUHXVYWTF_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
2396
2298
  const getStepStatus = (step, after) => {
2397
2299
  if (currentStep === step) return "active";
2398
2300
  if (after.includes(currentStep)) return "completed";
@@ -2436,7 +2338,7 @@ function WithdrawForm({
2436
2338
  const handleWithdraw = async () => {
2437
2339
  if (!amount || !selectedToken || exceedsBalance) return;
2438
2340
  setCancelled(false);
2439
- const amountInWei = chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals);
2341
+ const amountInWei = chunkUHXVYWTF_cjs.parseTokenAmount(amount, selectedToken.decimals);
2440
2342
  await withdraw({
2441
2343
  tokenId: selectedToken.id,
2442
2344
  amount: amountInWei
@@ -2449,7 +2351,7 @@ function WithdrawForm({
2449
2351
  };
2450
2352
  const hasValidAmount = amount && parseFloat(amount) > 0;
2451
2353
  const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
2452
- const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError && chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
2354
+ const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError && chunkUHXVYWTF_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
2453
2355
  const getButtonText = () => {
2454
2356
  if (!isConnected) return "Connect Wallet";
2455
2357
  return "Withdraw";
@@ -2461,7 +2363,7 @@ function WithdrawForm({
2461
2363
  title: "Withdrawal Complete",
2462
2364
  message: `Your ${selectedToken.symbol} withdrawal has been processed. Funds should appear in your wallet shortly.`,
2463
2365
  explorerUrl,
2464
- explorerLabel: targetChain ? chunkACLJPC75_cjs.getExplorerLabel(targetChain.id) : void 0,
2366
+ explorerLabel: targetChain ? chunkUHXVYWTF_cjs.getExplorerLabel(targetChain.id) : void 0,
2465
2367
  onDone: handleDone
2466
2368
  }
2467
2369
  );
@@ -2532,7 +2434,7 @@ function WithdrawForm({
2532
2434
  setAmount(value);
2533
2435
  }
2534
2436
  },
2535
- className: chunkACLJPC75_cjs.cn(
2437
+ className: chunkUHXVYWTF_cjs.cn(
2536
2438
  "text-foreground flex-1 bg-transparent text-sm outline-none",
2537
2439
  "placeholder:text-muted-foreground/50"
2538
2440
  )
@@ -2559,7 +2461,7 @@ function WithdrawForm({
2559
2461
  {
2560
2462
  onClick: handleWithdraw,
2561
2463
  disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
2562
- className: chunkACLJPC75_cjs.cn(
2464
+ className: chunkUHXVYWTF_cjs.cn(
2563
2465
  "flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
2564
2466
  "bg-primary text-primary-foreground hover:bg-primary/90",
2565
2467
  "disabled:cursor-not-allowed disabled:opacity-50"
@@ -2580,15 +2482,15 @@ function BalanceCards({
2580
2482
  tokenId: selectedToken.id
2581
2483
  });
2582
2484
  const { totalLocked, isLoading: lockedLoading } = useLockedFunds({ enabled: showLockedFunds });
2583
- const formattedBalance = chunkACLJPC75_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
2584
- const formattedLocked = showLockedFunds ? chunkACLJPC75_cjs.formatTokenAmount(String(totalLocked), selectedToken.decimals) : "0.00";
2585
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkACLJPC75_cjs.cn("flex gap-2", disabled && "opacity-50"), children: [
2485
+ const formattedBalance = chunkUHXVYWTF_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
2486
+ const formattedLocked = showLockedFunds ? chunkUHXVYWTF_cjs.formatTokenAmount(String(totalLocked), selectedToken.decimals) : "0.00";
2487
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkUHXVYWTF_cjs.cn("flex gap-2", disabled && "opacity-50"), children: [
2586
2488
  /* @__PURE__ */ jsxRuntime.jsxs(
2587
2489
  "button",
2588
2490
  {
2589
2491
  onClick: onBalanceClick,
2590
2492
  disabled,
2591
- className: chunkACLJPC75_cjs.cn(
2493
+ className: chunkUHXVYWTF_cjs.cn(
2592
2494
  "bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
2593
2495
  disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
2594
2496
  ),
@@ -2609,7 +2511,7 @@ function BalanceCards({
2609
2511
  {
2610
2512
  onClick: onLockedFundsClick,
2611
2513
  disabled,
2612
- className: chunkACLJPC75_cjs.cn(
2514
+ className: chunkUHXVYWTF_cjs.cn(
2613
2515
  "bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
2614
2516
  disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
2615
2517
  ),
@@ -2635,7 +2537,7 @@ function Tabs({
2635
2537
  return /* @__PURE__ */ jsxRuntime.jsxs(
2636
2538
  "div",
2637
2539
  {
2638
- className: chunkACLJPC75_cjs.cn(
2540
+ className: chunkUHXVYWTF_cjs.cn(
2639
2541
  "bg-muted relative flex gap-2 overflow-hidden rounded-[10px] p-1",
2640
2542
  disabled && "opacity-50"
2641
2543
  ),
@@ -2643,7 +2545,7 @@ function Tabs({
2643
2545
  /* @__PURE__ */ jsxRuntime.jsx(
2644
2546
  "div",
2645
2547
  {
2646
- className: chunkACLJPC75_cjs.cn(
2548
+ className: chunkUHXVYWTF_cjs.cn(
2647
2549
  "bg-input absolute top-1 bottom-1 left-1 w-[calc(50%-8px)] rounded-md transition-transform duration-200",
2648
2550
  activeTab === "withdraw" && "translate-x-[calc(100%+8px)]"
2649
2551
  )
@@ -2654,7 +2556,7 @@ function Tabs({
2654
2556
  {
2655
2557
  onClick: () => !disabled && onTabChange("deposit"),
2656
2558
  disabled,
2657
- className: chunkACLJPC75_cjs.cn(
2559
+ className: chunkUHXVYWTF_cjs.cn(
2658
2560
  "relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
2659
2561
  activeTab === "deposit" ? "text-foreground" : "text-muted-foreground",
2660
2562
  disabled ? "cursor-not-allowed" : "cursor-pointer"
@@ -2667,7 +2569,7 @@ function Tabs({
2667
2569
  {
2668
2570
  onClick: () => !disabled && onTabChange("withdraw"),
2669
2571
  disabled,
2670
- className: chunkACLJPC75_cjs.cn(
2572
+ className: chunkUHXVYWTF_cjs.cn(
2671
2573
  "relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
2672
2574
  activeTab === "withdraw" ? "text-foreground" : "text-muted-foreground",
2673
2575
  disabled ? "cursor-not-allowed" : "cursor-pointer"
@@ -2680,14 +2582,14 @@ function Tabs({
2680
2582
  );
2681
2583
  }
2682
2584
  function LockedFundsView({ onBack }) {
2683
- const { getTokenById } = chunkACLJPC75_cjs.usePrivanaContext();
2585
+ const { getTokenById } = chunkUHXVYWTF_cjs.usePrivanaContext();
2684
2586
  const { locks, isLoading } = useLockedFunds();
2685
2587
  const { unlockFunds, unlockAllExpired, isPending } = useUnlockFunds();
2686
2588
  const [collapsedSections, setCollapsedSections] = react.useState({});
2687
2589
  const sections = react.useMemo(() => {
2688
2590
  const sectionMap = {};
2689
2591
  locks.forEach((lock) => {
2690
- const serviceName = chunkACLJPC75_cjs.shortenAddress(lock.service_address);
2592
+ const serviceName = chunkUHXVYWTF_cjs.shortenAddress(lock.service_address);
2691
2593
  if (!sectionMap[lock.service_address]) {
2692
2594
  sectionMap[lock.service_address] = {
2693
2595
  title: `Service ${serviceName}`,
@@ -2696,9 +2598,9 @@ function LockedFundsView({ onBack }) {
2696
2598
  }
2697
2599
  sectionMap[lock.service_address].items.push({
2698
2600
  lockId: lock.lock_id,
2699
- amount: chunkACLJPC75_cjs.formatTokenAmount(String(lock.amount), getTokenById(lock.token_id)?.decimals ?? 18),
2601
+ amount: chunkUHXVYWTF_cjs.formatTokenAmount(String(lock.amount), getTokenById(lock.token_id)?.decimals ?? 18),
2700
2602
  serviceAddress: lock.service_address,
2701
- time: lock.is_expired ? "Click to unlock" : chunkACLJPC75_cjs.formatTimeRemaining(lock.expiry),
2603
+ time: lock.is_expired ? "Click to unlock" : chunkUHXVYWTF_cjs.formatTimeRemaining(lock.expiry),
2702
2604
  isExpired: lock.is_expired
2703
2605
  });
2704
2606
  });
@@ -2750,7 +2652,7 @@ function LockedFundsView({ onBack }) {
2750
2652
  !collapsedSections[section.title] && section.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
2751
2653
  "div",
2752
2654
  {
2753
- className: chunkACLJPC75_cjs.cn(
2655
+ className: chunkUHXVYWTF_cjs.cn(
2754
2656
  "flex items-center justify-between gap-3 rounded-lg p-3",
2755
2657
  item.isExpired && "bg-secondary"
2756
2658
  ),
@@ -2764,7 +2666,7 @@ function LockedFundsView({ onBack }) {
2764
2666
  ] }),
2765
2667
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-xs", children: [
2766
2668
  "Service: ",
2767
- chunkACLJPC75_cjs.shortenAddress(item.serviceAddress)
2669
+ chunkUHXVYWTF_cjs.shortenAddress(item.serviceAddress)
2768
2670
  ] })
2769
2671
  ] })
2770
2672
  ] }),
@@ -2805,7 +2707,7 @@ function BalanceTokenRow({ token }) {
2805
2707
  const { balanceWei, isLoading } = useBalance({
2806
2708
  tokenId: token.id
2807
2709
  });
2808
- const formattedBalance = chunkACLJPC75_cjs.formatTokenAmount(balanceWei, token.decimals);
2710
+ const formattedBalance = chunkUHXVYWTF_cjs.formatTokenAmount(balanceWei, token.decimals);
2809
2711
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-2 rounded-lg px-3 py-2.5", children: [
2810
2712
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-[18px] w-[18px] overflow-hidden rounded-full", children: getTokenIcon(token.symbol, 18) }),
2811
2713
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground flex-1 text-sm", children: token.symbol }),
@@ -2813,7 +2715,7 @@ function BalanceTokenRow({ token }) {
2813
2715
  ] });
2814
2716
  }
2815
2717
  function BalanceDetailsView({ onBack }) {
2816
- const { enabledTokens, chains } = chunkACLJPC75_cjs.usePrivanaContext();
2718
+ const { enabledTokens, chains } = chunkUHXVYWTF_cjs.usePrivanaContext();
2817
2719
  const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
2818
2720
  const chainTokens = react.useMemo(() => {
2819
2721
  return enabledTokens.filter((t) => t.chainId === selectedChainId);
@@ -2839,7 +2741,7 @@ function BalanceDetailsView({ onBack }) {
2839
2741
  "button",
2840
2742
  {
2841
2743
  onClick: () => setSelectedChainId(chain.id),
2842
- className: chunkACLJPC75_cjs.cn(
2744
+ className: chunkUHXVYWTF_cjs.cn(
2843
2745
  "hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
2844
2746
  isSelected && "bg-secondary"
2845
2747
  ),
@@ -2880,12 +2782,12 @@ function TokenRow({
2880
2782
  query: { enabled: !!address && !isNative }
2881
2783
  });
2882
2784
  const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
2883
- const formattedBalance = walletBalance ? chunkACLJPC75_cjs.formatTokenAmount(walletBalance.toString(), token.decimals) : "0.00";
2785
+ const formattedBalance = walletBalance ? chunkUHXVYWTF_cjs.formatTokenAmount(walletBalance.toString(), token.decimals) : "0.00";
2884
2786
  return /* @__PURE__ */ jsxRuntime.jsxs(
2885
2787
  "button",
2886
2788
  {
2887
2789
  onClick,
2888
- className: chunkACLJPC75_cjs.cn(
2790
+ className: chunkUHXVYWTF_cjs.cn(
2889
2791
  "hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
2890
2792
  isSelected && "bg-secondary"
2891
2793
  ),
@@ -2902,7 +2804,7 @@ function TokenSelectorView({
2902
2804
  onSelect,
2903
2805
  selectedTokenId
2904
2806
  }) {
2905
- const { enabledTokens, chains } = chunkACLJPC75_cjs.usePrivanaContext();
2807
+ const { enabledTokens, chains } = chunkUHXVYWTF_cjs.usePrivanaContext();
2906
2808
  const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
2907
2809
  const chainTokens = react.useMemo(() => {
2908
2810
  return enabledTokens.filter((t) => t.chainId === selectedChainId);
@@ -2932,7 +2834,7 @@ function TokenSelectorView({
2932
2834
  "button",
2933
2835
  {
2934
2836
  onClick: () => setSelectedChainId(chain.id),
2935
- className: chunkACLJPC75_cjs.cn(
2837
+ className: chunkUHXVYWTF_cjs.cn(
2936
2838
  "hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
2937
2839
  isSelected && "bg-secondary"
2938
2840
  ),
@@ -2967,7 +2869,7 @@ function ModalBody({
2967
2869
  defaultTab = "deposit",
2968
2870
  onDepositSuccess
2969
2871
  }) {
2970
- const { defaultToken, tokensStatus } = chunkACLJPC75_cjs.usePrivanaContext();
2872
+ const { defaultToken, tokensStatus } = chunkUHXVYWTF_cjs.usePrivanaContext();
2971
2873
  const [selectedToken, setSelectedToken] = react.useState(defaultToken);
2972
2874
  const [activeTab, setActiveTab] = react.useState(defaultTab);
2973
2875
  const [currentView, setCurrentView] = react.useState("main");
@@ -3025,7 +2927,7 @@ function ModalBody({
3025
2927
  );
3026
2928
  }
3027
2929
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 pb-4", children: [
3028
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkACLJPC75_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(
2930
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkUHXVYWTF_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(
3029
2931
  BalanceCards,
3030
2932
  {
3031
2933
  selectedToken,
@@ -3035,7 +2937,7 @@ function ModalBody({
3035
2937
  disabled: isInteractionPending
3036
2938
  }
3037
2939
  ) }),
3038
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkACLJPC75_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(Tabs, { activeTab, onTabChange: setActiveTab, disabled: isInteractionPending }) }),
2940
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkUHXVYWTF_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(Tabs, { activeTab, onTabChange: setActiveTab, disabled: isInteractionPending }) }),
3039
2941
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted rounded-[10px] p-5", children: activeTab === "deposit" ? /* @__PURE__ */ jsxRuntime.jsx(
3040
2942
  DepositForm,
3041
2943
  {
@@ -3096,7 +2998,7 @@ function PrivanaModal({
3096
2998
  onClick: handleClose,
3097
2999
  disabled: isCloseBlocked,
3098
3000
  "aria-label": "Close",
3099
- className: chunkACLJPC75_cjs.cn(
3001
+ className: chunkUHXVYWTF_cjs.cn(
3100
3002
  "absolute top-6 right-5 z-20 flex h-6 w-6 items-center justify-center transition-colors",
3101
3003
  isCloseBlocked ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
3102
3004
  ),
@@ -3152,7 +3054,7 @@ function PrivanaInlineModal({
3152
3054
  "div",
3153
3055
  {
3154
3056
  "data-privana": true,
3155
- className: chunkACLJPC75_cjs.cn(
3057
+ className: chunkUHXVYWTF_cjs.cn(
3156
3058
  "bg-card flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
3157
3059
  className
3158
3060
  ),
@@ -3187,12 +3089,12 @@ function PrivanaButton({
3187
3089
  }
3188
3090
  const handleClick = () => setModalOpen(true);
3189
3091
  const buttonElement = renderButton ? renderButton({ onClick: handleClick, isOpen: modalOpen }) : /* @__PURE__ */ jsxRuntime.jsx(
3190
- chunkACLJPC75_cjs.Button,
3092
+ chunkUHXVYWTF_cjs.Button,
3191
3093
  {
3192
3094
  variant,
3193
3095
  size,
3194
3096
  asChild,
3195
- className: chunkACLJPC75_cjs.cn(className),
3097
+ className: chunkUHXVYWTF_cjs.cn(className),
3196
3098
  onClick: handleClick,
3197
3099
  disabled: !isConnected,
3198
3100
  ...buttonProps,
@@ -3256,7 +3158,7 @@ function useMoonpayLimits({
3256
3158
  };
3257
3159
  }
3258
3160
  function TokenSelectorView2({ selectedTokenId, onSelect }) {
3259
- const { enabledTokens } = chunkACLJPC75_cjs.usePrivanaContext();
3161
+ const { enabledTokens } = chunkUHXVYWTF_cjs.usePrivanaContext();
3260
3162
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col rounded-[10px] p-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex max-h-72 flex-col gap-1 overflow-y-auto", children: [
3261
3163
  enabledTokens.map((token) => {
3262
3164
  const isSelected = selectedTokenId === token.id;
@@ -3265,7 +3167,7 @@ function TokenSelectorView2({ selectedTokenId, onSelect }) {
3265
3167
  {
3266
3168
  type: "button",
3267
3169
  onClick: () => onSelect(token.id),
3268
- className: chunkACLJPC75_cjs.cn(
3170
+ className: chunkUHXVYWTF_cjs.cn(
3269
3171
  "hover:bg-secondary flex w-full cursor-pointer items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors",
3270
3172
  isSelected && "bg-secondary"
3271
3173
  ),
@@ -3306,7 +3208,10 @@ function TokenSelectorView2({ selectedTokenId, onSelect }) {
3306
3208
  function CreditCardWidgetView({
3307
3209
  token,
3308
3210
  amount,
3309
- allowance
3211
+ allowance,
3212
+ onCredited,
3213
+ onLockSubmitted,
3214
+ onLockFailed
3310
3215
  }) {
3311
3216
  const moonpayCurrencyCode = token?.moonpayCurrencyCode;
3312
3217
  const containerRef = react.useRef(null);
@@ -3317,14 +3222,22 @@ function CreditCardWidgetView({
3317
3222
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
3318
3223
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: "Complete your purchase" }),
3319
3224
  token && moonpayCurrencyCode ? /* @__PURE__ */ jsxRuntime.jsx(
3320
- chunkACLJPC75_cjs.FiatOnRampForm,
3225
+ chunkUHXVYWTF_cjs.FiatOnRampForm,
3321
3226
  {
3322
3227
  tokenId: token.id,
3323
3228
  currencyCode: moonpayCurrencyCode,
3324
- defaultBaseCurrencyAmount: amount || void 0,
3229
+ quoteCurrencyAmount: amount || void 0,
3230
+ lockAmount: true,
3325
3231
  variant: "embedded",
3326
3232
  autoStart: true,
3327
- theme: widgetTheme
3233
+ theme: widgetTheme,
3234
+ postDepositLock: allowance ? {
3235
+ maxAmount: BigInt(allowance.value),
3236
+ lockDuration: allowance.lockDuration
3237
+ } : void 0,
3238
+ onCredited,
3239
+ onLockSubmitted,
3240
+ onLockFailed
3328
3241
  }
3329
3242
  ) : /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground text-sm", children: [
3330
3243
  token?.symbol ?? "This token",
@@ -3369,7 +3282,7 @@ function PolicyTermRow({
3369
3282
  /* @__PURE__ */ jsxRuntime.jsx(
3370
3283
  "div",
3371
3284
  {
3372
- className: chunkACLJPC75_cjs.cn(
3285
+ className: chunkUHXVYWTF_cjs.cn(
3373
3286
  "mt-0.5 shrink-0",
3374
3287
  kind === "permission" ? "text-emerald-500" : "text-orange-500"
3375
3288
  ),
@@ -3431,7 +3344,7 @@ function AllowancePolicySection({
3431
3344
  ] });
3432
3345
  }
3433
3346
  function MoonPayGate({ enabled, children }) {
3434
- const { networkConfig } = chunkACLJPC75_cjs.usePrivanaContext();
3347
+ const { networkConfig } = chunkUHXVYWTF_cjs.usePrivanaContext();
3435
3348
  const apiKey = networkConfig.moonpayApiKey;
3436
3349
  if (!enabled || !apiKey) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
3437
3350
  return /* @__PURE__ */ jsxRuntime.jsx(moonpayReact.MoonPayProvider, { apiKey, children });
@@ -3444,7 +3357,7 @@ function MethodTabs({
3444
3357
  /* @__PURE__ */ jsxRuntime.jsx(
3445
3358
  "div",
3446
3359
  {
3447
- className: chunkACLJPC75_cjs.cn(
3360
+ className: chunkUHXVYWTF_cjs.cn(
3448
3361
  "bg-input absolute top-1 bottom-1 left-1 w-[calc(50%-8px)] rounded-md transition-transform duration-200",
3449
3362
  activeTab === "credit-card" && "translate-x-[calc(100%+8px)]"
3450
3363
  )
@@ -3455,7 +3368,7 @@ function MethodTabs({
3455
3368
  {
3456
3369
  type: "button",
3457
3370
  onClick: () => onTabChange("crypto"),
3458
- className: chunkACLJPC75_cjs.cn(
3371
+ className: chunkUHXVYWTF_cjs.cn(
3459
3372
  "relative z-10 flex-1 cursor-pointer rounded-md px-3 py-[9px] text-sm font-medium transition-colors",
3460
3373
  activeTab === "crypto" ? "text-foreground" : "text-muted-foreground"
3461
3374
  ),
@@ -3467,7 +3380,7 @@ function MethodTabs({
3467
3380
  {
3468
3381
  type: "button",
3469
3382
  onClick: () => onTabChange("credit-card"),
3470
- className: chunkACLJPC75_cjs.cn(
3383
+ className: chunkUHXVYWTF_cjs.cn(
3471
3384
  "relative z-10 flex-1 cursor-pointer rounded-md px-3 py-[9px] text-sm font-medium transition-colors",
3472
3385
  activeTab === "credit-card" ? "text-foreground" : "text-muted-foreground"
3473
3386
  ),
@@ -3508,7 +3421,7 @@ function DepositView({
3508
3421
  onSubmit,
3509
3422
  isSubmitting = false
3510
3423
  }) {
3511
- const { getChainById: getChainById2, chains, serviceName, serviceIcon, networkConfig } = chunkACLJPC75_cjs.usePrivanaContext();
3424
+ const { getChainById: getChainById2, chains, serviceName, serviceIcon, networkConfig } = chunkUHXVYWTF_cjs.usePrivanaContext();
3512
3425
  const { address, isConnected } = wagmi.useAccount();
3513
3426
  const appName = serviceName ?? "Privana";
3514
3427
  const chain = selectedToken ? getChainById2(selectedToken.chainId) : void 0;
@@ -3531,7 +3444,7 @@ function DepositView({
3531
3444
  query: { enabled: isConnectedSource && !!address && !!selectedToken && !isNative }
3532
3445
  });
3533
3446
  const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
3534
- const formattedWalletBalance = walletBalance != null && selectedToken ? chunkACLJPC75_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
3447
+ const formattedWalletBalance = walletBalance != null && selectedToken ? chunkUHXVYWTF_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
3535
3448
  const {
3536
3449
  minBuyAmount: moonpayMinBuy,
3537
3450
  isLoading: moonpayLimitsLoading,
@@ -3544,7 +3457,7 @@ function DepositView({
3544
3457
  const hasValidAmount = !!amount && parseFloat(amount) > 0;
3545
3458
  const maxAmountDecimals = isCreditCard ? 2 : selectedToken?.decimals;
3546
3459
  const tooManyDecimals = hasValidAmount && maxAmountDecimals != null && amount.includes(".") && amount.split(".")[1].length > maxAmountDecimals;
3547
- const exceedsBalance = isConnectedSource && hasValidAmount && !tooManyDecimals && !!selectedToken && walletBalance != null && chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
3460
+ const exceedsBalance = isConnectedSource && hasValidAmount && !tooManyDecimals && !!selectedToken && walletBalance != null && chunkUHXVYWTF_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
3548
3461
  const belowMoonpayMin = isCreditCard && hasValidAmount && moonpayMinBuy != null && parseFloat(amount) < moonpayMinBuy;
3549
3462
  const moonpayLimitsUnready = isCreditCard && !!selectedToken?.moonpayCurrencyCode && moonpayMinBuy == null;
3550
3463
  const creditCardUnavailable = isCreditCard && !!selectedToken && !selectedToken.moonpayCurrencyCode;
@@ -3599,7 +3512,7 @@ function DepositView({
3599
3512
  /* @__PURE__ */ jsxRuntime.jsxs(
3600
3513
  "div",
3601
3514
  {
3602
- className: chunkACLJPC75_cjs.cn(
3515
+ className: chunkUHXVYWTF_cjs.cn(
3603
3516
  "border-border bg-input flex items-center gap-2 rounded-[10px] border",
3604
3517
  isConnectedSource ? "py-1 pr-1 pl-3" : "px-3 py-3"
3605
3518
  ),
@@ -3626,7 +3539,7 @@ function DepositView({
3626
3539
  className: "bg-secondary text-foreground hover:bg-secondary/80 cursor-pointer rounded px-3 py-2.5 text-xs font-semibold transition-colors",
3627
3540
  children: "MAX"
3628
3541
  }
3629
- ) : isCreditCard ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "USD" }) : selectedToken && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: selectedToken.symbol })
3542
+ ) : isCreditCard ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: selectedToken?.symbol ?? "USD" }) : selectedToken && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: selectedToken.symbol })
3630
3543
  ]
3631
3544
  }
3632
3545
  ),
@@ -3680,14 +3593,105 @@ function SummaryRow({ value, label }) {
3680
3593
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: label })
3681
3594
  ] });
3682
3595
  }
3596
+ var LISTENING_WINDOW_MS = 36e5;
3597
+ function remainingSeconds(deadline) {
3598
+ return Math.max(0, Math.round((deadline - Date.now()) / 1e3));
3599
+ }
3600
+ function useCountdown(deadline) {
3601
+ const [secondsLeft, setSecondsLeft] = react.useState(() => remainingSeconds(deadline));
3602
+ react.useEffect(() => {
3603
+ if (remainingSeconds(deadline) <= 0) return;
3604
+ const id = setInterval(() => {
3605
+ const left = remainingSeconds(deadline);
3606
+ setSecondsLeft(left);
3607
+ if (left <= 0) clearInterval(id);
3608
+ }, 1e3);
3609
+ return () => clearInterval(id);
3610
+ }, [deadline]);
3611
+ return secondsLeft;
3612
+ }
3613
+ function AwaitingDepositStatus({
3614
+ title,
3615
+ subtitle,
3616
+ remaining
3617
+ }) {
3618
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 text-center", children: [
3619
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 32 }) }),
3620
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
3621
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-foreground text-xl leading-6 font-medium", children: title }),
3622
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground text-sm leading-[18px]", children: [
3623
+ subtitle,
3624
+ remaining && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3625
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
3626
+ "Remaining time: ",
3627
+ remaining
3628
+ ] })
3629
+ ] })
3630
+ ] })
3631
+ ] });
3632
+ }
3683
3633
  function ExternalDepositView({
3684
3634
  token,
3685
- amount
3635
+ amount,
3636
+ onCredited
3686
3637
  }) {
3687
- const { getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
3638
+ const { getChainById: getChainById2 } = chunkUHXVYWTF_cjs.usePrivanaContext();
3688
3639
  const { depositAddress, isReady, isLoading } = useDepositAddress();
3689
3640
  const chain = token ? getChainById2(token.chainId) : void 0;
3690
3641
  const [copied, setCopied] = react.useState(false);
3642
+ const [deadline] = react.useState(() => Date.now() + LISTENING_WINDOW_MS);
3643
+ const secondsLeft = useCountdown(deadline);
3644
+ const listening = secondsLeft > 0;
3645
+ const [nothingFound, setNothingFound] = react.useState(false);
3646
+ const [credited, setCredited] = react.useState(null);
3647
+ const verification = chunkUHXVYWTF_cjs.useDepositVerification({
3648
+ onCredited: (txHash) => {
3649
+ if (onCredited) {
3650
+ onCredited();
3651
+ return;
3652
+ }
3653
+ setCredited({ txHash });
3654
+ }
3655
+ });
3656
+ const { isVerifying, verificationFailed, didTimeout, verify } = verification;
3657
+ const scanPaused = isVerifying || verificationFailed || didTimeout || !!credited;
3658
+ const {
3659
+ pending,
3660
+ isFetching: isScanning,
3661
+ isError: isScanError,
3662
+ isRateLimited,
3663
+ isUnavailable,
3664
+ refetch: refetchPendingDeposits
3665
+ } = usePendingDeposits({
3666
+ chainId: token?.chainId,
3667
+ enabled: isReady && !!depositAddress && !!token,
3668
+ refetchInterval: listening && !scanPaused ? 3e4 : false
3669
+ });
3670
+ const processedRef = react.useRef(/* @__PURE__ */ new Set());
3671
+ react.useEffect(() => {
3672
+ if (scanPaused) return;
3673
+ const next = [...pending].sort((a, b) => a.block_number - b.block_number).find((d) => !processedRef.current.has(`${d.tx_hash}:${d.log_index}`));
3674
+ if (!next) return;
3675
+ processedRef.current.add(`${next.tx_hash}:${next.log_index}`);
3676
+ void verify({
3677
+ hash: next.tx_hash,
3678
+ chainId: next.chain_id,
3679
+ amount: BigInt(next.amount),
3680
+ logIndex: next.log_index
3681
+ });
3682
+ }, [pending, scanPaused, verify]);
3683
+ const nothingFoundTimerRef = react.useRef(void 0);
3684
+ react.useEffect(() => () => clearTimeout(nothingFoundTimerRef.current), []);
3685
+ const handleRefresh = () => {
3686
+ processedRef.current.clear();
3687
+ void refetchPendingDeposits().then((result) => {
3688
+ if (!result || result.pending.length === 0) {
3689
+ setNothingFound(true);
3690
+ clearTimeout(nothingFoundTimerRef.current);
3691
+ nothingFoundTimerRef.current = setTimeout(() => setNothingFound(false), 4e3);
3692
+ }
3693
+ });
3694
+ };
3691
3695
  const handleCopy = () => {
3692
3696
  if (!depositAddress) return;
3693
3697
  void navigator.clipboard.writeText(depositAddress);
@@ -3706,11 +3710,11 @@ function ExternalDepositView({
3706
3710
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-border h-px w-full" }),
3707
3711
  /* @__PURE__ */ jsxRuntime.jsx(SummaryRow, { value: amount || "\u2014", label: "Value" })
3708
3712
  ] }),
3709
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-secondary flex h-50 items-center justify-center rounded-[10px]", children: !isReady ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground px-6 text-center text-sm", children: "Connect your wallet to generate a deposit address." }) : depositAddress ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-[10px] bg-white p-3", children: /* @__PURE__ */ jsxRuntime.jsx(qrcode_react.QRCodeSVG, { value: depositAddress, size: 160 }) }) : isLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunkACLJPC75_cjs.Skeleton, { className: "h-full w-full rounded-[10px]" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Deposit address unavailable" }) }),
3713
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-secondary flex h-50 items-center justify-center rounded-[10px]", children: !isReady ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground px-6 text-center text-sm", children: "Connect your wallet to generate a deposit address." }) : depositAddress ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-[10px] bg-white p-3", children: /* @__PURE__ */ jsxRuntime.jsx(qrcode_react.QRCodeSVG, { value: depositAddress, size: 160 }) }) : isLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunkUHXVYWTF_cjs.Skeleton, { className: "h-full w-full rounded-[10px]" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Deposit address unavailable" }) }),
3710
3714
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
3711
3715
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Deposit Address" }),
3712
3716
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
3713
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-border flex h-10 min-w-0 flex-1 items-center rounded-[10px] border px-3", children: depositAddress ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-foreground min-w-0 flex-1 truncate text-sm", children: depositAddress }) : isReady && isLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunkACLJPC75_cjs.Skeleton, { className: "h-4 w-3/4" }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "\u2014" }) }),
3717
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-border flex h-10 min-w-0 flex-1 items-center rounded-[10px] border px-3", children: depositAddress ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-foreground min-w-0 flex-1 truncate text-sm", children: depositAddress }) : isReady && isLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunkUHXVYWTF_cjs.Skeleton, { className: "h-4 w-3/4" }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "\u2014" }) }),
3714
3718
  /* @__PURE__ */ jsxRuntime.jsxs(
3715
3719
  "button",
3716
3720
  {
@@ -3725,6 +3729,55 @@ function ExternalDepositView({
3725
3729
  }
3726
3730
  )
3727
3731
  ] })
3732
+ ] }),
3733
+ credited ? /* @__PURE__ */ jsxRuntime.jsx(
3734
+ TransactionSuccessView,
3735
+ {
3736
+ title: "Deposit Credited",
3737
+ message: `Transfer ${chunkUHXVYWTF_cjs.shortenAddress(credited.txHash)} has been credited to your Privana balance.`,
3738
+ onDone: () => {
3739
+ setCredited(null);
3740
+ verification.reset();
3741
+ void refetchPendingDeposits();
3742
+ }
3743
+ }
3744
+ ) : verificationFailed || didTimeout ? /* @__PURE__ */ jsxRuntime.jsx(
3745
+ TransactionErrorView,
3746
+ {
3747
+ title: "Could not verify deposit",
3748
+ message: didTimeout ? "Verification timed out \u2014 your deposit may still be credited in the background." : verification.error?.message ?? "Your transfer was found but could not be verified.",
3749
+ onRetry: () => void verification.retryVerification(),
3750
+ onDismiss: () => verification.reset(),
3751
+ isRetrying: isVerifying
3752
+ }
3753
+ ) : isVerifying ? /* @__PURE__ */ jsxRuntime.jsx(
3754
+ AwaitingDepositStatus,
3755
+ {
3756
+ title: "Deposit detected",
3757
+ subtitle: "Crediting the incoming transaction to your Privana balance..."
3758
+ }
3759
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3760
+ /* @__PURE__ */ jsxRuntime.jsx(
3761
+ AwaitingDepositStatus,
3762
+ {
3763
+ title: "Awaiting Deposit",
3764
+ subtitle: listening ? "We are listening for your incoming transaction for the next hour." : "We've stopped listening automatically. Use the button below to check for your deposit.",
3765
+ remaining: listening ? chunkUHXVYWTF_cjs.formatCountdown(secondsLeft) : void 0
3766
+ }
3767
+ ),
3768
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
3769
+ /* @__PURE__ */ jsxRuntime.jsx(
3770
+ "button",
3771
+ {
3772
+ type: "button",
3773
+ onClick: handleRefresh,
3774
+ disabled: !depositAddress || isScanning,
3775
+ className: "bg-secondary text-foreground hover:bg-secondary/80 flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
3776
+ children: "Refresh deposit status"
3777
+ }
3778
+ ),
3779
+ isRateLimited ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-center text-sm", children: "Checked too recently \u2014 try again in a moment." }) : isUnavailable ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-center text-sm", children: "Deposit discovery is unavailable for this chain." }) : isScanError ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-center text-sm", children: "Chain temporarily unreachable \u2014 retrying automatically." }) : nothingFound ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-center text-sm", children: "No incoming transaction found yet." }) : null
3780
+ ] })
3728
3781
  ] })
3729
3782
  ] });
3730
3783
  }
@@ -3737,11 +3790,12 @@ function DepositModalContent({
3737
3790
  onConnectWallet,
3738
3791
  onDeposit,
3739
3792
  onDepositSuccess,
3793
+ onLockFailed,
3740
3794
  onClose,
3741
3795
  onCloseBlockedChange,
3742
3796
  onExit
3743
3797
  }) {
3744
- const { serviceName, enabledTokens, defaultToken, hostedAuthConfig, getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
3798
+ const { serviceName, enabledTokens, defaultToken, hostedAuthConfig, getChainById: getChainById2 } = chunkUHXVYWTF_cjs.usePrivanaContext();
3745
3799
  const { address } = wagmi.useAccount();
3746
3800
  const appName = serviceName ?? "Privana";
3747
3801
  const [activeTab, setActiveTab] = react.useState(defaultTab);
@@ -3768,6 +3822,21 @@ function DepositModalContent({
3768
3822
  const [showSuccess, setShowSuccess] = react.useState(false);
3769
3823
  const [showTimeout, setShowTimeout] = react.useState(false);
3770
3824
  const [cancelled, setCancelled] = react.useState(false);
3825
+ const [isSubmittingLock, setIsSubmittingLock] = react.useState(false);
3826
+ const [lockFailedMessage, setLockFailedMessage] = react.useState(null);
3827
+ const finishDeposit = () => {
3828
+ setAmount("");
3829
+ if (onDepositSuccess) {
3830
+ resetDeposit();
3831
+ onDepositSuccess();
3832
+ } else {
3833
+ setShowSuccess(true);
3834
+ }
3835
+ };
3836
+ const finishCardPurchase = () => {
3837
+ setAmount("");
3838
+ onDepositSuccess?.();
3839
+ };
3771
3840
  const {
3772
3841
  txHash,
3773
3842
  isGettingAddress,
@@ -3782,14 +3851,24 @@ function DepositModalContent({
3782
3851
  retryVerification,
3783
3852
  reset: resetDeposit
3784
3853
  } = useDeposit({
3785
- onCredited: () => {
3786
- setAmount("");
3787
- if (onDepositSuccess) {
3788
- resetDeposit();
3789
- onDepositSuccess();
3790
- } else {
3791
- setShowSuccess(true);
3854
+ onCredited: (_txHash, _response, lockPending) => {
3855
+ if (lockPending) {
3856
+ setIsSubmittingLock(true);
3857
+ return;
3792
3858
  }
3859
+ finishDeposit();
3860
+ },
3861
+ onLockSubmitted: () => {
3862
+ setIsSubmittingLock(false);
3863
+ finishDeposit();
3864
+ },
3865
+ // The deposit credited; only the policy lock failed. Success must not
3866
+ // fire (the host would act on unlocked funds) — show the dedicated
3867
+ // error view and let the host re-prompt for a fresh lock.
3868
+ onLockFailed: (err) => {
3869
+ setIsSubmittingLock(false);
3870
+ setLockFailedMessage(err.message);
3871
+ onLockFailed?.(err);
3793
3872
  },
3794
3873
  onCheckTimeout: () => {
3795
3874
  setAmount("");
@@ -3822,7 +3901,11 @@ function DepositModalContent({
3822
3901
  setCancelled(false);
3823
3902
  deposit({
3824
3903
  tokenId: token.id,
3825
- amount: chunkACLJPC75_cjs.parseTokenAmount(args.amount, token.decimals)
3904
+ amount: chunkUHXVYWTF_cjs.parseTokenAmount(args.amount, token.decimals),
3905
+ postDepositLock: allowance ? {
3906
+ maxAmount: BigInt(allowance.value),
3907
+ lockDuration: allowance.lockDuration
3908
+ } : void 0
3826
3909
  }).catch((err) => {
3827
3910
  sonner.toast.error(err instanceof Error ? err.message : "Deposit failed");
3828
3911
  });
@@ -3832,26 +3915,32 @@ function DepositModalContent({
3832
3915
  const depositSteps = [
3833
3916
  {
3834
3917
  label: "Getting deposit address",
3835
- status: isGettingAddress ? "active" : isSwitchingChain || isSendingTransaction || isWaitingForConfirmation || isWaitingForProcessing ? "completed" : "pending"
3918
+ status: isGettingAddress ? "active" : isSwitchingChain || isSendingTransaction || isWaitingForConfirmation || isWaitingForProcessing || isSubmittingLock ? "completed" : "pending"
3836
3919
  },
3837
3920
  {
3838
3921
  label: `Switching to ${targetChain?.name ?? "deposit chain"}`,
3839
- status: isSwitchingChain ? "active" : isSendingTransaction || isWaitingForConfirmation || isWaitingForProcessing ? "completed" : "pending"
3922
+ status: isSwitchingChain ? "active" : isSendingTransaction || isWaitingForConfirmation || isWaitingForProcessing || isSubmittingLock ? "completed" : "pending"
3840
3923
  },
3841
3924
  {
3842
3925
  label: "Confirm in wallet",
3843
- status: isSendingTransaction ? "active" : isWaitingForConfirmation || isWaitingForProcessing ? "completed" : "pending"
3926
+ status: isSendingTransaction ? "active" : isWaitingForConfirmation || isWaitingForProcessing || isSubmittingLock ? "completed" : "pending"
3844
3927
  },
3845
3928
  {
3846
3929
  label: "Confirming transaction",
3847
- status: isWaitingForConfirmation ? "active" : isWaitingForProcessing ? "completed" : "pending"
3930
+ status: isWaitingForConfirmation ? "active" : isWaitingForProcessing || isSubmittingLock ? "completed" : "pending"
3848
3931
  },
3849
3932
  {
3850
3933
  label: "Verifying deposit \u2014 may take up to a few minutes",
3851
- status: isWaitingForProcessing ? "active" : "pending"
3852
- }
3934
+ status: isWaitingForProcessing ? "active" : isSubmittingLock ? "completed" : "pending"
3935
+ },
3936
+ ...allowance ? [
3937
+ {
3938
+ label: `Locking funds for ${appName}`,
3939
+ status: isSubmittingLock ? "active" : "pending"
3940
+ }
3941
+ ] : []
3853
3942
  ];
3854
- const flowView = showSuccess ? "deposit-success" : showTimeout ? "deposit-timeout" : verificationFailed ? "deposit-error" : isPending && !cancelled ? "depositing" : null;
3943
+ const flowView = showSuccess ? "deposit-success" : lockFailedMessage ? "lock-error" : showTimeout ? "deposit-timeout" : verificationFailed ? "deposit-error" : isPending && !cancelled || isSubmittingLock ? "depositing" : null;
3855
3944
  const activeView = flowView ?? view;
3856
3945
  const handleDepositDone = () => {
3857
3946
  setShowSuccess(false);
@@ -3863,6 +3952,12 @@ function DepositModalContent({
3863
3952
  setCancelled(true);
3864
3953
  resetDeposit();
3865
3954
  };
3955
+ const handleLockFailedDone = () => {
3956
+ setLockFailedMessage(null);
3957
+ setAmount("");
3958
+ setCancelled(false);
3959
+ resetDeposit();
3960
+ };
3866
3961
  const handleDismissVerificationError = () => {
3867
3962
  setAmount("");
3868
3963
  setCancelled(false);
@@ -3888,7 +3983,7 @@ function DepositModalContent({
3888
3983
  onClick: onClose,
3889
3984
  disabled: isUnsafeToClose,
3890
3985
  "aria-label": "Close",
3891
- className: chunkACLJPC75_cjs.cn(
3986
+ className: chunkUHXVYWTF_cjs.cn(
3892
3987
  "absolute top-6 right-5 z-20 flex h-5 w-5 items-center justify-center transition-colors",
3893
3988
  isUnsafeToClose ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
3894
3989
  ),
@@ -3916,6 +4011,14 @@ function DepositModalContent({
3916
4011
  onDone: handleDepositDone
3917
4012
  }
3918
4013
  ),
4014
+ activeView === "lock-error" && /* @__PURE__ */ jsxRuntime.jsx(
4015
+ TransactionWarningView,
4016
+ {
4017
+ title: "Deposit credited, lock failed",
4018
+ message: `Your deposit was credited but locking the funds for ${appName} failed: ${lockFailedMessage}`,
4019
+ onDone: handleLockFailedDone
4020
+ }
4021
+ ),
3919
4022
  activeView === "deposit-timeout" && /* @__PURE__ */ jsxRuntime.jsx(
3920
4023
  TransactionWarningView,
3921
4024
  {
@@ -4009,8 +4112,28 @@ function DepositModalContent({
4009
4112
  }
4010
4113
  }
4011
4114
  ),
4012
- activeView === "external-deposit" && /* @__PURE__ */ jsxRuntime.jsx(ExternalDepositView, { token: selectedToken, amount }),
4013
- activeView === "credit-card-widget" && /* @__PURE__ */ jsxRuntime.jsx(MoonPayGate, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(CreditCardWidgetView, { token: selectedToken, amount, allowance }) })
4115
+ activeView === "external-deposit" && /* @__PURE__ */ jsxRuntime.jsx(
4116
+ ExternalDepositView,
4117
+ {
4118
+ token: selectedToken,
4119
+ amount,
4120
+ onCredited: allowance ? void 0 : onDepositSuccess
4121
+ }
4122
+ ),
4123
+ activeView === "credit-card-widget" && /* @__PURE__ */ jsxRuntime.jsx(MoonPayGate, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(
4124
+ CreditCardWidgetView,
4125
+ {
4126
+ token: selectedToken,
4127
+ amount,
4128
+ allowance,
4129
+ onCredited: allowance ? void 0 : finishCardPurchase,
4130
+ onLockSubmitted: finishCardPurchase,
4131
+ onLockFailed: (err) => {
4132
+ setLockFailedMessage(err.message);
4133
+ onLockFailed?.(err);
4134
+ }
4135
+ }
4136
+ ) })
4014
4137
  ] });
4015
4138
  }
4016
4139
  function DepositModal({ open, onClose, ...handlers }) {
@@ -4059,7 +4182,7 @@ function DepositInlineModal({ className, ...handlers }) {
4059
4182
  "div",
4060
4183
  {
4061
4184
  "data-privana": true,
4062
- className: chunkACLJPC75_cjs.cn(
4185
+ className: chunkUHXVYWTF_cjs.cn(
4063
4186
  "bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
4064
4187
  className
4065
4188
  ),
@@ -4074,7 +4197,7 @@ function WithdrawView({
4074
4197
  onSelectToken,
4075
4198
  onPendingChange
4076
4199
  }) {
4077
- const { chains, getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
4200
+ const { chains, getChainById: getChainById2 } = chunkUHXVYWTF_cjs.usePrivanaContext();
4078
4201
  const { isConnected, address } = wagmi.useAccount();
4079
4202
  const [showSuccess, setShowSuccess] = react.useState(false);
4080
4203
  const [showTimeout, setShowTimeout] = react.useState(false);
@@ -4088,7 +4211,7 @@ function WithdrawView({
4088
4211
  tokenId: selectedToken?.id,
4089
4212
  enabled: !!selectedToken
4090
4213
  });
4091
- const formattedBalance = selectedToken ? chunkACLJPC75_cjs.formatTokenAmount(balanceWei, selectedToken.decimals) : "0.00";
4214
+ const formattedBalance = selectedToken ? chunkUHXVYWTF_cjs.formatTokenAmount(balanceWei, selectedToken.decimals) : "0.00";
4092
4215
  const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
4093
4216
  onProcessingSuccess: () => {
4094
4217
  onAmountChange("");
@@ -4099,7 +4222,7 @@ function WithdrawView({
4099
4222
  setShowTimeout(true);
4100
4223
  }
4101
4224
  });
4102
- const explorerUrl = address && targetChain ? chunkACLJPC75_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
4225
+ const explorerUrl = address && targetChain ? chunkUHXVYWTF_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
4103
4226
  const getStepStatus = (step, after) => {
4104
4227
  if (currentStep === step) return "active";
4105
4228
  if (after.includes(currentStep)) return "completed";
@@ -4124,7 +4247,7 @@ function WithdrawView({
4124
4247
  }, [isPending, cancelled, onPendingChange]);
4125
4248
  const hasValidAmount = !!amount && parseFloat(amount) > 0;
4126
4249
  const tooManyDecimals = !!hasValidAmount && !!selectedToken && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
4127
- const exceedsBalance = !!hasValidAmount && !tooManyDecimals && !!selectedToken && !isBalanceLoading && !isBalanceError && chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
4250
+ const exceedsBalance = !!hasValidAmount && !tooManyDecimals && !!selectedToken && !isBalanceLoading && !isBalanceError && chunkUHXVYWTF_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
4128
4251
  const canWithdraw = isConnected && hasValidAmount && !!selectedToken && !tooManyDecimals && !exceedsBalance;
4129
4252
  const handleMax = () => {
4130
4253
  if (!selectedToken) return;
@@ -4136,7 +4259,7 @@ function WithdrawView({
4136
4259
  setCancelled(false);
4137
4260
  await withdraw({
4138
4261
  tokenId: selectedToken.id,
4139
- amount: chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals)
4262
+ amount: chunkUHXVYWTF_cjs.parseTokenAmount(amount, selectedToken.decimals)
4140
4263
  });
4141
4264
  };
4142
4265
  const handleCancel = () => {
@@ -4156,7 +4279,7 @@ function WithdrawView({
4156
4279
  title: "Withdrawal Complete",
4157
4280
  message: `Your ${selectedToken.symbol} withdrawal has been processed. Funds should appear in your wallet shortly.`,
4158
4281
  explorerUrl,
4159
- explorerLabel: targetChain ? chunkACLJPC75_cjs.getExplorerLabel(targetChain.id) : void 0,
4282
+ explorerLabel: targetChain ? chunkUHXVYWTF_cjs.getExplorerLabel(targetChain.id) : void 0,
4160
4283
  onDone: handleDone
4161
4284
  }
4162
4285
  ) });
@@ -4267,7 +4390,7 @@ function WithdrawModalContent({
4267
4390
  onPendingChange,
4268
4391
  onBack
4269
4392
  }) {
4270
- const { serviceName, enabledTokens, defaultToken, hostedAuthConfig } = chunkACLJPC75_cjs.usePrivanaContext();
4393
+ const { serviceName, enabledTokens, defaultToken, hostedAuthConfig } = chunkUHXVYWTF_cjs.usePrivanaContext();
4271
4394
  const { address } = wagmi.useAccount();
4272
4395
  const appName = serviceName ?? "Privana";
4273
4396
  const [view, setView] = react.useState("form");
@@ -4385,7 +4508,7 @@ function WithdrawInlineModal({ className }) {
4385
4508
  "div",
4386
4509
  {
4387
4510
  "data-privana": true,
4388
- className: chunkACLJPC75_cjs.cn(
4511
+ className: chunkUHXVYWTF_cjs.cn(
4389
4512
  "bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
4390
4513
  className
4391
4514
  ),
@@ -4429,14 +4552,14 @@ function SegmentedBalanceBar({
4429
4552
  showAvailable && /* @__PURE__ */ jsxRuntime.jsx(
4430
4553
  "div",
4431
4554
  {
4432
- className: chunkACLJPC75_cjs.cn(AVAILABLE_COLOR, "rounded-l-full", !showInUse && "rounded-r-full"),
4555
+ className: chunkUHXVYWTF_cjs.cn(AVAILABLE_COLOR, "rounded-l-full", !showInUse && "rounded-r-full"),
4433
4556
  style: { flexGrow: grow(availableWei) }
4434
4557
  }
4435
4558
  ),
4436
4559
  showInUse && /* @__PURE__ */ jsxRuntime.jsx(
4437
4560
  "div",
4438
4561
  {
4439
- className: chunkACLJPC75_cjs.cn(IN_USE_COLOR, "rounded-r-full", !showAvailable && "rounded-l-full"),
4562
+ className: chunkUHXVYWTF_cjs.cn(IN_USE_COLOR, "rounded-r-full", !showAvailable && "rounded-l-full"),
4440
4563
  style: { flexGrow: grow(inUseWei) }
4441
4564
  }
4442
4565
  )
@@ -4444,7 +4567,7 @@ function SegmentedBalanceBar({
4444
4567
  }
4445
4568
  function BalanceLegendItem({ color, label }) {
4446
4569
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
4447
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkACLJPC75_cjs.cn("h-2.5 w-2.5 rounded-full", color) }),
4570
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkUHXVYWTF_cjs.cn("h-2.5 w-2.5 rounded-full", color) }),
4448
4571
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-sm leading-5", children: label })
4449
4572
  ] });
4450
4573
  }
@@ -4453,11 +4576,11 @@ function WalletBalanceView({
4453
4576
  allowance,
4454
4577
  amount,
4455
4578
  onAmountChange,
4456
- onPlay,
4579
+ onFundSession,
4457
4580
  onAddFunds,
4458
4581
  onWithdraw
4459
4582
  }) {
4460
- const { serviceName, serviceIcon, defaultToken } = chunkACLJPC75_cjs.usePrivanaContext();
4583
+ const { serviceName, serviceIcon, defaultToken } = chunkUHXVYWTF_cjs.usePrivanaContext();
4461
4584
  const appName = serviceName ?? "Privana";
4462
4585
  const token = defaultToken;
4463
4586
  const {
@@ -4470,33 +4593,32 @@ function WalletBalanceView({
4470
4593
  const variant = !session ? "idle" : inUseWei === 0n ? "session-zero" : availableWei === 0n ? "fully-in-use" : "mixed";
4471
4594
  const expiry = session?.expiry;
4472
4595
  useNow(3e4, expiry != null);
4473
- const countdown = expiry != null ? chunkACLJPC75_cjs.formatTimeRemaining(expiry) : null;
4596
+ const countdown = expiry != null ? chunkUHXVYWTF_cjs.formatTimeRemaining(expiry) : null;
4474
4597
  const decimals = token?.decimals ?? 18;
4475
- const totalFormatted = chunkACLJPC75_cjs.formatTokenAmount((availableWei + inUseWei).toString(), decimals);
4476
- const availableFormatted = chunkACLJPC75_cjs.formatTokenAmount(availableWei.toString(), decimals);
4477
- const inUseFormatted = chunkACLJPC75_cjs.formatTokenAmount(inUseWei.toString(), decimals);
4598
+ const totalFormatted = chunkUHXVYWTF_cjs.formatTokenAmount((availableWei + inUseWei).toString(), decimals);
4599
+ const availableFormatted = chunkUHXVYWTF_cjs.formatTokenAmount(availableWei.toString(), decimals);
4600
+ const inUseFormatted = chunkUHXVYWTF_cjs.formatTokenAmount(inUseWei.toString(), decimals);
4478
4601
  const hasValidAmount = !!amount && parseFloat(amount) > 0;
4479
4602
  const tooManyDecimals = hasValidAmount && !!token && amount.includes(".") && amount.split(".")[1].length > token.decimals;
4480
- const exceedsBalance = hasValidAmount && !tooManyDecimals && !!token && !isBalanceLoading && !isBalanceError && chunkACLJPC75_cjs.parseTokenAmount(amount, token.decimals) > availableWei;
4481
- const canPlay = hasValidAmount && !!token && !tooManyDecimals && !exceedsBalance && !isBalanceLoading && !isBalanceError;
4603
+ const exceedsBalance = hasValidAmount && !tooManyDecimals && !!token && !isBalanceLoading && !isBalanceError && chunkUHXVYWTF_cjs.parseTokenAmount(amount, token.decimals) > availableWei;
4604
+ const canFundSession = hasValidAmount && !!token && !tooManyDecimals && !exceedsBalance && !isBalanceLoading && !isBalanceError;
4482
4605
  const handleMax = () => {
4483
4606
  const max = availableFormatted.replace(/\s/g, "");
4484
4607
  if (parseFloat(max) > 0) onAmountChange(max);
4485
4608
  };
4486
- const handlePlay = () => {
4487
- if (!token || !canPlay || !onPlay) return;
4488
- onPlay({ tokenId: token.id, amount });
4489
- onAmountChange("");
4609
+ const handleFundSession = () => {
4610
+ if (!token || !canFundSession || !onFundSession) return;
4611
+ onFundSession({ tokenId: token.id, amount });
4490
4612
  };
4491
4613
  const showInput = variant !== "fully-in-use";
4492
- const showInlinePlay = variant === "session-zero" || variant === "mixed";
4614
+ const showInlineFund = variant === "session-zero" || variant === "mixed";
4493
4615
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
4494
4616
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
4495
4617
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
4496
4618
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm leading-[14px]", children: "Total" }),
4497
4619
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-secondary text-muted-foreground rounded-full px-2 py-[5px] text-[10px] leading-[10px] font-bold", children: token?.symbol ?? "\u2014" })
4498
4620
  ] }),
4499
- isBalanceLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunkACLJPC75_cjs.Skeleton, { className: "h-9 w-40" }) : isBalanceError ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-[32px] leading-9 font-medium", children: "\u2014" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-[32px] leading-9 font-medium", children: totalFormatted })
4621
+ isBalanceLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunkUHXVYWTF_cjs.Skeleton, { className: "h-9 w-40" }) : isBalanceError ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-[32px] leading-9 font-medium", children: "\u2014" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-[32px] leading-9 font-medium", children: totalFormatted })
4500
4622
  ] }),
4501
4623
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
4502
4624
  /* @__PURE__ */ jsxRuntime.jsx(SegmentedBalanceBar, { availableWei, inUseWei }),
@@ -4541,14 +4663,14 @@ function WalletBalanceView({
4541
4663
  }
4542
4664
  )
4543
4665
  ] }),
4544
- showInlinePlay && /* @__PURE__ */ jsxRuntime.jsx(
4666
+ showInlineFund && /* @__PURE__ */ jsxRuntime.jsx(
4545
4667
  "button",
4546
4668
  {
4547
4669
  type: "button",
4548
- disabled: !onPlay || !canPlay,
4549
- onClick: handlePlay,
4670
+ disabled: !onFundSession || !canFundSession,
4671
+ onClick: handleFundSession,
4550
4672
  className: "border-border flex h-10 min-w-20 cursor-pointer items-center justify-center rounded-[10px] border px-3 text-sm font-medium text-[#4fc77f] transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",
4551
- children: "Play"
4673
+ children: "Fund session"
4552
4674
  }
4553
4675
  )
4554
4676
  ] }),
@@ -4572,10 +4694,10 @@ function WalletBalanceView({
4572
4694
  "button",
4573
4695
  {
4574
4696
  type: "button",
4575
- disabled: !onPlay || !canPlay,
4576
- onClick: handlePlay,
4697
+ disabled: !onFundSession || !canFundSession,
4698
+ onClick: handleFundSession,
4577
4699
  className: "bg-primary text-primary-foreground hover:bg-primary/90 flex h-10 flex-1 cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
4578
- children: "Play"
4700
+ children: "Fund session"
4579
4701
  }
4580
4702
  ),
4581
4703
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -4612,17 +4734,41 @@ function WalletBalanceView({
4612
4734
  ] }) })
4613
4735
  ] });
4614
4736
  }
4737
+ function invokeGuarded(runRef, invoke, handlers) {
4738
+ const run = ++runRef.current;
4739
+ const isCurrent = () => runRef.current === run;
4740
+ let result;
4741
+ try {
4742
+ result = invoke();
4743
+ } catch (err) {
4744
+ if (isCurrent()) handlers.onError(err);
4745
+ return;
4746
+ }
4747
+ if (result == null || typeof result.then !== "function") {
4748
+ handlers.onSyncResult();
4749
+ return;
4750
+ }
4751
+ handlers.onAsyncStart();
4752
+ result.then(
4753
+ () => {
4754
+ if (isCurrent()) handlers.onSuccess();
4755
+ },
4756
+ (err) => {
4757
+ if (isCurrent()) handlers.onError(err);
4758
+ }
4759
+ );
4760
+ }
4615
4761
  function WalletModalContent({
4616
4762
  session,
4617
4763
  allowance,
4618
- onPlay,
4764
+ onFundSession,
4619
4765
  onEndSession,
4620
4766
  onDepositSuccess,
4621
4767
  onClose,
4622
4768
  onCloseBlockedChange,
4623
4769
  ...depositHandlers
4624
4770
  }) {
4625
- const { serviceName, hostedAuthConfig } = chunkACLJPC75_cjs.usePrivanaContext();
4771
+ const { serviceName, hostedAuthConfig } = chunkUHXVYWTF_cjs.usePrivanaContext();
4626
4772
  const { address } = wagmi.useAccount();
4627
4773
  const appName = serviceName ?? "Privana";
4628
4774
  const [view, setView] = react.useState("balance");
@@ -4630,7 +4776,10 @@ function WalletModalContent({
4630
4776
  const [depositBlocked, setDepositBlocked] = react.useState(false);
4631
4777
  const [withdrawPending, setWithdrawPending] = react.useState(false);
4632
4778
  const [endSessionError, setEndSessionError] = react.useState(null);
4779
+ const [fundSessionError, setFundSessionError] = react.useState(null);
4633
4780
  const endSessionRunRef = react.useRef(0);
4781
+ const fundSessionRunRef = react.useRef(0);
4782
+ const [pendingFundSession, setPendingFundSession] = react.useState(null);
4634
4783
  const prevAddressRef = react.useRef(address);
4635
4784
  react.useEffect(() => {
4636
4785
  const prev = prevAddressRef.current;
@@ -4642,10 +4791,13 @@ function WalletModalContent({
4642
4791
  setDepositBlocked(false);
4643
4792
  setWithdrawPending(false);
4644
4793
  setEndSessionError(null);
4794
+ setFundSessionError(null);
4795
+ setPendingFundSession(null);
4645
4796
  endSessionRunRef.current++;
4797
+ fundSessionRunRef.current++;
4646
4798
  }
4647
4799
  }, [address, hostedAuthConfig]);
4648
- const closeBlocked = depositBlocked || withdrawPending || view === "ending-session";
4800
+ const closeBlocked = depositBlocked || withdrawPending || view === "funding-session" || view === "ending-session";
4649
4801
  react.useEffect(() => {
4650
4802
  onCloseBlockedChange?.(closeBlocked);
4651
4803
  }, [closeBlocked, onCloseBlockedChange]);
@@ -4659,20 +4811,16 @@ function WalletModalContent({
4659
4811
  };
4660
4812
  const startEndSession = () => {
4661
4813
  if (!onEndSession) return;
4662
- const run = ++endSessionRunRef.current;
4663
4814
  setEndSessionError(null);
4664
- setView("ending-session");
4665
- Promise.resolve().then(() => onEndSession()).then(
4666
- () => {
4667
- if (endSessionRunRef.current !== run) return;
4668
- setView("withdraw");
4669
- },
4670
- (err) => {
4671
- if (endSessionRunRef.current !== run) return;
4815
+ invokeGuarded(endSessionRunRef, () => onEndSession(), {
4816
+ onSyncResult: () => setView("withdraw"),
4817
+ onAsyncStart: () => setView("ending-session"),
4818
+ onSuccess: () => setView("withdraw"),
4819
+ onError: (err) => {
4672
4820
  setEndSessionError(err instanceof Error ? err.message : null);
4673
4821
  setView("end-session-error");
4674
4822
  }
4675
- );
4823
+ });
4676
4824
  };
4677
4825
  const handleWithdraw = () => {
4678
4826
  if (session && onEndSession) {
@@ -4686,6 +4834,36 @@ function WalletModalContent({
4686
4834
  setEndSessionError(null);
4687
4835
  setView("balance");
4688
4836
  };
4837
+ const fundSession = (args) => {
4838
+ if (!onFundSession) return;
4839
+ setFundSessionError(null);
4840
+ setPendingFundSession(args);
4841
+ setAmount("");
4842
+ invokeGuarded(fundSessionRunRef, () => onFundSession(args), {
4843
+ onSyncResult: () => {
4844
+ setPendingFundSession(null);
4845
+ setView("balance");
4846
+ },
4847
+ onAsyncStart: () => setView("funding-session"),
4848
+ onSuccess: () => {
4849
+ setPendingFundSession(null);
4850
+ setView("balance");
4851
+ },
4852
+ onError: (err) => {
4853
+ setFundSessionError(err instanceof Error ? err.message : null);
4854
+ setView("fund-session-error");
4855
+ }
4856
+ });
4857
+ };
4858
+ const dismissFundSessionError = () => {
4859
+ fundSessionRunRef.current++;
4860
+ setFundSessionError(null);
4861
+ if (pendingFundSession) {
4862
+ setAmount(pendingFundSession.amount);
4863
+ setPendingFundSession(null);
4864
+ }
4865
+ setView("balance");
4866
+ };
4689
4867
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4690
4868
  onClose && /* @__PURE__ */ jsxRuntime.jsx(
4691
4869
  "button",
@@ -4694,14 +4872,14 @@ function WalletModalContent({
4694
4872
  onClick: onClose,
4695
4873
  disabled: closeBlocked,
4696
4874
  "aria-label": "Close",
4697
- className: chunkACLJPC75_cjs.cn(
4875
+ className: chunkUHXVYWTF_cjs.cn(
4698
4876
  "absolute top-6 right-5 z-20 flex h-5 w-5 items-center justify-center transition-colors",
4699
4877
  closeBlocked ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
4700
4878
  ),
4701
4879
  children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {})
4702
4880
  }
4703
4881
  ),
4704
- (view === "balance" || view === "ending-session" || view === "end-session-error") && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center px-5 py-4", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-xl leading-5 font-medium", children: appName }) }),
4882
+ (view === "balance" || view === "funding-session" || view === "fund-session-error" || view === "ending-session" || view === "end-session-error") && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center px-5 py-4", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-xl leading-5 font-medium", children: appName }) }),
4705
4883
  view === "balance" && /* @__PURE__ */ jsxRuntime.jsx(
4706
4884
  WalletBalanceView,
4707
4885
  {
@@ -4709,11 +4887,30 @@ function WalletModalContent({
4709
4887
  allowance,
4710
4888
  amount,
4711
4889
  onAmountChange: setAmount,
4712
- onPlay,
4890
+ onFundSession: onFundSession ? fundSession : void 0,
4713
4891
  onAddFunds: () => setView("deposit"),
4714
4892
  onWithdraw: handleWithdraw
4715
4893
  }
4716
4894
  ),
4895
+ view === "funding-session" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
4896
+ TransactionProgressView,
4897
+ {
4898
+ title: "Funding session...",
4899
+ steps: [{ label: "Waiting for the session to be funded", status: "active" }]
4900
+ }
4901
+ ) }),
4902
+ view === "fund-session-error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
4903
+ TransactionErrorView,
4904
+ {
4905
+ title: "Could not fund session",
4906
+ message: fundSessionError ? `Your session could not be funded. (${fundSessionError})` : "Your session could not be funded.",
4907
+ onRetry: () => {
4908
+ if (pendingFundSession) fundSession(pendingFundSession);
4909
+ },
4910
+ onDismiss: dismissFundSessionError,
4911
+ retryLabel: "Try again"
4912
+ }
4913
+ ) }),
4717
4914
  view === "ending-session" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
4718
4915
  TransactionProgressView,
4719
4916
  {
@@ -4727,7 +4924,8 @@ function WalletModalContent({
4727
4924
  title: "Could not end session",
4728
4925
  message: endSessionError ? `Your game session could not be ended, so the funds committed to it are not available to withdraw yet. (${endSessionError})` : "Your game session could not be ended, so the funds committed to it are not available to withdraw yet.",
4729
4926
  onRetry: startEndSession,
4730
- onDismiss: dismissEndSessionError
4927
+ onDismiss: dismissEndSessionError,
4928
+ retryLabel: "Try again"
4731
4929
  }
4732
4930
  ) }),
4733
4931
  view === "withdraw" && /* @__PURE__ */ jsxRuntime.jsx(WithdrawModalContent, { onBack: exitWithdraw, onPendingChange: setWithdrawPending }),
@@ -4792,7 +4990,7 @@ function WalletInlineModal({ className, ...handlers }) {
4792
4990
  "div",
4793
4991
  {
4794
4992
  "data-privana": true,
4795
- className: chunkACLJPC75_cjs.cn(
4993
+ className: chunkUHXVYWTF_cjs.cn(
4796
4994
  "bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
4797
4995
  className
4798
4996
  ),
@@ -4803,214 +5001,300 @@ function WalletInlineModal({ className, ...handlers }) {
4803
5001
 
4804
5002
  Object.defineProperty(exports, "AccountingApiError", {
4805
5003
  enumerable: true,
4806
- get: function () { return chunkACLJPC75_cjs.AccountingApiError; }
5004
+ get: function () { return chunkUHXVYWTF_cjs.AccountingApiError; }
4807
5005
  });
4808
5006
  Object.defineProperty(exports, "Button", {
4809
5007
  enumerable: true,
4810
- get: function () { return chunkACLJPC75_cjs.Button; }
5008
+ get: function () { return chunkUHXVYWTF_cjs.Button; }
5009
+ });
5010
+ Object.defineProperty(exports, "DEFAULT_LOCK_DURATION_SECONDS", {
5011
+ enumerable: true,
5012
+ get: function () { return chunkUHXVYWTF_cjs.DEFAULT_LOCK_DURATION_SECONDS; }
5013
+ });
5014
+ Object.defineProperty(exports, "DEFAULT_ONRAMP_LOCK_BUFFER", {
5015
+ enumerable: true,
5016
+ get: function () { return chunkUHXVYWTF_cjs.DEFAULT_ONRAMP_LOCK_BUFFER; }
4811
5017
  });
4812
5018
  Object.defineProperty(exports, "HOSTED_AUTH_CLOCK_SKEW_MS", {
4813
5019
  enumerable: true,
4814
- get: function () { return chunkACLJPC75_cjs.HOSTED_AUTH_CLOCK_SKEW_MS; }
5020
+ get: function () { return chunkUHXVYWTF_cjs.HOSTED_AUTH_CLOCK_SKEW_MS; }
4815
5021
  });
4816
5022
  Object.defineProperty(exports, "HostedAuthError", {
4817
5023
  enumerable: true,
4818
- get: function () { return chunkACLJPC75_cjs.HostedAuthError; }
5024
+ get: function () { return chunkUHXVYWTF_cjs.HostedAuthError; }
4819
5025
  });
4820
5026
  Object.defineProperty(exports, "HostedAuthRequiredError", {
4821
5027
  enumerable: true,
4822
- get: function () { return chunkACLJPC75_cjs.HostedAuthRequiredError; }
5028
+ get: function () { return chunkUHXVYWTF_cjs.HostedAuthRequiredError; }
4823
5029
  });
4824
5030
  Object.defineProperty(exports, "HostedAuthStateMismatchError", {
4825
5031
  enumerable: true,
4826
- get: function () { return chunkACLJPC75_cjs.HostedAuthStateMismatchError; }
5032
+ get: function () { return chunkUHXVYWTF_cjs.HostedAuthStateMismatchError; }
4827
5033
  });
4828
5034
  Object.defineProperty(exports, "HttpClient", {
4829
5035
  enumerable: true,
4830
- get: function () { return chunkACLJPC75_cjs.HttpClient; }
5036
+ get: function () { return chunkUHXVYWTF_cjs.HttpClient; }
5037
+ });
5038
+ Object.defineProperty(exports, "LOCK_TYPES", {
5039
+ enumerable: true,
5040
+ get: function () { return chunkUHXVYWTF_cjs.LOCK_TYPES; }
5041
+ });
5042
+ Object.defineProperty(exports, "MODIFY_LOCK_TYPES", {
5043
+ enumerable: true,
5044
+ get: function () { return chunkUHXVYWTF_cjs.MODIFY_LOCK_TYPES; }
4831
5045
  });
4832
5046
  Object.defineProperty(exports, "NETWORK_CONFIG", {
4833
5047
  enumerable: true,
4834
- get: function () { return chunkACLJPC75_cjs.NETWORK_CONFIG; }
5048
+ get: function () { return chunkUHXVYWTF_cjs.NETWORK_CONFIG; }
4835
5049
  });
4836
5050
  Object.defineProperty(exports, "NetworkError", {
4837
5051
  enumerable: true,
4838
- get: function () { return chunkACLJPC75_cjs.NetworkError; }
5052
+ get: function () { return chunkUHXVYWTF_cjs.NetworkError; }
5053
+ });
5054
+ Object.defineProperty(exports, "PostDepositLockError", {
5055
+ enumerable: true,
5056
+ get: function () { return chunkUHXVYWTF_cjs.PostDepositLockError; }
4839
5057
  });
4840
5058
  Object.defineProperty(exports, "PrivanaClient", {
4841
5059
  enumerable: true,
4842
- get: function () { return chunkACLJPC75_cjs.PrivanaClient; }
5060
+ get: function () { return chunkUHXVYWTF_cjs.PrivanaClient; }
4843
5061
  });
4844
5062
  Object.defineProperty(exports, "PrivanaProvider", {
4845
5063
  enumerable: true,
4846
- get: function () { return chunkACLJPC75_cjs.PrivanaProvider; }
5064
+ get: function () { return chunkUHXVYWTF_cjs.PrivanaProvider; }
4847
5065
  });
4848
5066
  Object.defineProperty(exports, "SUPPORTED_CHAINS", {
4849
5067
  enumerable: true,
4850
- get: function () { return chunkACLJPC75_cjs.SUPPORTED_CHAINS; }
5068
+ get: function () { return chunkUHXVYWTF_cjs.SUPPORTED_CHAINS; }
4851
5069
  });
4852
5070
  Object.defineProperty(exports, "SiweAuthProvider", {
4853
5071
  enumerable: true,
4854
- get: function () { return chunkACLJPC75_cjs.SiweAuthProvider; }
5072
+ get: function () { return chunkUHXVYWTF_cjs.SiweAuthProvider; }
4855
5073
  });
4856
5074
  Object.defineProperty(exports, "Skeleton", {
4857
5075
  enumerable: true,
4858
- get: function () { return chunkACLJPC75_cjs.Skeleton; }
5076
+ get: function () { return chunkUHXVYWTF_cjs.Skeleton; }
5077
+ });
5078
+ Object.defineProperty(exports, "TRANSFER_LOCKED_TYPES", {
5079
+ enumerable: true,
5080
+ get: function () { return chunkUHXVYWTF_cjs.TRANSFER_LOCKED_TYPES; }
5081
+ });
5082
+ Object.defineProperty(exports, "TRANSFER_TYPES", {
5083
+ enumerable: true,
5084
+ get: function () { return chunkUHXVYWTF_cjs.TRANSFER_TYPES; }
4859
5085
  });
4860
5086
  Object.defineProperty(exports, "ValidationError", {
4861
5087
  enumerable: true,
4862
- get: function () { return chunkACLJPC75_cjs.ValidationError; }
5088
+ get: function () { return chunkUHXVYWTF_cjs.ValidationError; }
5089
+ });
5090
+ Object.defineProperty(exports, "WITHDRAW_FROM_LOCK_TYPES", {
5091
+ enumerable: true,
5092
+ get: function () { return chunkUHXVYWTF_cjs.WITHDRAW_FROM_LOCK_TYPES; }
5093
+ });
5094
+ Object.defineProperty(exports, "WITHDRAW_TYPES", {
5095
+ enumerable: true,
5096
+ get: function () { return chunkUHXVYWTF_cjs.WITHDRAW_TYPES; }
5097
+ });
5098
+ Object.defineProperty(exports, "applyLockBuffer", {
5099
+ enumerable: true,
5100
+ get: function () { return chunkUHXVYWTF_cjs.applyLockBuffer; }
4863
5101
  });
4864
5102
  Object.defineProperty(exports, "applyRefreshResponse", {
4865
5103
  enumerable: true,
4866
- get: function () { return chunkACLJPC75_cjs.applyRefreshResponse; }
5104
+ get: function () { return chunkUHXVYWTF_cjs.applyRefreshResponse; }
4867
5105
  });
4868
5106
  Object.defineProperty(exports, "buildHostedAuthSession", {
4869
5107
  enumerable: true,
4870
- get: function () { return chunkACLJPC75_cjs.buildHostedAuthSession; }
5108
+ get: function () { return chunkUHXVYWTF_cjs.buildHostedAuthSession; }
4871
5109
  });
4872
5110
  Object.defineProperty(exports, "buildSiweStatement", {
4873
5111
  enumerable: true,
4874
- get: function () { return chunkACLJPC75_cjs.buildSiweStatement; }
5112
+ get: function () { return chunkUHXVYWTF_cjs.buildSiweStatement; }
4875
5113
  });
4876
5114
  Object.defineProperty(exports, "buttonVariants", {
4877
5115
  enumerable: true,
4878
- get: function () { return chunkACLJPC75_cjs.buttonVariants; }
5116
+ get: function () { return chunkUHXVYWTF_cjs.buttonVariants; }
5117
+ });
5118
+ Object.defineProperty(exports, "clampLockAmount", {
5119
+ enumerable: true,
5120
+ get: function () { return chunkUHXVYWTF_cjs.clampLockAmount; }
4879
5121
  });
4880
5122
  Object.defineProperty(exports, "clearHostedAuthPendingTransaction", {
4881
5123
  enumerable: true,
4882
- get: function () { return chunkACLJPC75_cjs.clearHostedAuthPendingTransaction; }
5124
+ get: function () { return chunkUHXVYWTF_cjs.clearHostedAuthPendingTransaction; }
5125
+ });
5126
+ Object.defineProperty(exports, "clearPendingLock", {
5127
+ enumerable: true,
5128
+ get: function () { return chunkUHXVYWTF_cjs.clearPendingLock; }
5129
+ });
5130
+ Object.defineProperty(exports, "createDomain", {
5131
+ enumerable: true,
5132
+ get: function () { return chunkUHXVYWTF_cjs.createDomain; }
4883
5133
  });
4884
5134
  Object.defineProperty(exports, "createHostedAuthPendingStorageKey", {
4885
5135
  enumerable: true,
4886
- get: function () { return chunkACLJPC75_cjs.createHostedAuthPendingStorageKey; }
5136
+ get: function () { return chunkUHXVYWTF_cjs.createHostedAuthPendingStorageKey; }
4887
5137
  });
4888
5138
  Object.defineProperty(exports, "createHostedAuthState", {
4889
5139
  enumerable: true,
4890
- get: function () { return chunkACLJPC75_cjs.createHostedAuthState; }
5140
+ get: function () { return chunkUHXVYWTF_cjs.createHostedAuthState; }
4891
5141
  });
4892
5142
  Object.defineProperty(exports, "createHostedAuthStorageKey", {
4893
5143
  enumerable: true,
4894
- get: function () { return chunkACLJPC75_cjs.createHostedAuthStorageKey; }
5144
+ get: function () { return chunkUHXVYWTF_cjs.createHostedAuthStorageKey; }
5145
+ });
5146
+ Object.defineProperty(exports, "createLockExpiry", {
5147
+ enumerable: true,
5148
+ get: function () { return chunkUHXVYWTF_cjs.createLockExpiry; }
4895
5149
  });
4896
5150
  Object.defineProperty(exports, "createPkceChallenge", {
4897
5151
  enumerable: true,
4898
- get: function () { return chunkACLJPC75_cjs.createPkceChallenge; }
5152
+ get: function () { return chunkUHXVYWTF_cjs.createPkceChallenge; }
4899
5153
  });
4900
5154
  Object.defineProperty(exports, "createPkceVerifier", {
4901
5155
  enumerable: true,
4902
- get: function () { return chunkACLJPC75_cjs.createPkceVerifier; }
5156
+ get: function () { return chunkUHXVYWTF_cjs.createPkceVerifier; }
5157
+ });
5158
+ Object.defineProperty(exports, "createSignedLockRequest", {
5159
+ enumerable: true,
5160
+ get: function () { return chunkUHXVYWTF_cjs.createSignedLockRequest; }
4903
5161
  });
4904
5162
  Object.defineProperty(exports, "getAccountingContract", {
4905
5163
  enumerable: true,
4906
- get: function () { return chunkACLJPC75_cjs.getAccountingContract; }
5164
+ get: function () { return chunkUHXVYWTF_cjs.getAccountingContract; }
4907
5165
  });
4908
5166
  Object.defineProperty(exports, "getApiUrl", {
4909
5167
  enumerable: true,
4910
- get: function () { return chunkACLJPC75_cjs.getApiUrl; }
5168
+ get: function () { return chunkUHXVYWTF_cjs.getApiUrl; }
4911
5169
  });
4912
5170
  Object.defineProperty(exports, "getChainById", {
4913
5171
  enumerable: true,
4914
- get: function () { return chunkACLJPC75_cjs.getChainById; }
5172
+ get: function () { return chunkUHXVYWTF_cjs.getChainById; }
4915
5173
  });
4916
5174
  Object.defineProperty(exports, "getChainId", {
4917
5175
  enumerable: true,
4918
- get: function () { return chunkACLJPC75_cjs.getChainId; }
5176
+ get: function () { return chunkUHXVYWTF_cjs.getChainId; }
4919
5177
  });
4920
5178
  Object.defineProperty(exports, "getExplorerAddressUrl", {
4921
5179
  enumerable: true,
4922
- get: function () { return chunkACLJPC75_cjs.getExplorerAddressUrl; }
5180
+ get: function () { return chunkUHXVYWTF_cjs.getExplorerAddressUrl; }
4923
5181
  });
4924
5182
  Object.defineProperty(exports, "getExplorerLabel", {
4925
5183
  enumerable: true,
4926
- get: function () { return chunkACLJPC75_cjs.getExplorerLabel; }
5184
+ get: function () { return chunkUHXVYWTF_cjs.getExplorerLabel; }
4927
5185
  });
4928
5186
  Object.defineProperty(exports, "isHostedAuthRefreshActive", {
4929
5187
  enumerable: true,
4930
- get: function () { return chunkACLJPC75_cjs.isHostedAuthRefreshActive; }
5188
+ get: function () { return chunkUHXVYWTF_cjs.isHostedAuthRefreshActive; }
4931
5189
  });
4932
5190
  Object.defineProperty(exports, "isHostedAuthSessionActive", {
4933
5191
  enumerable: true,
4934
- get: function () { return chunkACLJPC75_cjs.isHostedAuthSessionActive; }
5192
+ get: function () { return chunkUHXVYWTF_cjs.isHostedAuthSessionActive; }
5193
+ });
5194
+ Object.defineProperty(exports, "isSignedLockUsable", {
5195
+ enumerable: true,
5196
+ get: function () { return chunkUHXVYWTF_cjs.isSignedLockUsable; }
5197
+ });
5198
+ Object.defineProperty(exports, "loadPendingLock", {
5199
+ enumerable: true,
5200
+ get: function () { return chunkUHXVYWTF_cjs.loadPendingLock; }
4935
5201
  });
4936
5202
  Object.defineProperty(exports, "normalizeAddress", {
4937
5203
  enumerable: true,
4938
- get: function () { return chunkACLJPC75_cjs.normalizeAddress; }
5204
+ get: function () { return chunkUHXVYWTF_cjs.normalizeAddress; }
4939
5205
  });
4940
5206
  Object.defineProperty(exports, "normalizeHex", {
4941
5207
  enumerable: true,
4942
- get: function () { return chunkACLJPC75_cjs.normalizeHex; }
5208
+ get: function () { return chunkUHXVYWTF_cjs.normalizeHex; }
4943
5209
  });
4944
5210
  Object.defineProperty(exports, "parseHostedAuthCallback", {
4945
5211
  enumerable: true,
4946
- get: function () { return chunkACLJPC75_cjs.parseHostedAuthCallback; }
5212
+ get: function () { return chunkUHXVYWTF_cjs.parseHostedAuthCallback; }
4947
5213
  });
4948
5214
  Object.defineProperty(exports, "persistHostedAuthPendingTransaction", {
4949
5215
  enumerable: true,
4950
- get: function () { return chunkACLJPC75_cjs.persistHostedAuthPendingTransaction; }
5216
+ get: function () { return chunkUHXVYWTF_cjs.persistHostedAuthPendingTransaction; }
4951
5217
  });
4952
5218
  Object.defineProperty(exports, "readHostedAuthPendingTransaction", {
4953
5219
  enumerable: true,
4954
- get: function () { return chunkACLJPC75_cjs.readHostedAuthPendingTransaction; }
5220
+ get: function () { return chunkUHXVYWTF_cjs.readHostedAuthPendingTransaction; }
4955
5221
  });
4956
5222
  Object.defineProperty(exports, "readStoredHostedAuthSession", {
4957
5223
  enumerable: true,
4958
- get: function () { return chunkACLJPC75_cjs.readStoredHostedAuthSession; }
5224
+ get: function () { return chunkUHXVYWTF_cjs.readStoredHostedAuthSession; }
5225
+ });
5226
+ Object.defineProperty(exports, "savePendingLock", {
5227
+ enumerable: true,
5228
+ get: function () { return chunkUHXVYWTF_cjs.savePendingLock; }
5229
+ });
5230
+ Object.defineProperty(exports, "signLockMessage", {
5231
+ enumerable: true,
5232
+ get: function () { return chunkUHXVYWTF_cjs.signLockMessage; }
5233
+ });
5234
+ Object.defineProperty(exports, "signModifyLockMessage", {
5235
+ enumerable: true,
5236
+ get: function () { return chunkUHXVYWTF_cjs.signModifyLockMessage; }
5237
+ });
5238
+ Object.defineProperty(exports, "signTransferLockedMessage", {
5239
+ enumerable: true,
5240
+ get: function () { return chunkUHXVYWTF_cjs.signTransferLockedMessage; }
5241
+ });
5242
+ Object.defineProperty(exports, "signTransferMessage", {
5243
+ enumerable: true,
5244
+ get: function () { return chunkUHXVYWTF_cjs.signTransferMessage; }
5245
+ });
5246
+ Object.defineProperty(exports, "signWithdrawFromLockMessage", {
5247
+ enumerable: true,
5248
+ get: function () { return chunkUHXVYWTF_cjs.signWithdrawFromLockMessage; }
5249
+ });
5250
+ Object.defineProperty(exports, "signWithdrawMessage", {
5251
+ enumerable: true,
5252
+ get: function () { return chunkUHXVYWTF_cjs.signWithdrawMessage; }
4959
5253
  });
4960
5254
  Object.defineProperty(exports, "stripHostedAuthCallbackParams", {
4961
5255
  enumerable: true,
4962
- get: function () { return chunkACLJPC75_cjs.stripHostedAuthCallbackParams; }
5256
+ get: function () { return chunkUHXVYWTF_cjs.stripHostedAuthCallbackParams; }
5257
+ });
5258
+ Object.defineProperty(exports, "submitPendingLock", {
5259
+ enumerable: true,
5260
+ get: function () { return chunkUHXVYWTF_cjs.submitPendingLock; }
4963
5261
  });
4964
5262
  Object.defineProperty(exports, "syncHostedAuthSessionToClient", {
4965
5263
  enumerable: true,
4966
- get: function () { return chunkACLJPC75_cjs.syncHostedAuthSessionToClient; }
5264
+ get: function () { return chunkUHXVYWTF_cjs.syncHostedAuthSessionToClient; }
4967
5265
  });
4968
5266
  Object.defineProperty(exports, "useDepositVerification", {
4969
5267
  enumerable: true,
4970
- get: function () { return chunkACLJPC75_cjs.useDepositVerification; }
5268
+ get: function () { return chunkUHXVYWTF_cjs.useDepositVerification; }
4971
5269
  });
4972
5270
  Object.defineProperty(exports, "usePrivanaContext", {
4973
5271
  enumerable: true,
4974
- get: function () { return chunkACLJPC75_cjs.usePrivanaContext; }
5272
+ get: function () { return chunkUHXVYWTF_cjs.usePrivanaContext; }
4975
5273
  });
4976
5274
  Object.defineProperty(exports, "useSafeAccount", {
4977
5275
  enumerable: true,
4978
- get: function () { return chunkACLJPC75_cjs.useSafeAccount; }
5276
+ get: function () { return chunkUHXVYWTF_cjs.useSafeAccount; }
4979
5277
  });
4980
5278
  Object.defineProperty(exports, "useSafePrivanaContext", {
4981
5279
  enumerable: true,
4982
- get: function () { return chunkACLJPC75_cjs.useSafePrivanaContext; }
5280
+ get: function () { return chunkUHXVYWTF_cjs.useSafePrivanaContext; }
4983
5281
  });
4984
5282
  Object.defineProperty(exports, "useSiweAuth", {
4985
5283
  enumerable: true,
4986
- get: function () { return chunkACLJPC75_cjs.useSiweAuth; }
5284
+ get: function () { return chunkUHXVYWTF_cjs.useSiweAuth; }
4987
5285
  });
4988
5286
  exports.DepositInlineModal = DepositInlineModal;
4989
5287
  exports.DepositModal = DepositModal;
4990
- exports.LOCK_TYPES = LOCK_TYPES;
4991
- exports.MODIFY_LOCK_TYPES = MODIFY_LOCK_TYPES;
4992
5288
  exports.PrivanaButton = PrivanaButton;
4993
5289
  exports.PrivanaIcon = PrivanaIcon;
4994
5290
  exports.PrivanaInlineModal = PrivanaInlineModal;
4995
5291
  exports.PrivanaModal = PrivanaModal;
4996
- exports.TRANSFER_LOCKED_TYPES = TRANSFER_LOCKED_TYPES;
4997
- exports.TRANSFER_TYPES = TRANSFER_TYPES;
4998
- exports.WITHDRAW_FROM_LOCK_TYPES = WITHDRAW_FROM_LOCK_TYPES;
4999
- exports.WITHDRAW_TYPES = WITHDRAW_TYPES;
5000
5292
  exports.WalletInlineModal = WalletInlineModal;
5001
5293
  exports.WalletModal = WalletModal;
5002
5294
  exports.WithdrawInlineModal = WithdrawInlineModal;
5003
5295
  exports.WithdrawModal = WithdrawModal;
5004
- exports.createDomain = createDomain;
5005
- exports.createLockExpiry = createLockExpiry;
5006
5296
  exports.getChainIcon = getChainIcon;
5007
5297
  exports.getTokenIcon = getTokenIcon;
5008
- exports.signLockMessage = signLockMessage;
5009
- exports.signModifyLockMessage = signModifyLockMessage;
5010
- exports.signTransferLockedMessage = signTransferLockedMessage;
5011
- exports.signTransferMessage = signTransferMessage;
5012
- exports.signWithdrawFromLockMessage = signWithdrawFromLockMessage;
5013
- exports.signWithdrawMessage = signWithdrawMessage;
5014
5298
  exports.useBalance = useBalance;
5015
5299
  exports.useBatchBalances = useBatchBalances;
5016
5300
  exports.useDeposit = useDeposit;
@@ -5021,6 +5305,7 @@ exports.useHostedRedirectAuth = useHostedRedirectAuth;
5021
5305
  exports.useLockFunds = useLockFunds;
5022
5306
  exports.useLockedFunds = useLockedFunds;
5023
5307
  exports.useModifyLock = useModifyLock;
5308
+ exports.usePendingDeposits = usePendingDeposits;
5024
5309
  exports.usePendingWithdrawals = usePendingWithdrawals;
5025
5310
  exports.usePrivanaClient = usePrivanaClient;
5026
5311
  exports.useTokenInfo = useTokenInfo;