@rango-dev/widget-embedded 0.1.11-next.11 → 0.1.11-next.12
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/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/utils/routing.d.ts +4 -4
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +230 -199
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +230 -199
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +230 -199
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/pages/ConfirmSwapPage.tsx +3 -1
- package/src/pages/Home.tsx +2 -1
- package/src/pages/SwapDetailsPage.tsx +6 -12
- package/src/utils/routing.ts +31 -11
package/package.json
CHANGED
package/src/pages/Home.tsx
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
import BigNumber from 'bignumber.js';
|
|
37
37
|
import { HeaderButtons } from '../components/HeaderButtons';
|
|
38
38
|
import { useUiStore } from '../store/ui';
|
|
39
|
+
import { getFormatedBestRoute } from '../utils/routing';
|
|
39
40
|
|
|
40
41
|
const Container = styled('div', {
|
|
41
42
|
display: 'flex',
|
|
@@ -177,7 +178,7 @@ export function Home() {
|
|
|
177
178
|
<BestRoute
|
|
178
179
|
error={bestRouteError}
|
|
179
180
|
loading={fetchingBestRoute}
|
|
180
|
-
data={bestRoute}
|
|
181
|
+
data={getFormatedBestRoute(bestRoute)}
|
|
181
182
|
totalFee={numberToString(totalFeeInUsd, 0, 2)}
|
|
182
183
|
feeWarning={highFee}
|
|
183
184
|
totalTime={secondsToString(totalArrivalTime(bestRoute))}
|
|
@@ -4,7 +4,7 @@ import useCopyToClipboard from '../hooks/useCopyToClipboard';
|
|
|
4
4
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
5
5
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
6
6
|
import { getPendingSwaps } from '../utils/queue';
|
|
7
|
-
import { SwapHistory
|
|
7
|
+
import { SwapHistory } from '@rango-dev/ui';
|
|
8
8
|
import { useUiStore } from '../store/ui';
|
|
9
9
|
import {
|
|
10
10
|
cancelSwap,
|
|
@@ -25,11 +25,10 @@ import {
|
|
|
25
25
|
isNetworkStatusInWarningState,
|
|
26
26
|
shouldRetrySwap,
|
|
27
27
|
} from '../utils/swap';
|
|
28
|
-
import { TokenPreview } from '../components/TokenPreview';
|
|
29
|
-
import { numberToString } from '../utils/numbers';
|
|
30
28
|
//@ts-ignore
|
|
31
29
|
import { t } from 'i18next';
|
|
32
30
|
import { SwapDetailsPlaceholder } from '../components/SwapDetailsPlaceholder';
|
|
31
|
+
import { getFormatedPendingSwap } from '../utils/routing';
|
|
33
32
|
|
|
34
33
|
export function SwapDetailsPage() {
|
|
35
34
|
const selectedSwapRequestId = useUiStore.use.selectedSwapRequestId();
|
|
@@ -68,11 +67,6 @@ export function SwapDetailsPage() {
|
|
|
68
67
|
/>
|
|
69
68
|
);
|
|
70
69
|
|
|
71
|
-
const firstStep = swap.steps[0];
|
|
72
|
-
const lastStep = swap.steps[swap.steps.length - 1];
|
|
73
|
-
const fromAmount = numberToString(swap.inputAmount);
|
|
74
|
-
const toAmount = numberToString(swap.simulationResult.outputAmount);
|
|
75
|
-
|
|
76
70
|
const currentStep = getCurrentStep(swap);
|
|
77
71
|
|
|
78
72
|
const currentStepBlockchain = currentStep
|
|
@@ -106,12 +100,13 @@ export function SwapDetailsPage() {
|
|
|
106
100
|
return (
|
|
107
101
|
<SwapHistory
|
|
108
102
|
onBack={navigateBackFrom.bind(null, navigationRoutes.swapDetails)}
|
|
103
|
+
/* TODO: It was temporarily removed to find a better solution*/
|
|
104
|
+
/*
|
|
109
105
|
previewInputs={
|
|
110
106
|
<>
|
|
111
107
|
<TokenPreview
|
|
112
108
|
chain={{
|
|
113
109
|
displayName: firstStep?.fromBlockchain || '',
|
|
114
|
-
// @ts-ignore
|
|
115
110
|
logo: firstStep?.fromBlockchainLogo || '',
|
|
116
111
|
}}
|
|
117
112
|
token={{
|
|
@@ -126,7 +121,6 @@ export function SwapDetailsPage() {
|
|
|
126
121
|
<TokenPreview
|
|
127
122
|
chain={{
|
|
128
123
|
displayName: lastStep?.toBlockchain || '',
|
|
129
|
-
//@ts-ignore
|
|
130
124
|
logo: lastStep?.toBlockchainLogo || '',
|
|
131
125
|
}}
|
|
132
126
|
token={{
|
|
@@ -139,8 +133,8 @@ export function SwapDetailsPage() {
|
|
|
139
133
|
/>
|
|
140
134
|
</>
|
|
141
135
|
}
|
|
142
|
-
|
|
143
|
-
pendingSwap={swap}
|
|
136
|
+
*/
|
|
137
|
+
pendingSwap={getFormatedPendingSwap(swap)}
|
|
144
138
|
onCopy={handleCopy}
|
|
145
139
|
isCopied={isCopied}
|
|
146
140
|
onCancel={onCancel}
|
package/src/utils/routing.ts
CHANGED
|
@@ -7,10 +7,8 @@ import { BestRouteResponse, BlockchainMeta, Token } from 'rango-sdk';
|
|
|
7
7
|
import { areEqual } from './common';
|
|
8
8
|
import { SelectedWallet } from './wallets';
|
|
9
9
|
import { BestRouteEqualityParams } from '../types';
|
|
10
|
-
import { TokenMeta } from '@rango-dev/ui/dist/types/meta';
|
|
11
10
|
import { numberToString } from './numbers';
|
|
12
|
-
import {
|
|
13
|
-
import { BestRouteWithFee } from '@rango-dev/ui';
|
|
11
|
+
import { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
14
12
|
|
|
15
13
|
export function searchParamsToToken(
|
|
16
14
|
tokens: Token[],
|
|
@@ -142,19 +140,41 @@ export function isRouteParametersChanged(params: BestRouteEqualityParams) {
|
|
|
142
140
|
return false;
|
|
143
141
|
}
|
|
144
142
|
|
|
145
|
-
export function
|
|
146
|
-
bestRoute: BestRouteResponse | null
|
|
147
|
-
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
const
|
|
143
|
+
export function getFormatedBestRoute(
|
|
144
|
+
bestRoute: BestRouteResponse | null
|
|
145
|
+
): BestRouteResponse | null {
|
|
146
|
+
if (!bestRoute) return null;
|
|
147
|
+
|
|
148
|
+
const formatedSwaps = (bestRoute.result?.swaps || []).map((swap) => ({
|
|
151
149
|
...swap,
|
|
152
|
-
|
|
150
|
+
fromAmount: numberToString(swap.fromAmount, 6, 6),
|
|
151
|
+
toAmount: numberToString(swap.toAmount, 6, 6),
|
|
153
152
|
}));
|
|
154
153
|
|
|
155
154
|
return {
|
|
156
155
|
...bestRoute,
|
|
157
|
-
|
|
156
|
+
...(bestRoute.result && {
|
|
157
|
+
result: { ...bestRoute.result, swaps: formatedSwaps },
|
|
158
|
+
}),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function getFormatedPendingSwap(pendingSwap: PendingSwap): PendingSwap {
|
|
163
|
+
const formatedSteps = pendingSwap.steps.map((step) => ({
|
|
164
|
+
...step,
|
|
165
|
+
feeInUsd: numberToString(step.feeInUsd, 4, 4),
|
|
166
|
+
outputAmount: numberToString(step.outputAmount, 6, 6),
|
|
167
|
+
expectedOutputAmountHumanReadable: numberToString(
|
|
168
|
+
step.expectedOutputAmountHumanReadable,
|
|
169
|
+
6,
|
|
170
|
+
6
|
|
171
|
+
),
|
|
172
|
+
}));
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
...pendingSwap,
|
|
176
|
+
inputAmount: numberToString(pendingSwap.inputAmount, 6, 6),
|
|
177
|
+
steps: formatedSteps,
|
|
158
178
|
};
|
|
159
179
|
}
|
|
160
180
|
|