@rango-dev/widget-embedded 0.20.0 → 0.20.1-next.1

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":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEtD;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC3B,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,WAK5B;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAGvB,GAAG,UAS9B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAGtE;AAED,eAAO,MAAM,YAAY,mBAC2B,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEtD;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC3B,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,WAK5B;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAGvB,GAAG,UAS9B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAGtE;AAED,eAAO,MAAM,YAAY,mBACkC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.20.0",
3
+ "version": "0.20.1-next.1",
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.0",
24
+ "@rango-dev/provider-all": "^0.25.1-next.0",
25
25
  "@rango-dev/queue-manager-core": "^0.25.0",
26
- "@rango-dev/queue-manager-rango-preset": "^0.25.0",
26
+ "@rango-dev/queue-manager-rango-preset": "^0.25.1-next.0",
27
27
  "@rango-dev/queue-manager-react": "^0.24.0",
28
- "@rango-dev/ui": "^0.26.0",
29
- "@rango-dev/wallets-react": "^0.11.0",
30
- "@rango-dev/wallets-shared": "^0.25.0",
28
+ "@rango-dev/ui": "^0.26.1-next.0",
29
+ "@rango-dev/wallets-react": "^0.11.1-next.0",
30
+ "@rango-dev/wallets-shared": "^0.25.1-next.0",
31
31
  "bignumber.js": "^9.1.1",
32
32
  "copy-to-clipboard": "^3.3.3",
33
33
  "dayjs": "^1.11.7",
@@ -47,4 +47,4 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  }
50
- }
50
+ }
@@ -18,6 +18,7 @@ import {
18
18
  import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
19
19
  import { useNavigate } from 'react-router-dom';
20
20
 
21
+ import { RANGO_SWAP_BOX_ID } from '../../constants';
21
22
  import { getQuoteErrorMessage } from '../../constants/errors';
22
23
  import { getQuoteUpdateWarningMessage } from '../../constants/warnings';
23
24
  import { useAppStore } from '../../store/AppStore';
@@ -238,7 +239,9 @@ export function ConfirmWalletsModal(props: PropTypes) {
238
239
  }
239
240
  }, [showCustomDestination]);
240
241
 
241
- const modalContainer = document.querySelector('#swap-box') as HTMLDivElement;
242
+ const modalContainer = document.getElementById(
243
+ RANGO_SWAP_BOX_ID
244
+ ) as HTMLDivElement;
242
245
 
243
246
  const navigate = useNavigate();
244
247
  return (
@@ -18,6 +18,7 @@ import {
18
18
  import React, { useEffect, useState } from 'react';
19
19
 
20
20
  import { useWallets } from '../..';
21
+ import { RANGO_SWAP_BOX_ID } from '../../constants';
21
22
  import { useWalletList } from '../../hooks/useWalletList';
22
23
  import {
23
24
  TIME_TO_CLOSE_MODAL,
@@ -107,7 +108,9 @@ export function WalletList(props: PropTypes) {
107
108
  });
108
109
  }, [JSON.stringify(list)]);
109
110
 
110
- const modalContainer = document.querySelector('#swap-box') as HTMLDivElement;
111
+ const modalContainer = document.getElementById(
112
+ RANGO_SWAP_BOX_ID
113
+ ) as HTMLDivElement;
111
114
 
112
115
  useEffect(() => {
113
116
  let timeout: ReturnType<typeof setTimeout> | null = null;
@@ -7,7 +7,7 @@ export const Container = styled('div', {
7
7
  borderRadius: '$primary',
8
8
  overflow: 'hidden !important',
9
9
  boxShadow: '15px 15px 15px 0px rgba(0, 0, 0, 0.05)',
10
- width: '95vw',
10
+ width: '100vw',
11
11
  minWidth: '300px',
12
12
  maxWidth: '390px',
13
13
  maxHeight: '700px',
@@ -20,10 +20,10 @@ export const Container = styled('div', {
20
20
  variants: {
21
21
  fixedHeight: {
22
22
  true: {
23
- height: '95vh',
23
+ height: '100vh',
24
24
  },
25
25
  false: {
26
- height: 'auto',
26
+ height: 'auto !important',
27
27
  },
28
28
  },
29
29
  },
@@ -4,7 +4,9 @@ import type { PropsWithChildren } from 'react';
4
4
  import { BottomLogo, Divider, Header } from '@rango-dev/ui';
5
5
  import React from 'react';
6
6
 
7
+ import { RANGO_SWAP_BOX_ID } from '../../constants';
7
8
  import { useNavigateBack } from '../../hooks/useNavigateBack';
9
+ import { useTheme } from '../../hooks/useTheme';
8
10
  import { useAppStore } from '../../store/AppStore';
9
11
  import { useUiStore } from '../../store/ui';
10
12
  import { useWalletsStore } from '../../store/wallets';
@@ -25,8 +27,9 @@ function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
25
27
  } = props;
26
28
  const connectedWallets = useWalletsStore.use.connectedWallets();
27
29
  const {
28
- config: { features },
30
+ config: { features, theme },
29
31
  } = useAppStore();
32
+ const { activeTheme } = useTheme(theme || {});
30
33
 
31
34
  const isConnectWalletHidden = isFeatureHidden(
32
35
  'connectWalletButton',
@@ -47,7 +50,11 @@ function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
47
50
  typeof header.hasBackButton === 'undefined' || header.hasBackButton;
48
51
 
49
52
  return (
50
- <Container ref={ref} fixedHeight={fixedHeight} id="swap-box">
53
+ <Container
54
+ ref={ref}
55
+ fixedHeight={fixedHeight}
56
+ id={RANGO_SWAP_BOX_ID}
57
+ className={activeTheme()}>
51
58
  <Header
52
59
  prefix={<>{showBackButton && <BackButton onClick={navigateBack} />}</>}
53
60
  title={header.title}
@@ -12,6 +12,8 @@ import {
12
12
  import React from 'react';
13
13
  import { useNavigate } from 'react-router-dom';
14
14
 
15
+ import { RANGO_SWAP_BOX_ID } from '../../constants';
16
+
15
17
  export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
16
18
  const {
17
19
  open,
@@ -31,7 +33,7 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
31
33
  <Modal
32
34
  open={open}
33
35
  onClose={onClose}
34
- container={document.getElementById('swap-box') || document.body}>
36
+ container={document.getElementById(RANGO_SWAP_BOX_ID) || document.body}>
35
37
  {status === 'success' ? (
36
38
  <MessageBox type="success" title={i18n.t('Swap Successful')}>
37
39
  <TokenAmount
@@ -4,6 +4,8 @@ import { Modal } from '@rango-dev/ui';
4
4
  import { PendingSwapNetworkStatus } from 'rango-types';
5
5
  import React from 'react';
6
6
 
7
+ import { RANGO_SWAP_BOX_ID } from '../../constants';
8
+
7
9
  import { CancelContent } from './SwapDetailsModal.Cancel';
8
10
  import { DeleteContent } from './SwapDetailsModal.Delete';
9
11
  import { modalNetworkValues } from './SwapDetailsModal.helpers';
@@ -22,7 +24,7 @@ export function SwapDetailsModal(props: ModalPropTypes) {
22
24
  <Modal
23
25
  open={!!state}
24
26
  onClose={onClose}
25
- container={document.getElementById('swap-box') || document.body}>
27
+ container={document.getElementById(RANGO_SWAP_BOX_ID) || document.body}>
26
28
  {showWalletStateContent && (
27
29
  <WalletStateContent
28
30
  type={modalNetworkValues[state].type}
@@ -3,6 +3,8 @@ import type { PropTypes } from './WalletModal.types';
3
3
  import { Divider, Modal } from '@rango-dev/ui';
4
4
  import React from 'react';
5
5
 
6
+ import { RANGO_SWAP_BOX_ID } from '../../constants';
7
+
6
8
  import { ModalContent } from './WalletModalContent';
7
9
 
8
10
  export function WalletModal(props: PropTypes) {
@@ -12,7 +14,7 @@ export function WalletModal(props: PropTypes) {
12
14
  <Modal
13
15
  open={open}
14
16
  onClose={onClose}
15
- container={document.getElementById('swap-box') || document.body}>
17
+ container={document.getElementById(RANGO_SWAP_BOX_ID) || document.body}>
16
18
  <ModalContent {...otherProps} />
17
19
  <Divider direction="vertical" size={32} />
18
20
  </Modal>
@@ -1,2 +1,3 @@
1
1
  export const RANGO_PUBLIC_API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32';
2
2
  export const DEFAULT_BASE_URL = 'https://api.rango.exchange';
3
+ export const RANGO_SWAP_BOX_ID = 'rango-swap-box';
@@ -1,7 +1,6 @@
1
1
  import { styled } from '@rango-dev/ui';
2
2
 
3
3
  export const MainContainer = styled('div', {
4
- width: '100%',
5
4
  display: 'flex',
6
5
  justifyContent: 'center',
7
6
  alignItems: 'center',
@@ -9,10 +8,10 @@ export const MainContainer = styled('div', {
9
8
  boxSizing: 'border-box',
10
9
  '& *, *::before, *::after': {
11
10
  boxSizing: 'inherit',
12
- listStyleType: 'none',
13
11
  },
14
12
  '& *:focus-visible': {
15
13
  outlineColor: '$info500',
16
14
  transition: 'none',
17
15
  },
16
+ '& ul, ol, li': { listStyleType: 'none' },
18
17
  });
@@ -1,4 +1,5 @@
1
1
  import type { WidgetConfig } from '../types';
2
+ import type { WalletInfo } from '@rango-dev/ui';
2
3
  import type { BlockchainMeta } from 'rango-sdk';
3
4
 
4
5
  import { WalletState } from '@rango-dev/ui';
@@ -101,15 +102,36 @@ export function useWalletList(params: Params) {
101
102
  };
102
103
  }, []);
103
104
 
105
+ /*
106
+ * Atm, we only support default injected wallet for the EVM
107
+ * so we show default wallet when there is no other evm wallet installed
108
+ * but we have ethereum injected
109
+ */
110
+ const shouldShowDefaultInjectedWallet = (wallets: WalletInfo[]) => {
111
+ const isEvmWalletInstalledExceptDefault = wallets.filter(
112
+ (wallet) =>
113
+ wallet.state != WalletState.NOT_INSTALLED &&
114
+ ![WalletTypes.DEFAULT, WalletTypes.WALLET_CONNECT_2].includes(
115
+ wallet.type as WalletTypes
116
+ ) &&
117
+ getWalletInfo(wallet.type).supportedChains.filter(
118
+ (blockchain) => blockchain.type == 'EVM'
119
+ ).length > 0
120
+ );
121
+ return isEvmWalletInstalledExceptDefault.length == 0;
122
+ };
123
+
104
124
  const shouldExcludeWallet = (
105
125
  walletType: string,
106
126
  chain: string,
107
127
  blockchains: BlockchainMeta[]
108
128
  ) => {
109
129
  return (
110
- isExperimentalChain(blockchains, chain) &&
111
- isExperimentalChainNotAdded(walletType) &&
112
- !KEPLR_COMPATIBLE_WALLETS.includes(walletType)
130
+ (isExperimentalChain(blockchains, chain) &&
131
+ isExperimentalChainNotAdded(walletType) &&
132
+ !KEPLR_COMPATIBLE_WALLETS.includes(walletType)) ||
133
+ (walletType == WalletTypes.DEFAULT &&
134
+ !shouldShowDefaultInjectedWallet(wallets))
113
135
  );
114
136
  };
115
137
 
@@ -1,3 +1,5 @@
1
+ import { RANGO_SWAP_BOX_ID } from '../constants';
2
+
1
3
  export function removeDuplicateFrom<T>(array: T[]): T[] {
2
4
  return Array.from(new Set(array));
3
5
  }
@@ -31,4 +33,4 @@ export function containsText(text: string, searchText: string): boolean {
31
33
  }
32
34
 
33
35
  export const getContainer = () =>
34
- document.getElementById('swap-box') as HTMLElement;
36
+ document.getElementById(RANGO_SWAP_BOX_ID) as HTMLElement;