@rango-dev/widget-embedded 0.12.0 → 0.12.1-next.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.
- package/CHANGELOG.md +0 -4
- package/dist/Wallets.d.ts +1 -1
- package/dist/Wallets.d.ts.map +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/SwitchFromAndTo.d.ts +2 -3
- package/dist/components/SwitchFromAndTo.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders.d.ts +1 -1
- package/dist/hooks/useWalletProviders.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +1 -1
- package/dist/utils/providers.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/QueueManager.tsx +1 -1
- package/src/Wallets.tsx +2 -2
- package/src/components/AppRouter.tsx +1 -1
- package/src/components/Layout.tsx +13 -66
- package/src/components/SwitchFromAndTo.tsx +34 -4
- package/src/hooks/useWalletProviders.ts +1 -1
- package/src/index.ts +1 -1
- package/src/pages/ConfirmSwapPage.tsx +21 -10
- package/src/pages/Home.tsx +101 -144
- package/src/pages/SwapDetailsPage.tsx +6 -3
- package/src/pages/WalletsPage.tsx +1 -1
- package/src/types/config.ts +1 -1
- package/src/utils/numbers.ts +2 -0
- package/src/utils/providers.ts +1 -1
- package/src/utils/wallets.ts +1 -1
- package/dist/components/PercentageChange.d.ts +0 -9
- package/dist/components/PercentageChange.d.ts.map +0 -1
- package/dist/components/RoutesOverview.d.ts +0 -120
- package/dist/components/RoutesOverview.d.ts.map +0 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts +0 -120
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +0 -1
- package/dist/components/TokenInfo.d.ts +0 -18
- package/dist/components/TokenInfo.d.ts.map +0 -1
- package/dist/components/TokenPreview.d.ts +0 -21
- package/dist/components/TokenPreview.d.ts.map +0 -1
- package/src/components/PercentageChange.tsx +0 -33
- package/src/components/RoutesOverview.tsx +0 -57
- package/src/components/SwapDetailsPlaceholder.tsx +0 -47
- package/src/components/TokenInfo.tsx +0 -329
- package/src/components/TokenPreview.tsx +0 -187
- package/src/languages/en.json +0 -14
- package/src/languages/tr.json +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AA0CnD,wBAAgB,eAAe,CAAC,EAC9B,wBAAwB,GACzB,EAAE;IACD,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,qBA0NA"}
|
package/dist/pages/Home.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AA8BzC,wBAAgB,IAAI,sBAgKnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwapDetailsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SwapDetailsPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SwapDetailsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SwapDetailsPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgC1B,wBAAgB,eAAe,sBAqI9B"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset } from 'rango-sdk';
|
|
2
2
|
import { WalletType } from '@rango-dev/wallets-shared';
|
|
3
|
-
import { ProviderInterface } from '@rango-dev/wallets-
|
|
3
|
+
import { ProviderInterface } from '@rango-dev/wallets-react';
|
|
4
4
|
import { Language } from '@rango-dev/ui';
|
|
5
5
|
/**
|
|
6
6
|
* The above type defines a set of optional color properties for a widget.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,YAAY,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE,CAAC;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,wBAAwB,CAAC;IAChC,EAAE,CAAC,EAAE,wBAAwB,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,UAAU,GAAG,iBAAiB,CAAC,EAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/utils/numbers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,eAAO,MAAM,eAAe,MAAO,MAAM,yBAAkB,MAC7B,CAAC;
|
|
1
|
+
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/utils/numbers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,eAAO,MAAM,eAAe,MAAO,MAAM,yBAAkB,MAC7B,CAAC;AAE/B,eAAO,MAAM,eAAe,MAAO,MAAM,KAAG,MAM3C,CAAC;AAEF,eAAO,MAAM,cAAc,WACjB,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,gBAChC,MAAM,GAAG,IAAI,gBACb,MAAM,GAAG,IAAI,KACzB,MA6DF,CAAC;AAEF,eAAO,MAAM,qBAAqB,UACzB,SAAS,YACN,MAAM,KACf,MAEF,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,UAAU,KAAG,MAKpD,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAQrE;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAW5E;AAED,eAAO,MAAM,gBAAgB,SAAU,iBAAiB,GAAG,IAAI,WACc,CAAC;AAE9E,eAAO,MAAM,OAAO,SAAU,iBAAiB,KAAG,MAOnC,CAAC;AAEhB,eAAO,MAAM,YAAY,SAAU,MAAM,cAAc,MAAM,YACF,CAAC;AAE5D,eAAO,MAAM,gBAAgB,UAAW,MAAM,YACd,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProviderInterface } from '@rango-dev/wallets-
|
|
1
|
+
import { ProviderInterface } from '@rango-dev/wallets-react';
|
|
2
2
|
import { WidgetConfig } from '../types';
|
|
3
3
|
export interface ProvidersOptions {
|
|
4
4
|
walletConnectProjectId?: WidgetConfig['walletConnectProjectId'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB,CAAC,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAC;CACjE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,EAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,iBAAiB,EAAE,CAkCrB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,EAC/B,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,EAAE,CAMV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.12.0",
|
|
3
|
+
"version": "0.12.1-next.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lingui/core": "4.2.1",
|
|
21
21
|
"@lingui/react": "4.2.1",
|
|
22
|
-
"@rango-dev/provider-all": "^0.15.0",
|
|
22
|
+
"@rango-dev/provider-all": "^0.15.1-next.0",
|
|
23
23
|
"@rango-dev/queue-manager-core": "^0.15.0",
|
|
24
|
-
"@rango-dev/queue-manager-rango-preset": "^0.15.0",
|
|
24
|
+
"@rango-dev/queue-manager-rango-preset": "^0.15.1-next.0",
|
|
25
25
|
"@rango-dev/queue-manager-react": "^0.15.0",
|
|
26
|
-
"@rango-dev/ui": "^0.15.0",
|
|
27
|
-
"@rango-dev/wallets-
|
|
28
|
-
"@rango-dev/wallets-shared": "^0.15.0",
|
|
26
|
+
"@rango-dev/ui": "^0.15.1-next.0",
|
|
27
|
+
"@rango-dev/wallets-react": "^0.1.1-next.1",
|
|
28
|
+
"@rango-dev/wallets-shared": "^0.15.1-next.0",
|
|
29
29
|
"bignumber.js": "^9.1.1",
|
|
30
30
|
"copy-to-clipboard": "^3.3.3",
|
|
31
31
|
"dayjs": "^1.11.7",
|
package/src/QueueManager.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
SwapQueueContext,
|
|
6
6
|
checkWaitingForNetworkChange,
|
|
7
7
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
8
|
-
import { useWallets } from '@rango-dev/wallets-
|
|
8
|
+
import { useWallets } from '@rango-dev/wallets-react';
|
|
9
9
|
import {
|
|
10
10
|
convertEvmBlockchainMetaToEvmChainInfo,
|
|
11
11
|
Network,
|
package/src/Wallets.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { useMetaStore } from './store/meta';
|
|
3
|
-
import { Events, Provider } from '@rango-dev/wallets-
|
|
4
|
-
import { EventHandler } from '@rango-dev/wallets-
|
|
3
|
+
import { Events, Provider } from '@rango-dev/wallets-react';
|
|
4
|
+
import type { EventHandler } from '@rango-dev/wallets-react';
|
|
5
5
|
import { Network } from '@rango-dev/wallets-shared';
|
|
6
6
|
import {
|
|
7
7
|
prepareAccountsForWalletStore,
|
|
@@ -4,7 +4,7 @@ import { useQueueManager } from '@rango-dev/queue-manager-rango-preset';
|
|
|
4
4
|
import { WalletType } from '@rango-dev/wallets-shared';
|
|
5
5
|
import { UpdateUrl } from './UpdateUrl';
|
|
6
6
|
import { useMetaStore } from '../store/meta';
|
|
7
|
-
import { useWallets } from '@rango-dev/wallets-
|
|
7
|
+
import { useWallets } from '@rango-dev/wallets-react';
|
|
8
8
|
import { isEvmBlockchain } from 'rango-types';
|
|
9
9
|
|
|
10
10
|
export function AppRouter({
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
AddWalletIcon,
|
|
4
|
-
Typography,
|
|
5
|
-
styled,
|
|
6
|
-
Spinner,
|
|
7
|
-
Image,
|
|
8
|
-
} from '@rango-dev/ui';
|
|
9
1
|
import React, { useEffect } from 'react';
|
|
10
2
|
import { useNavigate } from 'react-router-dom';
|
|
11
|
-
import {
|
|
3
|
+
import { HeaderLayout } from '@rango-dev/ui';
|
|
4
|
+
import { useWallets } from '@rango-dev/wallets-react';
|
|
12
5
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
13
6
|
import { useUiStore } from '../store/ui';
|
|
14
7
|
import { AppRoutes } from './AppRoutes';
|
|
@@ -20,33 +13,10 @@ import {
|
|
|
20
13
|
} from '../utils/wallets';
|
|
21
14
|
import { removeDuplicateFrom } from '../utils/common';
|
|
22
15
|
import { WidgetConfig } from '../types';
|
|
23
|
-
import { i18n } from '@lingui/core';
|
|
24
16
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
25
17
|
import { useMetaStore } from '../store/meta';
|
|
26
18
|
import { useSettingsStore } from '../store/settings';
|
|
27
19
|
|
|
28
|
-
const Header = styled('div', {
|
|
29
|
-
display: 'flex',
|
|
30
|
-
width: '100%',
|
|
31
|
-
justifyContent: 'end',
|
|
32
|
-
'.balance': {
|
|
33
|
-
display: 'flex',
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const WalletImages = styled('div', {
|
|
38
|
-
display: 'flex',
|
|
39
|
-
paddingLeft: '12px',
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const WalletImageContainer = styled('div', {
|
|
43
|
-
marginLeft: -15,
|
|
44
|
-
marginRight: '$6',
|
|
45
|
-
'& img': {
|
|
46
|
-
borderRadius: '50%',
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
20
|
export type LayoutProps = {
|
|
51
21
|
config?: WidgetConfig;
|
|
52
22
|
};
|
|
@@ -119,40 +89,17 @@ export function Layout({ config }: LayoutProps) {
|
|
|
119
89
|
|
|
120
90
|
return (
|
|
121
91
|
<>
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}}
|
|
134
|
-
prefix={
|
|
135
|
-
connectedWalletsImages?.length ? (
|
|
136
|
-
<WalletImages>
|
|
137
|
-
{connectedWalletsImages.map((walletImage, index) => (
|
|
138
|
-
<WalletImageContainer key={index}>
|
|
139
|
-
<Image src={walletImage} size={24} />
|
|
140
|
-
</WalletImageContainer>
|
|
141
|
-
))}
|
|
142
|
-
</WalletImages>
|
|
143
|
-
) : null
|
|
144
|
-
}>
|
|
145
|
-
<div className="balance">
|
|
146
|
-
<Typography variant="body2">
|
|
147
|
-
{!connectedWallets?.length
|
|
148
|
-
? i18n.t('Connect Wallet')
|
|
149
|
-
: `$${totalBalance || 0}`}
|
|
150
|
-
</Typography>
|
|
151
|
-
{fetchingBalance && <Spinner />}
|
|
152
|
-
</div>
|
|
153
|
-
</Button>
|
|
154
|
-
</Header>
|
|
155
|
-
<AppRoutes config={config} />
|
|
92
|
+
<HeaderLayout
|
|
93
|
+
loadingStatus={loadingMetaStatus}
|
|
94
|
+
connectedWalletsImages={connectedWalletsImages}
|
|
95
|
+
connectedWallets={connectedWallets}
|
|
96
|
+
totalBalance={totalBalance}
|
|
97
|
+
fetchingBalance={fetchingBalance}
|
|
98
|
+
onClick={() => {
|
|
99
|
+
if (!connectWalletsButtonDisabled) navigate(navigationRoutes.wallets);
|
|
100
|
+
}}>
|
|
101
|
+
<AppRoutes config={config} />
|
|
102
|
+
</HeaderLayout>
|
|
156
103
|
</>
|
|
157
104
|
);
|
|
158
105
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { useSearchParams } from 'react-router-dom';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useInRouterContext, useSearchParams } from 'react-router-dom';
|
|
3
|
+
import { styled, Button, VerticalSwapIcon } from '@rango-dev/ui';
|
|
3
4
|
import { SearchParams } from '../constants/searchParams';
|
|
4
5
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
function SwithFromAndTo({ count }: { count: number }) {
|
|
7
8
|
const firstRender = useRef(true);
|
|
8
9
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
9
10
|
const outputAmount = useBestRouteStore.use.outputAmount();
|
|
@@ -19,7 +20,9 @@ export function SwithFromAndTo({ count }: { count: number }) {
|
|
|
19
20
|
...(toTokenString && { [SearchParams.FROM_TOKEN]: toTokenString }),
|
|
20
21
|
...(fromChainString && { [SearchParams.TO_CHAIN]: fromChainString }),
|
|
21
22
|
...(fromTokenString && { [SearchParams.TO_TOKEN]: fromTokenString }),
|
|
22
|
-
...(outputAmount && {
|
|
23
|
+
...(outputAmount && {
|
|
24
|
+
[SearchParams.FROM_AMOUNT]: outputAmount.toString(),
|
|
25
|
+
}),
|
|
23
26
|
});
|
|
24
27
|
} else {
|
|
25
28
|
firstRender.current = false;
|
|
@@ -28,3 +31,30 @@ export function SwithFromAndTo({ count }: { count: number }) {
|
|
|
28
31
|
|
|
29
32
|
return null;
|
|
30
33
|
}
|
|
34
|
+
|
|
35
|
+
const SwitchButtonContainer = styled('div', {
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
bottom: '-12px',
|
|
38
|
+
left: '50%',
|
|
39
|
+
transform: 'translate(-50%, 10%)',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export function SwithFromAndToButton() {
|
|
43
|
+
const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
|
|
44
|
+
const isRouterInContext = useInRouterContext();
|
|
45
|
+
const [count, setCount] = useState(0);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<SwitchButtonContainer>
|
|
49
|
+
<Button
|
|
50
|
+
variant="ghost"
|
|
51
|
+
onClick={() => {
|
|
52
|
+
switchFromAndTo();
|
|
53
|
+
setCount((prev) => prev + 1);
|
|
54
|
+
}}>
|
|
55
|
+
<VerticalSwapIcon size={32} />
|
|
56
|
+
{isRouterInContext && <SwithFromAndTo count={count} />}
|
|
57
|
+
</Button>
|
|
58
|
+
</SwitchButtonContainer>
|
|
59
|
+
);
|
|
60
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import { useNavigate } from 'react-router-dom';
|
|
3
3
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
4
4
|
import { useWalletsStore } from '../store/wallets';
|
|
5
|
-
import { useWallets } from '@rango-dev/wallets-
|
|
5
|
+
import { useWallets } from '@rango-dev/wallets-react';
|
|
6
6
|
import { i18n } from '@lingui/core';
|
|
7
7
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
8
8
|
import {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '../utils/wallets';
|
|
14
14
|
import {
|
|
15
15
|
confirmSwapDisabled,
|
|
16
|
+
getPercentageChange,
|
|
16
17
|
getTotalFeeInUsd,
|
|
17
18
|
isValidCustomDestination,
|
|
18
19
|
} from '../utils/swap';
|
|
@@ -20,14 +21,15 @@ import { numberToString } from '../utils/numbers';
|
|
|
20
21
|
import { useMetaStore } from '../store/meta';
|
|
21
22
|
import { WalletType } from '@rango-dev/wallets-shared';
|
|
22
23
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
23
|
-
import { TokenPreview } from '../components/TokenPreview';
|
|
24
24
|
import {
|
|
25
25
|
Divider,
|
|
26
26
|
ConfirmSwap,
|
|
27
27
|
LoadingFailedAlert,
|
|
28
28
|
HighSlippageWarning,
|
|
29
|
+
PercentageChange,
|
|
30
|
+
RoutesOverview,
|
|
31
|
+
TokenPreview,
|
|
29
32
|
} from '@rango-dev/ui';
|
|
30
|
-
import RoutesOverview from '../components/RoutesOverview';
|
|
31
33
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
32
34
|
import { useConfirmSwap } from '../hooks/useConfirmSwap';
|
|
33
35
|
import { useSettingsStore } from '../store/settings';
|
|
@@ -37,7 +39,6 @@ import { ConfirmSwapErrors } from '../components/ConfirmSwapErrors';
|
|
|
37
39
|
import { ConfirmSwapWarnings } from '../components/ConfirmSwapWarnings';
|
|
38
40
|
import { HIGH_SLIPPAGE } from '../constants/swapSettings';
|
|
39
41
|
import { getBestRouteStatus } from '../utils/routing';
|
|
40
|
-
import { PercentageChange } from '../components/PercentageChange';
|
|
41
42
|
|
|
42
43
|
export function ConfirmSwapPage({
|
|
43
44
|
customDestinationEnabled,
|
|
@@ -120,6 +121,14 @@ export function ConfirmSwapPage({
|
|
|
120
121
|
|
|
121
122
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
122
123
|
|
|
124
|
+
const percentageChange =
|
|
125
|
+
!inputUsdValue || !outputUsdValue || !outputUsdValue.gt(0)
|
|
126
|
+
? null
|
|
127
|
+
: getPercentageChange(
|
|
128
|
+
inputUsdValue.toNumber(),
|
|
129
|
+
outputUsdValue.toNumber()
|
|
130
|
+
);
|
|
131
|
+
|
|
123
132
|
return (
|
|
124
133
|
<ConfirmSwap
|
|
125
134
|
requiredWallets={getRequiredChains(bestRoute)}
|
|
@@ -182,7 +191,7 @@ export function ConfirmSwapPage({
|
|
|
182
191
|
symbol: firstStep?.from.symbol || '',
|
|
183
192
|
image: firstStep?.from.logo || '',
|
|
184
193
|
}}
|
|
185
|
-
usdValue={inputUsdValue}
|
|
194
|
+
usdValue={inputUsdValue ? numberToString(inputUsdValue) : null}
|
|
186
195
|
amount={fromAmount}
|
|
187
196
|
label={i18n.t('From')}
|
|
188
197
|
loadingStatus={
|
|
@@ -201,7 +210,7 @@ export function ConfirmSwapPage({
|
|
|
201
210
|
symbol: lastStep?.to.symbol || '',
|
|
202
211
|
image: lastStep?.to.logo || '',
|
|
203
212
|
}}
|
|
204
|
-
usdValue={outputUsdValue}
|
|
213
|
+
usdValue={outputUsdValue ? numberToString(outputUsdValue) : null}
|
|
205
214
|
amount={toAmount}
|
|
206
215
|
label={i18n.t('To')}
|
|
207
216
|
loadingStatus={
|
|
@@ -210,10 +219,12 @@ export function ConfirmSwapPage({
|
|
|
210
219
|
: bestRouteloadingStatus
|
|
211
220
|
}
|
|
212
221
|
percentageChange={
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
!percentageChange ? null : (
|
|
223
|
+
<PercentageChange
|
|
224
|
+
percentageChange={numberToString(percentageChange, 0, 2)}
|
|
225
|
+
showPercentageChange={!!percentageChange?.lt(0)}
|
|
226
|
+
/>
|
|
227
|
+
)
|
|
217
228
|
}
|
|
218
229
|
/>
|
|
219
230
|
</>
|