@rango-dev/widget-embedded 0.1.16-next.2 → 0.1.16-next.21
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 +15 -0
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/Footer.d.ts +111 -1
- package/dist/components/Footer.d.ts.map +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/RoutesOverview.d.ts +111 -1
- package/dist/components/RoutesOverview.d.ts.map +1 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts +111 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +2 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +11 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/common.d.ts +0 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +2 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +127 -159
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +127 -159
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +129 -156
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +16 -13
- package/src/QueueManager.tsx +4 -1
- package/src/components/AppRoutes.tsx +1 -1
- package/src/components/BottomLogo.tsx +1 -1
- package/src/components/Layout.tsx +23 -17
- package/src/components/RoutesOverview.tsx +4 -4
- package/src/components/TokenInfo.tsx +13 -12
- package/src/components/TokenPreview.tsx +9 -9
- package/src/components/warnings/BalanceErrors.tsx +2 -2
- package/src/components/warnings/MinRequiredSlippage.tsx +2 -2
- package/src/hooks/useTheme.ts +46 -63
- package/src/index.tsx +1 -7
- package/src/pages/ConfirmSwapPage.tsx +38 -28
- package/src/pages/SettingsPage.tsx +4 -2
- package/src/pages/SwapDetailsPage.tsx +1 -1
- package/src/pages/WalletsPage.tsx +6 -2
- package/src/store/wallets.ts +13 -11
- package/src/types/config.ts +8 -1
- package/src/utils/common.ts +0 -21
- package/src/utils/wallets.ts +7 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
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';
|
|
@@ -18,7 +18,7 @@ import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
|
18
18
|
import { TokenPreview } from '../components/TokenPreview';
|
|
19
19
|
// @ts-ignore // TODO: fix error in tsc build
|
|
20
20
|
import { t } from 'i18next';
|
|
21
|
-
import {
|
|
21
|
+
import { Divider, ConfirmSwap, LoadingFailedAlert } from '@rango-dev/ui';
|
|
22
22
|
import RoutesOverview from '../components/RoutesOverview';
|
|
23
23
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
24
24
|
import { useConfirmSwap } from '../hooks/useConfirmSwap';
|
|
@@ -49,7 +49,7 @@ export function ConfirmSwapPage() {
|
|
|
49
49
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
50
50
|
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
51
51
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
52
|
-
|
|
52
|
+
const [dbErrorMessage, setDbErrorMessage] = useState<string>('');
|
|
53
53
|
const bestRouteloadingStatus = getBestRouteStatus(
|
|
54
54
|
fetchingBestRoute,
|
|
55
55
|
!!fetchingBestRouteError
|
|
@@ -66,14 +66,14 @@ export function ConfirmSwapPage() {
|
|
|
66
66
|
const selectedSlippage = customSlippage || slippage;
|
|
67
67
|
|
|
68
68
|
const showHighSlippageWarning = !errors.find(
|
|
69
|
-
|
|
69
|
+
error => error.type === ConfirmSwapErrorTypes.INSUFFICIENT_SLIPPAGE
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
const { getWalletInfo, connect } = useWallets();
|
|
73
73
|
const confirmDisabled =
|
|
74
74
|
fetchingBestRoute ||
|
|
75
|
-
!requiredWallets(bestRoute).every(
|
|
76
|
-
selectedWallets.map(
|
|
75
|
+
!requiredWallets(bestRoute).every(chain =>
|
|
76
|
+
selectedWallets.map(wallet => wallet.chain).includes(chain)
|
|
77
77
|
);
|
|
78
78
|
|
|
79
79
|
const firstStep = bestRoute?.result?.swaps[0];
|
|
@@ -94,8 +94,10 @@ export function ConfirmSwapPage() {
|
|
|
94
94
|
|
|
95
95
|
const handleConnectChain = (wallet: string) => {
|
|
96
96
|
const network = wallet as Network;
|
|
97
|
-
getKeplrCompatibleConnectedWallets(
|
|
98
|
-
|
|
97
|
+
getKeplrCompatibleConnectedWallets(
|
|
98
|
+
selectableWallets
|
|
99
|
+
).forEach((compatibleWallet: WalletType) =>
|
|
100
|
+
connect?.(compatibleWallet, network)
|
|
99
101
|
);
|
|
100
102
|
};
|
|
101
103
|
|
|
@@ -106,28 +108,32 @@ export function ConfirmSwapPage() {
|
|
|
106
108
|
requiredWallets={getRequiredChains(bestRoute)}
|
|
107
109
|
selectableWallets={selectableWallets}
|
|
108
110
|
onBack={navigateBackFrom.bind(null, navigationRoutes.confirmSwap)}
|
|
109
|
-
onConfirm={() => {
|
|
110
|
-
confirmSwap?.().then(
|
|
111
|
+
onConfirm={async () => {
|
|
112
|
+
confirmSwap?.().then(async swap => {
|
|
111
113
|
if (swap) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
try {
|
|
115
|
+
await manager?.create(
|
|
116
|
+
'swap',
|
|
117
|
+
{ swapDetails: swap },
|
|
118
|
+
{ id: swap.requestId }
|
|
119
|
+
);
|
|
120
|
+
setSelectedSwap(swap.requestId);
|
|
121
|
+
navigate('/' + navigationRoutes.swaps + `/${swap.requestId}`, {
|
|
122
|
+
replace: true,
|
|
123
|
+
});
|
|
124
|
+
setTimeout(() => {
|
|
125
|
+
setInputAmount('');
|
|
126
|
+
}, 0);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
setDbErrorMessage('Error: ' + (e as any)?.message);
|
|
129
|
+
}
|
|
124
130
|
}
|
|
125
131
|
});
|
|
126
132
|
}}
|
|
127
|
-
onChange={
|
|
133
|
+
onChange={wallet => setSelectedWallet(wallet)}
|
|
128
134
|
confirmDisabled={loadingMetaStatus !== 'success' || confirmDisabled}
|
|
129
|
-
handleConnectChain={
|
|
130
|
-
isExperimentalChain={
|
|
135
|
+
handleConnectChain={wallet => handleConnectChain(wallet)}
|
|
136
|
+
isExperimentalChain={wallet =>
|
|
131
137
|
getKeplrCompatibleConnectedWallets(selectableWallets).length > 0
|
|
132
138
|
? isExperimentalChain(blockchains, wallet)
|
|
133
139
|
: false
|
|
@@ -152,7 +158,7 @@ export function ConfirmSwapPage() {
|
|
|
152
158
|
: bestRouteloadingStatus
|
|
153
159
|
}
|
|
154
160
|
/>
|
|
155
|
-
<
|
|
161
|
+
<Divider size={12} />
|
|
156
162
|
<TokenPreview
|
|
157
163
|
chain={{
|
|
158
164
|
displayName: lastStep?.to.blockchain || '',
|
|
@@ -186,13 +192,17 @@ export function ConfirmSwapPage() {
|
|
|
186
192
|
/>
|
|
187
193
|
}
|
|
188
194
|
loading={fetchingConfirmedRoute}
|
|
189
|
-
errors={
|
|
195
|
+
errors={
|
|
196
|
+
dbErrorMessage
|
|
197
|
+
? [dbErrorMessage, ...ConfirmSwapErrors(errors)]
|
|
198
|
+
: ConfirmSwapErrors(errors)
|
|
199
|
+
}
|
|
190
200
|
warnings={ConfirmSwapWarnings(warnings)}
|
|
191
201
|
extraMessages={
|
|
192
202
|
<>
|
|
193
203
|
{loadingMetaStatus === 'failed' && <LoadingFailedAlert />}
|
|
194
204
|
{loadingMetaStatus === 'failed' && showHighSlippageWarning && (
|
|
195
|
-
<
|
|
205
|
+
<Divider />
|
|
196
206
|
)}
|
|
197
207
|
{showHighSlippageWarning && (
|
|
198
208
|
<ConfirmSwapExtraMessages selectedSlippage={selectedSlippage} />
|
|
@@ -13,8 +13,9 @@ import {
|
|
|
13
13
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
14
14
|
interface PropTypes {
|
|
15
15
|
supportedSwappers?: string[];
|
|
16
|
+
singleTheme?: boolean;
|
|
16
17
|
}
|
|
17
|
-
export function SettingsPage({ supportedSwappers }: PropTypes) {
|
|
18
|
+
export function SettingsPage({ supportedSwappers, singleTheme }: PropTypes) {
|
|
18
19
|
const slippage = useSettingsStore.use.slippage();
|
|
19
20
|
const setSlippage = useSettingsStore.use.setSlippage();
|
|
20
21
|
const disabledLiquiditySources =
|
|
@@ -77,7 +78,8 @@ export function SettingsPage({ supportedSwappers }: PropTypes) {
|
|
|
77
78
|
selectedLiquiditySources={supportedUniqueSwappersGroups.filter(
|
|
78
79
|
(s) => s.selected
|
|
79
80
|
)}
|
|
80
|
-
|
|
81
|
+
singleTheme={singleTheme}
|
|
82
|
+
customSlippage={customSlippage}
|
|
81
83
|
onCustomSlippageChange={setCustomSlippage}
|
|
82
84
|
minSlippage={MIN_SLIPPGAE}
|
|
83
85
|
maxSlippage={MAX_SLIPPAGE}
|
|
@@ -8,7 +8,11 @@ import {
|
|
|
8
8
|
} from '@rango-dev/ui';
|
|
9
9
|
import React, { useEffect, useRef, useState } from 'react';
|
|
10
10
|
import { getlistWallet, sortWalletsBasedOnState } from '../utils/wallets';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
WalletType,
|
|
13
|
+
WalletTypes,
|
|
14
|
+
detectMobileScreens,
|
|
15
|
+
} from '@rango-dev/wallets-shared';
|
|
12
16
|
import { useWallets } from '@rango-dev/wallets-core';
|
|
13
17
|
|
|
14
18
|
import { useUiStore } from '../store/ui';
|
|
@@ -50,7 +54,7 @@ export function WalletsPage({ supportedWallets, multiWallets }: PropTypes) {
|
|
|
50
54
|
const wallets = getlistWallet(
|
|
51
55
|
state,
|
|
52
56
|
getWalletInfo,
|
|
53
|
-
supportedWallets || Object.values(
|
|
57
|
+
supportedWallets || Object.values(WalletTypes)
|
|
54
58
|
);
|
|
55
59
|
const walletsRef = useRef<WalletInfo[]>();
|
|
56
60
|
|
package/src/store/wallets.ts
CHANGED
|
@@ -55,17 +55,19 @@ export const useWalletsStore = createSelectors(
|
|
|
55
55
|
connectWallet: (accounts) => {
|
|
56
56
|
const getOneOfWalletsDetails = get().getOneOfWalletsDetails;
|
|
57
57
|
set((state) => ({
|
|
58
|
-
connectedWallets: state.connectedWallets
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
connectedWallets: state.connectedWallets
|
|
59
|
+
.filter((wallet) => wallet.walletType !== accounts[0].walletType)
|
|
60
|
+
.concat(
|
|
61
|
+
accounts.map((account) => ({
|
|
62
|
+
balances: [],
|
|
63
|
+
address: account.address,
|
|
64
|
+
chain: account.chain,
|
|
65
|
+
loading: true,
|
|
66
|
+
walletType: account.walletType,
|
|
67
|
+
error: false,
|
|
68
|
+
explorerUrl: null,
|
|
69
|
+
}))
|
|
70
|
+
),
|
|
69
71
|
}));
|
|
70
72
|
accounts.forEach(async (account) => getOneOfWalletsDetails(account));
|
|
71
73
|
},
|
package/src/types/config.ts
CHANGED
|
@@ -9,6 +9,9 @@ import { WalletType } from '@rango-dev/wallets-shared';
|
|
|
9
9
|
* @property {string} success
|
|
10
10
|
* @property {string} error
|
|
11
11
|
* @property {string} warning
|
|
12
|
+
* @property {string} surface
|
|
13
|
+
* @property {string} neutral
|
|
14
|
+
|
|
12
15
|
*/
|
|
13
16
|
export type WidgetColors = {
|
|
14
17
|
background?: string;
|
|
@@ -17,6 +20,8 @@ export type WidgetColors = {
|
|
|
17
20
|
success?: string;
|
|
18
21
|
error?: string;
|
|
19
22
|
warning?: string;
|
|
23
|
+
surface?: string;
|
|
24
|
+
neutral?: string;
|
|
20
25
|
};
|
|
21
26
|
|
|
22
27
|
/**
|
|
@@ -33,14 +38,16 @@ export type WidgetColors = {
|
|
|
33
38
|
* specifies the radius of the corners of a widget.
|
|
34
39
|
* @property {number} width - The `width` property is a number that represents the width of the widget.
|
|
35
40
|
* @property {number} height - The `height` property is a number that specifies the height of the widget.
|
|
41
|
+
* @property {boolean} singleTheme - The `singleTheme` property is a boolean that specifies the theme is support dark and light or only light.
|
|
36
42
|
*/
|
|
37
43
|
export type WidgetTheme = {
|
|
38
44
|
mode?: 'auto' | 'light' | 'dark';
|
|
39
45
|
fontFamily?: string;
|
|
40
|
-
colors?: WidgetColors;
|
|
46
|
+
colors?: { light: WidgetColors; dark: WidgetColors };
|
|
41
47
|
borderRadius?: number;
|
|
42
48
|
width?: number;
|
|
43
49
|
height?: number;
|
|
50
|
+
singleTheme?: boolean;
|
|
44
51
|
};
|
|
45
52
|
|
|
46
53
|
/**
|
package/src/utils/common.ts
CHANGED
|
@@ -10,29 +10,8 @@ export function areEqual(
|
|
|
10
10
|
array1.length === array2.length && array1.every((v, i) => v === array2[i])
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
|
-
export function shadeColor(color: string, percent: number) {
|
|
14
|
-
var R = parseInt(color.substring(1, 3), 16);
|
|
15
|
-
var G = parseInt(color.substring(3, 5), 16);
|
|
16
|
-
var B = parseInt(color.substring(5, 7), 16);
|
|
17
13
|
|
|
18
|
-
R = (R * (100 + percent)) / 100;
|
|
19
|
-
G = (G * (100 + percent)) / 100;
|
|
20
|
-
B = (B * (100 + percent)) / 100;
|
|
21
14
|
|
|
22
|
-
R = R < 255 ? R : 255;
|
|
23
|
-
G = G < 255 ? G : 255;
|
|
24
|
-
B = B < 255 ? B : 255;
|
|
25
|
-
|
|
26
|
-
R = Math.round(R);
|
|
27
|
-
G = Math.round(G);
|
|
28
|
-
B = Math.round(B);
|
|
29
|
-
|
|
30
|
-
var RR = R.toString(16).length == 1 ? '0' + R.toString(16) : R.toString(16);
|
|
31
|
-
var GG = G.toString(16).length == 1 ? '0' + G.toString(16) : G.toString(16);
|
|
32
|
-
var BB = B.toString(16).length == 1 ? '0' + B.toString(16) : B.toString(16);
|
|
33
|
-
|
|
34
|
-
return '#' + RR + GG + BB;
|
|
35
|
-
}
|
|
36
15
|
|
|
37
16
|
export function debounce(fn: Function, time: number) {
|
|
38
17
|
let timeoutId: ReturnType<typeof setTimeout> | null;
|
package/src/utils/wallets.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
WalletType,
|
|
8
8
|
detectInstallLink,
|
|
9
9
|
WalletInfo,
|
|
10
|
+
WalletTypes,
|
|
10
11
|
} from '@rango-dev/wallets-shared';
|
|
11
12
|
|
|
12
13
|
import {
|
|
@@ -42,25 +43,15 @@ export function getStateWallet(state: WalletState): WalletStatus {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export const excludedWallets = [
|
|
46
|
-
WalletType.UNKNOWN,
|
|
47
|
-
WalletType.TERRA_STATION,
|
|
48
|
-
WalletType.LEAP,
|
|
49
|
-
];
|
|
46
|
+
export const excludedWallets = [WalletTypes.LEAP];
|
|
50
47
|
|
|
51
48
|
export function getlistWallet(
|
|
52
49
|
getState: (type: WalletType) => WalletState,
|
|
53
50
|
getWalletInfo: (type: WalletType) => WalletInfo,
|
|
54
51
|
list: WalletType[]
|
|
55
52
|
): ModalWalletInfo[] {
|
|
56
|
-
const excludedWallets = [
|
|
57
|
-
WalletType.UNKNOWN,
|
|
58
|
-
WalletType.TERRA_STATION,
|
|
59
|
-
WalletType.LEAP,
|
|
60
|
-
];
|
|
61
|
-
|
|
62
53
|
return list
|
|
63
|
-
.filter((wallet) => !excludedWallets.includes(wallet))
|
|
54
|
+
.filter((wallet) => !excludedWallets.includes(wallet as WalletTypes))
|
|
64
55
|
.map((type) => {
|
|
65
56
|
const {
|
|
66
57
|
name,
|
|
@@ -236,8 +227,7 @@ export function isAccountAndWalletMatched(
|
|
|
236
227
|
) {
|
|
237
228
|
return (
|
|
238
229
|
account.address === connectedWallet.address &&
|
|
239
|
-
account.chain === connectedWallet.chain
|
|
240
|
-
account.walletType === connectedWallet.walletType
|
|
230
|
+
account.chain === connectedWallet.chain
|
|
241
231
|
);
|
|
242
232
|
}
|
|
243
233
|
|
|
@@ -388,7 +378,9 @@ export const getKeplrCompatibleConnectedWallets = (
|
|
|
388
378
|
selectableWallets: SelectableWallet[]
|
|
389
379
|
): WalletType[] => {
|
|
390
380
|
const connectedWalletTypes = new Set(
|
|
391
|
-
selectableWallets.map((
|
|
381
|
+
selectableWallets.map((wallet) => {
|
|
382
|
+
return wallet.walletType;
|
|
383
|
+
})
|
|
392
384
|
);
|
|
393
385
|
|
|
394
386
|
return KEPLR_COMPATIBLE_WALLETS.filter((compatibleWallet) =>
|