@rango-dev/widget-embedded 0.20.1-next.4 → 0.20.1-next.5

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.20.1-next.4",
3
+ "version": "0.20.1-next.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -21,13 +21,13 @@
21
21
  "dependencies": {
22
22
  "@lingui/core": "4.2.1",
23
23
  "@lingui/react": "4.2.1",
24
- "@rango-dev/provider-all": "^0.25.1-next.1",
24
+ "@rango-dev/provider-all": "^0.25.1-next.2",
25
25
  "@rango-dev/queue-manager-core": "^0.25.0",
26
- "@rango-dev/queue-manager-rango-preset": "^0.25.1-next.0",
26
+ "@rango-dev/queue-manager-rango-preset": "^0.25.1-next.1",
27
27
  "@rango-dev/queue-manager-react": "^0.24.0",
28
- "@rango-dev/ui": "^0.26.1-next.2",
29
- "@rango-dev/wallets-react": "^0.11.1-next.0",
30
- "@rango-dev/wallets-shared": "^0.25.1-next.0",
28
+ "@rango-dev/ui": "^0.26.1-next.3",
29
+ "@rango-dev/wallets-react": "^0.11.1-next.1",
30
+ "@rango-dev/wallets-shared": "^0.25.1-next.1",
31
31
  "bignumber.js": "^9.1.1",
32
32
  "copy-to-clipboard": "^3.3.3",
33
33
  "dayjs": "^1.11.7",
@@ -3,6 +3,7 @@ import type {
3
3
  PropTypes,
4
4
  WidgetContextInterface,
5
5
  } from './Wallets.types';
6
+ import type { Wallet } from '../../types/wallets';
6
7
  import type { ProvidersOptions } from '../../utils/providers';
7
8
  import type { EventHandler } from '@rango-dev/wallets-react';
8
9
  import type { Network } from '@rango-dev/wallets-shared';
@@ -10,7 +11,7 @@ import type { PropsWithChildren } from 'react';
10
11
 
11
12
  import { Events, Provider } from '@rango-dev/wallets-react';
12
13
  import { isEvmBlockchain } from 'rango-sdk';
13
- import React, { createContext, useEffect, useRef } from 'react';
14
+ import React, { createContext, useEffect, useRef, useState } from 'react';
14
15
 
15
16
  import { useSyncStoresWithConfig } from '../../hooks/useSyncStoresWithConfig';
16
17
  import { useWalletProviders } from '../../hooks/useWalletProviders';
@@ -34,6 +35,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
34
35
  const walletOptions: ProvidersOptions = {
35
36
  walletConnectProjectId: props.config?.walletConnectProjectId,
36
37
  };
38
+ const [accounts, setAccounts] = useState<Wallet[]>([]);
37
39
  const { providers } = useWalletProviders(props.config.wallets, walletOptions);
38
40
  const { connectWallet, disconnectWallet } = useWalletsStore();
39
41
  const onConnectWalletHandler = useRef<OnConnectHandler>();
@@ -66,7 +68,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
66
68
  supportedChainNames,
67
69
  meta.isContractWallet
68
70
  );
69
- connectWallet(data, tokens);
71
+ setAccounts(data);
70
72
  } else {
71
73
  disconnectWallet(type);
72
74
  }
@@ -99,6 +101,13 @@ function Main(props: PropsWithChildren<PropTypes>) {
99
101
  props.onUpdateState(type, event, value, state, meta);
100
102
  }
101
103
  };
104
+
105
+ useEffect(() => {
106
+ if (accounts.length) {
107
+ connectWallet(accounts, tokens);
108
+ }
109
+ }, [accounts, tokens]);
110
+
102
111
  return (
103
112
  <WidgetContext.Provider
104
113
  // eslint-disable-next-line react/jsx-no-constructed-context-values