@rango-dev/widget-embedded 0.1.20-next.8 → 0.2.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":"SwapDetailsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SwapDetailsPage.tsx"],"names":[],"mappings":";AA+BA,wBAAgB,eAAe,gBA8H9B"}
1
+ {"version":3,"file":"SwapDetailsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SwapDetailsPage.tsx"],"names":[],"mappings":";AA6BA,wBAAgB,eAAe,gBAqI9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.1.20-next.8",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,13 +17,13 @@
17
17
  "lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
18
18
  },
19
19
  "dependencies": {
20
- "@rango-dev/provider-all": "^0.1.22-next.5",
21
- "@rango-dev/queue-manager-core": "^0.1.15-next.4",
22
- "@rango-dev/queue-manager-rango-preset": "^0.1.15-next.6",
23
- "@rango-dev/queue-manager-react": "^0.1.14-next.5",
24
- "@rango-dev/ui": "^0.1.16-next.8",
25
- "@rango-dev/wallets-core": "^0.1.16-next.6",
26
- "@rango-dev/wallets-shared": "^0.1.15-next.5",
20
+ "@rango-dev/provider-all": "^0.2.0",
21
+ "@rango-dev/queue-manager-core": "^0.2.0",
22
+ "@rango-dev/queue-manager-rango-preset": "^0.1.14",
23
+ "@rango-dev/queue-manager-react": "^0.1.13",
24
+ "@rango-dev/ui": "^0.2.0",
25
+ "@rango-dev/wallets-core": "^0.2.0",
26
+ "@rango-dev/wallets-shared": "^0.2.0",
27
27
  "bignumber.js": "^9.1.1",
28
28
  "copy-to-clipboard": "^3.3.3",
29
29
  "dayjs": "^1.11.7",
@@ -18,7 +18,7 @@ import { walletAndSupportedChainsNames } from './utils/wallets';
18
18
  import { isEvmBlockchain } from 'rango-sdk';
19
19
  import { getConfig } from './utils/configs';
20
20
 
21
- function QueueManager(props: PropsWithChildren<{}>) {
21
+ function QueueManager(props: PropsWithChildren) {
22
22
  const {
23
23
  providers,
24
24
  getSigners,
@@ -103,10 +103,12 @@ function QueueManager(props: PropsWithChildren<{}>) {
103
103
  },
104
104
  getSigners,
105
105
  //todo: remove Network type
106
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
106
107
  //@ts-ignore
107
108
  wallets,
108
109
  providers: allProviders,
109
110
  switchNetwork,
111
+ canSwitchNetworkTo,
110
112
  connect,
111
113
  state,
112
114
  isMobileWallet,
@@ -120,8 +122,7 @@ function QueueManager(props: PropsWithChildren<{}>) {
120
122
  onPersistedDataLoaded={(manager) => {
121
123
  checkWaitingForNetworkChange(manager);
122
124
  }}
123
- isPaused={false}
124
- >
125
+ isPaused={false}>
125
126
  {props.children}
126
127
  </ManagerProvider>
127
128
  );
@@ -5,6 +5,7 @@ import { WalletType } from '@rango-dev/wallets-shared';
5
5
  import { isEvmBlockchain } from 'rango-types';
6
6
  import { UpdateUrl } from './UpdateUrl';
7
7
  import { useMetaStore } from '../store/meta';
8
+ import { useWallets } from '@rango-dev/wallets-core';
8
9
 
9
10
  export function AppRouter({
10
11
  children,
@@ -17,6 +18,7 @@ export function AppRouter({
17
18
  const isRouterInContext = useInRouterContext();
18
19
  const Router = isRouterInContext ? Fragment : MemoryRouter;
19
20
  const { blockchains } = useMetaStore.use.meta();
21
+ const { canSwitchNetworkTo } = useWallets();
20
22
 
21
23
  const evmChains = blockchains.filter(isEvmBlockchain);
22
24
 
@@ -25,7 +27,9 @@ export function AppRouter({
25
27
  clearDisconnectedWallet: props.clearDisconnectedWallet,
26
28
  disconnectedWallet: props.disconnectedWallet,
27
29
  evmChains,
30
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
28
31
  notifier: () => {},
32
+ canSwitchNetworkTo,
29
33
  });
30
34
 
31
35
  return (
@@ -24,14 +24,12 @@ import {
24
24
  isNetworkStatusInWarningState,
25
25
  shouldRetrySwap,
26
26
  } from '../utils/swap';
27
- //@ts-ignore
28
- import { t } from 'i18next';
29
27
  import { SwapDetailsPlaceholder } from '../components/SwapDetailsPlaceholder';
30
28
  import { getFormatedPendingSwap } from '../utils/routing';
31
29
 
32
30
  export function SwapDetailsPage() {
33
31
  const selectedSwapRequestId = useUiStore.use.selectedSwapRequestId();
34
- const { canSwitchNetworkTo, connect } = useWallets();
32
+ const { canSwitchNetworkTo, connect, getWalletInfo } = useWallets();
35
33
  const retry = useBestRouteStore.use.retry();
36
34
  const navigate = useNavigate();
37
35
  const { navigateBackFrom } = useNavigateBack();
@@ -44,6 +42,7 @@ export function SwapDetailsPage() {
44
42
  );
45
43
 
46
44
  const onCancel = () => {
45
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
47
46
  const swap = manager?.get(selectedSwap?.id!);
48
47
  if (swap) cancelSwap(swap);
49
48
  };
@@ -77,14 +76,20 @@ export function SwapDetailsPage() {
77
76
 
78
77
  const shouldRetry = shouldRetrySwap(swap);
79
78
 
80
- const switchNetwork =
81
- !!currentStepBlockchain &&
82
- !!currentStepWallet?.walletType &&
79
+ const isMobileWallet = (walletType: string): boolean =>
80
+ !!getWalletInfo(walletType)?.mobileWallet;
81
+
82
+ const showSwitchNetwork =
83
83
  currentStepNetworkStatus ===
84
84
  PendingSwapNetworkStatus.WaitingForNetworkChange &&
85
- canSwitchNetworkTo(currentStepWallet?.walletType, currentStepBlockchain)
86
- ? connect.bind(null, currentStepWallet.walletType, currentStepBlockchain)
87
- : undefined;
85
+ !!currentStepBlockchain &&
86
+ !!currentStepWallet?.walletType &&
87
+ (isMobileWallet(currentStepWallet.walletType) ||
88
+ canSwitchNetworkTo(currentStepWallet.walletType, currentStepBlockchain));
89
+
90
+ const switchNetwork = showSwitchNetwork
91
+ ? connect.bind(null, currentStepWallet.walletType, currentStepBlockchain)
92
+ : undefined;
88
93
 
89
94
  const lastConvertedTokenInFailedSwap =
90
95
  getLastConvertedTokenInFailedSwap(swap);