@oasisprotocol/privana-sdk 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/{chunk-UHXVYWTF.cjs → chunk-7KEQHWZB.cjs} +902 -240
- package/dist/chunk-7KEQHWZB.cjs.map +1 -0
- package/dist/{chunk-ZVUMV4NR.js → chunk-DZURIIRE.js} +898 -242
- package/dist/chunk-DZURIIRE.js.map +1 -0
- package/dist/index.cjs +1356 -336
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +24 -11
- package/dist/index.d.ts +24 -11
- package/dist/index.js +1116 -104
- package/dist/index.js.map +1 -1
- package/dist/on-ramp.cjs +3 -3
- package/dist/on-ramp.d.cts +5 -4
- package/dist/on-ramp.d.ts +5 -4
- package/dist/on-ramp.js +1 -1
- package/dist/{pending-lock-BdkuMjmY.d.cts → pending-lock-f4bWWTyN.d.cts} +41 -7
- package/dist/{pending-lock-BdkuMjmY.d.ts → pending-lock-f4bWWTyN.d.ts} +41 -7
- package/package.json +1 -1
- package/dist/chunk-UHXVYWTF.cjs.map +0 -1
- package/dist/chunk-ZVUMV4NR.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunk7KEQHWZB_cjs = require('./chunk-7KEQHWZB.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var reactQuery = require('@tanstack/react-query');
|
|
7
7
|
var wagmi = require('wagmi');
|
|
@@ -35,18 +35,18 @@ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive)
|
|
|
35
35
|
|
|
36
36
|
// src/sdk/hooks/use-privana-client.ts
|
|
37
37
|
function usePrivanaClient() {
|
|
38
|
-
const { client } =
|
|
38
|
+
const { client } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
39
39
|
return client;
|
|
40
40
|
}
|
|
41
41
|
var hostedAuthExchangeInflight = /* @__PURE__ */ new Map();
|
|
42
42
|
function normalizeHostedAuthError(error) {
|
|
43
|
-
if (error instanceof
|
|
44
|
-
return new
|
|
43
|
+
if (error instanceof chunk7KEQHWZB_cjs.AccountingApiError && error.detail) {
|
|
44
|
+
return new chunk7KEQHWZB_cjs.HostedAuthError(error.detail);
|
|
45
45
|
}
|
|
46
46
|
if (error instanceof Error) {
|
|
47
47
|
return error;
|
|
48
48
|
}
|
|
49
|
-
return new
|
|
49
|
+
return new chunk7KEQHWZB_cjs.HostedAuthError("Hosted authentication failed.");
|
|
50
50
|
}
|
|
51
51
|
function useHostedRedirectAuth() {
|
|
52
52
|
const {
|
|
@@ -57,30 +57,30 @@ function useHostedRedirectAuth() {
|
|
|
57
57
|
setHostedAuthSession,
|
|
58
58
|
clearHostedAuthSession,
|
|
59
59
|
refreshHostedAuthSession
|
|
60
|
-
} =
|
|
60
|
+
} = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
61
61
|
const [error, setError] = react.useState(null);
|
|
62
62
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
63
63
|
const loginInflight = react.useRef(null);
|
|
64
64
|
const completionInflight = react.useRef(null);
|
|
65
65
|
const pendingStorageKey = react.useMemo(
|
|
66
|
-
() => hostedAuthConfig ?
|
|
66
|
+
() => hostedAuthConfig ? chunk7KEQHWZB_cjs.createHostedAuthPendingStorageKey(client.getBaseUrl(), hostedAuthConfig) : null,
|
|
67
67
|
[client, hostedAuthConfig]
|
|
68
68
|
);
|
|
69
69
|
const clearPendingLogin = react.useCallback(() => {
|
|
70
70
|
if (!pendingStorageKey || typeof window === "undefined") return;
|
|
71
|
-
|
|
71
|
+
chunk7KEQHWZB_cjs.clearHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
|
|
72
72
|
}, [pendingStorageKey]);
|
|
73
73
|
const login = react.useCallback(async () => {
|
|
74
74
|
if (!hostedAuthConfig) {
|
|
75
|
-
throw new
|
|
75
|
+
throw new chunk7KEQHWZB_cjs.HostedAuthRequiredError(
|
|
76
76
|
"Hosted redirect authentication is not configured for this provider."
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
79
|
if (typeof window === "undefined") {
|
|
80
|
-
throw new
|
|
80
|
+
throw new chunk7KEQHWZB_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
|
|
81
81
|
}
|
|
82
82
|
if (!pendingStorageKey) {
|
|
83
|
-
throw new
|
|
83
|
+
throw new chunk7KEQHWZB_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
|
|
84
84
|
}
|
|
85
85
|
if (loginInflight.current) {
|
|
86
86
|
return loginInflight.current;
|
|
@@ -89,10 +89,10 @@ function useHostedRedirectAuth() {
|
|
|
89
89
|
setIsLoading(true);
|
|
90
90
|
setError(null);
|
|
91
91
|
try {
|
|
92
|
-
const verifier =
|
|
93
|
-
const codeChallenge = await
|
|
94
|
-
const state =
|
|
95
|
-
|
|
92
|
+
const verifier = chunk7KEQHWZB_cjs.createPkceVerifier();
|
|
93
|
+
const codeChallenge = await chunk7KEQHWZB_cjs.createPkceChallenge(verifier);
|
|
94
|
+
const state = chunk7KEQHWZB_cjs.createHostedAuthState();
|
|
95
|
+
chunk7KEQHWZB_cjs.persistHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey, {
|
|
96
96
|
codeVerifier: verifier,
|
|
97
97
|
state
|
|
98
98
|
});
|
|
@@ -121,15 +121,15 @@ function useHostedRedirectAuth() {
|
|
|
121
121
|
}, [clearPendingLogin, client, hostedAuthConfig, networkConfig.chainId, pendingStorageKey]);
|
|
122
122
|
const completeLogin = react.useCallback(async () => {
|
|
123
123
|
if (!hostedAuthConfig) {
|
|
124
|
-
throw new
|
|
124
|
+
throw new chunk7KEQHWZB_cjs.HostedAuthRequiredError(
|
|
125
125
|
"Hosted redirect authentication is not configured for this provider."
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
128
|
if (typeof window === "undefined") {
|
|
129
|
-
throw new
|
|
129
|
+
throw new chunk7KEQHWZB_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
|
|
130
130
|
}
|
|
131
131
|
if (!pendingStorageKey) {
|
|
132
|
-
throw new
|
|
132
|
+
throw new chunk7KEQHWZB_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
|
|
133
133
|
}
|
|
134
134
|
if (completionInflight.current) {
|
|
135
135
|
return completionInflight.current;
|
|
@@ -139,30 +139,30 @@ function useHostedRedirectAuth() {
|
|
|
139
139
|
setError(null);
|
|
140
140
|
const callbackUrl = new URL(window.location.href);
|
|
141
141
|
const cleanupCallbackUrl = () => {
|
|
142
|
-
window.history.replaceState(null, "",
|
|
142
|
+
window.history.replaceState(null, "", chunk7KEQHWZB_cjs.stripHostedAuthCallbackParams(callbackUrl));
|
|
143
143
|
};
|
|
144
144
|
try {
|
|
145
|
-
const callback =
|
|
145
|
+
const callback = chunk7KEQHWZB_cjs.parseHostedAuthCallback(callbackUrl, hostedAuthConfig.redirectUri);
|
|
146
146
|
if (!callback) {
|
|
147
147
|
return null;
|
|
148
148
|
}
|
|
149
|
-
const pending =
|
|
149
|
+
const pending = chunk7KEQHWZB_cjs.readHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
|
|
150
150
|
if (!pending) {
|
|
151
151
|
clearPendingLogin();
|
|
152
152
|
cleanupCallbackUrl();
|
|
153
|
-
throw new
|
|
153
|
+
throw new chunk7KEQHWZB_cjs.HostedAuthError(
|
|
154
154
|
"Hosted authentication response could not be matched to a pending login request."
|
|
155
155
|
);
|
|
156
156
|
}
|
|
157
157
|
if (!callback.state || callback.state !== pending.state) {
|
|
158
158
|
clearPendingLogin();
|
|
159
159
|
cleanupCallbackUrl();
|
|
160
|
-
throw new
|
|
160
|
+
throw new chunk7KEQHWZB_cjs.HostedAuthStateMismatchError();
|
|
161
161
|
}
|
|
162
162
|
if ("error" in callback) {
|
|
163
163
|
clearPendingLogin();
|
|
164
164
|
cleanupCallbackUrl();
|
|
165
|
-
throw new
|
|
165
|
+
throw new chunk7KEQHWZB_cjs.HostedAuthError(
|
|
166
166
|
callback.errorDescription || callback.error || "Hosted authentication failed."
|
|
167
167
|
);
|
|
168
168
|
}
|
|
@@ -177,7 +177,7 @@ function useHostedRedirectAuth() {
|
|
|
177
177
|
client_id: hostedAuthConfig.clientId,
|
|
178
178
|
redirect_uri: hostedAuthConfig.redirectUri
|
|
179
179
|
});
|
|
180
|
-
const session =
|
|
180
|
+
const session = chunk7KEQHWZB_cjs.buildHostedAuthSession(response, hostedAuthConfig);
|
|
181
181
|
setHostedAuthSession(session);
|
|
182
182
|
clearPendingLogin();
|
|
183
183
|
cleanupCallbackUrl();
|
|
@@ -222,7 +222,7 @@ function useHostedRedirectAuth() {
|
|
|
222
222
|
try {
|
|
223
223
|
return await refreshHostedAuthSession();
|
|
224
224
|
} catch (refreshError) {
|
|
225
|
-
const normalizedError = refreshError instanceof Error ? refreshError : new
|
|
225
|
+
const normalizedError = refreshError instanceof Error ? refreshError : new chunk7KEQHWZB_cjs.HostedAuthError("Hosted authentication refresh failed.");
|
|
226
226
|
setError(normalizedError);
|
|
227
227
|
throw normalizedError;
|
|
228
228
|
} finally {
|
|
@@ -242,12 +242,12 @@ function useHostedRedirectAuth() {
|
|
|
242
242
|
}
|
|
243
243
|
function useBalance(options = {}) {
|
|
244
244
|
const queryClient = react.useContext(reactQuery.QueryClientContext);
|
|
245
|
-
const accountingContext =
|
|
245
|
+
const accountingContext = chunk7KEQHWZB_cjs.useSafePrivanaContext();
|
|
246
246
|
const hasProviders = !!queryClient && !!accountingContext;
|
|
247
247
|
const client = accountingContext?.client;
|
|
248
248
|
const defaultToken = accountingContext?.defaultToken;
|
|
249
249
|
const pollingInterval = accountingContext?.pollingInterval ?? 1e4;
|
|
250
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
250
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk7KEQHWZB_cjs.usePrivateReadRequest();
|
|
251
251
|
const tokenId = options.tokenId ?? defaultToken?.id;
|
|
252
252
|
const query = reactQuery.useQuery({
|
|
253
253
|
queryKey: ["accounting-balance", ...privateReadQueryScope, tokenId],
|
|
@@ -255,7 +255,7 @@ function useBalance(options = {}) {
|
|
|
255
255
|
if (!privateReadAddress) throw new Error("No authenticated account available");
|
|
256
256
|
if (!tokenId) throw new Error("No token ID provided");
|
|
257
257
|
if (!client) throw new Error("No accounting client");
|
|
258
|
-
return executePrivateRead(() =>
|
|
258
|
+
return executePrivateRead((readClient) => readClient.getBalance(tokenId));
|
|
259
259
|
},
|
|
260
260
|
enabled: hasProviders && (options.enabled ?? true) && privateReadReady && !!privateReadAddress && !!tokenId && !!client,
|
|
261
261
|
refetchInterval: pollingInterval
|
|
@@ -264,7 +264,7 @@ function useBalance(options = {}) {
|
|
|
264
264
|
return {
|
|
265
265
|
balance: balanceWei,
|
|
266
266
|
balanceWei,
|
|
267
|
-
balanceFormatted:
|
|
267
|
+
balanceFormatted: chunk7KEQHWZB_cjs.formatTokenAmount(balanceWei),
|
|
268
268
|
tokenSymbol: query.data?.token_symbol ?? "",
|
|
269
269
|
chainId: query.data?.chain_id ?? "",
|
|
270
270
|
isLoading: query.isPending || query.isLoading,
|
|
@@ -274,13 +274,15 @@ function useBalance(options = {}) {
|
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
276
|
function useBatchBalances(options) {
|
|
277
|
-
const { client, pollingInterval } =
|
|
278
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
277
|
+
const { client, pollingInterval } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
278
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk7KEQHWZB_cjs.usePrivateReadRequest();
|
|
279
279
|
const query = reactQuery.useQuery({
|
|
280
280
|
queryKey: ["accounting-batch-balances", ...privateReadQueryScope, options.tokenIds],
|
|
281
281
|
queryFn: async () => {
|
|
282
282
|
if (!privateReadAddress) throw new Error("No authenticated account available");
|
|
283
|
-
return executePrivateRead(
|
|
283
|
+
return executePrivateRead(
|
|
284
|
+
(readClient) => readClient.getBatchBalances({ token_ids: options.tokenIds })
|
|
285
|
+
);
|
|
284
286
|
},
|
|
285
287
|
enabled: (options.enabled ?? true) && privateReadReady && !!privateReadAddress && options.tokenIds.length > 0 && !!client,
|
|
286
288
|
refetchInterval: pollingInterval
|
|
@@ -298,17 +300,17 @@ function storageKey(address) {
|
|
|
298
300
|
return `privana:pending-deposit:${address.toLowerCase()}`;
|
|
299
301
|
}
|
|
300
302
|
function savePendingDeposit(address, data) {
|
|
301
|
-
const stored =
|
|
303
|
+
const stored = chunk7KEQHWZB_cjs.setBrowserStorageItem(storageKey(address), JSON.stringify(data));
|
|
302
304
|
if (!stored && data.signedLock) {
|
|
303
305
|
throw new Error("Unable to persist pending locked deposit for recovery");
|
|
304
306
|
}
|
|
305
307
|
}
|
|
306
308
|
function loadPendingDeposit(address) {
|
|
307
309
|
try {
|
|
308
|
-
const raw =
|
|
310
|
+
const raw = chunk7KEQHWZB_cjs.getBrowserStorageItem(storageKey(address));
|
|
309
311
|
if (!raw) return null;
|
|
310
312
|
const data = JSON.parse(raw);
|
|
311
|
-
if (Date.now() - data.savedAt > STALE_MS && !(data.signedLock &&
|
|
313
|
+
if (Date.now() - data.savedAt > STALE_MS && !(data.signedLock && chunk7KEQHWZB_cjs.isSignedLockUsable(data.signedLock))) {
|
|
312
314
|
clearPendingDeposit(address);
|
|
313
315
|
return null;
|
|
314
316
|
}
|
|
@@ -320,21 +322,23 @@ function loadPendingDeposit(address) {
|
|
|
320
322
|
function clearPendingDeposit(address, onlyForTxHash) {
|
|
321
323
|
if (onlyForTxHash) {
|
|
322
324
|
try {
|
|
323
|
-
const raw =
|
|
325
|
+
const raw = chunk7KEQHWZB_cjs.getBrowserStorageItem(storageKey(address));
|
|
324
326
|
const recordTxHash = raw ? JSON.parse(raw).txHash : void 0;
|
|
325
327
|
if (recordTxHash && recordTxHash !== onlyForTxHash) return;
|
|
326
328
|
} catch {
|
|
327
329
|
}
|
|
328
330
|
}
|
|
329
|
-
|
|
331
|
+
chunk7KEQHWZB_cjs.removeBrowserStorageItem(storageKey(address));
|
|
330
332
|
}
|
|
331
333
|
function useDeposit(options = {}) {
|
|
332
334
|
const { address } = wagmi.useAccount();
|
|
333
|
-
const { client, enabledTokens, getChainById: getChainById2, networkConfig, serviceAddress } =
|
|
335
|
+
const { client, enabledTokens, getChainById: getChainById2, networkConfig, serviceAddress } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
334
336
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
335
337
|
const queryClient = reactQuery.useQueryClient();
|
|
336
338
|
const config = wagmi.useConfig();
|
|
337
|
-
const { executePrivateRead } =
|
|
339
|
+
const { executePrivateRead, privateReadAddress } = chunk7KEQHWZB_cjs.usePrivateReadRequest();
|
|
340
|
+
const privateReadAddressRef = react.useRef(privateReadAddress);
|
|
341
|
+
privateReadAddressRef.current = privateReadAddress;
|
|
338
342
|
const confirmations = options.confirmations ?? 15;
|
|
339
343
|
const [depositAddress, setDepositAddress] = react.useState(null);
|
|
340
344
|
const [txHash, setTxHash] = react.useState();
|
|
@@ -370,12 +374,12 @@ function useDeposit(options = {}) {
|
|
|
370
374
|
]);
|
|
371
375
|
const pendingLockRef = react.useRef(null);
|
|
372
376
|
const submitPendingLockAfterCredit = react.useCallback(
|
|
373
|
-
async (signedLock,
|
|
377
|
+
async (signedLock, creditedAmount) => {
|
|
374
378
|
try {
|
|
375
|
-
const result = await
|
|
379
|
+
const result = await chunk7KEQHWZB_cjs.submitPendingLock({
|
|
376
380
|
client,
|
|
377
381
|
payload: signedLock,
|
|
378
|
-
creditedAmount
|
|
382
|
+
creditedAmount
|
|
379
383
|
});
|
|
380
384
|
queryClient.invalidateQueries({ queryKey: ["accounting-balance"] });
|
|
381
385
|
queryClient.invalidateQueries({ queryKey: ["accounting-locked-funds"] });
|
|
@@ -383,11 +387,11 @@ function useDeposit(options = {}) {
|
|
|
383
387
|
queryClient.invalidateQueries({ queryKey: ["accounting-history"] });
|
|
384
388
|
onLockSubmittedRef.current?.(result);
|
|
385
389
|
} catch (err) {
|
|
386
|
-
const error2 = err instanceof
|
|
390
|
+
const error2 = err instanceof chunk7KEQHWZB_cjs.PostDepositLockError ? err : new chunk7KEQHWZB_cjs.PostDepositLockError(
|
|
387
391
|
err instanceof Error ? err.message : "Lock submission failed",
|
|
388
392
|
"submission-failed",
|
|
389
393
|
BigInt(signedLock.amount),
|
|
390
|
-
|
|
394
|
+
creditedAmount,
|
|
391
395
|
{ cause: err }
|
|
392
396
|
);
|
|
393
397
|
(onLockFailedRef.current ?? onErrorRef.current)?.(error2);
|
|
@@ -402,15 +406,15 @@ function useDeposit(options = {}) {
|
|
|
402
406
|
error: verificationError,
|
|
403
407
|
verify,
|
|
404
408
|
reset: resetVerification
|
|
405
|
-
} =
|
|
409
|
+
} = chunk7KEQHWZB_cjs.useDepositVerification({
|
|
406
410
|
pollInterval: options.pollInterval,
|
|
407
411
|
pollTimeout: options.pollTimeout,
|
|
408
|
-
onCredited: (hash, response) => {
|
|
412
|
+
onCredited: (hash, response, creditedAmount) => {
|
|
409
413
|
verificationContextRef.current = null;
|
|
410
414
|
const signedLock = pendingLockRef.current;
|
|
411
415
|
pendingLockRef.current = null;
|
|
412
416
|
if (signedLock) {
|
|
413
|
-
void submitPendingLockAfterCredit(signedLock,
|
|
417
|
+
void submitPendingLockAfterCredit(signedLock, creditedAmount).finally(() => {
|
|
414
418
|
if (address) clearPendingDeposit(address, hash);
|
|
415
419
|
});
|
|
416
420
|
} else if (address) {
|
|
@@ -428,7 +432,7 @@ function useDeposit(options = {}) {
|
|
|
428
432
|
const addressMutation = reactQuery.useMutation({
|
|
429
433
|
mutationFn: async () => {
|
|
430
434
|
if (!address) throw new Error("No wallet connected");
|
|
431
|
-
return executePrivateRead(() =>
|
|
435
|
+
return executePrivateRead((readClient) => readClient.getDepositAddress());
|
|
432
436
|
},
|
|
433
437
|
onSuccess: (data) => {
|
|
434
438
|
setDepositAddress(data);
|
|
@@ -452,7 +456,7 @@ function useDeposit(options = {}) {
|
|
|
452
456
|
} = wagmi.useSendTransaction();
|
|
453
457
|
const isSendingTx = isWritingContract || isSendingNative;
|
|
454
458
|
const sendError = writeError ?? sendNativeError;
|
|
455
|
-
const { ensureCorrectChain } =
|
|
459
|
+
const { ensureCorrectChain } = chunk7KEQHWZB_cjs.useEnsureCorrectChain();
|
|
456
460
|
const invalidateGeneration = react.useCallback(() => {
|
|
457
461
|
generationRef.current++;
|
|
458
462
|
}, []);
|
|
@@ -500,16 +504,16 @@ function useDeposit(options = {}) {
|
|
|
500
504
|
try {
|
|
501
505
|
let confirmed = false;
|
|
502
506
|
try {
|
|
503
|
-
const receipt = await
|
|
507
|
+
const receipt = await chunk7KEQHWZB_cjs.getTransactionReceipt(config, {
|
|
504
508
|
hash,
|
|
505
509
|
chainId: persisted.chainId
|
|
506
510
|
});
|
|
507
|
-
const blockNumber = await
|
|
511
|
+
const blockNumber = await chunk7KEQHWZB_cjs.getBlockNumber(config, { chainId: persisted.chainId });
|
|
508
512
|
confirmed = blockNumber - receipt.blockNumber + 1n >= BigInt(confirmations);
|
|
509
513
|
} catch {
|
|
510
514
|
}
|
|
511
515
|
if (!confirmed) {
|
|
512
|
-
await
|
|
516
|
+
await chunk7KEQHWZB_cjs.waitForTransactionReceipt(config, {
|
|
513
517
|
hash,
|
|
514
518
|
chainId: persisted.chainId,
|
|
515
519
|
confirmations
|
|
@@ -560,12 +564,13 @@ function useDeposit(options = {}) {
|
|
|
560
564
|
`Amount is below the minimum deposit (${minAmountStr}) for ${isNative ? "native" : "ERC-20"} on chain ${sourceChain.id}`
|
|
561
565
|
);
|
|
562
566
|
}
|
|
563
|
-
if (params.postDepositLock && !
|
|
567
|
+
if (params.postDepositLock && !chunk7KEQHWZB_cjs.canUseBrowserStorage()) {
|
|
564
568
|
throw new Error("Browser storage is required for locked deposit recovery");
|
|
565
569
|
}
|
|
566
|
-
const lockAmount =
|
|
570
|
+
const lockAmount = chunk7KEQHWZB_cjs.clampLockAmount(params.amount, params.postDepositLock?.maxAmount);
|
|
567
571
|
let signedLock;
|
|
568
572
|
if (params.postDepositLock) {
|
|
573
|
+
const lockOwner = chunk7KEQHWZB_cjs.requireDepositLockOwner(address, privateReadAddress);
|
|
569
574
|
setIsSwitchingChain(true);
|
|
570
575
|
try {
|
|
571
576
|
await ensureCorrectChain(networkConfig.chainId);
|
|
@@ -573,21 +578,24 @@ function useDeposit(options = {}) {
|
|
|
573
578
|
if (!isStale()) setIsSwitchingChain(false);
|
|
574
579
|
}
|
|
575
580
|
if (isStale()) return;
|
|
576
|
-
const signingWalletClient = await
|
|
581
|
+
const signingWalletClient = await chunk7KEQHWZB_cjs.getWalletClient(config, {
|
|
577
582
|
chainId: networkConfig.chainId
|
|
578
583
|
});
|
|
579
|
-
signedLock = await
|
|
584
|
+
signedLock = await chunk7KEQHWZB_cjs.createSignedLockRequest({
|
|
580
585
|
client,
|
|
581
586
|
walletClient: signingWalletClient,
|
|
582
|
-
userAddress:
|
|
587
|
+
userAddress: lockOwner,
|
|
583
588
|
networkConfig,
|
|
584
|
-
serviceAddress: requireServiceAddress(
|
|
589
|
+
serviceAddress: chunk7KEQHWZB_cjs.requireServiceAddress(
|
|
585
590
|
params.postDepositLock.serviceAddress ?? serviceAddress
|
|
586
591
|
),
|
|
587
592
|
tokenId: params.tokenId,
|
|
588
593
|
amount: lockAmount,
|
|
589
594
|
lockDuration: params.postDepositLock.lockDuration
|
|
590
595
|
});
|
|
596
|
+
if (privateReadAddressRef.current?.toLowerCase() !== lockOwner.toLowerCase()) {
|
|
597
|
+
throw new Error("Authenticated deposit account changed while signing");
|
|
598
|
+
}
|
|
591
599
|
}
|
|
592
600
|
if (isStale()) return;
|
|
593
601
|
setIsSwitchingChain(true);
|
|
@@ -632,7 +640,7 @@ function useDeposit(options = {}) {
|
|
|
632
640
|
try {
|
|
633
641
|
setIsWaitingForConfirmation(true);
|
|
634
642
|
try {
|
|
635
|
-
await
|
|
643
|
+
await chunk7KEQHWZB_cjs.waitForTransactionReceipt(config, {
|
|
636
644
|
hash,
|
|
637
645
|
chainId: sourceChain.id,
|
|
638
646
|
confirmations
|
|
@@ -670,6 +678,7 @@ function useDeposit(options = {}) {
|
|
|
670
678
|
enabledTokens,
|
|
671
679
|
ensureCorrectChain,
|
|
672
680
|
networkConfig,
|
|
681
|
+
privateReadAddress,
|
|
673
682
|
queryClient,
|
|
674
683
|
serviceAddress,
|
|
675
684
|
writeContractAsync,
|
|
@@ -706,29 +715,24 @@ function useDeposit(options = {}) {
|
|
|
706
715
|
reset
|
|
707
716
|
};
|
|
708
717
|
}
|
|
709
|
-
function requireServiceAddress(serviceAddress) {
|
|
710
|
-
if (!serviceAddress) {
|
|
711
|
-
throw new Error("Service address not configured");
|
|
712
|
-
}
|
|
713
|
-
return serviceAddress;
|
|
714
|
-
}
|
|
715
718
|
function useDepositAddress(options = {}) {
|
|
716
719
|
const queryClient = react.useContext(reactQuery.QueryClientContext);
|
|
717
|
-
const accountingContext =
|
|
720
|
+
const accountingContext = chunk7KEQHWZB_cjs.useSafePrivanaContext();
|
|
718
721
|
const hasProviders = !!queryClient && !!accountingContext;
|
|
719
722
|
const client = accountingContext?.client;
|
|
720
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
723
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk7KEQHWZB_cjs.usePrivateReadRequest();
|
|
721
724
|
const isReady = hasProviders && privateReadReady && !!privateReadAddress && !!client;
|
|
722
725
|
const query = reactQuery.useQuery({
|
|
723
726
|
queryKey: ["accounting-deposit-address", ...privateReadQueryScope],
|
|
724
727
|
queryFn: async () => {
|
|
725
728
|
if (!privateReadAddress) throw new Error("No authenticated account available");
|
|
726
729
|
if (!client) throw new Error("No accounting client");
|
|
727
|
-
return executePrivateRead(() =>
|
|
730
|
+
return executePrivateRead((readClient) => readClient.getDepositAddress());
|
|
728
731
|
},
|
|
729
732
|
enabled: isReady && (options.enabled ?? true)
|
|
730
733
|
});
|
|
731
734
|
return {
|
|
735
|
+
response: query.data,
|
|
732
736
|
depositAddress: query.data?.deposit_address ?? null,
|
|
733
737
|
isReady,
|
|
734
738
|
isLoading: query.isLoading,
|
|
@@ -740,9 +744,9 @@ function useDepositAddress(options = {}) {
|
|
|
740
744
|
function useWithdraw(options = {}) {
|
|
741
745
|
const { address } = wagmi.useAccount();
|
|
742
746
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
743
|
-
const { client, networkConfig } =
|
|
747
|
+
const { client, networkConfig } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
744
748
|
const queryClient = reactQuery.useQueryClient();
|
|
745
|
-
const { chainId, ensureCorrectChain } =
|
|
749
|
+
const { chainId, ensureCorrectChain } = chunk7KEQHWZB_cjs.useEnsureCorrectChain();
|
|
746
750
|
const pollInterval = options.pollInterval ?? 3e3;
|
|
747
751
|
const pollTimeout = options.pollTimeout ?? 18e4;
|
|
748
752
|
const [currentStep, setCurrentStep] = react.useState("idle");
|
|
@@ -810,7 +814,7 @@ function useWithdraw(options = {}) {
|
|
|
810
814
|
if (isStale()) return void 0;
|
|
811
815
|
const nonce = BigInt(nonceResponse.nonce);
|
|
812
816
|
setCurrentStep("signing");
|
|
813
|
-
const signature = await
|
|
817
|
+
const signature = await chunk7KEQHWZB_cjs.signWithdrawMessage({
|
|
814
818
|
walletClient,
|
|
815
819
|
chainId: signingChainId,
|
|
816
820
|
verifyingContract: networkConfig.accountingContract,
|
|
@@ -939,7 +943,7 @@ function useWithdraw(options = {}) {
|
|
|
939
943
|
function useLockFunds(options = {}) {
|
|
940
944
|
const { address } = wagmi.useAccount();
|
|
941
945
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
942
|
-
const { client, networkConfig, serviceAddress } =
|
|
946
|
+
const { client, networkConfig, serviceAddress } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
943
947
|
const queryClient = reactQuery.useQueryClient();
|
|
944
948
|
const mutation = reactQuery.useMutation({
|
|
945
949
|
mutationFn: async (params) => {
|
|
@@ -950,7 +954,7 @@ function useLockFunds(options = {}) {
|
|
|
950
954
|
throw new Error("Service address not configured");
|
|
951
955
|
}
|
|
952
956
|
const { nonce } = await client.getLockNonce(address);
|
|
953
|
-
const signature = await
|
|
957
|
+
const signature = await chunk7KEQHWZB_cjs.signLockMessage({
|
|
954
958
|
walletClient,
|
|
955
959
|
chainId: networkConfig.chainId,
|
|
956
960
|
verifyingContract: networkConfig.accountingContract,
|
|
@@ -998,7 +1002,7 @@ function useLockFunds(options = {}) {
|
|
|
998
1002
|
}
|
|
999
1003
|
function useUnlockFunds(options = {}) {
|
|
1000
1004
|
const { address } = wagmi.useAccount();
|
|
1001
|
-
const { client } =
|
|
1005
|
+
const { client } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
1002
1006
|
const queryClient = reactQuery.useQueryClient();
|
|
1003
1007
|
const unlockMutation = reactQuery.useMutation({
|
|
1004
1008
|
mutationFn: async (params) => {
|
|
@@ -1068,7 +1072,7 @@ function useUnlockFunds(options = {}) {
|
|
|
1068
1072
|
function useTransfer(options = {}) {
|
|
1069
1073
|
const { address } = wagmi.useAccount();
|
|
1070
1074
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1071
|
-
const { client, networkConfig, serviceAddress } =
|
|
1075
|
+
const { client, networkConfig, serviceAddress } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
1072
1076
|
const queryClient = reactQuery.useQueryClient();
|
|
1073
1077
|
const transferMutation = reactQuery.useMutation({
|
|
1074
1078
|
mutationFn: async (params) => {
|
|
@@ -1076,7 +1080,7 @@ function useTransfer(options = {}) {
|
|
|
1076
1080
|
throw new Error("Wallet not connected");
|
|
1077
1081
|
}
|
|
1078
1082
|
const { nonce } = await client.getTransferNonce(address);
|
|
1079
|
-
const signature = await
|
|
1083
|
+
const signature = await chunk7KEQHWZB_cjs.signTransferMessage({
|
|
1080
1084
|
walletClient,
|
|
1081
1085
|
chainId: networkConfig.chainId,
|
|
1082
1086
|
verifyingContract: networkConfig.accountingContract,
|
|
@@ -1113,7 +1117,7 @@ function useTransfer(options = {}) {
|
|
|
1113
1117
|
throw new Error("Service address not configured");
|
|
1114
1118
|
}
|
|
1115
1119
|
const { nonce } = await client.getTransferLockedNonce(serviceAddress);
|
|
1116
|
-
const signature = await
|
|
1120
|
+
const signature = await chunk7KEQHWZB_cjs.signTransferLockedMessage({
|
|
1117
1121
|
walletClient,
|
|
1118
1122
|
chainId: networkConfig.chainId,
|
|
1119
1123
|
verifyingContract: networkConfig.accountingContract,
|
|
@@ -1173,13 +1177,13 @@ function useTransfer(options = {}) {
|
|
|
1173
1177
|
};
|
|
1174
1178
|
}
|
|
1175
1179
|
function useLockedFunds(options = {}) {
|
|
1176
|
-
const { client, pollingInterval, serviceAddress } =
|
|
1177
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1180
|
+
const { client, pollingInterval, serviceAddress } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
1181
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk7KEQHWZB_cjs.usePrivateReadRequest();
|
|
1178
1182
|
const query = reactQuery.useQuery({
|
|
1179
1183
|
queryKey: ["accounting-locked-funds", ...privateReadQueryScope, serviceAddress ?? null],
|
|
1180
1184
|
queryFn: async () => {
|
|
1181
1185
|
if (!privateReadAddress) throw new Error("No authenticated account available");
|
|
1182
|
-
return executePrivateRead(() =>
|
|
1186
|
+
return executePrivateRead((readClient) => readClient.getLockedFunds(serviceAddress));
|
|
1183
1187
|
},
|
|
1184
1188
|
enabled: (options.enabled ?? true) && privateReadReady && !!privateReadAddress && !!client,
|
|
1185
1189
|
refetchInterval: pollingInterval,
|
|
@@ -1196,15 +1200,15 @@ function useLockedFunds(options = {}) {
|
|
|
1196
1200
|
};
|
|
1197
1201
|
}
|
|
1198
1202
|
function useTotalLockedBalance(options = {}) {
|
|
1199
|
-
const { client, pollingInterval, defaultToken } =
|
|
1200
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1203
|
+
const { client, pollingInterval, defaultToken } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
1204
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk7KEQHWZB_cjs.usePrivateReadRequest();
|
|
1201
1205
|
const tokenId = options.tokenId ?? defaultToken?.id;
|
|
1202
1206
|
const query = reactQuery.useQuery({
|
|
1203
1207
|
queryKey: ["accounting-total-locked-balance", ...privateReadQueryScope, tokenId],
|
|
1204
1208
|
queryFn: async () => {
|
|
1205
1209
|
if (!privateReadAddress) throw new Error("No authenticated account available");
|
|
1206
1210
|
if (!tokenId) throw new Error("No token ID provided");
|
|
1207
|
-
return executePrivateRead(() =>
|
|
1211
|
+
return executePrivateRead((readClient) => readClient.getTotalLockedBalance(tokenId));
|
|
1208
1212
|
},
|
|
1209
1213
|
enabled: (options.enabled ?? true) && privateReadReady && !!privateReadAddress && !!tokenId && !!client,
|
|
1210
1214
|
refetchInterval: pollingInterval
|
|
@@ -1218,13 +1222,13 @@ function useTotalLockedBalance(options = {}) {
|
|
|
1218
1222
|
};
|
|
1219
1223
|
}
|
|
1220
1224
|
function useExpiredLocks(options = {}) {
|
|
1221
|
-
const { client, pollingInterval } =
|
|
1222
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1225
|
+
const { client, pollingInterval } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
1226
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk7KEQHWZB_cjs.usePrivateReadRequest();
|
|
1223
1227
|
const query = reactQuery.useQuery({
|
|
1224
1228
|
queryKey: ["accounting-expired-locks", ...privateReadQueryScope],
|
|
1225
1229
|
queryFn: async () => {
|
|
1226
1230
|
if (!privateReadAddress) throw new Error("No authenticated account available");
|
|
1227
|
-
return executePrivateRead(() =>
|
|
1231
|
+
return executePrivateRead((readClient) => readClient.getExpiredLocks());
|
|
1228
1232
|
},
|
|
1229
1233
|
enabled: (options.enabled ?? true) && privateReadReady && !!privateReadAddress && !!client,
|
|
1230
1234
|
refetchInterval: pollingInterval
|
|
@@ -1240,14 +1244,14 @@ function useExpiredLocks(options = {}) {
|
|
|
1240
1244
|
};
|
|
1241
1245
|
}
|
|
1242
1246
|
function statusCodeOf(error) {
|
|
1243
|
-
return error instanceof
|
|
1247
|
+
return error instanceof chunk7KEQHWZB_cjs.AccountingApiError ? error.statusCode : void 0;
|
|
1244
1248
|
}
|
|
1245
1249
|
function usePendingDeposits(options = {}) {
|
|
1246
1250
|
const queryClient = react.useContext(reactQuery.QueryClientContext);
|
|
1247
|
-
const accountingContext =
|
|
1251
|
+
const accountingContext = chunk7KEQHWZB_cjs.useSafePrivanaContext();
|
|
1248
1252
|
const hasProviders = !!queryClient && !!accountingContext;
|
|
1249
1253
|
const client = accountingContext?.client;
|
|
1250
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1254
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk7KEQHWZB_cjs.usePrivateReadRequest();
|
|
1251
1255
|
const { chainId, tokenAddress, lookbackBlocks } = options;
|
|
1252
1256
|
const query = reactQuery.useQuery({
|
|
1253
1257
|
queryKey: ["accounting-pending-deposits", ...privateReadQueryScope, chainId, tokenAddress],
|
|
@@ -1257,7 +1261,7 @@ function usePendingDeposits(options = {}) {
|
|
|
1257
1261
|
if (!client) throw new Error("No accounting client");
|
|
1258
1262
|
try {
|
|
1259
1263
|
return await executePrivateRead(
|
|
1260
|
-
() =>
|
|
1264
|
+
(readClient) => readClient.getPendingDeposits({
|
|
1261
1265
|
chain_id: chainId,
|
|
1262
1266
|
token_address: tokenAddress,
|
|
1263
1267
|
lookback_blocks: lookbackBlocks
|
|
@@ -1294,7 +1298,7 @@ function usePendingDeposits(options = {}) {
|
|
|
1294
1298
|
}
|
|
1295
1299
|
function usePendingWithdrawals(options = {}) {
|
|
1296
1300
|
const { address, isConnected } = wagmi.useAccount();
|
|
1297
|
-
const { client, pollingInterval } =
|
|
1301
|
+
const { client, pollingInterval } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
1298
1302
|
const query = reactQuery.useQuery({
|
|
1299
1303
|
queryKey: ["accounting-pending-withdrawals", address],
|
|
1300
1304
|
queryFn: async () => {
|
|
@@ -1330,15 +1334,15 @@ function usePendingWithdrawals(options = {}) {
|
|
|
1330
1334
|
};
|
|
1331
1335
|
}
|
|
1332
1336
|
function useHistory(options = {}) {
|
|
1333
|
-
const { client, pollingInterval } =
|
|
1334
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1337
|
+
const { client, pollingInterval } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
1338
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk7KEQHWZB_cjs.usePrivateReadRequest();
|
|
1335
1339
|
const offset = options.offset ?? -1;
|
|
1336
1340
|
const limit = options.limit ?? 50;
|
|
1337
1341
|
const query = reactQuery.useQuery({
|
|
1338
1342
|
queryKey: ["accounting-history", ...privateReadQueryScope, offset, limit],
|
|
1339
1343
|
queryFn: async () => {
|
|
1340
1344
|
if (!privateReadAddress) throw new Error("No authenticated account available");
|
|
1341
|
-
return executePrivateRead(() =>
|
|
1345
|
+
return executePrivateRead((readClient) => readClient.getHistory({ offset, limit }));
|
|
1342
1346
|
},
|
|
1343
1347
|
enabled: (options.enabled ?? true) && privateReadReady && !!privateReadAddress && !!client,
|
|
1344
1348
|
refetchInterval: pollingInterval,
|
|
@@ -1355,7 +1359,7 @@ function useHistory(options = {}) {
|
|
|
1355
1359
|
};
|
|
1356
1360
|
}
|
|
1357
1361
|
function useTokenInfo(options = {}) {
|
|
1358
|
-
const { client } =
|
|
1362
|
+
const { client } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
1359
1363
|
const { tokenId } = options;
|
|
1360
1364
|
const query = reactQuery.useQuery({
|
|
1361
1365
|
queryKey: ["accounting-token-info", tokenId],
|
|
@@ -1375,7 +1379,7 @@ function useTokenInfo(options = {}) {
|
|
|
1375
1379
|
};
|
|
1376
1380
|
}
|
|
1377
1381
|
function useTokenList(options = {}) {
|
|
1378
|
-
const { client } =
|
|
1382
|
+
const { client } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
1379
1383
|
const query = reactQuery.useQuery({
|
|
1380
1384
|
queryKey: ["accounting-token-list"],
|
|
1381
1385
|
queryFn: () => client.listTokens(),
|
|
@@ -1393,7 +1397,7 @@ function useTokenList(options = {}) {
|
|
|
1393
1397
|
function useModifyLock(options = {}) {
|
|
1394
1398
|
const { address } = wagmi.useAccount();
|
|
1395
1399
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1396
|
-
const { client, networkConfig } =
|
|
1400
|
+
const { client, networkConfig } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
1397
1401
|
const queryClient = reactQuery.useQueryClient();
|
|
1398
1402
|
const mutation = reactQuery.useMutation({
|
|
1399
1403
|
mutationFn: async (params) => {
|
|
@@ -1401,7 +1405,7 @@ function useModifyLock(options = {}) {
|
|
|
1401
1405
|
throw new Error("Wallet not connected");
|
|
1402
1406
|
}
|
|
1403
1407
|
const { nonce } = await client.getModifyLockNonce(address);
|
|
1404
|
-
const signature = await
|
|
1408
|
+
const signature = await chunk7KEQHWZB_cjs.signModifyLockMessage({
|
|
1405
1409
|
walletClient,
|
|
1406
1410
|
chainId: networkConfig.chainId,
|
|
1407
1411
|
verifyingContract: networkConfig.accountingContract,
|
|
@@ -1460,7 +1464,7 @@ function DialogOverlay({
|
|
|
1460
1464
|
{
|
|
1461
1465
|
"data-slot": "dialog-overlay",
|
|
1462
1466
|
"data-privana": true,
|
|
1463
|
-
className:
|
|
1467
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
1464
1468
|
"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",
|
|
1465
1469
|
className
|
|
1466
1470
|
),
|
|
@@ -1482,7 +1486,7 @@ function DialogContent({
|
|
|
1482
1486
|
{
|
|
1483
1487
|
"data-slot": "dialog-content",
|
|
1484
1488
|
"data-privana": true,
|
|
1485
|
-
className:
|
|
1489
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
1486
1490
|
"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",
|
|
1487
1491
|
className
|
|
1488
1492
|
),
|
|
@@ -1510,7 +1514,7 @@ function DialogHeader({ className, ...props }) {
|
|
|
1510
1514
|
"div",
|
|
1511
1515
|
{
|
|
1512
1516
|
"data-slot": "dialog-header",
|
|
1513
|
-
className:
|
|
1517
|
+
className: chunk7KEQHWZB_cjs.cn("flex flex-col gap-2 text-center sm:text-left", className),
|
|
1514
1518
|
...props
|
|
1515
1519
|
}
|
|
1516
1520
|
);
|
|
@@ -1520,7 +1524,7 @@ function DialogTitle({ className, ...props }) {
|
|
|
1520
1524
|
DialogPrimitive__namespace.Title,
|
|
1521
1525
|
{
|
|
1522
1526
|
"data-slot": "dialog-title",
|
|
1523
|
-
className:
|
|
1527
|
+
className: chunk7KEQHWZB_cjs.cn("text-lg leading-none font-semibold", className),
|
|
1524
1528
|
...props
|
|
1525
1529
|
}
|
|
1526
1530
|
);
|
|
@@ -1533,7 +1537,7 @@ function DialogDescription({
|
|
|
1533
1537
|
DialogPrimitive__namespace.Description,
|
|
1534
1538
|
{
|
|
1535
1539
|
"data-slot": "dialog-description",
|
|
1536
|
-
className:
|
|
1540
|
+
className: chunk7KEQHWZB_cjs.cn("text-muted-foreground text-sm", className),
|
|
1537
1541
|
...props
|
|
1538
1542
|
}
|
|
1539
1543
|
);
|
|
@@ -1728,7 +1732,7 @@ function ChevronDownIcon({
|
|
|
1728
1732
|
height: "16",
|
|
1729
1733
|
viewBox: "0 0 16 16",
|
|
1730
1734
|
fill: "none",
|
|
1731
|
-
className:
|
|
1735
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
1732
1736
|
"transition-transform",
|
|
1733
1737
|
direction === "right" && "-rotate-90",
|
|
1734
1738
|
direction === "up" && "rotate-180",
|
|
@@ -1925,7 +1929,16 @@ function WarningIcon() {
|
|
|
1925
1929
|
}
|
|
1926
1930
|
) });
|
|
1927
1931
|
}
|
|
1928
|
-
function TransactionWarningView({
|
|
1932
|
+
function TransactionWarningView({
|
|
1933
|
+
title,
|
|
1934
|
+
message,
|
|
1935
|
+
onDone,
|
|
1936
|
+
actionLabel = "Done",
|
|
1937
|
+
pendingLabel = actionLabel,
|
|
1938
|
+
isPending = false,
|
|
1939
|
+
onDismiss,
|
|
1940
|
+
dismissLabel = "Dismiss"
|
|
1941
|
+
}) {
|
|
1929
1942
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-col gap-4", children: [
|
|
1930
1943
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1931
1944
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-amber-500/10 text-amber-400", children: /* @__PURE__ */ jsxRuntime.jsx(WarningIcon, {}) }),
|
|
@@ -1934,14 +1947,26 @@ function TransactionWarningView({ title, message, onDone }) {
|
|
|
1934
1947
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs", children: message })
|
|
1935
1948
|
] })
|
|
1936
1949
|
] }),
|
|
1937
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1950
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
|
|
1951
|
+
onDismiss && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1952
|
+
"button",
|
|
1953
|
+
{
|
|
1954
|
+
onClick: onDismiss,
|
|
1955
|
+
disabled: isPending,
|
|
1956
|
+
className: "border-border text-foreground hover:bg-secondary flex h-10 flex-1 cursor-pointer items-center justify-center rounded-[10px] border px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
|
|
1957
|
+
children: dismissLabel
|
|
1958
|
+
}
|
|
1959
|
+
),
|
|
1960
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1961
|
+
"button",
|
|
1962
|
+
{
|
|
1963
|
+
onClick: onDone,
|
|
1964
|
+
disabled: isPending,
|
|
1965
|
+
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",
|
|
1966
|
+
children: isPending ? pendingLabel : actionLabel
|
|
1967
|
+
}
|
|
1968
|
+
)
|
|
1969
|
+
] })
|
|
1945
1970
|
] });
|
|
1946
1971
|
}
|
|
1947
1972
|
function TransactionErrorView({
|
|
@@ -1952,7 +1977,8 @@ function TransactionErrorView({
|
|
|
1952
1977
|
onRetry,
|
|
1953
1978
|
onDismiss,
|
|
1954
1979
|
isRetrying,
|
|
1955
|
-
retryLabel = "Retry Verification"
|
|
1980
|
+
retryLabel = "Retry Verification",
|
|
1981
|
+
dismissLabel = "Close"
|
|
1956
1982
|
}) {
|
|
1957
1983
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-col gap-4", children: [
|
|
1958
1984
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
@@ -1976,13 +2002,13 @@ function TransactionErrorView({
|
|
|
1976
2002
|
}
|
|
1977
2003
|
),
|
|
1978
2004
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
|
|
1979
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2005
|
+
onDismiss && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1980
2006
|
"button",
|
|
1981
2007
|
{
|
|
1982
2008
|
onClick: onDismiss,
|
|
1983
2009
|
disabled: isRetrying,
|
|
1984
2010
|
className: "border-border text-foreground hover:bg-secondary flex h-10 flex-1 cursor-pointer items-center justify-center rounded-[10px] border px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
|
|
1985
|
-
children:
|
|
2011
|
+
children: dismissLabel
|
|
1986
2012
|
}
|
|
1987
2013
|
),
|
|
1988
2014
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1991,7 +2017,7 @@ function TransactionErrorView({
|
|
|
1991
2017
|
onClick: onRetry,
|
|
1992
2018
|
disabled: isRetrying,
|
|
1993
2019
|
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",
|
|
1994
|
-
children: isRetrying ? "Retrying
|
|
2020
|
+
children: isRetrying ? "Retrying\u2026" : retryLabel
|
|
1995
2021
|
}
|
|
1996
2022
|
)
|
|
1997
2023
|
] })
|
|
@@ -2005,7 +2031,7 @@ function DepositForm({
|
|
|
2005
2031
|
onSuccess
|
|
2006
2032
|
}) {
|
|
2007
2033
|
const { isConnected, address } = wagmi.useAccount();
|
|
2008
|
-
const { chains, getChainById: getChainById2 } =
|
|
2034
|
+
const { chains, getChainById: getChainById2 } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
2009
2035
|
const [amount, setAmount] = react.useState("");
|
|
2010
2036
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
2011
2037
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
@@ -2030,7 +2056,7 @@ function DepositForm({
|
|
|
2030
2056
|
}
|
|
2031
2057
|
});
|
|
2032
2058
|
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
2033
|
-
const formattedWalletBalance = walletBalance ?
|
|
2059
|
+
const formattedWalletBalance = walletBalance ? chunk7KEQHWZB_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
|
|
2034
2060
|
const handleMaxClick = () => {
|
|
2035
2061
|
if (formattedWalletBalance && parseFloat(formattedWalletBalance) > 0) {
|
|
2036
2062
|
setAmount(formattedWalletBalance.replace(/[\s\u2009]/g, ""));
|
|
@@ -2038,7 +2064,7 @@ function DepositForm({
|
|
|
2038
2064
|
};
|
|
2039
2065
|
const hasValidAmount = amount && parseFloat(amount) > 0;
|
|
2040
2066
|
const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
2041
|
-
const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null &&
|
|
2067
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null && chunk7KEQHWZB_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
|
|
2042
2068
|
const {
|
|
2043
2069
|
txHash,
|
|
2044
2070
|
isGettingAddress,
|
|
@@ -2123,7 +2149,7 @@ function DepositForm({
|
|
|
2123
2149
|
const handleSubmit = async () => {
|
|
2124
2150
|
if (!amount || !selectedToken || exceedsBalance) return;
|
|
2125
2151
|
setCancelled(false);
|
|
2126
|
-
const amountInWei =
|
|
2152
|
+
const amountInWei = chunk7KEQHWZB_cjs.parseTokenAmount(amount, selectedToken.decimals);
|
|
2127
2153
|
await deposit({
|
|
2128
2154
|
tokenId: selectedToken.id,
|
|
2129
2155
|
amount: amountInWei
|
|
@@ -2131,7 +2157,7 @@ function DepositForm({
|
|
|
2131
2157
|
};
|
|
2132
2158
|
const getButtonText = () => {
|
|
2133
2159
|
if (!isConnected) return "Connect Wallet";
|
|
2134
|
-
if (isSwitchingChain) return "Switching
|
|
2160
|
+
if (isSwitchingChain) return "Switching\u2026";
|
|
2135
2161
|
return "Deposit";
|
|
2136
2162
|
};
|
|
2137
2163
|
if (showSuccess) {
|
|
@@ -2155,7 +2181,7 @@ function DepositForm({
|
|
|
2155
2181
|
);
|
|
2156
2182
|
}
|
|
2157
2183
|
if (verificationFailed) {
|
|
2158
|
-
const baseMessage = "Your transfer was sent on-chain but we could not verify the deposit. The funds are already at the deposit address
|
|
2184
|
+
const baseMessage = "Your transfer was sent on-chain but we could not verify the deposit. The funds are already at the deposit address. Retry verification instead of starting a new deposit.";
|
|
2159
2185
|
const detail = error?.message;
|
|
2160
2186
|
const message = detail ? `${baseMessage} (${detail})` : baseMessage;
|
|
2161
2187
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2175,7 +2201,7 @@ function DepositForm({
|
|
|
2175
2201
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2176
2202
|
TransactionProgressView,
|
|
2177
2203
|
{
|
|
2178
|
-
title: "Depositing
|
|
2204
|
+
title: "Depositing\u2026",
|
|
2179
2205
|
steps: depositSteps,
|
|
2180
2206
|
onCancel: canCancel ? handleCancel : void 0
|
|
2181
2207
|
}
|
|
@@ -2226,7 +2252,7 @@ function DepositForm({
|
|
|
2226
2252
|
setAmount(value);
|
|
2227
2253
|
}
|
|
2228
2254
|
},
|
|
2229
|
-
className:
|
|
2255
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2230
2256
|
"text-foreground flex-1 bg-transparent text-sm outline-none",
|
|
2231
2257
|
"placeholder:text-muted-foreground/50"
|
|
2232
2258
|
)
|
|
@@ -2253,7 +2279,7 @@ function DepositForm({
|
|
|
2253
2279
|
{
|
|
2254
2280
|
onClick: handleSubmit,
|
|
2255
2281
|
disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
|
|
2256
|
-
className:
|
|
2282
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2257
2283
|
"flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
|
|
2258
2284
|
"bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2259
2285
|
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
@@ -2270,7 +2296,7 @@ function WithdrawForm({
|
|
|
2270
2296
|
onUnsafeToCloseChange
|
|
2271
2297
|
}) {
|
|
2272
2298
|
const { isConnected, address } = wagmi.useAccount();
|
|
2273
|
-
const { chains, getChainById: getChainById2 } =
|
|
2299
|
+
const { chains, getChainById: getChainById2 } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
2274
2300
|
const [amount, setAmount] = react.useState("");
|
|
2275
2301
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
2276
2302
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
@@ -2283,7 +2309,7 @@ function WithdrawForm({
|
|
|
2283
2309
|
} = useBalance({
|
|
2284
2310
|
tokenId: selectedToken.id
|
|
2285
2311
|
});
|
|
2286
|
-
const formattedBalance =
|
|
2312
|
+
const formattedBalance = chunk7KEQHWZB_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
|
|
2287
2313
|
const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
|
|
2288
2314
|
onProcessingSuccess: () => {
|
|
2289
2315
|
setAmount("");
|
|
@@ -2294,7 +2320,7 @@ function WithdrawForm({
|
|
|
2294
2320
|
setShowTimeout(true);
|
|
2295
2321
|
}
|
|
2296
2322
|
});
|
|
2297
|
-
const explorerUrl = address && targetChain ?
|
|
2323
|
+
const explorerUrl = address && targetChain ? chunk7KEQHWZB_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
|
|
2298
2324
|
const getStepStatus = (step, after) => {
|
|
2299
2325
|
if (currentStep === step) return "active";
|
|
2300
2326
|
if (after.includes(currentStep)) return "completed";
|
|
@@ -2338,7 +2364,7 @@ function WithdrawForm({
|
|
|
2338
2364
|
const handleWithdraw = async () => {
|
|
2339
2365
|
if (!amount || !selectedToken || exceedsBalance) return;
|
|
2340
2366
|
setCancelled(false);
|
|
2341
|
-
const amountInWei =
|
|
2367
|
+
const amountInWei = chunk7KEQHWZB_cjs.parseTokenAmount(amount, selectedToken.decimals);
|
|
2342
2368
|
await withdraw({
|
|
2343
2369
|
tokenId: selectedToken.id,
|
|
2344
2370
|
amount: amountInWei
|
|
@@ -2351,7 +2377,7 @@ function WithdrawForm({
|
|
|
2351
2377
|
};
|
|
2352
2378
|
const hasValidAmount = amount && parseFloat(amount) > 0;
|
|
2353
2379
|
const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
2354
|
-
const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError &&
|
|
2380
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError && chunk7KEQHWZB_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
|
|
2355
2381
|
const getButtonText = () => {
|
|
2356
2382
|
if (!isConnected) return "Connect Wallet";
|
|
2357
2383
|
return "Withdraw";
|
|
@@ -2363,7 +2389,7 @@ function WithdrawForm({
|
|
|
2363
2389
|
title: "Withdrawal Complete",
|
|
2364
2390
|
message: `Your ${selectedToken.symbol} withdrawal has been processed. Funds should appear in your wallet shortly.`,
|
|
2365
2391
|
explorerUrl,
|
|
2366
|
-
explorerLabel: targetChain ?
|
|
2392
|
+
explorerLabel: targetChain ? chunk7KEQHWZB_cjs.getExplorerLabel(targetChain.id) : void 0,
|
|
2367
2393
|
onDone: handleDone
|
|
2368
2394
|
}
|
|
2369
2395
|
);
|
|
@@ -2434,7 +2460,7 @@ function WithdrawForm({
|
|
|
2434
2460
|
setAmount(value);
|
|
2435
2461
|
}
|
|
2436
2462
|
},
|
|
2437
|
-
className:
|
|
2463
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2438
2464
|
"text-foreground flex-1 bg-transparent text-sm outline-none",
|
|
2439
2465
|
"placeholder:text-muted-foreground/50"
|
|
2440
2466
|
)
|
|
@@ -2461,7 +2487,7 @@ function WithdrawForm({
|
|
|
2461
2487
|
{
|
|
2462
2488
|
onClick: handleWithdraw,
|
|
2463
2489
|
disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
|
|
2464
|
-
className:
|
|
2490
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2465
2491
|
"flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
|
|
2466
2492
|
"bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2467
2493
|
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
@@ -2482,15 +2508,15 @@ function BalanceCards({
|
|
|
2482
2508
|
tokenId: selectedToken.id
|
|
2483
2509
|
});
|
|
2484
2510
|
const { totalLocked, isLoading: lockedLoading } = useLockedFunds({ enabled: showLockedFunds });
|
|
2485
|
-
const formattedBalance =
|
|
2486
|
-
const formattedLocked = showLockedFunds ?
|
|
2487
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className:
|
|
2511
|
+
const formattedBalance = chunk7KEQHWZB_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
|
|
2512
|
+
const formattedLocked = showLockedFunds ? chunk7KEQHWZB_cjs.formatTokenAmount(String(totalLocked), selectedToken.decimals) : "0.00";
|
|
2513
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunk7KEQHWZB_cjs.cn("flex gap-2", disabled && "opacity-50"), children: [
|
|
2488
2514
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2489
2515
|
"button",
|
|
2490
2516
|
{
|
|
2491
2517
|
onClick: onBalanceClick,
|
|
2492
2518
|
disabled,
|
|
2493
|
-
className:
|
|
2519
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2494
2520
|
"bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
|
|
2495
2521
|
disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
|
|
2496
2522
|
),
|
|
@@ -2511,7 +2537,7 @@ function BalanceCards({
|
|
|
2511
2537
|
{
|
|
2512
2538
|
onClick: onLockedFundsClick,
|
|
2513
2539
|
disabled,
|
|
2514
|
-
className:
|
|
2540
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2515
2541
|
"bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
|
|
2516
2542
|
disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
|
|
2517
2543
|
),
|
|
@@ -2537,7 +2563,7 @@ function Tabs({
|
|
|
2537
2563
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2538
2564
|
"div",
|
|
2539
2565
|
{
|
|
2540
|
-
className:
|
|
2566
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2541
2567
|
"bg-muted relative flex gap-2 overflow-hidden rounded-[10px] p-1",
|
|
2542
2568
|
disabled && "opacity-50"
|
|
2543
2569
|
),
|
|
@@ -2545,7 +2571,7 @@ function Tabs({
|
|
|
2545
2571
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2546
2572
|
"div",
|
|
2547
2573
|
{
|
|
2548
|
-
className:
|
|
2574
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2549
2575
|
"bg-input absolute top-1 bottom-1 left-1 w-[calc(50%-8px)] rounded-md transition-transform duration-200",
|
|
2550
2576
|
activeTab === "withdraw" && "translate-x-[calc(100%+8px)]"
|
|
2551
2577
|
)
|
|
@@ -2556,7 +2582,7 @@ function Tabs({
|
|
|
2556
2582
|
{
|
|
2557
2583
|
onClick: () => !disabled && onTabChange("deposit"),
|
|
2558
2584
|
disabled,
|
|
2559
|
-
className:
|
|
2585
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2560
2586
|
"relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
|
|
2561
2587
|
activeTab === "deposit" ? "text-foreground" : "text-muted-foreground",
|
|
2562
2588
|
disabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
@@ -2569,7 +2595,7 @@ function Tabs({
|
|
|
2569
2595
|
{
|
|
2570
2596
|
onClick: () => !disabled && onTabChange("withdraw"),
|
|
2571
2597
|
disabled,
|
|
2572
|
-
className:
|
|
2598
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2573
2599
|
"relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
|
|
2574
2600
|
activeTab === "withdraw" ? "text-foreground" : "text-muted-foreground",
|
|
2575
2601
|
disabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
@@ -2582,14 +2608,14 @@ function Tabs({
|
|
|
2582
2608
|
);
|
|
2583
2609
|
}
|
|
2584
2610
|
function LockedFundsView({ onBack }) {
|
|
2585
|
-
const { getTokenById } =
|
|
2611
|
+
const { getTokenById } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
2586
2612
|
const { locks, isLoading } = useLockedFunds();
|
|
2587
2613
|
const { unlockFunds, unlockAllExpired, isPending } = useUnlockFunds();
|
|
2588
2614
|
const [collapsedSections, setCollapsedSections] = react.useState({});
|
|
2589
2615
|
const sections = react.useMemo(() => {
|
|
2590
2616
|
const sectionMap = {};
|
|
2591
2617
|
locks.forEach((lock) => {
|
|
2592
|
-
const serviceName =
|
|
2618
|
+
const serviceName = chunk7KEQHWZB_cjs.shortenAddress(lock.service_address);
|
|
2593
2619
|
if (!sectionMap[lock.service_address]) {
|
|
2594
2620
|
sectionMap[lock.service_address] = {
|
|
2595
2621
|
title: `Service ${serviceName}`,
|
|
@@ -2598,9 +2624,9 @@ function LockedFundsView({ onBack }) {
|
|
|
2598
2624
|
}
|
|
2599
2625
|
sectionMap[lock.service_address].items.push({
|
|
2600
2626
|
lockId: lock.lock_id,
|
|
2601
|
-
amount:
|
|
2627
|
+
amount: chunk7KEQHWZB_cjs.formatTokenAmount(String(lock.amount), getTokenById(lock.token_id)?.decimals ?? 18),
|
|
2602
2628
|
serviceAddress: lock.service_address,
|
|
2603
|
-
time: lock.is_expired ? "Click to unlock" :
|
|
2629
|
+
time: lock.is_expired ? "Click to unlock" : chunk7KEQHWZB_cjs.formatTimeRemaining(lock.expiry),
|
|
2604
2630
|
isExpired: lock.is_expired
|
|
2605
2631
|
});
|
|
2606
2632
|
});
|
|
@@ -2652,7 +2678,7 @@ function LockedFundsView({ onBack }) {
|
|
|
2652
2678
|
!collapsedSections[section.title] && section.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2653
2679
|
"div",
|
|
2654
2680
|
{
|
|
2655
|
-
className:
|
|
2681
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2656
2682
|
"flex items-center justify-between gap-3 rounded-lg p-3",
|
|
2657
2683
|
item.isExpired && "bg-secondary"
|
|
2658
2684
|
),
|
|
@@ -2666,7 +2692,7 @@ function LockedFundsView({ onBack }) {
|
|
|
2666
2692
|
] }),
|
|
2667
2693
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-xs", children: [
|
|
2668
2694
|
"Service: ",
|
|
2669
|
-
|
|
2695
|
+
chunk7KEQHWZB_cjs.shortenAddress(item.serviceAddress)
|
|
2670
2696
|
] })
|
|
2671
2697
|
] })
|
|
2672
2698
|
] }),
|
|
@@ -2707,7 +2733,7 @@ function BalanceTokenRow({ token }) {
|
|
|
2707
2733
|
const { balanceWei, isLoading } = useBalance({
|
|
2708
2734
|
tokenId: token.id
|
|
2709
2735
|
});
|
|
2710
|
-
const formattedBalance =
|
|
2736
|
+
const formattedBalance = chunk7KEQHWZB_cjs.formatTokenAmount(balanceWei, token.decimals);
|
|
2711
2737
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-2 rounded-lg px-3 py-2.5", children: [
|
|
2712
2738
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-[18px] w-[18px] overflow-hidden rounded-full", children: getTokenIcon(token.symbol, 18) }),
|
|
2713
2739
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground flex-1 text-sm", children: token.symbol }),
|
|
@@ -2715,7 +2741,7 @@ function BalanceTokenRow({ token }) {
|
|
|
2715
2741
|
] });
|
|
2716
2742
|
}
|
|
2717
2743
|
function BalanceDetailsView({ onBack }) {
|
|
2718
|
-
const { enabledTokens, chains } =
|
|
2744
|
+
const { enabledTokens, chains } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
2719
2745
|
const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
|
|
2720
2746
|
const chainTokens = react.useMemo(() => {
|
|
2721
2747
|
return enabledTokens.filter((t) => t.chainId === selectedChainId);
|
|
@@ -2741,7 +2767,7 @@ function BalanceDetailsView({ onBack }) {
|
|
|
2741
2767
|
"button",
|
|
2742
2768
|
{
|
|
2743
2769
|
onClick: () => setSelectedChainId(chain.id),
|
|
2744
|
-
className:
|
|
2770
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2745
2771
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2746
2772
|
isSelected && "bg-secondary"
|
|
2747
2773
|
),
|
|
@@ -2782,12 +2808,12 @@ function TokenRow({
|
|
|
2782
2808
|
query: { enabled: !!address && !isNative }
|
|
2783
2809
|
});
|
|
2784
2810
|
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
2785
|
-
const formattedBalance = walletBalance ?
|
|
2811
|
+
const formattedBalance = walletBalance ? chunk7KEQHWZB_cjs.formatTokenAmount(walletBalance.toString(), token.decimals) : "0.00";
|
|
2786
2812
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2787
2813
|
"button",
|
|
2788
2814
|
{
|
|
2789
2815
|
onClick,
|
|
2790
|
-
className:
|
|
2816
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2791
2817
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2792
2818
|
isSelected && "bg-secondary"
|
|
2793
2819
|
),
|
|
@@ -2804,7 +2830,7 @@ function TokenSelectorView({
|
|
|
2804
2830
|
onSelect,
|
|
2805
2831
|
selectedTokenId
|
|
2806
2832
|
}) {
|
|
2807
|
-
const { enabledTokens, chains } =
|
|
2833
|
+
const { enabledTokens, chains } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
2808
2834
|
const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
|
|
2809
2835
|
const chainTokens = react.useMemo(() => {
|
|
2810
2836
|
return enabledTokens.filter((t) => t.chainId === selectedChainId);
|
|
@@ -2834,7 +2860,7 @@ function TokenSelectorView({
|
|
|
2834
2860
|
"button",
|
|
2835
2861
|
{
|
|
2836
2862
|
onClick: () => setSelectedChainId(chain.id),
|
|
2837
|
-
className:
|
|
2863
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
2838
2864
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2839
2865
|
isSelected && "bg-secondary"
|
|
2840
2866
|
),
|
|
@@ -2869,7 +2895,7 @@ function ModalBody({
|
|
|
2869
2895
|
defaultTab = "deposit",
|
|
2870
2896
|
onDepositSuccess
|
|
2871
2897
|
}) {
|
|
2872
|
-
const { defaultToken, tokensStatus } =
|
|
2898
|
+
const { defaultToken, tokensStatus } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
2873
2899
|
const [selectedToken, setSelectedToken] = react.useState(defaultToken);
|
|
2874
2900
|
const [activeTab, setActiveTab] = react.useState(defaultTab);
|
|
2875
2901
|
const [currentView, setCurrentView] = react.useState("main");
|
|
@@ -2927,7 +2953,7 @@ function ModalBody({
|
|
|
2927
2953
|
);
|
|
2928
2954
|
}
|
|
2929
2955
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 pb-4", children: [
|
|
2930
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
2956
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: chunk7KEQHWZB_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2931
2957
|
BalanceCards,
|
|
2932
2958
|
{
|
|
2933
2959
|
selectedToken,
|
|
@@ -2937,7 +2963,7 @@ function ModalBody({
|
|
|
2937
2963
|
disabled: isInteractionPending
|
|
2938
2964
|
}
|
|
2939
2965
|
) }),
|
|
2940
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
2966
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: chunk7KEQHWZB_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(Tabs, { activeTab, onTabChange: setActiveTab, disabled: isInteractionPending }) }),
|
|
2941
2967
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted rounded-[10px] p-5", children: activeTab === "deposit" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2942
2968
|
DepositForm,
|
|
2943
2969
|
{
|
|
@@ -2998,7 +3024,7 @@ function PrivanaModal({
|
|
|
2998
3024
|
onClick: handleClose,
|
|
2999
3025
|
disabled: isCloseBlocked,
|
|
3000
3026
|
"aria-label": "Close",
|
|
3001
|
-
className:
|
|
3027
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
3002
3028
|
"absolute top-6 right-5 z-20 flex h-6 w-6 items-center justify-center transition-colors",
|
|
3003
3029
|
isCloseBlocked ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
|
|
3004
3030
|
),
|
|
@@ -3054,7 +3080,7 @@ function PrivanaInlineModal({
|
|
|
3054
3080
|
"div",
|
|
3055
3081
|
{
|
|
3056
3082
|
"data-privana": true,
|
|
3057
|
-
className:
|
|
3083
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
3058
3084
|
"bg-card flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
3059
3085
|
className
|
|
3060
3086
|
),
|
|
@@ -3089,12 +3115,12 @@ function PrivanaButton({
|
|
|
3089
3115
|
}
|
|
3090
3116
|
const handleClick = () => setModalOpen(true);
|
|
3091
3117
|
const buttonElement = renderButton ? renderButton({ onClick: handleClick, isOpen: modalOpen }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3092
|
-
|
|
3118
|
+
chunk7KEQHWZB_cjs.Button,
|
|
3093
3119
|
{
|
|
3094
3120
|
variant,
|
|
3095
3121
|
size,
|
|
3096
3122
|
asChild,
|
|
3097
|
-
className:
|
|
3123
|
+
className: chunk7KEQHWZB_cjs.cn(className),
|
|
3098
3124
|
onClick: handleClick,
|
|
3099
3125
|
disabled: !isConnected,
|
|
3100
3126
|
...buttonProps,
|
|
@@ -3115,6 +3141,745 @@ function PrivanaButton({
|
|
|
3115
3141
|
)
|
|
3116
3142
|
] });
|
|
3117
3143
|
}
|
|
3144
|
+
|
|
3145
|
+
// src/sdk/hooks/external-deposit-lock.ts
|
|
3146
|
+
var ACTIVE_SESSION_PREFIX = "privana:external-deposit-lock:active:";
|
|
3147
|
+
var SESSION_PREFIX = "privana:external-deposit-lock:session:";
|
|
3148
|
+
var ExternalDepositLockSessionChangedError = class _ExternalDepositLockSessionChangedError extends Error {
|
|
3149
|
+
constructor() {
|
|
3150
|
+
super("External deposit lock session changed");
|
|
3151
|
+
this.name = "ExternalDepositLockSessionChangedError";
|
|
3152
|
+
Object.setPrototypeOf(this, _ExternalDepositLockSessionChangedError.prototype);
|
|
3153
|
+
}
|
|
3154
|
+
};
|
|
3155
|
+
function externalDepositSessionId(chainId, tokenId) {
|
|
3156
|
+
return `${chainId}:${tokenId.toLowerCase()}`;
|
|
3157
|
+
}
|
|
3158
|
+
function isExternalDepositBlockInSession(session, blockNumber) {
|
|
3159
|
+
return Number.isSafeInteger(blockNumber) && blockNumber > session.startBlock;
|
|
3160
|
+
}
|
|
3161
|
+
function isCurrentExternalDepositVerification(session, txHash) {
|
|
3162
|
+
return session.creditedAmount === void 0 && session.verification?.hash.toLowerCase() === txHash.toLowerCase();
|
|
3163
|
+
}
|
|
3164
|
+
function getExternalDepositMinimum(response, chainId) {
|
|
3165
|
+
const value = response?.min_deposit?.[String(chainId)]?.erc20;
|
|
3166
|
+
if (value === void 0) return void 0;
|
|
3167
|
+
try {
|
|
3168
|
+
const amount = BigInt(value);
|
|
3169
|
+
return amount >= 0n ? amount : void 0;
|
|
3170
|
+
} catch {
|
|
3171
|
+
return void 0;
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
function activeSessionKey(owner) {
|
|
3175
|
+
return `${ACTIVE_SESSION_PREFIX}${owner.toLowerCase()}`;
|
|
3176
|
+
}
|
|
3177
|
+
function sessionKey(owner, sessionId) {
|
|
3178
|
+
return `${SESSION_PREFIX}${owner.toLowerCase()}:${sessionId}`;
|
|
3179
|
+
}
|
|
3180
|
+
function activeSessionId(owner) {
|
|
3181
|
+
const value = chunk7KEQHWZB_cjs.getSharedBrowserStorageItem(activeSessionKey(owner));
|
|
3182
|
+
return value || void 0;
|
|
3183
|
+
}
|
|
3184
|
+
function isPositiveIntegerString(value) {
|
|
3185
|
+
if (typeof value !== "string") return false;
|
|
3186
|
+
try {
|
|
3187
|
+
return BigInt(value) > 0n;
|
|
3188
|
+
} catch {
|
|
3189
|
+
return false;
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
function isSessionRecord(value) {
|
|
3193
|
+
if (!value || typeof value !== "object") return false;
|
|
3194
|
+
const record = value;
|
|
3195
|
+
if (record.version !== 1 || typeof record.owner !== "string" || typeof record.serviceAddress !== "string" || !Number.isInteger(record.chainId) || (record.chainId ?? 0) <= 0 || typeof record.tokenId !== "string" || !Number.isSafeInteger(record.startBlock) || (record.startBlock ?? -1) < 0 || !isPositiveIntegerString(record.depositAmount) || !isPositiveIntegerString(record.maxLockAmount) || !Number.isInteger(record.lockDuration) || (record.lockDuration ?? 0) <= 0 || typeof record.generation !== "string" || !record.generation || record.submissionAmbiguous !== void 0 && typeof record.submissionAmbiguous !== "boolean" || record.creditedAmount !== void 0 && !isPositiveIntegerString(record.creditedAmount)) {
|
|
3196
|
+
return false;
|
|
3197
|
+
}
|
|
3198
|
+
if (record.verification && (typeof record.verification.hash !== "string" || record.verification.chainId !== record.chainId || !isPositiveIntegerString(record.verification.amount) || record.verification.logIndex !== void 0 && (!Number.isInteger(record.verification.logIndex) || record.verification.logIndex < 0))) {
|
|
3199
|
+
return false;
|
|
3200
|
+
}
|
|
3201
|
+
if (record.verification && record.creditedAmount !== void 0) return false;
|
|
3202
|
+
if (record.submissionAmbiguous && record.creditedAmount === void 0) return false;
|
|
3203
|
+
if (!record.payload) {
|
|
3204
|
+
return record.creditedAmount !== void 0 && !record.submissionAmbiguous;
|
|
3205
|
+
}
|
|
3206
|
+
if (typeof record.payload.signature !== "string" || typeof record.payload.token_id !== "string" || typeof record.payload.service_address !== "string" || record.payload.signature !== record.generation || record.payload.token_id.toLowerCase() !== record.tokenId.toLowerCase() || record.payload.service_address.toLowerCase() !== record.serviceAddress.toLowerCase() || !isPositiveIntegerString(record.payload.amount)) {
|
|
3207
|
+
return false;
|
|
3208
|
+
}
|
|
3209
|
+
return BigInt(record.payload.amount) <= BigInt(record.maxLockAmount);
|
|
3210
|
+
}
|
|
3211
|
+
function writeSessionRecord(session) {
|
|
3212
|
+
const id = externalDepositSessionId(session.chainId, session.tokenId);
|
|
3213
|
+
return chunk7KEQHWZB_cjs.setSharedBrowserStorageItem(sessionKey(session.owner, id), JSON.stringify(session));
|
|
3214
|
+
}
|
|
3215
|
+
function saveExternalDepositLockSession(session, expectedSession = null) {
|
|
3216
|
+
if (!isSessionRecord(session)) throw new Error("Invalid external deposit lock session");
|
|
3217
|
+
const current = loadExternalDepositLockSession(session.owner);
|
|
3218
|
+
if (expectedSession === null && current || expectedSession !== null && (!current || !isSameSessionSnapshot(current, expectedSession))) {
|
|
3219
|
+
throw new ExternalDepositLockSessionChangedError();
|
|
3220
|
+
}
|
|
3221
|
+
const nextId = externalDepositSessionId(session.chainId, session.tokenId);
|
|
3222
|
+
const previousId = activeSessionId(session.owner);
|
|
3223
|
+
if (!writeSessionRecord(session)) {
|
|
3224
|
+
throw new Error("Unable to persist external deposit lock session");
|
|
3225
|
+
}
|
|
3226
|
+
if (previousId !== nextId) {
|
|
3227
|
+
if (!chunk7KEQHWZB_cjs.setSharedBrowserStorageItem(activeSessionKey(session.owner), nextId)) {
|
|
3228
|
+
chunk7KEQHWZB_cjs.removeSharedBrowserStorageItem(sessionKey(session.owner, nextId));
|
|
3229
|
+
throw new Error("Unable to persist external deposit lock session");
|
|
3230
|
+
}
|
|
3231
|
+
if (previousId) {
|
|
3232
|
+
chunk7KEQHWZB_cjs.removeSharedBrowserStorageItem(sessionKey(session.owner, previousId));
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
function loadExternalDepositLockSession(owner) {
|
|
3237
|
+
const id = activeSessionId(owner);
|
|
3238
|
+
if (!id) return void 0;
|
|
3239
|
+
const key = sessionKey(owner, id);
|
|
3240
|
+
try {
|
|
3241
|
+
const raw = chunk7KEQHWZB_cjs.getSharedBrowserStorageItem(key);
|
|
3242
|
+
const parsed = raw ? JSON.parse(raw) : void 0;
|
|
3243
|
+
if (!isSessionRecord(parsed) || parsed.owner.toLowerCase() !== owner.toLowerCase() || externalDepositSessionId(parsed.chainId, parsed.tokenId) !== id) {
|
|
3244
|
+
chunk7KEQHWZB_cjs.removeSharedBrowserStorageItem(key);
|
|
3245
|
+
chunk7KEQHWZB_cjs.removeSharedBrowserStorageItem(activeSessionKey(owner));
|
|
3246
|
+
return void 0;
|
|
3247
|
+
}
|
|
3248
|
+
return parsed;
|
|
3249
|
+
} catch {
|
|
3250
|
+
chunk7KEQHWZB_cjs.removeSharedBrowserStorageItem(key);
|
|
3251
|
+
chunk7KEQHWZB_cjs.removeSharedBrowserStorageItem(activeSessionKey(owner));
|
|
3252
|
+
return void 0;
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
function subscribeExternalDepositLockSession(owner, onChange) {
|
|
3256
|
+
if (typeof window === "undefined") return () => void 0;
|
|
3257
|
+
let localStorage;
|
|
3258
|
+
try {
|
|
3259
|
+
localStorage = window.localStorage;
|
|
3260
|
+
} catch {
|
|
3261
|
+
return () => void 0;
|
|
3262
|
+
}
|
|
3263
|
+
const activeKey = activeSessionKey(owner);
|
|
3264
|
+
const ownerSessionPrefix = `${SESSION_PREFIX}${owner.toLowerCase()}:`;
|
|
3265
|
+
const handleStorage = (event) => {
|
|
3266
|
+
if (event.storageArea !== localStorage) return;
|
|
3267
|
+
if (event.key !== null && event.key !== activeKey && !event.key.startsWith(ownerSessionPrefix)) {
|
|
3268
|
+
return;
|
|
3269
|
+
}
|
|
3270
|
+
onChange(loadExternalDepositLockSession(owner));
|
|
3271
|
+
};
|
|
3272
|
+
window.addEventListener("storage", handleStorage);
|
|
3273
|
+
return () => window.removeEventListener("storage", handleStorage);
|
|
3274
|
+
}
|
|
3275
|
+
function clearExternalDepositLockSession(owner, expectedSessionId, expectedGeneration) {
|
|
3276
|
+
const id = activeSessionId(owner);
|
|
3277
|
+
if (!id || expectedSessionId && id !== expectedSessionId) return;
|
|
3278
|
+
if (expectedGeneration) {
|
|
3279
|
+
const current = loadExternalDepositLockSession(owner);
|
|
3280
|
+
if (!current || current.generation !== expectedGeneration) return;
|
|
3281
|
+
}
|
|
3282
|
+
chunk7KEQHWZB_cjs.removeSharedBrowserStorageItem(sessionKey(owner, id));
|
|
3283
|
+
chunk7KEQHWZB_cjs.removeSharedBrowserStorageItem(activeSessionKey(owner));
|
|
3284
|
+
}
|
|
3285
|
+
function isSameVerification(left, right) {
|
|
3286
|
+
if (!left || !right) return left === right;
|
|
3287
|
+
return left.hash.toLowerCase() === right.hash.toLowerCase() && left.chainId === right.chainId && left.amount === right.amount && (left.logIndex ?? 0) === (right.logIndex ?? 0);
|
|
3288
|
+
}
|
|
3289
|
+
function isSamePayload(left, right) {
|
|
3290
|
+
if (!left || !right) return left === right;
|
|
3291
|
+
return left.service_address.toLowerCase() === right.service_address.toLowerCase() && left.token_id.toLowerCase() === right.token_id.toLowerCase() && left.amount === right.amount && left.expiry === right.expiry && left.nonce === right.nonce && left.signature === right.signature;
|
|
3292
|
+
}
|
|
3293
|
+
function isSameSessionSnapshot(left, right) {
|
|
3294
|
+
return left.version === right.version && left.owner.toLowerCase() === right.owner.toLowerCase() && left.serviceAddress.toLowerCase() === right.serviceAddress.toLowerCase() && left.chainId === right.chainId && left.tokenId.toLowerCase() === right.tokenId.toLowerCase() && left.startBlock === right.startBlock && left.depositAmount === right.depositAmount && left.maxLockAmount === right.maxLockAmount && left.lockDuration === right.lockDuration && left.generation === right.generation && left.creditedAmount === right.creditedAmount && left.submissionAmbiguous === right.submissionAmbiguous && isSameVerification(left.verification, right.verification) && isSamePayload(left.payload, right.payload);
|
|
3295
|
+
}
|
|
3296
|
+
function isSameExternalDepositLockSession(left, right) {
|
|
3297
|
+
return isSameSessionSnapshot(left, right);
|
|
3298
|
+
}
|
|
3299
|
+
function clearExternalDepositVerification(session) {
|
|
3300
|
+
if (!session.verification || session.creditedAmount) return void 0;
|
|
3301
|
+
const current = loadExternalDepositLockSession(session.owner);
|
|
3302
|
+
if (!current || current.generation !== session.generation || current.creditedAmount || !isSameVerification(current.verification, session.verification)) {
|
|
3303
|
+
return void 0;
|
|
3304
|
+
}
|
|
3305
|
+
const next = { ...current, verification: void 0 };
|
|
3306
|
+
if (!writeSessionRecord(next)) {
|
|
3307
|
+
throw new Error("Unable to clear failed deposit verification");
|
|
3308
|
+
}
|
|
3309
|
+
return next;
|
|
3310
|
+
}
|
|
3311
|
+
function discardExternalDepositLockSession(session) {
|
|
3312
|
+
const current = loadExternalDepositLockSession(session.owner);
|
|
3313
|
+
if (!current) return true;
|
|
3314
|
+
if (!isSameSessionSnapshot(current, session)) return false;
|
|
3315
|
+
clearExternalDepositLockSession(
|
|
3316
|
+
current.owner,
|
|
3317
|
+
externalDepositSessionId(current.chainId, current.tokenId),
|
|
3318
|
+
current.generation
|
|
3319
|
+
);
|
|
3320
|
+
return loadExternalDepositLockSession(current.owner) === void 0;
|
|
3321
|
+
}
|
|
3322
|
+
function clearSubmittedPayload(session, signature, clearAmbiguous = false) {
|
|
3323
|
+
const current = loadExternalDepositLockSession(session.owner);
|
|
3324
|
+
if (!current?.payload || current.payload.signature !== signature || current.submissionAmbiguous && !clearAmbiguous) {
|
|
3325
|
+
return false;
|
|
3326
|
+
}
|
|
3327
|
+
return writeSessionRecord({ ...current, submissionAmbiguous: void 0, payload: void 0 });
|
|
3328
|
+
}
|
|
3329
|
+
function markSubmissionAmbiguous(session, signature) {
|
|
3330
|
+
const current = loadExternalDepositLockSession(session.owner);
|
|
3331
|
+
if (!current?.payload || current.payload.signature !== signature) return false;
|
|
3332
|
+
if (current.submissionAmbiguous) return true;
|
|
3333
|
+
return writeSessionRecord({ ...current, submissionAmbiguous: true });
|
|
3334
|
+
}
|
|
3335
|
+
function ambiguousSubmissionError(error) {
|
|
3336
|
+
return new chunk7KEQHWZB_cjs.PostDepositLockError(
|
|
3337
|
+
"Lock submission could not be confirmed. Retry only the saved signature, or check locked funds before stopping recovery.",
|
|
3338
|
+
error.reason,
|
|
3339
|
+
error.signedAmount,
|
|
3340
|
+
error.creditedAmount,
|
|
3341
|
+
{
|
|
3342
|
+
cause: error.cause,
|
|
3343
|
+
submissionMayHaveSucceeded: true
|
|
3344
|
+
}
|
|
3345
|
+
);
|
|
3346
|
+
}
|
|
3347
|
+
function isDefinitiveSubmissionFailure(error) {
|
|
3348
|
+
const cause = error.cause;
|
|
3349
|
+
return cause instanceof chunk7KEQHWZB_cjs.AccountingApiError && cause.statusCode !== 408 && cause.statusCode < 500;
|
|
3350
|
+
}
|
|
3351
|
+
function submissionLockName(session) {
|
|
3352
|
+
return `privana:external-deposit-lock:submit:${session.owner.toLowerCase()}:${externalDepositSessionId(session.chainId, session.tokenId)}`;
|
|
3353
|
+
}
|
|
3354
|
+
async function withSubmissionLock(session, task) {
|
|
3355
|
+
const locks = typeof navigator === "undefined" ? void 0 : navigator.locks;
|
|
3356
|
+
if (!locks) return task(false);
|
|
3357
|
+
return locks.request(submissionLockName(session), () => task(true));
|
|
3358
|
+
}
|
|
3359
|
+
function externalDepositRetryAmount(session) {
|
|
3360
|
+
if (!session.creditedAmount) throw new Error("No credited external deposit to recover");
|
|
3361
|
+
const creditedAmount = BigInt(session.creditedAmount);
|
|
3362
|
+
const maxLockAmount = BigInt(session.maxLockAmount);
|
|
3363
|
+
return creditedAmount < maxLockAmount ? creditedAmount : maxLockAmount;
|
|
3364
|
+
}
|
|
3365
|
+
async function submitExternalDepositLock(client, session) {
|
|
3366
|
+
return withSubmissionLock(session, async (crossTabExclusive) => {
|
|
3367
|
+
const current = loadExternalDepositLockSession(session.owner);
|
|
3368
|
+
if (!current || current.generation !== session.generation) {
|
|
3369
|
+
throw new chunk7KEQHWZB_cjs.PostDepositLockError(
|
|
3370
|
+
"External deposit lock session changed before submission",
|
|
3371
|
+
"not-found",
|
|
3372
|
+
BigInt(session.maxLockAmount),
|
|
3373
|
+
session.creditedAmount ? BigInt(session.creditedAmount) : void 0
|
|
3374
|
+
);
|
|
3375
|
+
}
|
|
3376
|
+
const result = await submitExternalDepositLockAttempt(client, current, crossTabExclusive);
|
|
3377
|
+
clearExternalDepositLockSession(
|
|
3378
|
+
current.owner,
|
|
3379
|
+
externalDepositSessionId(current.chainId, current.tokenId),
|
|
3380
|
+
current.generation
|
|
3381
|
+
);
|
|
3382
|
+
return result;
|
|
3383
|
+
});
|
|
3384
|
+
}
|
|
3385
|
+
async function submitExternalDepositLockAttempt(client, session, crossTabExclusive) {
|
|
3386
|
+
const creditedAmount = session.creditedAmount ? BigInt(session.creditedAmount) : void 0;
|
|
3387
|
+
if (!creditedAmount) {
|
|
3388
|
+
throw new chunk7KEQHWZB_cjs.PostDepositLockError(
|
|
3389
|
+
"External deposit has not been credited",
|
|
3390
|
+
"submission-failed",
|
|
3391
|
+
BigInt(session.maxLockAmount)
|
|
3392
|
+
);
|
|
3393
|
+
}
|
|
3394
|
+
const payload = session.payload;
|
|
3395
|
+
if (!payload) {
|
|
3396
|
+
throw new chunk7KEQHWZB_cjs.PostDepositLockError(
|
|
3397
|
+
"No persisted signed policy found for this deposit session",
|
|
3398
|
+
"not-found",
|
|
3399
|
+
BigInt(session.maxLockAmount),
|
|
3400
|
+
creditedAmount
|
|
3401
|
+
);
|
|
3402
|
+
}
|
|
3403
|
+
try {
|
|
3404
|
+
return await chunk7KEQHWZB_cjs.submitPendingLock({
|
|
3405
|
+
client,
|
|
3406
|
+
payload,
|
|
3407
|
+
creditedAmount,
|
|
3408
|
+
beforeSubmit: () => {
|
|
3409
|
+
if (!markSubmissionAmbiguous(session, payload.signature)) {
|
|
3410
|
+
throw new Error("Unable to persist lock submission recovery state");
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
});
|
|
3414
|
+
} catch (err) {
|
|
3415
|
+
if (err instanceof chunk7KEQHWZB_cjs.PostDepositLockError && err.reason === "submission-failed" && crossTabExclusive && !session.submissionAmbiguous && isDefinitiveSubmissionFailure(err)) {
|
|
3416
|
+
if (!clearSubmittedPayload(session, payload.signature, true)) {
|
|
3417
|
+
const latest = loadExternalDepositLockSession(session.owner);
|
|
3418
|
+
if (latest?.submissionAmbiguous) throw ambiguousSubmissionError(err);
|
|
3419
|
+
}
|
|
3420
|
+
} else if (err instanceof chunk7KEQHWZB_cjs.PostDepositLockError && err.reason === "submission-failed") {
|
|
3421
|
+
const ambiguous = markSubmissionAmbiguous(session, payload.signature) || loadExternalDepositLockSession(session.owner)?.submissionAmbiguous === true;
|
|
3422
|
+
if (ambiguous) throw ambiguousSubmissionError(err);
|
|
3423
|
+
} else {
|
|
3424
|
+
const current = loadExternalDepositLockSession(session.owner);
|
|
3425
|
+
if (session.submissionAmbiguous || current?.submissionAmbiguous) {
|
|
3426
|
+
if (err instanceof chunk7KEQHWZB_cjs.PostDepositLockError) throw ambiguousSubmissionError(err);
|
|
3427
|
+
throw err;
|
|
3428
|
+
}
|
|
3429
|
+
if (!clearSubmittedPayload(session, payload.signature)) {
|
|
3430
|
+
const latest = loadExternalDepositLockSession(session.owner);
|
|
3431
|
+
if (latest?.submissionAmbiguous && err instanceof chunk7KEQHWZB_cjs.PostDepositLockError) {
|
|
3432
|
+
throw ambiguousSubmissionError(err);
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
throw err;
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
function useExternalDepositLock({
|
|
3440
|
+
allowance,
|
|
3441
|
+
onLockSubmitted,
|
|
3442
|
+
onLockFailed
|
|
3443
|
+
}) {
|
|
3444
|
+
const { client, networkConfig, serviceAddress, getTokenById, tokensStatus } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
3445
|
+
const config = wagmi.useConfig();
|
|
3446
|
+
const queryClient = reactQuery.useQueryClient();
|
|
3447
|
+
const { address } = wagmi.useAccount();
|
|
3448
|
+
const { privateReadAddress } = chunk7KEQHWZB_cjs.usePrivateReadRequest();
|
|
3449
|
+
const { ensureCorrectChain } = chunk7KEQHWZB_cjs.useEnsureCorrectChain();
|
|
3450
|
+
const [isSigning, setIsSigning] = react.useState(false);
|
|
3451
|
+
const [isSubmittingLock, setIsSubmittingLock] = react.useState(false);
|
|
3452
|
+
const [session, setSession] = react.useState(null);
|
|
3453
|
+
const sessionRef = react.useRef(null);
|
|
3454
|
+
const signingRef = react.useRef(false);
|
|
3455
|
+
const settlingRef = react.useRef(false);
|
|
3456
|
+
const pendingCreditedTransitionRef = react.useRef(null);
|
|
3457
|
+
const hydratedScopeRef = react.useRef(null);
|
|
3458
|
+
const beneficiaryRef = react.useRef(privateReadAddress);
|
|
3459
|
+
beneficiaryRef.current = privateReadAddress;
|
|
3460
|
+
const onLockSubmittedRef = react.useRef(onLockSubmitted);
|
|
3461
|
+
const onLockFailedRef = react.useRef(onLockFailed);
|
|
3462
|
+
react.useEffect(() => {
|
|
3463
|
+
onLockSubmittedRef.current = onLockSubmitted;
|
|
3464
|
+
onLockFailedRef.current = onLockFailed;
|
|
3465
|
+
}, [onLockSubmitted, onLockFailed]);
|
|
3466
|
+
const installSession = react.useCallback((next) => {
|
|
3467
|
+
sessionRef.current = next;
|
|
3468
|
+
setSession(next);
|
|
3469
|
+
}, []);
|
|
3470
|
+
const preserveCreditedFallback = react.useCallback(
|
|
3471
|
+
(durable) => {
|
|
3472
|
+
const pending = pendingCreditedTransitionRef.current;
|
|
3473
|
+
if (pending && durable && isSameExternalDepositLockSession(durable, pending.predecessor)) {
|
|
3474
|
+
return pending.credited;
|
|
3475
|
+
}
|
|
3476
|
+
pendingCreditedTransitionRef.current = null;
|
|
3477
|
+
return durable;
|
|
3478
|
+
},
|
|
3479
|
+
[]
|
|
3480
|
+
);
|
|
3481
|
+
const notifyFailure = react.useCallback((error) => {
|
|
3482
|
+
onLockFailedRef.current?.(error);
|
|
3483
|
+
}, []);
|
|
3484
|
+
const submitSession = react.useCallback(
|
|
3485
|
+
async (active) => {
|
|
3486
|
+
if (settlingRef.current) return;
|
|
3487
|
+
settlingRef.current = true;
|
|
3488
|
+
setIsSubmittingLock(true);
|
|
3489
|
+
let result;
|
|
3490
|
+
try {
|
|
3491
|
+
let submission = active;
|
|
3492
|
+
const storedBeforeSubmit = loadExternalDepositLockSession(active.owner);
|
|
3493
|
+
if (storedBeforeSubmit?.generation === active.generation) {
|
|
3494
|
+
if (active.creditedAmount && !storedBeforeSubmit.creditedAmount) {
|
|
3495
|
+
const pending = pendingCreditedTransitionRef.current;
|
|
3496
|
+
if (!pending || !isSameExternalDepositLockSession(active, pending.credited) || !isSameExternalDepositLockSession(storedBeforeSubmit, pending.predecessor)) {
|
|
3497
|
+
throw new ExternalDepositLockSessionChangedError();
|
|
3498
|
+
}
|
|
3499
|
+
saveExternalDepositLockSession(pending.credited, pending.predecessor);
|
|
3500
|
+
pendingCreditedTransitionRef.current = null;
|
|
3501
|
+
submission = pending.credited;
|
|
3502
|
+
} else {
|
|
3503
|
+
submission = storedBeforeSubmit;
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
result = await submitExternalDepositLock(client, submission);
|
|
3507
|
+
} catch (err) {
|
|
3508
|
+
const stored = loadExternalDepositLockSession(active.owner);
|
|
3509
|
+
const error = err instanceof chunk7KEQHWZB_cjs.PostDepositLockError ? err : new chunk7KEQHWZB_cjs.PostDepositLockError(
|
|
3510
|
+
err instanceof Error ? err.message : "Lock submission failed",
|
|
3511
|
+
"submission-failed",
|
|
3512
|
+
BigInt(active.maxLockAmount),
|
|
3513
|
+
active.creditedAmount ? BigInt(active.creditedAmount) : void 0,
|
|
3514
|
+
{ cause: err }
|
|
3515
|
+
);
|
|
3516
|
+
if (err instanceof ExternalDepositLockSessionChangedError) {
|
|
3517
|
+
pendingCreditedTransitionRef.current = null;
|
|
3518
|
+
installSession(stored ?? null);
|
|
3519
|
+
return;
|
|
3520
|
+
}
|
|
3521
|
+
if (!stored || stored.generation !== active.generation) {
|
|
3522
|
+
pendingCreditedTransitionRef.current = null;
|
|
3523
|
+
installSession(stored ?? null);
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
if (active.creditedAmount && !stored.creditedAmount) {
|
|
3527
|
+
const pending = pendingCreditedTransitionRef.current;
|
|
3528
|
+
if (pending && isSameExternalDepositLockSession(active, pending.credited) && isSameExternalDepositLockSession(stored, pending.predecessor)) {
|
|
3529
|
+
installSession(pending.credited);
|
|
3530
|
+
notifyFailure(error);
|
|
3531
|
+
return;
|
|
3532
|
+
}
|
|
3533
|
+
pendingCreditedTransitionRef.current = null;
|
|
3534
|
+
installSession(stored);
|
|
3535
|
+
return;
|
|
3536
|
+
}
|
|
3537
|
+
installSession(active.creditedAmount && !stored.creditedAmount ? active : stored);
|
|
3538
|
+
notifyFailure(error);
|
|
3539
|
+
return;
|
|
3540
|
+
} finally {
|
|
3541
|
+
settlingRef.current = false;
|
|
3542
|
+
setIsSubmittingLock(false);
|
|
3543
|
+
}
|
|
3544
|
+
installSession(loadExternalDepositLockSession(active.owner) ?? null);
|
|
3545
|
+
queryClient.invalidateQueries({ queryKey: ["accounting-balance"] });
|
|
3546
|
+
queryClient.invalidateQueries({ queryKey: ["accounting-locked-funds"] });
|
|
3547
|
+
queryClient.invalidateQueries({ queryKey: ["accounting-total-locked-balance"] });
|
|
3548
|
+
queryClient.invalidateQueries({ queryKey: ["accounting-history"] });
|
|
3549
|
+
onLockSubmittedRef.current?.(result);
|
|
3550
|
+
},
|
|
3551
|
+
[client, installSession, notifyFailure, queryClient]
|
|
3552
|
+
);
|
|
3553
|
+
const validateRestoredSession = react.useCallback(
|
|
3554
|
+
(restored) => {
|
|
3555
|
+
if (!restored || !serviceAddress) return null;
|
|
3556
|
+
const token = getTokenById(restored.tokenId);
|
|
3557
|
+
const invalid = restored.serviceAddress.toLowerCase() !== serviceAddress.toLowerCase() || !token || token.chainId !== restored.chainId || token.contract === viem.zeroAddress || !restored.creditedAmount && !restored.payload;
|
|
3558
|
+
if (!invalid) return restored;
|
|
3559
|
+
clearExternalDepositLockSession(
|
|
3560
|
+
restored.owner,
|
|
3561
|
+
externalDepositSessionId(restored.chainId, restored.tokenId),
|
|
3562
|
+
restored.generation
|
|
3563
|
+
);
|
|
3564
|
+
return null;
|
|
3565
|
+
},
|
|
3566
|
+
[getTokenById, serviceAddress]
|
|
3567
|
+
);
|
|
3568
|
+
react.useEffect(() => {
|
|
3569
|
+
if (!privateReadAddress || !serviceAddress || tokensStatus !== "ready") {
|
|
3570
|
+
setSession(null);
|
|
3571
|
+
return;
|
|
3572
|
+
}
|
|
3573
|
+
const hydrationKey = `${privateReadAddress.toLowerCase()}:${serviceAddress.toLowerCase()}`;
|
|
3574
|
+
const shouldResume = hydratedScopeRef.current !== hydrationKey;
|
|
3575
|
+
hydratedScopeRef.current = hydrationKey;
|
|
3576
|
+
const restored = preserveCreditedFallback(
|
|
3577
|
+
validateRestoredSession(loadExternalDepositLockSession(privateReadAddress))
|
|
3578
|
+
);
|
|
3579
|
+
installSession(restored);
|
|
3580
|
+
if (!restored) {
|
|
3581
|
+
return;
|
|
3582
|
+
}
|
|
3583
|
+
if (!shouldResume) return;
|
|
3584
|
+
if (restored.creditedAmount && restored.payload) {
|
|
3585
|
+
void submitSession(restored);
|
|
3586
|
+
} else if (restored.creditedAmount) {
|
|
3587
|
+
notifyFailure(
|
|
3588
|
+
new chunk7KEQHWZB_cjs.PostDepositLockError(
|
|
3589
|
+
"Deposit credited; sign a fresh policy to lock the funds",
|
|
3590
|
+
"not-found",
|
|
3591
|
+
BigInt(restored.maxLockAmount),
|
|
3592
|
+
BigInt(restored.creditedAmount)
|
|
3593
|
+
)
|
|
3594
|
+
);
|
|
3595
|
+
}
|
|
3596
|
+
}, [
|
|
3597
|
+
installSession,
|
|
3598
|
+
notifyFailure,
|
|
3599
|
+
privateReadAddress,
|
|
3600
|
+
preserveCreditedFallback,
|
|
3601
|
+
serviceAddress,
|
|
3602
|
+
submitSession,
|
|
3603
|
+
tokensStatus,
|
|
3604
|
+
validateRestoredSession
|
|
3605
|
+
]);
|
|
3606
|
+
react.useEffect(() => {
|
|
3607
|
+
if (!privateReadAddress || !serviceAddress || tokensStatus !== "ready") return;
|
|
3608
|
+
const reconcile = (restored) => {
|
|
3609
|
+
installSession(preserveCreditedFallback(validateRestoredSession(restored)));
|
|
3610
|
+
};
|
|
3611
|
+
const unsubscribe = subscribeExternalDepositLockSession(privateReadAddress, reconcile);
|
|
3612
|
+
reconcile(loadExternalDepositLockSession(privateReadAddress));
|
|
3613
|
+
return unsubscribe;
|
|
3614
|
+
}, [
|
|
3615
|
+
installSession,
|
|
3616
|
+
preserveCreditedFallback,
|
|
3617
|
+
privateReadAddress,
|
|
3618
|
+
serviceAddress,
|
|
3619
|
+
tokensStatus,
|
|
3620
|
+
validateRestoredSession
|
|
3621
|
+
]);
|
|
3622
|
+
const signAndPersist = react.useCallback(
|
|
3623
|
+
async ({ tokenId, amount }) => {
|
|
3624
|
+
if (!allowance) throw new Error("No allowance configured for this deposit");
|
|
3625
|
+
if (signingRef.current || settlingRef.current) {
|
|
3626
|
+
throw new Error("A policy operation is already in progress");
|
|
3627
|
+
}
|
|
3628
|
+
if (!chunk7KEQHWZB_cjs.canUseSharedBrowserStorage()) {
|
|
3629
|
+
throw new Error("Browser storage is required for locked deposit recovery");
|
|
3630
|
+
}
|
|
3631
|
+
const owner = chunk7KEQHWZB_cjs.requireDepositLockOwner(address, privateReadAddress);
|
|
3632
|
+
if (sessionRef.current || loadExternalDepositLockSession(owner)) {
|
|
3633
|
+
throw new Error("Finish or cancel the active external deposit before starting another");
|
|
3634
|
+
}
|
|
3635
|
+
const token = getTokenById(tokenId);
|
|
3636
|
+
if (!token) throw new Error(`Unknown token ID: ${tokenId}`);
|
|
3637
|
+
if (token.contract === viem.zeroAddress) {
|
|
3638
|
+
throw new Error("External deposits support ERC20 tokens only");
|
|
3639
|
+
}
|
|
3640
|
+
const targetService = chunk7KEQHWZB_cjs.requireServiceAddress(serviceAddress);
|
|
3641
|
+
const lockDuration = allowance.lockDuration ?? chunk7KEQHWZB_cjs.DEFAULT_LOCK_DURATION_SECONDS;
|
|
3642
|
+
signingRef.current = true;
|
|
3643
|
+
setIsSigning(true);
|
|
3644
|
+
try {
|
|
3645
|
+
await ensureCorrectChain(networkConfig.chainId);
|
|
3646
|
+
const signingWalletClient = await chunk7KEQHWZB_cjs.getWalletClient(config, {
|
|
3647
|
+
chainId: networkConfig.chainId
|
|
3648
|
+
});
|
|
3649
|
+
const payload = await chunk7KEQHWZB_cjs.createSignedLockRequest({
|
|
3650
|
+
client,
|
|
3651
|
+
walletClient: signingWalletClient,
|
|
3652
|
+
userAddress: owner,
|
|
3653
|
+
networkConfig,
|
|
3654
|
+
serviceAddress: targetService,
|
|
3655
|
+
tokenId: token.id,
|
|
3656
|
+
amount: chunk7KEQHWZB_cjs.clampLockAmount(amount, BigInt(allowance.value)),
|
|
3657
|
+
lockDuration
|
|
3658
|
+
});
|
|
3659
|
+
const startBlock = await chunk7KEQHWZB_cjs.getBlockNumber(config, { chainId: token.chainId });
|
|
3660
|
+
if (startBlock > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
3661
|
+
throw new Error("Source-chain block number exceeds the supported range");
|
|
3662
|
+
}
|
|
3663
|
+
if (beneficiaryRef.current?.toLowerCase() !== owner.toLowerCase()) {
|
|
3664
|
+
throw new Error("Authenticated deposit account changed while signing");
|
|
3665
|
+
}
|
|
3666
|
+
const next = {
|
|
3667
|
+
version: 1,
|
|
3668
|
+
owner,
|
|
3669
|
+
serviceAddress: targetService,
|
|
3670
|
+
chainId: token.chainId,
|
|
3671
|
+
tokenId: token.id,
|
|
3672
|
+
startBlock: Number(startBlock),
|
|
3673
|
+
depositAmount: amount.toString(),
|
|
3674
|
+
maxLockAmount: String(payload.amount),
|
|
3675
|
+
lockDuration,
|
|
3676
|
+
generation: payload.signature,
|
|
3677
|
+
payload
|
|
3678
|
+
};
|
|
3679
|
+
saveExternalDepositLockSession(next, null);
|
|
3680
|
+
installSession(next);
|
|
3681
|
+
} finally {
|
|
3682
|
+
signingRef.current = false;
|
|
3683
|
+
setIsSigning(false);
|
|
3684
|
+
}
|
|
3685
|
+
},
|
|
3686
|
+
[
|
|
3687
|
+
address,
|
|
3688
|
+
allowance,
|
|
3689
|
+
client,
|
|
3690
|
+
config,
|
|
3691
|
+
ensureCorrectChain,
|
|
3692
|
+
getTokenById,
|
|
3693
|
+
installSession,
|
|
3694
|
+
networkConfig,
|
|
3695
|
+
privateReadAddress,
|
|
3696
|
+
serviceAddress
|
|
3697
|
+
]
|
|
3698
|
+
);
|
|
3699
|
+
const settleAfterCredit = react.useCallback(
|
|
3700
|
+
async (txHash, creditedAmount) => {
|
|
3701
|
+
const active = sessionRef.current;
|
|
3702
|
+
if (!active || settlingRef.current) return;
|
|
3703
|
+
if (!isCurrentExternalDepositVerification(active, txHash)) {
|
|
3704
|
+
return;
|
|
3705
|
+
}
|
|
3706
|
+
if (creditedAmount <= 0n) throw new Error("Credited amount must be positive");
|
|
3707
|
+
const credited = {
|
|
3708
|
+
...active,
|
|
3709
|
+
verification: void 0,
|
|
3710
|
+
creditedAmount: creditedAmount.toString()
|
|
3711
|
+
};
|
|
3712
|
+
try {
|
|
3713
|
+
saveExternalDepositLockSession(credited, active);
|
|
3714
|
+
pendingCreditedTransitionRef.current = null;
|
|
3715
|
+
} catch (err) {
|
|
3716
|
+
const stored = loadExternalDepositLockSession(active.owner);
|
|
3717
|
+
if (err instanceof ExternalDepositLockSessionChangedError || !stored || !isSameExternalDepositLockSession(stored, active)) {
|
|
3718
|
+
pendingCreditedTransitionRef.current = null;
|
|
3719
|
+
installSession(stored ?? null);
|
|
3720
|
+
return;
|
|
3721
|
+
}
|
|
3722
|
+
pendingCreditedTransitionRef.current = { predecessor: active, credited };
|
|
3723
|
+
installSession(credited);
|
|
3724
|
+
notifyFailure(
|
|
3725
|
+
new chunk7KEQHWZB_cjs.PostDepositLockError(
|
|
3726
|
+
err instanceof Error ? err.message : "Unable to persist credited deposit state",
|
|
3727
|
+
"submission-failed",
|
|
3728
|
+
BigInt(active.maxLockAmount),
|
|
3729
|
+
creditedAmount,
|
|
3730
|
+
{ cause: err }
|
|
3731
|
+
)
|
|
3732
|
+
);
|
|
3733
|
+
return;
|
|
3734
|
+
}
|
|
3735
|
+
installSession(credited);
|
|
3736
|
+
await submitSession(credited);
|
|
3737
|
+
},
|
|
3738
|
+
[installSession, notifyFailure, submitSession]
|
|
3739
|
+
);
|
|
3740
|
+
const recordVerification = react.useCallback(
|
|
3741
|
+
(context) => {
|
|
3742
|
+
const active = sessionRef.current;
|
|
3743
|
+
if (!active || active.creditedAmount) {
|
|
3744
|
+
throw new Error("No external deposit session is awaiting verification");
|
|
3745
|
+
}
|
|
3746
|
+
if (active.verification) {
|
|
3747
|
+
const sameTransfer = active.verification.hash.toLowerCase() === context.hash.toLowerCase() && active.verification.chainId === context.chainId && active.verification.amount === context.amount.toString() && (active.verification.logIndex ?? 0) === (context.logIndex ?? 0);
|
|
3748
|
+
if (sameTransfer) return;
|
|
3749
|
+
throw new Error("Another transfer is already being verified for this deposit session");
|
|
3750
|
+
}
|
|
3751
|
+
if (context.chainId !== active.chainId || context.amount <= 0n) {
|
|
3752
|
+
throw new Error("Discovered transfer does not match the signed deposit session");
|
|
3753
|
+
}
|
|
3754
|
+
const current = loadExternalDepositLockSession(active.owner);
|
|
3755
|
+
if (!current || current.generation !== active.generation) {
|
|
3756
|
+
throw new Error("The signed deposit session changed before verification");
|
|
3757
|
+
}
|
|
3758
|
+
const next = {
|
|
3759
|
+
...active,
|
|
3760
|
+
verification: {
|
|
3761
|
+
hash: context.hash,
|
|
3762
|
+
chainId: context.chainId,
|
|
3763
|
+
amount: context.amount.toString(),
|
|
3764
|
+
logIndex: context.logIndex
|
|
3765
|
+
}
|
|
3766
|
+
};
|
|
3767
|
+
saveExternalDepositLockSession(next, active);
|
|
3768
|
+
installSession(next);
|
|
3769
|
+
},
|
|
3770
|
+
[installSession]
|
|
3771
|
+
);
|
|
3772
|
+
const retryAfterCredit = react.useCallback(async () => {
|
|
3773
|
+
const active = sessionRef.current;
|
|
3774
|
+
if (!active?.creditedAmount) throw new Error("No credited external deposit to recover");
|
|
3775
|
+
if (signingRef.current || settlingRef.current) {
|
|
3776
|
+
throw new Error("A policy operation is already in progress");
|
|
3777
|
+
}
|
|
3778
|
+
if (privateReadAddress?.toLowerCase() !== active.owner.toLowerCase()) {
|
|
3779
|
+
throw new Error("Authenticated deposit account does not match the credited deposit");
|
|
3780
|
+
}
|
|
3781
|
+
const token = getTokenById(active.tokenId);
|
|
3782
|
+
if (!token || token.chainId !== active.chainId || token.contract === viem.zeroAddress) {
|
|
3783
|
+
throw new Error("The credited token is no longer available");
|
|
3784
|
+
}
|
|
3785
|
+
const targetService = chunk7KEQHWZB_cjs.requireServiceAddress(serviceAddress);
|
|
3786
|
+
if (targetService.toLowerCase() !== active.serviceAddress.toLowerCase()) {
|
|
3787
|
+
throw new Error("The service for this credited deposit has changed");
|
|
3788
|
+
}
|
|
3789
|
+
if (active.payload) {
|
|
3790
|
+
await submitSession(active);
|
|
3791
|
+
return;
|
|
3792
|
+
}
|
|
3793
|
+
if (active.submissionAmbiguous) {
|
|
3794
|
+
throw new Error(
|
|
3795
|
+
"The previous lock submission may have succeeded; a fresh signature is unsafe"
|
|
3796
|
+
);
|
|
3797
|
+
}
|
|
3798
|
+
const owner = chunk7KEQHWZB_cjs.requireDepositLockOwner(address, privateReadAddress);
|
|
3799
|
+
const amount = externalDepositRetryAmount(active);
|
|
3800
|
+
let retrySession;
|
|
3801
|
+
signingRef.current = true;
|
|
3802
|
+
setIsSigning(true);
|
|
3803
|
+
try {
|
|
3804
|
+
await ensureCorrectChain(networkConfig.chainId);
|
|
3805
|
+
const signingWalletClient = await chunk7KEQHWZB_cjs.getWalletClient(config, {
|
|
3806
|
+
chainId: networkConfig.chainId
|
|
3807
|
+
});
|
|
3808
|
+
const payload = await chunk7KEQHWZB_cjs.createSignedLockRequest({
|
|
3809
|
+
client,
|
|
3810
|
+
walletClient: signingWalletClient,
|
|
3811
|
+
userAddress: owner,
|
|
3812
|
+
networkConfig,
|
|
3813
|
+
serviceAddress: targetService,
|
|
3814
|
+
tokenId: active.tokenId,
|
|
3815
|
+
amount,
|
|
3816
|
+
lockDuration: active.lockDuration
|
|
3817
|
+
});
|
|
3818
|
+
if (beneficiaryRef.current?.toLowerCase() !== owner.toLowerCase()) {
|
|
3819
|
+
throw new Error("Authenticated deposit account changed while signing");
|
|
3820
|
+
}
|
|
3821
|
+
retrySession = {
|
|
3822
|
+
...active,
|
|
3823
|
+
depositAmount: amount.toString(),
|
|
3824
|
+
generation: payload.signature,
|
|
3825
|
+
verification: void 0,
|
|
3826
|
+
submissionAmbiguous: void 0,
|
|
3827
|
+
payload
|
|
3828
|
+
};
|
|
3829
|
+
saveExternalDepositLockSession(retrySession, active);
|
|
3830
|
+
installSession(retrySession);
|
|
3831
|
+
} finally {
|
|
3832
|
+
signingRef.current = false;
|
|
3833
|
+
setIsSigning(false);
|
|
3834
|
+
}
|
|
3835
|
+
await submitSession(retrySession);
|
|
3836
|
+
}, [
|
|
3837
|
+
address,
|
|
3838
|
+
client,
|
|
3839
|
+
config,
|
|
3840
|
+
ensureCorrectChain,
|
|
3841
|
+
getTokenById,
|
|
3842
|
+
installSession,
|
|
3843
|
+
networkConfig,
|
|
3844
|
+
privateReadAddress,
|
|
3845
|
+
serviceAddress,
|
|
3846
|
+
submitSession
|
|
3847
|
+
]);
|
|
3848
|
+
const clearVerification = react.useCallback(() => {
|
|
3849
|
+
const active = sessionRef.current;
|
|
3850
|
+
if (!active?.verification || active.creditedAmount) return false;
|
|
3851
|
+
const next = clearExternalDepositVerification(active);
|
|
3852
|
+
if (!next) {
|
|
3853
|
+
installSession(loadExternalDepositLockSession(active.owner) ?? null);
|
|
3854
|
+
return false;
|
|
3855
|
+
}
|
|
3856
|
+
installSession(next);
|
|
3857
|
+
return true;
|
|
3858
|
+
}, [installSession]);
|
|
3859
|
+
const discardSession = react.useCallback(() => {
|
|
3860
|
+
const active = sessionRef.current;
|
|
3861
|
+
if (!active) return true;
|
|
3862
|
+
if (signingRef.current || settlingRef.current) return false;
|
|
3863
|
+
const pending = pendingCreditedTransitionRef.current;
|
|
3864
|
+
const discardTarget = pending && isSameExternalDepositLockSession(active, pending.credited) ? pending.predecessor : active;
|
|
3865
|
+
const discarded = discardExternalDepositLockSession(discardTarget);
|
|
3866
|
+
const restored = loadExternalDepositLockSession(active.owner) ?? null;
|
|
3867
|
+
if (discarded) pendingCreditedTransitionRef.current = null;
|
|
3868
|
+
installSession(restored);
|
|
3869
|
+
return discarded && !restored;
|
|
3870
|
+
}, [installSession]);
|
|
3871
|
+
return {
|
|
3872
|
+
isSigning,
|
|
3873
|
+
isSubmittingLock,
|
|
3874
|
+
session,
|
|
3875
|
+
signAndPersist,
|
|
3876
|
+
recordVerification,
|
|
3877
|
+
settleAfterCredit,
|
|
3878
|
+
retryAfterCredit,
|
|
3879
|
+
clearVerification,
|
|
3880
|
+
discardSession
|
|
3881
|
+
};
|
|
3882
|
+
}
|
|
3118
3883
|
var DEFAULT_MOONPAY_API_URL = "https://api.moonpay.com/v3";
|
|
3119
3884
|
function useMoonpayLimits({
|
|
3120
3885
|
currencyCode,
|
|
@@ -3158,7 +3923,7 @@ function useMoonpayLimits({
|
|
|
3158
3923
|
};
|
|
3159
3924
|
}
|
|
3160
3925
|
function TokenSelectorView2({ selectedTokenId, onSelect }) {
|
|
3161
|
-
const { enabledTokens } =
|
|
3926
|
+
const { enabledTokens } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
3162
3927
|
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: [
|
|
3163
3928
|
enabledTokens.map((token) => {
|
|
3164
3929
|
const isSelected = selectedTokenId === token.id;
|
|
@@ -3167,7 +3932,7 @@ function TokenSelectorView2({ selectedTokenId, onSelect }) {
|
|
|
3167
3932
|
{
|
|
3168
3933
|
type: "button",
|
|
3169
3934
|
onClick: () => onSelect(token.id),
|
|
3170
|
-
className:
|
|
3935
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
3171
3936
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors",
|
|
3172
3937
|
isSelected && "bg-secondary"
|
|
3173
3938
|
),
|
|
@@ -3222,7 +3987,7 @@ function CreditCardWidgetView({
|
|
|
3222
3987
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
|
|
3223
3988
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: "Complete your purchase" }),
|
|
3224
3989
|
token && moonpayCurrencyCode ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3225
|
-
|
|
3990
|
+
chunk7KEQHWZB_cjs.FiatOnRampForm,
|
|
3226
3991
|
{
|
|
3227
3992
|
tokenId: token.id,
|
|
3228
3993
|
currencyCode: moonpayCurrencyCode,
|
|
@@ -3282,7 +4047,7 @@ function PolicyTermRow({
|
|
|
3282
4047
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3283
4048
|
"div",
|
|
3284
4049
|
{
|
|
3285
|
-
className:
|
|
4050
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
3286
4051
|
"mt-0.5 shrink-0",
|
|
3287
4052
|
kind === "permission" ? "text-emerald-500" : "text-orange-500"
|
|
3288
4053
|
),
|
|
@@ -3344,11 +4109,19 @@ function AllowancePolicySection({
|
|
|
3344
4109
|
] });
|
|
3345
4110
|
}
|
|
3346
4111
|
function MoonPayGate({ enabled, children }) {
|
|
3347
|
-
const { networkConfig } =
|
|
4112
|
+
const { networkConfig } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
3348
4113
|
const apiKey = networkConfig.moonpayApiKey;
|
|
3349
4114
|
if (!enabled || !apiKey) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
3350
4115
|
return /* @__PURE__ */ jsxRuntime.jsx(moonpayReact.MoonPayProvider, { apiKey, children });
|
|
3351
4116
|
}
|
|
4117
|
+
function formatPostDepositLockFailure(error, token) {
|
|
4118
|
+
if (error?.reason === "credited-below-signed" && error.creditedAmount !== void 0 && error.signedAmount !== void 0 && token) {
|
|
4119
|
+
const creditedAmount = `${viem.formatUnits(error.creditedAmount, token.decimals)} ${token.symbol}`;
|
|
4120
|
+
const signedAmount = `${viem.formatUnits(error.signedAmount, token.decimals)} ${token.symbol}`;
|
|
4121
|
+
return `Credited amount (${creditedAmount}) is below the signed lock amount (${signedAmount})`;
|
|
4122
|
+
}
|
|
4123
|
+
return error?.message ?? "Lock submission failed";
|
|
4124
|
+
}
|
|
3352
4125
|
function MethodTabs({
|
|
3353
4126
|
activeTab,
|
|
3354
4127
|
onTabChange
|
|
@@ -3357,7 +4130,7 @@ function MethodTabs({
|
|
|
3357
4130
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3358
4131
|
"div",
|
|
3359
4132
|
{
|
|
3360
|
-
className:
|
|
4133
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
3361
4134
|
"bg-input absolute top-1 bottom-1 left-1 w-[calc(50%-8px)] rounded-md transition-transform duration-200",
|
|
3362
4135
|
activeTab === "credit-card" && "translate-x-[calc(100%+8px)]"
|
|
3363
4136
|
)
|
|
@@ -3368,7 +4141,7 @@ function MethodTabs({
|
|
|
3368
4141
|
{
|
|
3369
4142
|
type: "button",
|
|
3370
4143
|
onClick: () => onTabChange("crypto"),
|
|
3371
|
-
className:
|
|
4144
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
3372
4145
|
"relative z-10 flex-1 cursor-pointer rounded-md px-3 py-[9px] text-sm font-medium transition-colors",
|
|
3373
4146
|
activeTab === "crypto" ? "text-foreground" : "text-muted-foreground"
|
|
3374
4147
|
),
|
|
@@ -3380,7 +4153,7 @@ function MethodTabs({
|
|
|
3380
4153
|
{
|
|
3381
4154
|
type: "button",
|
|
3382
4155
|
onClick: () => onTabChange("credit-card"),
|
|
3383
|
-
className:
|
|
4156
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
3384
4157
|
"relative z-10 flex-1 cursor-pointer rounded-md px-3 py-[9px] text-sm font-medium transition-colors",
|
|
3385
4158
|
activeTab === "credit-card" ? "text-foreground" : "text-muted-foreground"
|
|
3386
4159
|
),
|
|
@@ -3415,19 +4188,21 @@ function DepositView({
|
|
|
3415
4188
|
selectedToken,
|
|
3416
4189
|
amount,
|
|
3417
4190
|
allowance,
|
|
4191
|
+
externalMinimum,
|
|
3418
4192
|
onAmountChange,
|
|
3419
4193
|
onSelectToken,
|
|
3420
4194
|
onConnectWallet,
|
|
3421
4195
|
onSubmit,
|
|
3422
4196
|
isSubmitting = false
|
|
3423
4197
|
}) {
|
|
3424
|
-
const { getChainById: getChainById2, chains, serviceName, serviceIcon, networkConfig } =
|
|
4198
|
+
const { getChainById: getChainById2, chains, serviceName, serviceIcon, networkConfig, hostedAuthConfig } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
3425
4199
|
const { address, isConnected } = wagmi.useAccount();
|
|
3426
4200
|
const appName = serviceName ?? "Privana";
|
|
3427
4201
|
const chain = selectedToken ? getChainById2(selectedToken.chainId) : void 0;
|
|
3428
4202
|
const targetChain = chain ?? chains[0];
|
|
3429
4203
|
const sourceLabel = source === "connected" ? "Connected Wallet" : "External Wallet";
|
|
3430
4204
|
const isConnectedSource = source === "connected";
|
|
4205
|
+
const isExternal = source === "external";
|
|
3431
4206
|
const isCreditCard = source === "credit-card";
|
|
3432
4207
|
const isNative = selectedToken?.contract === viem.zeroAddress;
|
|
3433
4208
|
const { data: nativeBalanceData } = wagmi.useBalance({
|
|
@@ -3444,7 +4219,7 @@ function DepositView({
|
|
|
3444
4219
|
query: { enabled: isConnectedSource && !!address && !!selectedToken && !isNative }
|
|
3445
4220
|
});
|
|
3446
4221
|
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
3447
|
-
const formattedWalletBalance = walletBalance != null && selectedToken ?
|
|
4222
|
+
const formattedWalletBalance = walletBalance != null && selectedToken ? chunk7KEQHWZB_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
|
|
3448
4223
|
const {
|
|
3449
4224
|
minBuyAmount: moonpayMinBuy,
|
|
3450
4225
|
isLoading: moonpayLimitsLoading,
|
|
@@ -3457,12 +4232,18 @@ function DepositView({
|
|
|
3457
4232
|
const hasValidAmount = !!amount && parseFloat(amount) > 0;
|
|
3458
4233
|
const maxAmountDecimals = isCreditCard ? 2 : selectedToken?.decimals;
|
|
3459
4234
|
const tooManyDecimals = hasValidAmount && maxAmountDecimals != null && amount.includes(".") && amount.split(".")[1].length > maxAmountDecimals;
|
|
3460
|
-
const exceedsBalance = isConnectedSource && hasValidAmount && !tooManyDecimals && !!selectedToken && walletBalance != null &&
|
|
4235
|
+
const exceedsBalance = isConnectedSource && hasValidAmount && !tooManyDecimals && !!selectedToken && walletBalance != null && chunk7KEQHWZB_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
|
|
3461
4236
|
const belowMoonpayMin = isCreditCard && hasValidAmount && moonpayMinBuy != null && parseFloat(amount) < moonpayMinBuy;
|
|
3462
4237
|
const moonpayLimitsUnready = isCreditCard && !!selectedToken?.moonpayCurrencyCode && moonpayMinBuy == null;
|
|
3463
4238
|
const creditCardUnavailable = isCreditCard && !!selectedToken && !selectedToken.moonpayCurrencyCode;
|
|
3464
|
-
const
|
|
3465
|
-
const
|
|
4239
|
+
const externalTokenUnavailable = isExternal && !!selectedToken && isNative;
|
|
4240
|
+
const externalMinimumRequired = isExternal && !!allowance && !!selectedToken;
|
|
4241
|
+
const externalMinimumLoading = externalMinimumRequired && externalMinimum === void 0;
|
|
4242
|
+
const externalMinimumUnavailable = externalMinimumRequired && externalMinimum === null;
|
|
4243
|
+
const belowExternalMinimum = externalMinimumRequired && hasValidAmount && !tooManyDecimals && !!selectedToken && typeof externalMinimum === "bigint" && chunk7KEQHWZB_cjs.parseTokenAmount(amount, selectedToken.decimals) < externalMinimum;
|
|
4244
|
+
const externalNeedsWallet = isExternal && (!!allowance || !hostedAuthConfig);
|
|
4245
|
+
const needsConnect = (isConnectedSource || externalNeedsWallet) && !isConnected;
|
|
4246
|
+
const canDeposit = hasValidAmount && !!selectedToken && !tooManyDecimals && !exceedsBalance && !belowMoonpayMin && !moonpayLimitsUnready && !creditCardUnavailable && !externalTokenUnavailable && !externalMinimumLoading && !externalMinimumUnavailable && !belowExternalMinimum && !needsConnect;
|
|
3466
4247
|
const handleMax = () => {
|
|
3467
4248
|
const max = formattedWalletBalance.replace(/\s/g, "");
|
|
3468
4249
|
if (parseFloat(max) > 0) onAmountChange(max);
|
|
@@ -3471,9 +4252,12 @@ function DepositView({
|
|
|
3471
4252
|
isCreditCard ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3472
4253
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: "Buy with credit card and deposit" }),
|
|
3473
4254
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Enter your deposit amount and proceed to sign a policy." })
|
|
3474
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs("
|
|
3475
|
-
"
|
|
3476
|
-
|
|
4255
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
4256
|
+
/* @__PURE__ */ jsxRuntime.jsxs("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: [
|
|
4257
|
+
"Deposit from ",
|
|
4258
|
+
sourceLabel
|
|
4259
|
+
] }),
|
|
4260
|
+
allowance && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Enter your deposit amount and proceed to sign a policy." })
|
|
3477
4261
|
] }),
|
|
3478
4262
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
3479
4263
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-muted-foreground text-sm", children: "Token" }),
|
|
@@ -3482,7 +4266,8 @@ function DepositView({
|
|
|
3482
4266
|
{
|
|
3483
4267
|
type: "button",
|
|
3484
4268
|
onClick: onSelectToken,
|
|
3485
|
-
|
|
4269
|
+
disabled: isSubmitting,
|
|
4270
|
+
className: "border-border bg-input flex w-full cursor-pointer items-center gap-3 rounded-lg border p-3 text-left disabled:cursor-not-allowed disabled:opacity-50",
|
|
3486
4271
|
children: [
|
|
3487
4272
|
selectedToken ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3488
4273
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 w-8 shrink-0 overflow-hidden rounded-full", children: getTokenIcon(selectedToken.symbol, 32) }),
|
|
@@ -3512,7 +4297,7 @@ function DepositView({
|
|
|
3512
4297
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3513
4298
|
"div",
|
|
3514
4299
|
{
|
|
3515
|
-
className:
|
|
4300
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
3516
4301
|
"border-border bg-input flex items-center gap-2 rounded-[10px] border",
|
|
3517
4302
|
isConnectedSource ? "py-1 pr-1 pl-3" : "px-3 py-3"
|
|
3518
4303
|
),
|
|
@@ -3523,6 +4308,7 @@ function DepositView({
|
|
|
3523
4308
|
type: "text",
|
|
3524
4309
|
inputMode: "decimal",
|
|
3525
4310
|
placeholder: "Enter Amount",
|
|
4311
|
+
disabled: isSubmitting,
|
|
3526
4312
|
value: amount,
|
|
3527
4313
|
onChange: (e) => {
|
|
3528
4314
|
const value = e.target.value.replace(/[^0-9.,]/g, "").replace(/,/g, ".");
|
|
@@ -3554,11 +4340,24 @@ function DepositView({
|
|
|
3554
4340
|
moonpayMinBuy,
|
|
3555
4341
|
" USD."
|
|
3556
4342
|
] }),
|
|
4343
|
+
belowExternalMinimum && selectedToken && typeof externalMinimum === "bigint" && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-destructive text-sm", children: [
|
|
4344
|
+
"Minimum deposit is ",
|
|
4345
|
+
viem.formatUnits(externalMinimum, selectedToken.decimals),
|
|
4346
|
+
" ",
|
|
4347
|
+
selectedToken.symbol,
|
|
4348
|
+
"."
|
|
4349
|
+
] }),
|
|
4350
|
+
externalMinimumLoading && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Checking minimum deposit\u2026" }),
|
|
4351
|
+
externalMinimumUnavailable && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-destructive text-sm", children: "Couldn\u2019t load the minimum deposit. Please try again." }),
|
|
3557
4352
|
isCreditCard && moonpayLimitsError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-destructive text-sm", children: "Couldn\u2019t load purchase limits. Please try again." }),
|
|
3558
4353
|
isCreditCard && moonpayLimitsLoading && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Checking purchase limits\u2026" }),
|
|
3559
4354
|
creditCardUnavailable && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-destructive text-sm", children: [
|
|
3560
4355
|
selectedToken?.symbol ?? "This token",
|
|
3561
4356
|
" isn\u2019t available for card purchases yet."
|
|
4357
|
+
] }),
|
|
4358
|
+
externalTokenUnavailable && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-destructive text-sm", children: [
|
|
4359
|
+
selectedToken?.symbol ?? "This token",
|
|
4360
|
+
" can\u2019t be used for external deposits. Choose an ERC20 token."
|
|
3562
4361
|
] })
|
|
3563
4362
|
] }),
|
|
3564
4363
|
allowance && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3633,19 +4432,33 @@ function AwaitingDepositStatus({
|
|
|
3633
4432
|
function ExternalDepositView({
|
|
3634
4433
|
token,
|
|
3635
4434
|
amount,
|
|
3636
|
-
|
|
4435
|
+
depositAddressState,
|
|
4436
|
+
onCredited,
|
|
4437
|
+
onDiscardLock,
|
|
4438
|
+
lock
|
|
3637
4439
|
}) {
|
|
3638
|
-
const { getChainById: getChainById2 } =
|
|
3639
|
-
const
|
|
4440
|
+
const { getChainById: getChainById2, getTokenById, serviceName } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
4441
|
+
const appName = serviceName ?? "Privana";
|
|
4442
|
+
const { depositAddress, isReady, isLoading } = depositAddressState;
|
|
3640
4443
|
const chain = token ? getChainById2(token.chainId) : void 0;
|
|
4444
|
+
const lockSession = lock?.session;
|
|
4445
|
+
const recordVerification = lock?.recordVerification;
|
|
4446
|
+
const settleAfterCredit = lock?.settleAfterCredit;
|
|
4447
|
+
const retryAfterCredit = lock?.retryAfterCredit;
|
|
4448
|
+
const discoveryToken = lockSession ? getTokenById(lockSession.tokenId) : token;
|
|
3641
4449
|
const [copied, setCopied] = react.useState(false);
|
|
3642
4450
|
const [deadline] = react.useState(() => Date.now() + LISTENING_WINDOW_MS);
|
|
3643
4451
|
const secondsLeft = useCountdown(deadline);
|
|
3644
4452
|
const listening = secondsLeft > 0;
|
|
3645
4453
|
const [nothingFound, setNothingFound] = react.useState(false);
|
|
3646
4454
|
const [credited, setCredited] = react.useState(null);
|
|
3647
|
-
const
|
|
3648
|
-
|
|
4455
|
+
const [showCancelWarning, setShowCancelWarning] = react.useState(false);
|
|
4456
|
+
const verification = chunk7KEQHWZB_cjs.useDepositVerification({
|
|
4457
|
+
onCredited: (txHash, _response, creditedAmount) => {
|
|
4458
|
+
if (settleAfterCredit) {
|
|
4459
|
+
void settleAfterCredit(txHash, creditedAmount);
|
|
4460
|
+
return;
|
|
4461
|
+
}
|
|
3649
4462
|
if (onCredited) {
|
|
3650
4463
|
onCredited();
|
|
3651
4464
|
return;
|
|
@@ -3653,8 +4466,9 @@ function ExternalDepositView({
|
|
|
3653
4466
|
setCredited({ txHash });
|
|
3654
4467
|
}
|
|
3655
4468
|
});
|
|
3656
|
-
const { isVerifying, verificationFailed, didTimeout, verify } = verification;
|
|
3657
|
-
const scanPaused = isVerifying || verificationFailed || didTimeout || !!credited;
|
|
4469
|
+
const { isVerifying, verificationFailed, canCheckAnotherTransfer, didTimeout, verify } = verification;
|
|
4470
|
+
const scanPaused = isVerifying || verificationFailed || didTimeout || !!credited || !!lock?.isSigning || !!lock?.isSubmittingLock || !!lockSession?.verification || !!lockSession?.creditedAmount;
|
|
4471
|
+
const showDepositInstructions = !credited && !lockSession?.creditedAmount;
|
|
3658
4472
|
const {
|
|
3659
4473
|
pending,
|
|
3660
4474
|
isFetching: isScanning,
|
|
@@ -3663,23 +4477,58 @@ function ExternalDepositView({
|
|
|
3663
4477
|
isUnavailable,
|
|
3664
4478
|
refetch: refetchPendingDeposits
|
|
3665
4479
|
} = usePendingDeposits({
|
|
3666
|
-
chainId:
|
|
3667
|
-
|
|
4480
|
+
chainId: discoveryToken?.chainId,
|
|
4481
|
+
tokenAddress: discoveryToken?.contract === viem.zeroAddress ? void 0 : discoveryToken?.contract,
|
|
4482
|
+
enabled: isReady && !!depositAddress && !!discoveryToken && discoveryToken.contract !== viem.zeroAddress,
|
|
3668
4483
|
refetchInterval: listening && !scanPaused ? 3e4 : false
|
|
3669
4484
|
});
|
|
3670
4485
|
const processedRef = react.useRef(/* @__PURE__ */ new Set());
|
|
4486
|
+
const verificationRunRef = react.useRef(null);
|
|
4487
|
+
react.useEffect(
|
|
4488
|
+
() => () => {
|
|
4489
|
+
verificationRunRef.current = null;
|
|
4490
|
+
},
|
|
4491
|
+
[]
|
|
4492
|
+
);
|
|
4493
|
+
react.useEffect(() => {
|
|
4494
|
+
const stored = lockSession?.verification;
|
|
4495
|
+
if (!stored || lockSession.creditedAmount || isVerifying || verificationFailed || didTimeout) {
|
|
4496
|
+
return;
|
|
4497
|
+
}
|
|
4498
|
+
const key = `${lockSession.generation}:${stored.chainId}:${stored.hash}:${stored.logIndex ?? 0}`;
|
|
4499
|
+
if (verificationRunRef.current === key) return;
|
|
4500
|
+
verificationRunRef.current = key;
|
|
4501
|
+
processedRef.current.add(`${stored.hash}:${stored.logIndex ?? 0}`);
|
|
4502
|
+
void verify({
|
|
4503
|
+
hash: stored.hash,
|
|
4504
|
+
chainId: stored.chainId,
|
|
4505
|
+
amount: BigInt(stored.amount),
|
|
4506
|
+
logIndex: stored.logIndex
|
|
4507
|
+
});
|
|
4508
|
+
}, [didTimeout, isVerifying, lockSession, verificationFailed, verify]);
|
|
3671
4509
|
react.useEffect(() => {
|
|
3672
4510
|
if (scanPaused) return;
|
|
3673
|
-
const next = [...pending].sort((a, b) => a.block_number - b.block_number).find(
|
|
4511
|
+
const next = [...pending].sort((a, b) => a.block_number - b.block_number).find(
|
|
4512
|
+
(deposit) => (!lockSession || isExternalDepositBlockInSession(lockSession, deposit.block_number)) && !processedRef.current.has(`${deposit.tx_hash}:${deposit.log_index}`)
|
|
4513
|
+
);
|
|
3674
4514
|
if (!next) return;
|
|
3675
|
-
|
|
3676
|
-
void verify({
|
|
4515
|
+
const context = {
|
|
3677
4516
|
hash: next.tx_hash,
|
|
3678
4517
|
chainId: next.chain_id,
|
|
3679
4518
|
amount: BigInt(next.amount),
|
|
3680
4519
|
logIndex: next.log_index
|
|
3681
|
-
}
|
|
3682
|
-
|
|
4520
|
+
};
|
|
4521
|
+
if (recordVerification) {
|
|
4522
|
+
try {
|
|
4523
|
+
recordVerification(context);
|
|
4524
|
+
} catch (err) {
|
|
4525
|
+
sonner.toast.error(err instanceof Error ? err.message : "Unable to save deposit recovery state");
|
|
4526
|
+
return;
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4529
|
+
processedRef.current.add(`${next.tx_hash}:${next.log_index}`);
|
|
4530
|
+
if (!recordVerification) void verify(context);
|
|
4531
|
+
}, [lockSession, pending, recordVerification, scanPaused, verify]);
|
|
3683
4532
|
const nothingFoundTimerRef = react.useRef(void 0);
|
|
3684
4533
|
react.useEffect(() => () => clearTimeout(nothingFoundTimerRef.current), []);
|
|
3685
4534
|
const handleRefresh = () => {
|
|
@@ -3692,11 +4541,27 @@ function ExternalDepositView({
|
|
|
3692
4541
|
}
|
|
3693
4542
|
});
|
|
3694
4543
|
};
|
|
3695
|
-
const handleCopy = () => {
|
|
4544
|
+
const handleCopy = async () => {
|
|
3696
4545
|
if (!depositAddress) return;
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
4546
|
+
try {
|
|
4547
|
+
await navigator.clipboard.writeText(depositAddress);
|
|
4548
|
+
setCopied(true);
|
|
4549
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
4550
|
+
} catch {
|
|
4551
|
+
sonner.toast.error("Unable to copy the deposit address");
|
|
4552
|
+
}
|
|
4553
|
+
};
|
|
4554
|
+
const handleCheckAnotherTransfer = () => {
|
|
4555
|
+
try {
|
|
4556
|
+
if (!lock?.clearVerification()) {
|
|
4557
|
+
sonner.toast.error("Deposit recovery changed in another tab. Please review the current state.");
|
|
4558
|
+
return;
|
|
4559
|
+
}
|
|
4560
|
+
verificationRunRef.current = null;
|
|
4561
|
+
verification.reset();
|
|
4562
|
+
} catch (err) {
|
|
4563
|
+
sonner.toast.error(err instanceof Error ? err.message : "Unable to continue deposit discovery");
|
|
4564
|
+
}
|
|
3700
4565
|
};
|
|
3701
4566
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
|
|
3702
4567
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
@@ -3710,31 +4575,68 @@ function ExternalDepositView({
|
|
|
3710
4575
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-border h-px w-full" }),
|
|
3711
4576
|
/* @__PURE__ */ jsxRuntime.jsx(SummaryRow, { value: amount || "\u2014", label: "Value" })
|
|
3712
4577
|
] }),
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Deposit
|
|
3716
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex
|
|
3717
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
3718
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3719
|
-
"
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
4578
|
+
showDepositInstructions && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4579
|
+
!scanPaused && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Send the displayed amount in one transfer. Transfers below the minimum are not combined or automatically returned." }),
|
|
4580
|
+
/* @__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(chunk7KEQHWZB_cjs.Skeleton, { className: "h-full w-full rounded-[10px]" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Deposit address unavailable" }) }),
|
|
4581
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
4582
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Deposit Address" }),
|
|
4583
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
4584
|
+
/* @__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(chunk7KEQHWZB_cjs.Skeleton, { className: "h-4 w-3/4" }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "\u2014" }) }),
|
|
4585
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4586
|
+
"button",
|
|
4587
|
+
{
|
|
4588
|
+
type: "button",
|
|
4589
|
+
onClick: handleCopy,
|
|
4590
|
+
disabled: !depositAddress,
|
|
4591
|
+
className: "bg-primary text-primary-foreground hover:bg-primary/90 flex h-10 shrink-0 cursor-pointer items-center gap-2 rounded-[10px] px-3 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
|
|
4592
|
+
children: [
|
|
4593
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyIcon, {}),
|
|
4594
|
+
copied ? "Copied" : "Copy"
|
|
4595
|
+
]
|
|
4596
|
+
}
|
|
4597
|
+
)
|
|
4598
|
+
] })
|
|
3731
4599
|
] })
|
|
3732
4600
|
] }),
|
|
3733
|
-
|
|
4601
|
+
showCancelWarning && lockSession && !lockSession.verification && !lockSession.creditedAmount ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4602
|
+
TransactionWarningView,
|
|
4603
|
+
{
|
|
4604
|
+
title: "Cancel this deposit?",
|
|
4605
|
+
message: "Only cancel if you have not sent funds. Canceling after a transfer was sent stops recovery and can leave the transfer uncredited or unlocked.",
|
|
4606
|
+
onDone: () => onDiscardLock?.(),
|
|
4607
|
+
actionLabel: "I haven\u2019t sent funds",
|
|
4608
|
+
onDismiss: () => setShowCancelWarning(false),
|
|
4609
|
+
dismissLabel: "Keep waiting"
|
|
4610
|
+
}
|
|
4611
|
+
) : lock?.isSigning ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4612
|
+
AwaitingDepositStatus,
|
|
4613
|
+
{
|
|
4614
|
+
title: "Confirm policy in your wallet",
|
|
4615
|
+
subtitle: "Sign a fresh policy for the funds already credited."
|
|
4616
|
+
}
|
|
4617
|
+
) : lock?.isSubmittingLock ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4618
|
+
AwaitingDepositStatus,
|
|
4619
|
+
{
|
|
4620
|
+
title: `Locking funds for ${appName}`,
|
|
4621
|
+
subtitle: "Deposit credited. Applying your signed policy\u2026"
|
|
4622
|
+
}
|
|
4623
|
+
) : lock?.session?.creditedAmount ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4624
|
+
TransactionWarningView,
|
|
4625
|
+
{
|
|
4626
|
+
title: lock.session.submissionAmbiguous ? "Lock status unknown" : "Deposit credited",
|
|
4627
|
+
message: lock.session.submissionAmbiguous ? "The lock may already have succeeded. Retry only the saved signature, or check locked funds before stopping recovery." : "The deposit is credited, but its signed lock still needs to be submitted.",
|
|
4628
|
+
onDone: () => {
|
|
4629
|
+
void retryAfterCredit?.().catch((err) => {
|
|
4630
|
+
sonner.toast.error(err instanceof Error ? err.message : "Policy recovery failed");
|
|
4631
|
+
});
|
|
4632
|
+
},
|
|
4633
|
+
actionLabel: lock.session.payload ? "Retry lock submission" : "Sign policy and lock funds"
|
|
4634
|
+
}
|
|
4635
|
+
) : credited ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3734
4636
|
TransactionSuccessView,
|
|
3735
4637
|
{
|
|
3736
4638
|
title: "Deposit Credited",
|
|
3737
|
-
message: `Transfer ${
|
|
4639
|
+
message: `Transfer ${chunk7KEQHWZB_cjs.shortenAddress(credited.txHash)} has been credited to your Privana balance.`,
|
|
3738
4640
|
onDone: () => {
|
|
3739
4641
|
setCredited(null);
|
|
3740
4642
|
verification.reset();
|
|
@@ -3747,14 +4649,15 @@ function ExternalDepositView({
|
|
|
3747
4649
|
title: "Could not verify deposit",
|
|
3748
4650
|
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
4651
|
onRetry: () => void verification.retryVerification(),
|
|
3750
|
-
onDismiss: () => verification.reset(),
|
|
4652
|
+
onDismiss: lock ? canCheckAnotherTransfer ? handleCheckAnotherTransfer : void 0 : () => verification.reset(),
|
|
4653
|
+
dismissLabel: lock && canCheckAnotherTransfer ? "Check another transfer" : void 0,
|
|
3751
4654
|
isRetrying: isVerifying
|
|
3752
4655
|
}
|
|
3753
4656
|
) : isVerifying ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3754
4657
|
AwaitingDepositStatus,
|
|
3755
4658
|
{
|
|
3756
4659
|
title: "Deposit detected",
|
|
3757
|
-
subtitle: "Crediting the incoming transaction to your Privana balance
|
|
4660
|
+
subtitle: "Crediting the incoming transaction to your Privana balance\u2026"
|
|
3758
4661
|
}
|
|
3759
4662
|
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3760
4663
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3762,7 +4665,7 @@ function ExternalDepositView({
|
|
|
3762
4665
|
{
|
|
3763
4666
|
title: "Awaiting Deposit",
|
|
3764
4667
|
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 ?
|
|
4668
|
+
remaining: listening ? chunk7KEQHWZB_cjs.formatCountdown(secondsLeft) : void 0
|
|
3766
4669
|
}
|
|
3767
4670
|
),
|
|
3768
4671
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
@@ -3776,7 +4679,16 @@ function ExternalDepositView({
|
|
|
3776
4679
|
children: "Refresh deposit status"
|
|
3777
4680
|
}
|
|
3778
4681
|
),
|
|
3779
|
-
|
|
4682
|
+
lockSession && !lockSession.verification && !lockSession.creditedAmount && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4683
|
+
"button",
|
|
4684
|
+
{
|
|
4685
|
+
type: "button",
|
|
4686
|
+
onClick: () => setShowCancelWarning(true),
|
|
4687
|
+
className: "border-border text-foreground hover:bg-secondary flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] border px-3 py-2 text-sm font-medium transition-colors",
|
|
4688
|
+
children: "Cancel deposit"
|
|
4689
|
+
}
|
|
4690
|
+
),
|
|
4691
|
+
isRateLimited ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-center text-sm", children: "Checked too recently. 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. Retrying automatically." }) : nothingFound ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-center text-sm", children: "No incoming transaction found yet." }) : null
|
|
3780
4692
|
] })
|
|
3781
4693
|
] })
|
|
3782
4694
|
] });
|
|
@@ -3795,7 +4707,7 @@ function DepositModalContent({
|
|
|
3795
4707
|
onCloseBlockedChange,
|
|
3796
4708
|
onExit
|
|
3797
4709
|
}) {
|
|
3798
|
-
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig, getChainById: getChainById2 } =
|
|
4710
|
+
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig, getChainById: getChainById2, getTokenById } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
3799
4711
|
const { address } = wagmi.useAccount();
|
|
3800
4712
|
const appName = serviceName ?? "Privana";
|
|
3801
4713
|
const [activeTab, setActiveTab] = react.useState(defaultTab);
|
|
@@ -3804,6 +4716,10 @@ function DepositModalContent({
|
|
|
3804
4716
|
const [selectedTokenId, setSelectedTokenId] = react.useState(defaultToken?.id ?? "");
|
|
3805
4717
|
const [amount, setAmount] = react.useState("");
|
|
3806
4718
|
const selectedToken = enabledTokens.find((t) => t.id === selectedTokenId) ?? defaultToken;
|
|
4719
|
+
const externalDepositAddress = useDepositAddress({
|
|
4720
|
+
enabled: source === "external" && (view === "deposit" || view === "external-deposit")
|
|
4721
|
+
});
|
|
4722
|
+
const externalMinimum = source !== "external" || !selectedToken ? void 0 : externalDepositAddress.isError ? null : externalDepositAddress.response ? getExternalDepositMinimum(externalDepositAddress.response, selectedToken.chainId) ?? null : void 0;
|
|
3807
4723
|
const prevAddressRef = react.useRef(address);
|
|
3808
4724
|
react.useEffect(() => {
|
|
3809
4725
|
const prev = prevAddressRef.current;
|
|
@@ -3823,9 +4739,10 @@ function DepositModalContent({
|
|
|
3823
4739
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
3824
4740
|
const [cancelled, setCancelled] = react.useState(false);
|
|
3825
4741
|
const [isSubmittingLock, setIsSubmittingLock] = react.useState(false);
|
|
3826
|
-
const [
|
|
4742
|
+
const [lockFailure, setLockFailure] = react.useState(null);
|
|
3827
4743
|
const finishDeposit = () => {
|
|
3828
4744
|
setAmount("");
|
|
4745
|
+
if (view === "external-deposit") setView("deposit");
|
|
3829
4746
|
if (onDepositSuccess) {
|
|
3830
4747
|
resetDeposit();
|
|
3831
4748
|
onDepositSuccess();
|
|
@@ -3860,6 +4777,7 @@ function DepositModalContent({
|
|
|
3860
4777
|
},
|
|
3861
4778
|
onLockSubmitted: () => {
|
|
3862
4779
|
setIsSubmittingLock(false);
|
|
4780
|
+
setLockFailure(null);
|
|
3863
4781
|
finishDeposit();
|
|
3864
4782
|
},
|
|
3865
4783
|
// The deposit credited; only the policy lock failed. Success must not
|
|
@@ -3867,7 +4785,7 @@ function DepositModalContent({
|
|
|
3867
4785
|
// error view and let the host re-prompt for a fresh lock.
|
|
3868
4786
|
onLockFailed: (err) => {
|
|
3869
4787
|
setIsSubmittingLock(false);
|
|
3870
|
-
|
|
4788
|
+
setLockFailure(err);
|
|
3871
4789
|
onLockFailed?.(err);
|
|
3872
4790
|
},
|
|
3873
4791
|
onCheckTimeout: () => {
|
|
@@ -3875,7 +4793,37 @@ function DepositModalContent({
|
|
|
3875
4793
|
setShowTimeout(true);
|
|
3876
4794
|
}
|
|
3877
4795
|
});
|
|
3878
|
-
const
|
|
4796
|
+
const externalLock = useExternalDepositLock({
|
|
4797
|
+
allowance,
|
|
4798
|
+
onLockSubmitted: () => {
|
|
4799
|
+
setLockFailure(null);
|
|
4800
|
+
finishDeposit();
|
|
4801
|
+
},
|
|
4802
|
+
// Same contract as the connected flow: the deposit credited, only the
|
|
4803
|
+
// lock failed — never report success, show the lock-error view instead.
|
|
4804
|
+
onLockFailed: (err) => {
|
|
4805
|
+
setLockFailure(err);
|
|
4806
|
+
onLockFailed?.(err);
|
|
4807
|
+
}
|
|
4808
|
+
});
|
|
4809
|
+
react.useEffect(() => {
|
|
4810
|
+
const restored = externalLock.session;
|
|
4811
|
+
if (!restored) return;
|
|
4812
|
+
const canRestore = view === "method" || source === "external" && (view === "deposit" || view === "external-deposit");
|
|
4813
|
+
if (!canRestore) return;
|
|
4814
|
+
const token = getTokenById(restored.tokenId);
|
|
4815
|
+
if (!token) return;
|
|
4816
|
+
setSource("external");
|
|
4817
|
+
setSelectedTokenId(token.id);
|
|
4818
|
+
setAmount(viem.formatUnits(BigInt(restored.depositAmount), token.decimals));
|
|
4819
|
+
setView("external-deposit");
|
|
4820
|
+
}, [externalLock.session, getTokenById, source, view]);
|
|
4821
|
+
react.useEffect(() => {
|
|
4822
|
+
if (view === "external-deposit" && allowance && !externalLock.session) {
|
|
4823
|
+
setView("deposit");
|
|
4824
|
+
}
|
|
4825
|
+
}, [allowance, externalLock.session, view]);
|
|
4826
|
+
const isUnsafeToClose = (isGettingAddress || isSendingTransaction) && !cancelled || externalLock.isSigning || externalLock.isSubmittingLock;
|
|
3879
4827
|
react.useEffect(() => {
|
|
3880
4828
|
onCloseBlockedChange?.(isUnsafeToClose);
|
|
3881
4829
|
}, [isUnsafeToClose, onCloseBlockedChange]);
|
|
@@ -3888,7 +4836,33 @@ function DepositModalContent({
|
|
|
3888
4836
|
}, [depositError, verificationFailed]);
|
|
3889
4837
|
const handleSubmit = (args) => {
|
|
3890
4838
|
if (args.source === "external") {
|
|
3891
|
-
|
|
4839
|
+
const token2 = enabledTokens.find((candidate) => candidate.id === args.tokenId);
|
|
4840
|
+
if (!token2) return;
|
|
4841
|
+
if (token2.contract === viem.zeroAddress) {
|
|
4842
|
+
sonner.toast.error("External deposits support ERC20 tokens only");
|
|
4843
|
+
return;
|
|
4844
|
+
}
|
|
4845
|
+
const depositAmount = chunk7KEQHWZB_cjs.parseTokenAmount(args.amount, token2.decimals);
|
|
4846
|
+
if (!allowance) {
|
|
4847
|
+
setView("external-deposit");
|
|
4848
|
+
return;
|
|
4849
|
+
}
|
|
4850
|
+
if (typeof externalMinimum !== "bigint") {
|
|
4851
|
+
sonner.toast.error("Minimum deposit is unavailable. Please try again.");
|
|
4852
|
+
return;
|
|
4853
|
+
}
|
|
4854
|
+
if (depositAmount < externalMinimum) {
|
|
4855
|
+
sonner.toast.error(
|
|
4856
|
+
`Minimum deposit is ${viem.formatUnits(externalMinimum, token2.decimals)} ${token2.symbol}`
|
|
4857
|
+
);
|
|
4858
|
+
return;
|
|
4859
|
+
}
|
|
4860
|
+
externalLock.signAndPersist({
|
|
4861
|
+
tokenId: token2.id,
|
|
4862
|
+
amount: depositAmount
|
|
4863
|
+
}).then(() => setView("external-deposit")).catch((err) => {
|
|
4864
|
+
sonner.toast.error(err instanceof Error ? err.message : "Policy signing failed");
|
|
4865
|
+
});
|
|
3892
4866
|
return;
|
|
3893
4867
|
}
|
|
3894
4868
|
if (args.source === "credit-card") {
|
|
@@ -3901,7 +4875,7 @@ function DepositModalContent({
|
|
|
3901
4875
|
setCancelled(false);
|
|
3902
4876
|
deposit({
|
|
3903
4877
|
tokenId: token.id,
|
|
3904
|
-
amount:
|
|
4878
|
+
amount: chunk7KEQHWZB_cjs.parseTokenAmount(args.amount, token.decimals),
|
|
3905
4879
|
postDepositLock: allowance ? {
|
|
3906
4880
|
maxAmount: BigInt(allowance.value),
|
|
3907
4881
|
lockDuration: allowance.lockDuration
|
|
@@ -3940,7 +4914,14 @@ function DepositModalContent({
|
|
|
3940
4914
|
}
|
|
3941
4915
|
] : []
|
|
3942
4916
|
];
|
|
3943
|
-
const
|
|
4917
|
+
const hasExternalLockRecovery = view === "external-deposit" && !!externalLock.session?.creditedAmount;
|
|
4918
|
+
const externalSubmissionAmbiguous = hasExternalLockRecovery && !!lockFailure?.submissionMayHaveSucceeded;
|
|
4919
|
+
const savedExternalPayloadUsable = !!externalLock.session?.payload && chunk7KEQHWZB_cjs.isSignedLockUsable(externalLock.session.payload);
|
|
4920
|
+
const ambiguousRecoveryMustBeAbandoned = externalSubmissionAmbiguous && !savedExternalPayloadUsable;
|
|
4921
|
+
const externalRecoveryExitLabel = externalSubmissionAmbiguous ? "Stop recovery" : "Keep funds unlocked";
|
|
4922
|
+
const lockFailureToken = hasExternalLockRecovery && externalLock.session ? getTokenById(externalLock.session.tokenId) ?? selectedToken : selectedToken;
|
|
4923
|
+
const lockFailureMessage = formatPostDepositLockFailure(lockFailure, lockFailureToken);
|
|
4924
|
+
const flowView = showSuccess ? "deposit-success" : lockFailure ? "lock-error" : showTimeout ? "deposit-timeout" : verificationFailed ? "deposit-error" : isPending && !cancelled || isSubmittingLock ? "depositing" : null;
|
|
3944
4925
|
const activeView = flowView ?? view;
|
|
3945
4926
|
const handleDepositDone = () => {
|
|
3946
4927
|
setShowSuccess(false);
|
|
@@ -3953,10 +4934,28 @@ function DepositModalContent({
|
|
|
3953
4934
|
resetDeposit();
|
|
3954
4935
|
};
|
|
3955
4936
|
const handleLockFailedDone = () => {
|
|
3956
|
-
|
|
4937
|
+
if (hasExternalLockRecovery && !externalLock.discardSession()) {
|
|
4938
|
+
sonner.toast.error("Deposit recovery changed in another tab. Please review the current state.");
|
|
4939
|
+
return;
|
|
4940
|
+
}
|
|
4941
|
+
setLockFailure(null);
|
|
3957
4942
|
setAmount("");
|
|
3958
4943
|
setCancelled(false);
|
|
3959
4944
|
resetDeposit();
|
|
4945
|
+
if (view === "external-deposit") setView("deposit");
|
|
4946
|
+
};
|
|
4947
|
+
const handleExternalLockRetry = () => {
|
|
4948
|
+
externalLock.retryAfterCredit().catch((err) => {
|
|
4949
|
+
sonner.toast.error(err instanceof Error ? err.message : "Policy signing failed");
|
|
4950
|
+
});
|
|
4951
|
+
};
|
|
4952
|
+
const handleExternalVerificationDiscard = () => {
|
|
4953
|
+
if (!externalLock.discardSession()) {
|
|
4954
|
+
sonner.toast.error("Deposit recovery changed in another tab. Please review the current state.");
|
|
4955
|
+
return;
|
|
4956
|
+
}
|
|
4957
|
+
setAmount("");
|
|
4958
|
+
setView("deposit");
|
|
3960
4959
|
};
|
|
3961
4960
|
const handleDismissVerificationError = () => {
|
|
3962
4961
|
setAmount("");
|
|
@@ -3969,6 +4968,10 @@ function DepositModalContent({
|
|
|
3969
4968
|
};
|
|
3970
4969
|
const back = view === "external-deposit" ? { to: "deposit", label: "Deposit from External Wallet" } : view === "credit-card-widget" ? { to: "deposit", label: "Buy with credit card and deposit" } : view === "select-token" ? { to: "deposit", label: "Deposit" } : { to: "method", label: "Deposit Method" };
|
|
3971
4970
|
const goBack = () => {
|
|
4971
|
+
if (view === "external-deposit" && externalLock.session) {
|
|
4972
|
+
sonner.toast.error("Cancel the active deposit from the address screen before going back");
|
|
4973
|
+
return;
|
|
4974
|
+
}
|
|
3972
4975
|
if (back.to === "method") {
|
|
3973
4976
|
setAmount("");
|
|
3974
4977
|
setSelectedTokenId("");
|
|
@@ -3983,7 +4986,7 @@ function DepositModalContent({
|
|
|
3983
4986
|
onClick: onClose,
|
|
3984
4987
|
disabled: isUnsafeToClose,
|
|
3985
4988
|
"aria-label": "Close",
|
|
3986
|
-
className:
|
|
4989
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
3987
4990
|
"absolute top-6 right-5 z-20 flex h-5 w-5 items-center justify-center transition-colors",
|
|
3988
4991
|
isUnsafeToClose ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
|
|
3989
4992
|
),
|
|
@@ -4014,9 +5017,14 @@ function DepositModalContent({
|
|
|
4014
5017
|
activeView === "lock-error" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4015
5018
|
TransactionWarningView,
|
|
4016
5019
|
{
|
|
4017
|
-
title: "Deposit credited, lock failed",
|
|
4018
|
-
message: `Your deposit was credited but locking the funds for ${appName} failed: ${
|
|
4019
|
-
onDone: handleLockFailedDone
|
|
5020
|
+
title: externalSubmissionAmbiguous ? "Deposit credited, lock status unknown" : "Deposit credited, lock failed",
|
|
5021
|
+
message: externalSubmissionAmbiguous ? `Your deposit was credited, but the lock for ${appName} may already have succeeded. Retry only the saved signature; if it has expired, check locked funds before stopping recovery.` : `Your deposit was credited but locking the funds for ${appName} failed: ${lockFailureMessage}`,
|
|
5022
|
+
onDone: hasExternalLockRecovery && !ambiguousRecoveryMustBeAbandoned ? handleExternalLockRetry : handleLockFailedDone,
|
|
5023
|
+
actionLabel: hasExternalLockRecovery ? ambiguousRecoveryMustBeAbandoned ? externalRecoveryExitLabel : externalLock.session?.payload ? "Retry lock submission" : "Sign policy and lock funds" : void 0,
|
|
5024
|
+
pendingLabel: externalLock.isSigning ? "Confirm policy in wallet\u2026" : "Locking funds\u2026",
|
|
5025
|
+
isPending: externalLock.isSigning || externalLock.isSubmittingLock,
|
|
5026
|
+
onDismiss: hasExternalLockRecovery && !ambiguousRecoveryMustBeAbandoned ? handleLockFailedDone : void 0,
|
|
5027
|
+
dismissLabel: externalRecoveryExitLabel
|
|
4020
5028
|
}
|
|
4021
5029
|
),
|
|
4022
5030
|
activeView === "deposit-timeout" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4031,7 +5039,7 @@ function DepositModalContent({
|
|
|
4031
5039
|
TransactionErrorView,
|
|
4032
5040
|
{
|
|
4033
5041
|
title: "Verification failed",
|
|
4034
|
-
message: depositError?.message ? `Your transfer was sent on-chain but we could not verify the deposit. The funds are already at the deposit address
|
|
5042
|
+
message: depositError?.message ? `Your transfer was sent on-chain but we could not verify the deposit. The funds are already at the deposit address. Retry verification instead of starting a new deposit. (${depositError.message})` : "Your transfer was sent on-chain but we could not verify the deposit. The funds are already at the deposit address. Retry verification instead of starting a new deposit.",
|
|
4035
5043
|
explorerUrl: explorerTxUrl,
|
|
4036
5044
|
explorerLabel: "View transaction",
|
|
4037
5045
|
onRetry: handleRetryVerification,
|
|
@@ -4041,7 +5049,7 @@ function DepositModalContent({
|
|
|
4041
5049
|
activeView === "depositing" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4042
5050
|
TransactionProgressView,
|
|
4043
5051
|
{
|
|
4044
|
-
title: "Depositing
|
|
5052
|
+
title: "Depositing\u2026",
|
|
4045
5053
|
steps: depositSteps,
|
|
4046
5054
|
onCancel: isGettingAddress || isSendingTransaction ? handleDepositCancel : void 0
|
|
4047
5055
|
}
|
|
@@ -4095,11 +5103,12 @@ function DepositModalContent({
|
|
|
4095
5103
|
selectedToken,
|
|
4096
5104
|
amount,
|
|
4097
5105
|
allowance,
|
|
5106
|
+
externalMinimum,
|
|
4098
5107
|
onAmountChange: setAmount,
|
|
4099
5108
|
onSelectToken: () => setView("select-token"),
|
|
4100
5109
|
onConnectWallet,
|
|
4101
5110
|
onSubmit: handleSubmit,
|
|
4102
|
-
isSubmitting: isPending
|
|
5111
|
+
isSubmitting: isPending || externalLock.isSigning || externalLock.isSubmittingLock
|
|
4103
5112
|
}
|
|
4104
5113
|
) }),
|
|
4105
5114
|
activeView === "select-token" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4112,12 +5121,15 @@ function DepositModalContent({
|
|
|
4112
5121
|
}
|
|
4113
5122
|
}
|
|
4114
5123
|
),
|
|
4115
|
-
activeView === "external-deposit" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5124
|
+
activeView === "external-deposit" && (!allowance || externalLock.session) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4116
5125
|
ExternalDepositView,
|
|
4117
5126
|
{
|
|
4118
5127
|
token: selectedToken,
|
|
4119
5128
|
amount,
|
|
4120
|
-
|
|
5129
|
+
depositAddressState: externalDepositAddress,
|
|
5130
|
+
onCredited: allowance ? void 0 : onDepositSuccess,
|
|
5131
|
+
onDiscardLock: handleExternalVerificationDiscard,
|
|
5132
|
+
lock: externalLock.session ? externalLock : void 0
|
|
4121
5133
|
}
|
|
4122
5134
|
),
|
|
4123
5135
|
activeView === "credit-card-widget" && /* @__PURE__ */ jsxRuntime.jsx(MoonPayGate, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4129,7 +5141,7 @@ function DepositModalContent({
|
|
|
4129
5141
|
onCredited: allowance ? void 0 : finishCardPurchase,
|
|
4130
5142
|
onLockSubmitted: finishCardPurchase,
|
|
4131
5143
|
onLockFailed: (err) => {
|
|
4132
|
-
|
|
5144
|
+
setLockFailure(err);
|
|
4133
5145
|
onLockFailed?.(err);
|
|
4134
5146
|
}
|
|
4135
5147
|
}
|
|
@@ -4182,7 +5194,7 @@ function DepositInlineModal({ className, ...handlers }) {
|
|
|
4182
5194
|
"div",
|
|
4183
5195
|
{
|
|
4184
5196
|
"data-privana": true,
|
|
4185
|
-
className:
|
|
5197
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
4186
5198
|
"bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
4187
5199
|
className
|
|
4188
5200
|
),
|
|
@@ -4197,7 +5209,7 @@ function WithdrawView({
|
|
|
4197
5209
|
onSelectToken,
|
|
4198
5210
|
onPendingChange
|
|
4199
5211
|
}) {
|
|
4200
|
-
const { chains, getChainById: getChainById2 } =
|
|
5212
|
+
const { chains, getChainById: getChainById2 } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
4201
5213
|
const { isConnected, address } = wagmi.useAccount();
|
|
4202
5214
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
4203
5215
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
@@ -4211,7 +5223,7 @@ function WithdrawView({
|
|
|
4211
5223
|
tokenId: selectedToken?.id,
|
|
4212
5224
|
enabled: !!selectedToken
|
|
4213
5225
|
});
|
|
4214
|
-
const formattedBalance = selectedToken ?
|
|
5226
|
+
const formattedBalance = selectedToken ? chunk7KEQHWZB_cjs.formatTokenAmount(balanceWei, selectedToken.decimals) : "0.00";
|
|
4215
5227
|
const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
|
|
4216
5228
|
onProcessingSuccess: () => {
|
|
4217
5229
|
onAmountChange("");
|
|
@@ -4222,7 +5234,7 @@ function WithdrawView({
|
|
|
4222
5234
|
setShowTimeout(true);
|
|
4223
5235
|
}
|
|
4224
5236
|
});
|
|
4225
|
-
const explorerUrl = address && targetChain ?
|
|
5237
|
+
const explorerUrl = address && targetChain ? chunk7KEQHWZB_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
|
|
4226
5238
|
const getStepStatus = (step, after) => {
|
|
4227
5239
|
if (currentStep === step) return "active";
|
|
4228
5240
|
if (after.includes(currentStep)) return "completed";
|
|
@@ -4247,7 +5259,7 @@ function WithdrawView({
|
|
|
4247
5259
|
}, [isPending, cancelled, onPendingChange]);
|
|
4248
5260
|
const hasValidAmount = !!amount && parseFloat(amount) > 0;
|
|
4249
5261
|
const tooManyDecimals = !!hasValidAmount && !!selectedToken && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
4250
|
-
const exceedsBalance = !!hasValidAmount && !tooManyDecimals && !!selectedToken && !isBalanceLoading && !isBalanceError &&
|
|
5262
|
+
const exceedsBalance = !!hasValidAmount && !tooManyDecimals && !!selectedToken && !isBalanceLoading && !isBalanceError && chunk7KEQHWZB_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
|
|
4251
5263
|
const canWithdraw = isConnected && hasValidAmount && !!selectedToken && !tooManyDecimals && !exceedsBalance;
|
|
4252
5264
|
const handleMax = () => {
|
|
4253
5265
|
if (!selectedToken) return;
|
|
@@ -4259,7 +5271,7 @@ function WithdrawView({
|
|
|
4259
5271
|
setCancelled(false);
|
|
4260
5272
|
await withdraw({
|
|
4261
5273
|
tokenId: selectedToken.id,
|
|
4262
|
-
amount:
|
|
5274
|
+
amount: chunk7KEQHWZB_cjs.parseTokenAmount(amount, selectedToken.decimals)
|
|
4263
5275
|
});
|
|
4264
5276
|
};
|
|
4265
5277
|
const handleCancel = () => {
|
|
@@ -4279,7 +5291,7 @@ function WithdrawView({
|
|
|
4279
5291
|
title: "Withdrawal Complete",
|
|
4280
5292
|
message: `Your ${selectedToken.symbol} withdrawal has been processed. Funds should appear in your wallet shortly.`,
|
|
4281
5293
|
explorerUrl,
|
|
4282
|
-
explorerLabel: targetChain ?
|
|
5294
|
+
explorerLabel: targetChain ? chunk7KEQHWZB_cjs.getExplorerLabel(targetChain.id) : void 0,
|
|
4283
5295
|
onDone: handleDone
|
|
4284
5296
|
}
|
|
4285
5297
|
) });
|
|
@@ -4390,7 +5402,7 @@ function WithdrawModalContent({
|
|
|
4390
5402
|
onPendingChange,
|
|
4391
5403
|
onBack
|
|
4392
5404
|
}) {
|
|
4393
|
-
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig } =
|
|
5405
|
+
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
4394
5406
|
const { address } = wagmi.useAccount();
|
|
4395
5407
|
const appName = serviceName ?? "Privana";
|
|
4396
5408
|
const [view, setView] = react.useState("form");
|
|
@@ -4508,7 +5520,7 @@ function WithdrawInlineModal({ className }) {
|
|
|
4508
5520
|
"div",
|
|
4509
5521
|
{
|
|
4510
5522
|
"data-privana": true,
|
|
4511
|
-
className:
|
|
5523
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
4512
5524
|
"bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
4513
5525
|
className
|
|
4514
5526
|
),
|
|
@@ -4552,14 +5564,14 @@ function SegmentedBalanceBar({
|
|
|
4552
5564
|
showAvailable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4553
5565
|
"div",
|
|
4554
5566
|
{
|
|
4555
|
-
className:
|
|
5567
|
+
className: chunk7KEQHWZB_cjs.cn(AVAILABLE_COLOR, "rounded-l-full", !showInUse && "rounded-r-full"),
|
|
4556
5568
|
style: { flexGrow: grow(availableWei) }
|
|
4557
5569
|
}
|
|
4558
5570
|
),
|
|
4559
5571
|
showInUse && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4560
5572
|
"div",
|
|
4561
5573
|
{
|
|
4562
|
-
className:
|
|
5574
|
+
className: chunk7KEQHWZB_cjs.cn(IN_USE_COLOR, "rounded-r-full", !showAvailable && "rounded-l-full"),
|
|
4563
5575
|
style: { flexGrow: grow(inUseWei) }
|
|
4564
5576
|
}
|
|
4565
5577
|
)
|
|
@@ -4567,7 +5579,7 @@ function SegmentedBalanceBar({
|
|
|
4567
5579
|
}
|
|
4568
5580
|
function BalanceLegendItem({ color, label }) {
|
|
4569
5581
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
4570
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className:
|
|
5582
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: chunk7KEQHWZB_cjs.cn("h-2.5 w-2.5 rounded-full", color) }),
|
|
4571
5583
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-sm leading-5", children: label })
|
|
4572
5584
|
] });
|
|
4573
5585
|
}
|
|
@@ -4580,7 +5592,7 @@ function WalletBalanceView({
|
|
|
4580
5592
|
onAddFunds,
|
|
4581
5593
|
onWithdraw
|
|
4582
5594
|
}) {
|
|
4583
|
-
const { serviceName, serviceIcon, defaultToken } =
|
|
5595
|
+
const { serviceName, serviceIcon, defaultToken } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
4584
5596
|
const appName = serviceName ?? "Privana";
|
|
4585
5597
|
const token = defaultToken;
|
|
4586
5598
|
const {
|
|
@@ -4593,14 +5605,14 @@ function WalletBalanceView({
|
|
|
4593
5605
|
const variant = !session ? "idle" : inUseWei === 0n ? "session-zero" : availableWei === 0n ? "fully-in-use" : "mixed";
|
|
4594
5606
|
const expiry = session?.expiry;
|
|
4595
5607
|
useNow(3e4, expiry != null);
|
|
4596
|
-
const countdown = expiry != null ?
|
|
5608
|
+
const countdown = expiry != null ? chunk7KEQHWZB_cjs.formatTimeRemaining(expiry) : null;
|
|
4597
5609
|
const decimals = token?.decimals ?? 18;
|
|
4598
|
-
const totalFormatted =
|
|
4599
|
-
const availableFormatted =
|
|
4600
|
-
const inUseFormatted =
|
|
5610
|
+
const totalFormatted = chunk7KEQHWZB_cjs.formatTokenAmount((availableWei + inUseWei).toString(), decimals);
|
|
5611
|
+
const availableFormatted = chunk7KEQHWZB_cjs.formatTokenAmount(availableWei.toString(), decimals);
|
|
5612
|
+
const inUseFormatted = chunk7KEQHWZB_cjs.formatTokenAmount(inUseWei.toString(), decimals);
|
|
4601
5613
|
const hasValidAmount = !!amount && parseFloat(amount) > 0;
|
|
4602
5614
|
const tooManyDecimals = hasValidAmount && !!token && amount.includes(".") && amount.split(".")[1].length > token.decimals;
|
|
4603
|
-
const exceedsBalance = hasValidAmount && !tooManyDecimals && !!token && !isBalanceLoading && !isBalanceError &&
|
|
5615
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && !!token && !isBalanceLoading && !isBalanceError && chunk7KEQHWZB_cjs.parseTokenAmount(amount, token.decimals) > availableWei;
|
|
4604
5616
|
const canFundSession = hasValidAmount && !!token && !tooManyDecimals && !exceedsBalance && !isBalanceLoading && !isBalanceError;
|
|
4605
5617
|
const handleMax = () => {
|
|
4606
5618
|
const max = availableFormatted.replace(/\s/g, "");
|
|
@@ -4618,7 +5630,7 @@ function WalletBalanceView({
|
|
|
4618
5630
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm leading-[14px]", children: "Total" }),
|
|
4619
5631
|
/* @__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" })
|
|
4620
5632
|
] }),
|
|
4621
|
-
isBalanceLoading ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5633
|
+
isBalanceLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunk7KEQHWZB_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 })
|
|
4622
5634
|
] }),
|
|
4623
5635
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
4624
5636
|
/* @__PURE__ */ jsxRuntime.jsx(SegmentedBalanceBar, { availableWei, inUseWei }),
|
|
@@ -4768,7 +5780,7 @@ function WalletModalContent({
|
|
|
4768
5780
|
onCloseBlockedChange,
|
|
4769
5781
|
...depositHandlers
|
|
4770
5782
|
}) {
|
|
4771
|
-
const { serviceName, hostedAuthConfig } =
|
|
5783
|
+
const { serviceName, hostedAuthConfig } = chunk7KEQHWZB_cjs.usePrivanaContext();
|
|
4772
5784
|
const { address } = wagmi.useAccount();
|
|
4773
5785
|
const appName = serviceName ?? "Privana";
|
|
4774
5786
|
const [view, setView] = react.useState("balance");
|
|
@@ -4872,7 +5884,7 @@ function WalletModalContent({
|
|
|
4872
5884
|
onClick: onClose,
|
|
4873
5885
|
disabled: closeBlocked,
|
|
4874
5886
|
"aria-label": "Close",
|
|
4875
|
-
className:
|
|
5887
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
4876
5888
|
"absolute top-6 right-5 z-20 flex h-5 w-5 items-center justify-center transition-colors",
|
|
4877
5889
|
closeBlocked ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
|
|
4878
5890
|
),
|
|
@@ -4889,7 +5901,7 @@ function WalletModalContent({
|
|
|
4889
5901
|
onAmountChange: setAmount,
|
|
4890
5902
|
onFundSession: onFundSession ? fundSession : void 0,
|
|
4891
5903
|
onAddFunds: () => setView("deposit"),
|
|
4892
|
-
onWithdraw: handleWithdraw
|
|
5904
|
+
onWithdraw: session && !onEndSession ? void 0 : handleWithdraw
|
|
4893
5905
|
}
|
|
4894
5906
|
),
|
|
4895
5907
|
view === "funding-session" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4990,7 +6002,7 @@ function WalletInlineModal({ className, ...handlers }) {
|
|
|
4990
6002
|
"div",
|
|
4991
6003
|
{
|
|
4992
6004
|
"data-privana": true,
|
|
4993
|
-
className:
|
|
6005
|
+
className: chunk7KEQHWZB_cjs.cn(
|
|
4994
6006
|
"bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
4995
6007
|
className
|
|
4996
6008
|
),
|
|
@@ -5001,287 +6013,295 @@ function WalletInlineModal({ className, ...handlers }) {
|
|
|
5001
6013
|
|
|
5002
6014
|
Object.defineProperty(exports, "AccountingApiError", {
|
|
5003
6015
|
enumerable: true,
|
|
5004
|
-
get: function () { return
|
|
6016
|
+
get: function () { return chunk7KEQHWZB_cjs.AccountingApiError; }
|
|
5005
6017
|
});
|
|
5006
6018
|
Object.defineProperty(exports, "Button", {
|
|
5007
6019
|
enumerable: true,
|
|
5008
|
-
get: function () { return
|
|
6020
|
+
get: function () { return chunk7KEQHWZB_cjs.Button; }
|
|
5009
6021
|
});
|
|
5010
6022
|
Object.defineProperty(exports, "DEFAULT_LOCK_DURATION_SECONDS", {
|
|
5011
6023
|
enumerable: true,
|
|
5012
|
-
get: function () { return
|
|
6024
|
+
get: function () { return chunk7KEQHWZB_cjs.DEFAULT_LOCK_DURATION_SECONDS; }
|
|
5013
6025
|
});
|
|
5014
6026
|
Object.defineProperty(exports, "DEFAULT_ONRAMP_LOCK_BUFFER", {
|
|
5015
6027
|
enumerable: true,
|
|
5016
|
-
get: function () { return
|
|
6028
|
+
get: function () { return chunk7KEQHWZB_cjs.DEFAULT_ONRAMP_LOCK_BUFFER; }
|
|
5017
6029
|
});
|
|
5018
6030
|
Object.defineProperty(exports, "HOSTED_AUTH_CLOCK_SKEW_MS", {
|
|
5019
6031
|
enumerable: true,
|
|
5020
|
-
get: function () { return
|
|
6032
|
+
get: function () { return chunk7KEQHWZB_cjs.HOSTED_AUTH_CLOCK_SKEW_MS; }
|
|
5021
6033
|
});
|
|
5022
6034
|
Object.defineProperty(exports, "HostedAuthError", {
|
|
5023
6035
|
enumerable: true,
|
|
5024
|
-
get: function () { return
|
|
6036
|
+
get: function () { return chunk7KEQHWZB_cjs.HostedAuthError; }
|
|
5025
6037
|
});
|
|
5026
6038
|
Object.defineProperty(exports, "HostedAuthRequiredError", {
|
|
5027
6039
|
enumerable: true,
|
|
5028
|
-
get: function () { return
|
|
6040
|
+
get: function () { return chunk7KEQHWZB_cjs.HostedAuthRequiredError; }
|
|
5029
6041
|
});
|
|
5030
6042
|
Object.defineProperty(exports, "HostedAuthStateMismatchError", {
|
|
5031
6043
|
enumerable: true,
|
|
5032
|
-
get: function () { return
|
|
6044
|
+
get: function () { return chunk7KEQHWZB_cjs.HostedAuthStateMismatchError; }
|
|
5033
6045
|
});
|
|
5034
6046
|
Object.defineProperty(exports, "HttpClient", {
|
|
5035
6047
|
enumerable: true,
|
|
5036
|
-
get: function () { return
|
|
6048
|
+
get: function () { return chunk7KEQHWZB_cjs.HttpClient; }
|
|
5037
6049
|
});
|
|
5038
6050
|
Object.defineProperty(exports, "LOCK_TYPES", {
|
|
5039
6051
|
enumerable: true,
|
|
5040
|
-
get: function () { return
|
|
6052
|
+
get: function () { return chunk7KEQHWZB_cjs.LOCK_TYPES; }
|
|
5041
6053
|
});
|
|
5042
6054
|
Object.defineProperty(exports, "MODIFY_LOCK_TYPES", {
|
|
5043
6055
|
enumerable: true,
|
|
5044
|
-
get: function () { return
|
|
6056
|
+
get: function () { return chunk7KEQHWZB_cjs.MODIFY_LOCK_TYPES; }
|
|
5045
6057
|
});
|
|
5046
6058
|
Object.defineProperty(exports, "NETWORK_CONFIG", {
|
|
5047
6059
|
enumerable: true,
|
|
5048
|
-
get: function () { return
|
|
6060
|
+
get: function () { return chunk7KEQHWZB_cjs.NETWORK_CONFIG; }
|
|
5049
6061
|
});
|
|
5050
6062
|
Object.defineProperty(exports, "NetworkError", {
|
|
5051
6063
|
enumerable: true,
|
|
5052
|
-
get: function () { return
|
|
6064
|
+
get: function () { return chunk7KEQHWZB_cjs.NetworkError; }
|
|
5053
6065
|
});
|
|
5054
6066
|
Object.defineProperty(exports, "PostDepositLockError", {
|
|
5055
6067
|
enumerable: true,
|
|
5056
|
-
get: function () { return
|
|
6068
|
+
get: function () { return chunk7KEQHWZB_cjs.PostDepositLockError; }
|
|
5057
6069
|
});
|
|
5058
6070
|
Object.defineProperty(exports, "PrivanaClient", {
|
|
5059
6071
|
enumerable: true,
|
|
5060
|
-
get: function () { return
|
|
6072
|
+
get: function () { return chunk7KEQHWZB_cjs.PrivanaClient; }
|
|
5061
6073
|
});
|
|
5062
6074
|
Object.defineProperty(exports, "PrivanaProvider", {
|
|
5063
6075
|
enumerable: true,
|
|
5064
|
-
get: function () { return
|
|
6076
|
+
get: function () { return chunk7KEQHWZB_cjs.PrivanaProvider; }
|
|
5065
6077
|
});
|
|
5066
6078
|
Object.defineProperty(exports, "SUPPORTED_CHAINS", {
|
|
5067
6079
|
enumerable: true,
|
|
5068
|
-
get: function () { return
|
|
6080
|
+
get: function () { return chunk7KEQHWZB_cjs.SUPPORTED_CHAINS; }
|
|
5069
6081
|
});
|
|
5070
6082
|
Object.defineProperty(exports, "SiweAuthProvider", {
|
|
5071
6083
|
enumerable: true,
|
|
5072
|
-
get: function () { return
|
|
6084
|
+
get: function () { return chunk7KEQHWZB_cjs.SiweAuthProvider; }
|
|
5073
6085
|
});
|
|
5074
6086
|
Object.defineProperty(exports, "Skeleton", {
|
|
5075
6087
|
enumerable: true,
|
|
5076
|
-
get: function () { return
|
|
6088
|
+
get: function () { return chunk7KEQHWZB_cjs.Skeleton; }
|
|
5077
6089
|
});
|
|
5078
6090
|
Object.defineProperty(exports, "TRANSFER_LOCKED_TYPES", {
|
|
5079
6091
|
enumerable: true,
|
|
5080
|
-
get: function () { return
|
|
6092
|
+
get: function () { return chunk7KEQHWZB_cjs.TRANSFER_LOCKED_TYPES; }
|
|
5081
6093
|
});
|
|
5082
6094
|
Object.defineProperty(exports, "TRANSFER_TYPES", {
|
|
5083
6095
|
enumerable: true,
|
|
5084
|
-
get: function () { return
|
|
6096
|
+
get: function () { return chunk7KEQHWZB_cjs.TRANSFER_TYPES; }
|
|
5085
6097
|
});
|
|
5086
6098
|
Object.defineProperty(exports, "ValidationError", {
|
|
5087
6099
|
enumerable: true,
|
|
5088
|
-
get: function () { return
|
|
6100
|
+
get: function () { return chunk7KEQHWZB_cjs.ValidationError; }
|
|
5089
6101
|
});
|
|
5090
6102
|
Object.defineProperty(exports, "WITHDRAW_FROM_LOCK_TYPES", {
|
|
5091
6103
|
enumerable: true,
|
|
5092
|
-
get: function () { return
|
|
6104
|
+
get: function () { return chunk7KEQHWZB_cjs.WITHDRAW_FROM_LOCK_TYPES; }
|
|
5093
6105
|
});
|
|
5094
6106
|
Object.defineProperty(exports, "WITHDRAW_TYPES", {
|
|
5095
6107
|
enumerable: true,
|
|
5096
|
-
get: function () { return
|
|
6108
|
+
get: function () { return chunk7KEQHWZB_cjs.WITHDRAW_TYPES; }
|
|
5097
6109
|
});
|
|
5098
6110
|
Object.defineProperty(exports, "applyLockBuffer", {
|
|
5099
6111
|
enumerable: true,
|
|
5100
|
-
get: function () { return
|
|
6112
|
+
get: function () { return chunk7KEQHWZB_cjs.applyLockBuffer; }
|
|
5101
6113
|
});
|
|
5102
6114
|
Object.defineProperty(exports, "applyRefreshResponse", {
|
|
5103
6115
|
enumerable: true,
|
|
5104
|
-
get: function () { return
|
|
6116
|
+
get: function () { return chunk7KEQHWZB_cjs.applyRefreshResponse; }
|
|
5105
6117
|
});
|
|
5106
6118
|
Object.defineProperty(exports, "buildHostedAuthSession", {
|
|
5107
6119
|
enumerable: true,
|
|
5108
|
-
get: function () { return
|
|
6120
|
+
get: function () { return chunk7KEQHWZB_cjs.buildHostedAuthSession; }
|
|
5109
6121
|
});
|
|
5110
6122
|
Object.defineProperty(exports, "buildSiweStatement", {
|
|
5111
6123
|
enumerable: true,
|
|
5112
|
-
get: function () { return
|
|
6124
|
+
get: function () { return chunk7KEQHWZB_cjs.buildSiweStatement; }
|
|
5113
6125
|
});
|
|
5114
6126
|
Object.defineProperty(exports, "buttonVariants", {
|
|
5115
6127
|
enumerable: true,
|
|
5116
|
-
get: function () { return
|
|
6128
|
+
get: function () { return chunk7KEQHWZB_cjs.buttonVariants; }
|
|
5117
6129
|
});
|
|
5118
6130
|
Object.defineProperty(exports, "clampLockAmount", {
|
|
5119
6131
|
enumerable: true,
|
|
5120
|
-
get: function () { return
|
|
6132
|
+
get: function () { return chunk7KEQHWZB_cjs.clampLockAmount; }
|
|
5121
6133
|
});
|
|
5122
6134
|
Object.defineProperty(exports, "clearHostedAuthPendingTransaction", {
|
|
5123
6135
|
enumerable: true,
|
|
5124
|
-
get: function () { return
|
|
6136
|
+
get: function () { return chunk7KEQHWZB_cjs.clearHostedAuthPendingTransaction; }
|
|
5125
6137
|
});
|
|
5126
6138
|
Object.defineProperty(exports, "clearPendingLock", {
|
|
5127
6139
|
enumerable: true,
|
|
5128
|
-
get: function () { return
|
|
6140
|
+
get: function () { return chunk7KEQHWZB_cjs.clearPendingLock; }
|
|
5129
6141
|
});
|
|
5130
6142
|
Object.defineProperty(exports, "createDomain", {
|
|
5131
6143
|
enumerable: true,
|
|
5132
|
-
get: function () { return
|
|
6144
|
+
get: function () { return chunk7KEQHWZB_cjs.createDomain; }
|
|
5133
6145
|
});
|
|
5134
6146
|
Object.defineProperty(exports, "createHostedAuthPendingStorageKey", {
|
|
5135
6147
|
enumerable: true,
|
|
5136
|
-
get: function () { return
|
|
6148
|
+
get: function () { return chunk7KEQHWZB_cjs.createHostedAuthPendingStorageKey; }
|
|
5137
6149
|
});
|
|
5138
6150
|
Object.defineProperty(exports, "createHostedAuthState", {
|
|
5139
6151
|
enumerable: true,
|
|
5140
|
-
get: function () { return
|
|
6152
|
+
get: function () { return chunk7KEQHWZB_cjs.createHostedAuthState; }
|
|
5141
6153
|
});
|
|
5142
6154
|
Object.defineProperty(exports, "createHostedAuthStorageKey", {
|
|
5143
6155
|
enumerable: true,
|
|
5144
|
-
get: function () { return
|
|
6156
|
+
get: function () { return chunk7KEQHWZB_cjs.createHostedAuthStorageKey; }
|
|
5145
6157
|
});
|
|
5146
6158
|
Object.defineProperty(exports, "createLockExpiry", {
|
|
5147
6159
|
enumerable: true,
|
|
5148
|
-
get: function () { return
|
|
6160
|
+
get: function () { return chunk7KEQHWZB_cjs.createLockExpiry; }
|
|
5149
6161
|
});
|
|
5150
6162
|
Object.defineProperty(exports, "createPkceChallenge", {
|
|
5151
6163
|
enumerable: true,
|
|
5152
|
-
get: function () { return
|
|
6164
|
+
get: function () { return chunk7KEQHWZB_cjs.createPkceChallenge; }
|
|
5153
6165
|
});
|
|
5154
6166
|
Object.defineProperty(exports, "createPkceVerifier", {
|
|
5155
6167
|
enumerable: true,
|
|
5156
|
-
get: function () { return
|
|
6168
|
+
get: function () { return chunk7KEQHWZB_cjs.createPkceVerifier; }
|
|
5157
6169
|
});
|
|
5158
6170
|
Object.defineProperty(exports, "createSignedLockRequest", {
|
|
5159
6171
|
enumerable: true,
|
|
5160
|
-
get: function () { return
|
|
6172
|
+
get: function () { return chunk7KEQHWZB_cjs.createSignedLockRequest; }
|
|
5161
6173
|
});
|
|
5162
6174
|
Object.defineProperty(exports, "getAccountingContract", {
|
|
5163
6175
|
enumerable: true,
|
|
5164
|
-
get: function () { return
|
|
6176
|
+
get: function () { return chunk7KEQHWZB_cjs.getAccountingContract; }
|
|
5165
6177
|
});
|
|
5166
6178
|
Object.defineProperty(exports, "getApiUrl", {
|
|
5167
6179
|
enumerable: true,
|
|
5168
|
-
get: function () { return
|
|
6180
|
+
get: function () { return chunk7KEQHWZB_cjs.getApiUrl; }
|
|
5169
6181
|
});
|
|
5170
6182
|
Object.defineProperty(exports, "getChainById", {
|
|
5171
6183
|
enumerable: true,
|
|
5172
|
-
get: function () { return
|
|
6184
|
+
get: function () { return chunk7KEQHWZB_cjs.getChainById; }
|
|
5173
6185
|
});
|
|
5174
6186
|
Object.defineProperty(exports, "getChainId", {
|
|
5175
6187
|
enumerable: true,
|
|
5176
|
-
get: function () { return
|
|
6188
|
+
get: function () { return chunk7KEQHWZB_cjs.getChainId; }
|
|
5177
6189
|
});
|
|
5178
6190
|
Object.defineProperty(exports, "getExplorerAddressUrl", {
|
|
5179
6191
|
enumerable: true,
|
|
5180
|
-
get: function () { return
|
|
6192
|
+
get: function () { return chunk7KEQHWZB_cjs.getExplorerAddressUrl; }
|
|
5181
6193
|
});
|
|
5182
6194
|
Object.defineProperty(exports, "getExplorerLabel", {
|
|
5183
6195
|
enumerable: true,
|
|
5184
|
-
get: function () { return
|
|
6196
|
+
get: function () { return chunk7KEQHWZB_cjs.getExplorerLabel; }
|
|
5185
6197
|
});
|
|
5186
6198
|
Object.defineProperty(exports, "isHostedAuthRefreshActive", {
|
|
5187
6199
|
enumerable: true,
|
|
5188
|
-
get: function () { return
|
|
6200
|
+
get: function () { return chunk7KEQHWZB_cjs.isHostedAuthRefreshActive; }
|
|
5189
6201
|
});
|
|
5190
6202
|
Object.defineProperty(exports, "isHostedAuthSessionActive", {
|
|
5191
6203
|
enumerable: true,
|
|
5192
|
-
get: function () { return
|
|
6204
|
+
get: function () { return chunk7KEQHWZB_cjs.isHostedAuthSessionActive; }
|
|
5193
6205
|
});
|
|
5194
6206
|
Object.defineProperty(exports, "isSignedLockUsable", {
|
|
5195
6207
|
enumerable: true,
|
|
5196
|
-
get: function () { return
|
|
6208
|
+
get: function () { return chunk7KEQHWZB_cjs.isSignedLockUsable; }
|
|
5197
6209
|
});
|
|
5198
6210
|
Object.defineProperty(exports, "loadPendingLock", {
|
|
5199
6211
|
enumerable: true,
|
|
5200
|
-
get: function () { return
|
|
6212
|
+
get: function () { return chunk7KEQHWZB_cjs.loadPendingLock; }
|
|
5201
6213
|
});
|
|
5202
6214
|
Object.defineProperty(exports, "normalizeAddress", {
|
|
5203
6215
|
enumerable: true,
|
|
5204
|
-
get: function () { return
|
|
6216
|
+
get: function () { return chunk7KEQHWZB_cjs.normalizeAddress; }
|
|
5205
6217
|
});
|
|
5206
6218
|
Object.defineProperty(exports, "normalizeHex", {
|
|
5207
6219
|
enumerable: true,
|
|
5208
|
-
get: function () { return
|
|
6220
|
+
get: function () { return chunk7KEQHWZB_cjs.normalizeHex; }
|
|
5209
6221
|
});
|
|
5210
6222
|
Object.defineProperty(exports, "parseHostedAuthCallback", {
|
|
5211
6223
|
enumerable: true,
|
|
5212
|
-
get: function () { return
|
|
6224
|
+
get: function () { return chunk7KEQHWZB_cjs.parseHostedAuthCallback; }
|
|
5213
6225
|
});
|
|
5214
6226
|
Object.defineProperty(exports, "persistHostedAuthPendingTransaction", {
|
|
5215
6227
|
enumerable: true,
|
|
5216
|
-
get: function () { return
|
|
6228
|
+
get: function () { return chunk7KEQHWZB_cjs.persistHostedAuthPendingTransaction; }
|
|
5217
6229
|
});
|
|
5218
6230
|
Object.defineProperty(exports, "readHostedAuthPendingTransaction", {
|
|
5219
6231
|
enumerable: true,
|
|
5220
|
-
get: function () { return
|
|
6232
|
+
get: function () { return chunk7KEQHWZB_cjs.readHostedAuthPendingTransaction; }
|
|
5221
6233
|
});
|
|
5222
6234
|
Object.defineProperty(exports, "readStoredHostedAuthSession", {
|
|
5223
6235
|
enumerable: true,
|
|
5224
|
-
get: function () { return
|
|
6236
|
+
get: function () { return chunk7KEQHWZB_cjs.readStoredHostedAuthSession; }
|
|
6237
|
+
});
|
|
6238
|
+
Object.defineProperty(exports, "requireDepositLockOwner", {
|
|
6239
|
+
enumerable: true,
|
|
6240
|
+
get: function () { return chunk7KEQHWZB_cjs.requireDepositLockOwner; }
|
|
6241
|
+
});
|
|
6242
|
+
Object.defineProperty(exports, "requireServiceAddress", {
|
|
6243
|
+
enumerable: true,
|
|
6244
|
+
get: function () { return chunk7KEQHWZB_cjs.requireServiceAddress; }
|
|
5225
6245
|
});
|
|
5226
6246
|
Object.defineProperty(exports, "savePendingLock", {
|
|
5227
6247
|
enumerable: true,
|
|
5228
|
-
get: function () { return
|
|
6248
|
+
get: function () { return chunk7KEQHWZB_cjs.savePendingLock; }
|
|
5229
6249
|
});
|
|
5230
6250
|
Object.defineProperty(exports, "signLockMessage", {
|
|
5231
6251
|
enumerable: true,
|
|
5232
|
-
get: function () { return
|
|
6252
|
+
get: function () { return chunk7KEQHWZB_cjs.signLockMessage; }
|
|
5233
6253
|
});
|
|
5234
6254
|
Object.defineProperty(exports, "signModifyLockMessage", {
|
|
5235
6255
|
enumerable: true,
|
|
5236
|
-
get: function () { return
|
|
6256
|
+
get: function () { return chunk7KEQHWZB_cjs.signModifyLockMessage; }
|
|
5237
6257
|
});
|
|
5238
6258
|
Object.defineProperty(exports, "signTransferLockedMessage", {
|
|
5239
6259
|
enumerable: true,
|
|
5240
|
-
get: function () { return
|
|
6260
|
+
get: function () { return chunk7KEQHWZB_cjs.signTransferLockedMessage; }
|
|
5241
6261
|
});
|
|
5242
6262
|
Object.defineProperty(exports, "signTransferMessage", {
|
|
5243
6263
|
enumerable: true,
|
|
5244
|
-
get: function () { return
|
|
6264
|
+
get: function () { return chunk7KEQHWZB_cjs.signTransferMessage; }
|
|
5245
6265
|
});
|
|
5246
6266
|
Object.defineProperty(exports, "signWithdrawFromLockMessage", {
|
|
5247
6267
|
enumerable: true,
|
|
5248
|
-
get: function () { return
|
|
6268
|
+
get: function () { return chunk7KEQHWZB_cjs.signWithdrawFromLockMessage; }
|
|
5249
6269
|
});
|
|
5250
6270
|
Object.defineProperty(exports, "signWithdrawMessage", {
|
|
5251
6271
|
enumerable: true,
|
|
5252
|
-
get: function () { return
|
|
6272
|
+
get: function () { return chunk7KEQHWZB_cjs.signWithdrawMessage; }
|
|
5253
6273
|
});
|
|
5254
6274
|
Object.defineProperty(exports, "stripHostedAuthCallbackParams", {
|
|
5255
6275
|
enumerable: true,
|
|
5256
|
-
get: function () { return
|
|
6276
|
+
get: function () { return chunk7KEQHWZB_cjs.stripHostedAuthCallbackParams; }
|
|
5257
6277
|
});
|
|
5258
6278
|
Object.defineProperty(exports, "submitPendingLock", {
|
|
5259
6279
|
enumerable: true,
|
|
5260
|
-
get: function () { return
|
|
6280
|
+
get: function () { return chunk7KEQHWZB_cjs.submitPendingLock; }
|
|
5261
6281
|
});
|
|
5262
6282
|
Object.defineProperty(exports, "syncHostedAuthSessionToClient", {
|
|
5263
6283
|
enumerable: true,
|
|
5264
|
-
get: function () { return
|
|
6284
|
+
get: function () { return chunk7KEQHWZB_cjs.syncHostedAuthSessionToClient; }
|
|
5265
6285
|
});
|
|
5266
6286
|
Object.defineProperty(exports, "useDepositVerification", {
|
|
5267
6287
|
enumerable: true,
|
|
5268
|
-
get: function () { return
|
|
6288
|
+
get: function () { return chunk7KEQHWZB_cjs.useDepositVerification; }
|
|
5269
6289
|
});
|
|
5270
6290
|
Object.defineProperty(exports, "usePrivanaContext", {
|
|
5271
6291
|
enumerable: true,
|
|
5272
|
-
get: function () { return
|
|
6292
|
+
get: function () { return chunk7KEQHWZB_cjs.usePrivanaContext; }
|
|
5273
6293
|
});
|
|
5274
6294
|
Object.defineProperty(exports, "useSafeAccount", {
|
|
5275
6295
|
enumerable: true,
|
|
5276
|
-
get: function () { return
|
|
6296
|
+
get: function () { return chunk7KEQHWZB_cjs.useSafeAccount; }
|
|
5277
6297
|
});
|
|
5278
6298
|
Object.defineProperty(exports, "useSafePrivanaContext", {
|
|
5279
6299
|
enumerable: true,
|
|
5280
|
-
get: function () { return
|
|
6300
|
+
get: function () { return chunk7KEQHWZB_cjs.useSafePrivanaContext; }
|
|
5281
6301
|
});
|
|
5282
6302
|
Object.defineProperty(exports, "useSiweAuth", {
|
|
5283
6303
|
enumerable: true,
|
|
5284
|
-
get: function () { return
|
|
6304
|
+
get: function () { return chunk7KEQHWZB_cjs.useSiweAuth; }
|
|
5285
6305
|
});
|
|
5286
6306
|
exports.DepositInlineModal = DepositInlineModal;
|
|
5287
6307
|
exports.DepositModal = DepositModal;
|