@diviswap/sdk 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +73 -82
- package/bin/create-diviswap-app.js +5 -5
- package/dist/cli/index.js +442 -185
- package/dist/cli/templates/nextjs-app/api-route.ts.hbs +8 -52
- package/dist/cli/templates/nextjs-app/types.ts.hbs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +333 -215
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +333 -215
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +260 -183
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +260 -183
- package/dist/react/index.mjs.map +1 -1
- package/dist/{wallet-DZymADRo.d.mts → wallet-Cohx6L51.d.mts} +12 -24
- package/dist/{wallet-DZymADRo.d.ts → wallet-Cohx6L51.d.ts} +12 -24
- package/package.json +98 -97
- package/src/cli/templates/index.ts +86 -54
- package/src/cli/templates/nextjs-app/api-route.ts.hbs +8 -52
- package/src/cli/templates/nextjs-app/types.ts.hbs +1 -1
- package/src/cli/templates/shared/client.ts +65 -65
package/dist/react/index.mjs
CHANGED
|
@@ -2,9 +2,7 @@ import React, { createContext, useState, useEffect, useContext, useCallback } fr
|
|
|
2
2
|
|
|
3
3
|
// src/react/provider.tsx
|
|
4
4
|
var DiviswapContext = createContext(null);
|
|
5
|
-
function DiviswapProvider({
|
|
6
|
-
children
|
|
7
|
-
}) {
|
|
5
|
+
function DiviswapProvider({ children }) {
|
|
8
6
|
const [user, setUser] = useState(null);
|
|
9
7
|
const [loading, setLoading] = useState(false);
|
|
10
8
|
const [error, setError] = useState(null);
|
|
@@ -94,7 +92,10 @@ function DiviswapProvider({
|
|
|
94
92
|
return response.json();
|
|
95
93
|
};
|
|
96
94
|
const getTransactions = async (filters) => {
|
|
97
|
-
const params = new URLSearchParams({
|
|
95
|
+
const params = new URLSearchParams({
|
|
96
|
+
resource: "transactions",
|
|
97
|
+
...filters
|
|
98
|
+
});
|
|
98
99
|
const response = await fetch(`/api/diviswap?${params}`);
|
|
99
100
|
if (!response.ok) {
|
|
100
101
|
throw new Error("Failed to fetch transactions");
|
|
@@ -210,8 +211,10 @@ function DiviswapFarcasterProvider({
|
|
|
210
211
|
};
|
|
211
212
|
const checkSession = async (token) => {
|
|
212
213
|
try {
|
|
213
|
-
const headers = token ? {
|
|
214
|
-
const response = await fetch("/api/diviswap?resource=session", {
|
|
214
|
+
const headers = token ? { Authorization: `Bearer ${token}` } : {};
|
|
215
|
+
const response = await fetch("/api/diviswap?resource=session", {
|
|
216
|
+
headers
|
|
217
|
+
});
|
|
215
218
|
if (response.ok) {
|
|
216
219
|
const userData = await response.json();
|
|
217
220
|
if (userData) {
|
|
@@ -293,7 +296,11 @@ function DiviswapFarcasterProvider({
|
|
|
293
296
|
const response = await fetch("/api/diviswap", {
|
|
294
297
|
method: "POST",
|
|
295
298
|
headers: getAuthHeaders(),
|
|
296
|
-
body: JSON.stringify({
|
|
299
|
+
body: JSON.stringify({
|
|
300
|
+
action: "createTransaction",
|
|
301
|
+
sessionToken,
|
|
302
|
+
...data
|
|
303
|
+
})
|
|
297
304
|
});
|
|
298
305
|
if (!response.ok) {
|
|
299
306
|
throw new Error("Transaction creation failed");
|
|
@@ -307,7 +314,7 @@ function DiviswapFarcasterProvider({
|
|
|
307
314
|
...filters
|
|
308
315
|
});
|
|
309
316
|
const response = await fetch(`/api/diviswap?${params}`, {
|
|
310
|
-
headers: sessionToken ? {
|
|
317
|
+
headers: sessionToken ? { Authorization: `Bearer ${sessionToken}` } : {}
|
|
311
318
|
});
|
|
312
319
|
if (!response.ok) {
|
|
313
320
|
throw new Error("Failed to fetch transactions");
|
|
@@ -318,7 +325,11 @@ function DiviswapFarcasterProvider({
|
|
|
318
325
|
const response = await fetch("/api/diviswap", {
|
|
319
326
|
method: "POST",
|
|
320
327
|
headers: getAuthHeaders(),
|
|
321
|
-
body: JSON.stringify({
|
|
328
|
+
body: JSON.stringify({
|
|
329
|
+
action: "createPayee",
|
|
330
|
+
sessionToken,
|
|
331
|
+
...data
|
|
332
|
+
})
|
|
322
333
|
});
|
|
323
334
|
if (!response.ok) {
|
|
324
335
|
throw new Error("Payee creation failed");
|
|
@@ -331,7 +342,7 @@ function DiviswapFarcasterProvider({
|
|
|
331
342
|
params.append("sessionToken", sessionToken);
|
|
332
343
|
}
|
|
333
344
|
const response = await fetch(`/api/diviswap?${params}`, {
|
|
334
|
-
headers: sessionToken ? {
|
|
345
|
+
headers: sessionToken ? { Authorization: `Bearer ${sessionToken}` } : {}
|
|
335
346
|
});
|
|
336
347
|
if (!response.ok) {
|
|
337
348
|
throw new Error("Failed to fetch payees");
|
|
@@ -346,7 +357,7 @@ function DiviswapFarcasterProvider({
|
|
|
346
357
|
});
|
|
347
358
|
const response = await fetch(`/api/diviswap?${params}`, {
|
|
348
359
|
method: "DELETE",
|
|
349
|
-
headers: sessionToken ? {
|
|
360
|
+
headers: sessionToken ? { Authorization: `Bearer ${sessionToken}` } : {}
|
|
350
361
|
});
|
|
351
362
|
if (!response.ok) {
|
|
352
363
|
throw new Error("Failed to delete payee");
|
|
@@ -356,7 +367,11 @@ function DiviswapFarcasterProvider({
|
|
|
356
367
|
const response = await fetch("/api/diviswap", {
|
|
357
368
|
method: "POST",
|
|
358
369
|
headers: getAuthHeaders(),
|
|
359
|
-
body: JSON.stringify({
|
|
370
|
+
body: JSON.stringify({
|
|
371
|
+
action: "calculateFees",
|
|
372
|
+
sessionToken,
|
|
373
|
+
amount
|
|
374
|
+
})
|
|
360
375
|
});
|
|
361
376
|
if (!response.ok) {
|
|
362
377
|
throw new Error("Fee calculation failed");
|
|
@@ -410,32 +425,38 @@ function useTransactions() {
|
|
|
410
425
|
const { createTransaction, getTransactions, error } = useDiviswap();
|
|
411
426
|
const [transactions, setTransactions] = useState([]);
|
|
412
427
|
const [loading, setLoading] = useState(false);
|
|
413
|
-
const fetchTransactions = useCallback(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
428
|
+
const fetchTransactions = useCallback(
|
|
429
|
+
async (filters) => {
|
|
430
|
+
setLoading(true);
|
|
431
|
+
try {
|
|
432
|
+
const data = await getTransactions(filters);
|
|
433
|
+
setTransactions(data);
|
|
434
|
+
return data;
|
|
435
|
+
} catch (err) {
|
|
436
|
+
console.error("Failed to fetch transactions:", err);
|
|
437
|
+
throw err;
|
|
438
|
+
} finally {
|
|
439
|
+
setLoading(false);
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
[getTransactions]
|
|
443
|
+
);
|
|
444
|
+
const create = useCallback(
|
|
445
|
+
async (data) => {
|
|
446
|
+
setLoading(true);
|
|
447
|
+
try {
|
|
448
|
+
const transaction = await createTransaction(data);
|
|
449
|
+
await fetchTransactions();
|
|
450
|
+
return transaction;
|
|
451
|
+
} catch (err) {
|
|
452
|
+
console.error("Failed to create transaction:", err);
|
|
453
|
+
throw err;
|
|
454
|
+
} finally {
|
|
455
|
+
setLoading(false);
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
[createTransaction, fetchTransactions]
|
|
459
|
+
);
|
|
439
460
|
return {
|
|
440
461
|
transactions,
|
|
441
462
|
loading,
|
|
@@ -462,31 +483,37 @@ function usePayees() {
|
|
|
462
483
|
setLoading(false);
|
|
463
484
|
}
|
|
464
485
|
}, [getPayees]);
|
|
465
|
-
const create = useCallback(
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
486
|
+
const create = useCallback(
|
|
487
|
+
async (data) => {
|
|
488
|
+
setLoading(true);
|
|
489
|
+
try {
|
|
490
|
+
const payee = await createPayee(data);
|
|
491
|
+
await fetchPayees();
|
|
492
|
+
return payee;
|
|
493
|
+
} catch (err) {
|
|
494
|
+
console.error("Failed to create payee:", err);
|
|
495
|
+
throw err;
|
|
496
|
+
} finally {
|
|
497
|
+
setLoading(false);
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
[createPayee, fetchPayees]
|
|
501
|
+
);
|
|
502
|
+
const remove = useCallback(
|
|
503
|
+
async (id) => {
|
|
504
|
+
setLoading(true);
|
|
505
|
+
try {
|
|
506
|
+
await deletePayee(id);
|
|
507
|
+
await fetchPayees();
|
|
508
|
+
} catch (err) {
|
|
509
|
+
console.error("Failed to delete payee:", err);
|
|
510
|
+
throw err;
|
|
511
|
+
} finally {
|
|
512
|
+
setLoading(false);
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
[deletePayee, fetchPayees]
|
|
516
|
+
);
|
|
490
517
|
useEffect(() => {
|
|
491
518
|
fetchPayees();
|
|
492
519
|
}, [fetchPayees]);
|
|
@@ -509,8 +536,10 @@ function useKYCStatus(options) {
|
|
|
509
536
|
setLoading(true);
|
|
510
537
|
setError(null);
|
|
511
538
|
const params = new URLSearchParams({ resource: "kycStatus" });
|
|
512
|
-
if (options?.customerId)
|
|
513
|
-
|
|
539
|
+
if (options?.customerId)
|
|
540
|
+
params.set("customerId", options.customerId);
|
|
541
|
+
if (options?.customerEmail)
|
|
542
|
+
params.set("customerEmail", options.customerEmail);
|
|
514
543
|
const response = await fetch(`/api/diviswap?${params}`);
|
|
515
544
|
if (!response.ok) {
|
|
516
545
|
throw new Error("Failed to fetch KYC status");
|
|
@@ -595,10 +624,13 @@ function useDashboard(options) {
|
|
|
595
624
|
const finalTransactions = txData.filter(
|
|
596
625
|
(tx) => tx.tx_type === "BANK_WITHDRAWAL" || tx.tx_type === "BANK_DEPOSIT"
|
|
597
626
|
);
|
|
598
|
-
const totalVolume = finalTransactions.reduce(
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
627
|
+
const totalVolume = finalTransactions.reduce(
|
|
628
|
+
(sum, tx) => {
|
|
629
|
+
const amount = tx.transaction_details?.amount || 0;
|
|
630
|
+
return sum + amount;
|
|
631
|
+
},
|
|
632
|
+
0
|
|
633
|
+
);
|
|
602
634
|
const pendingTransactions = finalTransactions.filter(
|
|
603
635
|
(tx) => tx.status === "INITIATED" || tx.status === "PROCESSING" || tx.status === "pending" || tx.status === "processing"
|
|
604
636
|
).length;
|
|
@@ -628,7 +660,10 @@ function useDashboard(options) {
|
|
|
628
660
|
0
|
|
629
661
|
);
|
|
630
662
|
return {
|
|
631
|
-
date: new Date(date).toLocaleDateString("en-US", {
|
|
663
|
+
date: new Date(date).toLocaleDateString("en-US", {
|
|
664
|
+
month: "short",
|
|
665
|
+
day: "numeric"
|
|
666
|
+
}),
|
|
632
667
|
volume,
|
|
633
668
|
// Amount is already in dollars
|
|
634
669
|
transactions: dayTransactions.length
|
|
@@ -840,7 +875,9 @@ var _WalletTracker = class _WalletTracker {
|
|
|
840
875
|
* Get chain name from chain ID
|
|
841
876
|
*/
|
|
842
877
|
getChainName(chainId) {
|
|
843
|
-
const builtInChain = Object.entries(CHAIN_IDS).find(
|
|
878
|
+
const builtInChain = Object.entries(CHAIN_IDS).find(
|
|
879
|
+
([_, id]) => id === chainId
|
|
880
|
+
)?.[0];
|
|
844
881
|
if (builtInChain) return builtInChain;
|
|
845
882
|
return this.config.customChains?.[chainId];
|
|
846
883
|
}
|
|
@@ -893,69 +930,90 @@ function useAddresses(diviswap) {
|
|
|
893
930
|
const result = await diviswap.addresses.list();
|
|
894
931
|
setAddresses(result);
|
|
895
932
|
} catch (err) {
|
|
896
|
-
setError(
|
|
933
|
+
setError(
|
|
934
|
+
err instanceof Error ? err : new Error("Failed to fetch addresses")
|
|
935
|
+
);
|
|
897
936
|
} finally {
|
|
898
937
|
setLoading(false);
|
|
899
938
|
}
|
|
900
939
|
}, [diviswap]);
|
|
901
|
-
const createAddress = useCallback(
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
));
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
940
|
+
const createAddress = useCallback(
|
|
941
|
+
async (data) => {
|
|
942
|
+
if (!diviswap) throw new Error("Diviswap instance not provided");
|
|
943
|
+
setLoading(true);
|
|
944
|
+
setError(null);
|
|
945
|
+
try {
|
|
946
|
+
const newAddress = await diviswap.addresses.create(data);
|
|
947
|
+
setAddresses((prev) => [...prev, newAddress]);
|
|
948
|
+
return newAddress;
|
|
949
|
+
} catch (err) {
|
|
950
|
+
const error2 = err instanceof Error ? err : new Error("Failed to create address");
|
|
951
|
+
setError(error2);
|
|
952
|
+
throw error2;
|
|
953
|
+
} finally {
|
|
954
|
+
setLoading(false);
|
|
955
|
+
}
|
|
956
|
+
},
|
|
957
|
+
[diviswap]
|
|
958
|
+
);
|
|
959
|
+
const setDefaultAddress = useCallback(
|
|
960
|
+
async (data) => {
|
|
961
|
+
if (!diviswap) throw new Error("Diviswap instance not provided");
|
|
962
|
+
setLoading(true);
|
|
963
|
+
setError(null);
|
|
964
|
+
try {
|
|
965
|
+
await diviswap.addresses.setDefault(data);
|
|
966
|
+
await fetchAddresses();
|
|
967
|
+
} catch (err) {
|
|
968
|
+
const error2 = err instanceof Error ? err : new Error("Failed to set default address");
|
|
969
|
+
setError(error2);
|
|
970
|
+
throw error2;
|
|
971
|
+
} finally {
|
|
972
|
+
setLoading(false);
|
|
973
|
+
}
|
|
974
|
+
},
|
|
975
|
+
[diviswap, fetchAddresses]
|
|
976
|
+
);
|
|
977
|
+
const deleteAddress = useCallback(
|
|
978
|
+
async (data) => {
|
|
979
|
+
if (!diviswap) throw new Error("Diviswap instance not provided");
|
|
980
|
+
setLoading(true);
|
|
981
|
+
setError(null);
|
|
982
|
+
try {
|
|
983
|
+
await diviswap.addresses.delete(data);
|
|
984
|
+
setAddresses(
|
|
985
|
+
(prev) => prev.filter(
|
|
986
|
+
(addr) => !(addr.chain_id === data.chain_id && addr.address.toLowerCase() === data.address.toLowerCase())
|
|
987
|
+
)
|
|
988
|
+
);
|
|
989
|
+
} catch (err) {
|
|
990
|
+
const error2 = err instanceof Error ? err : new Error("Failed to delete address");
|
|
991
|
+
setError(error2);
|
|
992
|
+
throw error2;
|
|
993
|
+
} finally {
|
|
994
|
+
setLoading(false);
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
[diviswap]
|
|
998
|
+
);
|
|
999
|
+
const getByChain = useCallback(
|
|
1000
|
+
(chainIdOrName) => {
|
|
1001
|
+
if (!diviswap) return [];
|
|
1002
|
+
const chainId = typeof chainIdOrName === "string" ? diviswap.addresses.getChainId(chainIdOrName) : chainIdOrName;
|
|
1003
|
+
return addresses.filter((addr) => addr.chain_id === chainId);
|
|
1004
|
+
},
|
|
1005
|
+
[addresses, diviswap]
|
|
1006
|
+
);
|
|
1007
|
+
const getDefault = useCallback(
|
|
1008
|
+
(chainIdOrName) => {
|
|
1009
|
+
if (!diviswap) return null;
|
|
1010
|
+
const chainId = typeof chainIdOrName === "string" ? diviswap.addresses.getChainId(chainIdOrName) : chainIdOrName;
|
|
1011
|
+
return addresses.find(
|
|
1012
|
+
(addr) => addr.chain_id === chainId && addr.is_default
|
|
1013
|
+
) || null;
|
|
1014
|
+
},
|
|
1015
|
+
[addresses, diviswap]
|
|
1016
|
+
);
|
|
959
1017
|
useEffect(() => {
|
|
960
1018
|
if (diviswap) {
|
|
961
1019
|
fetchAddresses();
|
|
@@ -978,49 +1036,62 @@ function useWalletConnection(diviswap, config) {
|
|
|
978
1036
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
979
1037
|
const [isTracking, setIsTracking] = useState(false);
|
|
980
1038
|
const [error, setError] = useState(null);
|
|
981
|
-
const connect = useCallback(
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1039
|
+
const connect = useCallback(
|
|
1040
|
+
async (wallet) => {
|
|
1041
|
+
if (!diviswap) throw new Error("Diviswap instance not provided");
|
|
1042
|
+
setIsConnecting(true);
|
|
1043
|
+
setError(null);
|
|
1044
|
+
try {
|
|
1045
|
+
const result = await connectWallet(diviswap, wallet, config);
|
|
1046
|
+
setConnections(result);
|
|
1047
|
+
return result;
|
|
1048
|
+
} catch (err) {
|
|
1049
|
+
const error2 = err instanceof Error ? err : new Error("Failed to connect wallet");
|
|
1050
|
+
setError(error2);
|
|
1051
|
+
throw error2;
|
|
1052
|
+
} finally {
|
|
1053
|
+
setIsConnecting(false);
|
|
1054
|
+
}
|
|
1055
|
+
},
|
|
1056
|
+
[diviswap, config]
|
|
1057
|
+
);
|
|
1058
|
+
const trackCurrent = useCallback(
|
|
1059
|
+
async (wallet) => {
|
|
1060
|
+
if (!diviswap) throw new Error("Diviswap instance not provided");
|
|
1061
|
+
setIsTracking(true);
|
|
1062
|
+
setError(null);
|
|
1063
|
+
try {
|
|
1064
|
+
const result = await trackCurrentWallet(
|
|
1065
|
+
diviswap,
|
|
1066
|
+
wallet,
|
|
1067
|
+
config
|
|
1068
|
+
);
|
|
1069
|
+
setConnections(result);
|
|
1070
|
+
return result;
|
|
1071
|
+
} catch (err) {
|
|
1072
|
+
const error2 = err instanceof Error ? err : new Error("Failed to track current wallet");
|
|
1073
|
+
setError(error2);
|
|
1074
|
+
throw error2;
|
|
1075
|
+
} finally {
|
|
1076
|
+
setIsTracking(false);
|
|
1077
|
+
}
|
|
1078
|
+
},
|
|
1079
|
+
[diviswap, config]
|
|
1080
|
+
);
|
|
1081
|
+
const setupTracking = useCallback(
|
|
1082
|
+
(wallet) => {
|
|
1083
|
+
if (!diviswap) throw new Error("Diviswap instance not provided");
|
|
1084
|
+
try {
|
|
1085
|
+
const tracker = setupWalletTracking(diviswap, wallet, config);
|
|
1086
|
+
return tracker;
|
|
1087
|
+
} catch (err) {
|
|
1088
|
+
const error2 = err instanceof Error ? err : new Error("Failed to setup wallet tracking");
|
|
1089
|
+
setError(error2);
|
|
1090
|
+
throw error2;
|
|
1091
|
+
}
|
|
1092
|
+
},
|
|
1093
|
+
[diviswap, config]
|
|
1094
|
+
);
|
|
1024
1095
|
return {
|
|
1025
1096
|
connections,
|
|
1026
1097
|
isConnecting,
|
|
@@ -1034,16 +1105,22 @@ function useWalletConnection(diviswap, config) {
|
|
|
1034
1105
|
function useWalletAddresses(diviswap, config) {
|
|
1035
1106
|
const addressHook = useAddresses(diviswap);
|
|
1036
1107
|
const walletHook = useWalletConnection(diviswap, config);
|
|
1037
|
-
const connectAndTrack = useCallback(
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1108
|
+
const connectAndTrack = useCallback(
|
|
1109
|
+
async (wallet) => {
|
|
1110
|
+
const connections = await walletHook.connect(wallet);
|
|
1111
|
+
await addressHook.fetchAddresses();
|
|
1112
|
+
return connections;
|
|
1113
|
+
},
|
|
1114
|
+
[walletHook.connect, addressHook.fetchAddresses]
|
|
1115
|
+
);
|
|
1116
|
+
const trackCurrentAndRefresh = useCallback(
|
|
1117
|
+
async (wallet) => {
|
|
1118
|
+
const connections = await walletHook.trackCurrent(wallet);
|
|
1119
|
+
await addressHook.fetchAddresses();
|
|
1120
|
+
return connections;
|
|
1121
|
+
},
|
|
1122
|
+
[walletHook.trackCurrent, addressHook.fetchAddresses]
|
|
1123
|
+
);
|
|
1047
1124
|
return {
|
|
1048
1125
|
// Address management
|
|
1049
1126
|
...addressHook,
|