@oasisprotocol/privana-sdk 0.4.0 → 0.4.1
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-RDMJGMI3.cjs → chunk-CRJNDCDT.cjs} +19 -3
- package/dist/chunk-CRJNDCDT.cjs.map +1 -0
- package/dist/{chunk-ZVNC4FTJ.js → chunk-ZXFQJ5MG.js} +19 -4
- package/dist/chunk-ZXFQJ5MG.js.map +1 -0
- package/dist/index.cjs +150 -157
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3 -13
- package/dist/index.js.map +1 -1
- package/dist/on-ramp.cjs +149 -52
- package/dist/on-ramp.cjs.map +1 -1
- package/dist/on-ramp.d.cts +6 -0
- package/dist/on-ramp.d.ts +6 -0
- package/dist/on-ramp.js +146 -49
- package/dist/on-ramp.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-RDMJGMI3.cjs.map +0 -1
- package/dist/chunk-ZVNC4FTJ.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunkCRJNDCDT_cjs = require('./chunk-CRJNDCDT.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var reactQuery = require('@tanstack/react-query');
|
|
7
7
|
var wagmi = require('wagmi');
|
|
@@ -229,18 +229,18 @@ async function signWithdrawFromLockMessage({
|
|
|
229
229
|
|
|
230
230
|
// src/sdk/hooks/use-privana-client.ts
|
|
231
231
|
function usePrivanaClient() {
|
|
232
|
-
const { client } =
|
|
232
|
+
const { client } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
233
233
|
return client;
|
|
234
234
|
}
|
|
235
235
|
var hostedAuthExchangeInflight = /* @__PURE__ */ new Map();
|
|
236
236
|
function normalizeHostedAuthError(error) {
|
|
237
|
-
if (error instanceof
|
|
238
|
-
return new
|
|
237
|
+
if (error instanceof chunkCRJNDCDT_cjs.AccountingApiError && error.detail) {
|
|
238
|
+
return new chunkCRJNDCDT_cjs.HostedAuthError(error.detail);
|
|
239
239
|
}
|
|
240
240
|
if (error instanceof Error) {
|
|
241
241
|
return error;
|
|
242
242
|
}
|
|
243
|
-
return new
|
|
243
|
+
return new chunkCRJNDCDT_cjs.HostedAuthError("Hosted authentication failed.");
|
|
244
244
|
}
|
|
245
245
|
function useHostedRedirectAuth() {
|
|
246
246
|
const {
|
|
@@ -251,30 +251,30 @@ function useHostedRedirectAuth() {
|
|
|
251
251
|
setHostedAuthSession,
|
|
252
252
|
clearHostedAuthSession,
|
|
253
253
|
refreshHostedAuthSession
|
|
254
|
-
} =
|
|
254
|
+
} = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
255
255
|
const [error, setError] = react.useState(null);
|
|
256
256
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
257
257
|
const loginInflight = react.useRef(null);
|
|
258
258
|
const completionInflight = react.useRef(null);
|
|
259
259
|
const pendingStorageKey = react.useMemo(
|
|
260
|
-
() => hostedAuthConfig ?
|
|
260
|
+
() => hostedAuthConfig ? chunkCRJNDCDT_cjs.createHostedAuthPendingStorageKey(client.getBaseUrl(), hostedAuthConfig) : null,
|
|
261
261
|
[client, hostedAuthConfig]
|
|
262
262
|
);
|
|
263
263
|
const clearPendingLogin = react.useCallback(() => {
|
|
264
264
|
if (!pendingStorageKey || typeof window === "undefined") return;
|
|
265
|
-
|
|
265
|
+
chunkCRJNDCDT_cjs.clearHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
|
|
266
266
|
}, [pendingStorageKey]);
|
|
267
267
|
const login = react.useCallback(async () => {
|
|
268
268
|
if (!hostedAuthConfig) {
|
|
269
|
-
throw new
|
|
269
|
+
throw new chunkCRJNDCDT_cjs.HostedAuthRequiredError(
|
|
270
270
|
"Hosted redirect authentication is not configured for this provider."
|
|
271
271
|
);
|
|
272
272
|
}
|
|
273
273
|
if (typeof window === "undefined") {
|
|
274
|
-
throw new
|
|
274
|
+
throw new chunkCRJNDCDT_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
|
|
275
275
|
}
|
|
276
276
|
if (!pendingStorageKey) {
|
|
277
|
-
throw new
|
|
277
|
+
throw new chunkCRJNDCDT_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
|
|
278
278
|
}
|
|
279
279
|
if (loginInflight.current) {
|
|
280
280
|
return loginInflight.current;
|
|
@@ -283,10 +283,10 @@ function useHostedRedirectAuth() {
|
|
|
283
283
|
setIsLoading(true);
|
|
284
284
|
setError(null);
|
|
285
285
|
try {
|
|
286
|
-
const verifier =
|
|
287
|
-
const codeChallenge = await
|
|
288
|
-
const state =
|
|
289
|
-
|
|
286
|
+
const verifier = chunkCRJNDCDT_cjs.createPkceVerifier();
|
|
287
|
+
const codeChallenge = await chunkCRJNDCDT_cjs.createPkceChallenge(verifier);
|
|
288
|
+
const state = chunkCRJNDCDT_cjs.createHostedAuthState();
|
|
289
|
+
chunkCRJNDCDT_cjs.persistHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey, {
|
|
290
290
|
codeVerifier: verifier,
|
|
291
291
|
state
|
|
292
292
|
});
|
|
@@ -315,15 +315,15 @@ function useHostedRedirectAuth() {
|
|
|
315
315
|
}, [clearPendingLogin, client, hostedAuthConfig, networkConfig.chainId, pendingStorageKey]);
|
|
316
316
|
const completeLogin = react.useCallback(async () => {
|
|
317
317
|
if (!hostedAuthConfig) {
|
|
318
|
-
throw new
|
|
318
|
+
throw new chunkCRJNDCDT_cjs.HostedAuthRequiredError(
|
|
319
319
|
"Hosted redirect authentication is not configured for this provider."
|
|
320
320
|
);
|
|
321
321
|
}
|
|
322
322
|
if (typeof window === "undefined") {
|
|
323
|
-
throw new
|
|
323
|
+
throw new chunkCRJNDCDT_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
|
|
324
324
|
}
|
|
325
325
|
if (!pendingStorageKey) {
|
|
326
|
-
throw new
|
|
326
|
+
throw new chunkCRJNDCDT_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
|
|
327
327
|
}
|
|
328
328
|
if (completionInflight.current) {
|
|
329
329
|
return completionInflight.current;
|
|
@@ -333,30 +333,30 @@ function useHostedRedirectAuth() {
|
|
|
333
333
|
setError(null);
|
|
334
334
|
const callbackUrl = new URL(window.location.href);
|
|
335
335
|
const cleanupCallbackUrl = () => {
|
|
336
|
-
window.history.replaceState(null, "",
|
|
336
|
+
window.history.replaceState(null, "", chunkCRJNDCDT_cjs.stripHostedAuthCallbackParams(callbackUrl));
|
|
337
337
|
};
|
|
338
338
|
try {
|
|
339
|
-
const callback =
|
|
339
|
+
const callback = chunkCRJNDCDT_cjs.parseHostedAuthCallback(callbackUrl, hostedAuthConfig.redirectUri);
|
|
340
340
|
if (!callback) {
|
|
341
341
|
return null;
|
|
342
342
|
}
|
|
343
|
-
const pending =
|
|
343
|
+
const pending = chunkCRJNDCDT_cjs.readHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
|
|
344
344
|
if (!pending) {
|
|
345
345
|
clearPendingLogin();
|
|
346
346
|
cleanupCallbackUrl();
|
|
347
|
-
throw new
|
|
347
|
+
throw new chunkCRJNDCDT_cjs.HostedAuthError(
|
|
348
348
|
"Hosted authentication response could not be matched to a pending login request."
|
|
349
349
|
);
|
|
350
350
|
}
|
|
351
351
|
if (!callback.state || callback.state !== pending.state) {
|
|
352
352
|
clearPendingLogin();
|
|
353
353
|
cleanupCallbackUrl();
|
|
354
|
-
throw new
|
|
354
|
+
throw new chunkCRJNDCDT_cjs.HostedAuthStateMismatchError();
|
|
355
355
|
}
|
|
356
356
|
if ("error" in callback) {
|
|
357
357
|
clearPendingLogin();
|
|
358
358
|
cleanupCallbackUrl();
|
|
359
|
-
throw new
|
|
359
|
+
throw new chunkCRJNDCDT_cjs.HostedAuthError(
|
|
360
360
|
callback.errorDescription || callback.error || "Hosted authentication failed."
|
|
361
361
|
);
|
|
362
362
|
}
|
|
@@ -371,7 +371,7 @@ function useHostedRedirectAuth() {
|
|
|
371
371
|
client_id: hostedAuthConfig.clientId,
|
|
372
372
|
redirect_uri: hostedAuthConfig.redirectUri
|
|
373
373
|
});
|
|
374
|
-
const session =
|
|
374
|
+
const session = chunkCRJNDCDT_cjs.buildHostedAuthSession(response, hostedAuthConfig);
|
|
375
375
|
setHostedAuthSession(session);
|
|
376
376
|
clearPendingLogin();
|
|
377
377
|
cleanupCallbackUrl();
|
|
@@ -416,7 +416,7 @@ function useHostedRedirectAuth() {
|
|
|
416
416
|
try {
|
|
417
417
|
return await refreshHostedAuthSession();
|
|
418
418
|
} catch (refreshError) {
|
|
419
|
-
const normalizedError = refreshError instanceof Error ? refreshError : new
|
|
419
|
+
const normalizedError = refreshError instanceof Error ? refreshError : new chunkCRJNDCDT_cjs.HostedAuthError("Hosted authentication refresh failed.");
|
|
420
420
|
setError(normalizedError);
|
|
421
421
|
throw normalizedError;
|
|
422
422
|
} finally {
|
|
@@ -436,12 +436,12 @@ function useHostedRedirectAuth() {
|
|
|
436
436
|
}
|
|
437
437
|
function useBalance(options = {}) {
|
|
438
438
|
const queryClient = react.useContext(reactQuery.QueryClientContext);
|
|
439
|
-
const accountingContext =
|
|
439
|
+
const accountingContext = chunkCRJNDCDT_cjs.useSafePrivanaContext();
|
|
440
440
|
const hasProviders = !!queryClient && !!accountingContext;
|
|
441
441
|
const client = accountingContext?.client;
|
|
442
442
|
const defaultToken = accountingContext?.defaultToken;
|
|
443
443
|
const pollingInterval = accountingContext?.pollingInterval ?? 1e4;
|
|
444
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
444
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkCRJNDCDT_cjs.usePrivateReadRequest();
|
|
445
445
|
const tokenId = options.tokenId ?? defaultToken?.id;
|
|
446
446
|
const query = reactQuery.useQuery({
|
|
447
447
|
queryKey: ["accounting-balance", ...privateReadQueryScope, tokenId],
|
|
@@ -458,7 +458,7 @@ function useBalance(options = {}) {
|
|
|
458
458
|
return {
|
|
459
459
|
balance: balanceWei,
|
|
460
460
|
balanceWei,
|
|
461
|
-
balanceFormatted:
|
|
461
|
+
balanceFormatted: chunkCRJNDCDT_cjs.formatTokenAmount(balanceWei),
|
|
462
462
|
tokenSymbol: query.data?.token_symbol ?? "",
|
|
463
463
|
chainId: query.data?.chain_id ?? "",
|
|
464
464
|
isLoading: query.isPending || query.isLoading,
|
|
@@ -468,8 +468,8 @@ function useBalance(options = {}) {
|
|
|
468
468
|
};
|
|
469
469
|
}
|
|
470
470
|
function useBatchBalances(options) {
|
|
471
|
-
const { client, pollingInterval } =
|
|
472
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
471
|
+
const { client, pollingInterval } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
472
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkCRJNDCDT_cjs.usePrivateReadRequest();
|
|
473
473
|
const query = reactQuery.useQuery({
|
|
474
474
|
queryKey: ["accounting-batch-balances", ...privateReadQueryScope, options.tokenIds],
|
|
475
475
|
queryFn: async () => {
|
|
@@ -495,7 +495,7 @@ function useEnsureCorrectChain() {
|
|
|
495
495
|
async (expectedChainId, timeoutMs, pollIntervalMs = 250) => {
|
|
496
496
|
const startedAt = Date.now();
|
|
497
497
|
while (Date.now() - startedAt < timeoutMs) {
|
|
498
|
-
const currentChainId =
|
|
498
|
+
const currentChainId = chunkCRJNDCDT_cjs.getChainId2(config);
|
|
499
499
|
if (currentChainId === expectedChainId) return true;
|
|
500
500
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
501
501
|
}
|
|
@@ -505,7 +505,7 @@ function useEnsureCorrectChain() {
|
|
|
505
505
|
);
|
|
506
506
|
const ensureCorrectChain = react.useCallback(
|
|
507
507
|
async (targetChainId) => {
|
|
508
|
-
const currentChainId =
|
|
508
|
+
const currentChainId = chunkCRJNDCDT_cjs.getChainId2(config);
|
|
509
509
|
if (currentChainId === targetChainId) return false;
|
|
510
510
|
let switchErrorMessage;
|
|
511
511
|
try {
|
|
@@ -572,11 +572,11 @@ function clearPendingDeposit(address) {
|
|
|
572
572
|
}
|
|
573
573
|
function useDeposit(options = {}) {
|
|
574
574
|
const { address } = wagmi.useAccount();
|
|
575
|
-
const { client, enabledTokens, getChainById: getChainById2 } =
|
|
575
|
+
const { client, enabledTokens, getChainById: getChainById2 } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
576
576
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
577
577
|
const queryClient = reactQuery.useQueryClient();
|
|
578
578
|
const config = wagmi.useConfig();
|
|
579
|
-
const { executePrivateRead } =
|
|
579
|
+
const { executePrivateRead } = chunkCRJNDCDT_cjs.usePrivateReadRequest();
|
|
580
580
|
const confirmations = options.confirmations ?? 15;
|
|
581
581
|
const [depositAddress, setDepositAddress] = react.useState(null);
|
|
582
582
|
const [txHash, setTxHash] = react.useState();
|
|
@@ -611,7 +611,7 @@ function useDeposit(options = {}) {
|
|
|
611
611
|
error: verificationError,
|
|
612
612
|
verify,
|
|
613
613
|
reset: resetVerification
|
|
614
|
-
} =
|
|
614
|
+
} = chunkCRJNDCDT_cjs.useDepositVerification({
|
|
615
615
|
pollInterval: options.pollInterval,
|
|
616
616
|
pollTimeout: options.pollTimeout,
|
|
617
617
|
onCredited: (hash, response) => {
|
|
@@ -699,12 +699,12 @@ function useDeposit(options = {}) {
|
|
|
699
699
|
try {
|
|
700
700
|
let confirmed = false;
|
|
701
701
|
try {
|
|
702
|
-
await
|
|
702
|
+
await chunkCRJNDCDT_cjs.getTransactionReceipt(config, { hash, chainId: persisted.chainId });
|
|
703
703
|
confirmed = true;
|
|
704
704
|
} catch {
|
|
705
705
|
}
|
|
706
706
|
if (!confirmed) {
|
|
707
|
-
await
|
|
707
|
+
await chunkCRJNDCDT_cjs.waitForTransactionReceipt(config, {
|
|
708
708
|
hash,
|
|
709
709
|
chainId: persisted.chainId,
|
|
710
710
|
confirmations
|
|
@@ -791,7 +791,7 @@ function useDeposit(options = {}) {
|
|
|
791
791
|
try {
|
|
792
792
|
setIsWaitingForConfirmation(true);
|
|
793
793
|
try {
|
|
794
|
-
await
|
|
794
|
+
await chunkCRJNDCDT_cjs.waitForTransactionReceipt(config, {
|
|
795
795
|
hash,
|
|
796
796
|
chainId: sourceChain.id,
|
|
797
797
|
confirmations
|
|
@@ -865,7 +865,7 @@ function useDeposit(options = {}) {
|
|
|
865
865
|
function useWithdraw(options = {}) {
|
|
866
866
|
const { address } = wagmi.useAccount();
|
|
867
867
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
868
|
-
const { client, networkConfig } =
|
|
868
|
+
const { client, networkConfig } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
869
869
|
const queryClient = reactQuery.useQueryClient();
|
|
870
870
|
const { chainId, ensureCorrectChain } = useEnsureCorrectChain();
|
|
871
871
|
const pollInterval = options.pollInterval ?? 3e3;
|
|
@@ -1064,7 +1064,7 @@ function useWithdraw(options = {}) {
|
|
|
1064
1064
|
function useLockFunds(options = {}) {
|
|
1065
1065
|
const { address } = wagmi.useAccount();
|
|
1066
1066
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1067
|
-
const { client, networkConfig, serviceAddress } =
|
|
1067
|
+
const { client, networkConfig, serviceAddress } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1068
1068
|
const queryClient = reactQuery.useQueryClient();
|
|
1069
1069
|
const mutation = reactQuery.useMutation({
|
|
1070
1070
|
mutationFn: async (params) => {
|
|
@@ -1123,7 +1123,7 @@ function useLockFunds(options = {}) {
|
|
|
1123
1123
|
}
|
|
1124
1124
|
function useUnlockFunds(options = {}) {
|
|
1125
1125
|
const { address } = wagmi.useAccount();
|
|
1126
|
-
const { client } =
|
|
1126
|
+
const { client } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1127
1127
|
const queryClient = reactQuery.useQueryClient();
|
|
1128
1128
|
const unlockMutation = reactQuery.useMutation({
|
|
1129
1129
|
mutationFn: async (params) => {
|
|
@@ -1191,7 +1191,7 @@ function useUnlockFunds(options = {}) {
|
|
|
1191
1191
|
function useTransfer(options = {}) {
|
|
1192
1192
|
const { address } = wagmi.useAccount();
|
|
1193
1193
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1194
|
-
const { client, networkConfig, serviceAddress } =
|
|
1194
|
+
const { client, networkConfig, serviceAddress } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1195
1195
|
const queryClient = reactQuery.useQueryClient();
|
|
1196
1196
|
const transferMutation = reactQuery.useMutation({
|
|
1197
1197
|
mutationFn: async (params) => {
|
|
@@ -1296,8 +1296,8 @@ function useTransfer(options = {}) {
|
|
|
1296
1296
|
};
|
|
1297
1297
|
}
|
|
1298
1298
|
function useLockedFunds(options = {}) {
|
|
1299
|
-
const { client, pollingInterval, serviceAddress } =
|
|
1300
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1299
|
+
const { client, pollingInterval, serviceAddress } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1300
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkCRJNDCDT_cjs.usePrivateReadRequest();
|
|
1301
1301
|
const query = reactQuery.useQuery({
|
|
1302
1302
|
queryKey: ["accounting-locked-funds", ...privateReadQueryScope, serviceAddress ?? null],
|
|
1303
1303
|
queryFn: async () => {
|
|
@@ -1319,8 +1319,8 @@ function useLockedFunds(options = {}) {
|
|
|
1319
1319
|
};
|
|
1320
1320
|
}
|
|
1321
1321
|
function useTotalLockedBalance(options = {}) {
|
|
1322
|
-
const { client, pollingInterval, defaultToken } =
|
|
1323
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1322
|
+
const { client, pollingInterval, defaultToken } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1323
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkCRJNDCDT_cjs.usePrivateReadRequest();
|
|
1324
1324
|
const tokenId = options.tokenId ?? defaultToken?.id;
|
|
1325
1325
|
const query = reactQuery.useQuery({
|
|
1326
1326
|
queryKey: ["accounting-total-locked-balance", ...privateReadQueryScope, tokenId],
|
|
@@ -1341,8 +1341,8 @@ function useTotalLockedBalance(options = {}) {
|
|
|
1341
1341
|
};
|
|
1342
1342
|
}
|
|
1343
1343
|
function useExpiredLocks(options = {}) {
|
|
1344
|
-
const { client, pollingInterval } =
|
|
1345
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1344
|
+
const { client, pollingInterval } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1345
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkCRJNDCDT_cjs.usePrivateReadRequest();
|
|
1346
1346
|
const query = reactQuery.useQuery({
|
|
1347
1347
|
queryKey: ["accounting-expired-locks", ...privateReadQueryScope],
|
|
1348
1348
|
queryFn: async () => {
|
|
@@ -1364,7 +1364,7 @@ function useExpiredLocks(options = {}) {
|
|
|
1364
1364
|
}
|
|
1365
1365
|
function usePendingWithdrawals(options = {}) {
|
|
1366
1366
|
const { address, isConnected } = wagmi.useAccount();
|
|
1367
|
-
const { client, pollingInterval } =
|
|
1367
|
+
const { client, pollingInterval } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1368
1368
|
const query = reactQuery.useQuery({
|
|
1369
1369
|
queryKey: ["accounting-pending-withdrawals", address],
|
|
1370
1370
|
queryFn: async () => {
|
|
@@ -1400,8 +1400,8 @@ function usePendingWithdrawals(options = {}) {
|
|
|
1400
1400
|
};
|
|
1401
1401
|
}
|
|
1402
1402
|
function useHistory(options = {}) {
|
|
1403
|
-
const { client, pollingInterval } =
|
|
1404
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1403
|
+
const { client, pollingInterval } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1404
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunkCRJNDCDT_cjs.usePrivateReadRequest();
|
|
1405
1405
|
const offset = options.offset ?? -1;
|
|
1406
1406
|
const limit = options.limit ?? 50;
|
|
1407
1407
|
const query = reactQuery.useQuery({
|
|
@@ -1425,7 +1425,7 @@ function useHistory(options = {}) {
|
|
|
1425
1425
|
};
|
|
1426
1426
|
}
|
|
1427
1427
|
function useTokenInfo(options = {}) {
|
|
1428
|
-
const { client } =
|
|
1428
|
+
const { client } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1429
1429
|
const { tokenId } = options;
|
|
1430
1430
|
const query = reactQuery.useQuery({
|
|
1431
1431
|
queryKey: ["accounting-token-info", tokenId],
|
|
@@ -1445,7 +1445,7 @@ function useTokenInfo(options = {}) {
|
|
|
1445
1445
|
};
|
|
1446
1446
|
}
|
|
1447
1447
|
function useTokenList(options = {}) {
|
|
1448
|
-
const { client } =
|
|
1448
|
+
const { client } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1449
1449
|
const query = reactQuery.useQuery({
|
|
1450
1450
|
queryKey: ["accounting-token-list"],
|
|
1451
1451
|
queryFn: () => client.listTokens(),
|
|
@@ -1463,7 +1463,7 @@ function useTokenList(options = {}) {
|
|
|
1463
1463
|
function useModifyLock(options = {}) {
|
|
1464
1464
|
const { address } = wagmi.useAccount();
|
|
1465
1465
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1466
|
-
const { client, networkConfig } =
|
|
1466
|
+
const { client, networkConfig } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1467
1467
|
const queryClient = reactQuery.useQueryClient();
|
|
1468
1468
|
const mutation = reactQuery.useMutation({
|
|
1469
1469
|
mutationFn: async (params) => {
|
|
@@ -1529,7 +1529,7 @@ function DialogOverlay({
|
|
|
1529
1529
|
{
|
|
1530
1530
|
"data-slot": "dialog-overlay",
|
|
1531
1531
|
"data-privana": true,
|
|
1532
|
-
className:
|
|
1532
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
1533
1533
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
1534
1534
|
className
|
|
1535
1535
|
),
|
|
@@ -1551,7 +1551,7 @@ function DialogContent({
|
|
|
1551
1551
|
{
|
|
1552
1552
|
"data-slot": "dialog-content",
|
|
1553
1553
|
"data-privana": true,
|
|
1554
|
-
className:
|
|
1554
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
1555
1555
|
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
|
|
1556
1556
|
className
|
|
1557
1557
|
),
|
|
@@ -1579,7 +1579,7 @@ function DialogHeader({ className, ...props }) {
|
|
|
1579
1579
|
"div",
|
|
1580
1580
|
{
|
|
1581
1581
|
"data-slot": "dialog-header",
|
|
1582
|
-
className:
|
|
1582
|
+
className: chunkCRJNDCDT_cjs.cn("flex flex-col gap-2 text-center sm:text-left", className),
|
|
1583
1583
|
...props
|
|
1584
1584
|
}
|
|
1585
1585
|
);
|
|
@@ -1589,7 +1589,7 @@ function DialogTitle({ className, ...props }) {
|
|
|
1589
1589
|
DialogPrimitive__namespace.Title,
|
|
1590
1590
|
{
|
|
1591
1591
|
"data-slot": "dialog-title",
|
|
1592
|
-
className:
|
|
1592
|
+
className: chunkCRJNDCDT_cjs.cn("text-lg leading-none font-semibold", className),
|
|
1593
1593
|
...props
|
|
1594
1594
|
}
|
|
1595
1595
|
);
|
|
@@ -1602,7 +1602,7 @@ function DialogDescription({
|
|
|
1602
1602
|
DialogPrimitive__namespace.Description,
|
|
1603
1603
|
{
|
|
1604
1604
|
"data-slot": "dialog-description",
|
|
1605
|
-
className:
|
|
1605
|
+
className: chunkCRJNDCDT_cjs.cn("text-muted-foreground text-sm", className),
|
|
1606
1606
|
...props
|
|
1607
1607
|
}
|
|
1608
1608
|
);
|
|
@@ -1957,7 +1957,7 @@ function DepositForm({
|
|
|
1957
1957
|
onSuccess
|
|
1958
1958
|
}) {
|
|
1959
1959
|
const { isConnected, address } = wagmi.useAccount();
|
|
1960
|
-
const { chains, getChainById: getChainById2 } =
|
|
1960
|
+
const { chains, getChainById: getChainById2 } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
1961
1961
|
const [amount, setAmount] = react.useState("");
|
|
1962
1962
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
1963
1963
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
@@ -1982,7 +1982,7 @@ function DepositForm({
|
|
|
1982
1982
|
}
|
|
1983
1983
|
});
|
|
1984
1984
|
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
1985
|
-
const formattedWalletBalance = walletBalance ?
|
|
1985
|
+
const formattedWalletBalance = walletBalance ? chunkCRJNDCDT_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
|
|
1986
1986
|
const handleMaxClick = () => {
|
|
1987
1987
|
if (formattedWalletBalance && parseFloat(formattedWalletBalance) > 0) {
|
|
1988
1988
|
setAmount(formattedWalletBalance.replace(/[\s\u2009]/g, ""));
|
|
@@ -1990,7 +1990,7 @@ function DepositForm({
|
|
|
1990
1990
|
};
|
|
1991
1991
|
const hasValidAmount = amount && parseFloat(amount) > 0;
|
|
1992
1992
|
const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
1993
|
-
const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null &&
|
|
1993
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null && chunkCRJNDCDT_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
|
|
1994
1994
|
const {
|
|
1995
1995
|
txHash,
|
|
1996
1996
|
isGettingAddress,
|
|
@@ -2075,7 +2075,7 @@ function DepositForm({
|
|
|
2075
2075
|
const handleSubmit = async () => {
|
|
2076
2076
|
if (!amount || !selectedToken || exceedsBalance) return;
|
|
2077
2077
|
setCancelled(false);
|
|
2078
|
-
const amountInWei =
|
|
2078
|
+
const amountInWei = chunkCRJNDCDT_cjs.parseTokenAmount(amount, selectedToken.decimals);
|
|
2079
2079
|
await deposit({
|
|
2080
2080
|
tokenId: selectedToken.id,
|
|
2081
2081
|
amount: amountInWei
|
|
@@ -2178,7 +2178,7 @@ function DepositForm({
|
|
|
2178
2178
|
setAmount(value);
|
|
2179
2179
|
}
|
|
2180
2180
|
},
|
|
2181
|
-
className:
|
|
2181
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2182
2182
|
"text-foreground flex-1 bg-transparent text-sm outline-none",
|
|
2183
2183
|
"placeholder:text-muted-foreground/50"
|
|
2184
2184
|
)
|
|
@@ -2205,7 +2205,7 @@ function DepositForm({
|
|
|
2205
2205
|
{
|
|
2206
2206
|
onClick: handleSubmit,
|
|
2207
2207
|
disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
|
|
2208
|
-
className:
|
|
2208
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2209
2209
|
"flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
|
|
2210
2210
|
"bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2211
2211
|
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
@@ -2222,7 +2222,7 @@ function WithdrawForm({
|
|
|
2222
2222
|
onUnsafeToCloseChange
|
|
2223
2223
|
}) {
|
|
2224
2224
|
const { isConnected, address } = wagmi.useAccount();
|
|
2225
|
-
const { chains, getChainById: getChainById2 } =
|
|
2225
|
+
const { chains, getChainById: getChainById2 } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
2226
2226
|
const [amount, setAmount] = react.useState("");
|
|
2227
2227
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
2228
2228
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
@@ -2235,7 +2235,7 @@ function WithdrawForm({
|
|
|
2235
2235
|
} = useBalance({
|
|
2236
2236
|
tokenId: selectedToken.id
|
|
2237
2237
|
});
|
|
2238
|
-
const formattedBalance =
|
|
2238
|
+
const formattedBalance = chunkCRJNDCDT_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
|
|
2239
2239
|
const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
|
|
2240
2240
|
onProcessingSuccess: () => {
|
|
2241
2241
|
setAmount("");
|
|
@@ -2246,7 +2246,7 @@ function WithdrawForm({
|
|
|
2246
2246
|
setShowTimeout(true);
|
|
2247
2247
|
}
|
|
2248
2248
|
});
|
|
2249
|
-
const explorerUrl = address && targetChain ?
|
|
2249
|
+
const explorerUrl = address && targetChain ? chunkCRJNDCDT_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
|
|
2250
2250
|
const getStepStatus = (step, after) => {
|
|
2251
2251
|
if (currentStep === step) return "active";
|
|
2252
2252
|
if (after.includes(currentStep)) return "completed";
|
|
@@ -2290,7 +2290,7 @@ function WithdrawForm({
|
|
|
2290
2290
|
const handleWithdraw = async () => {
|
|
2291
2291
|
if (!amount || !selectedToken || exceedsBalance) return;
|
|
2292
2292
|
setCancelled(false);
|
|
2293
|
-
const amountInWei =
|
|
2293
|
+
const amountInWei = chunkCRJNDCDT_cjs.parseTokenAmount(amount, selectedToken.decimals);
|
|
2294
2294
|
await withdraw({
|
|
2295
2295
|
tokenId: selectedToken.id,
|
|
2296
2296
|
amount: amountInWei
|
|
@@ -2303,7 +2303,7 @@ function WithdrawForm({
|
|
|
2303
2303
|
};
|
|
2304
2304
|
const hasValidAmount = amount && parseFloat(amount) > 0;
|
|
2305
2305
|
const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
2306
|
-
const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError &&
|
|
2306
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError && chunkCRJNDCDT_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
|
|
2307
2307
|
const getButtonText = () => {
|
|
2308
2308
|
if (!isConnected) return "Connect Wallet";
|
|
2309
2309
|
return "Withdraw";
|
|
@@ -2386,7 +2386,7 @@ function WithdrawForm({
|
|
|
2386
2386
|
setAmount(value);
|
|
2387
2387
|
}
|
|
2388
2388
|
},
|
|
2389
|
-
className:
|
|
2389
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2390
2390
|
"text-foreground flex-1 bg-transparent text-sm outline-none",
|
|
2391
2391
|
"placeholder:text-muted-foreground/50"
|
|
2392
2392
|
)
|
|
@@ -2413,7 +2413,7 @@ function WithdrawForm({
|
|
|
2413
2413
|
{
|
|
2414
2414
|
onClick: handleWithdraw,
|
|
2415
2415
|
disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
|
|
2416
|
-
className:
|
|
2416
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2417
2417
|
"flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
|
|
2418
2418
|
"bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2419
2419
|
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
@@ -2468,7 +2468,7 @@ function ChevronDown({ collapsed }) {
|
|
|
2468
2468
|
width: "12",
|
|
2469
2469
|
height: "6",
|
|
2470
2470
|
viewBox: "0 0 12 6",
|
|
2471
|
-
className:
|
|
2471
|
+
className: chunkCRJNDCDT_cjs.cn("transition-transform", collapsed && "-rotate-90"),
|
|
2472
2472
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2473
2473
|
"path",
|
|
2474
2474
|
{
|
|
@@ -2494,15 +2494,15 @@ function BalanceCards({
|
|
|
2494
2494
|
tokenId: selectedToken.id
|
|
2495
2495
|
});
|
|
2496
2496
|
const { totalLocked, isLoading: lockedLoading } = useLockedFunds({ enabled: showLockedFunds });
|
|
2497
|
-
const formattedBalance =
|
|
2498
|
-
const formattedLocked = showLockedFunds ?
|
|
2499
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className:
|
|
2497
|
+
const formattedBalance = chunkCRJNDCDT_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
|
|
2498
|
+
const formattedLocked = showLockedFunds ? chunkCRJNDCDT_cjs.formatTokenAmount(String(totalLocked), selectedToken.decimals) : "0.00";
|
|
2499
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkCRJNDCDT_cjs.cn("flex gap-2", disabled && "opacity-50"), children: [
|
|
2500
2500
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2501
2501
|
"button",
|
|
2502
2502
|
{
|
|
2503
2503
|
onClick: onBalanceClick,
|
|
2504
2504
|
disabled,
|
|
2505
|
-
className:
|
|
2505
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2506
2506
|
"bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
|
|
2507
2507
|
disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
|
|
2508
2508
|
),
|
|
@@ -2523,7 +2523,7 @@ function BalanceCards({
|
|
|
2523
2523
|
{
|
|
2524
2524
|
onClick: onLockedFundsClick,
|
|
2525
2525
|
disabled,
|
|
2526
|
-
className:
|
|
2526
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2527
2527
|
"bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
|
|
2528
2528
|
disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
|
|
2529
2529
|
),
|
|
@@ -2549,7 +2549,7 @@ function Tabs({
|
|
|
2549
2549
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2550
2550
|
"div",
|
|
2551
2551
|
{
|
|
2552
|
-
className:
|
|
2552
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2553
2553
|
"bg-muted relative flex gap-2 overflow-hidden rounded-[10px] p-1",
|
|
2554
2554
|
disabled && "opacity-50"
|
|
2555
2555
|
),
|
|
@@ -2557,7 +2557,7 @@ function Tabs({
|
|
|
2557
2557
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2558
2558
|
"div",
|
|
2559
2559
|
{
|
|
2560
|
-
className:
|
|
2560
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2561
2561
|
"bg-input absolute top-1 bottom-1 left-1 w-[calc(50%-8px)] rounded-md transition-transform duration-200",
|
|
2562
2562
|
activeTab === "withdraw" && "translate-x-[calc(100%+8px)]"
|
|
2563
2563
|
)
|
|
@@ -2568,7 +2568,7 @@ function Tabs({
|
|
|
2568
2568
|
{
|
|
2569
2569
|
onClick: () => !disabled && onTabChange("deposit"),
|
|
2570
2570
|
disabled,
|
|
2571
|
-
className:
|
|
2571
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2572
2572
|
"relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
|
|
2573
2573
|
activeTab === "deposit" ? "text-foreground" : "text-muted-foreground",
|
|
2574
2574
|
disabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
@@ -2581,7 +2581,7 @@ function Tabs({
|
|
|
2581
2581
|
{
|
|
2582
2582
|
onClick: () => !disabled && onTabChange("withdraw"),
|
|
2583
2583
|
disabled,
|
|
2584
|
-
className:
|
|
2584
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2585
2585
|
"relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
|
|
2586
2586
|
activeTab === "withdraw" ? "text-foreground" : "text-muted-foreground",
|
|
2587
2587
|
disabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
@@ -2594,14 +2594,14 @@ function Tabs({
|
|
|
2594
2594
|
);
|
|
2595
2595
|
}
|
|
2596
2596
|
function LockedFundsView({ onBack }) {
|
|
2597
|
-
const { getTokenById } =
|
|
2597
|
+
const { getTokenById } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
2598
2598
|
const { locks, isLoading } = useLockedFunds();
|
|
2599
2599
|
const { unlockFunds, unlockAllExpired, isPending } = useUnlockFunds();
|
|
2600
2600
|
const [collapsedSections, setCollapsedSections] = react.useState({});
|
|
2601
2601
|
const sections = react.useMemo(() => {
|
|
2602
2602
|
const sectionMap = {};
|
|
2603
2603
|
locks.forEach((lock) => {
|
|
2604
|
-
const serviceName =
|
|
2604
|
+
const serviceName = chunkCRJNDCDT_cjs.shortenAddress(lock.service_address);
|
|
2605
2605
|
if (!sectionMap[lock.service_address]) {
|
|
2606
2606
|
sectionMap[lock.service_address] = {
|
|
2607
2607
|
title: `Service ${serviceName}`,
|
|
@@ -2610,9 +2610,9 @@ function LockedFundsView({ onBack }) {
|
|
|
2610
2610
|
}
|
|
2611
2611
|
sectionMap[lock.service_address].items.push({
|
|
2612
2612
|
lockId: lock.lock_id,
|
|
2613
|
-
amount:
|
|
2613
|
+
amount: chunkCRJNDCDT_cjs.formatTokenAmount(String(lock.amount), getTokenById(lock.token_id)?.decimals ?? 18),
|
|
2614
2614
|
serviceAddress: lock.service_address,
|
|
2615
|
-
time: lock.is_expired ? "Click to unlock" :
|
|
2615
|
+
time: lock.is_expired ? "Click to unlock" : chunkCRJNDCDT_cjs.formatTimeRemaining(lock.expiry),
|
|
2616
2616
|
isExpired: lock.is_expired
|
|
2617
2617
|
});
|
|
2618
2618
|
});
|
|
@@ -2659,7 +2659,7 @@ function LockedFundsView({ onBack }) {
|
|
|
2659
2659
|
!collapsedSections[section.title] && section.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2660
2660
|
"div",
|
|
2661
2661
|
{
|
|
2662
|
-
className:
|
|
2662
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2663
2663
|
"flex items-center justify-between gap-3 rounded-lg p-3",
|
|
2664
2664
|
item.isExpired && "bg-secondary"
|
|
2665
2665
|
),
|
|
@@ -2673,7 +2673,7 @@ function LockedFundsView({ onBack }) {
|
|
|
2673
2673
|
] }),
|
|
2674
2674
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-xs", children: [
|
|
2675
2675
|
"Service: ",
|
|
2676
|
-
|
|
2676
|
+
chunkCRJNDCDT_cjs.shortenAddress(item.serviceAddress)
|
|
2677
2677
|
] })
|
|
2678
2678
|
] })
|
|
2679
2679
|
] }),
|
|
@@ -2714,7 +2714,7 @@ function BalanceTokenRow({ token }) {
|
|
|
2714
2714
|
const { balanceWei, isLoading } = useBalance({
|
|
2715
2715
|
tokenId: token.id
|
|
2716
2716
|
});
|
|
2717
|
-
const formattedBalance =
|
|
2717
|
+
const formattedBalance = chunkCRJNDCDT_cjs.formatTokenAmount(balanceWei, token.decimals);
|
|
2718
2718
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-2 rounded-lg px-3 py-2.5", children: [
|
|
2719
2719
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-[18px] w-[18px] overflow-hidden rounded-full", children: getTokenIcon(token.symbol, 18) }),
|
|
2720
2720
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground flex-1 text-sm", children: token.symbol }),
|
|
@@ -2722,7 +2722,7 @@ function BalanceTokenRow({ token }) {
|
|
|
2722
2722
|
] });
|
|
2723
2723
|
}
|
|
2724
2724
|
function BalanceDetailsView({ onBack }) {
|
|
2725
|
-
const { enabledTokens, chains } =
|
|
2725
|
+
const { enabledTokens, chains } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
2726
2726
|
const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
|
|
2727
2727
|
const chainTokens = react.useMemo(() => {
|
|
2728
2728
|
return enabledTokens.filter((t) => t.chainId === selectedChainId);
|
|
@@ -2748,7 +2748,7 @@ function BalanceDetailsView({ onBack }) {
|
|
|
2748
2748
|
"button",
|
|
2749
2749
|
{
|
|
2750
2750
|
onClick: () => setSelectedChainId(chain.id),
|
|
2751
|
-
className:
|
|
2751
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2752
2752
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2753
2753
|
isSelected && "bg-secondary"
|
|
2754
2754
|
),
|
|
@@ -2789,12 +2789,12 @@ function TokenRow({
|
|
|
2789
2789
|
query: { enabled: !!address && !isNative }
|
|
2790
2790
|
});
|
|
2791
2791
|
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
2792
|
-
const formattedBalance = walletBalance ?
|
|
2792
|
+
const formattedBalance = walletBalance ? chunkCRJNDCDT_cjs.formatTokenAmount(walletBalance.toString(), token.decimals) : "0.00";
|
|
2793
2793
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2794
2794
|
"button",
|
|
2795
2795
|
{
|
|
2796
2796
|
onClick,
|
|
2797
|
-
className:
|
|
2797
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2798
2798
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2799
2799
|
isSelected && "bg-secondary"
|
|
2800
2800
|
),
|
|
@@ -2811,7 +2811,7 @@ function TokenSelectorView({
|
|
|
2811
2811
|
onSelect,
|
|
2812
2812
|
selectedTokenId
|
|
2813
2813
|
}) {
|
|
2814
|
-
const { enabledTokens, chains } =
|
|
2814
|
+
const { enabledTokens, chains } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
2815
2815
|
const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
|
|
2816
2816
|
const chainTokens = react.useMemo(() => {
|
|
2817
2817
|
return enabledTokens.filter((t) => t.chainId === selectedChainId);
|
|
@@ -2841,7 +2841,7 @@ function TokenSelectorView({
|
|
|
2841
2841
|
"button",
|
|
2842
2842
|
{
|
|
2843
2843
|
onClick: () => setSelectedChainId(chain.id),
|
|
2844
|
-
className:
|
|
2844
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
2845
2845
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2846
2846
|
isSelected && "bg-secondary"
|
|
2847
2847
|
),
|
|
@@ -2876,7 +2876,7 @@ function ModalBody({
|
|
|
2876
2876
|
defaultTab = "deposit",
|
|
2877
2877
|
onDepositSuccess
|
|
2878
2878
|
}) {
|
|
2879
|
-
const { defaultToken, tokensStatus } =
|
|
2879
|
+
const { defaultToken, tokensStatus } = chunkCRJNDCDT_cjs.usePrivanaContext();
|
|
2880
2880
|
const [selectedToken, setSelectedToken] = react.useState(defaultToken);
|
|
2881
2881
|
const [activeTab, setActiveTab] = react.useState(defaultTab);
|
|
2882
2882
|
const [currentView, setCurrentView] = react.useState("main");
|
|
@@ -2934,7 +2934,7 @@ function ModalBody({
|
|
|
2934
2934
|
);
|
|
2935
2935
|
}
|
|
2936
2936
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 pb-4", children: [
|
|
2937
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
2937
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkCRJNDCDT_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2938
2938
|
BalanceCards,
|
|
2939
2939
|
{
|
|
2940
2940
|
selectedToken,
|
|
@@ -2944,7 +2944,7 @@ function ModalBody({
|
|
|
2944
2944
|
disabled: isInteractionPending
|
|
2945
2945
|
}
|
|
2946
2946
|
) }),
|
|
2947
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
2947
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkCRJNDCDT_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(Tabs, { activeTab, onTabChange: setActiveTab, disabled: isInteractionPending }) }),
|
|
2948
2948
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted rounded-[10px] p-5", children: activeTab === "deposit" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2949
2949
|
DepositForm,
|
|
2950
2950
|
{
|
|
@@ -3005,7 +3005,7 @@ function PrivanaModal({
|
|
|
3005
3005
|
onClick: handleClose,
|
|
3006
3006
|
disabled: isCloseBlocked,
|
|
3007
3007
|
"aria-label": "Close",
|
|
3008
|
-
className:
|
|
3008
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
3009
3009
|
"absolute top-6 right-5 z-20 flex h-6 w-6 items-center justify-center transition-colors",
|
|
3010
3010
|
isCloseBlocked ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
|
|
3011
3011
|
),
|
|
@@ -3061,7 +3061,7 @@ function PrivanaInlineModal({
|
|
|
3061
3061
|
"div",
|
|
3062
3062
|
{
|
|
3063
3063
|
"data-privana": true,
|
|
3064
|
-
className:
|
|
3064
|
+
className: chunkCRJNDCDT_cjs.cn(
|
|
3065
3065
|
"bg-card flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
3066
3066
|
className
|
|
3067
3067
|
),
|
|
@@ -3096,12 +3096,12 @@ function PrivanaButton({
|
|
|
3096
3096
|
}
|
|
3097
3097
|
const handleClick = () => setModalOpen(true);
|
|
3098
3098
|
const buttonElement = renderButton ? renderButton({ onClick: handleClick, isOpen: modalOpen }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3099
|
-
|
|
3099
|
+
chunkCRJNDCDT_cjs.Button,
|
|
3100
3100
|
{
|
|
3101
3101
|
variant,
|
|
3102
3102
|
size,
|
|
3103
3103
|
asChild,
|
|
3104
|
-
className:
|
|
3104
|
+
className: chunkCRJNDCDT_cjs.cn(className),
|
|
3105
3105
|
onClick: handleClick,
|
|
3106
3106
|
disabled: !isConnected,
|
|
3107
3107
|
...buttonProps,
|
|
@@ -3122,195 +3122,188 @@ function PrivanaButton({
|
|
|
3122
3122
|
)
|
|
3123
3123
|
] });
|
|
3124
3124
|
}
|
|
3125
|
-
function Skeleton({ className, ...props }) {
|
|
3126
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3127
|
-
"div",
|
|
3128
|
-
{
|
|
3129
|
-
"data-slot": "skeleton",
|
|
3130
|
-
className: chunkRDMJGMI3_cjs.cn("bg-accent animate-pulse rounded-md", className),
|
|
3131
|
-
...props
|
|
3132
|
-
}
|
|
3133
|
-
);
|
|
3134
|
-
}
|
|
3135
3125
|
|
|
3136
3126
|
Object.defineProperty(exports, "AccountingApiError", {
|
|
3137
3127
|
enumerable: true,
|
|
3138
|
-
get: function () { return
|
|
3128
|
+
get: function () { return chunkCRJNDCDT_cjs.AccountingApiError; }
|
|
3139
3129
|
});
|
|
3140
3130
|
Object.defineProperty(exports, "Button", {
|
|
3141
3131
|
enumerable: true,
|
|
3142
|
-
get: function () { return
|
|
3132
|
+
get: function () { return chunkCRJNDCDT_cjs.Button; }
|
|
3143
3133
|
});
|
|
3144
3134
|
Object.defineProperty(exports, "HOSTED_AUTH_CLOCK_SKEW_MS", {
|
|
3145
3135
|
enumerable: true,
|
|
3146
|
-
get: function () { return
|
|
3136
|
+
get: function () { return chunkCRJNDCDT_cjs.HOSTED_AUTH_CLOCK_SKEW_MS; }
|
|
3147
3137
|
});
|
|
3148
3138
|
Object.defineProperty(exports, "HostedAuthError", {
|
|
3149
3139
|
enumerable: true,
|
|
3150
|
-
get: function () { return
|
|
3140
|
+
get: function () { return chunkCRJNDCDT_cjs.HostedAuthError; }
|
|
3151
3141
|
});
|
|
3152
3142
|
Object.defineProperty(exports, "HostedAuthRequiredError", {
|
|
3153
3143
|
enumerable: true,
|
|
3154
|
-
get: function () { return
|
|
3144
|
+
get: function () { return chunkCRJNDCDT_cjs.HostedAuthRequiredError; }
|
|
3155
3145
|
});
|
|
3156
3146
|
Object.defineProperty(exports, "HostedAuthStateMismatchError", {
|
|
3157
3147
|
enumerable: true,
|
|
3158
|
-
get: function () { return
|
|
3148
|
+
get: function () { return chunkCRJNDCDT_cjs.HostedAuthStateMismatchError; }
|
|
3159
3149
|
});
|
|
3160
3150
|
Object.defineProperty(exports, "HttpClient", {
|
|
3161
3151
|
enumerable: true,
|
|
3162
|
-
get: function () { return
|
|
3152
|
+
get: function () { return chunkCRJNDCDT_cjs.HttpClient; }
|
|
3163
3153
|
});
|
|
3164
3154
|
Object.defineProperty(exports, "NETWORK_CONFIG", {
|
|
3165
3155
|
enumerable: true,
|
|
3166
|
-
get: function () { return
|
|
3156
|
+
get: function () { return chunkCRJNDCDT_cjs.NETWORK_CONFIG; }
|
|
3167
3157
|
});
|
|
3168
3158
|
Object.defineProperty(exports, "NetworkError", {
|
|
3169
3159
|
enumerable: true,
|
|
3170
|
-
get: function () { return
|
|
3160
|
+
get: function () { return chunkCRJNDCDT_cjs.NetworkError; }
|
|
3171
3161
|
});
|
|
3172
3162
|
Object.defineProperty(exports, "PrivanaClient", {
|
|
3173
3163
|
enumerable: true,
|
|
3174
|
-
get: function () { return
|
|
3164
|
+
get: function () { return chunkCRJNDCDT_cjs.PrivanaClient; }
|
|
3175
3165
|
});
|
|
3176
3166
|
Object.defineProperty(exports, "PrivanaProvider", {
|
|
3177
3167
|
enumerable: true,
|
|
3178
|
-
get: function () { return
|
|
3168
|
+
get: function () { return chunkCRJNDCDT_cjs.PrivanaProvider; }
|
|
3179
3169
|
});
|
|
3180
3170
|
Object.defineProperty(exports, "SUPPORTED_CHAINS", {
|
|
3181
3171
|
enumerable: true,
|
|
3182
|
-
get: function () { return
|
|
3172
|
+
get: function () { return chunkCRJNDCDT_cjs.SUPPORTED_CHAINS; }
|
|
3183
3173
|
});
|
|
3184
3174
|
Object.defineProperty(exports, "SiweAuthProvider", {
|
|
3185
3175
|
enumerable: true,
|
|
3186
|
-
get: function () { return
|
|
3176
|
+
get: function () { return chunkCRJNDCDT_cjs.SiweAuthProvider; }
|
|
3177
|
+
});
|
|
3178
|
+
Object.defineProperty(exports, "Skeleton", {
|
|
3179
|
+
enumerable: true,
|
|
3180
|
+
get: function () { return chunkCRJNDCDT_cjs.Skeleton; }
|
|
3187
3181
|
});
|
|
3188
3182
|
Object.defineProperty(exports, "ValidationError", {
|
|
3189
3183
|
enumerable: true,
|
|
3190
|
-
get: function () { return
|
|
3184
|
+
get: function () { return chunkCRJNDCDT_cjs.ValidationError; }
|
|
3191
3185
|
});
|
|
3192
3186
|
Object.defineProperty(exports, "applyRefreshResponse", {
|
|
3193
3187
|
enumerable: true,
|
|
3194
|
-
get: function () { return
|
|
3188
|
+
get: function () { return chunkCRJNDCDT_cjs.applyRefreshResponse; }
|
|
3195
3189
|
});
|
|
3196
3190
|
Object.defineProperty(exports, "buildHostedAuthSession", {
|
|
3197
3191
|
enumerable: true,
|
|
3198
|
-
get: function () { return
|
|
3192
|
+
get: function () { return chunkCRJNDCDT_cjs.buildHostedAuthSession; }
|
|
3199
3193
|
});
|
|
3200
3194
|
Object.defineProperty(exports, "buttonVariants", {
|
|
3201
3195
|
enumerable: true,
|
|
3202
|
-
get: function () { return
|
|
3196
|
+
get: function () { return chunkCRJNDCDT_cjs.buttonVariants; }
|
|
3203
3197
|
});
|
|
3204
3198
|
Object.defineProperty(exports, "clearHostedAuthPendingTransaction", {
|
|
3205
3199
|
enumerable: true,
|
|
3206
|
-
get: function () { return
|
|
3200
|
+
get: function () { return chunkCRJNDCDT_cjs.clearHostedAuthPendingTransaction; }
|
|
3207
3201
|
});
|
|
3208
3202
|
Object.defineProperty(exports, "createHostedAuthPendingStorageKey", {
|
|
3209
3203
|
enumerable: true,
|
|
3210
|
-
get: function () { return
|
|
3204
|
+
get: function () { return chunkCRJNDCDT_cjs.createHostedAuthPendingStorageKey; }
|
|
3211
3205
|
});
|
|
3212
3206
|
Object.defineProperty(exports, "createHostedAuthState", {
|
|
3213
3207
|
enumerable: true,
|
|
3214
|
-
get: function () { return
|
|
3208
|
+
get: function () { return chunkCRJNDCDT_cjs.createHostedAuthState; }
|
|
3215
3209
|
});
|
|
3216
3210
|
Object.defineProperty(exports, "createHostedAuthStorageKey", {
|
|
3217
3211
|
enumerable: true,
|
|
3218
|
-
get: function () { return
|
|
3212
|
+
get: function () { return chunkCRJNDCDT_cjs.createHostedAuthStorageKey; }
|
|
3219
3213
|
});
|
|
3220
3214
|
Object.defineProperty(exports, "createPkceChallenge", {
|
|
3221
3215
|
enumerable: true,
|
|
3222
|
-
get: function () { return
|
|
3216
|
+
get: function () { return chunkCRJNDCDT_cjs.createPkceChallenge; }
|
|
3223
3217
|
});
|
|
3224
3218
|
Object.defineProperty(exports, "createPkceVerifier", {
|
|
3225
3219
|
enumerable: true,
|
|
3226
|
-
get: function () { return
|
|
3220
|
+
get: function () { return chunkCRJNDCDT_cjs.createPkceVerifier; }
|
|
3227
3221
|
});
|
|
3228
3222
|
Object.defineProperty(exports, "getAccountingContract", {
|
|
3229
3223
|
enumerable: true,
|
|
3230
|
-
get: function () { return
|
|
3224
|
+
get: function () { return chunkCRJNDCDT_cjs.getAccountingContract; }
|
|
3231
3225
|
});
|
|
3232
3226
|
Object.defineProperty(exports, "getApiUrl", {
|
|
3233
3227
|
enumerable: true,
|
|
3234
|
-
get: function () { return
|
|
3228
|
+
get: function () { return chunkCRJNDCDT_cjs.getApiUrl; }
|
|
3235
3229
|
});
|
|
3236
3230
|
Object.defineProperty(exports, "getChainById", {
|
|
3237
3231
|
enumerable: true,
|
|
3238
|
-
get: function () { return
|
|
3232
|
+
get: function () { return chunkCRJNDCDT_cjs.getChainById; }
|
|
3239
3233
|
});
|
|
3240
3234
|
Object.defineProperty(exports, "getChainId", {
|
|
3241
3235
|
enumerable: true,
|
|
3242
|
-
get: function () { return
|
|
3236
|
+
get: function () { return chunkCRJNDCDT_cjs.getChainId; }
|
|
3243
3237
|
});
|
|
3244
3238
|
Object.defineProperty(exports, "getExplorerAddressUrl", {
|
|
3245
3239
|
enumerable: true,
|
|
3246
|
-
get: function () { return
|
|
3240
|
+
get: function () { return chunkCRJNDCDT_cjs.getExplorerAddressUrl; }
|
|
3247
3241
|
});
|
|
3248
3242
|
Object.defineProperty(exports, "isHostedAuthRefreshActive", {
|
|
3249
3243
|
enumerable: true,
|
|
3250
|
-
get: function () { return
|
|
3244
|
+
get: function () { return chunkCRJNDCDT_cjs.isHostedAuthRefreshActive; }
|
|
3251
3245
|
});
|
|
3252
3246
|
Object.defineProperty(exports, "isHostedAuthSessionActive", {
|
|
3253
3247
|
enumerable: true,
|
|
3254
|
-
get: function () { return
|
|
3248
|
+
get: function () { return chunkCRJNDCDT_cjs.isHostedAuthSessionActive; }
|
|
3255
3249
|
});
|
|
3256
3250
|
Object.defineProperty(exports, "normalizeAddress", {
|
|
3257
3251
|
enumerable: true,
|
|
3258
|
-
get: function () { return
|
|
3252
|
+
get: function () { return chunkCRJNDCDT_cjs.normalizeAddress; }
|
|
3259
3253
|
});
|
|
3260
3254
|
Object.defineProperty(exports, "normalizeHex", {
|
|
3261
3255
|
enumerable: true,
|
|
3262
|
-
get: function () { return
|
|
3256
|
+
get: function () { return chunkCRJNDCDT_cjs.normalizeHex; }
|
|
3263
3257
|
});
|
|
3264
3258
|
Object.defineProperty(exports, "parseHostedAuthCallback", {
|
|
3265
3259
|
enumerable: true,
|
|
3266
|
-
get: function () { return
|
|
3260
|
+
get: function () { return chunkCRJNDCDT_cjs.parseHostedAuthCallback; }
|
|
3267
3261
|
});
|
|
3268
3262
|
Object.defineProperty(exports, "persistHostedAuthPendingTransaction", {
|
|
3269
3263
|
enumerable: true,
|
|
3270
|
-
get: function () { return
|
|
3264
|
+
get: function () { return chunkCRJNDCDT_cjs.persistHostedAuthPendingTransaction; }
|
|
3271
3265
|
});
|
|
3272
3266
|
Object.defineProperty(exports, "readHostedAuthPendingTransaction", {
|
|
3273
3267
|
enumerable: true,
|
|
3274
|
-
get: function () { return
|
|
3268
|
+
get: function () { return chunkCRJNDCDT_cjs.readHostedAuthPendingTransaction; }
|
|
3275
3269
|
});
|
|
3276
3270
|
Object.defineProperty(exports, "readStoredHostedAuthSession", {
|
|
3277
3271
|
enumerable: true,
|
|
3278
|
-
get: function () { return
|
|
3272
|
+
get: function () { return chunkCRJNDCDT_cjs.readStoredHostedAuthSession; }
|
|
3279
3273
|
});
|
|
3280
3274
|
Object.defineProperty(exports, "stripHostedAuthCallbackParams", {
|
|
3281
3275
|
enumerable: true,
|
|
3282
|
-
get: function () { return
|
|
3276
|
+
get: function () { return chunkCRJNDCDT_cjs.stripHostedAuthCallbackParams; }
|
|
3283
3277
|
});
|
|
3284
3278
|
Object.defineProperty(exports, "syncHostedAuthSessionToClient", {
|
|
3285
3279
|
enumerable: true,
|
|
3286
|
-
get: function () { return
|
|
3280
|
+
get: function () { return chunkCRJNDCDT_cjs.syncHostedAuthSessionToClient; }
|
|
3287
3281
|
});
|
|
3288
3282
|
Object.defineProperty(exports, "useDepositVerification", {
|
|
3289
3283
|
enumerable: true,
|
|
3290
|
-
get: function () { return
|
|
3284
|
+
get: function () { return chunkCRJNDCDT_cjs.useDepositVerification; }
|
|
3291
3285
|
});
|
|
3292
3286
|
Object.defineProperty(exports, "usePrivanaContext", {
|
|
3293
3287
|
enumerable: true,
|
|
3294
|
-
get: function () { return
|
|
3288
|
+
get: function () { return chunkCRJNDCDT_cjs.usePrivanaContext; }
|
|
3295
3289
|
});
|
|
3296
3290
|
Object.defineProperty(exports, "useSafeAccount", {
|
|
3297
3291
|
enumerable: true,
|
|
3298
|
-
get: function () { return
|
|
3292
|
+
get: function () { return chunkCRJNDCDT_cjs.useSafeAccount; }
|
|
3299
3293
|
});
|
|
3300
3294
|
Object.defineProperty(exports, "useSafePrivanaContext", {
|
|
3301
3295
|
enumerable: true,
|
|
3302
|
-
get: function () { return
|
|
3296
|
+
get: function () { return chunkCRJNDCDT_cjs.useSafePrivanaContext; }
|
|
3303
3297
|
});
|
|
3304
3298
|
Object.defineProperty(exports, "useSiweAuth", {
|
|
3305
3299
|
enumerable: true,
|
|
3306
|
-
get: function () { return
|
|
3300
|
+
get: function () { return chunkCRJNDCDT_cjs.useSiweAuth; }
|
|
3307
3301
|
});
|
|
3308
3302
|
exports.LOCK_TYPES = LOCK_TYPES;
|
|
3309
3303
|
exports.MODIFY_LOCK_TYPES = MODIFY_LOCK_TYPES;
|
|
3310
3304
|
exports.PrivanaButton = PrivanaButton;
|
|
3311
3305
|
exports.PrivanaInlineModal = PrivanaInlineModal;
|
|
3312
3306
|
exports.PrivanaModal = PrivanaModal;
|
|
3313
|
-
exports.Skeleton = Skeleton;
|
|
3314
3307
|
exports.TRANSFER_LOCKED_TYPES = TRANSFER_LOCKED_TYPES;
|
|
3315
3308
|
exports.TRANSFER_TYPES = TRANSFER_TYPES;
|
|
3316
3309
|
exports.WITHDRAW_FROM_LOCK_TYPES = WITHDRAW_FROM_LOCK_TYPES;
|