@rango-dev/widget-embedded 0.58.1-next.7 → 0.58.1-next.8

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.58.1-next.7",
3
+ "version": "0.58.1-next.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -54,4 +54,4 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  }
57
- }
57
+ }
@@ -466,7 +466,7 @@ export const createWalletsSlice = keepLastUpdated<AppStoreState, WalletsSlice>(
466
466
  const { _balances, _aggregatedBalances } =
467
467
  computeNextStateAfterWalletBalanceRemoval(
468
468
  partialCurrentState,
469
- walletType,
469
+ [walletType],
470
470
  options
471
471
  );
472
472
 
@@ -611,8 +611,10 @@ export const createWalletsSlice = keepLastUpdated<AppStoreState, WalletsSlice>(
611
611
  if (accounts.length === 0 || !accounts[0]) {
612
612
  return;
613
613
  }
614
- // All the `accounts` have same `walletType` so we can pick the first one.
615
- const walletType = accounts[0].walletType;
614
+
615
+ const walletTypes = [
616
+ ...new Set(accounts.map((account) => account.walletType)),
617
+ ];
616
618
 
617
619
  get().setConnectedWalletAsRefetching(accounts);
618
620
 
@@ -630,7 +632,6 @@ export const createWalletsSlice = keepLastUpdated<AppStoreState, WalletsSlice>(
630
632
  return;
631
633
  }
632
634
  const walletsDetails = response.wallets;
633
-
634
635
  if (walletsDetails) {
635
636
  let nextBalances: BalanceState = get()._balances;
636
637
  let nextAggregatedBalances: AggregatedBalanceState =
@@ -657,7 +658,7 @@ export const createWalletsSlice = keepLastUpdated<AppStoreState, WalletsSlice>(
657
658
  const { _balances, _aggregatedBalances } =
658
659
  computeNextStateAfterWalletBalanceRemoval(
659
660
  partialCurrentState,
660
- walletType,
661
+ walletTypes,
661
662
  {
662
663
  chains: [wallet.blockChain],
663
664
  }
@@ -672,7 +673,7 @@ export const createWalletsSlice = keepLastUpdated<AppStoreState, WalletsSlice>(
672
673
  if (
673
674
  !get().connectedWallets.find(
674
675
  (connectedWallet) =>
675
- connectedWallet.walletType === walletType &&
676
+ walletTypes.includes(connectedWallet.walletType) &&
676
677
  connectedWallet.address === wallet.address &&
677
678
  connectedWallet.chain === wallet.blockChain
678
679
  )
@@ -715,11 +716,23 @@ export const createWalletsSlice = keepLastUpdated<AppStoreState, WalletsSlice>(
715
716
  if (retryOnFailedBalances) {
716
717
  const failedWallets: Wallet[] = walletsDetails
717
718
  .filter((wallet) => wallet.failed)
718
- .map((wallet) => ({
719
- chain: wallet.blockChain,
720
- walletType: walletType,
721
- address: wallet.address,
722
- }));
719
+ .map((wallet) => {
720
+ const walletType = get().connectedWallets.find(
721
+ (connectedWallet) =>
722
+ connectedWallet.chain === wallet.blockChain &&
723
+ connectedWallet.address
724
+ )?.walletType;
725
+ // Return null if there is no related connected wallet.
726
+ if (!walletType) {
727
+ return null;
728
+ }
729
+ return {
730
+ chain: wallet.blockChain,
731
+ walletType: walletType,
732
+ address: wallet.address,
733
+ };
734
+ })
735
+ .filter((wallet) => !!wallet);
723
736
  if (failedWallets.length > 0) {
724
737
  await get().fetchMainTokensBalances(failedWallets, {
725
738
  retryOnFailedBalances: false,
@@ -164,14 +164,14 @@ export function computeNextStateAfterWalletBalanceRemoval(
164
164
  _aggregatedBalances: AggregatedBalanceState;
165
165
  connectedWallets: ConnectedWallet[];
166
166
  },
167
- walletType: string,
167
+ walletTypes: string[],
168
168
  options?: {
169
169
  chains?: string[];
170
170
  namespaces?: Namespace[];
171
171
  }
172
172
  ) {
173
173
  let walletsNeedsToBeRemoved = paritalCurrentState.connectedWallets.filter(
174
- (connectedWallet) => connectedWallet.walletType === walletType
174
+ (connectedWallet) => walletTypes.includes(connectedWallet.walletType)
175
175
  );
176
176
 
177
177
  /*
@@ -181,7 +181,7 @@ export function computeNextStateAfterWalletBalanceRemoval(
181
181
  * So we only delete balance when there is no connected wallet that has access to that specific chain and address.
182
182
  */
183
183
  paritalCurrentState.connectedWallets.forEach((connectedWallet) => {
184
- if (connectedWallet.walletType !== walletType) {
184
+ if (!walletTypes.includes(connectedWallet.walletType)) {
185
185
  walletsNeedsToBeRemoved = walletsNeedsToBeRemoved.filter((wallet) => {
186
186
  const isAnotherWalletHasSameAddressAndChain =
187
187
  wallet.chain === connectedWallet.chain &&