@oasisprotocol/privana-sdk 0.5.0 → 0.5.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-ACLJPC75.cjs → chunk-4IW4V7YJ.cjs} +929 -20
- package/dist/chunk-4IW4V7YJ.cjs.map +1 -0
- package/dist/{chunk-54FC6TO3.js → chunk-SAJ7K5WT.js} +900 -22
- package/dist/chunk-SAJ7K5WT.js.map +1 -0
- package/dist/index.cjs +711 -506
- 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 +56 -339
- package/dist/index.d.ts +56 -339
- package/dist/index.js +419 -301
- package/dist/index.js.map +1 -1
- package/dist/on-ramp.cjs +3 -3
- package/dist/on-ramp.d.cts +40 -4
- package/dist/on-ramp.d.ts +40 -4
- package/dist/on-ramp.js +1 -1
- package/dist/pending-lock-BdkuMjmY.d.cts +600 -0
- package/dist/pending-lock-BdkuMjmY.d.ts +600 -0
- package/package.json +1 -1
- package/dist/chunk-54FC6TO3.js.map +0 -1
- package/dist/chunk-ACLJPC75.cjs.map +0 -1
- package/dist/on-ramp-XLXsy0aI.d.cts +0 -130
- package/dist/on-ramp-XLXsy0aI.d.ts +0 -130
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunk4IW4V7YJ_cjs = require('./chunk-4IW4V7YJ.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var reactQuery = require('@tanstack/react-query');
|
|
7
7
|
var wagmi = require('wagmi');
|
|
@@ -33,216 +33,20 @@ function _interopNamespace(e) {
|
|
|
33
33
|
|
|
34
34
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
35
35
|
|
|
36
|
-
// src/sdk/signatures/eip712-types.ts
|
|
37
|
-
function createDomain(chainId, verifyingContract) {
|
|
38
|
-
return {
|
|
39
|
-
name: "AccountingModule",
|
|
40
|
-
version: "1",
|
|
41
|
-
chainId,
|
|
42
|
-
verifyingContract
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
var LOCK_TYPES = {
|
|
46
|
-
Lock: [
|
|
47
|
-
{ name: "serviceAddress", type: "address" },
|
|
48
|
-
{ name: "tokenId", type: "bytes32" },
|
|
49
|
-
{ name: "amount", type: "uint256" },
|
|
50
|
-
{ name: "expiry", type: "uint256" },
|
|
51
|
-
{ name: "nonce", type: "uint256" }
|
|
52
|
-
]
|
|
53
|
-
};
|
|
54
|
-
var TRANSFER_TYPES = {
|
|
55
|
-
Transfer: [
|
|
56
|
-
{ name: "toAddress", type: "address" },
|
|
57
|
-
{ name: "tokenId", type: "bytes32" },
|
|
58
|
-
{ name: "amount", type: "uint256" },
|
|
59
|
-
{ name: "nonce", type: "uint256" }
|
|
60
|
-
]
|
|
61
|
-
};
|
|
62
|
-
var TRANSFER_LOCKED_TYPES = {
|
|
63
|
-
TransferLocked: [
|
|
64
|
-
{ name: "userAddress", type: "address" },
|
|
65
|
-
{ name: "toAddress", type: "address" },
|
|
66
|
-
{ name: "lockId", type: "uint256" },
|
|
67
|
-
{ name: "amount", type: "uint256" },
|
|
68
|
-
{ name: "nonce", type: "uint256" },
|
|
69
|
-
{ name: "serviceAddress", type: "address" }
|
|
70
|
-
]
|
|
71
|
-
};
|
|
72
|
-
var WITHDRAW_TYPES = {
|
|
73
|
-
Withdraw: [
|
|
74
|
-
{ name: "tokenId", type: "bytes32" },
|
|
75
|
-
{ name: "amount", type: "uint256" },
|
|
76
|
-
{ name: "nonce", type: "uint256" }
|
|
77
|
-
]
|
|
78
|
-
};
|
|
79
|
-
var MODIFY_LOCK_TYPES = {
|
|
80
|
-
ModifyLock: [
|
|
81
|
-
{ name: "lockId", type: "uint256" },
|
|
82
|
-
{ name: "amount", type: "uint256" },
|
|
83
|
-
{ name: "newExpiry", type: "uint256" },
|
|
84
|
-
{ name: "nonce", type: "uint256" }
|
|
85
|
-
]
|
|
86
|
-
};
|
|
87
|
-
var WITHDRAW_FROM_LOCK_TYPES = {
|
|
88
|
-
WithdrawFromLock: [
|
|
89
|
-
{ name: "userAddress", type: "address" },
|
|
90
|
-
{ name: "toAddress", type: "address" },
|
|
91
|
-
{ name: "lockId", type: "uint256" },
|
|
92
|
-
{ name: "amount", type: "uint256" },
|
|
93
|
-
{ name: "nonce", type: "uint256" }
|
|
94
|
-
]
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// src/sdk/signatures/sign-lock.ts
|
|
98
|
-
async function signLockMessage({
|
|
99
|
-
walletClient,
|
|
100
|
-
chainId,
|
|
101
|
-
verifyingContract,
|
|
102
|
-
message
|
|
103
|
-
}) {
|
|
104
|
-
const account = walletClient.account;
|
|
105
|
-
if (!account) {
|
|
106
|
-
throw new Error("No account connected to wallet client");
|
|
107
|
-
}
|
|
108
|
-
const domain = createDomain(chainId, verifyingContract);
|
|
109
|
-
const signature = await walletClient.signTypedData({
|
|
110
|
-
account,
|
|
111
|
-
domain,
|
|
112
|
-
types: LOCK_TYPES,
|
|
113
|
-
primaryType: "Lock",
|
|
114
|
-
message
|
|
115
|
-
});
|
|
116
|
-
return signature;
|
|
117
|
-
}
|
|
118
|
-
function createLockExpiry(minutesFromNow = 60) {
|
|
119
|
-
return BigInt(Math.floor(Date.now() / 1e3) + minutesFromNow * 60);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// src/sdk/signatures/sign-modify-lock.ts
|
|
123
|
-
async function signModifyLockMessage({
|
|
124
|
-
walletClient,
|
|
125
|
-
chainId,
|
|
126
|
-
verifyingContract,
|
|
127
|
-
message
|
|
128
|
-
}) {
|
|
129
|
-
const account = walletClient.account;
|
|
130
|
-
if (!account) {
|
|
131
|
-
throw new Error("No account connected to wallet client");
|
|
132
|
-
}
|
|
133
|
-
const domain = createDomain(chainId, verifyingContract);
|
|
134
|
-
const signature = await walletClient.signTypedData({
|
|
135
|
-
account,
|
|
136
|
-
domain,
|
|
137
|
-
types: MODIFY_LOCK_TYPES,
|
|
138
|
-
primaryType: "ModifyLock",
|
|
139
|
-
message
|
|
140
|
-
});
|
|
141
|
-
return signature;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// src/sdk/signatures/sign-transfer.ts
|
|
145
|
-
async function signTransferMessage({
|
|
146
|
-
walletClient,
|
|
147
|
-
chainId,
|
|
148
|
-
verifyingContract,
|
|
149
|
-
message
|
|
150
|
-
}) {
|
|
151
|
-
const account = walletClient.account;
|
|
152
|
-
if (!account) {
|
|
153
|
-
throw new Error("No account connected to wallet client");
|
|
154
|
-
}
|
|
155
|
-
const domain = createDomain(chainId, verifyingContract);
|
|
156
|
-
const signature = await walletClient.signTypedData({
|
|
157
|
-
account,
|
|
158
|
-
domain,
|
|
159
|
-
types: TRANSFER_TYPES,
|
|
160
|
-
primaryType: "Transfer",
|
|
161
|
-
message
|
|
162
|
-
});
|
|
163
|
-
return signature;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// src/sdk/signatures/sign-transfer-locked.ts
|
|
167
|
-
async function signTransferLockedMessage({
|
|
168
|
-
walletClient,
|
|
169
|
-
chainId,
|
|
170
|
-
verifyingContract,
|
|
171
|
-
message
|
|
172
|
-
}) {
|
|
173
|
-
const account = walletClient.account;
|
|
174
|
-
if (!account) {
|
|
175
|
-
throw new Error("No account connected to wallet client");
|
|
176
|
-
}
|
|
177
|
-
const domain = createDomain(chainId, verifyingContract);
|
|
178
|
-
const signature = await walletClient.signTypedData({
|
|
179
|
-
account,
|
|
180
|
-
domain,
|
|
181
|
-
types: TRANSFER_LOCKED_TYPES,
|
|
182
|
-
primaryType: "TransferLocked",
|
|
183
|
-
message
|
|
184
|
-
});
|
|
185
|
-
return signature;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// src/sdk/signatures/sign-withdraw.ts
|
|
189
|
-
async function signWithdrawMessage({
|
|
190
|
-
walletClient,
|
|
191
|
-
chainId,
|
|
192
|
-
verifyingContract,
|
|
193
|
-
message
|
|
194
|
-
}) {
|
|
195
|
-
const account = walletClient.account;
|
|
196
|
-
if (!account) {
|
|
197
|
-
throw new Error("No account connected to wallet client");
|
|
198
|
-
}
|
|
199
|
-
const domain = createDomain(chainId, verifyingContract);
|
|
200
|
-
const signature = await walletClient.signTypedData({
|
|
201
|
-
account,
|
|
202
|
-
domain,
|
|
203
|
-
types: WITHDRAW_TYPES,
|
|
204
|
-
primaryType: "Withdraw",
|
|
205
|
-
message
|
|
206
|
-
});
|
|
207
|
-
return signature;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// src/sdk/signatures/sign-withdraw-from-lock.ts
|
|
211
|
-
async function signWithdrawFromLockMessage({
|
|
212
|
-
walletClient,
|
|
213
|
-
chainId,
|
|
214
|
-
verifyingContract,
|
|
215
|
-
message
|
|
216
|
-
}) {
|
|
217
|
-
const account = walletClient.account;
|
|
218
|
-
if (!account) {
|
|
219
|
-
throw new Error("No account connected to wallet client");
|
|
220
|
-
}
|
|
221
|
-
const domain = createDomain(chainId, verifyingContract);
|
|
222
|
-
const signature = await walletClient.signTypedData({
|
|
223
|
-
account,
|
|
224
|
-
domain,
|
|
225
|
-
types: WITHDRAW_FROM_LOCK_TYPES,
|
|
226
|
-
primaryType: "WithdrawFromLock",
|
|
227
|
-
message
|
|
228
|
-
});
|
|
229
|
-
return signature;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
36
|
// src/sdk/hooks/use-privana-client.ts
|
|
233
37
|
function usePrivanaClient() {
|
|
234
|
-
const { client } =
|
|
38
|
+
const { client } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
235
39
|
return client;
|
|
236
40
|
}
|
|
237
41
|
var hostedAuthExchangeInflight = /* @__PURE__ */ new Map();
|
|
238
42
|
function normalizeHostedAuthError(error) {
|
|
239
|
-
if (error instanceof
|
|
240
|
-
return new
|
|
43
|
+
if (error instanceof chunk4IW4V7YJ_cjs.AccountingApiError && error.detail) {
|
|
44
|
+
return new chunk4IW4V7YJ_cjs.HostedAuthError(error.detail);
|
|
241
45
|
}
|
|
242
46
|
if (error instanceof Error) {
|
|
243
47
|
return error;
|
|
244
48
|
}
|
|
245
|
-
return new
|
|
49
|
+
return new chunk4IW4V7YJ_cjs.HostedAuthError("Hosted authentication failed.");
|
|
246
50
|
}
|
|
247
51
|
function useHostedRedirectAuth() {
|
|
248
52
|
const {
|
|
@@ -253,30 +57,30 @@ function useHostedRedirectAuth() {
|
|
|
253
57
|
setHostedAuthSession,
|
|
254
58
|
clearHostedAuthSession,
|
|
255
59
|
refreshHostedAuthSession
|
|
256
|
-
} =
|
|
60
|
+
} = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
257
61
|
const [error, setError] = react.useState(null);
|
|
258
62
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
259
63
|
const loginInflight = react.useRef(null);
|
|
260
64
|
const completionInflight = react.useRef(null);
|
|
261
65
|
const pendingStorageKey = react.useMemo(
|
|
262
|
-
() => hostedAuthConfig ?
|
|
66
|
+
() => hostedAuthConfig ? chunk4IW4V7YJ_cjs.createHostedAuthPendingStorageKey(client.getBaseUrl(), hostedAuthConfig) : null,
|
|
263
67
|
[client, hostedAuthConfig]
|
|
264
68
|
);
|
|
265
69
|
const clearPendingLogin = react.useCallback(() => {
|
|
266
70
|
if (!pendingStorageKey || typeof window === "undefined") return;
|
|
267
|
-
|
|
71
|
+
chunk4IW4V7YJ_cjs.clearHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
|
|
268
72
|
}, [pendingStorageKey]);
|
|
269
73
|
const login = react.useCallback(async () => {
|
|
270
74
|
if (!hostedAuthConfig) {
|
|
271
|
-
throw new
|
|
75
|
+
throw new chunk4IW4V7YJ_cjs.HostedAuthRequiredError(
|
|
272
76
|
"Hosted redirect authentication is not configured for this provider."
|
|
273
77
|
);
|
|
274
78
|
}
|
|
275
79
|
if (typeof window === "undefined") {
|
|
276
|
-
throw new
|
|
80
|
+
throw new chunk4IW4V7YJ_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
|
|
277
81
|
}
|
|
278
82
|
if (!pendingStorageKey) {
|
|
279
|
-
throw new
|
|
83
|
+
throw new chunk4IW4V7YJ_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
|
|
280
84
|
}
|
|
281
85
|
if (loginInflight.current) {
|
|
282
86
|
return loginInflight.current;
|
|
@@ -285,10 +89,10 @@ function useHostedRedirectAuth() {
|
|
|
285
89
|
setIsLoading(true);
|
|
286
90
|
setError(null);
|
|
287
91
|
try {
|
|
288
|
-
const verifier =
|
|
289
|
-
const codeChallenge = await
|
|
290
|
-
const state =
|
|
291
|
-
|
|
92
|
+
const verifier = chunk4IW4V7YJ_cjs.createPkceVerifier();
|
|
93
|
+
const codeChallenge = await chunk4IW4V7YJ_cjs.createPkceChallenge(verifier);
|
|
94
|
+
const state = chunk4IW4V7YJ_cjs.createHostedAuthState();
|
|
95
|
+
chunk4IW4V7YJ_cjs.persistHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey, {
|
|
292
96
|
codeVerifier: verifier,
|
|
293
97
|
state
|
|
294
98
|
});
|
|
@@ -317,15 +121,15 @@ function useHostedRedirectAuth() {
|
|
|
317
121
|
}, [clearPendingLogin, client, hostedAuthConfig, networkConfig.chainId, pendingStorageKey]);
|
|
318
122
|
const completeLogin = react.useCallback(async () => {
|
|
319
123
|
if (!hostedAuthConfig) {
|
|
320
|
-
throw new
|
|
124
|
+
throw new chunk4IW4V7YJ_cjs.HostedAuthRequiredError(
|
|
321
125
|
"Hosted redirect authentication is not configured for this provider."
|
|
322
126
|
);
|
|
323
127
|
}
|
|
324
128
|
if (typeof window === "undefined") {
|
|
325
|
-
throw new
|
|
129
|
+
throw new chunk4IW4V7YJ_cjs.HostedAuthError("Hosted redirect authentication requires a browser environment.");
|
|
326
130
|
}
|
|
327
131
|
if (!pendingStorageKey) {
|
|
328
|
-
throw new
|
|
132
|
+
throw new chunk4IW4V7YJ_cjs.HostedAuthError("Hosted redirect authentication storage is not configured.");
|
|
329
133
|
}
|
|
330
134
|
if (completionInflight.current) {
|
|
331
135
|
return completionInflight.current;
|
|
@@ -335,30 +139,30 @@ function useHostedRedirectAuth() {
|
|
|
335
139
|
setError(null);
|
|
336
140
|
const callbackUrl = new URL(window.location.href);
|
|
337
141
|
const cleanupCallbackUrl = () => {
|
|
338
|
-
window.history.replaceState(null, "",
|
|
142
|
+
window.history.replaceState(null, "", chunk4IW4V7YJ_cjs.stripHostedAuthCallbackParams(callbackUrl));
|
|
339
143
|
};
|
|
340
144
|
try {
|
|
341
|
-
const callback =
|
|
145
|
+
const callback = chunk4IW4V7YJ_cjs.parseHostedAuthCallback(callbackUrl, hostedAuthConfig.redirectUri);
|
|
342
146
|
if (!callback) {
|
|
343
147
|
return null;
|
|
344
148
|
}
|
|
345
|
-
const pending =
|
|
149
|
+
const pending = chunk4IW4V7YJ_cjs.readHostedAuthPendingTransaction(window.sessionStorage, pendingStorageKey);
|
|
346
150
|
if (!pending) {
|
|
347
151
|
clearPendingLogin();
|
|
348
152
|
cleanupCallbackUrl();
|
|
349
|
-
throw new
|
|
153
|
+
throw new chunk4IW4V7YJ_cjs.HostedAuthError(
|
|
350
154
|
"Hosted authentication response could not be matched to a pending login request."
|
|
351
155
|
);
|
|
352
156
|
}
|
|
353
157
|
if (!callback.state || callback.state !== pending.state) {
|
|
354
158
|
clearPendingLogin();
|
|
355
159
|
cleanupCallbackUrl();
|
|
356
|
-
throw new
|
|
160
|
+
throw new chunk4IW4V7YJ_cjs.HostedAuthStateMismatchError();
|
|
357
161
|
}
|
|
358
162
|
if ("error" in callback) {
|
|
359
163
|
clearPendingLogin();
|
|
360
164
|
cleanupCallbackUrl();
|
|
361
|
-
throw new
|
|
165
|
+
throw new chunk4IW4V7YJ_cjs.HostedAuthError(
|
|
362
166
|
callback.errorDescription || callback.error || "Hosted authentication failed."
|
|
363
167
|
);
|
|
364
168
|
}
|
|
@@ -373,7 +177,7 @@ function useHostedRedirectAuth() {
|
|
|
373
177
|
client_id: hostedAuthConfig.clientId,
|
|
374
178
|
redirect_uri: hostedAuthConfig.redirectUri
|
|
375
179
|
});
|
|
376
|
-
const session =
|
|
180
|
+
const session = chunk4IW4V7YJ_cjs.buildHostedAuthSession(response, hostedAuthConfig);
|
|
377
181
|
setHostedAuthSession(session);
|
|
378
182
|
clearPendingLogin();
|
|
379
183
|
cleanupCallbackUrl();
|
|
@@ -418,7 +222,7 @@ function useHostedRedirectAuth() {
|
|
|
418
222
|
try {
|
|
419
223
|
return await refreshHostedAuthSession();
|
|
420
224
|
} catch (refreshError) {
|
|
421
|
-
const normalizedError = refreshError instanceof Error ? refreshError : new
|
|
225
|
+
const normalizedError = refreshError instanceof Error ? refreshError : new chunk4IW4V7YJ_cjs.HostedAuthError("Hosted authentication refresh failed.");
|
|
422
226
|
setError(normalizedError);
|
|
423
227
|
throw normalizedError;
|
|
424
228
|
} finally {
|
|
@@ -438,12 +242,12 @@ function useHostedRedirectAuth() {
|
|
|
438
242
|
}
|
|
439
243
|
function useBalance(options = {}) {
|
|
440
244
|
const queryClient = react.useContext(reactQuery.QueryClientContext);
|
|
441
|
-
const accountingContext =
|
|
245
|
+
const accountingContext = chunk4IW4V7YJ_cjs.useSafePrivanaContext();
|
|
442
246
|
const hasProviders = !!queryClient && !!accountingContext;
|
|
443
247
|
const client = accountingContext?.client;
|
|
444
248
|
const defaultToken = accountingContext?.defaultToken;
|
|
445
249
|
const pollingInterval = accountingContext?.pollingInterval ?? 1e4;
|
|
446
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
250
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk4IW4V7YJ_cjs.usePrivateReadRequest();
|
|
447
251
|
const tokenId = options.tokenId ?? defaultToken?.id;
|
|
448
252
|
const query = reactQuery.useQuery({
|
|
449
253
|
queryKey: ["accounting-balance", ...privateReadQueryScope, tokenId],
|
|
@@ -460,7 +264,7 @@ function useBalance(options = {}) {
|
|
|
460
264
|
return {
|
|
461
265
|
balance: balanceWei,
|
|
462
266
|
balanceWei,
|
|
463
|
-
balanceFormatted:
|
|
267
|
+
balanceFormatted: chunk4IW4V7YJ_cjs.formatTokenAmount(balanceWei),
|
|
464
268
|
tokenSymbol: query.data?.token_symbol ?? "",
|
|
465
269
|
chainId: query.data?.chain_id ?? "",
|
|
466
270
|
isLoading: query.isPending || query.isLoading,
|
|
@@ -470,8 +274,8 @@ function useBalance(options = {}) {
|
|
|
470
274
|
};
|
|
471
275
|
}
|
|
472
276
|
function useBatchBalances(options) {
|
|
473
|
-
const { client, pollingInterval } =
|
|
474
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
277
|
+
const { client, pollingInterval } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
278
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk4IW4V7YJ_cjs.usePrivateReadRequest();
|
|
475
279
|
const query = reactQuery.useQuery({
|
|
476
280
|
queryKey: ["accounting-batch-balances", ...privateReadQueryScope, options.tokenIds],
|
|
477
281
|
queryFn: async () => {
|
|
@@ -489,75 +293,22 @@ function useBatchBalances(options) {
|
|
|
489
293
|
refetch: query.refetch
|
|
490
294
|
};
|
|
491
295
|
}
|
|
492
|
-
function useEnsureCorrectChain() {
|
|
493
|
-
const config = wagmi.useConfig();
|
|
494
|
-
const chainId = wagmi.useChainId();
|
|
495
|
-
const { switchChainAsync } = wagmi.useSwitchChain();
|
|
496
|
-
const waitUntilOnChain = react.useCallback(
|
|
497
|
-
async (expectedChainId, timeoutMs, pollIntervalMs = 250) => {
|
|
498
|
-
const startedAt = Date.now();
|
|
499
|
-
while (Date.now() - startedAt < timeoutMs) {
|
|
500
|
-
const currentChainId = chunkACLJPC75_cjs.getChainId2(config);
|
|
501
|
-
if (currentChainId === expectedChainId) return true;
|
|
502
|
-
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
503
|
-
}
|
|
504
|
-
return false;
|
|
505
|
-
},
|
|
506
|
-
[config]
|
|
507
|
-
);
|
|
508
|
-
const ensureCorrectChain = react.useCallback(
|
|
509
|
-
async (targetChainId) => {
|
|
510
|
-
const currentChainId = chunkACLJPC75_cjs.getChainId2(config);
|
|
511
|
-
if (currentChainId === targetChainId) return false;
|
|
512
|
-
let switchErrorMessage;
|
|
513
|
-
try {
|
|
514
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
515
|
-
setTimeout(() => reject(new Error("Chain switch timeout")), 3e3);
|
|
516
|
-
});
|
|
517
|
-
await Promise.race([switchChainAsync({ chainId: targetChainId }), timeoutPromise]);
|
|
518
|
-
} catch (error) {
|
|
519
|
-
if (error instanceof Error && error.message.includes("Unsupported Chain")) {
|
|
520
|
-
console.warn("Got 'Unsupported Chain' error, chain may have switched anyway.");
|
|
521
|
-
} else {
|
|
522
|
-
switchErrorMessage = error instanceof Error ? error.message : "Unknown chain switch error";
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
const settled = await waitUntilOnChain(targetChainId, 2e4);
|
|
526
|
-
if (settled) return true;
|
|
527
|
-
if (switchErrorMessage) {
|
|
528
|
-
throw new Error(
|
|
529
|
-
`Failed to switch to chain (Chain ID: ${targetChainId}): ${switchErrorMessage}`
|
|
530
|
-
);
|
|
531
|
-
}
|
|
532
|
-
throw new Error(`Chain switch did not settle in time (expected ${targetChainId}).`);
|
|
533
|
-
},
|
|
534
|
-
[config, switchChainAsync, waitUntilOnChain]
|
|
535
|
-
);
|
|
536
|
-
const isOnChain = react.useCallback((targetChainId) => chainId === targetChainId, [chainId]);
|
|
537
|
-
return {
|
|
538
|
-
chainId,
|
|
539
|
-
ensureCorrectChain,
|
|
540
|
-
isOnChain
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// src/sdk/hooks/use-deposit.ts
|
|
545
296
|
var STALE_MS = 30 * 60 * 1e3;
|
|
546
297
|
function storageKey(address) {
|
|
547
298
|
return `privana:pending-deposit:${address.toLowerCase()}`;
|
|
548
299
|
}
|
|
549
300
|
function savePendingDeposit(address, data) {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
301
|
+
const stored = chunk4IW4V7YJ_cjs.setBrowserStorageItem(storageKey(address), JSON.stringify(data));
|
|
302
|
+
if (!stored && data.signedLock) {
|
|
303
|
+
throw new Error("Unable to persist pending locked deposit for recovery");
|
|
553
304
|
}
|
|
554
305
|
}
|
|
555
306
|
function loadPendingDeposit(address) {
|
|
556
307
|
try {
|
|
557
|
-
const raw =
|
|
308
|
+
const raw = chunk4IW4V7YJ_cjs.getBrowserStorageItem(storageKey(address));
|
|
558
309
|
if (!raw) return null;
|
|
559
310
|
const data = JSON.parse(raw);
|
|
560
|
-
if (Date.now() - data.savedAt > STALE_MS) {
|
|
311
|
+
if (Date.now() - data.savedAt > STALE_MS && !(data.signedLock && chunk4IW4V7YJ_cjs.isSignedLockUsable(data.signedLock))) {
|
|
561
312
|
clearPendingDeposit(address);
|
|
562
313
|
return null;
|
|
563
314
|
}
|
|
@@ -566,19 +317,24 @@ function loadPendingDeposit(address) {
|
|
|
566
317
|
return null;
|
|
567
318
|
}
|
|
568
319
|
}
|
|
569
|
-
function clearPendingDeposit(address) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
320
|
+
function clearPendingDeposit(address, onlyForTxHash) {
|
|
321
|
+
if (onlyForTxHash) {
|
|
322
|
+
try {
|
|
323
|
+
const raw = chunk4IW4V7YJ_cjs.getBrowserStorageItem(storageKey(address));
|
|
324
|
+
const recordTxHash = raw ? JSON.parse(raw).txHash : void 0;
|
|
325
|
+
if (recordTxHash && recordTxHash !== onlyForTxHash) return;
|
|
326
|
+
} catch {
|
|
327
|
+
}
|
|
573
328
|
}
|
|
329
|
+
chunk4IW4V7YJ_cjs.removeBrowserStorageItem(storageKey(address));
|
|
574
330
|
}
|
|
575
331
|
function useDeposit(options = {}) {
|
|
576
332
|
const { address } = wagmi.useAccount();
|
|
577
|
-
const { client, enabledTokens, getChainById: getChainById2 } =
|
|
333
|
+
const { client, enabledTokens, getChainById: getChainById2, networkConfig, serviceAddress } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
578
334
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
579
335
|
const queryClient = reactQuery.useQueryClient();
|
|
580
336
|
const config = wagmi.useConfig();
|
|
581
|
-
const { executePrivateRead } =
|
|
337
|
+
const { executePrivateRead } = chunk4IW4V7YJ_cjs.usePrivateReadRequest();
|
|
582
338
|
const confirmations = options.confirmations ?? 15;
|
|
583
339
|
const [depositAddress, setDepositAddress] = react.useState(null);
|
|
584
340
|
const [txHash, setTxHash] = react.useState();
|
|
@@ -591,21 +347,54 @@ function useDeposit(options = {}) {
|
|
|
591
347
|
const onDepositAddressReceivedRef = react.useRef(options.onDepositAddressReceived);
|
|
592
348
|
const onDepositSuccessRef = react.useRef(options.onDepositSuccess);
|
|
593
349
|
const onCreditedRef = react.useRef(options.onCredited);
|
|
350
|
+
const onLockSubmittedRef = react.useRef(options.onLockSubmitted);
|
|
351
|
+
const onLockFailedRef = react.useRef(options.onLockFailed);
|
|
594
352
|
const onCheckTimeoutRef = react.useRef(options.onCheckTimeout);
|
|
595
353
|
const onErrorRef = react.useRef(options.onError);
|
|
596
354
|
react.useEffect(() => {
|
|
597
355
|
onDepositAddressReceivedRef.current = options.onDepositAddressReceived;
|
|
598
356
|
onDepositSuccessRef.current = options.onDepositSuccess;
|
|
599
357
|
onCreditedRef.current = options.onCredited;
|
|
358
|
+
onLockSubmittedRef.current = options.onLockSubmitted;
|
|
359
|
+
onLockFailedRef.current = options.onLockFailed;
|
|
600
360
|
onCheckTimeoutRef.current = options.onCheckTimeout;
|
|
601
361
|
onErrorRef.current = options.onError;
|
|
602
362
|
}, [
|
|
603
363
|
options.onDepositAddressReceived,
|
|
604
364
|
options.onDepositSuccess,
|
|
605
365
|
options.onCredited,
|
|
366
|
+
options.onLockSubmitted,
|
|
367
|
+
options.onLockFailed,
|
|
606
368
|
options.onCheckTimeout,
|
|
607
369
|
options.onError
|
|
608
370
|
]);
|
|
371
|
+
const pendingLockRef = react.useRef(null);
|
|
372
|
+
const submitPendingLockAfterCredit = react.useCallback(
|
|
373
|
+
async (signedLock, response) => {
|
|
374
|
+
try {
|
|
375
|
+
const result = await chunk4IW4V7YJ_cjs.submitPendingLock({
|
|
376
|
+
client,
|
|
377
|
+
payload: signedLock,
|
|
378
|
+
creditedAmount: response.amount != null ? BigInt(response.amount) : void 0
|
|
379
|
+
});
|
|
380
|
+
queryClient.invalidateQueries({ queryKey: ["accounting-balance"] });
|
|
381
|
+
queryClient.invalidateQueries({ queryKey: ["accounting-locked-funds"] });
|
|
382
|
+
queryClient.invalidateQueries({ queryKey: ["accounting-total-locked-balance"] });
|
|
383
|
+
queryClient.invalidateQueries({ queryKey: ["accounting-history"] });
|
|
384
|
+
onLockSubmittedRef.current?.(result);
|
|
385
|
+
} catch (err) {
|
|
386
|
+
const error2 = err instanceof chunk4IW4V7YJ_cjs.PostDepositLockError ? err : new chunk4IW4V7YJ_cjs.PostDepositLockError(
|
|
387
|
+
err instanceof Error ? err.message : "Lock submission failed",
|
|
388
|
+
"submission-failed",
|
|
389
|
+
BigInt(signedLock.amount),
|
|
390
|
+
void 0,
|
|
391
|
+
{ cause: err }
|
|
392
|
+
);
|
|
393
|
+
(onLockFailedRef.current ?? onErrorRef.current)?.(error2);
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
[client, queryClient]
|
|
397
|
+
);
|
|
609
398
|
const {
|
|
610
399
|
isVerifying,
|
|
611
400
|
didTimeout,
|
|
@@ -613,13 +402,21 @@ function useDeposit(options = {}) {
|
|
|
613
402
|
error: verificationError,
|
|
614
403
|
verify,
|
|
615
404
|
reset: resetVerification
|
|
616
|
-
} =
|
|
405
|
+
} = chunk4IW4V7YJ_cjs.useDepositVerification({
|
|
617
406
|
pollInterval: options.pollInterval,
|
|
618
407
|
pollTimeout: options.pollTimeout,
|
|
619
408
|
onCredited: (hash, response) => {
|
|
620
409
|
verificationContextRef.current = null;
|
|
621
|
-
|
|
622
|
-
|
|
410
|
+
const signedLock = pendingLockRef.current;
|
|
411
|
+
pendingLockRef.current = null;
|
|
412
|
+
if (signedLock) {
|
|
413
|
+
void submitPendingLockAfterCredit(signedLock, response).finally(() => {
|
|
414
|
+
if (address) clearPendingDeposit(address, hash);
|
|
415
|
+
});
|
|
416
|
+
} else if (address) {
|
|
417
|
+
clearPendingDeposit(address);
|
|
418
|
+
}
|
|
419
|
+
onCreditedRef.current?.(hash, response, signedLock !== null);
|
|
623
420
|
},
|
|
624
421
|
onCheckTimeout: (hash) => {
|
|
625
422
|
onCheckTimeoutRef.current?.(hash);
|
|
@@ -655,7 +452,7 @@ function useDeposit(options = {}) {
|
|
|
655
452
|
} = wagmi.useSendTransaction();
|
|
656
453
|
const isSendingTx = isWritingContract || isSendingNative;
|
|
657
454
|
const sendError = writeError ?? sendNativeError;
|
|
658
|
-
const { ensureCorrectChain } = useEnsureCorrectChain();
|
|
455
|
+
const { ensureCorrectChain } = chunk4IW4V7YJ_cjs.useEnsureCorrectChain();
|
|
659
456
|
const invalidateGeneration = react.useCallback(() => {
|
|
660
457
|
generationRef.current++;
|
|
661
458
|
}, []);
|
|
@@ -670,6 +467,7 @@ function useDeposit(options = {}) {
|
|
|
670
467
|
resetVerification();
|
|
671
468
|
if (address) clearPendingDeposit(address);
|
|
672
469
|
verificationContextRef.current = null;
|
|
470
|
+
pendingLockRef.current = null;
|
|
673
471
|
setDepositAddress(null);
|
|
674
472
|
setTxHash(void 0);
|
|
675
473
|
setIsSwitchingChain(false);
|
|
@@ -689,6 +487,7 @@ function useDeposit(options = {}) {
|
|
|
689
487
|
setTxHash(hash);
|
|
690
488
|
setDepositAddress(persisted.depositAddress);
|
|
691
489
|
setIsWaitingForConfirmation(true);
|
|
490
|
+
pendingLockRef.current = persisted.signedLock ?? null;
|
|
692
491
|
const ctx = {
|
|
693
492
|
hash,
|
|
694
493
|
chainId: persisted.chainId,
|
|
@@ -701,12 +500,12 @@ function useDeposit(options = {}) {
|
|
|
701
500
|
try {
|
|
702
501
|
let confirmed = false;
|
|
703
502
|
try {
|
|
704
|
-
await
|
|
503
|
+
await chunk4IW4V7YJ_cjs.getTransactionReceipt(config, { hash, chainId: persisted.chainId });
|
|
705
504
|
confirmed = true;
|
|
706
505
|
} catch {
|
|
707
506
|
}
|
|
708
507
|
if (!confirmed) {
|
|
709
|
-
await
|
|
508
|
+
await chunk4IW4V7YJ_cjs.waitForTransactionReceipt(config, {
|
|
710
509
|
hash,
|
|
711
510
|
chainId: persisted.chainId,
|
|
712
511
|
confirmations
|
|
@@ -745,13 +544,6 @@ function useDeposit(options = {}) {
|
|
|
745
544
|
if (!sourceChain) throw new Error(`Chain ${token.chainId} not configured`);
|
|
746
545
|
const addrResponse = await addressMutation.mutateAsync();
|
|
747
546
|
if (isStale()) return;
|
|
748
|
-
setIsSwitchingChain(true);
|
|
749
|
-
try {
|
|
750
|
-
await ensureCorrectChain(sourceChain.id);
|
|
751
|
-
} finally {
|
|
752
|
-
if (!isStale()) setIsSwitchingChain(false);
|
|
753
|
-
}
|
|
754
|
-
if (isStale()) return;
|
|
755
547
|
const depositAddr = addrResponse.deposit_address;
|
|
756
548
|
if (!depositAddr || depositAddr === viem.zeroAddress) {
|
|
757
549
|
throw new Error("Invalid deposit address received from API");
|
|
@@ -764,6 +556,43 @@ function useDeposit(options = {}) {
|
|
|
764
556
|
`Amount is below the minimum deposit (${minAmountStr}) for ${isNative ? "native" : "ERC-20"} on chain ${sourceChain.id}`
|
|
765
557
|
);
|
|
766
558
|
}
|
|
559
|
+
if (params.postDepositLock && !chunk4IW4V7YJ_cjs.canUseBrowserStorage()) {
|
|
560
|
+
throw new Error("Browser storage is required for locked deposit recovery");
|
|
561
|
+
}
|
|
562
|
+
const lockAmount = chunk4IW4V7YJ_cjs.clampLockAmount(params.amount, params.postDepositLock?.maxAmount);
|
|
563
|
+
let signedLock;
|
|
564
|
+
if (params.postDepositLock) {
|
|
565
|
+
setIsSwitchingChain(true);
|
|
566
|
+
try {
|
|
567
|
+
await ensureCorrectChain(networkConfig.chainId);
|
|
568
|
+
} finally {
|
|
569
|
+
if (!isStale()) setIsSwitchingChain(false);
|
|
570
|
+
}
|
|
571
|
+
if (isStale()) return;
|
|
572
|
+
const signingWalletClient = await chunk4IW4V7YJ_cjs.getWalletClient(config, {
|
|
573
|
+
chainId: networkConfig.chainId
|
|
574
|
+
});
|
|
575
|
+
signedLock = await chunk4IW4V7YJ_cjs.createSignedLockRequest({
|
|
576
|
+
client,
|
|
577
|
+
walletClient: signingWalletClient,
|
|
578
|
+
userAddress: address,
|
|
579
|
+
networkConfig,
|
|
580
|
+
serviceAddress: requireServiceAddress(
|
|
581
|
+
params.postDepositLock.serviceAddress ?? serviceAddress
|
|
582
|
+
),
|
|
583
|
+
tokenId: params.tokenId,
|
|
584
|
+
amount: lockAmount,
|
|
585
|
+
lockDuration: params.postDepositLock.lockDuration
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
if (isStale()) return;
|
|
589
|
+
setIsSwitchingChain(true);
|
|
590
|
+
try {
|
|
591
|
+
await ensureCorrectChain(sourceChain.id);
|
|
592
|
+
} finally {
|
|
593
|
+
if (!isStale()) setIsSwitchingChain(false);
|
|
594
|
+
}
|
|
595
|
+
if (isStale()) return;
|
|
767
596
|
const hash = token.contract === viem.zeroAddress ? await sendTransactionAsync({
|
|
768
597
|
to: depositAddr,
|
|
769
598
|
value: params.amount,
|
|
@@ -783,17 +612,23 @@ function useDeposit(options = {}) {
|
|
|
783
612
|
amount: params.amount
|
|
784
613
|
};
|
|
785
614
|
verificationContextRef.current = ctx;
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
615
|
+
pendingLockRef.current = signedLock ?? null;
|
|
616
|
+
try {
|
|
617
|
+
savePendingDeposit(address, {
|
|
618
|
+
txHash: hash,
|
|
619
|
+
chainId: sourceChain.id,
|
|
620
|
+
amount: params.amount.toString(),
|
|
621
|
+
depositAddress: addrResponse,
|
|
622
|
+
signedLock,
|
|
623
|
+
savedAt: Date.now()
|
|
624
|
+
});
|
|
625
|
+
} catch (err) {
|
|
626
|
+
console.warn("Failed to persist pending deposit after transfer broadcast:", err);
|
|
627
|
+
}
|
|
793
628
|
try {
|
|
794
629
|
setIsWaitingForConfirmation(true);
|
|
795
630
|
try {
|
|
796
|
-
await
|
|
631
|
+
await chunk4IW4V7YJ_cjs.waitForTransactionReceipt(config, {
|
|
797
632
|
hash,
|
|
798
633
|
chainId: sourceChain.id,
|
|
799
634
|
confirmations
|
|
@@ -824,12 +659,15 @@ function useDeposit(options = {}) {
|
|
|
824
659
|
address,
|
|
825
660
|
walletClient,
|
|
826
661
|
addressMutation,
|
|
662
|
+
client,
|
|
827
663
|
getChainById2,
|
|
828
664
|
config,
|
|
829
665
|
confirmations,
|
|
830
666
|
enabledTokens,
|
|
831
667
|
ensureCorrectChain,
|
|
668
|
+
networkConfig,
|
|
832
669
|
queryClient,
|
|
670
|
+
serviceAddress,
|
|
833
671
|
writeContractAsync,
|
|
834
672
|
sendTransactionAsync,
|
|
835
673
|
reset,
|
|
@@ -864,12 +702,18 @@ function useDeposit(options = {}) {
|
|
|
864
702
|
reset
|
|
865
703
|
};
|
|
866
704
|
}
|
|
705
|
+
function requireServiceAddress(serviceAddress) {
|
|
706
|
+
if (!serviceAddress) {
|
|
707
|
+
throw new Error("Service address not configured");
|
|
708
|
+
}
|
|
709
|
+
return serviceAddress;
|
|
710
|
+
}
|
|
867
711
|
function useDepositAddress(options = {}) {
|
|
868
712
|
const queryClient = react.useContext(reactQuery.QueryClientContext);
|
|
869
|
-
const accountingContext =
|
|
713
|
+
const accountingContext = chunk4IW4V7YJ_cjs.useSafePrivanaContext();
|
|
870
714
|
const hasProviders = !!queryClient && !!accountingContext;
|
|
871
715
|
const client = accountingContext?.client;
|
|
872
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
716
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk4IW4V7YJ_cjs.usePrivateReadRequest();
|
|
873
717
|
const isReady = hasProviders && privateReadReady && !!privateReadAddress && !!client;
|
|
874
718
|
const query = reactQuery.useQuery({
|
|
875
719
|
queryKey: ["accounting-deposit-address", ...privateReadQueryScope],
|
|
@@ -892,9 +736,9 @@ function useDepositAddress(options = {}) {
|
|
|
892
736
|
function useWithdraw(options = {}) {
|
|
893
737
|
const { address } = wagmi.useAccount();
|
|
894
738
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
895
|
-
const { client, networkConfig } =
|
|
739
|
+
const { client, networkConfig } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
896
740
|
const queryClient = reactQuery.useQueryClient();
|
|
897
|
-
const { chainId, ensureCorrectChain } = useEnsureCorrectChain();
|
|
741
|
+
const { chainId, ensureCorrectChain } = chunk4IW4V7YJ_cjs.useEnsureCorrectChain();
|
|
898
742
|
const pollInterval = options.pollInterval ?? 3e3;
|
|
899
743
|
const pollTimeout = options.pollTimeout ?? 18e4;
|
|
900
744
|
const [currentStep, setCurrentStep] = react.useState("idle");
|
|
@@ -962,7 +806,7 @@ function useWithdraw(options = {}) {
|
|
|
962
806
|
if (isStale()) return void 0;
|
|
963
807
|
const nonce = BigInt(nonceResponse.nonce);
|
|
964
808
|
setCurrentStep("signing");
|
|
965
|
-
const signature = await signWithdrawMessage({
|
|
809
|
+
const signature = await chunk4IW4V7YJ_cjs.signWithdrawMessage({
|
|
966
810
|
walletClient,
|
|
967
811
|
chainId: signingChainId,
|
|
968
812
|
verifyingContract: networkConfig.accountingContract,
|
|
@@ -1091,7 +935,7 @@ function useWithdraw(options = {}) {
|
|
|
1091
935
|
function useLockFunds(options = {}) {
|
|
1092
936
|
const { address } = wagmi.useAccount();
|
|
1093
937
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1094
|
-
const { client, networkConfig, serviceAddress } =
|
|
938
|
+
const { client, networkConfig, serviceAddress } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1095
939
|
const queryClient = reactQuery.useQueryClient();
|
|
1096
940
|
const mutation = reactQuery.useMutation({
|
|
1097
941
|
mutationFn: async (params) => {
|
|
@@ -1102,7 +946,7 @@ function useLockFunds(options = {}) {
|
|
|
1102
946
|
throw new Error("Service address not configured");
|
|
1103
947
|
}
|
|
1104
948
|
const { nonce } = await client.getLockNonce(address);
|
|
1105
|
-
const signature = await signLockMessage({
|
|
949
|
+
const signature = await chunk4IW4V7YJ_cjs.signLockMessage({
|
|
1106
950
|
walletClient,
|
|
1107
951
|
chainId: networkConfig.chainId,
|
|
1108
952
|
verifyingContract: networkConfig.accountingContract,
|
|
@@ -1150,7 +994,7 @@ function useLockFunds(options = {}) {
|
|
|
1150
994
|
}
|
|
1151
995
|
function useUnlockFunds(options = {}) {
|
|
1152
996
|
const { address } = wagmi.useAccount();
|
|
1153
|
-
const { client } =
|
|
997
|
+
const { client } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1154
998
|
const queryClient = reactQuery.useQueryClient();
|
|
1155
999
|
const unlockMutation = reactQuery.useMutation({
|
|
1156
1000
|
mutationFn: async (params) => {
|
|
@@ -1220,7 +1064,7 @@ function useUnlockFunds(options = {}) {
|
|
|
1220
1064
|
function useTransfer(options = {}) {
|
|
1221
1065
|
const { address } = wagmi.useAccount();
|
|
1222
1066
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1223
|
-
const { client, networkConfig, serviceAddress } =
|
|
1067
|
+
const { client, networkConfig, serviceAddress } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1224
1068
|
const queryClient = reactQuery.useQueryClient();
|
|
1225
1069
|
const transferMutation = reactQuery.useMutation({
|
|
1226
1070
|
mutationFn: async (params) => {
|
|
@@ -1228,7 +1072,7 @@ function useTransfer(options = {}) {
|
|
|
1228
1072
|
throw new Error("Wallet not connected");
|
|
1229
1073
|
}
|
|
1230
1074
|
const { nonce } = await client.getTransferNonce(address);
|
|
1231
|
-
const signature = await signTransferMessage({
|
|
1075
|
+
const signature = await chunk4IW4V7YJ_cjs.signTransferMessage({
|
|
1232
1076
|
walletClient,
|
|
1233
1077
|
chainId: networkConfig.chainId,
|
|
1234
1078
|
verifyingContract: networkConfig.accountingContract,
|
|
@@ -1265,7 +1109,7 @@ function useTransfer(options = {}) {
|
|
|
1265
1109
|
throw new Error("Service address not configured");
|
|
1266
1110
|
}
|
|
1267
1111
|
const { nonce } = await client.getTransferLockedNonce(serviceAddress);
|
|
1268
|
-
const signature = await signTransferLockedMessage({
|
|
1112
|
+
const signature = await chunk4IW4V7YJ_cjs.signTransferLockedMessage({
|
|
1269
1113
|
walletClient,
|
|
1270
1114
|
chainId: networkConfig.chainId,
|
|
1271
1115
|
verifyingContract: networkConfig.accountingContract,
|
|
@@ -1325,8 +1169,8 @@ function useTransfer(options = {}) {
|
|
|
1325
1169
|
};
|
|
1326
1170
|
}
|
|
1327
1171
|
function useLockedFunds(options = {}) {
|
|
1328
|
-
const { client, pollingInterval, serviceAddress } =
|
|
1329
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1172
|
+
const { client, pollingInterval, serviceAddress } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1173
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk4IW4V7YJ_cjs.usePrivateReadRequest();
|
|
1330
1174
|
const query = reactQuery.useQuery({
|
|
1331
1175
|
queryKey: ["accounting-locked-funds", ...privateReadQueryScope, serviceAddress ?? null],
|
|
1332
1176
|
queryFn: async () => {
|
|
@@ -1348,8 +1192,8 @@ function useLockedFunds(options = {}) {
|
|
|
1348
1192
|
};
|
|
1349
1193
|
}
|
|
1350
1194
|
function useTotalLockedBalance(options = {}) {
|
|
1351
|
-
const { client, pollingInterval, defaultToken } =
|
|
1352
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1195
|
+
const { client, pollingInterval, defaultToken } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1196
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk4IW4V7YJ_cjs.usePrivateReadRequest();
|
|
1353
1197
|
const tokenId = options.tokenId ?? defaultToken?.id;
|
|
1354
1198
|
const query = reactQuery.useQuery({
|
|
1355
1199
|
queryKey: ["accounting-total-locked-balance", ...privateReadQueryScope, tokenId],
|
|
@@ -1370,8 +1214,8 @@ function useTotalLockedBalance(options = {}) {
|
|
|
1370
1214
|
};
|
|
1371
1215
|
}
|
|
1372
1216
|
function useExpiredLocks(options = {}) {
|
|
1373
|
-
const { client, pollingInterval } =
|
|
1374
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1217
|
+
const { client, pollingInterval } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1218
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk4IW4V7YJ_cjs.usePrivateReadRequest();
|
|
1375
1219
|
const query = reactQuery.useQuery({
|
|
1376
1220
|
queryKey: ["accounting-expired-locks", ...privateReadQueryScope],
|
|
1377
1221
|
queryFn: async () => {
|
|
@@ -1391,9 +1235,62 @@ function useExpiredLocks(options = {}) {
|
|
|
1391
1235
|
refetch: query.refetch
|
|
1392
1236
|
};
|
|
1393
1237
|
}
|
|
1238
|
+
function statusCodeOf(error) {
|
|
1239
|
+
return error instanceof chunk4IW4V7YJ_cjs.AccountingApiError ? error.statusCode : void 0;
|
|
1240
|
+
}
|
|
1241
|
+
function usePendingDeposits(options = {}) {
|
|
1242
|
+
const queryClient = react.useContext(reactQuery.QueryClientContext);
|
|
1243
|
+
const accountingContext = chunk4IW4V7YJ_cjs.useSafePrivanaContext();
|
|
1244
|
+
const hasProviders = !!queryClient && !!accountingContext;
|
|
1245
|
+
const client = accountingContext?.client;
|
|
1246
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk4IW4V7YJ_cjs.usePrivateReadRequest();
|
|
1247
|
+
const { chainId, tokenAddress, lookbackBlocks } = options;
|
|
1248
|
+
const query = reactQuery.useQuery({
|
|
1249
|
+
queryKey: ["accounting-pending-deposits", ...privateReadQueryScope, chainId, tokenAddress],
|
|
1250
|
+
queryFn: async () => {
|
|
1251
|
+
if (!privateReadAddress) throw new Error("No authenticated account available");
|
|
1252
|
+
if (!chainId) throw new Error("No chain ID provided");
|
|
1253
|
+
if (!client) throw new Error("No accounting client");
|
|
1254
|
+
try {
|
|
1255
|
+
return await executePrivateRead(
|
|
1256
|
+
() => client.getPendingDeposits({
|
|
1257
|
+
chain_id: chainId,
|
|
1258
|
+
token_address: tokenAddress,
|
|
1259
|
+
lookback_blocks: lookbackBlocks
|
|
1260
|
+
})
|
|
1261
|
+
);
|
|
1262
|
+
} catch (error) {
|
|
1263
|
+
if (statusCodeOf(error) === 404) {
|
|
1264
|
+
return { pending: [], scanned_from_block: 0, scanned_to_block: 0 };
|
|
1265
|
+
}
|
|
1266
|
+
throw error;
|
|
1267
|
+
}
|
|
1268
|
+
},
|
|
1269
|
+
enabled: hasProviders && (options.enabled ?? true) && privateReadReady && !!privateReadAddress && !!chainId && !!client,
|
|
1270
|
+
// A 503 means discovery is not configured for this chain server-side —
|
|
1271
|
+
// polling can't fix that, so stop until a manual refetch succeeds.
|
|
1272
|
+
refetchInterval: (query2) => statusCodeOf(query2.state.error) === 503 ? false : options.refetchInterval ?? 3e4,
|
|
1273
|
+
staleTime: 25e3,
|
|
1274
|
+
retry: (failureCount, error) => {
|
|
1275
|
+
const status = statusCodeOf(error);
|
|
1276
|
+
if (status === 429 || status === 404 || status === 503) return false;
|
|
1277
|
+
return failureCount < 2;
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
return {
|
|
1281
|
+
pending: query.data?.pending ?? [],
|
|
1282
|
+
scannedToBlock: query.data?.scanned_to_block,
|
|
1283
|
+
isFetching: query.isFetching,
|
|
1284
|
+
isError: query.isError,
|
|
1285
|
+
error: query.error,
|
|
1286
|
+
isRateLimited: statusCodeOf(query.error) === 429,
|
|
1287
|
+
isUnavailable: statusCodeOf(query.error) === 503,
|
|
1288
|
+
refetch: async () => (await query.refetch()).data
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1394
1291
|
function usePendingWithdrawals(options = {}) {
|
|
1395
1292
|
const { address, isConnected } = wagmi.useAccount();
|
|
1396
|
-
const { client, pollingInterval } =
|
|
1293
|
+
const { client, pollingInterval } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1397
1294
|
const query = reactQuery.useQuery({
|
|
1398
1295
|
queryKey: ["accounting-pending-withdrawals", address],
|
|
1399
1296
|
queryFn: async () => {
|
|
@@ -1429,8 +1326,8 @@ function usePendingWithdrawals(options = {}) {
|
|
|
1429
1326
|
};
|
|
1430
1327
|
}
|
|
1431
1328
|
function useHistory(options = {}) {
|
|
1432
|
-
const { client, pollingInterval } =
|
|
1433
|
-
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } =
|
|
1329
|
+
const { client, pollingInterval } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1330
|
+
const { executePrivateRead, privateReadAddress, privateReadQueryScope, privateReadReady } = chunk4IW4V7YJ_cjs.usePrivateReadRequest();
|
|
1434
1331
|
const offset = options.offset ?? -1;
|
|
1435
1332
|
const limit = options.limit ?? 50;
|
|
1436
1333
|
const query = reactQuery.useQuery({
|
|
@@ -1454,7 +1351,7 @@ function useHistory(options = {}) {
|
|
|
1454
1351
|
};
|
|
1455
1352
|
}
|
|
1456
1353
|
function useTokenInfo(options = {}) {
|
|
1457
|
-
const { client } =
|
|
1354
|
+
const { client } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1458
1355
|
const { tokenId } = options;
|
|
1459
1356
|
const query = reactQuery.useQuery({
|
|
1460
1357
|
queryKey: ["accounting-token-info", tokenId],
|
|
@@ -1474,7 +1371,7 @@ function useTokenInfo(options = {}) {
|
|
|
1474
1371
|
};
|
|
1475
1372
|
}
|
|
1476
1373
|
function useTokenList(options = {}) {
|
|
1477
|
-
const { client } =
|
|
1374
|
+
const { client } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1478
1375
|
const query = reactQuery.useQuery({
|
|
1479
1376
|
queryKey: ["accounting-token-list"],
|
|
1480
1377
|
queryFn: () => client.listTokens(),
|
|
@@ -1492,7 +1389,7 @@ function useTokenList(options = {}) {
|
|
|
1492
1389
|
function useModifyLock(options = {}) {
|
|
1493
1390
|
const { address } = wagmi.useAccount();
|
|
1494
1391
|
const { data: walletClient } = wagmi.useWalletClient();
|
|
1495
|
-
const { client, networkConfig } =
|
|
1392
|
+
const { client, networkConfig } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
1496
1393
|
const queryClient = reactQuery.useQueryClient();
|
|
1497
1394
|
const mutation = reactQuery.useMutation({
|
|
1498
1395
|
mutationFn: async (params) => {
|
|
@@ -1500,7 +1397,7 @@ function useModifyLock(options = {}) {
|
|
|
1500
1397
|
throw new Error("Wallet not connected");
|
|
1501
1398
|
}
|
|
1502
1399
|
const { nonce } = await client.getModifyLockNonce(address);
|
|
1503
|
-
const signature = await signModifyLockMessage({
|
|
1400
|
+
const signature = await chunk4IW4V7YJ_cjs.signModifyLockMessage({
|
|
1504
1401
|
walletClient,
|
|
1505
1402
|
chainId: networkConfig.chainId,
|
|
1506
1403
|
verifyingContract: networkConfig.accountingContract,
|
|
@@ -1559,7 +1456,7 @@ function DialogOverlay({
|
|
|
1559
1456
|
{
|
|
1560
1457
|
"data-slot": "dialog-overlay",
|
|
1561
1458
|
"data-privana": true,
|
|
1562
|
-
className:
|
|
1459
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
1563
1460
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
1564
1461
|
className
|
|
1565
1462
|
),
|
|
@@ -1581,7 +1478,7 @@ function DialogContent({
|
|
|
1581
1478
|
{
|
|
1582
1479
|
"data-slot": "dialog-content",
|
|
1583
1480
|
"data-privana": true,
|
|
1584
|
-
className:
|
|
1481
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
1585
1482
|
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
|
|
1586
1483
|
className
|
|
1587
1484
|
),
|
|
@@ -1609,7 +1506,7 @@ function DialogHeader({ className, ...props }) {
|
|
|
1609
1506
|
"div",
|
|
1610
1507
|
{
|
|
1611
1508
|
"data-slot": "dialog-header",
|
|
1612
|
-
className:
|
|
1509
|
+
className: chunk4IW4V7YJ_cjs.cn("flex flex-col gap-2 text-center sm:text-left", className),
|
|
1613
1510
|
...props
|
|
1614
1511
|
}
|
|
1615
1512
|
);
|
|
@@ -1619,7 +1516,7 @@ function DialogTitle({ className, ...props }) {
|
|
|
1619
1516
|
DialogPrimitive__namespace.Title,
|
|
1620
1517
|
{
|
|
1621
1518
|
"data-slot": "dialog-title",
|
|
1622
|
-
className:
|
|
1519
|
+
className: chunk4IW4V7YJ_cjs.cn("text-lg leading-none font-semibold", className),
|
|
1623
1520
|
...props
|
|
1624
1521
|
}
|
|
1625
1522
|
);
|
|
@@ -1632,7 +1529,7 @@ function DialogDescription({
|
|
|
1632
1529
|
DialogPrimitive__namespace.Description,
|
|
1633
1530
|
{
|
|
1634
1531
|
"data-slot": "dialog-description",
|
|
1635
|
-
className:
|
|
1532
|
+
className: chunk4IW4V7YJ_cjs.cn("text-muted-foreground text-sm", className),
|
|
1636
1533
|
...props
|
|
1637
1534
|
}
|
|
1638
1535
|
);
|
|
@@ -1827,7 +1724,7 @@ function ChevronDownIcon({
|
|
|
1827
1724
|
height: "16",
|
|
1828
1725
|
viewBox: "0 0 16 16",
|
|
1829
1726
|
fill: "none",
|
|
1830
|
-
className:
|
|
1727
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
1831
1728
|
"transition-transform",
|
|
1832
1729
|
direction === "right" && "-rotate-90",
|
|
1833
1730
|
direction === "up" && "rotate-180",
|
|
@@ -2103,7 +2000,7 @@ function DepositForm({
|
|
|
2103
2000
|
onSuccess
|
|
2104
2001
|
}) {
|
|
2105
2002
|
const { isConnected, address } = wagmi.useAccount();
|
|
2106
|
-
const { chains, getChainById: getChainById2 } =
|
|
2003
|
+
const { chains, getChainById: getChainById2 } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
2107
2004
|
const [amount, setAmount] = react.useState("");
|
|
2108
2005
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
2109
2006
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
@@ -2128,7 +2025,7 @@ function DepositForm({
|
|
|
2128
2025
|
}
|
|
2129
2026
|
});
|
|
2130
2027
|
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
2131
|
-
const formattedWalletBalance = walletBalance ?
|
|
2028
|
+
const formattedWalletBalance = walletBalance ? chunk4IW4V7YJ_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
|
|
2132
2029
|
const handleMaxClick = () => {
|
|
2133
2030
|
if (formattedWalletBalance && parseFloat(formattedWalletBalance) > 0) {
|
|
2134
2031
|
setAmount(formattedWalletBalance.replace(/[\s\u2009]/g, ""));
|
|
@@ -2136,7 +2033,7 @@ function DepositForm({
|
|
|
2136
2033
|
};
|
|
2137
2034
|
const hasValidAmount = amount && parseFloat(amount) > 0;
|
|
2138
2035
|
const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
2139
|
-
const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null &&
|
|
2036
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && walletBalance != null && chunk4IW4V7YJ_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
|
|
2140
2037
|
const {
|
|
2141
2038
|
txHash,
|
|
2142
2039
|
isGettingAddress,
|
|
@@ -2221,7 +2118,7 @@ function DepositForm({
|
|
|
2221
2118
|
const handleSubmit = async () => {
|
|
2222
2119
|
if (!amount || !selectedToken || exceedsBalance) return;
|
|
2223
2120
|
setCancelled(false);
|
|
2224
|
-
const amountInWei =
|
|
2121
|
+
const amountInWei = chunk4IW4V7YJ_cjs.parseTokenAmount(amount, selectedToken.decimals);
|
|
2225
2122
|
await deposit({
|
|
2226
2123
|
tokenId: selectedToken.id,
|
|
2227
2124
|
amount: amountInWei
|
|
@@ -2324,7 +2221,7 @@ function DepositForm({
|
|
|
2324
2221
|
setAmount(value);
|
|
2325
2222
|
}
|
|
2326
2223
|
},
|
|
2327
|
-
className:
|
|
2224
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2328
2225
|
"text-foreground flex-1 bg-transparent text-sm outline-none",
|
|
2329
2226
|
"placeholder:text-muted-foreground/50"
|
|
2330
2227
|
)
|
|
@@ -2351,7 +2248,7 @@ function DepositForm({
|
|
|
2351
2248
|
{
|
|
2352
2249
|
onClick: handleSubmit,
|
|
2353
2250
|
disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
|
|
2354
|
-
className:
|
|
2251
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2355
2252
|
"flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
|
|
2356
2253
|
"bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2357
2254
|
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
@@ -2368,7 +2265,7 @@ function WithdrawForm({
|
|
|
2368
2265
|
onUnsafeToCloseChange
|
|
2369
2266
|
}) {
|
|
2370
2267
|
const { isConnected, address } = wagmi.useAccount();
|
|
2371
|
-
const { chains, getChainById: getChainById2 } =
|
|
2268
|
+
const { chains, getChainById: getChainById2 } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
2372
2269
|
const [amount, setAmount] = react.useState("");
|
|
2373
2270
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
2374
2271
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
@@ -2381,7 +2278,7 @@ function WithdrawForm({
|
|
|
2381
2278
|
} = useBalance({
|
|
2382
2279
|
tokenId: selectedToken.id
|
|
2383
2280
|
});
|
|
2384
|
-
const formattedBalance =
|
|
2281
|
+
const formattedBalance = chunk4IW4V7YJ_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
|
|
2385
2282
|
const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
|
|
2386
2283
|
onProcessingSuccess: () => {
|
|
2387
2284
|
setAmount("");
|
|
@@ -2392,7 +2289,7 @@ function WithdrawForm({
|
|
|
2392
2289
|
setShowTimeout(true);
|
|
2393
2290
|
}
|
|
2394
2291
|
});
|
|
2395
|
-
const explorerUrl = address && targetChain ?
|
|
2292
|
+
const explorerUrl = address && targetChain ? chunk4IW4V7YJ_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
|
|
2396
2293
|
const getStepStatus = (step, after) => {
|
|
2397
2294
|
if (currentStep === step) return "active";
|
|
2398
2295
|
if (after.includes(currentStep)) return "completed";
|
|
@@ -2436,7 +2333,7 @@ function WithdrawForm({
|
|
|
2436
2333
|
const handleWithdraw = async () => {
|
|
2437
2334
|
if (!amount || !selectedToken || exceedsBalance) return;
|
|
2438
2335
|
setCancelled(false);
|
|
2439
|
-
const amountInWei =
|
|
2336
|
+
const amountInWei = chunk4IW4V7YJ_cjs.parseTokenAmount(amount, selectedToken.decimals);
|
|
2440
2337
|
await withdraw({
|
|
2441
2338
|
tokenId: selectedToken.id,
|
|
2442
2339
|
amount: amountInWei
|
|
@@ -2449,7 +2346,7 @@ function WithdrawForm({
|
|
|
2449
2346
|
};
|
|
2450
2347
|
const hasValidAmount = amount && parseFloat(amount) > 0;
|
|
2451
2348
|
const tooManyDecimals = hasValidAmount && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
2452
|
-
const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError &&
|
|
2349
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && !isBalanceLoading && !isBalanceError && chunk4IW4V7YJ_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
|
|
2453
2350
|
const getButtonText = () => {
|
|
2454
2351
|
if (!isConnected) return "Connect Wallet";
|
|
2455
2352
|
return "Withdraw";
|
|
@@ -2461,7 +2358,7 @@ function WithdrawForm({
|
|
|
2461
2358
|
title: "Withdrawal Complete",
|
|
2462
2359
|
message: `Your ${selectedToken.symbol} withdrawal has been processed. Funds should appear in your wallet shortly.`,
|
|
2463
2360
|
explorerUrl,
|
|
2464
|
-
explorerLabel: targetChain ?
|
|
2361
|
+
explorerLabel: targetChain ? chunk4IW4V7YJ_cjs.getExplorerLabel(targetChain.id) : void 0,
|
|
2465
2362
|
onDone: handleDone
|
|
2466
2363
|
}
|
|
2467
2364
|
);
|
|
@@ -2532,7 +2429,7 @@ function WithdrawForm({
|
|
|
2532
2429
|
setAmount(value);
|
|
2533
2430
|
}
|
|
2534
2431
|
},
|
|
2535
|
-
className:
|
|
2432
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2536
2433
|
"text-foreground flex-1 bg-transparent text-sm outline-none",
|
|
2537
2434
|
"placeholder:text-muted-foreground/50"
|
|
2538
2435
|
)
|
|
@@ -2559,7 +2456,7 @@ function WithdrawForm({
|
|
|
2559
2456
|
{
|
|
2560
2457
|
onClick: handleWithdraw,
|
|
2561
2458
|
disabled: !isConnected || !hasValidAmount || tooManyDecimals || !!exceedsBalance || isPending,
|
|
2562
|
-
className:
|
|
2459
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2563
2460
|
"flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors",
|
|
2564
2461
|
"bg-primary text-primary-foreground hover:bg-primary/90",
|
|
2565
2462
|
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
@@ -2580,15 +2477,15 @@ function BalanceCards({
|
|
|
2580
2477
|
tokenId: selectedToken.id
|
|
2581
2478
|
});
|
|
2582
2479
|
const { totalLocked, isLoading: lockedLoading } = useLockedFunds({ enabled: showLockedFunds });
|
|
2583
|
-
const formattedBalance =
|
|
2584
|
-
const formattedLocked = showLockedFunds ?
|
|
2585
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className:
|
|
2480
|
+
const formattedBalance = chunk4IW4V7YJ_cjs.formatTokenAmount(balanceWei, selectedToken.decimals);
|
|
2481
|
+
const formattedLocked = showLockedFunds ? chunk4IW4V7YJ_cjs.formatTokenAmount(String(totalLocked), selectedToken.decimals) : "0.00";
|
|
2482
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunk4IW4V7YJ_cjs.cn("flex gap-2", disabled && "opacity-50"), children: [
|
|
2586
2483
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2587
2484
|
"button",
|
|
2588
2485
|
{
|
|
2589
2486
|
onClick: onBalanceClick,
|
|
2590
2487
|
disabled,
|
|
2591
|
-
className:
|
|
2488
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2592
2489
|
"bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
|
|
2593
2490
|
disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
|
|
2594
2491
|
),
|
|
@@ -2609,7 +2506,7 @@ function BalanceCards({
|
|
|
2609
2506
|
{
|
|
2610
2507
|
onClick: onLockedFundsClick,
|
|
2611
2508
|
disabled,
|
|
2612
|
-
className:
|
|
2509
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2613
2510
|
"bg-muted flex flex-1 flex-col gap-2 rounded-[10px] p-5 text-left transition-colors",
|
|
2614
2511
|
disabled ? "cursor-not-allowed" : "hover:bg-muted/80 cursor-pointer"
|
|
2615
2512
|
),
|
|
@@ -2635,7 +2532,7 @@ function Tabs({
|
|
|
2635
2532
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2636
2533
|
"div",
|
|
2637
2534
|
{
|
|
2638
|
-
className:
|
|
2535
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2639
2536
|
"bg-muted relative flex gap-2 overflow-hidden rounded-[10px] p-1",
|
|
2640
2537
|
disabled && "opacity-50"
|
|
2641
2538
|
),
|
|
@@ -2643,7 +2540,7 @@ function Tabs({
|
|
|
2643
2540
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2644
2541
|
"div",
|
|
2645
2542
|
{
|
|
2646
|
-
className:
|
|
2543
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2647
2544
|
"bg-input absolute top-1 bottom-1 left-1 w-[calc(50%-8px)] rounded-md transition-transform duration-200",
|
|
2648
2545
|
activeTab === "withdraw" && "translate-x-[calc(100%+8px)]"
|
|
2649
2546
|
)
|
|
@@ -2654,7 +2551,7 @@ function Tabs({
|
|
|
2654
2551
|
{
|
|
2655
2552
|
onClick: () => !disabled && onTabChange("deposit"),
|
|
2656
2553
|
disabled,
|
|
2657
|
-
className:
|
|
2554
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2658
2555
|
"relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
|
|
2659
2556
|
activeTab === "deposit" ? "text-foreground" : "text-muted-foreground",
|
|
2660
2557
|
disabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
@@ -2667,7 +2564,7 @@ function Tabs({
|
|
|
2667
2564
|
{
|
|
2668
2565
|
onClick: () => !disabled && onTabChange("withdraw"),
|
|
2669
2566
|
disabled,
|
|
2670
|
-
className:
|
|
2567
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2671
2568
|
"relative z-10 flex-1 rounded-md px-3 py-[9px] text-sm transition-colors",
|
|
2672
2569
|
activeTab === "withdraw" ? "text-foreground" : "text-muted-foreground",
|
|
2673
2570
|
disabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
@@ -2680,14 +2577,14 @@ function Tabs({
|
|
|
2680
2577
|
);
|
|
2681
2578
|
}
|
|
2682
2579
|
function LockedFundsView({ onBack }) {
|
|
2683
|
-
const { getTokenById } =
|
|
2580
|
+
const { getTokenById } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
2684
2581
|
const { locks, isLoading } = useLockedFunds();
|
|
2685
2582
|
const { unlockFunds, unlockAllExpired, isPending } = useUnlockFunds();
|
|
2686
2583
|
const [collapsedSections, setCollapsedSections] = react.useState({});
|
|
2687
2584
|
const sections = react.useMemo(() => {
|
|
2688
2585
|
const sectionMap = {};
|
|
2689
2586
|
locks.forEach((lock) => {
|
|
2690
|
-
const serviceName =
|
|
2587
|
+
const serviceName = chunk4IW4V7YJ_cjs.shortenAddress(lock.service_address);
|
|
2691
2588
|
if (!sectionMap[lock.service_address]) {
|
|
2692
2589
|
sectionMap[lock.service_address] = {
|
|
2693
2590
|
title: `Service ${serviceName}`,
|
|
@@ -2696,9 +2593,9 @@ function LockedFundsView({ onBack }) {
|
|
|
2696
2593
|
}
|
|
2697
2594
|
sectionMap[lock.service_address].items.push({
|
|
2698
2595
|
lockId: lock.lock_id,
|
|
2699
|
-
amount:
|
|
2596
|
+
amount: chunk4IW4V7YJ_cjs.formatTokenAmount(String(lock.amount), getTokenById(lock.token_id)?.decimals ?? 18),
|
|
2700
2597
|
serviceAddress: lock.service_address,
|
|
2701
|
-
time: lock.is_expired ? "Click to unlock" :
|
|
2598
|
+
time: lock.is_expired ? "Click to unlock" : chunk4IW4V7YJ_cjs.formatTimeRemaining(lock.expiry),
|
|
2702
2599
|
isExpired: lock.is_expired
|
|
2703
2600
|
});
|
|
2704
2601
|
});
|
|
@@ -2750,7 +2647,7 @@ function LockedFundsView({ onBack }) {
|
|
|
2750
2647
|
!collapsedSections[section.title] && section.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2751
2648
|
"div",
|
|
2752
2649
|
{
|
|
2753
|
-
className:
|
|
2650
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2754
2651
|
"flex items-center justify-between gap-3 rounded-lg p-3",
|
|
2755
2652
|
item.isExpired && "bg-secondary"
|
|
2756
2653
|
),
|
|
@@ -2764,7 +2661,7 @@ function LockedFundsView({ onBack }) {
|
|
|
2764
2661
|
] }),
|
|
2765
2662
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-xs", children: [
|
|
2766
2663
|
"Service: ",
|
|
2767
|
-
|
|
2664
|
+
chunk4IW4V7YJ_cjs.shortenAddress(item.serviceAddress)
|
|
2768
2665
|
] })
|
|
2769
2666
|
] })
|
|
2770
2667
|
] }),
|
|
@@ -2805,7 +2702,7 @@ function BalanceTokenRow({ token }) {
|
|
|
2805
2702
|
const { balanceWei, isLoading } = useBalance({
|
|
2806
2703
|
tokenId: token.id
|
|
2807
2704
|
});
|
|
2808
|
-
const formattedBalance =
|
|
2705
|
+
const formattedBalance = chunk4IW4V7YJ_cjs.formatTokenAmount(balanceWei, token.decimals);
|
|
2809
2706
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center gap-2 rounded-lg px-3 py-2.5", children: [
|
|
2810
2707
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-[18px] w-[18px] overflow-hidden rounded-full", children: getTokenIcon(token.symbol, 18) }),
|
|
2811
2708
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground flex-1 text-sm", children: token.symbol }),
|
|
@@ -2813,7 +2710,7 @@ function BalanceTokenRow({ token }) {
|
|
|
2813
2710
|
] });
|
|
2814
2711
|
}
|
|
2815
2712
|
function BalanceDetailsView({ onBack }) {
|
|
2816
|
-
const { enabledTokens, chains } =
|
|
2713
|
+
const { enabledTokens, chains } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
2817
2714
|
const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
|
|
2818
2715
|
const chainTokens = react.useMemo(() => {
|
|
2819
2716
|
return enabledTokens.filter((t) => t.chainId === selectedChainId);
|
|
@@ -2839,7 +2736,7 @@ function BalanceDetailsView({ onBack }) {
|
|
|
2839
2736
|
"button",
|
|
2840
2737
|
{
|
|
2841
2738
|
onClick: () => setSelectedChainId(chain.id),
|
|
2842
|
-
className:
|
|
2739
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2843
2740
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2844
2741
|
isSelected && "bg-secondary"
|
|
2845
2742
|
),
|
|
@@ -2880,12 +2777,12 @@ function TokenRow({
|
|
|
2880
2777
|
query: { enabled: !!address && !isNative }
|
|
2881
2778
|
});
|
|
2882
2779
|
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
2883
|
-
const formattedBalance = walletBalance ?
|
|
2780
|
+
const formattedBalance = walletBalance ? chunk4IW4V7YJ_cjs.formatTokenAmount(walletBalance.toString(), token.decimals) : "0.00";
|
|
2884
2781
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2885
2782
|
"button",
|
|
2886
2783
|
{
|
|
2887
2784
|
onClick,
|
|
2888
|
-
className:
|
|
2785
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2889
2786
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2890
2787
|
isSelected && "bg-secondary"
|
|
2891
2788
|
),
|
|
@@ -2902,7 +2799,7 @@ function TokenSelectorView({
|
|
|
2902
2799
|
onSelect,
|
|
2903
2800
|
selectedTokenId
|
|
2904
2801
|
}) {
|
|
2905
|
-
const { enabledTokens, chains } =
|
|
2802
|
+
const { enabledTokens, chains } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
2906
2803
|
const [selectedChainId, setSelectedChainId] = react.useState(chains[0]?.id ?? 84532);
|
|
2907
2804
|
const chainTokens = react.useMemo(() => {
|
|
2908
2805
|
return enabledTokens.filter((t) => t.chainId === selectedChainId);
|
|
@@ -2932,7 +2829,7 @@ function TokenSelectorView({
|
|
|
2932
2829
|
"button",
|
|
2933
2830
|
{
|
|
2934
2831
|
onClick: () => setSelectedChainId(chain.id),
|
|
2935
|
-
className:
|
|
2832
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
2936
2833
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors",
|
|
2937
2834
|
isSelected && "bg-secondary"
|
|
2938
2835
|
),
|
|
@@ -2967,7 +2864,7 @@ function ModalBody({
|
|
|
2967
2864
|
defaultTab = "deposit",
|
|
2968
2865
|
onDepositSuccess
|
|
2969
2866
|
}) {
|
|
2970
|
-
const { defaultToken, tokensStatus } =
|
|
2867
|
+
const { defaultToken, tokensStatus } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
2971
2868
|
const [selectedToken, setSelectedToken] = react.useState(defaultToken);
|
|
2972
2869
|
const [activeTab, setActiveTab] = react.useState(defaultTab);
|
|
2973
2870
|
const [currentView, setCurrentView] = react.useState("main");
|
|
@@ -3025,7 +2922,7 @@ function ModalBody({
|
|
|
3025
2922
|
);
|
|
3026
2923
|
}
|
|
3027
2924
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 pb-4", children: [
|
|
3028
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
2925
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: chunk4IW4V7YJ_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3029
2926
|
BalanceCards,
|
|
3030
2927
|
{
|
|
3031
2928
|
selectedToken,
|
|
@@ -3035,7 +2932,7 @@ function ModalBody({
|
|
|
3035
2932
|
disabled: isInteractionPending
|
|
3036
2933
|
}
|
|
3037
2934
|
) }),
|
|
3038
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
2935
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: chunk4IW4V7YJ_cjs.cn(isInteractionPending && "pointer-events-none"), children: /* @__PURE__ */ jsxRuntime.jsx(Tabs, { activeTab, onTabChange: setActiveTab, disabled: isInteractionPending }) }),
|
|
3039
2936
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted rounded-[10px] p-5", children: activeTab === "deposit" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3040
2937
|
DepositForm,
|
|
3041
2938
|
{
|
|
@@ -3096,7 +2993,7 @@ function PrivanaModal({
|
|
|
3096
2993
|
onClick: handleClose,
|
|
3097
2994
|
disabled: isCloseBlocked,
|
|
3098
2995
|
"aria-label": "Close",
|
|
3099
|
-
className:
|
|
2996
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
3100
2997
|
"absolute top-6 right-5 z-20 flex h-6 w-6 items-center justify-center transition-colors",
|
|
3101
2998
|
isCloseBlocked ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
|
|
3102
2999
|
),
|
|
@@ -3152,7 +3049,7 @@ function PrivanaInlineModal({
|
|
|
3152
3049
|
"div",
|
|
3153
3050
|
{
|
|
3154
3051
|
"data-privana": true,
|
|
3155
|
-
className:
|
|
3052
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
3156
3053
|
"bg-card flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
3157
3054
|
className
|
|
3158
3055
|
),
|
|
@@ -3187,12 +3084,12 @@ function PrivanaButton({
|
|
|
3187
3084
|
}
|
|
3188
3085
|
const handleClick = () => setModalOpen(true);
|
|
3189
3086
|
const buttonElement = renderButton ? renderButton({ onClick: handleClick, isOpen: modalOpen }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3190
|
-
|
|
3087
|
+
chunk4IW4V7YJ_cjs.Button,
|
|
3191
3088
|
{
|
|
3192
3089
|
variant,
|
|
3193
3090
|
size,
|
|
3194
3091
|
asChild,
|
|
3195
|
-
className:
|
|
3092
|
+
className: chunk4IW4V7YJ_cjs.cn(className),
|
|
3196
3093
|
onClick: handleClick,
|
|
3197
3094
|
disabled: !isConnected,
|
|
3198
3095
|
...buttonProps,
|
|
@@ -3256,7 +3153,7 @@ function useMoonpayLimits({
|
|
|
3256
3153
|
};
|
|
3257
3154
|
}
|
|
3258
3155
|
function TokenSelectorView2({ selectedTokenId, onSelect }) {
|
|
3259
|
-
const { enabledTokens } =
|
|
3156
|
+
const { enabledTokens } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
3260
3157
|
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
3158
|
enabledTokens.map((token) => {
|
|
3262
3159
|
const isSelected = selectedTokenId === token.id;
|
|
@@ -3265,7 +3162,7 @@ function TokenSelectorView2({ selectedTokenId, onSelect }) {
|
|
|
3265
3162
|
{
|
|
3266
3163
|
type: "button",
|
|
3267
3164
|
onClick: () => onSelect(token.id),
|
|
3268
|
-
className:
|
|
3165
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
3269
3166
|
"hover:bg-secondary flex w-full cursor-pointer items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors",
|
|
3270
3167
|
isSelected && "bg-secondary"
|
|
3271
3168
|
),
|
|
@@ -3306,7 +3203,10 @@ function TokenSelectorView2({ selectedTokenId, onSelect }) {
|
|
|
3306
3203
|
function CreditCardWidgetView({
|
|
3307
3204
|
token,
|
|
3308
3205
|
amount,
|
|
3309
|
-
allowance
|
|
3206
|
+
allowance,
|
|
3207
|
+
onCredited,
|
|
3208
|
+
onLockSubmitted,
|
|
3209
|
+
onLockFailed
|
|
3310
3210
|
}) {
|
|
3311
3211
|
const moonpayCurrencyCode = token?.moonpayCurrencyCode;
|
|
3312
3212
|
const containerRef = react.useRef(null);
|
|
@@ -3317,14 +3217,22 @@ function CreditCardWidgetView({
|
|
|
3317
3217
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: "bg-muted flex flex-col gap-6 rounded-[10px] p-5", children: [
|
|
3318
3218
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-foreground text-[28px] leading-8 font-medium", children: "Complete your purchase" }),
|
|
3319
3219
|
token && moonpayCurrencyCode ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3320
|
-
|
|
3220
|
+
chunk4IW4V7YJ_cjs.FiatOnRampForm,
|
|
3321
3221
|
{
|
|
3322
3222
|
tokenId: token.id,
|
|
3323
3223
|
currencyCode: moonpayCurrencyCode,
|
|
3324
|
-
|
|
3224
|
+
quoteCurrencyAmount: amount || void 0,
|
|
3225
|
+
lockAmount: true,
|
|
3325
3226
|
variant: "embedded",
|
|
3326
3227
|
autoStart: true,
|
|
3327
|
-
theme: widgetTheme
|
|
3228
|
+
theme: widgetTheme,
|
|
3229
|
+
postDepositLock: allowance ? {
|
|
3230
|
+
maxAmount: BigInt(allowance.value),
|
|
3231
|
+
lockDuration: allowance.lockDuration
|
|
3232
|
+
} : void 0,
|
|
3233
|
+
onCredited,
|
|
3234
|
+
onLockSubmitted,
|
|
3235
|
+
onLockFailed
|
|
3328
3236
|
}
|
|
3329
3237
|
) : /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground text-sm", children: [
|
|
3330
3238
|
token?.symbol ?? "This token",
|
|
@@ -3369,7 +3277,7 @@ function PolicyTermRow({
|
|
|
3369
3277
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3370
3278
|
"div",
|
|
3371
3279
|
{
|
|
3372
|
-
className:
|
|
3280
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
3373
3281
|
"mt-0.5 shrink-0",
|
|
3374
3282
|
kind === "permission" ? "text-emerald-500" : "text-orange-500"
|
|
3375
3283
|
),
|
|
@@ -3431,7 +3339,7 @@ function AllowancePolicySection({
|
|
|
3431
3339
|
] });
|
|
3432
3340
|
}
|
|
3433
3341
|
function MoonPayGate({ enabled, children }) {
|
|
3434
|
-
const { networkConfig } =
|
|
3342
|
+
const { networkConfig } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
3435
3343
|
const apiKey = networkConfig.moonpayApiKey;
|
|
3436
3344
|
if (!enabled || !apiKey) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
3437
3345
|
return /* @__PURE__ */ jsxRuntime.jsx(moonpayReact.MoonPayProvider, { apiKey, children });
|
|
@@ -3444,7 +3352,7 @@ function MethodTabs({
|
|
|
3444
3352
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3445
3353
|
"div",
|
|
3446
3354
|
{
|
|
3447
|
-
className:
|
|
3355
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
3448
3356
|
"bg-input absolute top-1 bottom-1 left-1 w-[calc(50%-8px)] rounded-md transition-transform duration-200",
|
|
3449
3357
|
activeTab === "credit-card" && "translate-x-[calc(100%+8px)]"
|
|
3450
3358
|
)
|
|
@@ -3455,7 +3363,7 @@ function MethodTabs({
|
|
|
3455
3363
|
{
|
|
3456
3364
|
type: "button",
|
|
3457
3365
|
onClick: () => onTabChange("crypto"),
|
|
3458
|
-
className:
|
|
3366
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
3459
3367
|
"relative z-10 flex-1 cursor-pointer rounded-md px-3 py-[9px] text-sm font-medium transition-colors",
|
|
3460
3368
|
activeTab === "crypto" ? "text-foreground" : "text-muted-foreground"
|
|
3461
3369
|
),
|
|
@@ -3467,7 +3375,7 @@ function MethodTabs({
|
|
|
3467
3375
|
{
|
|
3468
3376
|
type: "button",
|
|
3469
3377
|
onClick: () => onTabChange("credit-card"),
|
|
3470
|
-
className:
|
|
3378
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
3471
3379
|
"relative z-10 flex-1 cursor-pointer rounded-md px-3 py-[9px] text-sm font-medium transition-colors",
|
|
3472
3380
|
activeTab === "credit-card" ? "text-foreground" : "text-muted-foreground"
|
|
3473
3381
|
),
|
|
@@ -3508,7 +3416,7 @@ function DepositView({
|
|
|
3508
3416
|
onSubmit,
|
|
3509
3417
|
isSubmitting = false
|
|
3510
3418
|
}) {
|
|
3511
|
-
const { getChainById: getChainById2, chains, serviceName, serviceIcon, networkConfig } =
|
|
3419
|
+
const { getChainById: getChainById2, chains, serviceName, serviceIcon, networkConfig } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
3512
3420
|
const { address, isConnected } = wagmi.useAccount();
|
|
3513
3421
|
const appName = serviceName ?? "Privana";
|
|
3514
3422
|
const chain = selectedToken ? getChainById2(selectedToken.chainId) : void 0;
|
|
@@ -3531,7 +3439,7 @@ function DepositView({
|
|
|
3531
3439
|
query: { enabled: isConnectedSource && !!address && !!selectedToken && !isNative }
|
|
3532
3440
|
});
|
|
3533
3441
|
const walletBalance = isNative ? nativeBalanceData?.value : erc20Balance;
|
|
3534
|
-
const formattedWalletBalance = walletBalance != null && selectedToken ?
|
|
3442
|
+
const formattedWalletBalance = walletBalance != null && selectedToken ? chunk4IW4V7YJ_cjs.formatTokenAmount(walletBalance.toString(), selectedToken.decimals) : "0.00";
|
|
3535
3443
|
const {
|
|
3536
3444
|
minBuyAmount: moonpayMinBuy,
|
|
3537
3445
|
isLoading: moonpayLimitsLoading,
|
|
@@ -3544,7 +3452,7 @@ function DepositView({
|
|
|
3544
3452
|
const hasValidAmount = !!amount && parseFloat(amount) > 0;
|
|
3545
3453
|
const maxAmountDecimals = isCreditCard ? 2 : selectedToken?.decimals;
|
|
3546
3454
|
const tooManyDecimals = hasValidAmount && maxAmountDecimals != null && amount.includes(".") && amount.split(".")[1].length > maxAmountDecimals;
|
|
3547
|
-
const exceedsBalance = isConnectedSource && hasValidAmount && !tooManyDecimals && !!selectedToken && walletBalance != null &&
|
|
3455
|
+
const exceedsBalance = isConnectedSource && hasValidAmount && !tooManyDecimals && !!selectedToken && walletBalance != null && chunk4IW4V7YJ_cjs.parseTokenAmount(amount, selectedToken.decimals) > walletBalance;
|
|
3548
3456
|
const belowMoonpayMin = isCreditCard && hasValidAmount && moonpayMinBuy != null && parseFloat(amount) < moonpayMinBuy;
|
|
3549
3457
|
const moonpayLimitsUnready = isCreditCard && !!selectedToken?.moonpayCurrencyCode && moonpayMinBuy == null;
|
|
3550
3458
|
const creditCardUnavailable = isCreditCard && !!selectedToken && !selectedToken.moonpayCurrencyCode;
|
|
@@ -3599,7 +3507,7 @@ function DepositView({
|
|
|
3599
3507
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3600
3508
|
"div",
|
|
3601
3509
|
{
|
|
3602
|
-
className:
|
|
3510
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
3603
3511
|
"border-border bg-input flex items-center gap-2 rounded-[10px] border",
|
|
3604
3512
|
isConnectedSource ? "py-1 pr-1 pl-3" : "px-3 py-3"
|
|
3605
3513
|
),
|
|
@@ -3626,7 +3534,7 @@ function DepositView({
|
|
|
3626
3534
|
className: "bg-secondary text-foreground hover:bg-secondary/80 cursor-pointer rounded px-3 py-2.5 text-xs font-semibold transition-colors",
|
|
3627
3535
|
children: "MAX"
|
|
3628
3536
|
}
|
|
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 })
|
|
3537
|
+
) : isCreditCard ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: selectedToken?.symbol ?? "USD" }) : selectedToken && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: selectedToken.symbol })
|
|
3630
3538
|
]
|
|
3631
3539
|
}
|
|
3632
3540
|
),
|
|
@@ -3680,14 +3588,105 @@ function SummaryRow({ value, label }) {
|
|
|
3680
3588
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: label })
|
|
3681
3589
|
] });
|
|
3682
3590
|
}
|
|
3591
|
+
var LISTENING_WINDOW_MS = 36e5;
|
|
3592
|
+
function remainingSeconds(deadline) {
|
|
3593
|
+
return Math.max(0, Math.round((deadline - Date.now()) / 1e3));
|
|
3594
|
+
}
|
|
3595
|
+
function useCountdown(deadline) {
|
|
3596
|
+
const [secondsLeft, setSecondsLeft] = react.useState(() => remainingSeconds(deadline));
|
|
3597
|
+
react.useEffect(() => {
|
|
3598
|
+
if (remainingSeconds(deadline) <= 0) return;
|
|
3599
|
+
const id = setInterval(() => {
|
|
3600
|
+
const left = remainingSeconds(deadline);
|
|
3601
|
+
setSecondsLeft(left);
|
|
3602
|
+
if (left <= 0) clearInterval(id);
|
|
3603
|
+
}, 1e3);
|
|
3604
|
+
return () => clearInterval(id);
|
|
3605
|
+
}, [deadline]);
|
|
3606
|
+
return secondsLeft;
|
|
3607
|
+
}
|
|
3608
|
+
function AwaitingDepositStatus({
|
|
3609
|
+
title,
|
|
3610
|
+
subtitle,
|
|
3611
|
+
remaining
|
|
3612
|
+
}) {
|
|
3613
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 text-center", children: [
|
|
3614
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 32 }) }),
|
|
3615
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3616
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-foreground text-xl leading-6 font-medium", children: title }),
|
|
3617
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground text-sm leading-[18px]", children: [
|
|
3618
|
+
subtitle,
|
|
3619
|
+
remaining && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3620
|
+
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
3621
|
+
"Remaining time: ",
|
|
3622
|
+
remaining
|
|
3623
|
+
] })
|
|
3624
|
+
] })
|
|
3625
|
+
] })
|
|
3626
|
+
] });
|
|
3627
|
+
}
|
|
3683
3628
|
function ExternalDepositView({
|
|
3684
3629
|
token,
|
|
3685
|
-
amount
|
|
3630
|
+
amount,
|
|
3631
|
+
onCredited
|
|
3686
3632
|
}) {
|
|
3687
|
-
const { getChainById: getChainById2 } =
|
|
3633
|
+
const { getChainById: getChainById2 } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
3688
3634
|
const { depositAddress, isReady, isLoading } = useDepositAddress();
|
|
3689
3635
|
const chain = token ? getChainById2(token.chainId) : void 0;
|
|
3690
3636
|
const [copied, setCopied] = react.useState(false);
|
|
3637
|
+
const [deadline] = react.useState(() => Date.now() + LISTENING_WINDOW_MS);
|
|
3638
|
+
const secondsLeft = useCountdown(deadline);
|
|
3639
|
+
const listening = secondsLeft > 0;
|
|
3640
|
+
const [nothingFound, setNothingFound] = react.useState(false);
|
|
3641
|
+
const [credited, setCredited] = react.useState(null);
|
|
3642
|
+
const verification = chunk4IW4V7YJ_cjs.useDepositVerification({
|
|
3643
|
+
onCredited: (txHash) => {
|
|
3644
|
+
if (onCredited) {
|
|
3645
|
+
onCredited();
|
|
3646
|
+
return;
|
|
3647
|
+
}
|
|
3648
|
+
setCredited({ txHash });
|
|
3649
|
+
}
|
|
3650
|
+
});
|
|
3651
|
+
const { isVerifying, verificationFailed, didTimeout, verify } = verification;
|
|
3652
|
+
const scanPaused = isVerifying || verificationFailed || didTimeout || !!credited;
|
|
3653
|
+
const {
|
|
3654
|
+
pending,
|
|
3655
|
+
isFetching: isScanning,
|
|
3656
|
+
isError: isScanError,
|
|
3657
|
+
isRateLimited,
|
|
3658
|
+
isUnavailable,
|
|
3659
|
+
refetch: refetchPendingDeposits
|
|
3660
|
+
} = usePendingDeposits({
|
|
3661
|
+
chainId: token?.chainId,
|
|
3662
|
+
enabled: isReady && !!depositAddress && !!token,
|
|
3663
|
+
refetchInterval: listening && !scanPaused ? 3e4 : false
|
|
3664
|
+
});
|
|
3665
|
+
const processedRef = react.useRef(/* @__PURE__ */ new Set());
|
|
3666
|
+
react.useEffect(() => {
|
|
3667
|
+
if (scanPaused) return;
|
|
3668
|
+
const next = [...pending].sort((a, b) => a.block_number - b.block_number).find((d) => !processedRef.current.has(`${d.tx_hash}:${d.log_index}`));
|
|
3669
|
+
if (!next) return;
|
|
3670
|
+
processedRef.current.add(`${next.tx_hash}:${next.log_index}`);
|
|
3671
|
+
void verify({
|
|
3672
|
+
hash: next.tx_hash,
|
|
3673
|
+
chainId: next.chain_id,
|
|
3674
|
+
amount: BigInt(next.amount),
|
|
3675
|
+
logIndex: next.log_index
|
|
3676
|
+
});
|
|
3677
|
+
}, [pending, scanPaused, verify]);
|
|
3678
|
+
const nothingFoundTimerRef = react.useRef(void 0);
|
|
3679
|
+
react.useEffect(() => () => clearTimeout(nothingFoundTimerRef.current), []);
|
|
3680
|
+
const handleRefresh = () => {
|
|
3681
|
+
processedRef.current.clear();
|
|
3682
|
+
void refetchPendingDeposits().then((result) => {
|
|
3683
|
+
if (!result || result.pending.length === 0) {
|
|
3684
|
+
setNothingFound(true);
|
|
3685
|
+
clearTimeout(nothingFoundTimerRef.current);
|
|
3686
|
+
nothingFoundTimerRef.current = setTimeout(() => setNothingFound(false), 4e3);
|
|
3687
|
+
}
|
|
3688
|
+
});
|
|
3689
|
+
};
|
|
3691
3690
|
const handleCopy = () => {
|
|
3692
3691
|
if (!depositAddress) return;
|
|
3693
3692
|
void navigator.clipboard.writeText(depositAddress);
|
|
@@ -3706,11 +3705,11 @@ function ExternalDepositView({
|
|
|
3706
3705
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-border h-px w-full" }),
|
|
3707
3706
|
/* @__PURE__ */ jsxRuntime.jsx(SummaryRow, { value: amount || "\u2014", label: "Value" })
|
|
3708
3707
|
] }),
|
|
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(
|
|
3708
|
+
/* @__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(chunk4IW4V7YJ_cjs.Skeleton, { className: "h-full w-full rounded-[10px]" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Deposit address unavailable" }) }),
|
|
3710
3709
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
3711
3710
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "Deposit Address" }),
|
|
3712
3711
|
/* @__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(
|
|
3712
|
+
/* @__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(chunk4IW4V7YJ_cjs.Skeleton, { className: "h-4 w-3/4" }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: "\u2014" }) }),
|
|
3714
3713
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3715
3714
|
"button",
|
|
3716
3715
|
{
|
|
@@ -3725,6 +3724,55 @@ function ExternalDepositView({
|
|
|
3725
3724
|
}
|
|
3726
3725
|
)
|
|
3727
3726
|
] })
|
|
3727
|
+
] }),
|
|
3728
|
+
credited ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3729
|
+
TransactionSuccessView,
|
|
3730
|
+
{
|
|
3731
|
+
title: "Deposit Credited",
|
|
3732
|
+
message: `Transfer ${chunk4IW4V7YJ_cjs.shortenAddress(credited.txHash)} has been credited to your Privana balance.`,
|
|
3733
|
+
onDone: () => {
|
|
3734
|
+
setCredited(null);
|
|
3735
|
+
verification.reset();
|
|
3736
|
+
void refetchPendingDeposits();
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3739
|
+
) : verificationFailed || didTimeout ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3740
|
+
TransactionErrorView,
|
|
3741
|
+
{
|
|
3742
|
+
title: "Could not verify deposit",
|
|
3743
|
+
message: didTimeout ? "Verification timed out \u2014 your deposit may still be credited in the background." : verification.error?.message ?? "Your transfer was found but could not be verified.",
|
|
3744
|
+
onRetry: () => void verification.retryVerification(),
|
|
3745
|
+
onDismiss: () => verification.reset(),
|
|
3746
|
+
isRetrying: isVerifying
|
|
3747
|
+
}
|
|
3748
|
+
) : isVerifying ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3749
|
+
AwaitingDepositStatus,
|
|
3750
|
+
{
|
|
3751
|
+
title: "Deposit detected",
|
|
3752
|
+
subtitle: "Crediting the incoming transaction to your Privana balance..."
|
|
3753
|
+
}
|
|
3754
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3755
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3756
|
+
AwaitingDepositStatus,
|
|
3757
|
+
{
|
|
3758
|
+
title: "Awaiting Deposit",
|
|
3759
|
+
subtitle: listening ? "We are listening for your incoming transaction for the next hour." : "We've stopped listening automatically. Use the button below to check for your deposit.",
|
|
3760
|
+
remaining: listening ? chunk4IW4V7YJ_cjs.formatCountdown(secondsLeft) : void 0
|
|
3761
|
+
}
|
|
3762
|
+
),
|
|
3763
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
3764
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3765
|
+
"button",
|
|
3766
|
+
{
|
|
3767
|
+
type: "button",
|
|
3768
|
+
onClick: handleRefresh,
|
|
3769
|
+
disabled: !depositAddress || isScanning,
|
|
3770
|
+
className: "bg-secondary text-foreground hover:bg-secondary/80 flex h-10 w-full cursor-pointer items-center justify-center rounded-[10px] px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
|
|
3771
|
+
children: "Refresh deposit status"
|
|
3772
|
+
}
|
|
3773
|
+
),
|
|
3774
|
+
isRateLimited ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-center text-sm", children: "Checked too recently \u2014 try again in a moment." }) : isUnavailable ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-center text-sm", children: "Deposit discovery is unavailable for this chain." }) : isScanError ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-center text-sm", children: "Chain temporarily unreachable \u2014 retrying automatically." }) : nothingFound ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-center text-sm", children: "No incoming transaction found yet." }) : null
|
|
3775
|
+
] })
|
|
3728
3776
|
] })
|
|
3729
3777
|
] });
|
|
3730
3778
|
}
|
|
@@ -3737,11 +3785,12 @@ function DepositModalContent({
|
|
|
3737
3785
|
onConnectWallet,
|
|
3738
3786
|
onDeposit,
|
|
3739
3787
|
onDepositSuccess,
|
|
3788
|
+
onLockFailed,
|
|
3740
3789
|
onClose,
|
|
3741
3790
|
onCloseBlockedChange,
|
|
3742
3791
|
onExit
|
|
3743
3792
|
}) {
|
|
3744
|
-
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig, getChainById: getChainById2 } =
|
|
3793
|
+
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig, getChainById: getChainById2 } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
3745
3794
|
const { address } = wagmi.useAccount();
|
|
3746
3795
|
const appName = serviceName ?? "Privana";
|
|
3747
3796
|
const [activeTab, setActiveTab] = react.useState(defaultTab);
|
|
@@ -3768,6 +3817,21 @@ function DepositModalContent({
|
|
|
3768
3817
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
3769
3818
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
3770
3819
|
const [cancelled, setCancelled] = react.useState(false);
|
|
3820
|
+
const [isSubmittingLock, setIsSubmittingLock] = react.useState(false);
|
|
3821
|
+
const [lockFailedMessage, setLockFailedMessage] = react.useState(null);
|
|
3822
|
+
const finishDeposit = () => {
|
|
3823
|
+
setAmount("");
|
|
3824
|
+
if (onDepositSuccess) {
|
|
3825
|
+
resetDeposit();
|
|
3826
|
+
onDepositSuccess();
|
|
3827
|
+
} else {
|
|
3828
|
+
setShowSuccess(true);
|
|
3829
|
+
}
|
|
3830
|
+
};
|
|
3831
|
+
const finishCardPurchase = () => {
|
|
3832
|
+
setAmount("");
|
|
3833
|
+
onDepositSuccess?.();
|
|
3834
|
+
};
|
|
3771
3835
|
const {
|
|
3772
3836
|
txHash,
|
|
3773
3837
|
isGettingAddress,
|
|
@@ -3782,14 +3846,24 @@ function DepositModalContent({
|
|
|
3782
3846
|
retryVerification,
|
|
3783
3847
|
reset: resetDeposit
|
|
3784
3848
|
} = useDeposit({
|
|
3785
|
-
onCredited: () => {
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
onDepositSuccess();
|
|
3790
|
-
} else {
|
|
3791
|
-
setShowSuccess(true);
|
|
3849
|
+
onCredited: (_txHash, _response, lockPending) => {
|
|
3850
|
+
if (lockPending) {
|
|
3851
|
+
setIsSubmittingLock(true);
|
|
3852
|
+
return;
|
|
3792
3853
|
}
|
|
3854
|
+
finishDeposit();
|
|
3855
|
+
},
|
|
3856
|
+
onLockSubmitted: () => {
|
|
3857
|
+
setIsSubmittingLock(false);
|
|
3858
|
+
finishDeposit();
|
|
3859
|
+
},
|
|
3860
|
+
// The deposit credited; only the policy lock failed. Success must not
|
|
3861
|
+
// fire (the host would act on unlocked funds) — show the dedicated
|
|
3862
|
+
// error view and let the host re-prompt for a fresh lock.
|
|
3863
|
+
onLockFailed: (err) => {
|
|
3864
|
+
setIsSubmittingLock(false);
|
|
3865
|
+
setLockFailedMessage(err.message);
|
|
3866
|
+
onLockFailed?.(err);
|
|
3793
3867
|
},
|
|
3794
3868
|
onCheckTimeout: () => {
|
|
3795
3869
|
setAmount("");
|
|
@@ -3822,7 +3896,11 @@ function DepositModalContent({
|
|
|
3822
3896
|
setCancelled(false);
|
|
3823
3897
|
deposit({
|
|
3824
3898
|
tokenId: token.id,
|
|
3825
|
-
amount:
|
|
3899
|
+
amount: chunk4IW4V7YJ_cjs.parseTokenAmount(args.amount, token.decimals),
|
|
3900
|
+
postDepositLock: allowance ? {
|
|
3901
|
+
maxAmount: BigInt(allowance.value),
|
|
3902
|
+
lockDuration: allowance.lockDuration
|
|
3903
|
+
} : void 0
|
|
3826
3904
|
}).catch((err) => {
|
|
3827
3905
|
sonner.toast.error(err instanceof Error ? err.message : "Deposit failed");
|
|
3828
3906
|
});
|
|
@@ -3832,26 +3910,32 @@ function DepositModalContent({
|
|
|
3832
3910
|
const depositSteps = [
|
|
3833
3911
|
{
|
|
3834
3912
|
label: "Getting deposit address",
|
|
3835
|
-
status: isGettingAddress ? "active" : isSwitchingChain || isSendingTransaction || isWaitingForConfirmation || isWaitingForProcessing ? "completed" : "pending"
|
|
3913
|
+
status: isGettingAddress ? "active" : isSwitchingChain || isSendingTransaction || isWaitingForConfirmation || isWaitingForProcessing || isSubmittingLock ? "completed" : "pending"
|
|
3836
3914
|
},
|
|
3837
3915
|
{
|
|
3838
3916
|
label: `Switching to ${targetChain?.name ?? "deposit chain"}`,
|
|
3839
|
-
status: isSwitchingChain ? "active" : isSendingTransaction || isWaitingForConfirmation || isWaitingForProcessing ? "completed" : "pending"
|
|
3917
|
+
status: isSwitchingChain ? "active" : isSendingTransaction || isWaitingForConfirmation || isWaitingForProcessing || isSubmittingLock ? "completed" : "pending"
|
|
3840
3918
|
},
|
|
3841
3919
|
{
|
|
3842
3920
|
label: "Confirm in wallet",
|
|
3843
|
-
status: isSendingTransaction ? "active" : isWaitingForConfirmation || isWaitingForProcessing ? "completed" : "pending"
|
|
3921
|
+
status: isSendingTransaction ? "active" : isWaitingForConfirmation || isWaitingForProcessing || isSubmittingLock ? "completed" : "pending"
|
|
3844
3922
|
},
|
|
3845
3923
|
{
|
|
3846
3924
|
label: "Confirming transaction",
|
|
3847
|
-
status: isWaitingForConfirmation ? "active" : isWaitingForProcessing ? "completed" : "pending"
|
|
3925
|
+
status: isWaitingForConfirmation ? "active" : isWaitingForProcessing || isSubmittingLock ? "completed" : "pending"
|
|
3848
3926
|
},
|
|
3849
3927
|
{
|
|
3850
3928
|
label: "Verifying deposit \u2014 may take up to a few minutes",
|
|
3851
|
-
status: isWaitingForProcessing ? "active" : "pending"
|
|
3852
|
-
}
|
|
3929
|
+
status: isWaitingForProcessing ? "active" : isSubmittingLock ? "completed" : "pending"
|
|
3930
|
+
},
|
|
3931
|
+
...allowance ? [
|
|
3932
|
+
{
|
|
3933
|
+
label: `Locking funds for ${appName}`,
|
|
3934
|
+
status: isSubmittingLock ? "active" : "pending"
|
|
3935
|
+
}
|
|
3936
|
+
] : []
|
|
3853
3937
|
];
|
|
3854
|
-
const flowView = showSuccess ? "deposit-success" : showTimeout ? "deposit-timeout" : verificationFailed ? "deposit-error" : isPending && !cancelled ? "depositing" : null;
|
|
3938
|
+
const flowView = showSuccess ? "deposit-success" : lockFailedMessage ? "lock-error" : showTimeout ? "deposit-timeout" : verificationFailed ? "deposit-error" : isPending && !cancelled || isSubmittingLock ? "depositing" : null;
|
|
3855
3939
|
const activeView = flowView ?? view;
|
|
3856
3940
|
const handleDepositDone = () => {
|
|
3857
3941
|
setShowSuccess(false);
|
|
@@ -3863,6 +3947,12 @@ function DepositModalContent({
|
|
|
3863
3947
|
setCancelled(true);
|
|
3864
3948
|
resetDeposit();
|
|
3865
3949
|
};
|
|
3950
|
+
const handleLockFailedDone = () => {
|
|
3951
|
+
setLockFailedMessage(null);
|
|
3952
|
+
setAmount("");
|
|
3953
|
+
setCancelled(false);
|
|
3954
|
+
resetDeposit();
|
|
3955
|
+
};
|
|
3866
3956
|
const handleDismissVerificationError = () => {
|
|
3867
3957
|
setAmount("");
|
|
3868
3958
|
setCancelled(false);
|
|
@@ -3888,7 +3978,7 @@ function DepositModalContent({
|
|
|
3888
3978
|
onClick: onClose,
|
|
3889
3979
|
disabled: isUnsafeToClose,
|
|
3890
3980
|
"aria-label": "Close",
|
|
3891
|
-
className:
|
|
3981
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
3892
3982
|
"absolute top-6 right-5 z-20 flex h-5 w-5 items-center justify-center transition-colors",
|
|
3893
3983
|
isUnsafeToClose ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
|
|
3894
3984
|
),
|
|
@@ -3916,6 +4006,14 @@ function DepositModalContent({
|
|
|
3916
4006
|
onDone: handleDepositDone
|
|
3917
4007
|
}
|
|
3918
4008
|
),
|
|
4009
|
+
activeView === "lock-error" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4010
|
+
TransactionWarningView,
|
|
4011
|
+
{
|
|
4012
|
+
title: "Deposit credited, lock failed",
|
|
4013
|
+
message: `Your deposit was credited but locking the funds for ${appName} failed: ${lockFailedMessage}`,
|
|
4014
|
+
onDone: handleLockFailedDone
|
|
4015
|
+
}
|
|
4016
|
+
),
|
|
3919
4017
|
activeView === "deposit-timeout" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3920
4018
|
TransactionWarningView,
|
|
3921
4019
|
{
|
|
@@ -4009,8 +4107,28 @@ function DepositModalContent({
|
|
|
4009
4107
|
}
|
|
4010
4108
|
}
|
|
4011
4109
|
),
|
|
4012
|
-
activeView === "external-deposit" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4013
|
-
|
|
4110
|
+
activeView === "external-deposit" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4111
|
+
ExternalDepositView,
|
|
4112
|
+
{
|
|
4113
|
+
token: selectedToken,
|
|
4114
|
+
amount,
|
|
4115
|
+
onCredited: allowance ? void 0 : onDepositSuccess
|
|
4116
|
+
}
|
|
4117
|
+
),
|
|
4118
|
+
activeView === "credit-card-widget" && /* @__PURE__ */ jsxRuntime.jsx(MoonPayGate, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4119
|
+
CreditCardWidgetView,
|
|
4120
|
+
{
|
|
4121
|
+
token: selectedToken,
|
|
4122
|
+
amount,
|
|
4123
|
+
allowance,
|
|
4124
|
+
onCredited: allowance ? void 0 : finishCardPurchase,
|
|
4125
|
+
onLockSubmitted: finishCardPurchase,
|
|
4126
|
+
onLockFailed: (err) => {
|
|
4127
|
+
setLockFailedMessage(err.message);
|
|
4128
|
+
onLockFailed?.(err);
|
|
4129
|
+
}
|
|
4130
|
+
}
|
|
4131
|
+
) })
|
|
4014
4132
|
] });
|
|
4015
4133
|
}
|
|
4016
4134
|
function DepositModal({ open, onClose, ...handlers }) {
|
|
@@ -4059,7 +4177,7 @@ function DepositInlineModal({ className, ...handlers }) {
|
|
|
4059
4177
|
"div",
|
|
4060
4178
|
{
|
|
4061
4179
|
"data-privana": true,
|
|
4062
|
-
className:
|
|
4180
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
4063
4181
|
"bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
4064
4182
|
className
|
|
4065
4183
|
),
|
|
@@ -4074,7 +4192,7 @@ function WithdrawView({
|
|
|
4074
4192
|
onSelectToken,
|
|
4075
4193
|
onPendingChange
|
|
4076
4194
|
}) {
|
|
4077
|
-
const { chains, getChainById: getChainById2 } =
|
|
4195
|
+
const { chains, getChainById: getChainById2 } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
4078
4196
|
const { isConnected, address } = wagmi.useAccount();
|
|
4079
4197
|
const [showSuccess, setShowSuccess] = react.useState(false);
|
|
4080
4198
|
const [showTimeout, setShowTimeout] = react.useState(false);
|
|
@@ -4088,7 +4206,7 @@ function WithdrawView({
|
|
|
4088
4206
|
tokenId: selectedToken?.id,
|
|
4089
4207
|
enabled: !!selectedToken
|
|
4090
4208
|
});
|
|
4091
|
-
const formattedBalance = selectedToken ?
|
|
4209
|
+
const formattedBalance = selectedToken ? chunk4IW4V7YJ_cjs.formatTokenAmount(balanceWei, selectedToken.decimals) : "0.00";
|
|
4092
4210
|
const { withdraw, isPending, currentStep, error, reset } = useWithdraw({
|
|
4093
4211
|
onProcessingSuccess: () => {
|
|
4094
4212
|
onAmountChange("");
|
|
@@ -4099,7 +4217,7 @@ function WithdrawView({
|
|
|
4099
4217
|
setShowTimeout(true);
|
|
4100
4218
|
}
|
|
4101
4219
|
});
|
|
4102
|
-
const explorerUrl = address && targetChain ?
|
|
4220
|
+
const explorerUrl = address && targetChain ? chunk4IW4V7YJ_cjs.getExplorerAddressUrl(targetChain.id, address) : void 0;
|
|
4103
4221
|
const getStepStatus = (step, after) => {
|
|
4104
4222
|
if (currentStep === step) return "active";
|
|
4105
4223
|
if (after.includes(currentStep)) return "completed";
|
|
@@ -4124,7 +4242,7 @@ function WithdrawView({
|
|
|
4124
4242
|
}, [isPending, cancelled, onPendingChange]);
|
|
4125
4243
|
const hasValidAmount = !!amount && parseFloat(amount) > 0;
|
|
4126
4244
|
const tooManyDecimals = !!hasValidAmount && !!selectedToken && amount.includes(".") && amount.split(".")[1].length > selectedToken.decimals;
|
|
4127
|
-
const exceedsBalance = !!hasValidAmount && !tooManyDecimals && !!selectedToken && !isBalanceLoading && !isBalanceError &&
|
|
4245
|
+
const exceedsBalance = !!hasValidAmount && !tooManyDecimals && !!selectedToken && !isBalanceLoading && !isBalanceError && chunk4IW4V7YJ_cjs.parseTokenAmount(amount, selectedToken.decimals) > BigInt(balanceWei);
|
|
4128
4246
|
const canWithdraw = isConnected && hasValidAmount && !!selectedToken && !tooManyDecimals && !exceedsBalance;
|
|
4129
4247
|
const handleMax = () => {
|
|
4130
4248
|
if (!selectedToken) return;
|
|
@@ -4136,7 +4254,7 @@ function WithdrawView({
|
|
|
4136
4254
|
setCancelled(false);
|
|
4137
4255
|
await withdraw({
|
|
4138
4256
|
tokenId: selectedToken.id,
|
|
4139
|
-
amount:
|
|
4257
|
+
amount: chunk4IW4V7YJ_cjs.parseTokenAmount(amount, selectedToken.decimals)
|
|
4140
4258
|
});
|
|
4141
4259
|
};
|
|
4142
4260
|
const handleCancel = () => {
|
|
@@ -4156,7 +4274,7 @@ function WithdrawView({
|
|
|
4156
4274
|
title: "Withdrawal Complete",
|
|
4157
4275
|
message: `Your ${selectedToken.symbol} withdrawal has been processed. Funds should appear in your wallet shortly.`,
|
|
4158
4276
|
explorerUrl,
|
|
4159
|
-
explorerLabel: targetChain ?
|
|
4277
|
+
explorerLabel: targetChain ? chunk4IW4V7YJ_cjs.getExplorerLabel(targetChain.id) : void 0,
|
|
4160
4278
|
onDone: handleDone
|
|
4161
4279
|
}
|
|
4162
4280
|
) });
|
|
@@ -4267,7 +4385,7 @@ function WithdrawModalContent({
|
|
|
4267
4385
|
onPendingChange,
|
|
4268
4386
|
onBack
|
|
4269
4387
|
}) {
|
|
4270
|
-
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig } =
|
|
4388
|
+
const { serviceName, enabledTokens, defaultToken, hostedAuthConfig } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
4271
4389
|
const { address } = wagmi.useAccount();
|
|
4272
4390
|
const appName = serviceName ?? "Privana";
|
|
4273
4391
|
const [view, setView] = react.useState("form");
|
|
@@ -4385,7 +4503,7 @@ function WithdrawInlineModal({ className }) {
|
|
|
4385
4503
|
"div",
|
|
4386
4504
|
{
|
|
4387
4505
|
"data-privana": true,
|
|
4388
|
-
className:
|
|
4506
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
4389
4507
|
"bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
4390
4508
|
className
|
|
4391
4509
|
),
|
|
@@ -4429,14 +4547,14 @@ function SegmentedBalanceBar({
|
|
|
4429
4547
|
showAvailable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4430
4548
|
"div",
|
|
4431
4549
|
{
|
|
4432
|
-
className:
|
|
4550
|
+
className: chunk4IW4V7YJ_cjs.cn(AVAILABLE_COLOR, "rounded-l-full", !showInUse && "rounded-r-full"),
|
|
4433
4551
|
style: { flexGrow: grow(availableWei) }
|
|
4434
4552
|
}
|
|
4435
4553
|
),
|
|
4436
4554
|
showInUse && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4437
4555
|
"div",
|
|
4438
4556
|
{
|
|
4439
|
-
className:
|
|
4557
|
+
className: chunk4IW4V7YJ_cjs.cn(IN_USE_COLOR, "rounded-r-full", !showAvailable && "rounded-l-full"),
|
|
4440
4558
|
style: { flexGrow: grow(inUseWei) }
|
|
4441
4559
|
}
|
|
4442
4560
|
)
|
|
@@ -4444,7 +4562,7 @@ function SegmentedBalanceBar({
|
|
|
4444
4562
|
}
|
|
4445
4563
|
function BalanceLegendItem({ color, label }) {
|
|
4446
4564
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
4447
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className:
|
|
4565
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: chunk4IW4V7YJ_cjs.cn("h-2.5 w-2.5 rounded-full", color) }),
|
|
4448
4566
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground text-sm leading-5", children: label })
|
|
4449
4567
|
] });
|
|
4450
4568
|
}
|
|
@@ -4457,7 +4575,7 @@ function WalletBalanceView({
|
|
|
4457
4575
|
onAddFunds,
|
|
4458
4576
|
onWithdraw
|
|
4459
4577
|
}) {
|
|
4460
|
-
const { serviceName, serviceIcon, defaultToken } =
|
|
4578
|
+
const { serviceName, serviceIcon, defaultToken } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
4461
4579
|
const appName = serviceName ?? "Privana";
|
|
4462
4580
|
const token = defaultToken;
|
|
4463
4581
|
const {
|
|
@@ -4470,14 +4588,14 @@ function WalletBalanceView({
|
|
|
4470
4588
|
const variant = !session ? "idle" : inUseWei === 0n ? "session-zero" : availableWei === 0n ? "fully-in-use" : "mixed";
|
|
4471
4589
|
const expiry = session?.expiry;
|
|
4472
4590
|
useNow(3e4, expiry != null);
|
|
4473
|
-
const countdown = expiry != null ?
|
|
4591
|
+
const countdown = expiry != null ? chunk4IW4V7YJ_cjs.formatTimeRemaining(expiry) : null;
|
|
4474
4592
|
const decimals = token?.decimals ?? 18;
|
|
4475
|
-
const totalFormatted =
|
|
4476
|
-
const availableFormatted =
|
|
4477
|
-
const inUseFormatted =
|
|
4593
|
+
const totalFormatted = chunk4IW4V7YJ_cjs.formatTokenAmount((availableWei + inUseWei).toString(), decimals);
|
|
4594
|
+
const availableFormatted = chunk4IW4V7YJ_cjs.formatTokenAmount(availableWei.toString(), decimals);
|
|
4595
|
+
const inUseFormatted = chunk4IW4V7YJ_cjs.formatTokenAmount(inUseWei.toString(), decimals);
|
|
4478
4596
|
const hasValidAmount = !!amount && parseFloat(amount) > 0;
|
|
4479
4597
|
const tooManyDecimals = hasValidAmount && !!token && amount.includes(".") && amount.split(".")[1].length > token.decimals;
|
|
4480
|
-
const exceedsBalance = hasValidAmount && !tooManyDecimals && !!token && !isBalanceLoading && !isBalanceError &&
|
|
4598
|
+
const exceedsBalance = hasValidAmount && !tooManyDecimals && !!token && !isBalanceLoading && !isBalanceError && chunk4IW4V7YJ_cjs.parseTokenAmount(amount, token.decimals) > availableWei;
|
|
4481
4599
|
const canPlay = hasValidAmount && !!token && !tooManyDecimals && !exceedsBalance && !isBalanceLoading && !isBalanceError;
|
|
4482
4600
|
const handleMax = () => {
|
|
4483
4601
|
const max = availableFormatted.replace(/\s/g, "");
|
|
@@ -4496,7 +4614,7 @@ function WalletBalanceView({
|
|
|
4496
4614
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm leading-[14px]", children: "Total" }),
|
|
4497
4615
|
/* @__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
4616
|
] }),
|
|
4499
|
-
isBalanceLoading ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4617
|
+
isBalanceLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunk4IW4V7YJ_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
4618
|
] }),
|
|
4501
4619
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
4502
4620
|
/* @__PURE__ */ jsxRuntime.jsx(SegmentedBalanceBar, { availableWei, inUseWei }),
|
|
@@ -4622,7 +4740,7 @@ function WalletModalContent({
|
|
|
4622
4740
|
onCloseBlockedChange,
|
|
4623
4741
|
...depositHandlers
|
|
4624
4742
|
}) {
|
|
4625
|
-
const { serviceName, hostedAuthConfig } =
|
|
4743
|
+
const { serviceName, hostedAuthConfig } = chunk4IW4V7YJ_cjs.usePrivanaContext();
|
|
4626
4744
|
const { address } = wagmi.useAccount();
|
|
4627
4745
|
const appName = serviceName ?? "Privana";
|
|
4628
4746
|
const [view, setView] = react.useState("balance");
|
|
@@ -4694,7 +4812,7 @@ function WalletModalContent({
|
|
|
4694
4812
|
onClick: onClose,
|
|
4695
4813
|
disabled: closeBlocked,
|
|
4696
4814
|
"aria-label": "Close",
|
|
4697
|
-
className:
|
|
4815
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
4698
4816
|
"absolute top-6 right-5 z-20 flex h-5 w-5 items-center justify-center transition-colors",
|
|
4699
4817
|
closeBlocked ? "text-muted-foreground/40 cursor-not-allowed" : "text-muted-foreground hover:text-foreground cursor-pointer"
|
|
4700
4818
|
),
|
|
@@ -4792,7 +4910,7 @@ function WalletInlineModal({ className, ...handlers }) {
|
|
|
4792
4910
|
"div",
|
|
4793
4911
|
{
|
|
4794
4912
|
"data-privana": true,
|
|
4795
|
-
className:
|
|
4913
|
+
className: chunk4IW4V7YJ_cjs.cn(
|
|
4796
4914
|
"bg-card relative flex w-[560px] max-w-full flex-col gap-2 overflow-hidden rounded-2xl p-2 shadow-lg",
|
|
4797
4915
|
className
|
|
4798
4916
|
),
|
|
@@ -4803,214 +4921,300 @@ function WalletInlineModal({ className, ...handlers }) {
|
|
|
4803
4921
|
|
|
4804
4922
|
Object.defineProperty(exports, "AccountingApiError", {
|
|
4805
4923
|
enumerable: true,
|
|
4806
|
-
get: function () { return
|
|
4924
|
+
get: function () { return chunk4IW4V7YJ_cjs.AccountingApiError; }
|
|
4807
4925
|
});
|
|
4808
4926
|
Object.defineProperty(exports, "Button", {
|
|
4809
4927
|
enumerable: true,
|
|
4810
|
-
get: function () { return
|
|
4928
|
+
get: function () { return chunk4IW4V7YJ_cjs.Button; }
|
|
4929
|
+
});
|
|
4930
|
+
Object.defineProperty(exports, "DEFAULT_LOCK_DURATION_SECONDS", {
|
|
4931
|
+
enumerable: true,
|
|
4932
|
+
get: function () { return chunk4IW4V7YJ_cjs.DEFAULT_LOCK_DURATION_SECONDS; }
|
|
4933
|
+
});
|
|
4934
|
+
Object.defineProperty(exports, "DEFAULT_ONRAMP_LOCK_BUFFER", {
|
|
4935
|
+
enumerable: true,
|
|
4936
|
+
get: function () { return chunk4IW4V7YJ_cjs.DEFAULT_ONRAMP_LOCK_BUFFER; }
|
|
4811
4937
|
});
|
|
4812
4938
|
Object.defineProperty(exports, "HOSTED_AUTH_CLOCK_SKEW_MS", {
|
|
4813
4939
|
enumerable: true,
|
|
4814
|
-
get: function () { return
|
|
4940
|
+
get: function () { return chunk4IW4V7YJ_cjs.HOSTED_AUTH_CLOCK_SKEW_MS; }
|
|
4815
4941
|
});
|
|
4816
4942
|
Object.defineProperty(exports, "HostedAuthError", {
|
|
4817
4943
|
enumerable: true,
|
|
4818
|
-
get: function () { return
|
|
4944
|
+
get: function () { return chunk4IW4V7YJ_cjs.HostedAuthError; }
|
|
4819
4945
|
});
|
|
4820
4946
|
Object.defineProperty(exports, "HostedAuthRequiredError", {
|
|
4821
4947
|
enumerable: true,
|
|
4822
|
-
get: function () { return
|
|
4948
|
+
get: function () { return chunk4IW4V7YJ_cjs.HostedAuthRequiredError; }
|
|
4823
4949
|
});
|
|
4824
4950
|
Object.defineProperty(exports, "HostedAuthStateMismatchError", {
|
|
4825
4951
|
enumerable: true,
|
|
4826
|
-
get: function () { return
|
|
4952
|
+
get: function () { return chunk4IW4V7YJ_cjs.HostedAuthStateMismatchError; }
|
|
4827
4953
|
});
|
|
4828
4954
|
Object.defineProperty(exports, "HttpClient", {
|
|
4829
4955
|
enumerable: true,
|
|
4830
|
-
get: function () { return
|
|
4956
|
+
get: function () { return chunk4IW4V7YJ_cjs.HttpClient; }
|
|
4957
|
+
});
|
|
4958
|
+
Object.defineProperty(exports, "LOCK_TYPES", {
|
|
4959
|
+
enumerable: true,
|
|
4960
|
+
get: function () { return chunk4IW4V7YJ_cjs.LOCK_TYPES; }
|
|
4961
|
+
});
|
|
4962
|
+
Object.defineProperty(exports, "MODIFY_LOCK_TYPES", {
|
|
4963
|
+
enumerable: true,
|
|
4964
|
+
get: function () { return chunk4IW4V7YJ_cjs.MODIFY_LOCK_TYPES; }
|
|
4831
4965
|
});
|
|
4832
4966
|
Object.defineProperty(exports, "NETWORK_CONFIG", {
|
|
4833
4967
|
enumerable: true,
|
|
4834
|
-
get: function () { return
|
|
4968
|
+
get: function () { return chunk4IW4V7YJ_cjs.NETWORK_CONFIG; }
|
|
4835
4969
|
});
|
|
4836
4970
|
Object.defineProperty(exports, "NetworkError", {
|
|
4837
4971
|
enumerable: true,
|
|
4838
|
-
get: function () { return
|
|
4972
|
+
get: function () { return chunk4IW4V7YJ_cjs.NetworkError; }
|
|
4973
|
+
});
|
|
4974
|
+
Object.defineProperty(exports, "PostDepositLockError", {
|
|
4975
|
+
enumerable: true,
|
|
4976
|
+
get: function () { return chunk4IW4V7YJ_cjs.PostDepositLockError; }
|
|
4839
4977
|
});
|
|
4840
4978
|
Object.defineProperty(exports, "PrivanaClient", {
|
|
4841
4979
|
enumerable: true,
|
|
4842
|
-
get: function () { return
|
|
4980
|
+
get: function () { return chunk4IW4V7YJ_cjs.PrivanaClient; }
|
|
4843
4981
|
});
|
|
4844
4982
|
Object.defineProperty(exports, "PrivanaProvider", {
|
|
4845
4983
|
enumerable: true,
|
|
4846
|
-
get: function () { return
|
|
4984
|
+
get: function () { return chunk4IW4V7YJ_cjs.PrivanaProvider; }
|
|
4847
4985
|
});
|
|
4848
4986
|
Object.defineProperty(exports, "SUPPORTED_CHAINS", {
|
|
4849
4987
|
enumerable: true,
|
|
4850
|
-
get: function () { return
|
|
4988
|
+
get: function () { return chunk4IW4V7YJ_cjs.SUPPORTED_CHAINS; }
|
|
4851
4989
|
});
|
|
4852
4990
|
Object.defineProperty(exports, "SiweAuthProvider", {
|
|
4853
4991
|
enumerable: true,
|
|
4854
|
-
get: function () { return
|
|
4992
|
+
get: function () { return chunk4IW4V7YJ_cjs.SiweAuthProvider; }
|
|
4855
4993
|
});
|
|
4856
4994
|
Object.defineProperty(exports, "Skeleton", {
|
|
4857
4995
|
enumerable: true,
|
|
4858
|
-
get: function () { return
|
|
4996
|
+
get: function () { return chunk4IW4V7YJ_cjs.Skeleton; }
|
|
4997
|
+
});
|
|
4998
|
+
Object.defineProperty(exports, "TRANSFER_LOCKED_TYPES", {
|
|
4999
|
+
enumerable: true,
|
|
5000
|
+
get: function () { return chunk4IW4V7YJ_cjs.TRANSFER_LOCKED_TYPES; }
|
|
5001
|
+
});
|
|
5002
|
+
Object.defineProperty(exports, "TRANSFER_TYPES", {
|
|
5003
|
+
enumerable: true,
|
|
5004
|
+
get: function () { return chunk4IW4V7YJ_cjs.TRANSFER_TYPES; }
|
|
4859
5005
|
});
|
|
4860
5006
|
Object.defineProperty(exports, "ValidationError", {
|
|
4861
5007
|
enumerable: true,
|
|
4862
|
-
get: function () { return
|
|
5008
|
+
get: function () { return chunk4IW4V7YJ_cjs.ValidationError; }
|
|
5009
|
+
});
|
|
5010
|
+
Object.defineProperty(exports, "WITHDRAW_FROM_LOCK_TYPES", {
|
|
5011
|
+
enumerable: true,
|
|
5012
|
+
get: function () { return chunk4IW4V7YJ_cjs.WITHDRAW_FROM_LOCK_TYPES; }
|
|
5013
|
+
});
|
|
5014
|
+
Object.defineProperty(exports, "WITHDRAW_TYPES", {
|
|
5015
|
+
enumerable: true,
|
|
5016
|
+
get: function () { return chunk4IW4V7YJ_cjs.WITHDRAW_TYPES; }
|
|
5017
|
+
});
|
|
5018
|
+
Object.defineProperty(exports, "applyLockBuffer", {
|
|
5019
|
+
enumerable: true,
|
|
5020
|
+
get: function () { return chunk4IW4V7YJ_cjs.applyLockBuffer; }
|
|
4863
5021
|
});
|
|
4864
5022
|
Object.defineProperty(exports, "applyRefreshResponse", {
|
|
4865
5023
|
enumerable: true,
|
|
4866
|
-
get: function () { return
|
|
5024
|
+
get: function () { return chunk4IW4V7YJ_cjs.applyRefreshResponse; }
|
|
4867
5025
|
});
|
|
4868
5026
|
Object.defineProperty(exports, "buildHostedAuthSession", {
|
|
4869
5027
|
enumerable: true,
|
|
4870
|
-
get: function () { return
|
|
5028
|
+
get: function () { return chunk4IW4V7YJ_cjs.buildHostedAuthSession; }
|
|
4871
5029
|
});
|
|
4872
5030
|
Object.defineProperty(exports, "buildSiweStatement", {
|
|
4873
5031
|
enumerable: true,
|
|
4874
|
-
get: function () { return
|
|
5032
|
+
get: function () { return chunk4IW4V7YJ_cjs.buildSiweStatement; }
|
|
4875
5033
|
});
|
|
4876
5034
|
Object.defineProperty(exports, "buttonVariants", {
|
|
4877
5035
|
enumerable: true,
|
|
4878
|
-
get: function () { return
|
|
5036
|
+
get: function () { return chunk4IW4V7YJ_cjs.buttonVariants; }
|
|
5037
|
+
});
|
|
5038
|
+
Object.defineProperty(exports, "clampLockAmount", {
|
|
5039
|
+
enumerable: true,
|
|
5040
|
+
get: function () { return chunk4IW4V7YJ_cjs.clampLockAmount; }
|
|
4879
5041
|
});
|
|
4880
5042
|
Object.defineProperty(exports, "clearHostedAuthPendingTransaction", {
|
|
4881
5043
|
enumerable: true,
|
|
4882
|
-
get: function () { return
|
|
5044
|
+
get: function () { return chunk4IW4V7YJ_cjs.clearHostedAuthPendingTransaction; }
|
|
5045
|
+
});
|
|
5046
|
+
Object.defineProperty(exports, "clearPendingLock", {
|
|
5047
|
+
enumerable: true,
|
|
5048
|
+
get: function () { return chunk4IW4V7YJ_cjs.clearPendingLock; }
|
|
5049
|
+
});
|
|
5050
|
+
Object.defineProperty(exports, "createDomain", {
|
|
5051
|
+
enumerable: true,
|
|
5052
|
+
get: function () { return chunk4IW4V7YJ_cjs.createDomain; }
|
|
4883
5053
|
});
|
|
4884
5054
|
Object.defineProperty(exports, "createHostedAuthPendingStorageKey", {
|
|
4885
5055
|
enumerable: true,
|
|
4886
|
-
get: function () { return
|
|
5056
|
+
get: function () { return chunk4IW4V7YJ_cjs.createHostedAuthPendingStorageKey; }
|
|
4887
5057
|
});
|
|
4888
5058
|
Object.defineProperty(exports, "createHostedAuthState", {
|
|
4889
5059
|
enumerable: true,
|
|
4890
|
-
get: function () { return
|
|
5060
|
+
get: function () { return chunk4IW4V7YJ_cjs.createHostedAuthState; }
|
|
4891
5061
|
});
|
|
4892
5062
|
Object.defineProperty(exports, "createHostedAuthStorageKey", {
|
|
4893
5063
|
enumerable: true,
|
|
4894
|
-
get: function () { return
|
|
5064
|
+
get: function () { return chunk4IW4V7YJ_cjs.createHostedAuthStorageKey; }
|
|
5065
|
+
});
|
|
5066
|
+
Object.defineProperty(exports, "createLockExpiry", {
|
|
5067
|
+
enumerable: true,
|
|
5068
|
+
get: function () { return chunk4IW4V7YJ_cjs.createLockExpiry; }
|
|
4895
5069
|
});
|
|
4896
5070
|
Object.defineProperty(exports, "createPkceChallenge", {
|
|
4897
5071
|
enumerable: true,
|
|
4898
|
-
get: function () { return
|
|
5072
|
+
get: function () { return chunk4IW4V7YJ_cjs.createPkceChallenge; }
|
|
4899
5073
|
});
|
|
4900
5074
|
Object.defineProperty(exports, "createPkceVerifier", {
|
|
4901
5075
|
enumerable: true,
|
|
4902
|
-
get: function () { return
|
|
5076
|
+
get: function () { return chunk4IW4V7YJ_cjs.createPkceVerifier; }
|
|
5077
|
+
});
|
|
5078
|
+
Object.defineProperty(exports, "createSignedLockRequest", {
|
|
5079
|
+
enumerable: true,
|
|
5080
|
+
get: function () { return chunk4IW4V7YJ_cjs.createSignedLockRequest; }
|
|
4903
5081
|
});
|
|
4904
5082
|
Object.defineProperty(exports, "getAccountingContract", {
|
|
4905
5083
|
enumerable: true,
|
|
4906
|
-
get: function () { return
|
|
5084
|
+
get: function () { return chunk4IW4V7YJ_cjs.getAccountingContract; }
|
|
4907
5085
|
});
|
|
4908
5086
|
Object.defineProperty(exports, "getApiUrl", {
|
|
4909
5087
|
enumerable: true,
|
|
4910
|
-
get: function () { return
|
|
5088
|
+
get: function () { return chunk4IW4V7YJ_cjs.getApiUrl; }
|
|
4911
5089
|
});
|
|
4912
5090
|
Object.defineProperty(exports, "getChainById", {
|
|
4913
5091
|
enumerable: true,
|
|
4914
|
-
get: function () { return
|
|
5092
|
+
get: function () { return chunk4IW4V7YJ_cjs.getChainById; }
|
|
4915
5093
|
});
|
|
4916
5094
|
Object.defineProperty(exports, "getChainId", {
|
|
4917
5095
|
enumerable: true,
|
|
4918
|
-
get: function () { return
|
|
5096
|
+
get: function () { return chunk4IW4V7YJ_cjs.getChainId; }
|
|
4919
5097
|
});
|
|
4920
5098
|
Object.defineProperty(exports, "getExplorerAddressUrl", {
|
|
4921
5099
|
enumerable: true,
|
|
4922
|
-
get: function () { return
|
|
5100
|
+
get: function () { return chunk4IW4V7YJ_cjs.getExplorerAddressUrl; }
|
|
4923
5101
|
});
|
|
4924
5102
|
Object.defineProperty(exports, "getExplorerLabel", {
|
|
4925
5103
|
enumerable: true,
|
|
4926
|
-
get: function () { return
|
|
5104
|
+
get: function () { return chunk4IW4V7YJ_cjs.getExplorerLabel; }
|
|
4927
5105
|
});
|
|
4928
5106
|
Object.defineProperty(exports, "isHostedAuthRefreshActive", {
|
|
4929
5107
|
enumerable: true,
|
|
4930
|
-
get: function () { return
|
|
5108
|
+
get: function () { return chunk4IW4V7YJ_cjs.isHostedAuthRefreshActive; }
|
|
4931
5109
|
});
|
|
4932
5110
|
Object.defineProperty(exports, "isHostedAuthSessionActive", {
|
|
4933
5111
|
enumerable: true,
|
|
4934
|
-
get: function () { return
|
|
5112
|
+
get: function () { return chunk4IW4V7YJ_cjs.isHostedAuthSessionActive; }
|
|
5113
|
+
});
|
|
5114
|
+
Object.defineProperty(exports, "isSignedLockUsable", {
|
|
5115
|
+
enumerable: true,
|
|
5116
|
+
get: function () { return chunk4IW4V7YJ_cjs.isSignedLockUsable; }
|
|
5117
|
+
});
|
|
5118
|
+
Object.defineProperty(exports, "loadPendingLock", {
|
|
5119
|
+
enumerable: true,
|
|
5120
|
+
get: function () { return chunk4IW4V7YJ_cjs.loadPendingLock; }
|
|
4935
5121
|
});
|
|
4936
5122
|
Object.defineProperty(exports, "normalizeAddress", {
|
|
4937
5123
|
enumerable: true,
|
|
4938
|
-
get: function () { return
|
|
5124
|
+
get: function () { return chunk4IW4V7YJ_cjs.normalizeAddress; }
|
|
4939
5125
|
});
|
|
4940
5126
|
Object.defineProperty(exports, "normalizeHex", {
|
|
4941
5127
|
enumerable: true,
|
|
4942
|
-
get: function () { return
|
|
5128
|
+
get: function () { return chunk4IW4V7YJ_cjs.normalizeHex; }
|
|
4943
5129
|
});
|
|
4944
5130
|
Object.defineProperty(exports, "parseHostedAuthCallback", {
|
|
4945
5131
|
enumerable: true,
|
|
4946
|
-
get: function () { return
|
|
5132
|
+
get: function () { return chunk4IW4V7YJ_cjs.parseHostedAuthCallback; }
|
|
4947
5133
|
});
|
|
4948
5134
|
Object.defineProperty(exports, "persistHostedAuthPendingTransaction", {
|
|
4949
5135
|
enumerable: true,
|
|
4950
|
-
get: function () { return
|
|
5136
|
+
get: function () { return chunk4IW4V7YJ_cjs.persistHostedAuthPendingTransaction; }
|
|
4951
5137
|
});
|
|
4952
5138
|
Object.defineProperty(exports, "readHostedAuthPendingTransaction", {
|
|
4953
5139
|
enumerable: true,
|
|
4954
|
-
get: function () { return
|
|
5140
|
+
get: function () { return chunk4IW4V7YJ_cjs.readHostedAuthPendingTransaction; }
|
|
4955
5141
|
});
|
|
4956
5142
|
Object.defineProperty(exports, "readStoredHostedAuthSession", {
|
|
4957
5143
|
enumerable: true,
|
|
4958
|
-
get: function () { return
|
|
5144
|
+
get: function () { return chunk4IW4V7YJ_cjs.readStoredHostedAuthSession; }
|
|
5145
|
+
});
|
|
5146
|
+
Object.defineProperty(exports, "savePendingLock", {
|
|
5147
|
+
enumerable: true,
|
|
5148
|
+
get: function () { return chunk4IW4V7YJ_cjs.savePendingLock; }
|
|
5149
|
+
});
|
|
5150
|
+
Object.defineProperty(exports, "signLockMessage", {
|
|
5151
|
+
enumerable: true,
|
|
5152
|
+
get: function () { return chunk4IW4V7YJ_cjs.signLockMessage; }
|
|
5153
|
+
});
|
|
5154
|
+
Object.defineProperty(exports, "signModifyLockMessage", {
|
|
5155
|
+
enumerable: true,
|
|
5156
|
+
get: function () { return chunk4IW4V7YJ_cjs.signModifyLockMessage; }
|
|
5157
|
+
});
|
|
5158
|
+
Object.defineProperty(exports, "signTransferLockedMessage", {
|
|
5159
|
+
enumerable: true,
|
|
5160
|
+
get: function () { return chunk4IW4V7YJ_cjs.signTransferLockedMessage; }
|
|
5161
|
+
});
|
|
5162
|
+
Object.defineProperty(exports, "signTransferMessage", {
|
|
5163
|
+
enumerable: true,
|
|
5164
|
+
get: function () { return chunk4IW4V7YJ_cjs.signTransferMessage; }
|
|
5165
|
+
});
|
|
5166
|
+
Object.defineProperty(exports, "signWithdrawFromLockMessage", {
|
|
5167
|
+
enumerable: true,
|
|
5168
|
+
get: function () { return chunk4IW4V7YJ_cjs.signWithdrawFromLockMessage; }
|
|
5169
|
+
});
|
|
5170
|
+
Object.defineProperty(exports, "signWithdrawMessage", {
|
|
5171
|
+
enumerable: true,
|
|
5172
|
+
get: function () { return chunk4IW4V7YJ_cjs.signWithdrawMessage; }
|
|
4959
5173
|
});
|
|
4960
5174
|
Object.defineProperty(exports, "stripHostedAuthCallbackParams", {
|
|
4961
5175
|
enumerable: true,
|
|
4962
|
-
get: function () { return
|
|
5176
|
+
get: function () { return chunk4IW4V7YJ_cjs.stripHostedAuthCallbackParams; }
|
|
5177
|
+
});
|
|
5178
|
+
Object.defineProperty(exports, "submitPendingLock", {
|
|
5179
|
+
enumerable: true,
|
|
5180
|
+
get: function () { return chunk4IW4V7YJ_cjs.submitPendingLock; }
|
|
4963
5181
|
});
|
|
4964
5182
|
Object.defineProperty(exports, "syncHostedAuthSessionToClient", {
|
|
4965
5183
|
enumerable: true,
|
|
4966
|
-
get: function () { return
|
|
5184
|
+
get: function () { return chunk4IW4V7YJ_cjs.syncHostedAuthSessionToClient; }
|
|
4967
5185
|
});
|
|
4968
5186
|
Object.defineProperty(exports, "useDepositVerification", {
|
|
4969
5187
|
enumerable: true,
|
|
4970
|
-
get: function () { return
|
|
5188
|
+
get: function () { return chunk4IW4V7YJ_cjs.useDepositVerification; }
|
|
4971
5189
|
});
|
|
4972
5190
|
Object.defineProperty(exports, "usePrivanaContext", {
|
|
4973
5191
|
enumerable: true,
|
|
4974
|
-
get: function () { return
|
|
5192
|
+
get: function () { return chunk4IW4V7YJ_cjs.usePrivanaContext; }
|
|
4975
5193
|
});
|
|
4976
5194
|
Object.defineProperty(exports, "useSafeAccount", {
|
|
4977
5195
|
enumerable: true,
|
|
4978
|
-
get: function () { return
|
|
5196
|
+
get: function () { return chunk4IW4V7YJ_cjs.useSafeAccount; }
|
|
4979
5197
|
});
|
|
4980
5198
|
Object.defineProperty(exports, "useSafePrivanaContext", {
|
|
4981
5199
|
enumerable: true,
|
|
4982
|
-
get: function () { return
|
|
5200
|
+
get: function () { return chunk4IW4V7YJ_cjs.useSafePrivanaContext; }
|
|
4983
5201
|
});
|
|
4984
5202
|
Object.defineProperty(exports, "useSiweAuth", {
|
|
4985
5203
|
enumerable: true,
|
|
4986
|
-
get: function () { return
|
|
5204
|
+
get: function () { return chunk4IW4V7YJ_cjs.useSiweAuth; }
|
|
4987
5205
|
});
|
|
4988
5206
|
exports.DepositInlineModal = DepositInlineModal;
|
|
4989
5207
|
exports.DepositModal = DepositModal;
|
|
4990
|
-
exports.LOCK_TYPES = LOCK_TYPES;
|
|
4991
|
-
exports.MODIFY_LOCK_TYPES = MODIFY_LOCK_TYPES;
|
|
4992
5208
|
exports.PrivanaButton = PrivanaButton;
|
|
4993
5209
|
exports.PrivanaIcon = PrivanaIcon;
|
|
4994
5210
|
exports.PrivanaInlineModal = PrivanaInlineModal;
|
|
4995
5211
|
exports.PrivanaModal = PrivanaModal;
|
|
4996
|
-
exports.TRANSFER_LOCKED_TYPES = TRANSFER_LOCKED_TYPES;
|
|
4997
|
-
exports.TRANSFER_TYPES = TRANSFER_TYPES;
|
|
4998
|
-
exports.WITHDRAW_FROM_LOCK_TYPES = WITHDRAW_FROM_LOCK_TYPES;
|
|
4999
|
-
exports.WITHDRAW_TYPES = WITHDRAW_TYPES;
|
|
5000
5212
|
exports.WalletInlineModal = WalletInlineModal;
|
|
5001
5213
|
exports.WalletModal = WalletModal;
|
|
5002
5214
|
exports.WithdrawInlineModal = WithdrawInlineModal;
|
|
5003
5215
|
exports.WithdrawModal = WithdrawModal;
|
|
5004
|
-
exports.createDomain = createDomain;
|
|
5005
|
-
exports.createLockExpiry = createLockExpiry;
|
|
5006
5216
|
exports.getChainIcon = getChainIcon;
|
|
5007
5217
|
exports.getTokenIcon = getTokenIcon;
|
|
5008
|
-
exports.signLockMessage = signLockMessage;
|
|
5009
|
-
exports.signModifyLockMessage = signModifyLockMessage;
|
|
5010
|
-
exports.signTransferLockedMessage = signTransferLockedMessage;
|
|
5011
|
-
exports.signTransferMessage = signTransferMessage;
|
|
5012
|
-
exports.signWithdrawFromLockMessage = signWithdrawFromLockMessage;
|
|
5013
|
-
exports.signWithdrawMessage = signWithdrawMessage;
|
|
5014
5218
|
exports.useBalance = useBalance;
|
|
5015
5219
|
exports.useBatchBalances = useBatchBalances;
|
|
5016
5220
|
exports.useDeposit = useDeposit;
|
|
@@ -5021,6 +5225,7 @@ exports.useHostedRedirectAuth = useHostedRedirectAuth;
|
|
|
5021
5225
|
exports.useLockFunds = useLockFunds;
|
|
5022
5226
|
exports.useLockedFunds = useLockedFunds;
|
|
5023
5227
|
exports.useModifyLock = useModifyLock;
|
|
5228
|
+
exports.usePendingDeposits = usePendingDeposits;
|
|
5024
5229
|
exports.usePendingWithdrawals = usePendingWithdrawals;
|
|
5025
5230
|
exports.usePrivanaClient = usePrivanaClient;
|
|
5026
5231
|
exports.useTokenInfo = useTokenInfo;
|