@rango-dev/widget-embedded 0.20.1-next.19 → 0.20.1-next.20

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.
@@ -1,4 +1,4 @@
1
- import { type Route, type RouteEvent, type Step, type StepEvent, StepExecutionBlockedEventStatus } from '@rango-dev/queue-manager-rango-preset';
1
+ import { type Route, type RouteEvent, type Step, type StepEvent } from '@rango-dev/queue-manager-rango-preset';
2
2
  type NotificationRoute = {
3
3
  from: {
4
4
  blockchain: Step['fromBlockchain'];
@@ -17,6 +17,5 @@ export type Notification = Pick<Route, 'requestId'> & {
17
17
  read: boolean;
18
18
  route: NotificationRoute;
19
19
  };
20
- export declare const validBlockedStatuses: StepExecutionBlockedEventStatus[];
21
20
  export {};
22
21
  //# sourceMappingURL=notification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../src/types/notification.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,SAAS,EACd,+BAA+B,EAChC,MAAM,uCAAuC,CAAC;AAE/C,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACnC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAChC,YAAY,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;KACzC,CAAC;IACF,EAAE,EAAE;QACF,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACjC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9B,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;KACvC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG;IACpD,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,iBAAiB,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,+BAA+B,EAIjE,CAAC"}
1
+ {"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../src/types/notification.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,SAAS,EACf,MAAM,uCAAuC,CAAC;AAE/C,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACnC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAChC,YAAY,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;KACzC,CAAC;IACF,EAAE,EAAE;QACF,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACjC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9B,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;KACvC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG;IACpD,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,iBAAiB,CAAC;CAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.20.1-next.19",
3
+ "version": "0.20.1-next.20",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -23,9 +23,9 @@
23
23
  "@lingui/react": "4.2.1",
24
24
  "@rango-dev/provider-all": "^0.25.1-next.3",
25
25
  "@rango-dev/queue-manager-core": "^0.25.0",
26
- "@rango-dev/queue-manager-rango-preset": "^0.25.1-next.1",
26
+ "@rango-dev/queue-manager-rango-preset": "^0.25.1-next.2",
27
27
  "@rango-dev/queue-manager-react": "^0.24.0",
28
- "@rango-dev/ui": "^0.26.1-next.10",
28
+ "@rango-dev/ui": "^0.26.1-next.11",
29
29
  "@rango-dev/wallets-react": "^0.11.1-next.1",
30
30
  "@rango-dev/wallets-shared": "^0.25.1-next.1",
31
31
  "bignumber.js": "^9.1.1",
@@ -1,6 +1,7 @@
1
1
  import type { Notification } from '../../types/notification';
2
2
 
3
3
  import { i18n } from '@lingui/core';
4
+ import { EventSeverity } from '@rango-dev/queue-manager-rango-preset';
4
5
  import {
5
6
  ChainToken,
6
7
  ChevronRightIcon,
@@ -74,7 +75,15 @@ export function NotificationContent() {
74
75
  key={notificationItem.requestId}
75
76
  onClick={() => handleOnClick(notificationItem.requestId)}
76
77
  title={
77
- <Typography variant="body" size="small" color="$neutral700">
78
+ <Typography
79
+ variant="body"
80
+ size="small"
81
+ color={
82
+ notificationItem.event.messageSeverity ===
83
+ EventSeverity.WARNING
84
+ ? '$foreground'
85
+ : '$neutral700'
86
+ }>
78
87
  {i18n.t(notificationItem.event.message)}
79
88
  </Typography>
80
89
  }
@@ -11,14 +11,12 @@ import { useEffect } from 'react';
11
11
  import { useAppStore } from '../store/AppStore';
12
12
  import { useNotificationStore } from '../store/notification';
13
13
  import { useWalletsStore } from '../store/wallets';
14
- import { validBlockedStatuses } from '../types/notification';
15
14
 
16
15
  export function WidgetEvents() {
17
16
  const tokens = useAppStore().tokens();
18
17
  const connectedWallets = useWalletsStore.use.connectedWallets();
19
18
  const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
20
19
  const setNotification = useNotificationStore.use.setNotification();
21
- const setAsRead = useNotificationStore.use.setAsRead();
22
20
  const widgetEvents = useEvents();
23
21
 
24
22
  useEffect(() => {
@@ -43,18 +41,8 @@ export function WidgetEvents() {
43
41
  fromAccount && getWalletsDetails([fromAccount], tokens);
44
42
  toAccount && getWalletsDetails([toAccount], tokens);
45
43
  }
46
- if (
47
- (event.type === StepEventType.TX_EXECUTION_BLOCKED &&
48
- validBlockedStatuses.includes(event.status)) ||
49
- event.type === StepEventType.FAILED
50
- ) {
51
- setNotification(event, route);
52
- } else if (
53
- event.type === StepEventType.TX_EXECUTION ||
54
- event.type === StepEventType.CHECK_STATUS
55
- ) {
56
- setAsRead(route.requestId);
57
- }
44
+
45
+ setNotification(event, route);
58
46
  });
59
47
 
60
48
  return () => widgetEvents.all.clear();
@@ -5,6 +5,7 @@ import React, { createContext, useContext } from 'react';
5
5
 
6
6
  import { useLanguage } from '../../hooks/useLanguage';
7
7
  import { useAppStore } from '../../store/AppStore';
8
+ import { useNotificationStore } from '../../store/notification';
8
9
  import { useQuoteStore } from '../../store/quote';
9
10
  import { useWalletsStore } from '../../store/wallets';
10
11
  import { calculateWalletUsdValue } from '../../utils/wallets';
@@ -28,6 +29,7 @@ export function WidgetInfo(props: React.PropsWithChildren) {
28
29
  const swappers = useAppStore().swappers();
29
30
  const loadingStatus = useAppStore().fetchStatus;
30
31
  const resetLanguage = useLanguage().resetLanguage;
32
+ const notifications = useNotificationStore().getUnreadNotifications();
31
33
 
32
34
  // eslint-disable-next-line react/jsx-no-constructed-context-values
33
35
  const value = {
@@ -45,6 +47,9 @@ export function WidgetInfo(props: React.PropsWithChildren) {
45
47
  loadingStatus,
46
48
  },
47
49
  resetLanguage,
50
+ notifications: {
51
+ list: notifications,
52
+ },
48
53
  };
49
54
 
50
55
  return (
@@ -2,6 +2,7 @@ import type { WidgetHistory } from './WidgetInfo.helpers';
2
2
  import type { FetchStatus } from '../../store/slices/data';
3
3
  import type { ConnectedWallet } from '../../store/wallets';
4
4
  import type { Wallet } from '../../types';
5
+ import type { Notification } from '../../types/notification';
5
6
  import type { BlockchainMeta, SwapperMeta, Token } from 'rango-sdk';
6
7
 
7
8
  export interface WidgetInfoContextInterface {
@@ -19,4 +20,7 @@ export interface WidgetInfoContextInterface {
19
20
  loadingStatus: FetchStatus;
20
21
  };
21
22
  resetLanguage: () => void;
23
+ notifications: {
24
+ list: Notification[];
25
+ };
22
26
  }
package/src/index.ts CHANGED
@@ -9,7 +9,6 @@ import type {
9
9
  WidgetTheme,
10
10
  } from './types';
11
11
  import type {
12
- EventSeverity,
13
12
  PendingSwapWithQueueID,
14
13
  Route,
15
14
  RouteEvent,
@@ -40,6 +39,7 @@ import type {
40
39
  import type { PendingSwap, PendingSwapStep } from 'rango-types';
41
40
 
42
41
  import {
42
+ EventSeverity,
43
43
  MainEvents,
44
44
  RouteEventType,
45
45
  StepEventType,
@@ -115,7 +115,6 @@ export type {
115
115
  PendingSwapWithQueueID,
116
116
  PendingSwapStep,
117
117
  RouteExecutionEvents,
118
- EventSeverity,
119
118
  };
120
119
 
121
120
  // Internal function and enum exports for Rango
@@ -125,4 +124,5 @@ export {
125
124
  WalletEvents,
126
125
  WalletTypes,
127
126
  PendingSwapNetworkStatus,
127
+ EventSeverity,
128
128
  };
@@ -3,7 +3,6 @@ import {
3
3
  type RouteEvent,
4
4
  type Step,
5
5
  type StepEvent,
6
- StepExecutionBlockedEventStatus,
7
6
  } from '@rango-dev/queue-manager-rango-preset';
8
7
 
9
8
  type NotificationRoute = {
@@ -25,9 +24,3 @@ export type Notification = Pick<Route, 'requestId'> & {
25
24
  read: boolean;
26
25
  route: NotificationRoute;
27
26
  };
28
-
29
- export const validBlockedStatuses: StepExecutionBlockedEventStatus[] = [
30
- StepExecutionBlockedEventStatus.WAITING_FOR_CHANGE_WALLET_ACCOUNT,
31
- StepExecutionBlockedEventStatus.WAITING_FOR_NETWORK_CHANGE,
32
- StepExecutionBlockedEventStatus.WAITING_FOR_WALLET_CONNECT,
33
- ];