@rango-dev/widget-embedded 0.1.11-next.17 → 0.1.11-next.20
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/dist/components/SwapDetailsPlaceholder.d.ts +1 -0
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/pages/HistoryPage.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/pages/WalletsPage.d.ts +0 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +30 -8
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +30 -8
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +30 -8
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/app.css +0 -9
- package/src/components/SwapDetailsPlaceholder.tsx +8 -1
- package/src/components/TokenInfo.tsx +1 -0
- package/src/lib.tsx +10 -1
- package/src/pages/HistoryPage.tsx +4 -1
- package/src/pages/Home.tsx +3 -2
- package/src/pages/SwapDetailsPage.tsx +2 -9
- package/src/pages/WalletsPage.tsx +2 -2
- package/src/utils/configs.ts +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.1.11-next.
|
|
3
|
+
"version": "0.1.11-next.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@rango-dev/queue-manager-core": "^0.1.11-next.0",
|
|
33
33
|
"@rango-dev/queue-manager-rango-preset": "^0.1.11-next.3",
|
|
34
34
|
"@rango-dev/queue-manager-react": "^0.1.10-next.76",
|
|
35
|
-
"@rango-dev/ui": "^0.1.11-next.
|
|
35
|
+
"@rango-dev/ui": "^0.1.11-next.9",
|
|
36
36
|
"@rango-dev/wallets-core": "^0.1.11-next.88",
|
|
37
37
|
"@rango-dev/wallets-shared": "^0.1.11-next.84",
|
|
38
38
|
"bignumber.js": "^9.1.1",
|
package/src/app.css
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SecondaryPage, Spinner, Alert, styled } from '@rango-dev/ui';
|
|
3
|
-
import { LoaderContainer } from '../pages/WalletsPage';
|
|
4
3
|
|
|
5
4
|
const PlaceholderContainer = styled('div', { height: '450px' });
|
|
6
5
|
|
|
6
|
+
export const LoaderContainer = styled('div', {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
justifyContent: 'center',
|
|
9
|
+
width: '100%',
|
|
10
|
+
paddingTop: '33%',
|
|
11
|
+
flex: 1,
|
|
12
|
+
});
|
|
13
|
+
|
|
7
14
|
interface PropTypes {
|
|
8
15
|
requestId: string;
|
|
9
16
|
loading: boolean;
|
package/src/lib.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SwapContainer } from '@rango-dev/ui';
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { AppRouter } from './components/AppRouter';
|
|
4
4
|
import { useMetaStore } from './store/meta';
|
|
5
5
|
import { Events, Provider } from '@rango-dev/wallets-core';
|
|
@@ -21,6 +21,7 @@ import './i18n';
|
|
|
21
21
|
import QueueManager from './QueueManager';
|
|
22
22
|
import { useUiStore } from './store/ui';
|
|
23
23
|
import { navigationRoutes } from './constants/navigationRoutes';
|
|
24
|
+
import { initConfig } from './utils/configs';
|
|
24
25
|
|
|
25
26
|
export type WidgetProps = {
|
|
26
27
|
config?: WidgetConfig;
|
|
@@ -45,6 +46,14 @@ export const SwapBox: React.FC<WidgetProps> = ({ config }) => {
|
|
|
45
46
|
.filter(isEvmBlockchain)
|
|
46
47
|
.map((chain) => chain.name);
|
|
47
48
|
|
|
49
|
+
useMemo(() => {
|
|
50
|
+
if (config?.apiKey) {
|
|
51
|
+
initConfig({
|
|
52
|
+
API_KEY: config?.apiKey,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}, [config]);
|
|
56
|
+
|
|
48
57
|
const onUpdateState: EventHandler = (
|
|
49
58
|
type,
|
|
50
59
|
event,
|
|
@@ -15,11 +15,14 @@ export function HistoryPage() {
|
|
|
15
15
|
const { manager } = useManager();
|
|
16
16
|
const pendingSwaps = getPendingSwaps(manager).map(({ swap }) => swap);
|
|
17
17
|
|
|
18
|
+
const loading = !manager?.isLoaded();
|
|
19
|
+
|
|
18
20
|
return (
|
|
19
21
|
<History
|
|
20
22
|
list={pendingSwaps}
|
|
21
23
|
groupBy={groupSwapsByDate}
|
|
22
|
-
|
|
24
|
+
loading={loading}
|
|
25
|
+
onSwapClick={(requestId) => {
|
|
23
26
|
setSelectedSwap(requestId);
|
|
24
27
|
navigate(navigationRoutes.swaps + `/${requestId}`, { replace: true });
|
|
25
28
|
}}
|
package/src/pages/Home.tsx
CHANGED
|
@@ -192,8 +192,9 @@ export function Home() {
|
|
|
192
192
|
<Alert type="error" title={`${swap?.swapperId} Limit`}>
|
|
193
193
|
<>
|
|
194
194
|
<Typography variant="body3">
|
|
195
|
-
{fromAmountRangeError}, Yours: {numberToString(
|
|
196
|
-
|
|
195
|
+
{`${fromAmountRangeError}, Yours: ${numberToString(
|
|
196
|
+
swap?.fromAmount || null
|
|
197
|
+
)} ${swap?.from.symbol}`}
|
|
197
198
|
</Typography>
|
|
198
199
|
<Typography variant="body3">{recommendation}</Typography>
|
|
199
200
|
</>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
3
3
|
import useCopyToClipboard from '../hooks/useCopyToClipboard';
|
|
4
4
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
@@ -39,14 +39,6 @@ export function SwapDetailsPage() {
|
|
|
39
39
|
const [isCopied, handleCopy] = useCopyToClipboard(2000);
|
|
40
40
|
const { manager } = useManager();
|
|
41
41
|
|
|
42
|
-
const [loading, setLoading] = useState(true);
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
setTimeout(() => {
|
|
46
|
-
setLoading(false);
|
|
47
|
-
}, 5_000);
|
|
48
|
-
}, []);
|
|
49
|
-
|
|
50
42
|
const pendingSwaps = getPendingSwaps(manager);
|
|
51
43
|
const selectedSwap = pendingSwaps.find(
|
|
52
44
|
({ swap }) => swap.requestId === selectedSwapRequestId
|
|
@@ -57,6 +49,7 @@ export function SwapDetailsPage() {
|
|
|
57
49
|
if (swap) cancelSwap(swap);
|
|
58
50
|
};
|
|
59
51
|
const swap = selectedSwap?.swap;
|
|
52
|
+
const loading = !manager?.isLoaded();
|
|
60
53
|
|
|
61
54
|
if (!swap)
|
|
62
55
|
return (
|
|
@@ -33,7 +33,7 @@ const ListContainer = styled('div', {
|
|
|
33
33
|
overflowY: 'auto',
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
const LoaderContainer = styled('div', {
|
|
37
37
|
display: 'flex',
|
|
38
38
|
justifyContent: 'center',
|
|
39
39
|
width: '100%',
|
|
@@ -113,7 +113,7 @@ export function WalletsPage({ supportedWallets, multiWallets }: PropTypes) {
|
|
|
113
113
|
<>
|
|
114
114
|
{walletErrorMessage && (
|
|
115
115
|
<AlertContainer>
|
|
116
|
-
<Alert type="error" title={walletErrorMessage}/>
|
|
116
|
+
<Alert type="error" title={walletErrorMessage} />
|
|
117
117
|
</AlertContainer>
|
|
118
118
|
)}
|
|
119
119
|
{loadingMetaStatus === 'loading' && (
|
package/src/utils/configs.ts
CHANGED
|
@@ -19,6 +19,12 @@ export function setConfig(name: keyof Configs, value: any) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function initConfig(nextConfigs: Configs) {
|
|
22
|
-
|
|
22
|
+
let clonedConfigs;
|
|
23
|
+
if (typeof structuredClone === 'function') {
|
|
24
|
+
clonedConfigs = structuredClone(nextConfigs);
|
|
25
|
+
} else {
|
|
26
|
+
clonedConfigs = JSON.parse(JSON.stringify(nextConfigs));
|
|
27
|
+
}
|
|
28
|
+
configs = clonedConfigs;
|
|
23
29
|
return configs;
|
|
24
30
|
}
|