@rango-dev/widget-embedded 0.39.1-next.8 → 0.39.1-next.9
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AppStoreState } from './types';
|
|
2
|
-
import type { Token } from 'rango-sdk';
|
|
2
|
+
import type { Token, WalletDetail } from 'rango-sdk';
|
|
3
3
|
import type { StateCreator } from 'zustand';
|
|
4
4
|
|
|
5
5
|
import BigNumber from 'bignumber.js';
|
|
@@ -63,6 +63,17 @@ export interface DeprecatedWalletDetail extends ConnectedWallet {
|
|
|
63
63
|
balances: DeprecatedTokenBalance[] | null;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
function matchWalletDetailsWithConnectedWallet(
|
|
67
|
+
connectedWallet: ConnectedWallet,
|
|
68
|
+
walletsDetails: WalletDetail[]
|
|
69
|
+
): WalletDetail | undefined {
|
|
70
|
+
return walletsDetails.find(
|
|
71
|
+
(walletDetails) =>
|
|
72
|
+
connectedWallet.address === walletDetails.address &&
|
|
73
|
+
connectedWallet.chain === walletDetails.blockChain
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
66
77
|
export interface WalletsSlice {
|
|
67
78
|
_balances: BalanceState;
|
|
68
79
|
_aggregatedBalances: AggregatedBalanceState;
|
|
@@ -71,7 +82,10 @@ export interface WalletsSlice {
|
|
|
71
82
|
|
|
72
83
|
setConnectedWalletAsRefetching: (walletType: string) => void;
|
|
73
84
|
setConnectedWalletHasError: (walletType: string) => void;
|
|
74
|
-
setConnectedWalletRetrievedData: (
|
|
85
|
+
setConnectedWalletRetrievedData: (
|
|
86
|
+
walletType: string,
|
|
87
|
+
walletsDetails: WalletDetail[]
|
|
88
|
+
) => void;
|
|
75
89
|
removeBalancesForWallet: (
|
|
76
90
|
walletType: string,
|
|
77
91
|
options?: {
|
|
@@ -136,7 +150,10 @@ export const createWalletsSlice: StateCreator<
|
|
|
136
150
|
};
|
|
137
151
|
});
|
|
138
152
|
},
|
|
139
|
-
setConnectedWalletRetrievedData: (
|
|
153
|
+
setConnectedWalletRetrievedData: (
|
|
154
|
+
walletType: string,
|
|
155
|
+
walletsDetails: WalletDetail[]
|
|
156
|
+
) => {
|
|
140
157
|
set((state) => {
|
|
141
158
|
return {
|
|
142
159
|
fetchingWallets: false,
|
|
@@ -146,6 +163,11 @@ export const createWalletsSlice: StateCreator<
|
|
|
146
163
|
...connectedWallet,
|
|
147
164
|
loading: false,
|
|
148
165
|
error: false,
|
|
166
|
+
explorerUrl:
|
|
167
|
+
matchWalletDetailsWithConnectedWallet(
|
|
168
|
+
connectedWallet,
|
|
169
|
+
walletsDetails
|
|
170
|
+
)?.explorerUrl || connectedWallet.explorerUrl,
|
|
149
171
|
};
|
|
150
172
|
}
|
|
151
173
|
|
|
@@ -415,12 +437,12 @@ export const createWalletsSlice: StateCreator<
|
|
|
415
437
|
}));
|
|
416
438
|
const response = await httpService().getWalletsDetails(addressesToFetch);
|
|
417
439
|
|
|
418
|
-
const
|
|
440
|
+
const walletsDetails = response.wallets;
|
|
419
441
|
|
|
420
|
-
if (
|
|
442
|
+
if (walletsDetails) {
|
|
421
443
|
const { retryOnFailedBalances = true } = options || {};
|
|
422
444
|
if (retryOnFailedBalances) {
|
|
423
|
-
const failedWallets: Wallet[] =
|
|
445
|
+
const failedWallets: Wallet[] = walletsDetails
|
|
424
446
|
.filter((wallet) => wallet.failed)
|
|
425
447
|
.map((wallet) => ({
|
|
426
448
|
chain: wallet.blockChain,
|
|
@@ -437,7 +459,7 @@ export const createWalletsSlice: StateCreator<
|
|
|
437
459
|
let nextBalances: BalanceState = {};
|
|
438
460
|
let nextAggregatedBalances: AggregatedBalanceState =
|
|
439
461
|
get()._aggregatedBalances;
|
|
440
|
-
|
|
462
|
+
walletsDetails.forEach((wallet) => {
|
|
441
463
|
if (wallet.failed) {
|
|
442
464
|
return;
|
|
443
465
|
}
|
|
@@ -463,7 +485,7 @@ export const createWalletsSlice: StateCreator<
|
|
|
463
485
|
_aggregatedBalances: nextAggregatedBalances,
|
|
464
486
|
}));
|
|
465
487
|
|
|
466
|
-
get().setConnectedWalletRetrievedData(walletType);
|
|
488
|
+
get().setConnectedWalletRetrievedData(walletType, walletsDetails);
|
|
467
489
|
} else {
|
|
468
490
|
get().setConnectedWalletHasError(walletType);
|
|
469
491
|
throw new Error(
|
|
@@ -529,7 +551,6 @@ export const createWalletsSlice: StateCreator<
|
|
|
529
551
|
|
|
530
552
|
return balancesForTargetWalletAddress;
|
|
531
553
|
},
|
|
532
|
-
|
|
533
554
|
getConnectedWalletsDetails: () => {
|
|
534
555
|
const connectedWallets = get().connectedWallets;
|
|
535
556
|
return connectedWallets.map((wallet) => {
|