@rango-dev/widget-embedded 0.17.1-next.24 → 0.17.1-next.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.17.1-next.24",
3
+ "version": "0.17.1-next.25",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -21,13 +21,13 @@
21
21
  "dependencies": {
22
22
  "@lingui/core": "4.2.1",
23
23
  "@lingui/react": "4.2.1",
24
- "@rango-dev/provider-all": "^0.22.1-next.6",
25
- "@rango-dev/queue-manager-core": "^0.22.1-next.2",
26
- "@rango-dev/queue-manager-rango-preset": "^0.22.1-next.8",
27
- "@rango-dev/queue-manager-react": "^0.22.1-next.2",
28
- "@rango-dev/ui": "^0.22.1-next.13",
29
- "@rango-dev/wallets-react": "^0.8.1-next.4",
30
- "@rango-dev/wallets-shared": "^0.21.1-next.4",
24
+ "@rango-dev/provider-all": "^0.22.1-next.7",
25
+ "@rango-dev/queue-manager-core": "^0.22.1-next.3",
26
+ "@rango-dev/queue-manager-rango-preset": "^0.22.1-next.9",
27
+ "@rango-dev/queue-manager-react": "^0.22.1-next.3",
28
+ "@rango-dev/ui": "^0.22.1-next.14",
29
+ "@rango-dev/wallets-react": "^0.8.1-next.5",
30
+ "@rango-dev/wallets-shared": "^0.21.1-next.5",
31
31
  "bignumber.js": "^9.1.1",
32
32
  "copy-to-clipboard": "^3.3.3",
33
33
  "dayjs": "^1.11.7",
@@ -0,0 +1,45 @@
1
+ import type { Manager } from '@rango-dev/queue-manager-core';
2
+ import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
3
+
4
+ import {
5
+ getCurrentBlockchainOfOrNull,
6
+ getCurrentStep,
7
+ getRelatedWalletOrNull,
8
+ } from '@rango-dev/queue-manager-rango-preset';
9
+
10
+ import { getPendingSwaps } from '../../utils/queue';
11
+
12
+ export class WidgetHistory {
13
+ private manager: Manager | undefined;
14
+
15
+ constructor(manager: Manager | undefined) {
16
+ this.manager = manager;
17
+ }
18
+
19
+ public getAllSwaps() {
20
+ return getPendingSwaps(this.manager);
21
+ }
22
+
23
+ public getCurrentStep(swap: PendingSwap) {
24
+ return this.getCurrentStepInfo(swap).step;
25
+ }
26
+
27
+ public getCurrentStepWallet(swap: PendingSwap) {
28
+ return this.getCurrentStepInfo(swap).wallet;
29
+ }
30
+
31
+ public getCurrentStepNetwork(swap: PendingSwap) {
32
+ return this.getCurrentStepInfo(swap).network;
33
+ }
34
+
35
+ private getCurrentStepInfo(swap: PendingSwap) {
36
+ const currentStep = getCurrentStep(swap);
37
+ return {
38
+ step: currentStep,
39
+ wallet: currentStep ? getRelatedWalletOrNull(swap, currentStep) : null,
40
+ network: currentStep
41
+ ? getCurrentBlockchainOfOrNull(swap, currentStep)
42
+ : null,
43
+ };
44
+ }
45
+ }
@@ -4,23 +4,24 @@ import { useManager } from '@rango-dev/queue-manager-react';
4
4
  import React, { createContext, useContext } from 'react';
5
5
 
6
6
  import { useWalletsStore } from '../../store/wallets';
7
- import { getPendingSwaps } from '../../utils/queue';
8
7
  import { calculateWalletUsdValue } from '../../utils/wallets';
9
8
 
9
+ import { WidgetHistory } from './WidgetInfo.helpers';
10
+
10
11
  export const WidgetInfoContext = createContext<
11
12
  WidgetInfoContextInterface | undefined
12
13
  >(undefined);
13
14
 
14
15
  export function WidgetInfo(props: React.PropsWithChildren) {
15
16
  const { manager } = useManager();
16
- const swaps = getPendingSwaps(manager);
17
+ const history = new WidgetHistory(manager);
17
18
  const details = useWalletsStore.use.connectedWallets();
18
19
  const isLoading = useWalletsStore.use.loading();
19
20
  const totalBalance = calculateWalletUsdValue(details);
20
21
  const refetch = useWalletsStore.use.getWalletsDetails();
21
22
  // eslint-disable-next-line react/jsx-no-constructed-context-values
22
23
  const value = {
23
- swaps,
24
+ history,
24
25
  wallets: {
25
26
  isLoading,
26
27
  details,
@@ -1,10 +1,10 @@
1
+ import type { WidgetHistory } from './WidgetInfo.helpers';
1
2
  import type { ConnectedWallet } from '../../store/wallets';
2
3
  import type { Wallet } from '../../types';
3
- import type { PendingSwapWithQueueID } from '@rango-dev/queue-manager-rango-preset';
4
4
  import type { Token } from 'rango-sdk';
5
5
 
6
6
  export interface WidgetInfoContextInterface {
7
- swaps: PendingSwapWithQueueID[];
7
+ history: WidgetHistory;
8
8
  wallets: {
9
9
  details: ConnectedWallet[];
10
10
  totalBalance: string;
package/src/index.ts CHANGED
@@ -8,8 +8,13 @@ import type {
8
8
  WidgetTheme,
9
9
  } from './types';
10
10
  import type {
11
+ EventSeverity,
12
+ PendingSwap,
13
+ PendingSwapStep,
14
+ PendingSwapWithQueueID,
11
15
  Route,
12
16
  RouteEvent,
17
+ RouteExecutionEvents,
13
18
  RouteFailedEvent,
14
19
  RouteStartedEvent,
15
20
  RouteSucceededEvent,
@@ -28,17 +33,27 @@ import type {
28
33
  EventHandler as HandleWalletsUpdate,
29
34
  ProviderInterface,
30
35
  } from '@rango-dev/wallets-react';
31
- import type { WalletType } from '@rango-dev/wallets-shared';
36
+ import type {
37
+ WalletInfo,
38
+ WalletState,
39
+ WalletType,
40
+ } from '@rango-dev/wallets-shared';
32
41
 
33
42
  import {
34
43
  MainEvents,
44
+ PendingSwapNetworkStatus,
35
45
  RouteEventType,
36
46
  StepEventType,
37
47
  StepExecutionBlockedEventStatus,
38
48
  StepExecutionEventStatus,
39
49
  useEvents as useWidgetEvents,
40
50
  } from '@rango-dev/queue-manager-rango-preset';
41
- import { useWallets } from '@rango-dev/wallets-react';
51
+ import {
52
+ readAccountAddress,
53
+ useWallets,
54
+ Events as WalletEvents,
55
+ } from '@rango-dev/wallets-react';
56
+ import { Networks, WalletTypes } from '@rango-dev/wallets-shared';
42
57
 
43
58
  import { WidgetWallets } from './containers/Wallets';
44
59
  import { Widget } from './containers/Widget';
@@ -90,3 +105,23 @@ export {
90
105
  StepExecutionEventStatus,
91
106
  StepExecutionBlockedEventStatus,
92
107
  };
108
+
109
+ // Internal type exports for Rango
110
+ export type {
111
+ WalletState,
112
+ WalletInfo,
113
+ PendingSwap,
114
+ PendingSwapWithQueueID,
115
+ PendingSwapStep,
116
+ RouteExecutionEvents,
117
+ EventSeverity,
118
+ };
119
+
120
+ // Internal function and enum exports for Rango
121
+ export {
122
+ readAccountAddress,
123
+ Networks,
124
+ WalletEvents,
125
+ WalletTypes,
126
+ PendingSwapNetworkStatus,
127
+ };