@oasisprotocol/privana-sdk 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-2AHJHISR.js → chunk-54FC6TO3.js} +1145 -26
- package/dist/chunk-54FC6TO3.js.map +1 -0
- package/dist/{chunk-EEAQ2NWF.cjs → chunk-ACLJPC75.cjs} +1145 -22
- package/dist/chunk-ACLJPC75.cjs.map +1 -0
- package/dist/index.cjs +2003 -312
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +137 -9
- package/dist/index.d.ts +137 -9
- package/dist/index.js +1758 -83
- package/dist/index.js.map +1 -1
- package/dist/{on-ramp-CdXqJjmm.d.cts → on-ramp-XLXsy0aI.d.cts} +15 -0
- package/dist/{on-ramp-CdXqJjmm.d.ts → on-ramp-XLXsy0aI.d.ts} +15 -0
- package/dist/on-ramp.cjs +10 -974
- package/dist/on-ramp.cjs.map +1 -1
- package/dist/on-ramp.d.cts +13 -3
- package/dist/on-ramp.d.ts +13 -3
- package/dist/on-ramp.js +1 -975
- package/dist/on-ramp.js.map +1 -1
- package/package.json +3 -2
- package/dist/chunk-2AHJHISR.js.map +0 -1
- package/dist/chunk-EEAQ2NWF.cjs.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 chunkACLJPC75_cjs = require('./chunk-ACLJPC75.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var reactQuery = require('@tanstack/react-query');
|
|
7
7
|
var wagmi = require('wagmi');
|
|
@@ -10,6 +10,8 @@ var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
|
10
10
|
var lucideReact = require('lucide-react');
|
|
11
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
12
|
var sonner = require('sonner');
|
|
13
|
+
var qrcode_react = require('qrcode.react');
|
|
14
|
+
var moonpayReact = require('@moonpay/moonpay-react');
|
|
13
15
|
|
|
14
16
|
function _interopNamespace(e) {
|
|
15
17
|
if (e && e.__esModule) return e;
|
|
@@ -229,18 +231,18 @@ async function signWithdrawFromLockMessage({
|
|
|
229
231
|
|
|
230
232
|
// src/sdk/hooks/use-privana-client.ts
|
|
231
233
|
function usePrivanaClient() {
|
|
232
|
-
const { client } =
|
|
234
|
+
const { client } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
233
235
|
return client;
|
|
234
236
|
}
|
|
235
237
|
var hostedAuthExchangeInflight = /* @__PURE__ */ new Map();
|
|
236
238
|
function normalizeHostedAuthError(error) {
|
|
237
|
-
if (error instanceof
|
|
238
|
-
return new
|
|
239
|
+
if (error instanceof chunkACLJPC75_cjs.AccountingApiError && error.detail) {
|
|
240
|
+
return new chunkACLJPC75_cjs.HostedAuthError(error.detail);
|
|
239
241
|
}
|
|
240
242
|
if (error instanceof Error) {
|
|
241
243
|
return error;
|
|
242
244
|
}
|
|
243
|
-
return new
|
|
245
|
+
return new chunkACLJPC75_cjs.HostedAuthError("Hosted authentication failed.");
|
|
244
246
|
}
|
|
245
247
|
function useHostedRedirectAuth() {
|
|
246
248
|
const {
|
|
@@ -251,30 +253,30 @@ function useHostedRedirectAuth() {
|
|
|
251
253
|
setHostedAuthSession,
|
|
252
254
|
clearHostedAuthSession,
|
|
253
255
|
refreshHostedAuthSession
|
|
254
|
-
} =
|
|
256
|
+
} = chunkACLJPC75_cjs.usePrivanaContext();
|
|
255
257
|
const [error, setError] = react.useState(null);
|
|
256
258
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
257
259
|
const loginInflight = react.useRef(null);
|
|
258
260
|
const completionInflight = react.useRef(null);
|
|
259
261
|
const pendingStorageKey = react.useMemo(
|
|
260
|
-
() => hostedAuthConfig ?
|
|
262
|
+
() => hostedAuthConfig ? chunkACLJPC75_cjs.createHostedAuthPendingStorageKey(client.getBaseUrl(), hostedAuthConfig) : null,
|
|
261
263
|
[client, hostedAuthConfig]
|
|
262
264
|
);
|
|
263
265
|
const clearPendingLogin = react.useCallback(() => {
|
|
264
266
|
if (!pendingStorageKey || typeof window === "undefined") return;
|
|
265
|
-
|
|
267
|
+
chunkACLJPC75_cjs.clearHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
|
|
266
268
|
}, [pendingStorageKey]);
|
|
267
269
|
const login = react.useCallback(async () => {
|
|
268
270
|
if (!hostedAuthConfig) {
|
|
269
|
-
throw new
|
|
271
|
+
throw new chunkACLJPC75_cjs.HostedAuthRequiredError(
|
|
270
272
|
"Hosted redirect authentication is not configured for this provider."
|
|
271
273
|
);
|
|
272
274
|
}
|
|
273
275
|
if (typeof window === "undefined") {
|
|
274
|
-
throw new
|
|
276
|
+
throw new chunkACLJPC75_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
|
|
275
277
|
}
|
|
276
278
|
if (!pendingStorageKey) {
|
|
277
|
-
throw new
|
|
279
|
+
throw new chunkACLJPC75_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
|
|
278
280
|
}
|
|
279
281
|
if (loginInflight.current) {
|
|
280
282
|
return loginInflight.current;
|
|
@@ -283,10 +285,10 @@ function useHostedRedirectAuth() {
|
|
|
283
285
|
setIsLoading(true);
|
|
284
286
|
setError(null);
|
|
285
287
|
try {
|
|
286
|
-
const verifier =
|
|
287
|
-
const codeChallenge = await
|
|
288
|
-
const state =
|
|
289
|
-
|
|
288
|
+
const verifier = chunkACLJPC75_cjs.createPkceVerifier();
|
|
289
|
+
const codeChallenge = await chunkACLJPC75_cjs.createPkceChallenge(verifier);
|
|
290
|
+
const state = chunkACLJPC75_cjs.createHostedAuthState();
|
|
291
|
+
chunkACLJPC75_cjs.persistHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey, {
|
|
290
292
|
codeVerifier: verifier,
|
|
291
293
|
state
|
|
292
294
|
});
|
|
@@ -315,15 +317,15 @@ function useHostedRedirectAuth() {
|
|
|
315
317
|
}, [clearPendingLogin, client, hostedAuthConfig, networkConfig.chainId, pendingStorageKey]);
|
|
316
318
|
const completeLogin = react.useCallback(async () => {
|
|
317
319
|
if (!hostedAuthConfig) {
|
|
318
|
-
throw new
|
|
320
|
+
throw new chunkACLJPC75_cjs.HostedAuthRequiredError(
|
|
319
321
|
"Hosted redirect authentication is not configured for this provider."
|
|
320
322
|
);
|
|
321
323
|
}
|
|
322
324
|
if (typeof window === "undefined") {
|
|
323
|
-
throw new
|
|
325
|
+
throw new chunkACLJPC75_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
|
|
324
326
|
}
|
|
325
327
|
if (!pendingStorageKey) {
|
|
326
|
-
throw new
|
|
328
|
+
throw new chunkACLJPC75_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
|
|
327
329
|
}
|
|
328
330
|
if (completionInflight.current) {
|
|
329
331
|
return completionInflight.current;
|
|
@@ -333,30 +335,30 @@ function useHostedRedirectAuth() {
|
|
|
333
335
|
setError(null);
|
|
334
336
|
const callbackUrl = new URL(window.location.href);
|
|
335
337
|
const cleanupCallbackUrl = () => {
|
|
336
|
-
window.history.replaceState(null, "",
|
|
338
|
+
window.history.replaceState(null, "", chunkACLJPC75_cjs.stripHostedAuthCallbackParams(callbackUrl));
|
|
337
339
|
};
|
|
338
340
|
try {
|
|
339
|
-
const callback =
|
|
341
|
+
const callback = chunkACLJPC75_cjs.parseHostedAuthCallback(callbackUrl, hostedAuthConfig.redirectUri);
|
|
340
342
|
if (!callback) {
|
|
341
343
|
return null;
|
|
342
344
|
}
|
|
343
|
-
const pending =
|
|
345
|
+
const pending = chunkACLJPC75_cjs.readHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
|
|
344
346
|
if (!pending) {
|
|
345
347
|
clearPendingLogin();
|
|
346
348
|
cleanupCallbackUrl();
|
|
347
|
-
throw new
|
|
349
|
+
throw new chunkACLJPC75_cjs.HostedAuthError(
|
|
348
350
|
"Hosted authentication response could not be matched to a pending login request."
|
|
349
351
|
);
|
|
350
352
|
}
|
|
351
353
|
if (!callback.state || callback.state !== pending.state) {
|
|
352
354
|
clearPendingLogin();
|
|
353
355
|
cleanupCallbackUrl();
|
|
354
|
-
throw new
|
|
356
|
+
throw new chunkACLJPC75_cjs.HostedAuthStateMismatchError();
|
|
355
357
|
}
|
|
356
358
|
if ("error" in callback) {
|
|
357
359
|
clearPendingLogin();
|
|
358
360
|
cleanupCallbackUrl();
|
|
359
|
-
throw new
|
|
361
|
+
throw new chunkACLJPC75_cjs.HostedAuthError(
|
|
360
362
|
callback.errorDescription || callback.error || "Hosted authentication failed."
|
|
361
363
|
);
|
|
362
364
|
}
|
|
@@ -371,7 +373,7 @@ function useHostedRedirectAuth() {
|
|
|
371
373
|
client_id: hostedAuthConfig.clientId,
|
|
372
374
|
redirect_uri: hostedAuthConfig.redirectUri
|
|
373
375
|
});
|
|
374
|
-
const session =
|
|
376
|
+
const session = chunkACLJPC75_cjs.buildHostedAuthSession(response, hostedAuthConfig);
|
|
375
377
|
setHostedAuthSession(session);
|
|
376
378
|
clearPendingLogin();
|
|
377
379
|
cleanupCallbackUrl();
|
|
@@ -416,7 +418,7 @@ function useHostedRedirectAuth() {
|
|
|
416
418
|
try {
|
|
417
419
|
return await refreshHostedAuthSession();
|
|
418
420
|
} catch (refreshError) {
|
|
419
|
-
const normalizedError = refreshError instanceof Error ? refreshError : new
|
|
421
|
+
const normalizedError = refreshError instanceof Error ? refreshError : new chunkACLJPC75_cjs.HostedAuthError("Hosted authentication refresh failed.");
|
|
420
422
|
setError(normalizedError);
|
|
421
423
|
throw normalizedError;
|
|
422
424
|
} finally {
|
|
@@ -436,12 +438,12 @@ function useHostedRedirectAuth() {
|
|
|
436
438
|
}
|
|
437
439
|
function useBalance(options = {}) {
|
|
438
440
|
const queryClient = react.useContext(reactQuery.QueryClientContext);
|
|
439
|
-
const accountingContext =
|
|
441
|
+
const accountingContext = chunkACLJPC75_cjs.useSafePrivanaContext();
|
|
440
442
|
const hasProviders = !!queryClient && !!accountingContext;
|
|
441
443
|
const client = accountingContext?.client;
|
|
442
444
|
const defaultToken = accountingContext?.defaultToken;
|
|
443
445
|
const pollingInterval = accountingContext?.pollingInterval ?? 1e4;
|
|
444
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
446
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
|
|
445
447
|
const tokenId = options.tokenId ?? defaultToken?.id;
|
|
446
448
|
const query = reactQuery.useQuery({
|
|
447
449
|
queryKey: ["accounting-balance", ...privateReadQueryScope, tokenId],
|
|
@@ -458,7 +460,7 @@ function useBalance(options = {}) {
|
|
|
458
460
|
return {
|
|
459
461
|
balance: balanceWei,
|
|
460
462
|
balanceWei,
|
|
461
|
-
balanceFormatted:
|
|
463
|
+
balanceFormatted: chunkACLJPC75_cjs.formatTokenAmount(balanceWei),
|
|
462
464
|
tokenSymbol: query.data?.token_symbol ?? "",
|
|
463
465
|
chainId: query.data?.chain_id ?? "",
|
|
464
466
|
isLoading: query.isPending || query.isLoading,
|
|
@@ -468,8 +470,8 @@ function useBalance(options = {}) {
|
|
|
468
470
|
};
|
|
469
471
|
}
|
|
470
472
|
function useBatchBalances(options) {
|
|
471
|
-
const { client, pollingInterval } =
|
|
472
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
473
|
+
const { client, pollingInterval } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
474
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
|
|
473
475
|
const query = reactQuery.useQuery({
|
|
474
476
|
queryKey: ["accounting-batch-balances", ...privateReadQueryScope, options.tokenIds],
|
|
475
477
|
queryFn: async () => {
|
|
@@ -495,7 +497,7 @@ function useEnsureCorrectChain() {
|
|
|
495
497
|
async (expectedChainId, timeoutMs, pollIntervalMs = 250) => {
|
|
496
498
|
const startedAt = Date.now();
|
|
497
499
|
while (Date.now() - startedAt < timeoutMs) {
|
|
498
|
-
const currentChainId =
|
|
500
|
+
const currentChainId = chunkACLJPC75_cjs.getChainId2(config);
|
|
499
501
|
if (currentChainId === expectedChainId) return true;
|
|
500
502
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
501
503
|
}
|
|
@@ -505,7 +507,7 @@ function useEnsureCorrectChain() {
|
|
|
505
507
|
);
|
|
506
508
|
const ensureCorrectChain = react.useCallback(
|
|
507
509
|
async (targetChainId) => {
|
|
508
|
-
const currentChainId =
|
|
510
|
+
const currentChainId = chunkACLJPC75_cjs.getChainId2(config);
|
|
509
511
|
if (currentChainId === targetChainId) return false;
|
|
510
512
|
let switchErrorMessage;
|
|
511
513
|
try {
|
|
@@ -572,11 +574,11 @@ function clearPendingDeposit(address) {
|
|
|
572
574
|
}
|
|
573
575
|
function useDeposit(options = {}) {
|
|
574
576
|
const { address } = wagmi.useAccount();
|
|
575
|
-
const { client, enabledTokens, getChainById: getChainById2 } =
|
|
577
|
+
const { client, enabledTokens, getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
576
578
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
577
579
|
const queryClient = reactQuery.useQueryClient();
|
|
578
580
|
const config = wagmi.useConfig();
|
|
579
|
-
const { executePrivateRead } =
|
|
581
|
+
const { executePrivateRead } = chunkACLJPC75_cjs.usePrivateReadRequest();
|
|
580
582
|
const confirmations = options.confirmations ?? 15;
|
|
581
583
|
const [depositAddress, setDepositAddress] = react.useState(null);
|
|
582
584
|
const [txHash, setTxHash] = react.useState();
|
|
@@ -611,7 +613,7 @@ function useDeposit(options = {}) {
|
|
|
611
613
|
error: verificationError,
|
|
612
614
|
verify,
|
|
613
615
|
reset: resetVerification
|
|
614
|
-
} =
|
|
616
|
+
} = chunkACLJPC75_cjs.useDepositVerification({
|
|
615
617
|
pollInterval: options.pollInterval,
|
|
616
618
|
pollTimeout: options.pollTimeout,
|
|
617
619
|
onCredited: (hash, response) => {
|
|
@@ -699,12 +701,12 @@ function useDeposit(options = {}) {
|
|
|
699
701
|
try {
|
|
700
702
|
let confirmed = false;
|
|
701
703
|
try {
|
|
702
|
-
await
|
|
704
|
+
await chunkACLJPC75_cjs.getTransactionReceipt(config, { hash, chainId: persisted.chainId });
|
|
703
705
|
confirmed = true;
|
|
704
706
|
} catch {
|
|
705
707
|
}
|
|
706
708
|
if (!confirmed) {
|
|
707
|
-
await
|
|
709
|
+
await chunkACLJPC75_cjs.waitForTransactionReceipt(config, {
|
|
708
710
|
hash,
|
|
709
711
|
chainId: persisted.chainId,
|
|
710
712
|
confirmations
|
|
@@ -791,7 +793,7 @@ function useDeposit(options = {}) {
|
|
|
791
793
|
try {
|
|
792
794
|
setIsWaitingForConfirmation(true);
|
|
793
795
|
try {
|
|
794
|
-
await
|
|
796
|
+
await chunkACLJPC75_cjs.waitForTransactionReceipt(config, {
|
|
795
797
|
hash,
|
|
796
798
|
chainId: sourceChain.id,
|
|
797
799
|
confirmations
|
|
@@ -862,10 +864,35 @@ function useDeposit(options = {}) {
|
|
|
862
864
|
reset
|
|
863
865
|
};
|
|
864
866
|
}
|
|
867
|
+
function useDepositAddress(options = {}) {
|
|
868
|
+
const queryClient = react.useContext(reactQuery.QueryClientContext);
|
|
869
|
+
const accountingContext = chunkACLJPC75_cjs.useSafePrivanaContext();
|
|
870
|
+
const hasProviders = !!queryClient && !!accountingContext;
|
|
871
|
+
const client = accountingContext?.client;
|
|
872
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
|
|
873
|
+
const isReady = hasProviders && privateReadReady && !!privateReadAddress && !!client;
|
|
874
|
+
const query = reactQuery.useQuery({
|
|
875
|
+
queryKey: ["accounting-deposit-address", ...privateReadQueryScope],
|
|
876
|
+
queryFn: async () => {
|
|
877
|
+
if (!privateReadAddress) throw new Error("No authenticated account available");
|
|
878
|
+
if (!client) throw new Error("No accounting client");
|
|
879
|
+
return executePrivateRead(() => client.getDepositAddress());
|
|
880
|
+
},
|
|
881
|
+
enabled: isReady && (options.enabled ?? true)
|
|
882
|
+
});
|
|
883
|
+
return {
|
|
884
|
+
depositAddress: query.data?.deposit_address ?? null,
|
|
885
|
+
isReady,
|
|
886
|
+
isLoading: query.isLoading,
|
|
887
|
+
isError: query.isError,
|
|
888
|
+
error: query.error,
|
|
889
|
+
refetch: query.refetch
|
|
890
|
+
};
|
|
891
|
+
}
|
|
865
892
|
function useWithdraw(options = {}) {
|
|
866
893
|
const { address } = wagmi.useAccount();
|
|
867
894
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
868
|
-
const { client, networkConfig } =
|
|
895
|
+
const { client, networkConfig } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
869
896
|
const queryClient = reactQuery.useQueryClient();
|
|
870
897
|
const { chainId, ensureCorrectChain } = useEnsureCorrectChain();
|
|
871
898
|
const pollInterval = options.pollInterval ?? 3e3;
|
|
@@ -1064,7 +1091,7 @@ function useWithdraw(options = {}) {
|
|
|
1064
1091
|
function useLockFunds(options = {}) {
|
|
1065
1092
|
const { address } = wagmi.useAccount();
|
|
1066
1093
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1067
|
-
const { client, networkConfig, serviceAddress } =
|
|
1094
|
+
const { client, networkConfig, serviceAddress } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1068
1095
|
const queryClient = reactQuery.useQueryClient();
|
|
1069
1096
|
const mutation = reactQuery.useMutation({
|
|
1070
1097
|
mutationFn: async (params) => {
|
|
@@ -1123,7 +1150,7 @@ function useLockFunds(options = {}) {
|
|
|
1123
1150
|
}
|
|
1124
1151
|
function useUnlockFunds(options = {}) {
|
|
1125
1152
|
const { address } = wagmi.useAccount();
|
|
1126
|
-
const { client } =
|
|
1153
|
+
const { client } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1127
1154
|
const queryClient = reactQuery.useQueryClient();
|
|
1128
1155
|
const unlockMutation = reactQuery.useMutation({
|
|
1129
1156
|
mutationFn: async (params) => {
|
|
@@ -1193,7 +1220,7 @@ function useUnlockFunds(options = {}) {
|
|
|
1193
1220
|
function useTransfer(options = {}) {
|
|
1194
1221
|
const { address } = wagmi.useAccount();
|
|
1195
1222
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1196
|
-
const { client, networkConfig, serviceAddress } =
|
|
1223
|
+
const { client, networkConfig, serviceAddress } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1197
1224
|
const queryClient = reactQuery.useQueryClient();
|
|
1198
1225
|
const transferMutation = reactQuery.useMutation({
|
|
1199
1226
|
mutationFn: async (params) => {
|
|
@@ -1298,8 +1325,8 @@ function useTransfer(options = {}) {
|
|
|
1298
1325
|
};
|
|
1299
1326
|
}
|
|
1300
1327
|
function useLockedFunds(options = {}) {
|
|
1301
|
-
const { client, pollingInterval, serviceAddress } =
|
|
1302
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1328
|
+
const { client, pollingInterval, serviceAddress } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1329
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
|
|
1303
1330
|
const query = reactQuery.useQuery({
|
|
1304
1331
|
queryKey: ["accounting-locked-funds", ...privateReadQueryScope, serviceAddress ?? null],
|
|
1305
1332
|
queryFn: async () => {
|
|
@@ -1321,8 +1348,8 @@ function useLockedFunds(options = {}) {
|
|
|
1321
1348
|
};
|
|
1322
1349
|
}
|
|
1323
1350
|
function useTotalLockedBalance(options = {}) {
|
|
1324
|
-
const { client, pollingInterval, defaultToken } =
|
|
1325
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1351
|
+
const { client, pollingInterval, defaultToken } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1352
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
|
|
1326
1353
|
const tokenId = options.tokenId ?? defaultToken?.id;
|
|
1327
1354
|
const query = reactQuery.useQuery({
|
|
1328
1355
|
queryKey: ["accounting-total-locked-balance", ...privateReadQueryScope, tokenId],
|
|
@@ -1343,8 +1370,8 @@ function useTotalLockedBalance(options = {}) {
|
|
|
1343
1370
|
};
|
|
1344
1371
|
}
|
|
1345
1372
|
function useExpiredLocks(options = {}) {
|
|
1346
|
-
const { client, pollingInterval } =
|
|
1347
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1373
|
+
const { client, pollingInterval } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1374
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
|
|
1348
1375
|
const query = reactQuery.useQuery({
|
|
1349
1376
|
queryKey: ["accounting-expired-locks", ...privateReadQueryScope],
|
|
1350
1377
|
queryFn: async () => {
|
|
@@ -1366,7 +1393,7 @@ function useExpiredLocks(options = {}) {
|
|
|
1366
1393
|
}
|
|
1367
1394
|
function usePendingWithdrawals(options = {}) {
|
|
1368
1395
|
const { address, isConnected } = wagmi.useAccount();
|
|
1369
|
-
const { client, pollingInterval } =
|
|
1396
|
+
const { client, pollingInterval } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1370
1397
|
const query = reactQuery.useQuery({
|
|
1371
1398
|
queryKey: ["accounting-pending-withdrawals", address],
|
|
1372
1399
|
queryFn: async () => {
|
|
@@ -1402,8 +1429,8 @@ function usePendingWithdrawals(options = {}) {
|
|
|
1402
1429
|
};
|
|
1403
1430
|
}
|
|
1404
1431
|
function useHistory(options = {}) {
|
|
1405
|
-
const { client, pollingInterval } =
|
|
1406
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1432
|
+
const { client, pollingInterval } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1433
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkACLJPC75_cjs.usePrivateReadRequest();
|
|
1407
1434
|
const offset = options.offset ?? -1;
|
|
1408
1435
|
const limit = options.limit ?? 50;
|
|
1409
1436
|
const query = reactQuery.useQuery({
|
|
@@ -1427,7 +1454,7 @@ function useHistory(options = {}) {
|
|
|
1427
1454
|
};
|
|
1428
1455
|
}
|
|
1429
1456
|
function useTokenInfo(options = {}) {
|
|
1430
|
-
const { client } =
|
|
1457
|
+
const { client } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1431
1458
|
const { tokenId } = options;
|
|
1432
1459
|
const query = reactQuery.useQuery({
|
|
1433
1460
|
queryKey: ["accounting-token-info", tokenId],
|
|
@@ -1447,7 +1474,7 @@ function useTokenInfo(options = {}) {
|
|
|
1447
1474
|
};
|
|
1448
1475
|
}
|
|
1449
1476
|
function useTokenList(options = {}) {
|
|
1450
|
-
const { client } =
|
|
1477
|
+
const { client } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1451
1478
|
const query = reactQuery.useQuery({
|
|
1452
1479
|
queryKey: ["accounting-token-list"],
|
|
1453
1480
|
queryFn: () => client.listTokens(),
|
|
@@ -1465,7 +1492,7 @@ function useTokenList(options = {}) {
|
|
|
1465
1492
|
function useModifyLock(options = {}) {
|
|
1466
1493
|
const { address } = wagmi.useAccount();
|
|
1467
1494
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1468
|
-
const { client, networkConfig } =
|
|
1495
|
+
const { client, networkConfig } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1469
1496
|
const queryClient = reactQuery.useQueryClient();
|
|
1470
1497
|
const mutation = reactQuery.useMutation({
|
|
1471
1498
|
mutationFn: async (params) => {
|
|
@@ -1532,7 +1559,7 @@ function DialogOverlay({
|
|
|
1532
1559
|
{
|
|
1533
1560
|
"data-slot": "dialog-overlay",
|
|
1534
1561
|
"data-privana": true,
|
|
1535
|
-
className:
|
|
1562
|
+
className: chunkACLJPC75_cjs.cn(
|
|
1536
1563
|
"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",
|
|
1537
1564
|
className
|
|
1538
1565
|
),
|
|
@@ -1554,7 +1581,7 @@ function DialogContent({
|
|
|
1554
1581
|
{
|
|
1555
1582
|
"data-slot": "dialog-content",
|
|
1556
1583
|
"data-privana": true,
|
|
1557
|
-
className:
|
|
1584
|
+
className: chunkACLJPC75_cjs.cn(
|
|
1558
1585
|
"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",
|
|
1559
1586
|
className
|
|
1560
1587
|
),
|
|
@@ -1582,7 +1609,7 @@ function DialogHeader({ className, ...props }) {
|
|
|
1582
1609
|
"div",
|
|
1583
1610
|
{
|
|
1584
1611
|
"data-slot": "dialog-header",
|
|
1585
|
-
className:
|
|
1612
|
+
className: chunkACLJPC75_cjs.cn("flex flex-col gap-2 text-center sm:text-left", className),
|
|
1586
1613
|
...props
|
|
1587
1614
|
}
|
|
1588
1615
|
);
|
|
@@ -1592,7 +1619,7 @@ function DialogTitle({ className, ...props }) {
|
|
|
1592
1619
|
DialogPrimitive__namespace.Title,
|
|
1593
1620
|
{
|
|
1594
1621
|
"data-slot": "dialog-title",
|
|
1595
|
-
className:
|
|
1622
|
+
className: chunkACLJPC75_cjs.cn("text-lg leading-none font-semibold", className),
|
|
1596
1623
|
...props
|
|
1597
1624
|
}
|
|
1598
1625
|
);
|
|
@@ -1605,24 +1632,11 @@ function DialogDescription({
|
|
|
1605
1632
|
DialogPrimitive__namespace.Description,
|
|
1606
1633
|
{
|
|
1607
1634
|
"data-slot": "dialog-description",
|
|
1608
|
-
className:
|
|
1635
|
+
className: chunkACLJPC75_cjs.cn("text-muted-foreground text-sm", className),
|
|
1609
1636
|
...props
|
|
1610
1637
|
}
|
|
1611
1638
|
);
|
|
1612
1639
|
}
|
|
1613
|
-
function ChevronRightIcon() {
|
|
1614
|
-
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "5", viewBox: "0 0 12 6", className: "-rotate-90", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1615
|
-
"path",
|
|
1616
|
-
{
|
|
1617
|
-
d: "M0 0l6 6 6-6",
|
|
1618
|
-
stroke: "currentColor",
|
|
1619
|
-
strokeWidth: "1.5",
|
|
1620
|
-
strokeLinecap: "round",
|
|
1621
|
-
strokeLinejoin: "round",
|
|
1622
|
-
fill: "none"
|
|
1623
|
-
}
|
|
1624
|
-
) });
|
|
1625
|
-
}
|
|
1626
1640
|
function USDCIcon({ className, size = 24 }) {
|
|
1627
1641
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1628
1642
|
"svg",
|
|
@@ -1764,6 +1778,135 @@ function getChainIcon(chainId, size) {
|
|
|
1764
1778
|
);
|
|
1765
1779
|
}
|
|
1766
1780
|
}
|
|
1781
|
+
function CloseIcon() {
|
|
1782
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "10", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1783
|
+
"path",
|
|
1784
|
+
{
|
|
1785
|
+
d: "M11.99997 11.99997l-5.99995-5.99995-6.00002-6.00002m6.00002 6.00002l6.00001-6.00002m-12.00003 12.00003l6.00002-6.00001",
|
|
1786
|
+
stroke: "currentColor",
|
|
1787
|
+
strokeWidth: "1.5",
|
|
1788
|
+
strokeLinecap: "round",
|
|
1789
|
+
strokeLinejoin: "round"
|
|
1790
|
+
}
|
|
1791
|
+
) });
|
|
1792
|
+
}
|
|
1793
|
+
function ChevronRightIcon() {
|
|
1794
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "5", viewBox: "0 0 12 6", className: "-rotate-90", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1795
|
+
"path",
|
|
1796
|
+
{
|
|
1797
|
+
d: "M0 0l6 6 6-6",
|
|
1798
|
+
stroke: "currentColor",
|
|
1799
|
+
strokeWidth: "1.5",
|
|
1800
|
+
strokeLinecap: "round",
|
|
1801
|
+
strokeLinejoin: "round",
|
|
1802
|
+
fill: "none"
|
|
1803
|
+
}
|
|
1804
|
+
) });
|
|
1805
|
+
}
|
|
1806
|
+
function ChevronLeftIcon() {
|
|
1807
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "5", viewBox: "0 0 12 6", className: "rotate-90", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1808
|
+
"path",
|
|
1809
|
+
{
|
|
1810
|
+
d: "M0 0l6 6 6-6",
|
|
1811
|
+
stroke: "currentColor",
|
|
1812
|
+
strokeWidth: "1.5",
|
|
1813
|
+
strokeLinecap: "round",
|
|
1814
|
+
strokeLinejoin: "round",
|
|
1815
|
+
fill: "none"
|
|
1816
|
+
}
|
|
1817
|
+
) });
|
|
1818
|
+
}
|
|
1819
|
+
function ChevronDownIcon({
|
|
1820
|
+
direction = "down",
|
|
1821
|
+
className
|
|
1822
|
+
}) {
|
|
1823
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1824
|
+
"svg",
|
|
1825
|
+
{
|
|
1826
|
+
width: "16",
|
|
1827
|
+
height: "16",
|
|
1828
|
+
viewBox: "0 0 16 16",
|
|
1829
|
+
fill: "none",
|
|
1830
|
+
className: chunkACLJPC75_cjs.cn(
|
|
1831
|
+
"transition-transform",
|
|
1832
|
+
direction === "right" && "-rotate-90",
|
|
1833
|
+
direction === "up" && "rotate-180",
|
|
1834
|
+
className
|
|
1835
|
+
),
|
|
1836
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1837
|
+
"path",
|
|
1838
|
+
{
|
|
1839
|
+
d: "M4 6l4 4 4-4",
|
|
1840
|
+
stroke: "currentColor",
|
|
1841
|
+
strokeWidth: "1.5",
|
|
1842
|
+
strokeLinecap: "round",
|
|
1843
|
+
strokeLinejoin: "round"
|
|
1844
|
+
}
|
|
1845
|
+
)
|
|
1846
|
+
}
|
|
1847
|
+
);
|
|
1848
|
+
}
|
|
1849
|
+
function CopyIcon() {
|
|
1850
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1851
|
+
"svg",
|
|
1852
|
+
{
|
|
1853
|
+
width: "16",
|
|
1854
|
+
height: "16",
|
|
1855
|
+
viewBox: "0 0 24 24",
|
|
1856
|
+
fill: "none",
|
|
1857
|
+
stroke: "currentColor",
|
|
1858
|
+
strokeWidth: "2",
|
|
1859
|
+
strokeLinecap: "round",
|
|
1860
|
+
strokeLinejoin: "round",
|
|
1861
|
+
children: [
|
|
1862
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
|
|
1863
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
1864
|
+
]
|
|
1865
|
+
}
|
|
1866
|
+
);
|
|
1867
|
+
}
|
|
1868
|
+
function CircleCheckIcon() {
|
|
1869
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [
|
|
1870
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "10", r: "9", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
1871
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1872
|
+
"path",
|
|
1873
|
+
{
|
|
1874
|
+
d: "M6 10l2.5 2.5L14 7.5",
|
|
1875
|
+
stroke: "currentColor",
|
|
1876
|
+
strokeWidth: "1.5",
|
|
1877
|
+
strokeLinecap: "round",
|
|
1878
|
+
strokeLinejoin: "round"
|
|
1879
|
+
}
|
|
1880
|
+
)
|
|
1881
|
+
] });
|
|
1882
|
+
}
|
|
1883
|
+
function CircleXIcon() {
|
|
1884
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [
|
|
1885
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "10", r: "9", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
1886
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1887
|
+
"path",
|
|
1888
|
+
{
|
|
1889
|
+
d: "M7 7l6 6M13 7l-6 6",
|
|
1890
|
+
stroke: "currentColor",
|
|
1891
|
+
strokeWidth: "1.5",
|
|
1892
|
+
strokeLinecap: "round",
|
|
1893
|
+
strokeLinejoin: "round"
|
|
1894
|
+
}
|
|
1895
|
+
)
|
|
1896
|
+
] });
|
|
1897
|
+
}
|
|
1898
|
+
function ArrowRightIcon({ className }) {
|
|
1899
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "8", viewBox: "0 0 24 8", fill: "none", className, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1900
|
+
"path",
|
|
1901
|
+
{
|
|
1902
|
+
d: "M0 4h22m0 0l-4-4m4 4l-4 4",
|
|
1903
|
+
stroke: "currentColor",
|
|
1904
|
+
strokeWidth: "1.5",
|
|
1905
|
+
strokeLinecap: "round",
|
|
1906
|
+
strokeLinejoin: "round"
|
|
1907
|
+
}
|
|
1908
|
+
) });
|
|
1909
|
+
}
|
|
1767
1910
|
function CheckIcon() {
|
|
1768
1911
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1769
1912
|
"path",
|
|
@@ -1960,7 +2103,7 @@ function DepositForm({
|
|
|
1960
2103
|
onSuccess
|
|
1961
2104
|
}) {
|
|
1962
2105
|
const { isConnected, address } = wagmi.useAccount();
|
|
1963
|
-
const { chains, getChainById: getChainById2 } =
|
|
2106
|
+
const { chains, getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
1964
2107
|
const [amount, setAmount] = react.useState("");
|
|
1965
2108
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
1966
2109
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
@@ -1985,7 +2128,7 @@ function DepositForm({
|
|
|
1985
2128
|
}
|
|
1986
2129
|
});
|
|
1987
2130
|
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
1988
|
-
const formattedWalletBalance = walletBalance ?
|
|
2131
|
+
const formattedWalletBalance = walletBalance ? chunkACLJPC75_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
|
|
1989
2132
|
const handleMaxClick = () => {
|
|
1990
2133
|
if (formattedWalletBalance && parseFloat(formattedWalletBalance) > 0) {
|
|
1991
2134
|
setAmount(formattedWalletBalance.replace(/[\s\u2009]/g, ""));
|
|
@@ -1993,7 +2136,7 @@ function DepositForm({
|
|
|
1993
2136
|
};
|
|
1994
2137
|
const hasValidAmount = amount && parseFloat(amount) > 0;
|
|
1995
2138
|
const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
1996
|
-
const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null &&
|
|
2139
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null && chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
|
|
1997
2140
|
const {
|
|
1998
2141
|
txHash,
|
|
1999
2142
|
isGettingAddress,
|
|
@@ -2078,7 +2221,7 @@ function DepositForm({
|
|
|
2078
2221
|
const handleSubmit = async () => {
|
|
2079
2222
|
if (!amount || !selectedToken || exceedsBalance) return;
|
|
2080
2223
|
setCancelled(false);
|
|
2081
|
-
const amountInWei =
|
|
2224
|
+
const amountInWei = chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals);
|
|
2082
2225
|
await deposit({
|
|
2083
2226
|
tokenId: selectedToken.id,
|
|
2084
2227
|
amount: amountInWei
|
|
@@ -2181,7 +2324,7 @@ function DepositForm({
|
|
|
2181
2324
|
setAmount(value);
|
|
2182
2325
|
}
|
|
2183
2326
|
},
|
|
2184
|
-
className:
|
|
2327
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2185
2328
|
"text-foreground flex-1 bg-transparent text-sm outline-none",
|
|
2186
2329
|
"placeholder:text-muted-foreground/50"
|
|
2187
2330
|
)
|
|
@@ -2208,7 +2351,7 @@ function DepositForm({
|
|
|
2208
2351
|
{
|
|
2209
2352
|
onClick: handleSubmit,
|
|
2210
2353
|
disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
|
|
2211
|
-
className:
|
|
2354
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2212
2355
|
"flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
|
|
2213
2356
|
"bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2214
2357
|
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
@@ -2225,7 +2368,7 @@ function WithdrawForm({
|
|
|
2225
2368
|
onUnsafeToCloseChange
|
|
2226
2369
|
}) {
|
|
2227
2370
|
const { isConnected, address } = wagmi.useAccount();
|
|
2228
|
-
const { chains, getChainById: getChainById2 } =
|
|
2371
|
+
const { chains, getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
2229
2372
|
const [amount, setAmount] = react.useState("");
|
|
2230
2373
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
2231
2374
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
@@ -2238,7 +2381,7 @@ function WithdrawForm({
|
|
|
2238
2381
|
} = useBalance({
|
|
2239
2382
|
tokenId: selectedToken.id
|
|
2240
2383
|
});
|
|
2241
|
-
const formattedBalance =
|
|
2384
|
+
const formattedBalance = chunkACLJPC75_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
|
|
2242
2385
|
const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
|
|
2243
2386
|
onProcessingSuccess: () => {
|
|
2244
2387
|
setAmount("");
|
|
@@ -2249,7 +2392,7 @@ function WithdrawForm({
|
|
|
2249
2392
|
setShowTimeout(true);
|
|
2250
2393
|
}
|
|
2251
2394
|
});
|
|
2252
|
-
const explorerUrl = address && targetChain ?
|
|
2395
|
+
const explorerUrl = address && targetChain ? chunkACLJPC75_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
|
|
2253
2396
|
const getStepStatus = (step, after) => {
|
|
2254
2397
|
if (currentStep === step) return "active";
|
|
2255
2398
|
if (after.includes(currentStep)) return "completed";
|
|
@@ -2293,7 +2436,7 @@ function WithdrawForm({
|
|
|
2293
2436
|
const handleWithdraw = async () => {
|
|
2294
2437
|
if (!amount || !selectedToken || exceedsBalance) return;
|
|
2295
2438
|
setCancelled(false);
|
|
2296
|
-
const amountInWei =
|
|
2439
|
+
const amountInWei = chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals);
|
|
2297
2440
|
await withdraw({
|
|
2298
2441
|
tokenId: selectedToken.id,
|
|
2299
2442
|
amount: amountInWei
|
|
@@ -2306,7 +2449,7 @@ function WithdrawForm({
|
|
|
2306
2449
|
};
|
|
2307
2450
|
const hasValidAmount = amount && parseFloat(amount) > 0;
|
|
2308
2451
|
const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
2309
|
-
const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError &&
|
|
2452
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError && chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
|
|
2310
2453
|
const getButtonText = () => {
|
|
2311
2454
|
if (!isConnected) return "Connect Wallet";
|
|
2312
2455
|
return "Withdraw";
|
|
@@ -2318,7 +2461,7 @@ function WithdrawForm({
|
|
|
2318
2461
|
title: "Withdrawal Complete",
|
|
2319
2462
|
message: `Your ${selectedToken.symbol} withdrawal has been processed. Funds should appear in your wallet shortly.`,
|
|
2320
2463
|
explorerUrl,
|
|
2321
|
-
explorerLabel:
|
|
2464
|
+
explorerLabel: targetChain ? chunkACLJPC75_cjs.getExplorerLabel(targetChain.id) : void 0,
|
|
2322
2465
|
onDone: handleDone
|
|
2323
2466
|
}
|
|
2324
2467
|
);
|
|
@@ -2389,7 +2532,7 @@ function WithdrawForm({
|
|
|
2389
2532
|
setAmount(value);
|
|
2390
2533
|
}
|
|
2391
2534
|
},
|
|
2392
|
-
className:
|
|
2535
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2393
2536
|
"text-foreground flex-1 bg-transparent text-sm outline-none",
|
|
2394
2537
|
"placeholder:text-muted-foreground/50"
|
|
2395
2538
|
)
|
|
@@ -2416,7 +2559,7 @@ function WithdrawForm({
|
|
|
2416
2559
|
{
|
|
2417
2560
|
onClick: handleWithdraw,
|
|
2418
2561
|
disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
|
|
2419
|
-
className:
|
|
2562
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2420
2563
|
"flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
|
|
2421
2564
|
"bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2422
2565
|
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
@@ -2426,66 +2569,6 @@ function WithdrawForm({
|
|
|
2426
2569
|
)
|
|
2427
2570
|
] });
|
|
2428
2571
|
}
|
|
2429
|
-
function CloseIcon() {
|
|
2430
|
-
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "10", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2431
|
-
"path",
|
|
2432
|
-
{
|
|
2433
|
-
d: "M11.99997 11.99997l-5.99995-5.99995-6.00002-6.00002m6.00002 6.00002l6.00001-6.00002m-12.00003 12.00003l6.00002-6.00001",
|
|
2434
|
-
stroke: "currentColor",
|
|
2435
|
-
strokeWidth: "1.5",
|
|
2436
|
-
strokeLinecap: "round",
|
|
2437
|
-
strokeLinejoin: "round"
|
|
2438
|
-
}
|
|
2439
|
-
) });
|
|
2440
|
-
}
|
|
2441
|
-
function ChevronRight() {
|
|
2442
|
-
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "5", viewBox: "0 0 12 6", className: "-rotate-90", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2443
|
-
"path",
|
|
2444
|
-
{
|
|
2445
|
-
d: "M0 0l6 6 6-6",
|
|
2446
|
-
stroke: "currentColor",
|
|
2447
|
-
strokeWidth: "1.5",
|
|
2448
|
-
strokeLinecap: "round",
|
|
2449
|
-
strokeLinejoin: "round",
|
|
2450
|
-
fill: "none"
|
|
2451
|
-
}
|
|
2452
|
-
) });
|
|
2453
|
-
}
|
|
2454
|
-
function ChevronLeft() {
|
|
2455
|
-
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "5", viewBox: "0 0 12 6", className: "rotate-90", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2456
|
-
"path",
|
|
2457
|
-
{
|
|
2458
|
-
d: "M0 0l6 6 6-6",
|
|
2459
|
-
stroke: "currentColor",
|
|
2460
|
-
strokeWidth: "1.5",
|
|
2461
|
-
strokeLinecap: "round",
|
|
2462
|
-
strokeLinejoin: "round",
|
|
2463
|
-
fill: "none"
|
|
2464
|
-
}
|
|
2465
|
-
) });
|
|
2466
|
-
}
|
|
2467
|
-
function ChevronDown({ collapsed }) {
|
|
2468
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2469
|
-
"svg",
|
|
2470
|
-
{
|
|
2471
|
-
width: "12",
|
|
2472
|
-
height: "6",
|
|
2473
|
-
viewBox: "0 0 12 6",
|
|
2474
|
-
className: chunkEEAQ2NWF_cjs.cn("transition-transform", collapsed && "-rotate-90"),
|
|
2475
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2476
|
-
"path",
|
|
2477
|
-
{
|
|
2478
|
-
d: "M0 0l6 6 6-6",
|
|
2479
|
-
stroke: "currentColor",
|
|
2480
|
-
strokeWidth: "1.5",
|
|
2481
|
-
strokeLinecap: "round",
|
|
2482
|
-
strokeLinejoin: "round",
|
|
2483
|
-
fill: "none"
|
|
2484
|
-
}
|
|
2485
|
-
)
|
|
2486
|
-
}
|
|
2487
|
-
);
|
|
2488
|
-
}
|
|
2489
2572
|
function BalanceCards({
|
|
2490
2573
|
selectedToken,
|
|
2491
2574
|
onLockedFundsClick,
|
|
@@ -2497,15 +2580,15 @@ function BalanceCards({
|
|
|
2497
2580
|
tokenId: selectedToken.id
|
|
2498
2581
|
});
|
|
2499
2582
|
const { totalLocked, isLoading: lockedLoading } = useLockedFunds({ enabled: showLockedFunds });
|
|
2500
|
-
const formattedBalance =
|
|
2501
|
-
const formattedLocked = showLockedFunds ?
|
|
2502
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className:
|
|
2583
|
+
const formattedBalance = chunkACLJPC75_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
|
|
2584
|
+
const formattedLocked = showLockedFunds ? chunkACLJPC75_cjs.formatTokenAmount(String(totalLocked), selectedToken.decimals) : "0.00";
|
|
2585
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkACLJPC75_cjs.cn("flex gap-2", disabled && "opacity-50"), children: [
|
|
2503
2586
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2504
2587
|
"button",
|
|
2505
2588
|
{
|
|
2506
2589
|
onClick: onBalanceClick,
|
|
2507
2590
|
disabled,
|
|
2508
|
-
className:
|
|
2591
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2509
2592
|
"bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
|
|
2510
2593
|
disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
|
|
2511
2594
|
),
|
|
@@ -2515,7 +2598,7 @@ function BalanceCards({
|
|
|
2515
2598
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Balance" }),
|
|
2516
2599
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-secondary text-muted-foreground rounded-full px-2 py-[5px] text-[10px] font-bold", children: selectedToken.symbol })
|
|
2517
2600
|
] }),
|
|
2518
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground flex h-6 w-6 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2601
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground flex h-6 w-6 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, {}) })
|
|
2519
2602
|
] }),
|
|
2520
2603
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-foreground text-xl font-medium", children: balanceLoading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-secondary inline-block h-6 w-24 animate-pulse rounded" }) : formattedBalance })
|
|
2521
2604
|
]
|
|
@@ -2526,7 +2609,7 @@ function BalanceCards({
|
|
|
2526
2609
|
{
|
|
2527
2610
|
onClick: onLockedFundsClick,
|
|
2528
2611
|
disabled,
|
|
2529
|
-
className:
|
|
2612
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2530
2613
|
"bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
|
|
2531
2614
|
disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
|
|
2532
2615
|
),
|
|
@@ -2536,7 +2619,7 @@ function BalanceCards({
|
|
|
2536
2619
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Locked Funds" }),
|
|
2537
2620
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-secondary text-muted-foreground rounded-full px-2 py-[5px] text-[10px] font-bold", children: selectedToken.symbol })
|
|
2538
2621
|
] }),
|
|
2539
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground flex h-6 w-6 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2622
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground flex h-6 w-6 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, {}) })
|
|
2540
2623
|
] }),
|
|
2541
2624
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-foreground text-xl font-medium", children: lockedLoading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-secondary inline-block h-6 w-20 animate-pulse rounded" }) : formattedLocked })
|
|
2542
2625
|
]
|
|
@@ -2552,7 +2635,7 @@ function Tabs({
|
|
|
2552
2635
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2553
2636
|
"div",
|
|
2554
2637
|
{
|
|
2555
|
-
className:
|
|
2638
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2556
2639
|
"bg-muted relative flex gap-2 overflow-hidden rounded-[10px] p-1",
|
|
2557
2640
|
disabled && "opacity-50"
|
|
2558
2641
|
),
|
|
@@ -2560,7 +2643,7 @@ function Tabs({
|
|
|
2560
2643
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2561
2644
|
"div",
|
|
2562
2645
|
{
|
|
2563
|
-
className:
|
|
2646
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2564
2647
|
"bg-input absolute top-1 bottom-1 left-1 w-[calc(50%-8px)] rounded-md transition-transform duration-200",
|
|
2565
2648
|
activeTab === "withdraw" && "translate-x-[calc(100%+8px)]"
|
|
2566
2649
|
)
|
|
@@ -2571,7 +2654,7 @@ function Tabs({
|
|
|
2571
2654
|
{
|
|
2572
2655
|
onClick: () => !disabled && onTabChange("deposit"),
|
|
2573
2656
|
disabled,
|
|
2574
|
-
className:
|
|
2657
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2575
2658
|
"relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
|
|
2576
2659
|
activeTab === "deposit" ? "text-foreground" : "text-muted-foreground",
|
|
2577
2660
|
disabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
@@ -2584,7 +2667,7 @@ function Tabs({
|
|
|
2584
2667
|
{
|
|
2585
2668
|
onClick: () => !disabled && onTabChange("withdraw"),
|
|
2586
2669
|
disabled,
|
|
2587
|
-
className:
|
|
2670
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2588
2671
|
"relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
|
|
2589
2672
|
activeTab === "withdraw" ? "text-foreground" : "text-muted-foreground",
|
|
2590
2673
|
disabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
@@ -2597,14 +2680,14 @@ function Tabs({
|
|
|
2597
2680
|
);
|
|
2598
2681
|
}
|
|
2599
2682
|
function LockedFundsView({ onBack }) {
|
|
2600
|
-
const { getTokenById } =
|
|
2683
|
+
const { getTokenById } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
2601
2684
|
const { locks, isLoading } = useLockedFunds();
|
|
2602
2685
|
const { unlockFunds, unlockAllExpired, isPending } = useUnlockFunds();
|
|
2603
2686
|
const [collapsedSections, setCollapsedSections] = react.useState({});
|
|
2604
2687
|
const sections = react.useMemo(() => {
|
|
2605
2688
|
const sectionMap = {};
|
|
2606
2689
|
locks.forEach((lock) => {
|
|
2607
|
-
const serviceName =
|
|
2690
|
+
const serviceName = chunkACLJPC75_cjs.shortenAddress(lock.service_address);
|
|
2608
2691
|
if (!sectionMap[lock.service_address]) {
|
|
2609
2692
|
sectionMap[lock.service_address] = {
|
|
2610
2693
|
title: `Service ${serviceName}`,
|
|
@@ -2613,9 +2696,9 @@ function LockedFundsView({ onBack }) {
|
|
|
2613
2696
|
}
|
|
2614
2697
|
sectionMap[lock.service_address].items.push({
|
|
2615
2698
|
lockId: lock.lock_id,
|
|
2616
|
-
amount:
|
|
2699
|
+
amount: chunkACLJPC75_cjs.formatTokenAmount(String(lock.amount), getTokenById(lock.token_id)?.decimals ?? 18),
|
|
2617
2700
|
serviceAddress: lock.service_address,
|
|
2618
|
-
time: lock.is_expired ? "Click to unlock" :
|
|
2701
|
+
time: lock.is_expired ? "Click to unlock" : chunkACLJPC75_cjs.formatTimeRemaining(lock.expiry),
|
|
2619
2702
|
isExpired: lock.is_expired
|
|
2620
2703
|
});
|
|
2621
2704
|
});
|
|
@@ -2635,7 +2718,7 @@ function LockedFundsView({ onBack }) {
|
|
|
2635
2718
|
{
|
|
2636
2719
|
onClick: onBack,
|
|
2637
2720
|
className: "text-muted-foreground hover:text-foreground -ml-2 flex h-6 w-6 cursor-pointer items-center justify-center transition-colors",
|
|
2638
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2721
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, {})
|
|
2639
2722
|
}
|
|
2640
2723
|
),
|
|
2641
2724
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-xl leading-6 font-medium", children: "Locked Funds" })
|
|
@@ -2655,14 +2738,19 @@ function LockedFundsView({ onBack }) {
|
|
|
2655
2738
|
className: "text-muted-foreground hover:bg-secondary flex w-full cursor-pointer items-center justify-between rounded-lg px-4 py-4 transition-colors",
|
|
2656
2739
|
children: [
|
|
2657
2740
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: section.title }),
|
|
2658
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2741
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2742
|
+
ChevronDownIcon,
|
|
2743
|
+
{
|
|
2744
|
+
direction: collapsedSections[section.title] ? "right" : "down"
|
|
2745
|
+
}
|
|
2746
|
+
)
|
|
2659
2747
|
]
|
|
2660
2748
|
}
|
|
2661
2749
|
),
|
|
2662
2750
|
!collapsedSections[section.title] && section.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2663
2751
|
"div",
|
|
2664
2752
|
{
|
|
2665
|
-
className:
|
|
2753
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2666
2754
|
"flex items-center justify-between gap-3 rounded-lg p-3",
|
|
2667
2755
|
item.isExpired && "bg-secondary"
|
|
2668
2756
|
),
|
|
@@ -2676,7 +2764,7 @@ function LockedFundsView({ onBack }) {
|
|
|
2676
2764
|
] }),
|
|
2677
2765
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-xs", children: [
|
|
2678
2766
|
"Service: ",
|
|
2679
|
-
|
|
2767
|
+
chunkACLJPC75_cjs.shortenAddress(item.serviceAddress)
|
|
2680
2768
|
] })
|
|
2681
2769
|
] })
|
|
2682
2770
|
] }),
|
|
@@ -2717,7 +2805,7 @@ function BalanceTokenRow({ token }) {
|
|
|
2717
2805
|
const { balanceWei, isLoading } = useBalance({
|
|
2718
2806
|
tokenId: token.id
|
|
2719
2807
|
});
|
|
2720
|
-
const formattedBalance =
|
|
2808
|
+
const formattedBalance = chunkACLJPC75_cjs.formatTokenAmount(balanceWei, token.decimals);
|
|
2721
2809
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-2 rounded-lg px-3 py-2.5", children: [
|
|
2722
2810
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-[18px] w-[18px] overflow-hidden rounded-full", children: getTokenIcon(token.symbol, 18) }),
|
|
2723
2811
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground flex-1 text-sm", children: token.symbol }),
|
|
@@ -2725,7 +2813,7 @@ function BalanceTokenRow({ token }) {
|
|
|
2725
2813
|
] });
|
|
2726
2814
|
}
|
|
2727
2815
|
function BalanceDetailsView({ onBack }) {
|
|
2728
|
-
const { enabledTokens, chains } =
|
|
2816
|
+
const { enabledTokens, chains } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
2729
2817
|
const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
|
|
2730
2818
|
const chainTokens = react.useMemo(() => {
|
|
2731
2819
|
return enabledTokens.filter((t) => t.chainId === selectedChainId);
|
|
@@ -2737,7 +2825,7 @@ function BalanceDetailsView({ onBack }) {
|
|
|
2737
2825
|
{
|
|
2738
2826
|
onClick: onBack,
|
|
2739
2827
|
className: "text-muted-foreground hover:text-foreground -ml-2 flex h-6 w-6 cursor-pointer items-center justify-center transition-colors",
|
|
2740
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2828
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, {})
|
|
2741
2829
|
}
|
|
2742
2830
|
),
|
|
2743
2831
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-xl leading-6 font-medium", children: "Token Balances" })
|
|
@@ -2751,7 +2839,7 @@ function BalanceDetailsView({ onBack }) {
|
|
|
2751
2839
|
"button",
|
|
2752
2840
|
{
|
|
2753
2841
|
onClick: () => setSelectedChainId(chain.id),
|
|
2754
|
-
className:
|
|
2842
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2755
2843
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2756
2844
|
isSelected && "bg-secondary"
|
|
2757
2845
|
),
|
|
@@ -2792,12 +2880,12 @@ function TokenRow({
|
|
|
2792
2880
|
query: { enabled: !!address && !isNative }
|
|
2793
2881
|
});
|
|
2794
2882
|
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
2795
|
-
const formattedBalance = walletBalance ?
|
|
2883
|
+
const formattedBalance = walletBalance ? chunkACLJPC75_cjs.formatTokenAmount(walletBalance.toString(), token.decimals) : "0.00";
|
|
2796
2884
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2797
2885
|
"button",
|
|
2798
2886
|
{
|
|
2799
2887
|
onClick,
|
|
2800
|
-
className:
|
|
2888
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2801
2889
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2802
2890
|
isSelected && "bg-secondary"
|
|
2803
2891
|
),
|
|
@@ -2814,7 +2902,7 @@ function TokenSelectorView({
|
|
|
2814
2902
|
onSelect,
|
|
2815
2903
|
selectedTokenId
|
|
2816
2904
|
}) {
|
|
2817
|
-
const { enabledTokens, chains } =
|
|
2905
|
+
const { enabledTokens, chains } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
2818
2906
|
const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
|
|
2819
2907
|
const chainTokens = react.useMemo(() => {
|
|
2820
2908
|
return enabledTokens.filter((t) => t.chainId === selectedChainId);
|
|
@@ -2830,7 +2918,7 @@ function TokenSelectorView({
|
|
|
2830
2918
|
{
|
|
2831
2919
|
onClick: onBack,
|
|
2832
2920
|
className: "text-muted-foreground hover:text-foreground -ml-2 flex h-6 w-6 cursor-pointer items-center justify-center transition-colors",
|
|
2833
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2921
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, {})
|
|
2834
2922
|
}
|
|
2835
2923
|
),
|
|
2836
2924
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-xl leading-6 font-medium", children: "Select Token" })
|
|
@@ -2844,7 +2932,7 @@ function TokenSelectorView({
|
|
|
2844
2932
|
"button",
|
|
2845
2933
|
{
|
|
2846
2934
|
onClick: () => setSelectedChainId(chain.id),
|
|
2847
|
-
className:
|
|
2935
|
+
className: chunkACLJPC75_cjs.cn(
|
|
2848
2936
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2849
2937
|
isSelected && "bg-secondary"
|
|
2850
2938
|
),
|
|
@@ -2879,7 +2967,7 @@ function ModalBody({
|
|
|
2879
2967
|
defaultTab = "deposit",
|
|
2880
2968
|
onDepositSuccess
|
|
2881
2969
|
}) {
|
|
2882
|
-
const { defaultToken, tokensStatus } =
|
|
2970
|
+
const { defaultToken, tokensStatus } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
2883
2971
|
const [selectedToken, setSelectedToken] = react.useState(defaultToken);
|
|
2884
2972
|
const [activeTab, setActiveTab] = react.useState(defaultTab);
|
|
2885
2973
|
const [currentView, setCurrentView] = react.useState("main");
|
|
@@ -2937,7 +3025,7 @@ function ModalBody({
|
|
|
2937
3025
|
);
|
|
2938
3026
|
}
|
|
2939
3027
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 pb-4", children: [
|
|
2940
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
3028
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkACLJPC75_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2941
3029
|
BalanceCards,
|
|
2942
3030
|
{
|
|
2943
3031
|
selectedToken,
|
|
@@ -2947,7 +3035,7 @@ function ModalBody({
|
|
|
2947
3035
|
disabled: isInteractionPending
|
|
2948
3036
|
}
|
|
2949
3037
|
) }),
|
|
2950
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
3038
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkACLJPC75_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(Tabs, { activeTab, onTabChange: setActiveTab, disabled: isInteractionPending }) }),
|
|
2951
3039
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted rounded-[10px] p-5", children: activeTab === "deposit" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2952
3040
|
DepositForm,
|
|
2953
3041
|
{
|
|
@@ -3008,7 +3096,7 @@ function PrivanaModal({
|
|
|
3008
3096
|
onClick: handleClose,
|
|
3009
3097
|
disabled: isCloseBlocked,
|
|
3010
3098
|
"aria-label": "Close",
|
|
3011
|
-
className:
|
|
3099
|
+
className: chunkACLJPC75_cjs.cn(
|
|
3012
3100
|
"absolute top-6 right-5 z-20 flex h-6 w-6 items-center justify-center transition-colors",
|
|
3013
3101
|
isCloseBlocked ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
|
|
3014
3102
|
),
|
|
@@ -3064,7 +3152,7 @@ function PrivanaInlineModal({
|
|
|
3064
3152
|
"div",
|
|
3065
3153
|
{
|
|
3066
3154
|
"data-privana": true,
|
|
3067
|
-
className:
|
|
3155
|
+
className: chunkACLJPC75_cjs.cn(
|
|
3068
3156
|
"bg-card flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
3069
3157
|
className
|
|
3070
3158
|
),
|
|
@@ -3099,12 +3187,12 @@ function PrivanaButton({
|
|
|
3099
3187
|
}
|
|
3100
3188
|
const handleClick = () => setModalOpen(true);
|
|
3101
3189
|
const buttonElement = renderButton ? renderButton({ onClick: handleClick, isOpen: modalOpen }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3102
|
-
|
|
3190
|
+
chunkACLJPC75_cjs.Button,
|
|
3103
3191
|
{
|
|
3104
3192
|
variant,
|
|
3105
3193
|
size,
|
|
3106
3194
|
asChild,
|
|
3107
|
-
className:
|
|
3195
|
+
className: chunkACLJPC75_cjs.cn(className),
|
|
3108
3196
|
onClick: handleClick,
|
|
3109
3197
|
disabled: !isConnected,
|
|
3110
3198
|
...buttonProps,
|
|
@@ -3125,192 +3213,1794 @@ function PrivanaButton({
|
|
|
3125
3213
|
)
|
|
3126
3214
|
] });
|
|
3127
3215
|
}
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
});
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
});
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
}
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
}
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
})
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
}
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
});
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
});
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
}
|
|
3241
|
-
|
|
3216
|
+
var DEFAULT_MOONPAY_API_URL = "https://api.moonpay.com/v3";
|
|
3217
|
+
function useMoonpayLimits({
|
|
3218
|
+
currencyCode,
|
|
3219
|
+
baseCurrencyCode = "usd",
|
|
3220
|
+
paymentMethod = "credit_debit_card",
|
|
3221
|
+
apiBaseUrl = DEFAULT_MOONPAY_API_URL,
|
|
3222
|
+
enabled = true
|
|
3223
|
+
}) {
|
|
3224
|
+
const { apiKey } = react.useContext(moonpayReact.MoonPayContext) ?? {};
|
|
3225
|
+
const canFetch = enabled && !!apiKey && !!currencyCode;
|
|
3226
|
+
const query = reactQuery.useQuery({
|
|
3227
|
+
queryKey: ["moonpay-limits", apiBaseUrl, currencyCode, baseCurrencyCode, paymentMethod, apiKey],
|
|
3228
|
+
enabled: canFetch,
|
|
3229
|
+
staleTime: 5 * 6e4,
|
|
3230
|
+
queryFn: async () => {
|
|
3231
|
+
const params = new URLSearchParams({
|
|
3232
|
+
apiKey,
|
|
3233
|
+
baseCurrencyCode,
|
|
3234
|
+
paymentMethod,
|
|
3235
|
+
areFeesIncluded: "true"
|
|
3236
|
+
});
|
|
3237
|
+
const res = await fetch(
|
|
3238
|
+
`${apiBaseUrl}/currencies/${currencyCode}/limits?${params.toString()}`
|
|
3239
|
+
);
|
|
3240
|
+
if (!res.ok) {
|
|
3241
|
+
throw new Error(`MoonPay limits request failed: ${res.status}`);
|
|
3242
|
+
}
|
|
3243
|
+
const data = await res.json();
|
|
3244
|
+
const asNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
3245
|
+
return {
|
|
3246
|
+
minBuyAmount: asNumber(data.baseCurrency?.minBuyAmount),
|
|
3247
|
+
maxBuyAmount: asNumber(data.baseCurrency?.maxBuyAmount)
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3250
|
+
});
|
|
3251
|
+
return {
|
|
3252
|
+
minBuyAmount: query.data?.minBuyAmount,
|
|
3253
|
+
maxBuyAmount: query.data?.maxBuyAmount,
|
|
3254
|
+
isLoading: query.isLoading,
|
|
3255
|
+
error: query.error ?? null
|
|
3256
|
+
};
|
|
3257
|
+
}
|
|
3258
|
+
function TokenSelectorView2({ selectedTokenId, onSelect }) {
|
|
3259
|
+
const { enabledTokens } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
3260
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col rounded-[10px] p-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex max-h-72 flex-col gap-1 overflow-y-auto", children: [
|
|
3261
|
+
enabledTokens.map((token) => {
|
|
3262
|
+
const isSelected = selectedTokenId === token.id;
|
|
3263
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3264
|
+
"button",
|
|
3265
|
+
{
|
|
3266
|
+
type: "button",
|
|
3267
|
+
onClick: () => onSelect(token.id),
|
|
3268
|
+
className: chunkACLJPC75_cjs.cn(
|
|
3269
|
+
"hover:bg-secondary flex w-full cursor-pointer items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors",
|
|
3270
|
+
isSelected && "bg-secondary"
|
|
3271
|
+
),
|
|
3272
|
+
children: [
|
|
3273
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-6 w-6 shrink-0 overflow-hidden rounded-full", children: getTokenIcon(token.symbol, 24) }),
|
|
3274
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
3275
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-foreground text-sm font-medium", children: token.symbol }),
|
|
3276
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground text-[11px]", children: token.name })
|
|
3277
|
+
] }),
|
|
3278
|
+
isSelected && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-primary flex h-4 w-4 shrink-0 items-center justify-center rounded-full", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3279
|
+
"svg",
|
|
3280
|
+
{
|
|
3281
|
+
width: "10",
|
|
3282
|
+
height: "10",
|
|
3283
|
+
viewBox: "0 0 10 10",
|
|
3284
|
+
fill: "none",
|
|
3285
|
+
className: "text-primary-foreground",
|
|
3286
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3287
|
+
"path",
|
|
3288
|
+
{
|
|
3289
|
+
d: "M2 5L4 7L8 3",
|
|
3290
|
+
stroke: "currentColor",
|
|
3291
|
+
strokeWidth: "1.5",
|
|
3292
|
+
strokeLinecap: "round",
|
|
3293
|
+
strokeLinejoin: "round"
|
|
3294
|
+
}
|
|
3295
|
+
)
|
|
3296
|
+
}
|
|
3297
|
+
) })
|
|
3298
|
+
]
|
|
3299
|
+
},
|
|
3300
|
+
token.id
|
|
3301
|
+
);
|
|
3302
|
+
}),
|
|
3303
|
+
enabledTokens.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground px-3 py-6 text-center text-sm", children: "No tokens available" })
|
|
3304
|
+
] }) });
|
|
3305
|
+
}
|
|
3306
|
+
function CreditCardWidgetView({
|
|
3307
|
+
token,
|
|
3308
|
+
amount,
|
|
3309
|
+
allowance
|
|
3310
|
+
}) {
|
|
3311
|
+
const moonpayCurrencyCode = token?.moonpayCurrencyCode;
|
|
3312
|
+
const containerRef = react.useRef(null);
|
|
3313
|
+
const [widgetTheme, setWidgetTheme] = react.useState();
|
|
3314
|
+
react.useEffect(() => {
|
|
3315
|
+
if (containerRef.current) setWidgetTheme(resolveSdkTheme(containerRef.current));
|
|
3316
|
+
}, []);
|
|
3317
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
|
|
3318
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: "Complete your purchase" }),
|
|
3319
|
+
token && moonpayCurrencyCode ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3320
|
+
chunkACLJPC75_cjs.FiatOnRampForm,
|
|
3321
|
+
{
|
|
3322
|
+
tokenId: token.id,
|
|
3323
|
+
currencyCode: moonpayCurrencyCode,
|
|
3324
|
+
defaultBaseCurrencyAmount: amount || void 0,
|
|
3325
|
+
variant: "embedded",
|
|
3326
|
+
autoStart: true,
|
|
3327
|
+
theme: widgetTheme
|
|
3328
|
+
}
|
|
3329
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground text-sm", children: [
|
|
3330
|
+
token?.symbol ?? "This token",
|
|
3331
|
+
" isn\u2019t available for card purchases yet."
|
|
3332
|
+
] })
|
|
3333
|
+
] });
|
|
3334
|
+
}
|
|
3335
|
+
function resolveSdkTheme(el) {
|
|
3336
|
+
const scheme = getComputedStyle(el).colorScheme;
|
|
3337
|
+
if (scheme === "dark") return "dark";
|
|
3338
|
+
if (scheme === "light") return "light";
|
|
3339
|
+
return el.closest(".dark") ? "dark" : "light";
|
|
3340
|
+
}
|
|
3341
|
+
function PrivanaIcon({ className, size = 32 }) {
|
|
3342
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3343
|
+
"svg",
|
|
3344
|
+
{
|
|
3345
|
+
width: size,
|
|
3346
|
+
height: size,
|
|
3347
|
+
viewBox: "0 0 32 32",
|
|
3348
|
+
fill: "none",
|
|
3349
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3350
|
+
className,
|
|
3351
|
+
children: [
|
|
3352
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "32", height: "32", rx: "3.55556", fill: "black" }),
|
|
3353
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3354
|
+
"path",
|
|
3355
|
+
{
|
|
3356
|
+
d: "M9.02789 9.05299L9.20884 7.82227H15.6221L16.1099 7.82683L16.5817 7.83825L17.0398 7.85652L17.4842 7.88163L17.9125 7.91588L18.3271 7.95698L18.7256 8.00722L19.1104 8.06202L19.4814 8.12595L19.8823 8.20815L20.2602 8.2972L20.6175 8.39538L20.9542 8.50042L21.2703 8.61687L21.5657 8.74017L21.8406 8.8726L22.0948 9.01645L22.1521 9.05299H9.02789ZM9.02789 12.0784L9.20884 10.8477H21.9505L22.1177 10.955L22.317 11.1057L22.4934 11.2633L22.6445 11.4322L22.7705 11.608L22.8713 11.793L22.9491 11.9871L22.9721 12.0784H9.02789ZM15.8167 11.0372H13.1369L13.0843 12.0784H18.8447L18.8264 12.0213L18.7645 11.9072L18.6844 11.7976L18.5836 11.6948L18.4645 11.6012L18.3271 11.5121L18.1736 11.4299L18.0041 11.3569L17.8209 11.2907L17.6193 11.2313L17.404 11.1811L17.1727 11.1354L16.9276 11.1011L16.6711 11.0737L16.3985 11.0532L16.1145 11.0418L15.8167 11.0372ZM9.02789 15.1038L9.20884 13.8731H22.7453L22.7728 13.9759L22.8003 14.1334L22.8232 14.3252L22.8163 14.5102L22.7819 14.6905L22.7178 14.8664L22.6239 15.0376L22.5735 15.1038H9.02789ZM13.1484 13.8731L13.0843 15.1038H17.5323L17.6674 15.0696L17.8644 15.0079L18.043 14.9372L18.2034 14.8618L18.3454 14.7796L18.4691 14.6883L18.5744 14.5946L18.6569 14.4942L18.721 14.3914L18.7622 14.2841L18.7828 14.1722V14.0558L18.7622 13.9348L18.7416 13.8731H13.1484ZM9.02789 18.1293L9.20884 16.8985H22.3605L22.2895 16.9899L22.1406 17.1406L21.9643 17.2867L21.7581 17.426L21.5268 17.5561L21.2703 17.6817L20.9862 17.7982L20.6747 17.9055L20.3381 18.006L19.9739 18.0996L19.8387 18.1293H9.02789ZM13.1484 16.8985L13.1392 17.0629H15.8144L16.1145 17.0607L16.3985 17.047L16.6665 17.0264L16.9207 16.999L17.1612 16.9625L17.388 16.9168L17.4658 16.8985H13.1484ZM9.02789 21.1547L9.20884 19.9217H19.7036L19.4562 19.9742L19.0989 20.0381L18.7256 20.0952L18.3316 20.1432L17.9239 20.1843L17.4956 20.2185L17.0536 20.2459L16.5932 20.2642L16.1168 20.2756L15.6243 20.2802H13.1301L13.0843 21.1547H9.02789ZM13.0843 24.1778H9.02789L9.20884 22.9471H13.1484L13.0843 24.1778Z",
|
|
3357
|
+
fill: "white"
|
|
3358
|
+
}
|
|
3359
|
+
)
|
|
3360
|
+
]
|
|
3361
|
+
}
|
|
3362
|
+
);
|
|
3363
|
+
}
|
|
3364
|
+
function PolicyTermRow({
|
|
3365
|
+
term,
|
|
3366
|
+
kind
|
|
3367
|
+
}) {
|
|
3368
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
|
|
3369
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3370
|
+
"div",
|
|
3371
|
+
{
|
|
3372
|
+
className: chunkACLJPC75_cjs.cn(
|
|
3373
|
+
"mt-0.5 shrink-0",
|
|
3374
|
+
kind === "permission" ? "text-emerald-500" : "text-orange-500"
|
|
3375
|
+
),
|
|
3376
|
+
children: kind === "permission" ? /* @__PURE__ */ jsxRuntime.jsx(CircleCheckIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(CircleXIcon, {})
|
|
3377
|
+
}
|
|
3378
|
+
),
|
|
3379
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
3380
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-sm leading-5 font-medium", children: term.title }),
|
|
3381
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm leading-5", children: term.description })
|
|
3382
|
+
] })
|
|
3383
|
+
] });
|
|
3384
|
+
}
|
|
3385
|
+
function AllowancePolicySection({
|
|
3386
|
+
allowance,
|
|
3387
|
+
serviceName,
|
|
3388
|
+
serviceIcon
|
|
3389
|
+
}) {
|
|
3390
|
+
const [collapsed, setCollapsed] = react.useState(false);
|
|
3391
|
+
const permissions = allowance.terms?.permissions ?? [];
|
|
3392
|
+
const restrictions = allowance.terms?.restrictions ?? [];
|
|
3393
|
+
const hasTerms = permissions.length > 0 || restrictions.length > 0;
|
|
3394
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
3395
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
3396
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-8 w-8 items-center justify-center overflow-hidden rounded-lg", children: serviceIcon }),
|
|
3397
|
+
/* @__PURE__ */ jsxRuntime.jsx(ArrowRightIcon, { className: "text-muted-foreground" }),
|
|
3398
|
+
/* @__PURE__ */ jsxRuntime.jsx(PrivanaIcon, { size: 32 })
|
|
3399
|
+
] }),
|
|
3400
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm leading-5", children: [
|
|
3401
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground font-medium", children: serviceName }),
|
|
3402
|
+
" ",
|
|
3403
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "wants a policy on your Privana account." })
|
|
3404
|
+
] }),
|
|
3405
|
+
hasTerms && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3406
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3407
|
+
"button",
|
|
3408
|
+
{
|
|
3409
|
+
type: "button",
|
|
3410
|
+
onClick: () => setCollapsed((prev) => !prev),
|
|
3411
|
+
className: "flex w-full cursor-pointer items-center gap-2",
|
|
3412
|
+
children: [
|
|
3413
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-border h-px flex-1" }),
|
|
3414
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-[10px] leading-[14px] font-medium tracking-[0.2px] whitespace-nowrap uppercase", children: collapsed ? "Show details" : "Hide details" }),
|
|
3415
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3416
|
+
ChevronDownIcon,
|
|
3417
|
+
{
|
|
3418
|
+
direction: collapsed ? "down" : "up",
|
|
3419
|
+
className: "text-foreground shrink-0"
|
|
3420
|
+
}
|
|
3421
|
+
),
|
|
3422
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-border h-px flex-1" })
|
|
3423
|
+
]
|
|
3424
|
+
}
|
|
3425
|
+
),
|
|
3426
|
+
!collapsed && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
3427
|
+
permissions.map((term, i) => /* @__PURE__ */ jsxRuntime.jsx(PolicyTermRow, { term, kind: "permission" }, `permission-${i}`)),
|
|
3428
|
+
restrictions.map((term, i) => /* @__PURE__ */ jsxRuntime.jsx(PolicyTermRow, { term, kind: "restriction" }, `restriction-${i}`))
|
|
3429
|
+
] })
|
|
3430
|
+
] })
|
|
3431
|
+
] });
|
|
3432
|
+
}
|
|
3433
|
+
function MoonPayGate({ enabled, children }) {
|
|
3434
|
+
const { networkConfig } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
3435
|
+
const apiKey = networkConfig.moonpayApiKey;
|
|
3436
|
+
if (!enabled || !apiKey) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
3437
|
+
return /* @__PURE__ */ jsxRuntime.jsx(moonpayReact.MoonPayProvider, { apiKey, children });
|
|
3438
|
+
}
|
|
3439
|
+
function MethodTabs({
|
|
3440
|
+
activeTab,
|
|
3441
|
+
onTabChange
|
|
3442
|
+
}) {
|
|
3443
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-secondary relative flex gap-2 overflow-hidden rounded-[10px] p-1", children: [
|
|
3444
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3445
|
+
"div",
|
|
3446
|
+
{
|
|
3447
|
+
className: chunkACLJPC75_cjs.cn(
|
|
3448
|
+
"bg-input absolute top-1 bottom-1 left-1 w-[calc(50%-8px)] rounded-md transition-transform duration-200",
|
|
3449
|
+
activeTab === "credit-card" && "translate-x-[calc(100%+8px)]"
|
|
3450
|
+
)
|
|
3451
|
+
}
|
|
3452
|
+
),
|
|
3453
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3454
|
+
"button",
|
|
3455
|
+
{
|
|
3456
|
+
type: "button",
|
|
3457
|
+
onClick: () => onTabChange("crypto"),
|
|
3458
|
+
className: chunkACLJPC75_cjs.cn(
|
|
3459
|
+
"relative z-10 flex-1 cursor-pointer rounded-md px-3 py-[9px] text-sm font-medium transition-colors",
|
|
3460
|
+
activeTab === "crypto" ? "text-foreground" : "text-muted-foreground"
|
|
3461
|
+
),
|
|
3462
|
+
children: "Crypto"
|
|
3463
|
+
}
|
|
3464
|
+
),
|
|
3465
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3466
|
+
"button",
|
|
3467
|
+
{
|
|
3468
|
+
type: "button",
|
|
3469
|
+
onClick: () => onTabChange("credit-card"),
|
|
3470
|
+
className: chunkACLJPC75_cjs.cn(
|
|
3471
|
+
"relative z-10 flex-1 cursor-pointer rounded-md px-3 py-[9px] text-sm font-medium transition-colors",
|
|
3472
|
+
activeTab === "credit-card" ? "text-foreground" : "text-muted-foreground"
|
|
3473
|
+
),
|
|
3474
|
+
children: "Credit Card"
|
|
3475
|
+
}
|
|
3476
|
+
)
|
|
3477
|
+
] });
|
|
3478
|
+
}
|
|
3479
|
+
function MethodOption({
|
|
3480
|
+
title,
|
|
3481
|
+
description,
|
|
3482
|
+
onClick
|
|
3483
|
+
}) {
|
|
3484
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3485
|
+
"button",
|
|
3486
|
+
{
|
|
3487
|
+
type: "button",
|
|
3488
|
+
onClick,
|
|
3489
|
+
className: "bg-input hover:bg-input/70 border-border flex w-full cursor-pointer items-center gap-3 rounded-lg border p-3 text-left transition-colors",
|
|
3490
|
+
children: [
|
|
3491
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3492
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-sm leading-[14px] font-medium", children: title }),
|
|
3493
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs leading-3", children: description })
|
|
3494
|
+
] }),
|
|
3495
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground flex h-5 w-5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, {}) })
|
|
3496
|
+
]
|
|
3497
|
+
}
|
|
3498
|
+
);
|
|
3499
|
+
}
|
|
3500
|
+
function DepositView({
|
|
3501
|
+
source,
|
|
3502
|
+
selectedToken,
|
|
3503
|
+
amount,
|
|
3504
|
+
allowance,
|
|
3505
|
+
onAmountChange,
|
|
3506
|
+
onSelectToken,
|
|
3507
|
+
onConnectWallet,
|
|
3508
|
+
onSubmit,
|
|
3509
|
+
isSubmitting = false
|
|
3510
|
+
}) {
|
|
3511
|
+
const { getChainById: getChainById2, chains, serviceName, serviceIcon, networkConfig } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
3512
|
+
const { address, isConnected } = wagmi.useAccount();
|
|
3513
|
+
const appName = serviceName ?? "Privana";
|
|
3514
|
+
const chain = selectedToken ? getChainById2(selectedToken.chainId) : void 0;
|
|
3515
|
+
const targetChain = chain ?? chains[0];
|
|
3516
|
+
const sourceLabel = source === "connected" ? "Connected Wallet" : "External Wallet";
|
|
3517
|
+
const isConnectedSource = source === "connected";
|
|
3518
|
+
const isCreditCard = source === "credit-card";
|
|
3519
|
+
const isNative = selectedToken?.contract === viem.zeroAddress;
|
|
3520
|
+
const { data: nativeBalanceData } = wagmi.useBalance({
|
|
3521
|
+
address,
|
|
3522
|
+
chainId: targetChain?.id,
|
|
3523
|
+
query: { enabled: isConnectedSource && !!address && !!selectedToken && isNative }
|
|
3524
|
+
});
|
|
3525
|
+
const { data: erc20Balance } = wagmi.useReadContract({
|
|
3526
|
+
address: selectedToken?.contract,
|
|
3527
|
+
abi: viem.erc20Abi,
|
|
3528
|
+
functionName: "balanceOf",
|
|
3529
|
+
args: address ? [address] : void 0,
|
|
3530
|
+
chainId: targetChain?.id,
|
|
3531
|
+
query: { enabled: isConnectedSource && !!address && !!selectedToken && !isNative }
|
|
3532
|
+
});
|
|
3533
|
+
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
3534
|
+
const formattedWalletBalance = walletBalance != null && selectedToken ? chunkACLJPC75_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
|
|
3535
|
+
const {
|
|
3536
|
+
minBuyAmount: moonpayMinBuy,
|
|
3537
|
+
isLoading: moonpayLimitsLoading,
|
|
3538
|
+
error: moonpayLimitsError
|
|
3539
|
+
} = useMoonpayLimits({
|
|
3540
|
+
currencyCode: selectedToken?.moonpayCurrencyCode,
|
|
3541
|
+
apiBaseUrl: networkConfig.moonpayApiUrl,
|
|
3542
|
+
enabled: isCreditCard
|
|
3543
|
+
});
|
|
3544
|
+
const hasValidAmount = !!amount && parseFloat(amount) > 0;
|
|
3545
|
+
const maxAmountDecimals = isCreditCard ? 2 : selectedToken?.decimals;
|
|
3546
|
+
const tooManyDecimals = hasValidAmount && maxAmountDecimals != null && amount.includes(".") && amount.split(".")[1].length > maxAmountDecimals;
|
|
3547
|
+
const exceedsBalance = isConnectedSource && hasValidAmount && !tooManyDecimals && !!selectedToken && walletBalance != null && chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
|
|
3548
|
+
const belowMoonpayMin = isCreditCard && hasValidAmount && moonpayMinBuy != null && parseFloat(amount) < moonpayMinBuy;
|
|
3549
|
+
const moonpayLimitsUnready = isCreditCard && !!selectedToken?.moonpayCurrencyCode && moonpayMinBuy == null;
|
|
3550
|
+
const creditCardUnavailable = isCreditCard && !!selectedToken && !selectedToken.moonpayCurrencyCode;
|
|
3551
|
+
const needsConnect = isConnectedSource && !isConnected;
|
|
3552
|
+
const canDeposit = hasValidAmount && !!selectedToken && !tooManyDecimals && !exceedsBalance && !belowMoonpayMin && !moonpayLimitsUnready && !creditCardUnavailable && !needsConnect;
|
|
3553
|
+
const handleMax = () => {
|
|
3554
|
+
const max = formattedWalletBalance.replace(/\s/g, "");
|
|
3555
|
+
if (parseFloat(max) > 0) onAmountChange(max);
|
|
3556
|
+
};
|
|
3557
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
|
|
3558
|
+
isCreditCard ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3559
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: "Buy with credit card and deposit" }),
|
|
3560
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Enter your deposit amount and proceed to sign a policy." })
|
|
3561
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: [
|
|
3562
|
+
"Deposit from ",
|
|
3563
|
+
sourceLabel
|
|
3564
|
+
] }),
|
|
3565
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
3566
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-muted-foreground text-sm", children: "Token" }),
|
|
3567
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3568
|
+
"button",
|
|
3569
|
+
{
|
|
3570
|
+
type: "button",
|
|
3571
|
+
onClick: onSelectToken,
|
|
3572
|
+
className: "border-border bg-input flex w-full cursor-pointer items-center gap-3 rounded-lg border p-3 text-left",
|
|
3573
|
+
children: [
|
|
3574
|
+
selectedToken ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3575
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 w-8 shrink-0 overflow-hidden rounded-full", children: getTokenIcon(selectedToken.symbol, 32) }),
|
|
3576
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col items-start gap-1", children: [
|
|
3577
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-sm font-medium", children: selectedToken.symbol }),
|
|
3578
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-xs", children: [
|
|
3579
|
+
"on ",
|
|
3580
|
+
chain?.name ?? "\u2014"
|
|
3581
|
+
] })
|
|
3582
|
+
] })
|
|
3583
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground flex-1 text-sm", children: "Select token" }),
|
|
3584
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground flex h-5 w-5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, {}) })
|
|
3585
|
+
]
|
|
3586
|
+
}
|
|
3587
|
+
)
|
|
3588
|
+
] }),
|
|
3589
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
3590
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
3591
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-muted-foreground text-sm", children: "Amount" }),
|
|
3592
|
+
isConnectedSource && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-sm", children: [
|
|
3593
|
+
"Available ",
|
|
3594
|
+
formattedWalletBalance,
|
|
3595
|
+
" ",
|
|
3596
|
+
selectedToken?.symbol
|
|
3597
|
+
] })
|
|
3598
|
+
] }),
|
|
3599
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3600
|
+
"div",
|
|
3601
|
+
{
|
|
3602
|
+
className: chunkACLJPC75_cjs.cn(
|
|
3603
|
+
"border-border bg-input flex items-center gap-2 rounded-[10px] border",
|
|
3604
|
+
isConnectedSource ? "py-1 pr-1 pl-3" : "px-3 py-3"
|
|
3605
|
+
),
|
|
3606
|
+
children: [
|
|
3607
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3608
|
+
"input",
|
|
3609
|
+
{
|
|
3610
|
+
type: "text",
|
|
3611
|
+
inputMode: "decimal",
|
|
3612
|
+
placeholder: "Enter Amount",
|
|
3613
|
+
value: amount,
|
|
3614
|
+
onChange: (e) => {
|
|
3615
|
+
const value = e.target.value.replace(/[^0-9.,]/g, "").replace(/,/g, ".");
|
|
3616
|
+
if (value.split(".").length <= 2) onAmountChange(value);
|
|
3617
|
+
},
|
|
3618
|
+
className: "text-foreground placeholder:text-muted-foreground/50 flex-1 bg-transparent text-sm outline-none"
|
|
3619
|
+
}
|
|
3620
|
+
),
|
|
3621
|
+
isConnectedSource ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3622
|
+
"button",
|
|
3623
|
+
{
|
|
3624
|
+
type: "button",
|
|
3625
|
+
onClick: handleMax,
|
|
3626
|
+
className: "bg-secondary text-foreground hover:bg-secondary/80 cursor-pointer rounded px-3 py-2.5 text-xs font-semibold transition-colors",
|
|
3627
|
+
children: "MAX"
|
|
3628
|
+
}
|
|
3629
|
+
) : isCreditCard ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "USD" }) : selectedToken && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: selectedToken.symbol })
|
|
3630
|
+
]
|
|
3631
|
+
}
|
|
3632
|
+
),
|
|
3633
|
+
tooManyDecimals && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-destructive text-sm", children: [
|
|
3634
|
+
"Too many decimal places (max: ",
|
|
3635
|
+
maxAmountDecimals,
|
|
3636
|
+
")"
|
|
3637
|
+
] }),
|
|
3638
|
+
exceedsBalance && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-destructive text-sm", children: "Insufficient balance" }),
|
|
3639
|
+
belowMoonpayMin && moonpayMinBuy != null && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-destructive text-sm", children: [
|
|
3640
|
+
"Minimum purchase is $",
|
|
3641
|
+
moonpayMinBuy,
|
|
3642
|
+
" USD."
|
|
3643
|
+
] }),
|
|
3644
|
+
isCreditCard && moonpayLimitsError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-destructive text-sm", children: "Couldn\u2019t load purchase limits. Please try again." }),
|
|
3645
|
+
isCreditCard && moonpayLimitsLoading && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Checking purchase limits\u2026" }),
|
|
3646
|
+
creditCardUnavailable && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-destructive text-sm", children: [
|
|
3647
|
+
selectedToken?.symbol ?? "This token",
|
|
3648
|
+
" isn\u2019t available for card purchases yet."
|
|
3649
|
+
] })
|
|
3650
|
+
] }),
|
|
3651
|
+
allowance && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3652
|
+
AllowancePolicySection,
|
|
3653
|
+
{
|
|
3654
|
+
allowance,
|
|
3655
|
+
serviceName: appName,
|
|
3656
|
+
serviceIcon
|
|
3657
|
+
}
|
|
3658
|
+
),
|
|
3659
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3660
|
+
"button",
|
|
3661
|
+
{
|
|
3662
|
+
type: "button",
|
|
3663
|
+
disabled: needsConnect ? !onConnectWallet : !canDeposit || isSubmitting,
|
|
3664
|
+
onClick: () => {
|
|
3665
|
+
if (needsConnect) {
|
|
3666
|
+
onConnectWallet?.();
|
|
3667
|
+
return;
|
|
3668
|
+
}
|
|
3669
|
+
if (selectedToken) onSubmit({ source, tokenId: selectedToken.id, amount });
|
|
3670
|
+
},
|
|
3671
|
+
className: "bg-primary text-primary-foreground hover:bg-primary/90 flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
|
|
3672
|
+
children: needsConnect ? "Connect Wallet" : allowance ? "Sign Policy and Deposit" : "Deposit"
|
|
3673
|
+
}
|
|
3674
|
+
)
|
|
3675
|
+
] });
|
|
3676
|
+
}
|
|
3677
|
+
function SummaryRow({ value, label }) {
|
|
3678
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm leading-5", children: [
|
|
3679
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground font-medium", children: value }),
|
|
3680
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: label })
|
|
3681
|
+
] });
|
|
3682
|
+
}
|
|
3683
|
+
function ExternalDepositView({
|
|
3684
|
+
token,
|
|
3685
|
+
amount
|
|
3686
|
+
}) {
|
|
3687
|
+
const { getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
3688
|
+
const { depositAddress, isReady, isLoading } = useDepositAddress();
|
|
3689
|
+
const chain = token ? getChainById2(token.chainId) : void 0;
|
|
3690
|
+
const [copied, setCopied] = react.useState(false);
|
|
3691
|
+
const handleCopy = () => {
|
|
3692
|
+
if (!depositAddress) return;
|
|
3693
|
+
void navigator.clipboard.writeText(depositAddress);
|
|
3694
|
+
setCopied(true);
|
|
3695
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
3696
|
+
};
|
|
3697
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
|
|
3698
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3699
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: "Deposit from an External Wallet" }),
|
|
3700
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Transfer crypto from external wallet or exchange." })
|
|
3701
|
+
] }),
|
|
3702
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3703
|
+
/* @__PURE__ */ jsxRuntime.jsx(SummaryRow, { value: chain?.name ?? "\u2014", label: "Chain" }),
|
|
3704
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-border h-px w-full" }),
|
|
3705
|
+
/* @__PURE__ */ jsxRuntime.jsx(SummaryRow, { value: token?.symbol ?? "\u2014", label: "Currency" }),
|
|
3706
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-border h-px w-full" }),
|
|
3707
|
+
/* @__PURE__ */ jsxRuntime.jsx(SummaryRow, { value: amount || "\u2014", label: "Value" })
|
|
3708
|
+
] }),
|
|
3709
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-secondary flex h-50 items-center justify-center rounded-[10px]", children: !isReady ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground px-6 text-center text-sm", children: "Connect your wallet to generate a deposit address." }) : depositAddress ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-[10px] bg-white p-3", children: /* @__PURE__ */ jsxRuntime.jsx(qrcode_react.QRCodeSVG, { value: depositAddress, size: 160 }) }) : isLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunkACLJPC75_cjs.Skeleton, { className: "h-full w-full rounded-[10px]" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Deposit address unavailable" }) }),
|
|
3710
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
3711
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Deposit Address" }),
|
|
3712
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
3713
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-border flex h-10 min-w-0 flex-1 items-center rounded-[10px] border px-3", children: depositAddress ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-foreground min-w-0 flex-1 truncate text-sm", children: depositAddress }) : isReady && isLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunkACLJPC75_cjs.Skeleton, { className: "h-4 w-3/4" }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "\u2014" }) }),
|
|
3714
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3715
|
+
"button",
|
|
3716
|
+
{
|
|
3717
|
+
type: "button",
|
|
3718
|
+
onClick: handleCopy,
|
|
3719
|
+
disabled: !depositAddress,
|
|
3720
|
+
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",
|
|
3721
|
+
children: [
|
|
3722
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyIcon, {}),
|
|
3723
|
+
copied ? "Copied" : "Copy"
|
|
3724
|
+
]
|
|
3725
|
+
}
|
|
3726
|
+
)
|
|
3727
|
+
] })
|
|
3728
|
+
] })
|
|
3729
|
+
] });
|
|
3730
|
+
}
|
|
3731
|
+
function DepositModalContent({
|
|
3732
|
+
defaultTab = "crypto",
|
|
3733
|
+
allowance,
|
|
3734
|
+
onSelectConnectedWallet,
|
|
3735
|
+
onSelectExternalWallet,
|
|
3736
|
+
onSelectCreditCard,
|
|
3737
|
+
onConnectWallet,
|
|
3738
|
+
onDeposit,
|
|
3739
|
+
onDepositSuccess,
|
|
3740
|
+
onClose,
|
|
3741
|
+
onCloseBlockedChange,
|
|
3742
|
+
onExit
|
|
3743
|
+
}) {
|
|
3744
|
+
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig, getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
3745
|
+
const { address } = wagmi.useAccount();
|
|
3746
|
+
const appName = serviceName ?? "Privana";
|
|
3747
|
+
const [activeTab, setActiveTab] = react.useState(defaultTab);
|
|
3748
|
+
const [view, setView] = react.useState("method");
|
|
3749
|
+
const [source, setSource] = react.useState("connected");
|
|
3750
|
+
const [selectedTokenId, setSelectedTokenId] = react.useState(defaultToken?.id ?? "");
|
|
3751
|
+
const [amount, setAmount] = react.useState("");
|
|
3752
|
+
const selectedToken = enabledTokens.find((t) => t.id === selectedTokenId) ?? defaultToken;
|
|
3753
|
+
const prevAddressRef = react.useRef(address);
|
|
3754
|
+
react.useEffect(() => {
|
|
3755
|
+
const prev = prevAddressRef.current;
|
|
3756
|
+
prevAddressRef.current = address;
|
|
3757
|
+
if (hostedAuthConfig) return;
|
|
3758
|
+
if (prev && address && prev !== address) {
|
|
3759
|
+
setView("method");
|
|
3760
|
+
setAmount("");
|
|
3761
|
+
setSelectedTokenId("");
|
|
3762
|
+
}
|
|
3763
|
+
}, [address, hostedAuthConfig]);
|
|
3764
|
+
const openDeposit = (next) => {
|
|
3765
|
+
setSource(next);
|
|
3766
|
+
setView("deposit");
|
|
3767
|
+
};
|
|
3768
|
+
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
3769
|
+
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
3770
|
+
const [cancelled, setCancelled] = react.useState(false);
|
|
3771
|
+
const {
|
|
3772
|
+
txHash,
|
|
3773
|
+
isGettingAddress,
|
|
3774
|
+
isSwitchingChain,
|
|
3775
|
+
isSendingTransaction,
|
|
3776
|
+
isWaitingForConfirmation,
|
|
3777
|
+
isWaitingForProcessing,
|
|
3778
|
+
verificationFailed,
|
|
3779
|
+
isPending,
|
|
3780
|
+
error: depositError,
|
|
3781
|
+
deposit,
|
|
3782
|
+
retryVerification,
|
|
3783
|
+
reset: resetDeposit
|
|
3784
|
+
} = useDeposit({
|
|
3785
|
+
onCredited: () => {
|
|
3786
|
+
setAmount("");
|
|
3787
|
+
if (onDepositSuccess) {
|
|
3788
|
+
resetDeposit();
|
|
3789
|
+
onDepositSuccess();
|
|
3790
|
+
} else {
|
|
3791
|
+
setShowSuccess(true);
|
|
3792
|
+
}
|
|
3793
|
+
},
|
|
3794
|
+
onCheckTimeout: () => {
|
|
3795
|
+
setAmount("");
|
|
3796
|
+
setShowTimeout(true);
|
|
3797
|
+
}
|
|
3798
|
+
});
|
|
3799
|
+
const isUnsafeToClose = (isGettingAddress || isSendingTransaction) && !cancelled;
|
|
3800
|
+
react.useEffect(() => {
|
|
3801
|
+
onCloseBlockedChange?.(isUnsafeToClose);
|
|
3802
|
+
}, [isUnsafeToClose, onCloseBlockedChange]);
|
|
3803
|
+
react.useEffect(() => {
|
|
3804
|
+
if (depositError && !verificationFailed) {
|
|
3805
|
+
sonner.toast.error(
|
|
3806
|
+
depositError.message.length > 100 ? `${depositError.message.slice(0, 100)}...` : depositError.message
|
|
3807
|
+
);
|
|
3808
|
+
}
|
|
3809
|
+
}, [depositError, verificationFailed]);
|
|
3810
|
+
const handleSubmit = (args) => {
|
|
3811
|
+
if (args.source === "external") {
|
|
3812
|
+
setView("external-deposit");
|
|
3813
|
+
return;
|
|
3814
|
+
}
|
|
3815
|
+
if (args.source === "credit-card") {
|
|
3816
|
+
setView("credit-card-widget");
|
|
3817
|
+
return;
|
|
3818
|
+
}
|
|
3819
|
+
const token = enabledTokens.find((t) => t.id === args.tokenId);
|
|
3820
|
+
if (!token) return;
|
|
3821
|
+
onDeposit?.(args);
|
|
3822
|
+
setCancelled(false);
|
|
3823
|
+
deposit({
|
|
3824
|
+
tokenId: token.id,
|
|
3825
|
+
amount: chunkACLJPC75_cjs.parseTokenAmount(args.amount, token.decimals)
|
|
3826
|
+
}).catch((err) => {
|
|
3827
|
+
sonner.toast.error(err instanceof Error ? err.message : "Deposit failed");
|
|
3828
|
+
});
|
|
3829
|
+
};
|
|
3830
|
+
const targetChain = selectedToken ? getChainById2(selectedToken.chainId) : void 0;
|
|
3831
|
+
const explorerTxUrl = txHash && targetChain?.explorerUrl ? `${targetChain.explorerUrl}/tx/${txHash}` : void 0;
|
|
3832
|
+
const depositSteps = [
|
|
3833
|
+
{
|
|
3834
|
+
label: "Getting deposit address",
|
|
3835
|
+
status: isGettingAddress ? "active" : isSwitchingChain || isSendingTransaction || isWaitingForConfirmation || isWaitingForProcessing ? "completed" : "pending"
|
|
3836
|
+
},
|
|
3837
|
+
{
|
|
3838
|
+
label: `Switching to ${targetChain?.name ?? "deposit chain"}`,
|
|
3839
|
+
status: isSwitchingChain ? "active" : isSendingTransaction || isWaitingForConfirmation || isWaitingForProcessing ? "completed" : "pending"
|
|
3840
|
+
},
|
|
3841
|
+
{
|
|
3842
|
+
label: "Confirm in wallet",
|
|
3843
|
+
status: isSendingTransaction ? "active" : isWaitingForConfirmation || isWaitingForProcessing ? "completed" : "pending"
|
|
3844
|
+
},
|
|
3845
|
+
{
|
|
3846
|
+
label: "Confirming transaction",
|
|
3847
|
+
status: isWaitingForConfirmation ? "active" : isWaitingForProcessing ? "completed" : "pending"
|
|
3848
|
+
},
|
|
3849
|
+
{
|
|
3850
|
+
label: "Verifying deposit \u2014 may take up to a few minutes",
|
|
3851
|
+
status: isWaitingForProcessing ? "active" : "pending"
|
|
3852
|
+
}
|
|
3853
|
+
];
|
|
3854
|
+
const flowView = showSuccess ? "deposit-success" : showTimeout ? "deposit-timeout" : verificationFailed ? "deposit-error" : isPending && !cancelled ? "depositing" : null;
|
|
3855
|
+
const activeView = flowView ?? view;
|
|
3856
|
+
const handleDepositDone = () => {
|
|
3857
|
+
setShowSuccess(false);
|
|
3858
|
+
setShowTimeout(false);
|
|
3859
|
+
setCancelled(false);
|
|
3860
|
+
resetDeposit();
|
|
3861
|
+
};
|
|
3862
|
+
const handleDepositCancel = () => {
|
|
3863
|
+
setCancelled(true);
|
|
3864
|
+
resetDeposit();
|
|
3865
|
+
};
|
|
3866
|
+
const handleDismissVerificationError = () => {
|
|
3867
|
+
setAmount("");
|
|
3868
|
+
setCancelled(false);
|
|
3869
|
+
resetDeposit();
|
|
3870
|
+
};
|
|
3871
|
+
const handleRetryVerification = () => {
|
|
3872
|
+
retryVerification().catch(() => {
|
|
3873
|
+
});
|
|
3874
|
+
};
|
|
3875
|
+
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" };
|
|
3876
|
+
const goBack = () => {
|
|
3877
|
+
if (back.to === "method") {
|
|
3878
|
+
setAmount("");
|
|
3879
|
+
setSelectedTokenId("");
|
|
3880
|
+
}
|
|
3881
|
+
setView(back.to);
|
|
3882
|
+
};
|
|
3883
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3884
|
+
onClose && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3885
|
+
"button",
|
|
3886
|
+
{
|
|
3887
|
+
"data-privana-close": true,
|
|
3888
|
+
onClick: onClose,
|
|
3889
|
+
disabled: isUnsafeToClose,
|
|
3890
|
+
"aria-label": "Close",
|
|
3891
|
+
className: chunkACLJPC75_cjs.cn(
|
|
3892
|
+
"absolute top-6 right-5 z-20 flex h-5 w-5 items-center justify-center transition-colors",
|
|
3893
|
+
isUnsafeToClose ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
|
|
3894
|
+
),
|
|
3895
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {})
|
|
3896
|
+
}
|
|
3897
|
+
),
|
|
3898
|
+
flowView || activeView === "method" && !onExit ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center px-5 py-4", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-xl leading-5 font-medium", children: appName }) }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3899
|
+
"button",
|
|
3900
|
+
{
|
|
3901
|
+
type: "button",
|
|
3902
|
+
onClick: activeView === "method" ? onExit : goBack,
|
|
3903
|
+
className: "text-foreground flex w-fit cursor-pointer items-center gap-2 px-5 py-4 text-sm font-medium transition-opacity hover:opacity-70",
|
|
3904
|
+
children: [
|
|
3905
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, {}),
|
|
3906
|
+
activeView === "method" ? appName : back.label
|
|
3907
|
+
]
|
|
3908
|
+
}
|
|
3909
|
+
),
|
|
3910
|
+
flowView && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
|
|
3911
|
+
activeView === "deposit-success" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3912
|
+
TransactionSuccessView,
|
|
3913
|
+
{
|
|
3914
|
+
title: "Deposit Successful",
|
|
3915
|
+
message: `Your ${selectedToken?.symbol ?? ""} deposit has been processed.`,
|
|
3916
|
+
onDone: handleDepositDone
|
|
3917
|
+
}
|
|
3918
|
+
),
|
|
3919
|
+
activeView === "deposit-timeout" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3920
|
+
TransactionWarningView,
|
|
3921
|
+
{
|
|
3922
|
+
title: "Deposit Processing",
|
|
3923
|
+
message: "Your transaction was confirmed but the deposit is still being processed. Please check your balance - it should update shortly.",
|
|
3924
|
+
onDone: handleDepositDone
|
|
3925
|
+
}
|
|
3926
|
+
),
|
|
3927
|
+
activeView === "deposit-error" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3928
|
+
TransactionErrorView,
|
|
3929
|
+
{
|
|
3930
|
+
title: "Verification failed",
|
|
3931
|
+
message: depositError?.message ? `Your transfer was sent on-chain but we could not verify the deposit. The funds are already at the deposit address \u2014 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 \u2014 retry verification instead of starting a new deposit.",
|
|
3932
|
+
explorerUrl: explorerTxUrl,
|
|
3933
|
+
explorerLabel: "View transaction",
|
|
3934
|
+
onRetry: handleRetryVerification,
|
|
3935
|
+
onDismiss: handleDismissVerificationError
|
|
3936
|
+
}
|
|
3937
|
+
),
|
|
3938
|
+
activeView === "depositing" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3939
|
+
TransactionProgressView,
|
|
3940
|
+
{
|
|
3941
|
+
title: "Depositing...",
|
|
3942
|
+
steps: depositSteps,
|
|
3943
|
+
onCancel: isGettingAddress || isSendingTransaction ? handleDepositCancel : void 0
|
|
3944
|
+
}
|
|
3945
|
+
)
|
|
3946
|
+
] }),
|
|
3947
|
+
activeView === "method" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
|
|
3948
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3949
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: activeTab === "crypto" ? "Choose the deposit method" : "Buy with credit card and deposit" }),
|
|
3950
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: activeTab === "crypto" ? "Choose the deposit method." : "Use credit card to buy crypto and deposit" })
|
|
3951
|
+
] }),
|
|
3952
|
+
/* @__PURE__ */ jsxRuntime.jsx(MethodTabs, { activeTab, onTabChange: setActiveTab }),
|
|
3953
|
+
activeTab === "crypto" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
3954
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3955
|
+
MethodOption,
|
|
3956
|
+
{
|
|
3957
|
+
title: "Connected wallet",
|
|
3958
|
+
description: "Deposit from your connected wallet.",
|
|
3959
|
+
onClick: () => {
|
|
3960
|
+
onSelectConnectedWallet?.();
|
|
3961
|
+
openDeposit("connected");
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
),
|
|
3965
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3966
|
+
MethodOption,
|
|
3967
|
+
{
|
|
3968
|
+
title: "External Wallet",
|
|
3969
|
+
description: "Send funds from external wallet or exchange.",
|
|
3970
|
+
onClick: () => {
|
|
3971
|
+
onSelectExternalWallet?.();
|
|
3972
|
+
openDeposit("external");
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
)
|
|
3976
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3977
|
+
MethodOption,
|
|
3978
|
+
{
|
|
3979
|
+
title: "Moonpay",
|
|
3980
|
+
description: "on selected address",
|
|
3981
|
+
onClick: () => {
|
|
3982
|
+
onSelectCreditCard?.();
|
|
3983
|
+
openDeposit("credit-card");
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
) })
|
|
3987
|
+
] }),
|
|
3988
|
+
activeView === "deposit" && /* @__PURE__ */ jsxRuntime.jsx(MoonPayGate, { enabled: source === "credit-card", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3989
|
+
DepositView,
|
|
3990
|
+
{
|
|
3991
|
+
source,
|
|
3992
|
+
selectedToken,
|
|
3993
|
+
amount,
|
|
3994
|
+
allowance,
|
|
3995
|
+
onAmountChange: setAmount,
|
|
3996
|
+
onSelectToken: () => setView("select-token"),
|
|
3997
|
+
onConnectWallet,
|
|
3998
|
+
onSubmit: handleSubmit,
|
|
3999
|
+
isSubmitting: isPending
|
|
4000
|
+
}
|
|
4001
|
+
) }),
|
|
4002
|
+
activeView === "select-token" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4003
|
+
TokenSelectorView2,
|
|
4004
|
+
{
|
|
4005
|
+
selectedTokenId: selectedToken?.id,
|
|
4006
|
+
onSelect: (id) => {
|
|
4007
|
+
setSelectedTokenId(id);
|
|
4008
|
+
setView("deposit");
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
),
|
|
4012
|
+
activeView === "external-deposit" && /* @__PURE__ */ jsxRuntime.jsx(ExternalDepositView, { token: selectedToken, amount }),
|
|
4013
|
+
activeView === "credit-card-widget" && /* @__PURE__ */ jsxRuntime.jsx(MoonPayGate, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(CreditCardWidgetView, { token: selectedToken, amount, allowance }) })
|
|
4014
|
+
] });
|
|
4015
|
+
}
|
|
4016
|
+
function DepositModal({ open, onClose, ...handlers }) {
|
|
4017
|
+
const titleId = react.useId();
|
|
4018
|
+
const descId = react.useId();
|
|
4019
|
+
const [isCloseBlocked, setIsCloseBlocked] = react.useState(false);
|
|
4020
|
+
const handleClose = () => {
|
|
4021
|
+
if (!isCloseBlocked) onClose();
|
|
4022
|
+
};
|
|
4023
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4024
|
+
Dialog,
|
|
4025
|
+
{
|
|
4026
|
+
open,
|
|
4027
|
+
onOpenChange: (isOpen) => {
|
|
4028
|
+
if (!isOpen) handleClose();
|
|
4029
|
+
},
|
|
4030
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4031
|
+
DialogContent,
|
|
4032
|
+
{
|
|
4033
|
+
"data-privana": true,
|
|
4034
|
+
showCloseButton: false,
|
|
4035
|
+
onInteractOutside: isCloseBlocked ? (e) => e.preventDefault() : void 0,
|
|
4036
|
+
onEscapeKeyDown: isCloseBlocked ? (e) => e.preventDefault() : void 0,
|
|
4037
|
+
className: "bg-card flex w-[560px] max-w-[95vw] flex-col gap-2 rounded-2xl border-0 p-2",
|
|
4038
|
+
"aria-labelledby": titleId,
|
|
4039
|
+
"aria-describedby": descId,
|
|
4040
|
+
children: [
|
|
4041
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { id: titleId, className: "sr-only", children: "Deposit" }),
|
|
4042
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { id: descId, className: "sr-only", children: "Deposit funds into your account." }),
|
|
4043
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4044
|
+
DepositModalContent,
|
|
4045
|
+
{
|
|
4046
|
+
onClose: handleClose,
|
|
4047
|
+
onCloseBlockedChange: setIsCloseBlocked,
|
|
4048
|
+
...handlers
|
|
4049
|
+
}
|
|
4050
|
+
)
|
|
4051
|
+
]
|
|
4052
|
+
}
|
|
4053
|
+
)
|
|
4054
|
+
}
|
|
4055
|
+
);
|
|
4056
|
+
}
|
|
4057
|
+
function DepositInlineModal({ className, ...handlers }) {
|
|
4058
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4059
|
+
"div",
|
|
4060
|
+
{
|
|
4061
|
+
"data-privana": true,
|
|
4062
|
+
className: chunkACLJPC75_cjs.cn(
|
|
4063
|
+
"bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
4064
|
+
className
|
|
4065
|
+
),
|
|
4066
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DepositModalContent, { ...handlers })
|
|
4067
|
+
}
|
|
4068
|
+
);
|
|
4069
|
+
}
|
|
4070
|
+
function WithdrawView({
|
|
4071
|
+
selectedToken,
|
|
4072
|
+
amount,
|
|
4073
|
+
onAmountChange,
|
|
4074
|
+
onSelectToken,
|
|
4075
|
+
onPendingChange
|
|
4076
|
+
}) {
|
|
4077
|
+
const { chains, getChainById: getChainById2 } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
4078
|
+
const { isConnected, address } = wagmi.useAccount();
|
|
4079
|
+
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
4080
|
+
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
4081
|
+
const [cancelled, setCancelled] = react.useState(false);
|
|
4082
|
+
const targetChain = selectedToken ? getChainById2(selectedToken.chainId) ?? chains[0] : chains[0];
|
|
4083
|
+
const {
|
|
4084
|
+
balanceWei,
|
|
4085
|
+
isLoading: isBalanceLoading,
|
|
4086
|
+
isError: isBalanceError
|
|
4087
|
+
} = useBalance({
|
|
4088
|
+
tokenId: selectedToken?.id,
|
|
4089
|
+
enabled: !!selectedToken
|
|
4090
|
+
});
|
|
4091
|
+
const formattedBalance = selectedToken ? chunkACLJPC75_cjs.formatTokenAmount(balanceWei, selectedToken.decimals) : "0.00";
|
|
4092
|
+
const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
|
|
4093
|
+
onProcessingSuccess: () => {
|
|
4094
|
+
onAmountChange("");
|
|
4095
|
+
setShowSuccess(true);
|
|
4096
|
+
},
|
|
4097
|
+
onProcessingTimeout: () => {
|
|
4098
|
+
onAmountChange("");
|
|
4099
|
+
setShowTimeout(true);
|
|
4100
|
+
}
|
|
4101
|
+
});
|
|
4102
|
+
const explorerUrl = address && targetChain ? chunkACLJPC75_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
|
|
4103
|
+
const getStepStatus = (step, after) => {
|
|
4104
|
+
if (currentStep === step) return "active";
|
|
4105
|
+
if (after.includes(currentStep)) return "completed";
|
|
4106
|
+
return "pending";
|
|
4107
|
+
};
|
|
4108
|
+
const withdrawSteps = [
|
|
4109
|
+
{
|
|
4110
|
+
label: "Switching to signing chain",
|
|
4111
|
+
status: getStepStatus("switching-chain", ["signing", "submitting", "processing"])
|
|
4112
|
+
},
|
|
4113
|
+
{ label: "Sign in wallet", status: getStepStatus("signing", ["submitting", "processing"]) },
|
|
4114
|
+
{ label: "Submitting withdrawal", status: getStepStatus("submitting", ["processing"]) },
|
|
4115
|
+
{ label: "Processing \u2014 may take a minute or two", status: getStepStatus("processing", []) }
|
|
4116
|
+
];
|
|
4117
|
+
react.useEffect(() => {
|
|
4118
|
+
if (error) {
|
|
4119
|
+
sonner.toast.error(error.message.length > 100 ? `${error.message.slice(0, 100)}...` : error.message);
|
|
4120
|
+
}
|
|
4121
|
+
}, [error]);
|
|
4122
|
+
react.useEffect(() => {
|
|
4123
|
+
onPendingChange?.(isPending && !cancelled);
|
|
4124
|
+
}, [isPending, cancelled, onPendingChange]);
|
|
4125
|
+
const hasValidAmount = !!amount && parseFloat(amount) > 0;
|
|
4126
|
+
const tooManyDecimals = !!hasValidAmount && !!selectedToken && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
4127
|
+
const exceedsBalance = !!hasValidAmount && !tooManyDecimals && !!selectedToken && !isBalanceLoading && !isBalanceError && chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
|
|
4128
|
+
const canWithdraw = isConnected && hasValidAmount && !!selectedToken && !tooManyDecimals && !exceedsBalance;
|
|
4129
|
+
const handleMax = () => {
|
|
4130
|
+
if (!selectedToken) return;
|
|
4131
|
+
const max = formattedBalance.replace(/\s/g, "");
|
|
4132
|
+
if (parseFloat(max) > 0) onAmountChange(max);
|
|
4133
|
+
};
|
|
4134
|
+
const handleWithdraw = async () => {
|
|
4135
|
+
if (!selectedToken || !canWithdraw) return;
|
|
4136
|
+
setCancelled(false);
|
|
4137
|
+
await withdraw({
|
|
4138
|
+
tokenId: selectedToken.id,
|
|
4139
|
+
amount: chunkACLJPC75_cjs.parseTokenAmount(amount, selectedToken.decimals)
|
|
4140
|
+
});
|
|
4141
|
+
};
|
|
4142
|
+
const handleCancel = () => {
|
|
4143
|
+
setCancelled(true);
|
|
4144
|
+
reset();
|
|
4145
|
+
};
|
|
4146
|
+
const handleDone = () => {
|
|
4147
|
+
setShowSuccess(false);
|
|
4148
|
+
setShowTimeout(false);
|
|
4149
|
+
setCancelled(false);
|
|
4150
|
+
reset();
|
|
4151
|
+
};
|
|
4152
|
+
if (showSuccess && selectedToken) {
|
|
4153
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4154
|
+
TransactionSuccessView,
|
|
4155
|
+
{
|
|
4156
|
+
title: "Withdrawal Complete",
|
|
4157
|
+
message: `Your ${selectedToken.symbol} withdrawal has been processed. Funds should appear in your wallet shortly.`,
|
|
4158
|
+
explorerUrl,
|
|
4159
|
+
explorerLabel: targetChain ? chunkACLJPC75_cjs.getExplorerLabel(targetChain.id) : void 0,
|
|
4160
|
+
onDone: handleDone
|
|
4161
|
+
}
|
|
4162
|
+
) });
|
|
4163
|
+
}
|
|
4164
|
+
if (showTimeout) {
|
|
4165
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4166
|
+
TransactionWarningView,
|
|
4167
|
+
{
|
|
4168
|
+
title: "Withdrawal Processing",
|
|
4169
|
+
message: "Your withdrawal is still being processed. Please check your balance \u2014 it should update shortly.",
|
|
4170
|
+
onDone: handleDone
|
|
4171
|
+
}
|
|
4172
|
+
) });
|
|
4173
|
+
}
|
|
4174
|
+
if (isPending && !cancelled) {
|
|
4175
|
+
const canCancel = currentStep === "idle" || currentStep === "switching-chain" || currentStep === "signing";
|
|
4176
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4177
|
+
TransactionProgressView,
|
|
4178
|
+
{
|
|
4179
|
+
title: "Withdrawing...",
|
|
4180
|
+
steps: withdrawSteps,
|
|
4181
|
+
onCancel: canCancel ? handleCancel : void 0
|
|
4182
|
+
}
|
|
4183
|
+
) });
|
|
4184
|
+
}
|
|
4185
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
|
|
4186
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: "Withdraw" }),
|
|
4187
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
4188
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-muted-foreground text-sm", children: "Token" }),
|
|
4189
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4190
|
+
"button",
|
|
4191
|
+
{
|
|
4192
|
+
type: "button",
|
|
4193
|
+
onClick: onSelectToken,
|
|
4194
|
+
className: "border-border bg-input flex w-full cursor-pointer items-center gap-3 rounded-lg border p-3 text-left",
|
|
4195
|
+
children: [
|
|
4196
|
+
selectedToken ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4197
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 w-8 shrink-0 overflow-hidden rounded-full", children: getTokenIcon(selectedToken.symbol, 32) }),
|
|
4198
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col items-start gap-1", children: [
|
|
4199
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-sm font-medium", children: selectedToken.symbol }),
|
|
4200
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-xs", children: [
|
|
4201
|
+
"on ",
|
|
4202
|
+
targetChain?.name ?? "\u2014"
|
|
4203
|
+
] })
|
|
4204
|
+
] })
|
|
4205
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground flex-1 text-sm", children: "Select token" }),
|
|
4206
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground flex h-5 w-5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, {}) })
|
|
4207
|
+
]
|
|
4208
|
+
}
|
|
4209
|
+
)
|
|
4210
|
+
] }),
|
|
4211
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
4212
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
4213
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-muted-foreground text-sm", children: "Amount" }),
|
|
4214
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-sm", children: [
|
|
4215
|
+
"Available ",
|
|
4216
|
+
formattedBalance,
|
|
4217
|
+
" ",
|
|
4218
|
+
selectedToken?.symbol
|
|
4219
|
+
] })
|
|
4220
|
+
] }),
|
|
4221
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-border bg-input flex items-center gap-2 rounded-[10px] border py-1 pr-1 pl-3", children: [
|
|
4222
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4223
|
+
"input",
|
|
4224
|
+
{
|
|
4225
|
+
type: "text",
|
|
4226
|
+
inputMode: "decimal",
|
|
4227
|
+
placeholder: "Enter Amount",
|
|
4228
|
+
value: amount,
|
|
4229
|
+
onChange: (e) => {
|
|
4230
|
+
const value = e.target.value.replace(/[^0-9.,]/g, "").replace(/,/g, ".");
|
|
4231
|
+
if (value.split(".").length <= 2) onAmountChange(value);
|
|
4232
|
+
},
|
|
4233
|
+
className: "text-foreground placeholder:text-muted-foreground/50 flex-1 bg-transparent text-sm outline-none"
|
|
4234
|
+
}
|
|
4235
|
+
),
|
|
4236
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4237
|
+
"button",
|
|
4238
|
+
{
|
|
4239
|
+
type: "button",
|
|
4240
|
+
onClick: handleMax,
|
|
4241
|
+
className: "bg-secondary text-foreground hover:bg-secondary/80 cursor-pointer rounded px-3 py-2.5 text-xs font-semibold transition-colors",
|
|
4242
|
+
children: "MAX"
|
|
4243
|
+
}
|
|
4244
|
+
)
|
|
4245
|
+
] }),
|
|
4246
|
+
tooManyDecimals && selectedToken && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-destructive text-sm", children: [
|
|
4247
|
+
"Too many decimal places (max: ",
|
|
4248
|
+
selectedToken.decimals,
|
|
4249
|
+
")"
|
|
4250
|
+
] }),
|
|
4251
|
+
exceedsBalance && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-destructive text-sm", children: "Insufficient balance" })
|
|
4252
|
+
] }),
|
|
4253
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4254
|
+
"button",
|
|
4255
|
+
{
|
|
4256
|
+
type: "button",
|
|
4257
|
+
disabled: !canWithdraw,
|
|
4258
|
+
onClick: handleWithdraw,
|
|
4259
|
+
className: "bg-primary text-primary-foreground hover:bg-primary/90 flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
|
|
4260
|
+
children: !isConnected ? "Connect Wallet" : "Withdraw"
|
|
4261
|
+
}
|
|
4262
|
+
)
|
|
4263
|
+
] });
|
|
4264
|
+
}
|
|
4265
|
+
function WithdrawModalContent({
|
|
4266
|
+
onClose,
|
|
4267
|
+
onPendingChange,
|
|
4268
|
+
onBack
|
|
4269
|
+
}) {
|
|
4270
|
+
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
4271
|
+
const { address } = wagmi.useAccount();
|
|
4272
|
+
const appName = serviceName ?? "Privana";
|
|
4273
|
+
const [view, setView] = react.useState("form");
|
|
4274
|
+
const [selectedTokenId, setSelectedTokenId] = react.useState(defaultToken?.id ?? "");
|
|
4275
|
+
const [amount, setAmount] = react.useState("");
|
|
4276
|
+
const [isPending, setIsPending] = react.useState(false);
|
|
4277
|
+
const handlePendingChange = (pending) => {
|
|
4278
|
+
setIsPending(pending);
|
|
4279
|
+
onPendingChange?.(pending);
|
|
4280
|
+
};
|
|
4281
|
+
const selectedToken = enabledTokens.find((t) => t.id === selectedTokenId) ?? defaultToken;
|
|
4282
|
+
const prevAddressRef = react.useRef(address);
|
|
4283
|
+
react.useEffect(() => {
|
|
4284
|
+
const prev = prevAddressRef.current;
|
|
4285
|
+
prevAddressRef.current = address;
|
|
4286
|
+
if (hostedAuthConfig) return;
|
|
4287
|
+
if (prev && address && prev !== address) {
|
|
4288
|
+
setView("form");
|
|
4289
|
+
setAmount("");
|
|
4290
|
+
setSelectedTokenId("");
|
|
4291
|
+
}
|
|
4292
|
+
}, [address, hostedAuthConfig]);
|
|
4293
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4294
|
+
onClose && !isPending && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4295
|
+
"button",
|
|
4296
|
+
{
|
|
4297
|
+
"data-privana-close": true,
|
|
4298
|
+
onClick: onClose,
|
|
4299
|
+
"aria-label": "Close",
|
|
4300
|
+
className: "text-muted-foreground hover:text-foreground absolute top-6 right-5 z-20 flex h-5 w-5 cursor-pointer items-center justify-center transition-colors",
|
|
4301
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {})
|
|
4302
|
+
}
|
|
4303
|
+
),
|
|
4304
|
+
view === "select-token" ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4305
|
+
"button",
|
|
4306
|
+
{
|
|
4307
|
+
type: "button",
|
|
4308
|
+
onClick: () => setView("form"),
|
|
4309
|
+
className: "text-foreground flex w-fit cursor-pointer items-center gap-2 px-5 py-4 text-sm font-medium transition-opacity hover:opacity-70",
|
|
4310
|
+
children: [
|
|
4311
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, {}),
|
|
4312
|
+
"Withdraw"
|
|
4313
|
+
]
|
|
4314
|
+
}
|
|
4315
|
+
) : onBack && !isPending ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4316
|
+
"button",
|
|
4317
|
+
{
|
|
4318
|
+
type: "button",
|
|
4319
|
+
onClick: onBack,
|
|
4320
|
+
className: "text-foreground flex w-fit cursor-pointer items-center gap-2 px-5 py-4 text-sm font-medium transition-opacity hover:opacity-70",
|
|
4321
|
+
children: [
|
|
4322
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, {}),
|
|
4323
|
+
appName
|
|
4324
|
+
]
|
|
4325
|
+
}
|
|
4326
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center px-5 py-4", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-xl leading-5 font-medium", children: appName }) }),
|
|
4327
|
+
view === "form" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4328
|
+
WithdrawView,
|
|
4329
|
+
{
|
|
4330
|
+
selectedToken,
|
|
4331
|
+
amount,
|
|
4332
|
+
onAmountChange: setAmount,
|
|
4333
|
+
onSelectToken: () => setView("select-token"),
|
|
4334
|
+
onPendingChange: handlePendingChange
|
|
4335
|
+
}
|
|
4336
|
+
),
|
|
4337
|
+
view === "select-token" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4338
|
+
TokenSelectorView2,
|
|
4339
|
+
{
|
|
4340
|
+
selectedTokenId: selectedToken?.id,
|
|
4341
|
+
onSelect: (id) => {
|
|
4342
|
+
setSelectedTokenId(id);
|
|
4343
|
+
setView("form");
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
)
|
|
4347
|
+
] });
|
|
4348
|
+
}
|
|
4349
|
+
function WithdrawModal({ open, onClose }) {
|
|
4350
|
+
const titleId = react.useId();
|
|
4351
|
+
const descId = react.useId();
|
|
4352
|
+
const [isCloseBlocked, setIsCloseBlocked] = react.useState(false);
|
|
4353
|
+
const handleClose = () => {
|
|
4354
|
+
if (!isCloseBlocked) onClose();
|
|
4355
|
+
};
|
|
4356
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4357
|
+
Dialog,
|
|
4358
|
+
{
|
|
4359
|
+
open,
|
|
4360
|
+
onOpenChange: (isOpen) => {
|
|
4361
|
+
if (!isOpen) handleClose();
|
|
4362
|
+
},
|
|
4363
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4364
|
+
DialogContent,
|
|
4365
|
+
{
|
|
4366
|
+
"data-privana": true,
|
|
4367
|
+
showCloseButton: false,
|
|
4368
|
+
onInteractOutside: isCloseBlocked ? (e) => e.preventDefault() : void 0,
|
|
4369
|
+
onEscapeKeyDown: isCloseBlocked ? (e) => e.preventDefault() : void 0,
|
|
4370
|
+
className: "bg-card flex w-[560px] max-w-[95vw] flex-col gap-2 rounded-2xl border-0 p-2",
|
|
4371
|
+
"aria-labelledby": titleId,
|
|
4372
|
+
"aria-describedby": descId,
|
|
4373
|
+
children: [
|
|
4374
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { id: titleId, className: "sr-only", children: "Withdraw" }),
|
|
4375
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { id: descId, className: "sr-only", children: "Withdraw funds from your account." }),
|
|
4376
|
+
/* @__PURE__ */ jsxRuntime.jsx(WithdrawModalContent, { onClose: handleClose, onPendingChange: setIsCloseBlocked })
|
|
4377
|
+
]
|
|
4378
|
+
}
|
|
4379
|
+
)
|
|
4380
|
+
}
|
|
4381
|
+
);
|
|
4382
|
+
}
|
|
4383
|
+
function WithdrawInlineModal({ className }) {
|
|
4384
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4385
|
+
"div",
|
|
4386
|
+
{
|
|
4387
|
+
"data-privana": true,
|
|
4388
|
+
className: chunkACLJPC75_cjs.cn(
|
|
4389
|
+
"bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
4390
|
+
className
|
|
4391
|
+
),
|
|
4392
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(WithdrawModalContent, {})
|
|
4393
|
+
}
|
|
4394
|
+
);
|
|
4395
|
+
}
|
|
4396
|
+
var AVAILABLE_COLOR = "bg-[#007bff]";
|
|
4397
|
+
var IN_USE_COLOR = "bg-[#4fc77f]";
|
|
4398
|
+
function toInUseWei(value) {
|
|
4399
|
+
let parsed;
|
|
4400
|
+
try {
|
|
4401
|
+
parsed = typeof value === "bigint" ? value : BigInt(value);
|
|
4402
|
+
} catch {
|
|
4403
|
+
console.warn(`[privana-sdk] Invalid session.inUse value: ${value}`);
|
|
4404
|
+
return 0n;
|
|
4405
|
+
}
|
|
4406
|
+
if (parsed < 0n) {
|
|
4407
|
+
console.warn(`[privana-sdk] Negative session.inUse value: ${value}`);
|
|
4408
|
+
return 0n;
|
|
4409
|
+
}
|
|
4410
|
+
return parsed;
|
|
4411
|
+
}
|
|
4412
|
+
function useNow(intervalMs, enabled) {
|
|
4413
|
+
const [, setTick] = react.useState(0);
|
|
4414
|
+
react.useEffect(() => {
|
|
4415
|
+
if (!enabled) return;
|
|
4416
|
+
const id = setInterval(() => setTick((t) => t + 1), intervalMs);
|
|
4417
|
+
return () => clearInterval(id);
|
|
4418
|
+
}, [intervalMs, enabled]);
|
|
4419
|
+
}
|
|
4420
|
+
function SegmentedBalanceBar({
|
|
4421
|
+
availableWei,
|
|
4422
|
+
inUseWei
|
|
4423
|
+
}) {
|
|
4424
|
+
const total = availableWei + inUseWei;
|
|
4425
|
+
const showAvailable = inUseWei === 0n || availableWei > 0n;
|
|
4426
|
+
const showInUse = inUseWei > 0n;
|
|
4427
|
+
const grow = (part) => total > 0n ? Number(part * 1000n / total) : 1;
|
|
4428
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-1.5 w-full", children: [
|
|
4429
|
+
showAvailable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4430
|
+
"div",
|
|
4431
|
+
{
|
|
4432
|
+
className: chunkACLJPC75_cjs.cn(AVAILABLE_COLOR, "rounded-l-full", !showInUse && "rounded-r-full"),
|
|
4433
|
+
style: { flexGrow: grow(availableWei) }
|
|
4434
|
+
}
|
|
4435
|
+
),
|
|
4436
|
+
showInUse && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4437
|
+
"div",
|
|
4438
|
+
{
|
|
4439
|
+
className: chunkACLJPC75_cjs.cn(IN_USE_COLOR, "rounded-r-full", !showAvailable && "rounded-l-full"),
|
|
4440
|
+
style: { flexGrow: grow(inUseWei) }
|
|
4441
|
+
}
|
|
4442
|
+
)
|
|
4443
|
+
] });
|
|
4444
|
+
}
|
|
4445
|
+
function BalanceLegendItem({ color, label }) {
|
|
4446
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
4447
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkACLJPC75_cjs.cn("h-2.5 w-2.5 rounded-full", color) }),
|
|
4448
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-sm leading-5", children: label })
|
|
4449
|
+
] });
|
|
4450
|
+
}
|
|
4451
|
+
function WalletBalanceView({
|
|
4452
|
+
session,
|
|
4453
|
+
allowance,
|
|
4454
|
+
amount,
|
|
4455
|
+
onAmountChange,
|
|
4456
|
+
onPlay,
|
|
4457
|
+
onAddFunds,
|
|
4458
|
+
onWithdraw
|
|
4459
|
+
}) {
|
|
4460
|
+
const { serviceName, serviceIcon, defaultToken } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
4461
|
+
const appName = serviceName ?? "Privana";
|
|
4462
|
+
const token = defaultToken;
|
|
4463
|
+
const {
|
|
4464
|
+
balanceWei,
|
|
4465
|
+
isLoading: isBalanceLoading,
|
|
4466
|
+
isError: isBalanceError
|
|
4467
|
+
} = useBalance({ tokenId: token?.id, enabled: !!token });
|
|
4468
|
+
const inUseWei = session ? toInUseWei(session.inUse) : 0n;
|
|
4469
|
+
const availableWei = BigInt(balanceWei);
|
|
4470
|
+
const variant = !session ? "idle" : inUseWei === 0n ? "session-zero" : availableWei === 0n ? "fully-in-use" : "mixed";
|
|
4471
|
+
const expiry = session?.expiry;
|
|
4472
|
+
useNow(3e4, expiry != null);
|
|
4473
|
+
const countdown = expiry != null ? chunkACLJPC75_cjs.formatTimeRemaining(expiry) : null;
|
|
4474
|
+
const decimals = token?.decimals ?? 18;
|
|
4475
|
+
const totalFormatted = chunkACLJPC75_cjs.formatTokenAmount((availableWei + inUseWei).toString(), decimals);
|
|
4476
|
+
const availableFormatted = chunkACLJPC75_cjs.formatTokenAmount(availableWei.toString(), decimals);
|
|
4477
|
+
const inUseFormatted = chunkACLJPC75_cjs.formatTokenAmount(inUseWei.toString(), decimals);
|
|
4478
|
+
const hasValidAmount = !!amount && parseFloat(amount) > 0;
|
|
4479
|
+
const tooManyDecimals = hasValidAmount && !!token && amount.includes(".") && amount.split(".")[1].length > token.decimals;
|
|
4480
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && !!token && !isBalanceLoading && !isBalanceError && chunkACLJPC75_cjs.parseTokenAmount(amount, token.decimals) > availableWei;
|
|
4481
|
+
const canPlay = hasValidAmount && !!token && !tooManyDecimals && !exceedsBalance && !isBalanceLoading && !isBalanceError;
|
|
4482
|
+
const handleMax = () => {
|
|
4483
|
+
const max = availableFormatted.replace(/\s/g, "");
|
|
4484
|
+
if (parseFloat(max) > 0) onAmountChange(max);
|
|
4485
|
+
};
|
|
4486
|
+
const handlePlay = () => {
|
|
4487
|
+
if (!token || !canPlay || !onPlay) return;
|
|
4488
|
+
onPlay({ tokenId: token.id, amount });
|
|
4489
|
+
onAmountChange("");
|
|
4490
|
+
};
|
|
4491
|
+
const showInput = variant !== "fully-in-use";
|
|
4492
|
+
const showInlinePlay = variant === "session-zero" || variant === "mixed";
|
|
4493
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
|
|
4494
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
4495
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
4496
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm leading-[14px]", children: "Total" }),
|
|
4497
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-secondary text-muted-foreground rounded-full px-2 py-[5px] text-[10px] leading-[10px] font-bold", children: token?.symbol ?? "\u2014" })
|
|
4498
|
+
] }),
|
|
4499
|
+
isBalanceLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunkACLJPC75_cjs.Skeleton, { className: "h-9 w-40" }) : isBalanceError ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-[32px] leading-9 font-medium", children: "\u2014" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-[32px] leading-9 font-medium", children: totalFormatted })
|
|
4500
|
+
] }),
|
|
4501
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
4502
|
+
/* @__PURE__ */ jsxRuntime.jsx(SegmentedBalanceBar, { availableWei, inUseWei }),
|
|
4503
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
4504
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: variant === "fully-in-use" ? /* @__PURE__ */ jsxRuntime.jsx(BalanceLegendItem, { color: IN_USE_COLOR, label: "In use" }) : variant === "mixed" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4505
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4506
|
+
BalanceLegendItem,
|
|
4507
|
+
{
|
|
4508
|
+
color: AVAILABLE_COLOR,
|
|
4509
|
+
label: `Available (${availableFormatted})`
|
|
4510
|
+
}
|
|
4511
|
+
),
|
|
4512
|
+
/* @__PURE__ */ jsxRuntime.jsx(BalanceLegendItem, { color: IN_USE_COLOR, label: `In use (${inUseFormatted})` })
|
|
4513
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(BalanceLegendItem, { color: AVAILABLE_COLOR, label: "Available" }) }),
|
|
4514
|
+
countdown && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm leading-5 whitespace-nowrap", children: countdown })
|
|
4515
|
+
] })
|
|
4516
|
+
] }),
|
|
4517
|
+
showInput && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
4518
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4519
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-border bg-input flex h-10 flex-1 items-center gap-2 rounded-[10px] border py-1 pr-1 pl-3", children: [
|
|
4520
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4521
|
+
"input",
|
|
4522
|
+
{
|
|
4523
|
+
type: "text",
|
|
4524
|
+
inputMode: "decimal",
|
|
4525
|
+
placeholder: "Enter Amount",
|
|
4526
|
+
value: amount,
|
|
4527
|
+
onChange: (e) => {
|
|
4528
|
+
const value = e.target.value.replace(/[^0-9.,]/g, "").replace(/,/g, ".");
|
|
4529
|
+
if (value.split(".").length <= 2) onAmountChange(value);
|
|
4530
|
+
},
|
|
4531
|
+
className: "text-foreground placeholder:text-muted-foreground/50 min-w-0 flex-1 bg-transparent text-sm outline-none"
|
|
4532
|
+
}
|
|
4533
|
+
),
|
|
4534
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4535
|
+
"button",
|
|
4536
|
+
{
|
|
4537
|
+
type: "button",
|
|
4538
|
+
onClick: handleMax,
|
|
4539
|
+
className: "text-foreground cursor-pointer rounded px-3 py-2.5 text-xs font-semibold",
|
|
4540
|
+
children: "MAX"
|
|
4541
|
+
}
|
|
4542
|
+
)
|
|
4543
|
+
] }),
|
|
4544
|
+
showInlinePlay && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4545
|
+
"button",
|
|
4546
|
+
{
|
|
4547
|
+
type: "button",
|
|
4548
|
+
disabled: !onPlay || !canPlay,
|
|
4549
|
+
onClick: handlePlay,
|
|
4550
|
+
className: "border-border flex h-10 min-w-20 cursor-pointer items-center justify-center rounded-[10px] border px-3 text-sm font-medium text-[#4fc77f] transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",
|
|
4551
|
+
children: "Play"
|
|
4552
|
+
}
|
|
4553
|
+
)
|
|
4554
|
+
] }),
|
|
4555
|
+
tooManyDecimals && token && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-destructive text-sm", children: [
|
|
4556
|
+
"Too many decimal places (max: ",
|
|
4557
|
+
token.decimals,
|
|
4558
|
+
")"
|
|
4559
|
+
] }),
|
|
4560
|
+
exceedsBalance && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-destructive text-sm", children: "Insufficient balance" })
|
|
4561
|
+
] }),
|
|
4562
|
+
variant === "idle" && allowance && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted rounded-[10px] p-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4563
|
+
AllowancePolicySection,
|
|
4564
|
+
{
|
|
4565
|
+
allowance,
|
|
4566
|
+
serviceName: appName,
|
|
4567
|
+
serviceIcon
|
|
4568
|
+
}
|
|
4569
|
+
) }),
|
|
4570
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-start gap-4", children: variant === "idle" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4571
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4572
|
+
"button",
|
|
4573
|
+
{
|
|
4574
|
+
type: "button",
|
|
4575
|
+
disabled: !onPlay || !canPlay,
|
|
4576
|
+
onClick: handlePlay,
|
|
4577
|
+
className: "bg-primary text-primary-foreground hover:bg-primary/90 flex h-10 flex-1 cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
|
|
4578
|
+
children: "Play"
|
|
4579
|
+
}
|
|
4580
|
+
),
|
|
4581
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4582
|
+
"button",
|
|
4583
|
+
{
|
|
4584
|
+
type: "button",
|
|
4585
|
+
disabled: !onAddFunds,
|
|
4586
|
+
onClick: onAddFunds,
|
|
4587
|
+
className: "bg-secondary text-foreground hover:bg-secondary/80 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",
|
|
4588
|
+
children: "Add funds"
|
|
4589
|
+
}
|
|
4590
|
+
)
|
|
4591
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4592
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4593
|
+
"button",
|
|
4594
|
+
{
|
|
4595
|
+
type: "button",
|
|
4596
|
+
disabled: !onAddFunds,
|
|
4597
|
+
onClick: onAddFunds,
|
|
4598
|
+
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",
|
|
4599
|
+
children: "Add Funds"
|
|
4600
|
+
}
|
|
4601
|
+
),
|
|
4602
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4603
|
+
"button",
|
|
4604
|
+
{
|
|
4605
|
+
type: "button",
|
|
4606
|
+
disabled: !onWithdraw,
|
|
4607
|
+
onClick: onWithdraw,
|
|
4608
|
+
className: "bg-secondary text-foreground hover:bg-secondary/80 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",
|
|
4609
|
+
children: "Withdraw"
|
|
4610
|
+
}
|
|
4611
|
+
)
|
|
4612
|
+
] }) })
|
|
4613
|
+
] });
|
|
4614
|
+
}
|
|
4615
|
+
function WalletModalContent({
|
|
4616
|
+
session,
|
|
4617
|
+
allowance,
|
|
4618
|
+
onPlay,
|
|
4619
|
+
onEndSession,
|
|
4620
|
+
onDepositSuccess,
|
|
4621
|
+
onClose,
|
|
4622
|
+
onCloseBlockedChange,
|
|
4623
|
+
...depositHandlers
|
|
4624
|
+
}) {
|
|
4625
|
+
const { serviceName, hostedAuthConfig } = chunkACLJPC75_cjs.usePrivanaContext();
|
|
4626
|
+
const { address } = wagmi.useAccount();
|
|
4627
|
+
const appName = serviceName ?? "Privana";
|
|
4628
|
+
const [view, setView] = react.useState("balance");
|
|
4629
|
+
const [amount, setAmount] = react.useState("");
|
|
4630
|
+
const [depositBlocked, setDepositBlocked] = react.useState(false);
|
|
4631
|
+
const [withdrawPending, setWithdrawPending] = react.useState(false);
|
|
4632
|
+
const [endSessionError, setEndSessionError] = react.useState(null);
|
|
4633
|
+
const endSessionRunRef = react.useRef(0);
|
|
4634
|
+
const prevAddressRef = react.useRef(address);
|
|
4635
|
+
react.useEffect(() => {
|
|
4636
|
+
const prev = prevAddressRef.current;
|
|
4637
|
+
prevAddressRef.current = address;
|
|
4638
|
+
if (hostedAuthConfig) return;
|
|
4639
|
+
if (prev && address && prev !== address) {
|
|
4640
|
+
setView("balance");
|
|
4641
|
+
setAmount("");
|
|
4642
|
+
setDepositBlocked(false);
|
|
4643
|
+
setWithdrawPending(false);
|
|
4644
|
+
setEndSessionError(null);
|
|
4645
|
+
endSessionRunRef.current++;
|
|
4646
|
+
}
|
|
4647
|
+
}, [address, hostedAuthConfig]);
|
|
4648
|
+
const closeBlocked = depositBlocked || withdrawPending || view === "ending-session";
|
|
4649
|
+
react.useEffect(() => {
|
|
4650
|
+
onCloseBlockedChange?.(closeBlocked);
|
|
4651
|
+
}, [closeBlocked, onCloseBlockedChange]);
|
|
4652
|
+
const exitDeposit = () => {
|
|
4653
|
+
setDepositBlocked(false);
|
|
4654
|
+
setView("balance");
|
|
4655
|
+
};
|
|
4656
|
+
const exitWithdraw = () => {
|
|
4657
|
+
setWithdrawPending(false);
|
|
4658
|
+
setView("balance");
|
|
4659
|
+
};
|
|
4660
|
+
const startEndSession = () => {
|
|
4661
|
+
if (!onEndSession) return;
|
|
4662
|
+
const run = ++endSessionRunRef.current;
|
|
4663
|
+
setEndSessionError(null);
|
|
4664
|
+
setView("ending-session");
|
|
4665
|
+
Promise.resolve().then(() => onEndSession()).then(
|
|
4666
|
+
() => {
|
|
4667
|
+
if (endSessionRunRef.current !== run) return;
|
|
4668
|
+
setView("withdraw");
|
|
4669
|
+
},
|
|
4670
|
+
(err) => {
|
|
4671
|
+
if (endSessionRunRef.current !== run) return;
|
|
4672
|
+
setEndSessionError(err instanceof Error ? err.message : null);
|
|
4673
|
+
setView("end-session-error");
|
|
4674
|
+
}
|
|
4675
|
+
);
|
|
4676
|
+
};
|
|
4677
|
+
const handleWithdraw = () => {
|
|
4678
|
+
if (session && onEndSession) {
|
|
4679
|
+
startEndSession();
|
|
4680
|
+
} else {
|
|
4681
|
+
setView("withdraw");
|
|
4682
|
+
}
|
|
4683
|
+
};
|
|
4684
|
+
const dismissEndSessionError = () => {
|
|
4685
|
+
endSessionRunRef.current++;
|
|
4686
|
+
setEndSessionError(null);
|
|
4687
|
+
setView("balance");
|
|
4688
|
+
};
|
|
4689
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4690
|
+
onClose && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4691
|
+
"button",
|
|
4692
|
+
{
|
|
4693
|
+
"data-privana-close": true,
|
|
4694
|
+
onClick: onClose,
|
|
4695
|
+
disabled: closeBlocked,
|
|
4696
|
+
"aria-label": "Close",
|
|
4697
|
+
className: chunkACLJPC75_cjs.cn(
|
|
4698
|
+
"absolute top-6 right-5 z-20 flex h-5 w-5 items-center justify-center transition-colors",
|
|
4699
|
+
closeBlocked ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
|
|
4700
|
+
),
|
|
4701
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {})
|
|
4702
|
+
}
|
|
4703
|
+
),
|
|
4704
|
+
(view === "balance" || view === "ending-session" || view === "end-session-error") && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center px-5 py-4", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-xl leading-5 font-medium", children: appName }) }),
|
|
4705
|
+
view === "balance" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4706
|
+
WalletBalanceView,
|
|
4707
|
+
{
|
|
4708
|
+
session,
|
|
4709
|
+
allowance,
|
|
4710
|
+
amount,
|
|
4711
|
+
onAmountChange: setAmount,
|
|
4712
|
+
onPlay,
|
|
4713
|
+
onAddFunds: () => setView("deposit"),
|
|
4714
|
+
onWithdraw: handleWithdraw
|
|
4715
|
+
}
|
|
4716
|
+
),
|
|
4717
|
+
view === "ending-session" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4718
|
+
TransactionProgressView,
|
|
4719
|
+
{
|
|
4720
|
+
title: "Ending game session...",
|
|
4721
|
+
steps: [{ label: "Waiting for the game session to settle", status: "active" }]
|
|
4722
|
+
}
|
|
4723
|
+
) }),
|
|
4724
|
+
view === "end-session-error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4725
|
+
TransactionErrorView,
|
|
4726
|
+
{
|
|
4727
|
+
title: "Could not end session",
|
|
4728
|
+
message: endSessionError ? `Your game session could not be ended, so the funds committed to it are not available to withdraw yet. (${endSessionError})` : "Your game session could not be ended, so the funds committed to it are not available to withdraw yet.",
|
|
4729
|
+
onRetry: startEndSession,
|
|
4730
|
+
onDismiss: dismissEndSessionError
|
|
4731
|
+
}
|
|
4732
|
+
) }),
|
|
4733
|
+
view === "withdraw" && /* @__PURE__ */ jsxRuntime.jsx(WithdrawModalContent, { onBack: exitWithdraw, onPendingChange: setWithdrawPending }),
|
|
4734
|
+
view === "deposit" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4735
|
+
DepositModalContent,
|
|
4736
|
+
{
|
|
4737
|
+
...depositHandlers,
|
|
4738
|
+
allowance,
|
|
4739
|
+
onExit: exitDeposit,
|
|
4740
|
+
onCloseBlockedChange: setDepositBlocked,
|
|
4741
|
+
onDepositSuccess: () => {
|
|
4742
|
+
exitDeposit();
|
|
4743
|
+
onDepositSuccess?.();
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
)
|
|
4747
|
+
] });
|
|
4748
|
+
}
|
|
4749
|
+
function WalletModal({ open, onClose, ...handlers }) {
|
|
4750
|
+
const titleId = react.useId();
|
|
4751
|
+
const descId = react.useId();
|
|
4752
|
+
const [isCloseBlocked, setIsCloseBlocked] = react.useState(false);
|
|
4753
|
+
const handleClose = () => {
|
|
4754
|
+
if (!isCloseBlocked) onClose();
|
|
4755
|
+
};
|
|
4756
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4757
|
+
Dialog,
|
|
4758
|
+
{
|
|
4759
|
+
open,
|
|
4760
|
+
onOpenChange: (isOpen) => {
|
|
4761
|
+
if (!isOpen) handleClose();
|
|
4762
|
+
},
|
|
4763
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4764
|
+
DialogContent,
|
|
4765
|
+
{
|
|
4766
|
+
"data-privana": true,
|
|
4767
|
+
showCloseButton: false,
|
|
4768
|
+
onInteractOutside: isCloseBlocked ? (e) => e.preventDefault() : void 0,
|
|
4769
|
+
onEscapeKeyDown: isCloseBlocked ? (e) => e.preventDefault() : void 0,
|
|
4770
|
+
className: "bg-card flex w-[560px] max-w-[95vw] flex-col gap-2 rounded-2xl border-0 p-2",
|
|
4771
|
+
"aria-labelledby": titleId,
|
|
4772
|
+
"aria-describedby": descId,
|
|
4773
|
+
children: [
|
|
4774
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { id: titleId, className: "sr-only", children: "Wallet" }),
|
|
4775
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { id: descId, className: "sr-only", children: "Manage your account balance." }),
|
|
4776
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4777
|
+
WalletModalContent,
|
|
4778
|
+
{
|
|
4779
|
+
onClose: handleClose,
|
|
4780
|
+
onCloseBlockedChange: setIsCloseBlocked,
|
|
4781
|
+
...handlers
|
|
4782
|
+
}
|
|
4783
|
+
)
|
|
4784
|
+
]
|
|
4785
|
+
}
|
|
4786
|
+
)
|
|
4787
|
+
}
|
|
4788
|
+
);
|
|
4789
|
+
}
|
|
4790
|
+
function WalletInlineModal({ className, ...handlers }) {
|
|
4791
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4792
|
+
"div",
|
|
4793
|
+
{
|
|
4794
|
+
"data-privana": true,
|
|
4795
|
+
className: chunkACLJPC75_cjs.cn(
|
|
4796
|
+
"bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
4797
|
+
className
|
|
4798
|
+
),
|
|
4799
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(WalletModalContent, { ...handlers })
|
|
4800
|
+
}
|
|
4801
|
+
);
|
|
4802
|
+
}
|
|
4803
|
+
|
|
4804
|
+
Object.defineProperty(exports, "AccountingApiError", {
|
|
4805
|
+
enumerable: true,
|
|
4806
|
+
get: function () { return chunkACLJPC75_cjs.AccountingApiError; }
|
|
4807
|
+
});
|
|
4808
|
+
Object.defineProperty(exports, "Button", {
|
|
4809
|
+
enumerable: true,
|
|
4810
|
+
get: function () { return chunkACLJPC75_cjs.Button; }
|
|
4811
|
+
});
|
|
4812
|
+
Object.defineProperty(exports, "HOSTED_AUTH_CLOCK_SKEW_MS", {
|
|
4813
|
+
enumerable: true,
|
|
4814
|
+
get: function () { return chunkACLJPC75_cjs.HOSTED_AUTH_CLOCK_SKEW_MS; }
|
|
4815
|
+
});
|
|
4816
|
+
Object.defineProperty(exports, "HostedAuthError", {
|
|
4817
|
+
enumerable: true,
|
|
4818
|
+
get: function () { return chunkACLJPC75_cjs.HostedAuthError; }
|
|
4819
|
+
});
|
|
4820
|
+
Object.defineProperty(exports, "HostedAuthRequiredError", {
|
|
4821
|
+
enumerable: true,
|
|
4822
|
+
get: function () { return chunkACLJPC75_cjs.HostedAuthRequiredError; }
|
|
4823
|
+
});
|
|
4824
|
+
Object.defineProperty(exports, "HostedAuthStateMismatchError", {
|
|
4825
|
+
enumerable: true,
|
|
4826
|
+
get: function () { return chunkACLJPC75_cjs.HostedAuthStateMismatchError; }
|
|
4827
|
+
});
|
|
4828
|
+
Object.defineProperty(exports, "HttpClient", {
|
|
4829
|
+
enumerable: true,
|
|
4830
|
+
get: function () { return chunkACLJPC75_cjs.HttpClient; }
|
|
4831
|
+
});
|
|
4832
|
+
Object.defineProperty(exports, "NETWORK_CONFIG", {
|
|
4833
|
+
enumerable: true,
|
|
4834
|
+
get: function () { return chunkACLJPC75_cjs.NETWORK_CONFIG; }
|
|
4835
|
+
});
|
|
4836
|
+
Object.defineProperty(exports, "NetworkError", {
|
|
4837
|
+
enumerable: true,
|
|
4838
|
+
get: function () { return chunkACLJPC75_cjs.NetworkError; }
|
|
4839
|
+
});
|
|
4840
|
+
Object.defineProperty(exports, "PrivanaClient", {
|
|
4841
|
+
enumerable: true,
|
|
4842
|
+
get: function () { return chunkACLJPC75_cjs.PrivanaClient; }
|
|
4843
|
+
});
|
|
4844
|
+
Object.defineProperty(exports, "PrivanaProvider", {
|
|
4845
|
+
enumerable: true,
|
|
4846
|
+
get: function () { return chunkACLJPC75_cjs.PrivanaProvider; }
|
|
4847
|
+
});
|
|
4848
|
+
Object.defineProperty(exports, "SUPPORTED_CHAINS", {
|
|
4849
|
+
enumerable: true,
|
|
4850
|
+
get: function () { return chunkACLJPC75_cjs.SUPPORTED_CHAINS; }
|
|
4851
|
+
});
|
|
4852
|
+
Object.defineProperty(exports, "SiweAuthProvider", {
|
|
4853
|
+
enumerable: true,
|
|
4854
|
+
get: function () { return chunkACLJPC75_cjs.SiweAuthProvider; }
|
|
4855
|
+
});
|
|
4856
|
+
Object.defineProperty(exports, "Skeleton", {
|
|
4857
|
+
enumerable: true,
|
|
4858
|
+
get: function () { return chunkACLJPC75_cjs.Skeleton; }
|
|
4859
|
+
});
|
|
4860
|
+
Object.defineProperty(exports, "ValidationError", {
|
|
4861
|
+
enumerable: true,
|
|
4862
|
+
get: function () { return chunkACLJPC75_cjs.ValidationError; }
|
|
4863
|
+
});
|
|
4864
|
+
Object.defineProperty(exports, "applyRefreshResponse", {
|
|
4865
|
+
enumerable: true,
|
|
4866
|
+
get: function () { return chunkACLJPC75_cjs.applyRefreshResponse; }
|
|
4867
|
+
});
|
|
4868
|
+
Object.defineProperty(exports, "buildHostedAuthSession", {
|
|
4869
|
+
enumerable: true,
|
|
4870
|
+
get: function () { return chunkACLJPC75_cjs.buildHostedAuthSession; }
|
|
4871
|
+
});
|
|
4872
|
+
Object.defineProperty(exports, "buildSiweStatement", {
|
|
4873
|
+
enumerable: true,
|
|
4874
|
+
get: function () { return chunkACLJPC75_cjs.buildSiweStatement; }
|
|
4875
|
+
});
|
|
4876
|
+
Object.defineProperty(exports, "buttonVariants", {
|
|
4877
|
+
enumerable: true,
|
|
4878
|
+
get: function () { return chunkACLJPC75_cjs.buttonVariants; }
|
|
4879
|
+
});
|
|
4880
|
+
Object.defineProperty(exports, "clearHostedAuthPendingTransaction", {
|
|
4881
|
+
enumerable: true,
|
|
4882
|
+
get: function () { return chunkACLJPC75_cjs.clearHostedAuthPendingTransaction; }
|
|
4883
|
+
});
|
|
4884
|
+
Object.defineProperty(exports, "createHostedAuthPendingStorageKey", {
|
|
4885
|
+
enumerable: true,
|
|
4886
|
+
get: function () { return chunkACLJPC75_cjs.createHostedAuthPendingStorageKey; }
|
|
4887
|
+
});
|
|
4888
|
+
Object.defineProperty(exports, "createHostedAuthState", {
|
|
4889
|
+
enumerable: true,
|
|
4890
|
+
get: function () { return chunkACLJPC75_cjs.createHostedAuthState; }
|
|
4891
|
+
});
|
|
4892
|
+
Object.defineProperty(exports, "createHostedAuthStorageKey", {
|
|
4893
|
+
enumerable: true,
|
|
4894
|
+
get: function () { return chunkACLJPC75_cjs.createHostedAuthStorageKey; }
|
|
4895
|
+
});
|
|
4896
|
+
Object.defineProperty(exports, "createPkceChallenge", {
|
|
4897
|
+
enumerable: true,
|
|
4898
|
+
get: function () { return chunkACLJPC75_cjs.createPkceChallenge; }
|
|
4899
|
+
});
|
|
4900
|
+
Object.defineProperty(exports, "createPkceVerifier", {
|
|
4901
|
+
enumerable: true,
|
|
4902
|
+
get: function () { return chunkACLJPC75_cjs.createPkceVerifier; }
|
|
4903
|
+
});
|
|
4904
|
+
Object.defineProperty(exports, "getAccountingContract", {
|
|
4905
|
+
enumerable: true,
|
|
4906
|
+
get: function () { return chunkACLJPC75_cjs.getAccountingContract; }
|
|
4907
|
+
});
|
|
4908
|
+
Object.defineProperty(exports, "getApiUrl", {
|
|
4909
|
+
enumerable: true,
|
|
4910
|
+
get: function () { return chunkACLJPC75_cjs.getApiUrl; }
|
|
4911
|
+
});
|
|
4912
|
+
Object.defineProperty(exports, "getChainById", {
|
|
4913
|
+
enumerable: true,
|
|
4914
|
+
get: function () { return chunkACLJPC75_cjs.getChainById; }
|
|
4915
|
+
});
|
|
4916
|
+
Object.defineProperty(exports, "getChainId", {
|
|
4917
|
+
enumerable: true,
|
|
4918
|
+
get: function () { return chunkACLJPC75_cjs.getChainId; }
|
|
4919
|
+
});
|
|
4920
|
+
Object.defineProperty(exports, "getExplorerAddressUrl", {
|
|
4921
|
+
enumerable: true,
|
|
4922
|
+
get: function () { return chunkACLJPC75_cjs.getExplorerAddressUrl; }
|
|
4923
|
+
});
|
|
4924
|
+
Object.defineProperty(exports, "getExplorerLabel", {
|
|
3242
4925
|
enumerable: true,
|
|
3243
|
-
get: function () { return
|
|
4926
|
+
get: function () { return chunkACLJPC75_cjs.getExplorerLabel; }
|
|
3244
4927
|
});
|
|
3245
4928
|
Object.defineProperty(exports, "isHostedAuthRefreshActive", {
|
|
3246
4929
|
enumerable: true,
|
|
3247
|
-
get: function () { return
|
|
4930
|
+
get: function () { return chunkACLJPC75_cjs.isHostedAuthRefreshActive; }
|
|
3248
4931
|
});
|
|
3249
4932
|
Object.defineProperty(exports, "isHostedAuthSessionActive", {
|
|
3250
4933
|
enumerable: true,
|
|
3251
|
-
get: function () { return
|
|
4934
|
+
get: function () { return chunkACLJPC75_cjs.isHostedAuthSessionActive; }
|
|
3252
4935
|
});
|
|
3253
4936
|
Object.defineProperty(exports, "normalizeAddress", {
|
|
3254
4937
|
enumerable: true,
|
|
3255
|
-
get: function () { return
|
|
4938
|
+
get: function () { return chunkACLJPC75_cjs.normalizeAddress; }
|
|
3256
4939
|
});
|
|
3257
4940
|
Object.defineProperty(exports, "normalizeHex", {
|
|
3258
4941
|
enumerable: true,
|
|
3259
|
-
get: function () { return
|
|
4942
|
+
get: function () { return chunkACLJPC75_cjs.normalizeHex; }
|
|
3260
4943
|
});
|
|
3261
4944
|
Object.defineProperty(exports, "parseHostedAuthCallback", {
|
|
3262
4945
|
enumerable: true,
|
|
3263
|
-
get: function () { return
|
|
4946
|
+
get: function () { return chunkACLJPC75_cjs.parseHostedAuthCallback; }
|
|
3264
4947
|
});
|
|
3265
4948
|
Object.defineProperty(exports, "persistHostedAuthPendingTransaction", {
|
|
3266
4949
|
enumerable: true,
|
|
3267
|
-
get: function () { return
|
|
4950
|
+
get: function () { return chunkACLJPC75_cjs.persistHostedAuthPendingTransaction; }
|
|
3268
4951
|
});
|
|
3269
4952
|
Object.defineProperty(exports, "readHostedAuthPendingTransaction", {
|
|
3270
4953
|
enumerable: true,
|
|
3271
|
-
get: function () { return
|
|
4954
|
+
get: function () { return chunkACLJPC75_cjs.readHostedAuthPendingTransaction; }
|
|
3272
4955
|
});
|
|
3273
4956
|
Object.defineProperty(exports, "readStoredHostedAuthSession", {
|
|
3274
4957
|
enumerable: true,
|
|
3275
|
-
get: function () { return
|
|
4958
|
+
get: function () { return chunkACLJPC75_cjs.readStoredHostedAuthSession; }
|
|
3276
4959
|
});
|
|
3277
4960
|
Object.defineProperty(exports, "stripHostedAuthCallbackParams", {
|
|
3278
4961
|
enumerable: true,
|
|
3279
|
-
get: function () { return
|
|
4962
|
+
get: function () { return chunkACLJPC75_cjs.stripHostedAuthCallbackParams; }
|
|
3280
4963
|
});
|
|
3281
4964
|
Object.defineProperty(exports, "syncHostedAuthSessionToClient", {
|
|
3282
4965
|
enumerable: true,
|
|
3283
|
-
get: function () { return
|
|
4966
|
+
get: function () { return chunkACLJPC75_cjs.syncHostedAuthSessionToClient; }
|
|
3284
4967
|
});
|
|
3285
4968
|
Object.defineProperty(exports, "useDepositVerification", {
|
|
3286
4969
|
enumerable: true,
|
|
3287
|
-
get: function () { return
|
|
4970
|
+
get: function () { return chunkACLJPC75_cjs.useDepositVerification; }
|
|
3288
4971
|
});
|
|
3289
4972
|
Object.defineProperty(exports, "usePrivanaContext", {
|
|
3290
4973
|
enumerable: true,
|
|
3291
|
-
get: function () { return
|
|
4974
|
+
get: function () { return chunkACLJPC75_cjs.usePrivanaContext; }
|
|
3292
4975
|
});
|
|
3293
4976
|
Object.defineProperty(exports, "useSafeAccount", {
|
|
3294
4977
|
enumerable: true,
|
|
3295
|
-
get: function () { return
|
|
4978
|
+
get: function () { return chunkACLJPC75_cjs.useSafeAccount; }
|
|
3296
4979
|
});
|
|
3297
4980
|
Object.defineProperty(exports, "useSafePrivanaContext", {
|
|
3298
4981
|
enumerable: true,
|
|
3299
|
-
get: function () { return
|
|
4982
|
+
get: function () { return chunkACLJPC75_cjs.useSafePrivanaContext; }
|
|
3300
4983
|
});
|
|
3301
4984
|
Object.defineProperty(exports, "useSiweAuth", {
|
|
3302
4985
|
enumerable: true,
|
|
3303
|
-
get: function () { return
|
|
4986
|
+
get: function () { return chunkACLJPC75_cjs.useSiweAuth; }
|
|
3304
4987
|
});
|
|
4988
|
+
exports.DepositInlineModal = DepositInlineModal;
|
|
4989
|
+
exports.DepositModal = DepositModal;
|
|
3305
4990
|
exports.LOCK_TYPES = LOCK_TYPES;
|
|
3306
4991
|
exports.MODIFY_LOCK_TYPES = MODIFY_LOCK_TYPES;
|
|
3307
4992
|
exports.PrivanaButton = PrivanaButton;
|
|
4993
|
+
exports.PrivanaIcon = PrivanaIcon;
|
|
3308
4994
|
exports.PrivanaInlineModal = PrivanaInlineModal;
|
|
3309
4995
|
exports.PrivanaModal = PrivanaModal;
|
|
3310
4996
|
exports.TRANSFER_LOCKED_TYPES = TRANSFER_LOCKED_TYPES;
|
|
3311
4997
|
exports.TRANSFER_TYPES = TRANSFER_TYPES;
|
|
3312
4998
|
exports.WITHDRAW_FROM_LOCK_TYPES = WITHDRAW_FROM_LOCK_TYPES;
|
|
3313
4999
|
exports.WITHDRAW_TYPES = WITHDRAW_TYPES;
|
|
5000
|
+
exports.WalletInlineModal = WalletInlineModal;
|
|
5001
|
+
exports.WalletModal = WalletModal;
|
|
5002
|
+
exports.WithdrawInlineModal = WithdrawInlineModal;
|
|
5003
|
+
exports.WithdrawModal = WithdrawModal;
|
|
3314
5004
|
exports.createDomain = createDomain;
|
|
3315
5005
|
exports.createLockExpiry = createLockExpiry;
|
|
3316
5006
|
exports.getChainIcon = getChainIcon;
|
|
@@ -3324,6 +5014,7 @@ exports.signWithdrawMessage = signWithdrawMessage;
|
|
|
3324
5014
|
exports.useBalance = useBalance;
|
|
3325
5015
|
exports.useBatchBalances = useBatchBalances;
|
|
3326
5016
|
exports.useDeposit = useDeposit;
|
|
5017
|
+
exports.useDepositAddress = useDepositAddress;
|
|
3327
5018
|
exports.useExpiredLocks = useExpiredLocks;
|
|
3328
5019
|
exports.useHistory = useHistory;
|
|
3329
5020
|
exports.useHostedRedirectAuth = useHostedRedirectAuth;
|