@rango-dev/widget-embedded 0.51.1-next.0 → 0.51.1-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/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -1
- package/dist/components/Layout/Layout.constants.d.ts +5 -3
- package/dist/components/Layout/Layout.constants.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/ConnectStatus.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Detached.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
- package/dist/containers/App/App.styles.d.ts.map +1 -1
- package/dist/hooks/useScreenDetect.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts +2 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -17
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/common.d.ts +2 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +11 -1
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +6 -13
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +9 -9
- package/src/components/ConfirmWalletsModal/WalletList.tsx +10 -9
- package/src/components/HeaderButtons/WalletButton.tsx +4 -2
- package/src/components/Layout/Layout.constants.ts +5 -3
- package/src/components/Layout/Layout.styles.ts +12 -5
- package/src/components/Layout/Layout.tsx +18 -32
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +3 -3
- package/src/components/WalletStatefulConnect/ConnectStatus.tsx +6 -3
- package/src/components/WalletStatefulConnect/Detached.tsx +16 -4
- package/src/components/WalletStatefulConnect/Namespaces.tsx +16 -4
- package/src/containers/App/App.styles.ts +1 -0
- package/src/containers/Wallets/Wallets.tsx +1 -1
- package/src/hooks/useScreenDetect.ts +7 -1
- package/src/hooks/useWalletList.ts +2 -5
- package/src/hooks/useWalletProviders/useWalletProviders.helpers.ts +6 -1
- package/src/index.ts +2 -0
- package/src/pages/SelectBlockchainPage.tsx +14 -5
- package/src/pages/WalletsPage.tsx +1 -20
- package/src/store/slices/data.ts +2 -13
- package/src/types/config.ts +4 -17
- package/src/utils/common.ts +16 -1
- package/src/utils/providers.ts +1 -1
- package/src/utils/wallets.ts +42 -52
- package/dist/hooks/useDeepLink.d.ts +0 -7
- package/dist/hooks/useDeepLink.d.ts.map +0 -1
- package/src/hooks/useDeepLink.ts +0 -48
package/src/types/config.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Language, theme } from '@rango-dev/ui';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Provider } from '@rango-dev/wallets-core';
|
|
3
|
+
import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
|
|
3
4
|
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
4
5
|
import type { Asset } from 'rango-sdk';
|
|
5
6
|
import type { ReactElement } from 'react';
|
|
@@ -175,19 +176,7 @@ export type TrezorManifest = {
|
|
|
175
176
|
appUrl: string;
|
|
176
177
|
email: string;
|
|
177
178
|
};
|
|
178
|
-
|
|
179
|
-
* `DeepLinking`
|
|
180
|
-
*
|
|
181
|
-
* @property {string} [targetUrl]
|
|
182
|
-
* - The URL to be opened in the provider's in-app browser.
|
|
183
|
-
*
|
|
184
|
-
* @property {string} [appHost]
|
|
185
|
-
* - The full domain of the app, excluding the protocol (https://), path, and query parameters.
|
|
186
|
-
*/
|
|
187
|
-
export type DeepLinking = {
|
|
188
|
-
targetUrl: string;
|
|
189
|
-
appHost: string;
|
|
190
|
-
};
|
|
179
|
+
|
|
191
180
|
/**
|
|
192
181
|
*
|
|
193
182
|
* @property {string} manifestUrl - The URL of the TON Connect [manifest]{@link https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest}, containing the Dapp metadata to be displayed in the user’s wallet.
|
|
@@ -235,7 +224,6 @@ export type TonConnectConfig = {
|
|
|
235
224
|
* @property {WidgetTheme} theme - The `theme` property is a part of the `WidgetConfig` type and is
|
|
236
225
|
* used to specify the visual theme of the widget. It is of type `WidgetTheme`, which is an interface
|
|
237
226
|
* that defines the various properties of the theme, such as colors, fonts, and others.
|
|
238
|
-
* @property {DeepLinking} deepLinking - Configures deep linking parameters for providers that support it.
|
|
239
227
|
* @property {boolean} externalWallets
|
|
240
228
|
* If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
|
|
241
229
|
* @property {boolean} excludeLiquiditySources - The `excludeLiquiditySources` property is a boolean value that when you
|
|
@@ -272,13 +260,12 @@ export type WidgetConfig = {
|
|
|
272
260
|
from?: BlockchainAndTokenConfig;
|
|
273
261
|
to?: BlockchainAndTokenConfig;
|
|
274
262
|
liquiditySources?: string[];
|
|
275
|
-
wallets?: (WalletType | LegacyProviderInterface)[];
|
|
263
|
+
wallets?: (WalletType | LegacyProviderInterface | Provider)[];
|
|
276
264
|
multiWallets?: boolean;
|
|
277
265
|
customDestination?: boolean;
|
|
278
266
|
defaultCustomDestinations?: { [blockchain: string]: string };
|
|
279
267
|
language?: Language;
|
|
280
268
|
theme?: WidgetTheme;
|
|
281
|
-
deepLinking?: DeepLinking;
|
|
282
269
|
externalWallets?: boolean;
|
|
283
270
|
excludeLiquiditySources?: boolean;
|
|
284
271
|
features?: Features;
|
package/src/utils/common.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WalletInfoWithExtra } from '../types';
|
|
2
|
-
import type { Token } from 'rango-sdk';
|
|
2
|
+
import type { BlockchainMeta, Token } from 'rango-sdk';
|
|
3
3
|
|
|
4
4
|
import { BlockchainCategories, WalletState } from '@rango-dev/ui';
|
|
5
5
|
import { TransactionType } from 'rango-sdk';
|
|
@@ -280,3 +280,18 @@ export function memoizedResult(): <R>(fn: () => R, key: number | string) => R {
|
|
|
280
280
|
return result;
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
|
+
|
|
284
|
+
export function filterBlockchainsWithAtLeastOneToken(
|
|
285
|
+
blockchains: BlockchainMeta[],
|
|
286
|
+
tokens: Token[]
|
|
287
|
+
) {
|
|
288
|
+
const blockchainsWithAtLeastOneToken = new Set<string>();
|
|
289
|
+
|
|
290
|
+
tokens.forEach((token) => {
|
|
291
|
+
blockchainsWithAtLeastOneToken.add(token.blockchain);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
return blockchains.filter((blockchain) =>
|
|
295
|
+
blockchainsWithAtLeastOneToken.has(blockchain.name)
|
|
296
|
+
);
|
|
297
|
+
}
|
package/src/utils/providers.ts
CHANGED
|
@@ -95,7 +95,7 @@ export function matchAndGenerateProviders({
|
|
|
95
95
|
return allProviders;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
function pickProviderVersionWithFallbackToLegacy(
|
|
98
|
+
export function pickProviderVersionWithFallbackToLegacy(
|
|
99
99
|
provider: VersionedProviders
|
|
100
100
|
): BothProvidersInterface {
|
|
101
101
|
try {
|
package/src/utils/wallets.ts
CHANGED
|
@@ -5,11 +5,12 @@ import type {
|
|
|
5
5
|
Wallet,
|
|
6
6
|
WalletInfoWithExtra,
|
|
7
7
|
} from '../types';
|
|
8
|
-
import type {
|
|
9
|
-
|
|
8
|
+
import type {
|
|
9
|
+
ExtendedWalletInfo,
|
|
10
|
+
ProviderContext,
|
|
11
|
+
} from '@rango-dev/wallets-react';
|
|
10
12
|
import type {
|
|
11
13
|
Network,
|
|
12
|
-
WalletState,
|
|
13
14
|
WalletType,
|
|
14
15
|
WalletTypes,
|
|
15
16
|
} from '@rango-dev/wallets-shared';
|
|
@@ -46,19 +47,27 @@ import { formatThousandsWithCommas } from './sanitizers';
|
|
|
46
47
|
export type ExtendedModalWalletInfo = WalletInfoWithExtra &
|
|
47
48
|
Pick<ExtendedWalletInfo, 'properties' | 'isHub'>;
|
|
48
49
|
|
|
49
|
-
export function
|
|
50
|
-
|
|
50
|
+
export function getWalletConnectionStatus(
|
|
51
|
+
wallet: ExtendedWalletInfo,
|
|
52
|
+
walletState: ReturnType<ProviderContext['state']>
|
|
53
|
+
): WalletStatus {
|
|
54
|
+
if (checkIsWalletPartiallyConnected(wallet, walletState)) {
|
|
55
|
+
return WalletStatus.PARTIALLY_CONNECTED;
|
|
56
|
+
}
|
|
57
|
+
if (walletState.connected) {
|
|
51
58
|
return WalletStatus.CONNECTED;
|
|
52
|
-
}
|
|
59
|
+
}
|
|
60
|
+
if (walletState.connecting) {
|
|
53
61
|
return WalletStatus.CONNECTING;
|
|
54
|
-
}
|
|
62
|
+
}
|
|
63
|
+
if (!walletState.installed) {
|
|
55
64
|
return WalletStatus.NOT_INSTALLED;
|
|
56
65
|
}
|
|
57
66
|
return WalletStatus.DISCONNECTED;
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
export function mapWalletTypesToWalletInfo(
|
|
61
|
-
getState:
|
|
70
|
+
getState: ProviderContext['state'],
|
|
62
71
|
getWalletInfo: (type: WalletType) => ExtendedWalletInfo,
|
|
63
72
|
list: WalletType[],
|
|
64
73
|
chain?: string
|
|
@@ -96,7 +105,11 @@ export function mapWalletTypesToWalletInfo(
|
|
|
96
105
|
const blockchainTypes = removeDuplicateFrom(
|
|
97
106
|
supportedChains.map((item) => item.type)
|
|
98
107
|
);
|
|
99
|
-
|
|
108
|
+
|
|
109
|
+
const state = getWalletConnectionStatus(
|
|
110
|
+
getWalletInfo(type),
|
|
111
|
+
getState(type)
|
|
112
|
+
);
|
|
100
113
|
return {
|
|
101
114
|
title: name,
|
|
102
115
|
image,
|
|
@@ -112,6 +125,7 @@ export function mapWalletTypesToWalletInfo(
|
|
|
112
125
|
};
|
|
113
126
|
});
|
|
114
127
|
}
|
|
128
|
+
|
|
115
129
|
export function walletAndSupportedChainsNames(
|
|
116
130
|
supportedBlockchains: BlockchainMeta[]
|
|
117
131
|
): Network[] | null {
|
|
@@ -418,42 +432,22 @@ export function areTokensEqual(
|
|
|
418
432
|
}
|
|
419
433
|
|
|
420
434
|
export function sortWalletsBasedOnConnectionState(
|
|
421
|
-
wallets: ExtendedModalWalletInfo[]
|
|
422
|
-
state: (type: WalletType) => {
|
|
423
|
-
namespaces?: Map<Namespace, { connected: boolean }>;
|
|
424
|
-
}
|
|
435
|
+
wallets: ExtendedModalWalletInfo[]
|
|
425
436
|
): ExtendedModalWalletInfo[] {
|
|
426
|
-
return (
|
|
427
|
-
|
|
428
|
-
.
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
) -
|
|
441
|
-
Number(
|
|
442
|
-
a.state === WalletStatus.CONNECTED && !a.isPartiallyConnected
|
|
443
|
-
) ||
|
|
444
|
-
Number(b.state === WalletStatus.CONNECTED) -
|
|
445
|
-
Number(a.state === WalletStatus.CONNECTED) ||
|
|
446
|
-
Number(
|
|
447
|
-
b.state === WalletStatus.DISCONNECTED ||
|
|
448
|
-
b.state === WalletStatus.CONNECTING
|
|
449
|
-
) -
|
|
450
|
-
Number(
|
|
451
|
-
a.state === WalletStatus.DISCONNECTED ||
|
|
452
|
-
a.state === WalletStatus.CONNECTING
|
|
453
|
-
)
|
|
454
|
-
)
|
|
455
|
-
// remove isPartiallyConnected from wallet items
|
|
456
|
-
.map(({ isPartiallyConnected, ...wallet }) => wallet)
|
|
437
|
+
return wallets.sort(
|
|
438
|
+
(a, b) =>
|
|
439
|
+
Number(b.state === WalletStatus.CONNECTED) -
|
|
440
|
+
Number(a.state === WalletStatus.CONNECTED) ||
|
|
441
|
+
Number(b.state === WalletStatus.PARTIALLY_CONNECTED) -
|
|
442
|
+
Number(a.state === WalletStatus.PARTIALLY_CONNECTED) ||
|
|
443
|
+
Number(
|
|
444
|
+
b.state === WalletStatus.DISCONNECTED ||
|
|
445
|
+
b.state === WalletStatus.CONNECTING
|
|
446
|
+
) -
|
|
447
|
+
Number(
|
|
448
|
+
a.state === WalletStatus.DISCONNECTED ||
|
|
449
|
+
a.state === WalletStatus.CONNECTING
|
|
450
|
+
)
|
|
457
451
|
);
|
|
458
452
|
}
|
|
459
453
|
|
|
@@ -536,14 +530,10 @@ export function filterWalletsByCategory(
|
|
|
536
530
|
}
|
|
537
531
|
|
|
538
532
|
export function checkIsWalletPartiallyConnected(
|
|
539
|
-
wallet:
|
|
540
|
-
|
|
533
|
+
wallet: ExtendedWalletInfo,
|
|
534
|
+
walletState: ReturnType<ProviderContext['state']>
|
|
541
535
|
) {
|
|
542
|
-
if (
|
|
543
|
-
!wallet.isHub ||
|
|
544
|
-
!wallet.needsNamespace ||
|
|
545
|
-
wallet.state !== WalletStatus.CONNECTED
|
|
546
|
-
) {
|
|
536
|
+
if (!wallet.isHub || !wallet.needsNamespace || !walletState.connected) {
|
|
547
537
|
return false;
|
|
548
538
|
}
|
|
549
539
|
const namespaces = wallet.needsNamespace.data;
|
|
@@ -555,7 +545,7 @@ export function checkIsWalletPartiallyConnected(
|
|
|
555
545
|
return (
|
|
556
546
|
wallet.needsNamespace.selection === 'multiple' &&
|
|
557
547
|
supportedNamespaces.some(
|
|
558
|
-
(namespace) => !
|
|
548
|
+
(namespace) => !walletState.namespaces?.get(namespace.value)?.connected
|
|
559
549
|
)
|
|
560
550
|
);
|
|
561
551
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { InstallObjects } from '@rango-dev/wallets-shared';
|
|
2
|
-
export declare function useDeepLink(): {
|
|
3
|
-
getWalletDeepLink: (walletType: string) => string | undefined;
|
|
4
|
-
getWalletLink: (walletType: string) => string | InstallObjects;
|
|
5
|
-
checkHasDeepLink: (walletType: string) => boolean;
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=useDeepLink.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepLink.d.ts","sourceRoot":"","sources":["../../src/hooks/useDeepLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAOhE,wBAAgB,WAAW;oCAKc,MAAM,KAAG,MAAM,GAAG,SAAS;gCAsB/B,MAAM,KAAG,MAAM,GAAG,cAAc;mCAS7B,MAAM,KAAG,OAAO;EAIvD"}
|
package/src/hooks/useDeepLink.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { InstallObjects } from '@rango-dev/wallets-shared';
|
|
2
|
-
|
|
3
|
-
import { useWallets } from '@rango-dev/wallets-react';
|
|
4
|
-
import { detectMobileScreens } from '@rango-dev/wallets-shared';
|
|
5
|
-
|
|
6
|
-
import { useAppStore } from '../store/AppStore';
|
|
7
|
-
|
|
8
|
-
export function useDeepLink() {
|
|
9
|
-
const { getWalletInfo } = useWallets();
|
|
10
|
-
const { config } = useAppStore();
|
|
11
|
-
const isMobileScreen = detectMobileScreens();
|
|
12
|
-
|
|
13
|
-
function getWalletDeepLink(walletType: string): string | undefined {
|
|
14
|
-
const wallet = getWalletInfo(walletType);
|
|
15
|
-
const appHost = config.deepLinking?.appHost;
|
|
16
|
-
const targetUrl = config.deepLinking?.targetUrl;
|
|
17
|
-
if (!appHost || !targetUrl) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
return wallet.generateDeepLink?.({
|
|
21
|
-
appHost,
|
|
22
|
-
targetUrl,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Returns the appropriate wallet link based on the given wallet type.
|
|
28
|
-
*
|
|
29
|
-
* If a deep link is available and the user is on a mobile screen, the deep link is returned.
|
|
30
|
-
* Otherwise, it falls back to returning the wallet's install link.
|
|
31
|
-
*
|
|
32
|
-
* @param {string} walletType - The type of the wallet (e.g., 'metamask', 'trust-wallet').
|
|
33
|
-
* @returns {string | InstallObjects} - A deep link string if available on mobile, or an install link object otherwise.
|
|
34
|
-
*/
|
|
35
|
-
function getWalletLink(walletType: string): string | InstallObjects {
|
|
36
|
-
const deepLink = getWalletDeepLink(walletType);
|
|
37
|
-
if (deepLink && isMobileScreen) {
|
|
38
|
-
return deepLink;
|
|
39
|
-
}
|
|
40
|
-
const wallet = getWalletInfo(walletType);
|
|
41
|
-
return wallet.installLink;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function checkHasDeepLink(walletType: string): boolean {
|
|
45
|
-
return !!getWalletDeepLink(walletType) && isMobileScreen;
|
|
46
|
-
}
|
|
47
|
-
return { getWalletDeepLink, getWalletLink, checkHasDeepLink };
|
|
48
|
-
}
|