@rango-dev/widget-embedded 0.64.4-next.1 → 0.64.4-next.10
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/Wallets/Wallets.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.helpers.d.ts.map +1 -1
- package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +4 -4
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/wallets.d.ts +1 -3
- package/dist/store/slices/wallets.d.ts.map +1 -1
- package/dist/types/event.d.ts +2 -30
- package/dist/types/event.d.ts.map +1 -1
- package/dist/utils/events.d.ts +1 -2
- package/dist/utils/events.d.ts.map +1 -1
- package/package.json +21 -11
- package/src/containers/Wallets/Wallets.helpers.ts +2 -5
- package/src/containers/Wallets/Wallets.tsx +2 -0
- package/src/containers/Wallets/useUpdates.ts +1 -3
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +1 -1
- package/src/hooks/useWalletList.ts +0 -36
- package/src/index.ts +6 -3
- package/src/store/slices/config.ts +23 -19
- package/src/store/slices/wallets.ts +3 -28
- package/src/types/event.ts +9 -42
- package/src/utils/events.ts +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/store/slices/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAEV,kCAAkC,EACnC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAC1D,O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I,CAAC;IACV,YAAY,EAAE,QAAQ,EAAE,CAAC;IACzB,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,qBAAqB,EAAE,MAAM,QAAQ,EAAE,CAAC;CACzC;AAqCD,eAAO,MAAM,iBAAiB,EAAE,2BAA2B,CACzD,kCAAkC,EAClC,WAAW,GAAG,aAAa,GAAG,SAAS,EACvC,WAAW,CA4HZ,CAAC"}
|
|
@@ -60,9 +60,7 @@ export interface WalletsSlice {
|
|
|
60
60
|
/**
|
|
61
61
|
* Add new accounts to store and fetch balances for them.
|
|
62
62
|
*/
|
|
63
|
-
newWalletConnected: (accounts: Wallet[], namespace?: Namespace, derivationPath?: string
|
|
64
|
-
walletName?: string;
|
|
65
|
-
}) => Promise<void>;
|
|
63
|
+
newWalletConnected: (accounts: Wallet[], namespace?: Namespace, derivationPath?: string) => Promise<void>;
|
|
66
64
|
disconnectNamespaces: (walletType: string, namespaces: Namespace[]) => void;
|
|
67
65
|
/**
|
|
68
66
|
* Disconnect a wallet and clean up balances after that.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../../src/store/slices/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAK5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../../src/store/slices/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,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1,13 @@
|
|
|
1
1
|
import type { SelectedQuote } from './quote';
|
|
2
|
-
import type { Wallet } from './wallets';
|
|
3
2
|
import type { RouteEventData, StepEventData } from '@rango-dev/queue-manager-rango-preset';
|
|
4
|
-
type
|
|
3
|
+
import type { WalletEventData } from '@rango-dev/wallets-react';
|
|
4
|
+
type EventData<T extends QuoteEventTypes | UiEventTypes, U extends Record<string, unknown> | null> = {
|
|
5
5
|
type: T;
|
|
6
6
|
payload: U;
|
|
7
7
|
};
|
|
8
8
|
export type PreventableEventPayload<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
9
9
|
preventDefault: () => void;
|
|
10
10
|
} & T;
|
|
11
|
-
type Account = Wallet;
|
|
12
11
|
export declare enum QuoteEventTypes {
|
|
13
12
|
QUOTE_INPUT_UPDATE = "quoteInputUpdate",
|
|
14
13
|
QUOTE_OUTPUT_UPDATE = "quoteOutputUpdate",
|
|
@@ -21,11 +20,6 @@ export declare enum QuoteEventTypes {
|
|
|
21
20
|
/** The user overrode the auto-selected route. */
|
|
22
21
|
ROUTE_CHANGED = "routeChanged"
|
|
23
22
|
}
|
|
24
|
-
export declare enum WalletEventTypes {
|
|
25
|
-
CONNECT = "connect",
|
|
26
|
-
DISCONNECT = "disconnect",
|
|
27
|
-
DETECTED = "detected"
|
|
28
|
-
}
|
|
29
23
|
/**
|
|
30
24
|
* We use a prefix for interaction type and a name for defining the event name: INTERACTION_EVENT_NAME
|
|
31
25
|
* e.g. CLICK_X_BUTTON or NAVIGATE_WALLET_PAGE
|
|
@@ -63,21 +57,6 @@ export type QuoteInputUpdateEventPayload = {
|
|
|
63
57
|
requestAmount?: string;
|
|
64
58
|
};
|
|
65
59
|
export type QuoteUpdateEventPayload = Pick<SelectedQuote, 'requestAmount' | 'swaps' | 'outputAmount' | 'resultType' | 'tags'> | null;
|
|
66
|
-
export type ConnectWalletEventPayload = {
|
|
67
|
-
walletType: string;
|
|
68
|
-
accounts: Account[];
|
|
69
|
-
/** Blockchain of the first connected account. */
|
|
70
|
-
chain: string | null;
|
|
71
|
-
/** wallet type (e.g. "metamask"). */
|
|
72
|
-
walletName: string;
|
|
73
|
-
};
|
|
74
|
-
export type DisconnectWalletEventPayload = {
|
|
75
|
-
walletType: string;
|
|
76
|
-
walletName: string;
|
|
77
|
-
};
|
|
78
|
-
export type WalletDetectedEventPayload = {
|
|
79
|
-
walletName: string;
|
|
80
|
-
};
|
|
81
60
|
export type ClickConnectWalletPayload = PreventableEventPayload;
|
|
82
61
|
/** Shared shape describing a route/quote, used by several swap events. */
|
|
83
62
|
export type SwapEstimateEventPayload = {
|
|
@@ -197,14 +176,7 @@ export type SwapCancelledEventPayload = {
|
|
|
197
176
|
routeId: string;
|
|
198
177
|
};
|
|
199
178
|
export type QuoteEventData = EventData<QuoteEventTypes.QUOTE_INPUT_UPDATE, QuoteInputUpdateEventPayload> | EventData<QuoteEventTypes.QUOTE_OUTPUT_UPDATE, QuoteUpdateEventPayload> | EventData<QuoteEventTypes.ROUTE_REQUESTED, RouteRequestedEventPayload> | EventData<QuoteEventTypes.ROUTE_NOT_FOUND, RouteNotFoundEventPayload> | EventData<QuoteEventTypes.ROUTE_FETCH_FAILED, RouteFetchFailedEventPayload> | EventData<QuoteEventTypes.ROUTE_CHANGED, RouteChangedEventPayload>;
|
|
200
|
-
export type WalletEventData = EventData<WalletEventTypes.CONNECT, ConnectWalletEventPayload> | EventData<WalletEventTypes.DISCONNECT, DisconnectWalletEventPayload> | EventData<WalletEventTypes.DETECTED, WalletDetectedEventPayload>;
|
|
201
179
|
export type UiEventData = EventData<UiEventTypes.CLICK_CONNECT_WALLET, ClickConnectWalletPayload> | EventData<UiEventTypes.TOKEN_SELECTED, TokenSelectedEventPayload> | EventData<UiEventTypes.CHAIN_FILTER_APPLIED, ChainFilterAppliedEventPayload> | EventData<UiEventTypes.SETTINGS_CHANGED, SettingsChangedEventPayload> | EventData<UiEventTypes.ROUTE_FEE_VIEWED, RouteFeeViewedEventPayload> | EventData<UiEventTypes.DESTINATION_ADDRESS_SET, DestinationAddressSetEventPayload> | EventData<UiEventTypes.GAS_WARNING_SHOWN, GasWarningEventPayload> | EventData<UiEventTypes.GAS_WARNING_BYPASSED, GasWarningEventPayload> | EventData<UiEventTypes.SWAP_INITIATED, SwapInitiatedEventPayload> | EventData<UiEventTypes.SWAP_WALLETS_MODAL_SHOWN, SwapWalletsModalShownEventPayload> | EventData<UiEventTypes.SWAP_WALLETS_CONFIRMED, SwapWalletsConfirmedEventPayload> | EventData<UiEventTypes.SWAP_STARTED, SwapStartedEventPayload> | EventData<UiEventTypes.SWAP_RESUMED, SwapResumedEventPayload> | EventData<UiEventTypes.SWAP_RETRIED, SwapRetriedEventPayload> | EventData<UiEventTypes.SWAP_CANCELLED, SwapCancelledEventPayload>;
|
|
202
|
-
/**
|
|
203
|
-
* RouteEvent/StepEvent must match the queue-manager's `WidgetEvents` string
|
|
204
|
-
* values (`QueueManagerEvents`) so events route correctly. They're inlined as
|
|
205
|
-
* literals rather than referencing the other enum to keep this a pure string
|
|
206
|
-
* enum (a cross-enum reference makes `no-mixed-enums` read them as numeric).
|
|
207
|
-
*/
|
|
208
180
|
export declare enum WidgetEvents {
|
|
209
181
|
RouteEvent = "routeEvent",
|
|
210
182
|
StepEvent = "stepEvent",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/types/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/types/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAKhE,KAAK,SAAS,CACZ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yB,CAAC,CAAC;AAEtE,oBAAY,YAAY;IACtB,UAAU,eAAgC;IAC1C,SAAS,cAA+B;IACxC,UAAU,eAAe;IAEzB,WAAW,gBAA0B;IACrC,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;IAC1C,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;IACxC,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;IAC1C,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC5C,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;CACrC,CAAC;AAEF,OAAO,MAAM,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAE5D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,CAAC,GAAG,SAAS,YAAY,EACzB,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GACjC,IAAI,CAAC;IACR,GAAG,CAAC,GAAG,SAAS,YAAY,EAC1B,IAAI,EAAE,GAAG,EACT,OAAO,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAClC,IAAI,CAAC;CACT,CAAC"}
|
package/dist/utils/events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ClickConnectWalletPayload, type QuoteEventData, type UiEventData, type UiEventTypes
|
|
1
|
+
import { type ClickConnectWalletPayload, type QuoteEventData, type UiEventData, type UiEventTypes } from '../types';
|
|
2
2
|
type PreventableUiEvent = {
|
|
3
3
|
type: UiEventTypes.CLICK_CONNECT_WALLET;
|
|
4
4
|
payload?: Omit<ClickConnectWalletPayload, 'preventDefault'>;
|
|
@@ -6,6 +6,5 @@ type PreventableUiEvent = {
|
|
|
6
6
|
export declare function emitUiEvent(event: UiEventData): void;
|
|
7
7
|
export declare function emitPreventableEvent(event: PreventableUiEvent, action: () => void): void;
|
|
8
8
|
export declare function emitQuoteEvent(event: QuoteEventData): void;
|
|
9
|
-
export declare function emitWalletDetected(payload: WalletDetectedEventPayload): void;
|
|
10
9
|
export {};
|
|
11
10
|
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/utils/events.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/utils/events.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,EAElB,MAAM,UAAU,CAAC;AAElB,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,YAAY,CAAC,oBAAoB,CAAC;IACxC,OAAO,CAAC,EAAE,IAAI,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,CAAC;CAC7D,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAEpD;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,kBAAkB,EACzB,MAAM,EAAE,MAAM,IAAI,GACjB,IAAI,CAeN;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAE1D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.64.4-next.
|
|
3
|
+
"version": "0.64.4-next.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -23,19 +23,29 @@
|
|
|
23
23
|
"test:coverage": "vitest run --coverage"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@hub3js/
|
|
27
|
-
"@hub3js/
|
|
26
|
+
"@hub3js/bip122": "^0.3.0",
|
|
27
|
+
"@hub3js/core": "^0.63.0",
|
|
28
|
+
"@hub3js/evm": "^0.6.0",
|
|
29
|
+
"@hub3js/namespaces": "^0.7.0",
|
|
30
|
+
"@hub3js/solana": "^0.6.0",
|
|
31
|
+
"@hub3js/starknet": "^0.5.0",
|
|
32
|
+
"@hub3js/std": "^0.5.0",
|
|
33
|
+
"@hub3js/stellar": "^0.5.0",
|
|
34
|
+
"@hub3js/sui": "^0.5.0",
|
|
35
|
+
"@hub3js/tron": "^0.2.0",
|
|
36
|
+
"@hub3js/tvm": "^0.5.0",
|
|
37
|
+
"@hub3js/xrpl": "^0.5.0",
|
|
28
38
|
"@lingui/core": "4.2.1",
|
|
29
39
|
"@lingui/react": "4.2.1",
|
|
30
|
-
"@rango-dev/internal-blockchains": "^0.2.2-next.
|
|
40
|
+
"@rango-dev/internal-blockchains": "^0.2.2-next.3",
|
|
31
41
|
"@rango-dev/logging-core": "^0.15.1-next.0",
|
|
32
|
-
"@rango-dev/provider-all": "^0.66.4-next.
|
|
42
|
+
"@rango-dev/provider-all": "^0.66.4-next.9",
|
|
33
43
|
"@rango-dev/queue-manager-core": "^0.35.1-next.0",
|
|
34
|
-
"@rango-dev/queue-manager-rango-preset": "^0.65.2-next.
|
|
44
|
+
"@rango-dev/queue-manager-rango-preset": "^0.65.2-next.7",
|
|
35
45
|
"@rango-dev/queue-manager-react": "^0.35.1-next.0",
|
|
36
|
-
"@rango-dev/signer-solana": "^0.50.1-next.
|
|
37
|
-
"@rango-dev/ui": "^0.66.2-next.
|
|
38
|
-
"@rango-dev/wallets-react": "^0.49.2-next.
|
|
46
|
+
"@rango-dev/signer-solana": "^0.50.1-next.1",
|
|
47
|
+
"@rango-dev/ui": "^0.66.2-next.6",
|
|
48
|
+
"@rango-dev/wallets-react": "^0.49.2-next.6",
|
|
39
49
|
"bignumber.js": "^9.1.1",
|
|
40
50
|
"copy-to-clipboard": "^3.3.3",
|
|
41
51
|
"crypto-browserify": "^3.12.1",
|
|
@@ -43,8 +53,8 @@
|
|
|
43
53
|
"ethers": "^6.13.2",
|
|
44
54
|
"immer": "^9.0.19",
|
|
45
55
|
"mitt": "^3.0.0",
|
|
46
|
-
"rango-sdk": "^0.
|
|
47
|
-
"rango-types": "^0.
|
|
56
|
+
"rango-sdk": "^0.6.0",
|
|
57
|
+
"rango-types": "^0.6.0",
|
|
48
58
|
"react": "^18.2.0",
|
|
49
59
|
"react-dom": "^18.2.0",
|
|
50
60
|
"react-i18next": "^12.2.0",
|
|
@@ -6,7 +6,7 @@ import { Events } from '@rango-dev/wallets-react';
|
|
|
6
6
|
/*
|
|
7
7
|
* propagate updates for Dapps using external wallets
|
|
8
8
|
*
|
|
9
|
-
* Note: to take more control over the public interface and
|
|
9
|
+
* Note: to take more control over the public interface and `@hub3js/core` interface (which may be changed) we use this layer
|
|
10
10
|
*/
|
|
11
11
|
export function propagateEvents(
|
|
12
12
|
cb: OnUpdateState,
|
|
@@ -14,10 +14,7 @@ export function propagateEvents(
|
|
|
14
14
|
): void {
|
|
15
15
|
const [walletType, event, value, coreState, info] = eventParams;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
* PROVIDER_DISCONNECTED has conflict with WalletEventTypes.DISCONNECT since they are doing samething, the first one is using only for Hub, the second one is what we exposed to the lib users.
|
|
19
|
-
* so for backward-compat we need to keep the behavior of WalletEventTypes.DISCONNECT
|
|
20
|
-
*/
|
|
17
|
+
// PROVIDER_DISCONNECTED is used only by the hub, so it isn't propagated to lib users.
|
|
21
18
|
if (event === Events.PROVIDER_DISCONNECTED) {
|
|
22
19
|
return;
|
|
23
20
|
}
|
|
@@ -13,6 +13,7 @@ import { Provider } from '@rango-dev/wallets-react';
|
|
|
13
13
|
import React, { createContext, useEffect, useMemo, useRef } from 'react';
|
|
14
14
|
|
|
15
15
|
import { useWalletProviders } from '../../hooks/useWalletProviders';
|
|
16
|
+
import { eventEmitter } from '../../services/eventEmitter';
|
|
16
17
|
import { AppStoreProvider, useAppStore } from '../../store/AppStore';
|
|
17
18
|
import { useUiStore } from '../../store/ui';
|
|
18
19
|
|
|
@@ -88,6 +89,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
88
89
|
<Provider
|
|
89
90
|
allBlockChains={blockchains}
|
|
90
91
|
providers={providers}
|
|
92
|
+
emitter={eventEmitter}
|
|
91
93
|
onUpdateState={(type, event, value, state, info) => {
|
|
92
94
|
const eventParams: Parameters<EventHandler> = [
|
|
93
95
|
type,
|
|
@@ -68,9 +68,7 @@ export function useUpdates(params: UseUpdatesParams): UseUpdates {
|
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
if (data.length) {
|
|
71
|
-
void newWalletConnected(data, info.namespace, state.derivationPath
|
|
72
|
-
walletName: type,
|
|
73
|
-
});
|
|
71
|
+
void newWalletConnected(data, info.namespace, state.derivationPath);
|
|
74
72
|
}
|
|
75
73
|
};
|
|
76
74
|
|
|
@@ -47,7 +47,7 @@ export interface UseStatefulConnect {
|
|
|
47
47
|
* This hook maintains state of wallet and checks if additional information
|
|
48
48
|
* is required to call the `connect` method of `core` package properly.
|
|
49
49
|
*
|
|
50
|
-
* The final goal is running `runConnect` which calls
|
|
50
|
+
* The final goal is running `runConnect` which calls `@hub3js/core`'s `connect` method.
|
|
51
51
|
* But sometimes it needs to get more information like what namespace it should be connected to,
|
|
52
52
|
* or what derivation path should be used for.
|
|
53
53
|
*
|
|
@@ -8,7 +8,6 @@ import { useCallback, useEffect } from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { useAppStore } from '../store/AppStore';
|
|
10
10
|
import { detectMobileScreens } from '../utils/common';
|
|
11
|
-
import { emitWalletDetected } from '../utils/events';
|
|
12
11
|
import { configWalletsToWalletName } from '../utils/providers';
|
|
13
12
|
import {
|
|
14
13
|
hashWalletsState,
|
|
@@ -18,26 +17,6 @@ import {
|
|
|
18
17
|
|
|
19
18
|
import { useStatefulConnect } from './useStatefulConnect/useStatefulConnect';
|
|
20
19
|
|
|
21
|
-
/**
|
|
22
|
-
* Wallet types we've already reported as detected this session. Module-scoped so
|
|
23
|
-
* the `walletDetected` event fires at most once per provider regardless of how
|
|
24
|
-
* often the wallet list re-renders or remounts.
|
|
25
|
-
*/
|
|
26
|
-
const detectedWalletsReported = new Set<string>();
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Wallet types that aren't browser-injected extensions (hardware wallets,
|
|
30
|
-
* WalletConnect, TON Connect). Their presence doesn't indicate an installed
|
|
31
|
-
* wallet, so they're excluded from the `walletDetected` signal.
|
|
32
|
-
*/
|
|
33
|
-
const NON_INJECTED_WALLET_TYPES = new Set<string>([
|
|
34
|
-
WalletTypes.LEDGER,
|
|
35
|
-
WalletTypes.TREZOR,
|
|
36
|
-
WalletTypes.WALLET_CONNECT_2,
|
|
37
|
-
WalletTypes.TON_CONNECT,
|
|
38
|
-
WalletTypes.DEFAULT,
|
|
39
|
-
]);
|
|
40
|
-
|
|
41
20
|
const DEFAULT_EVM_WALLETS = new Set<string>([
|
|
42
21
|
WalletTypes.DEFAULT,
|
|
43
22
|
WalletTypes.WALLET_CONNECT_2,
|
|
@@ -87,21 +66,6 @@ export function useWalletList(params?: Params): API {
|
|
|
87
66
|
|
|
88
67
|
const sortedWallets = sortWalletsBasedOnConnectionState(wallets);
|
|
89
68
|
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
wallets.forEach((wallet) => {
|
|
92
|
-
if (NON_INJECTED_WALLET_TYPES.has(wallet.type)) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const isDetected = wallet.state !== WalletState.NOT_INSTALLED;
|
|
96
|
-
if (isDetected && !detectedWalletsReported.has(wallet.type)) {
|
|
97
|
-
detectedWalletsReported.add(wallet.type);
|
|
98
|
-
emitWalletDetected({
|
|
99
|
-
walletName: wallet.type,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}, [hashWalletsState(wallets)]);
|
|
104
|
-
|
|
105
69
|
const terminateConnectingWallets = useCallback(() => {
|
|
106
70
|
const connectingWallets =
|
|
107
71
|
wallets?.filter((wallet) => wallet.state === WalletState.CONNECTING) ||
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
QuoteEventData,
|
|
7
7
|
Tokens,
|
|
8
8
|
UiEventData,
|
|
9
|
-
WalletEventData,
|
|
10
9
|
WalletInfoWithExtra,
|
|
11
10
|
WidgetColors,
|
|
12
11
|
WidgetColorsKeys,
|
|
@@ -39,6 +38,7 @@ import type {
|
|
|
39
38
|
import type {
|
|
40
39
|
EventHandler as HandleWalletsUpdate,
|
|
41
40
|
ProviderInterface,
|
|
41
|
+
WalletEventData,
|
|
42
42
|
WalletInfo,
|
|
43
43
|
WalletState,
|
|
44
44
|
} from '@rango-dev/wallets-react';
|
|
@@ -52,7 +52,11 @@ import {
|
|
|
52
52
|
StepExecutionBlockedEventStatus,
|
|
53
53
|
StepExecutionEventStatus,
|
|
54
54
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
55
|
-
import {
|
|
55
|
+
import {
|
|
56
|
+
useWallets,
|
|
57
|
+
Events as WalletEvents,
|
|
58
|
+
WalletEventTypes,
|
|
59
|
+
} from '@rango-dev/wallets-react';
|
|
56
60
|
import { PendingSwapNetworkStatus } from 'rango-types';
|
|
57
61
|
|
|
58
62
|
import {
|
|
@@ -81,7 +85,6 @@ import {
|
|
|
81
85
|
WidgetEvents as MainEvents,
|
|
82
86
|
QuoteEventTypes,
|
|
83
87
|
UiEventTypes,
|
|
84
|
-
WalletEventTypes,
|
|
85
88
|
WidgetEvents,
|
|
86
89
|
} from './types';
|
|
87
90
|
import { customizedThemeTokens } from './utils/ui';
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
|
|
15
15
|
import { cacheService } from '../../services/cacheService';
|
|
16
16
|
import {
|
|
17
|
-
configWalletsToWalletName,
|
|
18
17
|
matchAndGenerateProviders,
|
|
19
18
|
type ProvidersOptions,
|
|
20
19
|
} from '../../utils/providers';
|
|
@@ -41,14 +40,6 @@ export const DEFAULT_CONFIG: WidgetConfigWithoutLegacyProviders = {
|
|
|
41
40
|
excludeLiquiditySources: true,
|
|
42
41
|
customDestination: true,
|
|
43
42
|
variant: 'default',
|
|
44
|
-
trezorManifest: {
|
|
45
|
-
appUrl: 'https://widget.rango.exchange/',
|
|
46
|
-
email: 'hi+trezorwidget@rango.exchange',
|
|
47
|
-
},
|
|
48
|
-
tonConnect: {
|
|
49
|
-
manifestUrl:
|
|
50
|
-
'https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/manifests/tonconnect/manifest.json',
|
|
51
|
-
},
|
|
52
43
|
};
|
|
53
44
|
|
|
54
45
|
interface IframeConfigs {
|
|
@@ -97,20 +88,33 @@ function generateProviders(
|
|
|
97
88
|
const allProviders = getAllProviders();
|
|
98
89
|
const allBuiltProviders = allProviders.map((build) => build());
|
|
99
90
|
|
|
100
|
-
|
|
91
|
+
return allBuiltProviders.filter((provider) =>
|
|
92
|
+
hasRequiredConfig(provider.id, config)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
96
|
+
const REQUIRED_CONFIG_BY_WALLET: Partial<
|
|
97
|
+
Record<string, keyof WidgetConfigWithoutLegacyProviders>
|
|
98
|
+
> = {
|
|
99
|
+
[WalletTypes.LEDGER_WALLET]: 'ledgerWallet',
|
|
100
|
+
[WalletTypes.TREZOR]: 'trezorManifest',
|
|
101
|
+
[WalletTypes.TON_CONNECT]: 'tonConnect',
|
|
102
|
+
[WalletTypes.WALLET_CONNECT_2]: 'walletConnectProjectId',
|
|
103
|
+
};
|
|
109
104
|
|
|
105
|
+
function hasRequiredConfig(
|
|
106
|
+
walletId: string,
|
|
107
|
+
config: WidgetConfigWithoutLegacyProviders
|
|
108
|
+
): boolean {
|
|
109
|
+
const requiredKey = REQUIRED_CONFIG_BY_WALLET[walletId];
|
|
110
|
+
if (!requiredKey || config[requiredKey]) {
|
|
110
111
|
return true;
|
|
111
|
-
}
|
|
112
|
+
}
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
console.warn(
|
|
115
|
+
`${walletId} is listed in config wallets but ${requiredKey} config is not provided!`
|
|
116
|
+
);
|
|
117
|
+
return false;
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
export const createConfigSlice: StateCreatorWithInitialData<
|
|
@@ -6,14 +6,8 @@ import BigNumber from 'bignumber.js';
|
|
|
6
6
|
|
|
7
7
|
import { ZERO } from '../../constants/numbers';
|
|
8
8
|
import { BALANCE_SEPARATOR } from '../../constants/wallets';
|
|
9
|
-
import { eventEmitter } from '../../services/eventEmitter';
|
|
10
9
|
import { httpService } from '../../services/httpService';
|
|
11
|
-
import {
|
|
12
|
-
type Balance,
|
|
13
|
-
type Wallet,
|
|
14
|
-
WalletEventTypes,
|
|
15
|
-
WidgetEvents,
|
|
16
|
-
} from '../../types';
|
|
10
|
+
import { type Balance, type Wallet } from '../../types';
|
|
17
11
|
import { memoizedResult } from '../../utils/common';
|
|
18
12
|
import { isAccountAndWalletMatched } from '../../utils/wallets';
|
|
19
13
|
import { keepLastUpdated } from '../middlewares/keepLastUpdated';
|
|
@@ -114,8 +108,7 @@ export interface WalletsSlice {
|
|
|
114
108
|
newWalletConnected: (
|
|
115
109
|
accounts: Wallet[],
|
|
116
110
|
namespace?: Namespace,
|
|
117
|
-
derivationPath?: string
|
|
118
|
-
meta?: { walletName?: string }
|
|
111
|
+
derivationPath?: string
|
|
119
112
|
) => Promise<void>;
|
|
120
113
|
disconnectNamespaces: (walletType: string, namespaces: Namespace[]) => void;
|
|
121
114
|
/**
|
|
@@ -444,20 +437,11 @@ export const createWalletsSlice = keepLastUpdated<AppStoreState, WalletsSlice>(
|
|
|
444
437
|
connectedWallets: nextConnectedWalletsWithUpdatedSelectedStatus,
|
|
445
438
|
});
|
|
446
439
|
},
|
|
447
|
-
newWalletConnected: async (accounts, namespace, derivationPath
|
|
440
|
+
newWalletConnected: async (accounts, namespace, derivationPath) => {
|
|
448
441
|
const newAccount = accounts[0];
|
|
449
442
|
if (!newAccount) {
|
|
450
443
|
return;
|
|
451
444
|
}
|
|
452
|
-
eventEmitter.emit(WidgetEvents.WalletEvent, {
|
|
453
|
-
type: WalletEventTypes.CONNECT,
|
|
454
|
-
payload: {
|
|
455
|
-
walletType: newAccount.walletType,
|
|
456
|
-
accounts,
|
|
457
|
-
chain: newAccount.chain ?? null,
|
|
458
|
-
walletName: meta?.walletName ?? newAccount.walletType,
|
|
459
|
-
},
|
|
460
|
-
});
|
|
461
445
|
|
|
462
446
|
get().addConnectedWallet(accounts, namespace, derivationPath);
|
|
463
447
|
|
|
@@ -525,15 +509,6 @@ export const createWalletsSlice = keepLastUpdated<AppStoreState, WalletsSlice>(
|
|
|
525
509
|
get().connectedWallets.find(
|
|
526
510
|
(wallet) => wallet.walletType === walletType
|
|
527
511
|
);
|
|
528
|
-
/*
|
|
529
|
-
* Previously DISCONNECT event was being emitted if target wallet existed in connected wallets.
|
|
530
|
-
* Considering that connected wallets get clear on namespace disconnect in hub,
|
|
531
|
-
* now emitting this event is done without checking for connected wallets to be compatible with hub.
|
|
532
|
-
*/
|
|
533
|
-
eventEmitter.emit(WidgetEvents.WalletEvent, {
|
|
534
|
-
type: WalletEventTypes.DISCONNECT,
|
|
535
|
-
payload: { walletType, walletName: walletType },
|
|
536
|
-
});
|
|
537
512
|
if (isTargetWalletExistsInConnectedWallets) {
|
|
538
513
|
// This should be called before updating connectedWallets since we need the old state to remove balances.
|
|
539
514
|
get().removeBalancesForWallet(walletType);
|
package/src/types/event.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { SelectedQuote } from './quote';
|
|
2
|
-
import type { Wallet } from './wallets';
|
|
3
2
|
import type {
|
|
4
3
|
RouteEventData,
|
|
5
4
|
StepEventData,
|
|
6
5
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
6
|
+
import type { WalletEventData } from '@rango-dev/wallets-react';
|
|
7
|
+
|
|
8
|
+
import { WidgetEvents as QueueManagerEvents } from '@rango-dev/queue-manager-rango-preset';
|
|
9
|
+
import { WalletEventChannel } from '@rango-dev/wallets-react';
|
|
7
10
|
|
|
8
11
|
type EventData<
|
|
9
|
-
T extends QuoteEventTypes |
|
|
12
|
+
T extends QuoteEventTypes | UiEventTypes,
|
|
10
13
|
U extends Record<string, unknown> | null
|
|
11
14
|
> = { type: T; payload: U };
|
|
12
15
|
|
|
@@ -16,8 +19,6 @@ export type PreventableEventPayload<
|
|
|
16
19
|
preventDefault: () => void;
|
|
17
20
|
} & T;
|
|
18
21
|
|
|
19
|
-
type Account = Wallet;
|
|
20
|
-
|
|
21
22
|
export enum QuoteEventTypes {
|
|
22
23
|
QUOTE_INPUT_UPDATE = 'quoteInputUpdate',
|
|
23
24
|
QUOTE_OUTPUT_UPDATE = 'quoteOutputUpdate',
|
|
@@ -31,12 +32,6 @@ export enum QuoteEventTypes {
|
|
|
31
32
|
ROUTE_CHANGED = 'routeChanged',
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
export enum WalletEventTypes {
|
|
35
|
-
CONNECT = 'connect',
|
|
36
|
-
DISCONNECT = 'disconnect',
|
|
37
|
-
DETECTED = 'detected',
|
|
38
|
-
}
|
|
39
|
-
|
|
40
35
|
/**
|
|
41
36
|
* We use a prefix for interaction type and a name for defining the event name: INTERACTION_EVENT_NAME
|
|
42
37
|
* e.g. CLICK_X_BUTTON or NAVIGATE_WALLET_PAGE
|
|
@@ -72,24 +67,6 @@ export type QuoteUpdateEventPayload = Pick<
|
|
|
72
67
|
'requestAmount' | 'swaps' | 'outputAmount' | 'resultType' | 'tags'
|
|
73
68
|
> | null;
|
|
74
69
|
|
|
75
|
-
export type ConnectWalletEventPayload = {
|
|
76
|
-
walletType: string;
|
|
77
|
-
accounts: Account[];
|
|
78
|
-
/** Blockchain of the first connected account. */
|
|
79
|
-
chain: string | null;
|
|
80
|
-
/** wallet type (e.g. "metamask"). */
|
|
81
|
-
walletName: string;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export type DisconnectWalletEventPayload = {
|
|
85
|
-
walletType: string;
|
|
86
|
-
walletName: string;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type WalletDetectedEventPayload = {
|
|
90
|
-
walletName: string;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
70
|
export type ClickConnectWalletPayload = PreventableEventPayload;
|
|
94
71
|
|
|
95
72
|
/** Shared shape describing a route/quote, used by several swap events. */
|
|
@@ -217,11 +194,6 @@ export type QuoteEventData =
|
|
|
217
194
|
| EventData<QuoteEventTypes.ROUTE_FETCH_FAILED, RouteFetchFailedEventPayload>
|
|
218
195
|
| EventData<QuoteEventTypes.ROUTE_CHANGED, RouteChangedEventPayload>;
|
|
219
196
|
|
|
220
|
-
export type WalletEventData =
|
|
221
|
-
| EventData<WalletEventTypes.CONNECT, ConnectWalletEventPayload>
|
|
222
|
-
| EventData<WalletEventTypes.DISCONNECT, DisconnectWalletEventPayload>
|
|
223
|
-
| EventData<WalletEventTypes.DETECTED, WalletDetectedEventPayload>;
|
|
224
|
-
|
|
225
197
|
export type UiEventData =
|
|
226
198
|
| EventData<UiEventTypes.CLICK_CONNECT_WALLET, ClickConnectWalletPayload>
|
|
227
199
|
| EventData<UiEventTypes.TOKEN_SELECTED, TokenSelectedEventPayload>
|
|
@@ -248,17 +220,12 @@ export type UiEventData =
|
|
|
248
220
|
| EventData<UiEventTypes.SWAP_RETRIED, SwapRetriedEventPayload>
|
|
249
221
|
| EventData<UiEventTypes.SWAP_CANCELLED, SwapCancelledEventPayload>;
|
|
250
222
|
|
|
251
|
-
/**
|
|
252
|
-
* RouteEvent/StepEvent must match the queue-manager's `WidgetEvents` string
|
|
253
|
-
* values (`QueueManagerEvents`) so events route correctly. They're inlined as
|
|
254
|
-
* literals rather than referencing the other enum to keep this a pure string
|
|
255
|
-
* enum (a cross-enum reference makes `no-mixed-enums` read them as numeric).
|
|
256
|
-
*/
|
|
257
223
|
export enum WidgetEvents {
|
|
258
|
-
RouteEvent =
|
|
259
|
-
StepEvent =
|
|
224
|
+
RouteEvent = QueueManagerEvents.RouteEvent,
|
|
225
|
+
StepEvent = QueueManagerEvents.StepEvent,
|
|
260
226
|
QuoteEvent = 'quoteEvent',
|
|
261
|
-
|
|
227
|
+
// `isolatedModules` rejects a bare const reference in an enum initializer (TS18055).
|
|
228
|
+
WalletEvent = `${WalletEventChannel}`,
|
|
262
229
|
UiEvent = 'uiEvent',
|
|
263
230
|
}
|
|
264
231
|
|
package/src/utils/events.ts
CHANGED
|
@@ -4,8 +4,6 @@ import {
|
|
|
4
4
|
type QuoteEventData,
|
|
5
5
|
type UiEventData,
|
|
6
6
|
type UiEventTypes,
|
|
7
|
-
type WalletDetectedEventPayload,
|
|
8
|
-
WalletEventTypes,
|
|
9
7
|
WidgetEvents,
|
|
10
8
|
} from '../types';
|
|
11
9
|
|
|
@@ -41,10 +39,3 @@ export function emitPreventableEvent(
|
|
|
41
39
|
export function emitQuoteEvent(event: QuoteEventData): void {
|
|
42
40
|
eventEmitter.emit(WidgetEvents.QuoteEvent, event);
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
export function emitWalletDetected(payload: WalletDetectedEventPayload): void {
|
|
46
|
-
eventEmitter.emit(WidgetEvents.WalletEvent, {
|
|
47
|
-
type: WalletEventTypes.DETECTED,
|
|
48
|
-
payload,
|
|
49
|
-
});
|
|
50
|
-
}
|