@rango-dev/widget-embedded 0.22.4-next.9 → 0.23.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.
@@ -1 +1 @@
1
- {"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAuCnD,wBAAgB,IAAI,sBAkQnB"}
1
+ {"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAuCnD,wBAAgB,IAAI,sBAgQnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.22.4-next.9",
3
+ "version": "0.23.0",
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.27.1-next.1",
25
- "@rango-dev/queue-manager-core": "^0.25.1-next.0",
26
- "@rango-dev/queue-manager-rango-preset": "^0.27.1-next.1",
27
- "@rango-dev/queue-manager-react": "^0.25.1-next.0",
28
- "@rango-dev/ui": "^0.28.2-next.8",
29
- "@rango-dev/wallets-react": "^0.13.1-next.1",
30
- "@rango-dev/wallets-shared": "^0.27.1-next.1",
24
+ "@rango-dev/provider-all": "^0.28.0",
25
+ "@rango-dev/queue-manager-core": "^0.26.0",
26
+ "@rango-dev/queue-manager-rango-preset": "^0.28.0",
27
+ "@rango-dev/queue-manager-react": "^0.26.0",
28
+ "@rango-dev/ui": "^0.29.0",
29
+ "@rango-dev/wallets-react": "^0.14.0",
30
+ "@rango-dev/wallets-shared": "^0.28.0",
31
31
  "bignumber.js": "^9.1.1",
32
32
  "copy-to-clipboard": "^3.3.3",
33
33
  "dayjs": "^1.11.7",
@@ -80,9 +80,6 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
80
80
  getSupportedChainNames,
81
81
  },
82
82
  getSigners,
83
- //todo: remove Network type
84
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
85
- //@ts-ignore
86
83
  wallets,
87
84
  providers: allProviders,
88
85
  switchNetwork,
@@ -84,18 +84,23 @@ export function ConfirmWalletsModal(props: PropTypes) {
84
84
  const isWalletRequiredFor = (blockchain: string) =>
85
85
  !!selectedQuote?.swaps.find((swap) => swap.from.blockchain === blockchain);
86
86
 
87
- const [selectableWallets, setSelectableWallets] = useState<ConnectedWallet[]>(
87
+ const getInitialSelectableWallets = () =>
88
88
  connectedWallets.filter((connectedWallet) => {
89
89
  return (
90
90
  connectedWallet.selected &&
91
91
  requiredWallets.includes(connectedWallet.chain)
92
92
  );
93
- })
93
+ });
94
+
95
+ const [selectableWallets, setSelectableWallets] = useState<ConnectedWallet[]>(
96
+ getInitialSelectableWallets()
94
97
  );
95
98
  const lastStepToBlockchainMeta = blockchains.find(
96
99
  (chain) => chain.name === lastStepToBlockchain?.name
97
100
  );
98
101
 
102
+ const isInsufficientBalanceModalOpen = balanceWarnings.length > 0;
103
+
99
104
  const isSelected = (walletType: string, chain: string) =>
100
105
  !!selectableWallets.find(
101
106
  (selectableWallet) =>
@@ -291,7 +296,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
291
296
  })}
292
297
  anchor="center">
293
298
  <WatermarkedModal
294
- open={balanceWarnings.length > 0}
299
+ open={isInsufficientBalanceModalOpen}
295
300
  onClose={setBalanceWarnings.bind(null, [])}
296
301
  container={modalContainer}>
297
302
  <MessageBox
@@ -95,9 +95,7 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
95
95
  type="primary"
96
96
  size="large"
97
97
  onClick={() => window.open(diagnosisUrl, '_blank')}>
98
- <Typography variant="title" size="medium" color="primary">
99
- {i18n.t('Diagnosis')}
100
- </Typography>
98
+ {i18n.t('Diagnosis')}
101
99
  </Button>
102
100
  <Divider size={12} />
103
101
  </>
@@ -1,7 +1,7 @@
1
1
  import type { CancelContentProps } from './SwapDetailsModal.types';
2
2
 
3
3
  import { i18n } from '@lingui/core';
4
- import { Button, Divider, MessageBox, Typography } from '@rango-dev/ui';
4
+ import { Button, Divider, MessageBox } from '@rango-dev/ui';
5
5
  import React from 'react';
6
6
 
7
7
  export const CancelContent = ({ onCancel, onClose }: CancelContentProps) => {
@@ -19,15 +19,11 @@ export const CancelContent = ({ onCancel, onClose }: CancelContentProps) => {
19
19
  type="primary"
20
20
  size="large"
21
21
  onClick={onCancel}>
22
- <Typography variant="title" size="medium" color="neutral100">
23
- {i18n.t('Yes, Cancel it')}
24
- </Typography>
22
+ {i18n.t('Yes, Cancel it')}
25
23
  </Button>
26
24
  <Divider size={12} />
27
25
  <Button variant="outlined" type="primary" size="large" onClick={onClose}>
28
- <Typography variant="title" size="medium" color="primary">
29
- {i18n.t('No, Continue')}
30
- </Typography>
26
+ {i18n.t('No, Continue')}
31
27
  </Button>
32
28
  </>
33
29
  );
@@ -19,9 +19,7 @@ export const DeleteContent = ({ onDelete, onClose }: DeleteContentProps) => {
19
19
  type="primary"
20
20
  size="large"
21
21
  onClick={onDelete}>
22
- <Typography variant="title" size="medium" color="neutral100">
23
- {i18n.t('Yes, Delete it')}
24
- </Typography>
22
+ {i18n.t('Yes, Delete it')}
25
23
  </Button>
26
24
  <Divider size={12} />
27
25
  <Button variant="outlined" type="primary" size="large" onClick={onClose}>
@@ -3,15 +3,14 @@ import type {
3
3
  PropTypes,
4
4
  WidgetContextInterface,
5
5
  } from './Wallets.types';
6
- import type { Wallet } from '../../types/wallets';
7
6
  import type { ProvidersOptions } from '../../utils/providers';
8
7
  import type { EventHandler } from '@rango-dev/wallets-react';
9
- import type { Network } from '@rango-dev/wallets-shared';
10
8
  import type { PropsWithChildren } from 'react';
11
9
 
12
10
  import { Events, Provider } from '@rango-dev/wallets-react';
11
+ import { type Network } from '@rango-dev/wallets-shared';
13
12
  import { isEvmBlockchain } from 'rango-sdk';
14
- import React, { createContext, useEffect, useRef, useState } from 'react';
13
+ import React, { createContext, useEffect, useRef } from 'react';
15
14
 
16
15
  import { useWalletProviders } from '../../hooks/useWalletProviders';
17
16
  import { AppStoreProvider, useAppStore } from '../../store/AppStore';
@@ -35,7 +34,6 @@ function Main(props: PropsWithChildren<PropTypes>) {
35
34
  const walletOptions: ProvidersOptions = {
36
35
  walletConnectProjectId: props.config?.walletConnectProjectId,
37
36
  };
38
- const [accounts, setAccounts] = useState<Wallet[]>([]);
39
37
  const { providers } = useWalletProviders(props.config.wallets, walletOptions);
40
38
  const { connectWallet, disconnectWallet } = useWalletsStore();
41
39
  const onConnectWalletHandler = useRef<OnConnectHandler>();
@@ -67,7 +65,9 @@ function Main(props: PropsWithChildren<PropTypes>) {
67
65
  supportedChainNames,
68
66
  meta.isContractWallet
69
67
  );
70
- setAccounts(data);
68
+ if (data.length) {
69
+ connectWallet(data, tokens);
70
+ }
71
71
  } else {
72
72
  disconnectWallet(type);
73
73
  }
@@ -102,12 +102,6 @@ function Main(props: PropsWithChildren<PropTypes>) {
102
102
  };
103
103
  const isActiveTab = useUiStore.use.isActiveTab();
104
104
 
105
- useEffect(() => {
106
- if (accounts.length) {
107
- connectWallet(accounts, tokens);
108
- }
109
- }, [accounts, tokens]);
110
-
111
105
  return (
112
106
  <WidgetContext.Provider
113
107
  // eslint-disable-next-line react/jsx-no-constructed-context-values
@@ -102,7 +102,7 @@ export function Home() {
102
102
  formatBalance(fromTokenBalance)?.amount ?? '0';
103
103
 
104
104
  const tokenBalanceReal =
105
- !!fromBlockchain && !!fromToken
105
+ !!fromBlockchain && !!fromToken && fromTokenBalance?.amount
106
106
  ? numberToString(fromTokenBalance?.amount, fromTokenBalance?.decimals)
107
107
  : '0';
108
108
 
@@ -203,9 +203,7 @@ export function Home() {
203
203
  loadingBalance={fetchingBalance}
204
204
  tooltipContainer={getContainer()}
205
205
  onSelectMaxBalance={() => {
206
- if (fromTokenFormattedBalance !== '0') {
207
- setInputAmount(tokenBalanceReal.split(',').join(''));
208
- }
206
+ setInputAmount(tokenBalanceReal.split(',').join(''));
209
207
  }}
210
208
  />
211
209
  <SwitchFromAndToButton />