@rango-dev/widget-embedded 0.17.1-next.27 → 0.17.1-next.28
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/containers/App/App.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +9 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +8 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/containers/App/App.tsx +1 -2
- package/src/containers/Wallets/Wallets.tsx +5 -1
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +20 -1
- package/src/containers/WidgetInfo/WidgetInfo.tsx +15 -1
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +8 -1
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ import { MainContainer } from './App.styles';
|
|
|
18
18
|
export function Main() {
|
|
19
19
|
globalFont();
|
|
20
20
|
|
|
21
|
-
const {
|
|
21
|
+
const { config } = useAppStore();
|
|
22
22
|
const { activeTheme } = useTheme(config?.theme || {});
|
|
23
23
|
const { activeLanguage, changeLanguage } = useLanguage();
|
|
24
24
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
@@ -27,7 +27,6 @@ export function Main() {
|
|
|
27
27
|
const widgetContext = useContext(WidgetContext);
|
|
28
28
|
|
|
29
29
|
useEffect(() => {
|
|
30
|
-
void fetchMeta().catch();
|
|
31
30
|
void useNotificationStore.persist.rehydrate();
|
|
32
31
|
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
33
32
|
}, []);
|
|
@@ -28,7 +28,7 @@ export const WidgetContext = createContext<WidgetContextInterface>({
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
function Main(props: PropsWithChildren<PropTypes>) {
|
|
31
|
-
const { updateConfig, updateSettings } = useAppStore();
|
|
31
|
+
const { updateConfig, updateSettings, fetch: fetchMeta } = useAppStore();
|
|
32
32
|
const blockchains = useAppStore().blockchains();
|
|
33
33
|
const tokens = useAppStore().tokens();
|
|
34
34
|
const walletOptions: ProvidersOptions = {
|
|
@@ -39,6 +39,10 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
39
39
|
const onConnectWalletHandler = useRef<OnConnectHandler>();
|
|
40
40
|
useSyncStoresWithConfig();
|
|
41
41
|
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
void fetchMeta().catch(console.log);
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
42
46
|
useEffect(() => {
|
|
43
47
|
if (props.config) {
|
|
44
48
|
updateConfig(props.config);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { Meta } from '../../store/quote';
|
|
1
2
|
import type { Manager } from '@rango-dev/queue-manager-core';
|
|
2
3
|
import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
3
4
|
|
|
4
5
|
import {
|
|
6
|
+
cancelSwap,
|
|
5
7
|
getCurrentBlockchainOfOrNull,
|
|
6
8
|
getCurrentStep,
|
|
7
9
|
getRelatedWalletOrNull,
|
|
@@ -9,11 +11,17 @@ import {
|
|
|
9
11
|
|
|
10
12
|
import { getPendingSwaps } from '../../utils/queue';
|
|
11
13
|
|
|
14
|
+
interface WidgetHistoryActions {
|
|
15
|
+
retrySwap: (pendingSwap: PendingSwap, meta: Meta) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
export class WidgetHistory {
|
|
13
19
|
private manager: Manager | undefined;
|
|
20
|
+
private actions: WidgetHistoryActions;
|
|
14
21
|
|
|
15
|
-
constructor(manager: Manager | undefined) {
|
|
22
|
+
constructor(manager: Manager | undefined, actions: WidgetHistoryActions) {
|
|
16
23
|
this.manager = manager;
|
|
24
|
+
this.actions = actions;
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
public getAllSwaps() {
|
|
@@ -32,6 +40,17 @@ export class WidgetHistory {
|
|
|
32
40
|
return this.getCurrentStepInfo(swap).network;
|
|
33
41
|
}
|
|
34
42
|
|
|
43
|
+
public retry(swap: PendingSwap, meta: Meta) {
|
|
44
|
+
return this.actions.retrySwap(swap, meta);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public cancel(id: string) {
|
|
48
|
+
const queue = this.manager?.get(id);
|
|
49
|
+
if (queue) {
|
|
50
|
+
cancelSwap(queue);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
35
54
|
private getCurrentStepInfo(swap: PendingSwap) {
|
|
36
55
|
const currentStep = getCurrentStep(swap);
|
|
37
56
|
return {
|
|
@@ -3,6 +3,8 @@ import type { WidgetInfoContextInterface } from './WidgetInfo.types';
|
|
|
3
3
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
4
4
|
import React, { createContext, useContext } from 'react';
|
|
5
5
|
|
|
6
|
+
import { useAppStore } from '../../store/AppStore';
|
|
7
|
+
import { useQuoteStore } from '../../store/quote';
|
|
6
8
|
import { useWalletsStore } from '../../store/wallets';
|
|
7
9
|
import { calculateWalletUsdValue } from '../../utils/wallets';
|
|
8
10
|
|
|
@@ -14,11 +16,17 @@ export const WidgetInfoContext = createContext<
|
|
|
14
16
|
|
|
15
17
|
export function WidgetInfo(props: React.PropsWithChildren) {
|
|
16
18
|
const { manager } = useManager();
|
|
17
|
-
const
|
|
19
|
+
const retrySwap = useQuoteStore.use.retry();
|
|
20
|
+
const history = new WidgetHistory(manager, { retrySwap });
|
|
18
21
|
const details = useWalletsStore.use.connectedWallets();
|
|
19
22
|
const isLoading = useWalletsStore.use.loading();
|
|
20
23
|
const totalBalance = calculateWalletUsdValue(details);
|
|
21
24
|
const refetch = useWalletsStore.use.getWalletsDetails();
|
|
25
|
+
const blockchains = useAppStore().blockchains();
|
|
26
|
+
const tokens = useAppStore().tokens();
|
|
27
|
+
const swappers = useAppStore().swappers();
|
|
28
|
+
const loadingStatus = useAppStore().fetchStatus;
|
|
29
|
+
|
|
22
30
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
23
31
|
const value = {
|
|
24
32
|
history,
|
|
@@ -28,6 +36,12 @@ export function WidgetInfo(props: React.PropsWithChildren) {
|
|
|
28
36
|
totalBalance,
|
|
29
37
|
refetch,
|
|
30
38
|
},
|
|
39
|
+
meta: {
|
|
40
|
+
blockchains,
|
|
41
|
+
tokens,
|
|
42
|
+
swappers,
|
|
43
|
+
loadingStatus,
|
|
44
|
+
},
|
|
31
45
|
};
|
|
32
46
|
|
|
33
47
|
return (
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { WidgetHistory } from './WidgetInfo.helpers';
|
|
2
|
+
import type { FetchStatus } from '../../store/slices/data';
|
|
2
3
|
import type { ConnectedWallet } from '../../store/wallets';
|
|
3
4
|
import type { Wallet } from '../../types';
|
|
4
|
-
import type { Token } from 'rango-sdk';
|
|
5
|
+
import type { BlockchainMeta, SwapperMeta, Token } from 'rango-sdk';
|
|
5
6
|
|
|
6
7
|
export interface WidgetInfoContextInterface {
|
|
7
8
|
history: WidgetHistory;
|
|
@@ -11,4 +12,10 @@ export interface WidgetInfoContextInterface {
|
|
|
11
12
|
isLoading: boolean;
|
|
12
13
|
refetch: (accounts: Wallet[], tokens: Token[]) => void;
|
|
13
14
|
};
|
|
15
|
+
meta: {
|
|
16
|
+
blockchains: BlockchainMeta[];
|
|
17
|
+
tokens: Token[];
|
|
18
|
+
swappers: SwapperMeta[];
|
|
19
|
+
loadingStatus: FetchStatus;
|
|
20
|
+
};
|
|
14
21
|
}
|