@rango-dev/widget-embedded 0.24.2-next.3 → 0.24.2-next.5
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/hooks/useBootstrap/useBootstrap.d.ts.map +1 -1
- package/dist/hooks/useSubscribeToWidgetEvents/index.d.ts +2 -0
- package/dist/hooks/useSubscribeToWidgetEvents/index.d.ts.map +1 -0
- package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts +2 -0
- package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/package.json +3 -3
- package/src/containers/App/App.tsx +0 -2
- package/src/hooks/useBootstrap/useBootstrap.ts +2 -0
- package/src/hooks/useSubscribeToWidgetEvents/index.ts +1 -0
- package/src/{components/WidgetEvents.tsx → hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts} +14 -12
- package/src/index.ts +4 -0
- package/dist/components/WidgetEvents.d.ts +0 -2
- package/dist/components/WidgetEvents.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.24.2-next.
|
|
3
|
+
"version": "0.24.2-next.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"@lingui/core": "4.2.1",
|
|
23
23
|
"@lingui/react": "4.2.1",
|
|
24
24
|
"@rango-dev/logging-core": "^0.2.0",
|
|
25
|
-
"@rango-dev/provider-all": "^0.29.1-next.
|
|
25
|
+
"@rango-dev/provider-all": "^0.29.1-next.1",
|
|
26
26
|
"@rango-dev/queue-manager-core": "^0.26.0",
|
|
27
|
-
"@rango-dev/queue-manager-rango-preset": "^0.29.2-next.
|
|
27
|
+
"@rango-dev/queue-manager-rango-preset": "^0.29.2-next.1",
|
|
28
28
|
"@rango-dev/queue-manager-react": "^0.26.0",
|
|
29
29
|
"@rango-dev/ui": "^0.30.1-next.1",
|
|
30
30
|
"@rango-dev/wallets-react": "^0.15.1-next.0",
|
|
@@ -2,7 +2,6 @@ import { I18nManager } from '@rango-dev/ui';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
import { AppRoutes } from '../../components/AppRoutes';
|
|
5
|
-
import { WidgetEvents } from '../../components/WidgetEvents';
|
|
6
5
|
import { useBootstrap } from '../../hooks/useBootstrap';
|
|
7
6
|
import { useLanguage } from '../../hooks/useLanguage';
|
|
8
7
|
import { useTheme } from '../../hooks/useTheme';
|
|
@@ -19,7 +18,6 @@ export function Main() {
|
|
|
19
18
|
return (
|
|
20
19
|
<I18nManager language={activeLanguage}>
|
|
21
20
|
<MainContainer id="swap-container" className={activeTheme()}>
|
|
22
|
-
<WidgetEvents />
|
|
23
21
|
<AppRoutes />
|
|
24
22
|
</MainContainer>
|
|
25
23
|
</I18nManager>
|
|
@@ -13,10 +13,12 @@ import { useNotificationStore } from '../../store/notification';
|
|
|
13
13
|
import { tabManager } from '../../store/ui';
|
|
14
14
|
import { useFetchApiConfig } from '../useFetchApiConfig';
|
|
15
15
|
import { useForceAutoConnect } from '../useForceAutoConnect';
|
|
16
|
+
import { useSubscribeToWidgetEvents } from '../useSubscribeToWidgetEvents';
|
|
16
17
|
|
|
17
18
|
export function useBootstrap() {
|
|
18
19
|
globalFont();
|
|
19
20
|
useForceAutoConnect();
|
|
21
|
+
useSubscribeToWidgetEvents();
|
|
20
22
|
const blockchains = useAppStore().blockchains();
|
|
21
23
|
const { canSwitchNetworkTo } = useWallets();
|
|
22
24
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSubscribeToWidgetEvents } from './useSubscribeToWidgetEvents';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { RouteEventData, StepEventData } from '../..';
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
isApprovalTX,
|
|
3
5
|
MainEvents,
|
|
@@ -8,11 +10,11 @@ import {
|
|
|
8
10
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
9
11
|
import { useEffect } from 'react';
|
|
10
12
|
|
|
11
|
-
import { useAppStore } from '
|
|
12
|
-
import { useNotificationStore } from '
|
|
13
|
-
import { useWalletsStore } from '
|
|
13
|
+
import { useAppStore } from '../../store/AppStore';
|
|
14
|
+
import { useNotificationStore } from '../../store/notification';
|
|
15
|
+
import { useWalletsStore } from '../../store/wallets';
|
|
14
16
|
|
|
15
|
-
export function
|
|
17
|
+
export function useSubscribeToWidgetEvents() {
|
|
16
18
|
const tokens = useAppStore().tokens();
|
|
17
19
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
18
20
|
const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
|
|
@@ -20,7 +22,7 @@ export function WidgetEvents() {
|
|
|
20
22
|
const widgetEvents = useEvents();
|
|
21
23
|
|
|
22
24
|
useEffect(() => {
|
|
23
|
-
|
|
25
|
+
const handleStepEvent = (widgetEvent: StepEventData) => {
|
|
24
26
|
const { event, step, route } = widgetEvent;
|
|
25
27
|
const shouldRefetchBalance =
|
|
26
28
|
(event.type === StepEventType.TX_EXECUTION &&
|
|
@@ -43,13 +45,14 @@ export function WidgetEvents() {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
setNotification(event, route);
|
|
46
|
-
}
|
|
48
|
+
};
|
|
49
|
+
widgetEvents.on(MainEvents.StepEvent, handleStepEvent);
|
|
47
50
|
|
|
48
|
-
return () => widgetEvents.
|
|
51
|
+
return () => widgetEvents.off(MainEvents.StepEvent, handleStepEvent);
|
|
49
52
|
}, [widgetEvents, connectedWallets.length]);
|
|
50
53
|
|
|
51
54
|
useEffect(() => {
|
|
52
|
-
|
|
55
|
+
const handleRouteEvent = (widgetEvent: RouteEventData) => {
|
|
53
56
|
const { event, route } = widgetEvent;
|
|
54
57
|
|
|
55
58
|
if (
|
|
@@ -58,10 +61,9 @@ export function WidgetEvents() {
|
|
|
58
61
|
) {
|
|
59
62
|
setNotification(event, route);
|
|
60
63
|
}
|
|
61
|
-
}
|
|
64
|
+
};
|
|
65
|
+
widgetEvents.on(MainEvents.RouteEvent, handleRouteEvent);
|
|
62
66
|
|
|
63
|
-
return () => widgetEvents.
|
|
67
|
+
return () => widgetEvents.off(MainEvents.RouteEvent, handleRouteEvent);
|
|
64
68
|
}, [widgetEvents, connectedWallets.length]);
|
|
65
|
-
|
|
66
|
-
return null;
|
|
67
69
|
}
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
PendingSwapWithQueueID,
|
|
14
14
|
Route,
|
|
15
15
|
RouteEvent,
|
|
16
|
+
RouteEventData,
|
|
16
17
|
RouteExecutionEvents,
|
|
17
18
|
RouteFailedEvent,
|
|
18
19
|
RouteStartedEvent,
|
|
@@ -21,6 +22,7 @@ import type {
|
|
|
21
22
|
StepApprovalTxSucceededEvent,
|
|
22
23
|
StepCheckStatusEvent,
|
|
23
24
|
StepEvent,
|
|
25
|
+
StepEventData,
|
|
24
26
|
StepFailedEvent,
|
|
25
27
|
StepOutputRevealedEvent,
|
|
26
28
|
StepStartedEvent,
|
|
@@ -73,7 +75,9 @@ export type {
|
|
|
73
75
|
BlockchainAndTokenConfig,
|
|
74
76
|
WidgetProps,
|
|
75
77
|
RouteEvent,
|
|
78
|
+
RouteEventData,
|
|
76
79
|
StepEvent,
|
|
80
|
+
StepEventData,
|
|
77
81
|
Route,
|
|
78
82
|
Step,
|
|
79
83
|
RouteStartedEvent,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetEvents.d.ts","sourceRoot":"","sources":["../../src/components/WidgetEvents.tsx"],"names":[],"mappings":"AAcA,wBAAgB,YAAY,SAoD3B"}
|