@rango-dev/widget-embedded 0.11.1-next.3 → 0.12.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 +4 -0
- 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/PercentageChange.d.ts +9 -0
- package/dist/components/PercentageChange.d.ts.map +1 -0
- package/dist/components/RoutesOverview.d.ts +120 -0
- package/dist/components/RoutesOverview.d.ts.map +1 -0
- package/dist/components/SwapDetailsPlaceholder.d.ts +120 -0
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -0
- package/dist/components/SwitchFromAndTo.d.ts +3 -2
- package/dist/components/SwitchFromAndTo.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts +18 -0
- package/dist/components/TokenInfo.d.ts.map +1 -0
- package/dist/components/TokenPreview.d.ts +21 -0
- package/dist/components/TokenPreview.d.ts.map +1 -0
- 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 +8 -8
- package/src/QueueManager.tsx +1 -1
- package/src/Wallets.tsx +2 -2
- package/src/components/AppRouter.tsx +1 -1
- package/src/components/Layout.tsx +66 -13
- package/src/components/PercentageChange.tsx +33 -0
- package/src/components/RoutesOverview.tsx +57 -0
- package/src/components/SwapDetailsPlaceholder.tsx +47 -0
- package/src/components/SwitchFromAndTo.tsx +4 -34
- package/src/components/TokenInfo.tsx +329 -0
- package/src/components/TokenPreview.tsx +187 -0
- package/src/hooks/useWalletProviders.ts +1 -1
- package/src/index.ts +1 -1
- package/src/languages/en.json +14 -0
- package/src/languages/tr.json +11 -0
- package/src/pages/ConfirmSwapPage.tsx +10 -21
- package/src/pages/Home.tsx +144 -101
- package/src/pages/SwapDetailsPage.tsx +3 -6
- package/src/pages/WalletsPage.tsx +1 -1
- package/src/types/config.ts +1 -1
- package/src/utils/numbers.ts +0 -2
- package/src/utils/providers.ts +1 -1
- package/src/utils/wallets.ts +1 -1
|
@@ -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;AAyCnD,wBAAgB,eAAe,CAAC,EAC9B,wBAAwB,GACzB,EAAE;IACD,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,qBAgNA"}
|
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":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AA+DnD,wBAAgB,IAAI,sBA+JnB"}
|
|
@@ -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;AA6B1B,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-core';
|
|
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,yBAAyB,CAAC;AAC5D,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;AAC/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,MAIpD,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-core';
|
|
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,yBAAyB,CAAC;AAC5D,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.
|
|
3
|
+
"version": "0.12.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.
|
|
23
|
-
"@rango-dev/queue-manager-core": "^0.
|
|
24
|
-
"@rango-dev/queue-manager-rango-preset": "^0.
|
|
25
|
-
"@rango-dev/queue-manager-react": "^0.
|
|
26
|
-
"@rango-dev/ui": "^0.
|
|
27
|
-
"@rango-dev/wallets-
|
|
28
|
-
"@rango-dev/wallets-shared": "^0.
|
|
22
|
+
"@rango-dev/provider-all": "^0.15.0",
|
|
23
|
+
"@rango-dev/queue-manager-core": "^0.15.0",
|
|
24
|
+
"@rango-dev/queue-manager-rango-preset": "^0.15.0",
|
|
25
|
+
"@rango-dev/queue-manager-react": "^0.15.0",
|
|
26
|
+
"@rango-dev/ui": "^0.15.0",
|
|
27
|
+
"@rango-dev/wallets-core": "^0.15.0",
|
|
28
|
+
"@rango-dev/wallets-shared": "^0.15.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-core';
|
|
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
|
|
3
|
+
import { Events, Provider } from '@rango-dev/wallets-core';
|
|
4
|
+
import { EventHandler } from '@rango-dev/wallets-core';
|
|
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-core';
|
|
8
8
|
import { isEvmBlockchain } from 'rango-types';
|
|
9
9
|
|
|
10
10
|
export function AppRouter({
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
AddWalletIcon,
|
|
4
|
+
Typography,
|
|
5
|
+
styled,
|
|
6
|
+
Spinner,
|
|
7
|
+
Image,
|
|
8
|
+
} from '@rango-dev/ui';
|
|
1
9
|
import React, { useEffect } from 'react';
|
|
2
10
|
import { useNavigate } from 'react-router-dom';
|
|
3
|
-
import {
|
|
4
|
-
import { useWallets } from '@rango-dev/wallets-react';
|
|
11
|
+
import { useWallets } from '@rango-dev/wallets-core';
|
|
5
12
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
6
13
|
import { useUiStore } from '../store/ui';
|
|
7
14
|
import { AppRoutes } from './AppRoutes';
|
|
@@ -13,10 +20,33 @@ import {
|
|
|
13
20
|
} from '../utils/wallets';
|
|
14
21
|
import { removeDuplicateFrom } from '../utils/common';
|
|
15
22
|
import { WidgetConfig } from '../types';
|
|
23
|
+
import { i18n } from '@lingui/core';
|
|
16
24
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
17
25
|
import { useMetaStore } from '../store/meta';
|
|
18
26
|
import { useSettingsStore } from '../store/settings';
|
|
19
27
|
|
|
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
|
+
|
|
20
50
|
export type LayoutProps = {
|
|
21
51
|
config?: WidgetConfig;
|
|
22
52
|
};
|
|
@@ -89,17 +119,40 @@ export function Layout({ config }: LayoutProps) {
|
|
|
89
119
|
|
|
90
120
|
return (
|
|
91
121
|
<>
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
122
|
+
<Header>
|
|
123
|
+
<Button
|
|
124
|
+
size="small"
|
|
125
|
+
suffix={<AddWalletIcon size={20} />}
|
|
126
|
+
variant="ghost"
|
|
127
|
+
flexContent
|
|
128
|
+
loading={loadingMetaStatus === 'loading'}
|
|
129
|
+
disabled={loadingMetaStatus === 'failed'}
|
|
130
|
+
onClick={() => {
|
|
131
|
+
if (!connectWalletsButtonDisabled)
|
|
132
|
+
navigate(navigationRoutes.wallets);
|
|
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} />
|
|
103
156
|
</>
|
|
104
157
|
);
|
|
105
158
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { getPercentageChange } from '../utils/swap';
|
|
4
|
+
import { Typography } from '@rango-dev/ui';
|
|
5
|
+
import { numberToString } from '../utils/numbers';
|
|
6
|
+
|
|
7
|
+
interface PropTypes {
|
|
8
|
+
inputUsdValue: BigNumber | null;
|
|
9
|
+
outputUsdValue: BigNumber | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function PercentageChange(props: PropTypes) {
|
|
13
|
+
const { inputUsdValue, outputUsdValue } = props;
|
|
14
|
+
|
|
15
|
+
if (!inputUsdValue || !outputUsdValue || !outputUsdValue.gt(0)) return null;
|
|
16
|
+
|
|
17
|
+
const percentageChange = getPercentageChange(
|
|
18
|
+
inputUsdValue.toNumber(),
|
|
19
|
+
outputUsdValue.toNumber()
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const showPercentageChange = percentageChange?.lt(0);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
{showPercentageChange && (
|
|
27
|
+
<Typography variant="caption" color="$error500">
|
|
28
|
+
{`(${numberToString(percentageChange, 0, 2)}%)`}
|
|
29
|
+
</Typography>
|
|
30
|
+
)}
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { styled, ChevronRightIcon, GasIcon, Divider } from '@rango-dev/ui';
|
|
3
|
+
import { BestRouteResponse } from 'rango-sdk';
|
|
4
|
+
|
|
5
|
+
export const Container = styled('div', {
|
|
6
|
+
display: 'flex',
|
|
7
|
+
alignItems: 'center',
|
|
8
|
+
justifyContent: 'space-between',
|
|
9
|
+
padding: '$8',
|
|
10
|
+
borderRadius: '$5',
|
|
11
|
+
backgroundColor: '$neutral100',
|
|
12
|
+
color: '$neutral800',
|
|
13
|
+
fontSize: '$12',
|
|
14
|
+
|
|
15
|
+
'.routes': {
|
|
16
|
+
display: 'flex',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
},
|
|
19
|
+
'.fee': {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
interface PropTypes {
|
|
26
|
+
routes: BestRouteResponse | null;
|
|
27
|
+
totalFee?: string;
|
|
28
|
+
}
|
|
29
|
+
function RoutesOverview(props: PropTypes) {
|
|
30
|
+
if (!props.routes) return null;
|
|
31
|
+
|
|
32
|
+
const swaps = props.routes.result?.swaps;
|
|
33
|
+
return (
|
|
34
|
+
<Container>
|
|
35
|
+
<div className="routes">
|
|
36
|
+
{swaps?.map((swap, idx) => {
|
|
37
|
+
const isLast = idx + 1 == swaps.length;
|
|
38
|
+
return (
|
|
39
|
+
<React.Fragment key={idx}>
|
|
40
|
+
<div className="route">{swap.from.symbol}</div>
|
|
41
|
+
<ChevronRightIcon size={12} />
|
|
42
|
+
{isLast ? <div className="route">{swap.to.symbol}</div> : null}
|
|
43
|
+
</React.Fragment>
|
|
44
|
+
);
|
|
45
|
+
})}
|
|
46
|
+
</div>
|
|
47
|
+
{props.totalFee ? (
|
|
48
|
+
<div className="fee">
|
|
49
|
+
<GasIcon size={12} />
|
|
50
|
+
<Divider size={4} direction="horizontal" />${props.totalFee}
|
|
51
|
+
</div>
|
|
52
|
+
) : null}
|
|
53
|
+
</Container>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default RoutesOverview;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SecondaryPage, Spinner, Alert, styled } from '@rango-dev/ui';
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
|
|
5
|
+
const PlaceholderContainer = styled('div', { height: '450px' });
|
|
6
|
+
|
|
7
|
+
export const LoaderContainer = styled('div', {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
width: '100%',
|
|
11
|
+
paddingTop: '33%',
|
|
12
|
+
flex: 1,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
interface PropTypes {
|
|
16
|
+
requestId: string;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
onBack: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function SwapDetailsPlaceholder(props: PropTypes) {
|
|
22
|
+
const { requestId, loading, onBack } = props;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<SecondaryPage
|
|
26
|
+
title={i18n.t('Swap Details')}
|
|
27
|
+
textField={false}
|
|
28
|
+
onBack={onBack}>
|
|
29
|
+
<PlaceholderContainer>
|
|
30
|
+
{loading ? (
|
|
31
|
+
<LoaderContainer>
|
|
32
|
+
<Spinner size={24} />
|
|
33
|
+
</LoaderContainer>
|
|
34
|
+
) : (
|
|
35
|
+
<Alert
|
|
36
|
+
type="secondary"
|
|
37
|
+
title={i18n.t(
|
|
38
|
+
'swapNotFound',
|
|
39
|
+
{ requestId },
|
|
40
|
+
{ message: 'Swap with request ID = ${requestId} not found.' }
|
|
41
|
+
)}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
</PlaceholderContainer>
|
|
45
|
+
</SecondaryPage>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { styled, Button, VerticalSwapIcon } from '@rango-dev/ui';
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useSearchParams } from 'react-router-dom';
|
|
4
3
|
import { SearchParams } from '../constants/searchParams';
|
|
5
4
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
6
5
|
|
|
7
|
-
function SwithFromAndTo({ count }: { count: number }) {
|
|
6
|
+
export function SwithFromAndTo({ count }: { count: number }) {
|
|
8
7
|
const firstRender = useRef(true);
|
|
9
8
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
10
9
|
const outputAmount = useBestRouteStore.use.outputAmount();
|
|
@@ -20,9 +19,7 @@ function SwithFromAndTo({ count }: { count: number }) {
|
|
|
20
19
|
...(toTokenString && { [SearchParams.FROM_TOKEN]: toTokenString }),
|
|
21
20
|
...(fromChainString && { [SearchParams.TO_CHAIN]: fromChainString }),
|
|
22
21
|
...(fromTokenString && { [SearchParams.TO_TOKEN]: fromTokenString }),
|
|
23
|
-
...(outputAmount && {
|
|
24
|
-
[SearchParams.FROM_AMOUNT]: outputAmount.toString(),
|
|
25
|
-
}),
|
|
22
|
+
...(outputAmount && { [SearchParams.FROM_AMOUNT]: outputAmount.toString() }),
|
|
26
23
|
});
|
|
27
24
|
} else {
|
|
28
25
|
firstRender.current = false;
|
|
@@ -31,30 +28,3 @@ function SwithFromAndTo({ count }: { count: number }) {
|
|
|
31
28
|
|
|
32
29
|
return null;
|
|
33
30
|
}
|
|
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
|
-
}
|