@rango-dev/widget-embedded 0.20.1-next.21 → 0.20.1-next.22
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/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +6 -6
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useSyncUrlAndStore/index.d.ts +2 -0
- package/dist/hooks/useSyncUrlAndStore/index.d.ts.map +1 -0
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts +2 -0
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -0
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.d.ts +4 -0
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.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/utils/quote.d.ts +0 -1
- package/dist/utils/quote.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/AppRouter.tsx +1 -8
- package/src/components/AppRoutes.tsx +11 -0
- package/src/components/Layout/Layout.tsx +1 -6
- package/src/components/NotificationContent/NotificationContent.tsx +0 -3
- package/src/constants/searchParams.ts +6 -6
- package/src/containers/Wallets/Wallets.tsx +0 -2
- package/src/hooks/useSwapInput.ts +6 -1
- package/src/hooks/useSyncStoresWithConfig.ts +3 -17
- package/src/hooks/useSyncUrlAndStore/index.ts +1 -0
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.ts +35 -0
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +135 -0
- package/src/pages/ConfirmSwapPage.tsx +3 -5
- package/src/pages/HistoryPage.tsx +1 -6
- package/src/pages/Home.tsx +9 -6
- package/src/pages/SwapDetailsPage.tsx +21 -7
- package/src/utils/quote.ts +0 -27
- package/dist/components/UpdateUrl.d.ts +0 -2
- package/dist/components/UpdateUrl.d.ts.map +0 -1
- package/dist/store/ui.d.ts +0 -22
- package/dist/store/ui.d.ts.map +0 -1
- package/src/components/UpdateUrl.tsx +0 -158
- package/src/store/ui.ts +0 -21
package/dist/store/ui.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
interface UiState {
|
|
2
|
-
connectWalletsButtonDisabled: boolean;
|
|
3
|
-
selectedSwapRequestId: string | null;
|
|
4
|
-
currentPage: string;
|
|
5
|
-
setSelectedSwap: (requestId: string | null) => void;
|
|
6
|
-
setCurrentPage: (path: string) => void;
|
|
7
|
-
}
|
|
8
|
-
export declare const useUiStore: {
|
|
9
|
-
(): UiState;
|
|
10
|
-
<U>(selector: (state: UiState) => U): U;
|
|
11
|
-
<U_1>(selector: (state: UiState) => U_1, equalityFn: (a: U_1, b: U_1) => boolean): U_1;
|
|
12
|
-
} & import("zustand").StoreApi<UiState> & {
|
|
13
|
-
use: {
|
|
14
|
-
connectWalletsButtonDisabled: () => boolean;
|
|
15
|
-
selectedSwapRequestId: () => string | null;
|
|
16
|
-
currentPage: () => string;
|
|
17
|
-
setSelectedSwap: () => (requestId: string | null) => void;
|
|
18
|
-
setCurrentPage: () => (path: string) => void;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=ui.d.ts.map
|
package/dist/store/ui.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/store/ui.ts"],"names":[],"mappings":"AAIA,UAAU,OAAO;IACf,4BAA4B,EAAE,OAAO,CAAC;IACtC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACpD,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,UAAU;;;;;;;;;2CAJQ,MAAM,GAAG,IAAI,KAAK,IAAI;qCAC5B,MAAM,KAAK,IAAI;;CAWvC,CAAC"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
createSearchParams,
|
|
4
|
-
useLocation,
|
|
5
|
-
useSearchParams,
|
|
6
|
-
} from 'react-router-dom';
|
|
7
|
-
|
|
8
|
-
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
9
|
-
import { SearchParams } from '../constants/searchParams';
|
|
10
|
-
import { useAppStore } from '../store/AppStore';
|
|
11
|
-
import { useQuoteStore } from '../store/quote';
|
|
12
|
-
import { useUiStore } from '../store/ui';
|
|
13
|
-
import { searchParamsToToken } from '../utils/quote';
|
|
14
|
-
|
|
15
|
-
export function UpdateUrl() {
|
|
16
|
-
const firstRender = useRef(true);
|
|
17
|
-
const [searchParams, setSearchParams] = useSearchParams();
|
|
18
|
-
const location = useLocation();
|
|
19
|
-
const firstRenderSearchParams = useRef(location.search);
|
|
20
|
-
const searchParamsRef = useRef<Record<string, string>>({});
|
|
21
|
-
const fromBlockchain = useQuoteStore.use.fromBlockchain();
|
|
22
|
-
const toBlockchain = useQuoteStore.use.toBlockchain();
|
|
23
|
-
const fromToken = useQuoteStore.use.fromToken();
|
|
24
|
-
const toToken = useQuoteStore.use.toToken();
|
|
25
|
-
const setFromBlockchain = useQuoteStore.use.setFromBlockchain();
|
|
26
|
-
const setFromToken = useQuoteStore.use.setFromToken();
|
|
27
|
-
const setToBlockchain = useQuoteStore.use.setToBlockchain();
|
|
28
|
-
const setToToken = useQuoteStore.use.setToToken();
|
|
29
|
-
const inputAmount = useQuoteStore.use.inputAmount();
|
|
30
|
-
const setInputAmount = useQuoteStore.use.setInputAmount();
|
|
31
|
-
const fetchMetaStatus = useAppStore().fetchStatus;
|
|
32
|
-
const blockchains = useAppStore().blockchains();
|
|
33
|
-
const tokens = useAppStore().tokens();
|
|
34
|
-
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
const params: Record<string, string> = {};
|
|
38
|
-
createSearchParams(firstRenderSearchParams.current).forEach(
|
|
39
|
-
(value, key) => {
|
|
40
|
-
params[key] = value;
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
searchParamsRef.current = params;
|
|
44
|
-
const requestId =
|
|
45
|
-
location.pathname.split(navigationRoutes.swaps + '/')[1] || null;
|
|
46
|
-
if (requestId) {
|
|
47
|
-
setSelectedSwap(requestId);
|
|
48
|
-
}
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
if (!firstRender.current) {
|
|
53
|
-
let fromChainString = '',
|
|
54
|
-
fromTokenString = '',
|
|
55
|
-
toChainString = '',
|
|
56
|
-
toTokenString = '',
|
|
57
|
-
fromAmount = '';
|
|
58
|
-
const autoConnect = searchParamsRef.current[SearchParams.AUTO_CONNECT];
|
|
59
|
-
if (fetchMetaStatus !== 'success') {
|
|
60
|
-
fromChainString = searchParamsRef.current[SearchParams.FROM_CHAIN];
|
|
61
|
-
fromTokenString = searchParamsRef.current[SearchParams.FROM_TOKEN];
|
|
62
|
-
toChainString = searchParamsRef.current[SearchParams.TO_CHAIN];
|
|
63
|
-
toTokenString = searchParamsRef.current[SearchParams.TO_TOKEN];
|
|
64
|
-
fromAmount =
|
|
65
|
-
searchParamsRef.current[SearchParams.FROM_AMOUNT] || inputAmount;
|
|
66
|
-
} else {
|
|
67
|
-
fromChainString = fromBlockchain?.name || '';
|
|
68
|
-
fromTokenString =
|
|
69
|
-
(fromToken?.symbol || '') +
|
|
70
|
-
(fromToken?.address ? `--${fromToken?.address}` : '');
|
|
71
|
-
toChainString = toBlockchain?.name || '';
|
|
72
|
-
toTokenString =
|
|
73
|
-
(toToken?.symbol || '') +
|
|
74
|
-
(toToken?.address ? `--${toToken?.address}` : '');
|
|
75
|
-
fromAmount = inputAmount;
|
|
76
|
-
}
|
|
77
|
-
setSearchParams(
|
|
78
|
-
{
|
|
79
|
-
...(fromChainString && {
|
|
80
|
-
[SearchParams.FROM_CHAIN]: fromChainString,
|
|
81
|
-
}),
|
|
82
|
-
...(fromTokenString && {
|
|
83
|
-
[SearchParams.FROM_TOKEN]: fromTokenString,
|
|
84
|
-
}),
|
|
85
|
-
...(toChainString && { [SearchParams.TO_CHAIN]: toChainString }),
|
|
86
|
-
...(toTokenString && { [SearchParams.TO_TOKEN]: toTokenString }),
|
|
87
|
-
...(fromAmount && {
|
|
88
|
-
[SearchParams.FROM_AMOUNT]: fromAmount.toString(),
|
|
89
|
-
}),
|
|
90
|
-
...(autoConnect && {
|
|
91
|
-
[SearchParams.AUTO_CONNECT]: autoConnect,
|
|
92
|
-
}),
|
|
93
|
-
},
|
|
94
|
-
{ replace: true }
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
firstRender.current = false;
|
|
98
|
-
}, [
|
|
99
|
-
location.pathname,
|
|
100
|
-
inputAmount,
|
|
101
|
-
fromBlockchain,
|
|
102
|
-
fromToken,
|
|
103
|
-
toBlockchain,
|
|
104
|
-
toToken,
|
|
105
|
-
]);
|
|
106
|
-
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
if (fetchMetaStatus === 'success') {
|
|
109
|
-
const fromChainString = searchParams.get(SearchParams.FROM_CHAIN);
|
|
110
|
-
const fromTokenString = searchParams.get(SearchParams.FROM_TOKEN);
|
|
111
|
-
const toChainString = searchParams.get(SearchParams.TO_CHAIN);
|
|
112
|
-
const toTokenString = searchParams.get(SearchParams.TO_TOKEN);
|
|
113
|
-
const fromAmount = searchParams.get(SearchParams.FROM_AMOUNT);
|
|
114
|
-
const fromBlockchain = blockchains.find(
|
|
115
|
-
(blockchain) => blockchain.name === fromChainString
|
|
116
|
-
);
|
|
117
|
-
const fromToken = searchParamsToToken(
|
|
118
|
-
tokens,
|
|
119
|
-
fromTokenString,
|
|
120
|
-
fromBlockchain || null
|
|
121
|
-
);
|
|
122
|
-
const toBlockchain = blockchains.find(
|
|
123
|
-
(blockchain) => blockchain.name === toChainString
|
|
124
|
-
);
|
|
125
|
-
const toToken = searchParamsToToken(
|
|
126
|
-
tokens,
|
|
127
|
-
toTokenString,
|
|
128
|
-
toBlockchain || null
|
|
129
|
-
);
|
|
130
|
-
if (!!fromBlockchain) {
|
|
131
|
-
setFromBlockchain(fromBlockchain);
|
|
132
|
-
if (!!fromToken) {
|
|
133
|
-
setFromToken({
|
|
134
|
-
token: fromToken,
|
|
135
|
-
meta: {
|
|
136
|
-
blockchains: blockchains,
|
|
137
|
-
tokens: tokens,
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (!!toBlockchain) {
|
|
143
|
-
setToBlockchain(toBlockchain);
|
|
144
|
-
if (!!toToken) {
|
|
145
|
-
setToToken({
|
|
146
|
-
token: toToken,
|
|
147
|
-
meta: { blockchains: blockchains, tokens: tokens },
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (fromAmount) {
|
|
152
|
-
setInputAmount(fromAmount);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}, [fetchMetaStatus]);
|
|
156
|
-
|
|
157
|
-
return null;
|
|
158
|
-
}
|
package/src/store/ui.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { create } from 'zustand';
|
|
2
|
-
|
|
3
|
-
import createSelectors from './selectors';
|
|
4
|
-
|
|
5
|
-
interface UiState {
|
|
6
|
-
connectWalletsButtonDisabled: boolean;
|
|
7
|
-
selectedSwapRequestId: string | null;
|
|
8
|
-
currentPage: string;
|
|
9
|
-
setSelectedSwap: (requestId: string | null) => void;
|
|
10
|
-
setCurrentPage: (path: string) => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const useUiStore = createSelectors(
|
|
14
|
-
create<UiState>()((set) => ({
|
|
15
|
-
connectWalletsButtonDisabled: false,
|
|
16
|
-
selectedSwapRequestId: null,
|
|
17
|
-
currentPage: '',
|
|
18
|
-
setSelectedSwap: (requestId) => set({ selectedSwapRequestId: requestId }),
|
|
19
|
-
setCurrentPage: (path) => set({ currentPage: path }),
|
|
20
|
-
}))
|
|
21
|
-
);
|