@rango-dev/widget-embedded 0.63.1-next.3 → 0.63.1-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/QueueManager.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +7 -3
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.test.d.ts +2 -0
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.test.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +5 -4
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +3 -3
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/types/config.d.ts +16 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +1 -1
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/common.d.ts +1 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/QueueManager.tsx +2 -6
- package/src/components/NamespaceItem/NamespaceItem.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.tsx +8 -2
- package/src/components/WalletStatefulConnect/DerivationPath.helpers.test.ts +98 -0
- package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +14 -10
- package/src/components/WalletStatefulConnect/DerivationPath.tsx +14 -7
- package/src/components/WalletStatefulConnect/Namespaces.tsx +1 -1
- package/src/containers/Wallets/Wallets.tsx +4 -1
- package/src/containers/Wallets/useUpdates.ts +1 -1
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +5 -2
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +6 -3
- package/src/hooks/useWalletList.ts +9 -6
- package/src/index.ts +4 -7
- package/src/store/slices/config.ts +25 -6
- package/src/types/config.ts +20 -2
- package/src/types/wallets.ts +1 -1
- package/src/utils/common.ts +6 -0
- package/src/utils/swap.ts +1 -1
- package/src/utils/wallets.ts +14 -13
|
@@ -4,10 +4,14 @@ import type { WidgetConfig } from '../../types';
|
|
|
4
4
|
import type { StateCreatorWithInitialData } from '../app';
|
|
5
5
|
import type { VersionedProviders } from '@hub3js/core/utils';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
allProviders as getAllProviders,
|
|
9
|
+
WalletTypes,
|
|
10
|
+
} from '@rango-dev/provider-all';
|
|
8
11
|
|
|
9
12
|
import { cacheService } from '../../services/cacheService';
|
|
10
13
|
import {
|
|
14
|
+
configWalletsToWalletName,
|
|
11
15
|
matchAndGenerateProviders,
|
|
12
16
|
type ProvidersOptions,
|
|
13
17
|
} from '../../utils/providers';
|
|
@@ -84,11 +88,24 @@ export interface ConfigSlice {
|
|
|
84
88
|
getAvailableProviders: () => VersionedProviders[];
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
function generateProviders() {
|
|
91
|
+
function generateProviders(config: WidgetConfig): VersionedProviders[] {
|
|
88
92
|
const allProviders = getAllProviders();
|
|
89
93
|
const allBuiltProviders = allProviders.map((build) => build());
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
const providerNames = configWalletsToWalletName(allBuiltProviders);
|
|
96
|
+
|
|
97
|
+
const filteredProviders = allBuiltProviders.filter((_, index) => {
|
|
98
|
+
if (
|
|
99
|
+
providerNames[index] === WalletTypes.LEDGER_WALLET &&
|
|
100
|
+
(!config.ledgerWallet?.apiKey || !config.ledgerWallet?.dAppIdentifier)
|
|
101
|
+
) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return true;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return filteredProviders;
|
|
92
109
|
}
|
|
93
110
|
|
|
94
111
|
export const createConfigSlice: StateCreatorWithInitialData<
|
|
@@ -96,9 +113,10 @@ export const createConfigSlice: StateCreatorWithInitialData<
|
|
|
96
113
|
ConfigSlice & SettingsSlice & DataSlice,
|
|
97
114
|
ConfigSlice
|
|
98
115
|
> = (initialData, set, get) => {
|
|
99
|
-
const
|
|
116
|
+
const config: WidgetConfig = { ...DEFAULT_CONFIG, ...initialData };
|
|
117
|
+
const allBuiltProviders = generateProviders(config);
|
|
100
118
|
return {
|
|
101
|
-
config
|
|
119
|
+
config,
|
|
102
120
|
iframe: DEFAULT_IFRAME_CONFIGS,
|
|
103
121
|
campaignMode: DEFAULT_CAMPAIGN_MODE,
|
|
104
122
|
allProviders: allBuiltProviders,
|
|
@@ -194,7 +212,8 @@ export const createConfigSlice: StateCreatorWithInitialData<
|
|
|
194
212
|
},
|
|
195
213
|
|
|
196
214
|
buildAndSetProviders: () => {
|
|
197
|
-
const
|
|
215
|
+
const { config } = get();
|
|
216
|
+
const allBuiltProviders = generateProviders(config);
|
|
198
217
|
|
|
199
218
|
set({
|
|
200
219
|
allProviders: allBuiltProviders,
|
package/src/types/config.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Provider } from '@hub3js/core';
|
|
2
2
|
import type { Language, theme } from '@rango-dev/ui';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {
|
|
4
|
+
LegacyProviderInterface,
|
|
5
|
+
LegacyWalletType as WalletType,
|
|
6
|
+
} from '@rango-dev/wallets-core/legacy';
|
|
5
7
|
import type { Asset } from 'rango-sdk';
|
|
6
8
|
import type { ReactElement } from 'react';
|
|
7
9
|
|
|
@@ -186,6 +188,21 @@ export type TonConnectConfig = {
|
|
|
186
188
|
manifestUrl?: string;
|
|
187
189
|
};
|
|
188
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Configuration for the Ledger wallet integration.
|
|
193
|
+
*
|
|
194
|
+
* @property {string} dAppIdentifier - Unique identifier of your dApp, registered with Ledger to authorize the integration.
|
|
195
|
+
* @property {string} apiKey - API key issued by Ledger, used to authenticate requests from your dApp.
|
|
196
|
+
* @property {'fatal' | 'error' | 'warn' | 'info' | 'debug'} [loggerLevel] - Verbosity of the Ledger logger.
|
|
197
|
+
* @property {boolean} [hideButton] - When `true`, hides the built-in Ledger floating button.
|
|
198
|
+
*/
|
|
199
|
+
export type LedgerWalletConfig = {
|
|
200
|
+
dAppIdentifier: string;
|
|
201
|
+
apiKey: string;
|
|
202
|
+
loggerLevel?: 'fatal' | 'error' | 'warn' | 'info' | 'debug';
|
|
203
|
+
hideButton?: boolean;
|
|
204
|
+
};
|
|
205
|
+
|
|
189
206
|
/**
|
|
190
207
|
* The type WidgetConfig defines the configuration options for a widget, including API key, affiliate
|
|
191
208
|
* reference, amount, blockchain and token configurations, liquidity sources, wallet types, language,
|
|
@@ -254,6 +271,7 @@ export type WidgetConfig = {
|
|
|
254
271
|
title?: string;
|
|
255
272
|
walletConnectProjectId?: string;
|
|
256
273
|
trezorManifest?: TrezorManifest;
|
|
274
|
+
ledgerWallet?: LedgerWalletConfig;
|
|
257
275
|
tonConnect?: TonConnectConfig;
|
|
258
276
|
affiliate?: WidgetAffiliate;
|
|
259
277
|
amount?: number;
|
package/src/types/wallets.ts
CHANGED
package/src/utils/common.ts
CHANGED
|
@@ -294,3 +294,9 @@ export function filterBlockchainsWithAtLeastOneToken(
|
|
|
294
294
|
blockchainsWithAtLeastOneToken.has(blockchain.name)
|
|
295
295
|
);
|
|
296
296
|
}
|
|
297
|
+
|
|
298
|
+
export function detectMobileScreens(): boolean {
|
|
299
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
300
|
+
navigator.userAgent
|
|
301
|
+
);
|
|
302
|
+
}
|
package/src/utils/swap.ts
CHANGED
|
@@ -9,8 +9,8 @@ import type {
|
|
|
9
9
|
SwapButtonState,
|
|
10
10
|
Wallet,
|
|
11
11
|
} from '../types';
|
|
12
|
+
import type { LegacyWalletType as WalletType } from '@rango-dev/wallets-core/legacy';
|
|
12
13
|
import type { ExtendedWalletInfo } from '@rango-dev/wallets-react';
|
|
13
|
-
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
14
14
|
import type {
|
|
15
15
|
BestRouteRequest,
|
|
16
16
|
BlockchainMeta,
|
package/src/utils/wallets.ts
CHANGED
|
@@ -5,30 +5,31 @@ import type {
|
|
|
5
5
|
Wallet,
|
|
6
6
|
WalletInfoWithExtra,
|
|
7
7
|
} from '../types';
|
|
8
|
+
import type {
|
|
9
|
+
LegacyNetwork as Network,
|
|
10
|
+
LegacyWalletType as WalletType,
|
|
11
|
+
} from '@rango-dev/wallets-core/legacy';
|
|
8
12
|
import type {
|
|
9
13
|
ExtendedWalletInfo,
|
|
10
14
|
ProviderContext,
|
|
11
15
|
} from '@rango-dev/wallets-react';
|
|
12
|
-
import type {
|
|
13
|
-
Network,
|
|
14
|
-
WalletType,
|
|
15
|
-
WalletTypes,
|
|
16
|
-
} from '@rango-dev/wallets-shared';
|
|
17
16
|
import type { BlockchainMeta, Token, TransactionType } from 'rango-sdk';
|
|
18
17
|
|
|
18
|
+
import {
|
|
19
|
+
HYPERLIQUID_SIGN_NETWORK,
|
|
20
|
+
Networks,
|
|
21
|
+
} from '@rango-dev/internal-blockchains';
|
|
19
22
|
import {
|
|
20
23
|
BlockchainCategories,
|
|
24
|
+
detectInstallLink,
|
|
21
25
|
WalletState as WalletStatus,
|
|
22
26
|
} from '@rango-dev/ui';
|
|
23
|
-
import { legacyReadAccountAddress as readAccountAddress } from '@rango-dev/wallets-core/legacy';
|
|
24
27
|
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
isEvmAddress,
|
|
29
|
-
Networks,
|
|
30
|
-
} from '@rango-dev/wallets-shared';
|
|
28
|
+
legacyGetBlockChainNameFromId as getBlockChainNameFromId,
|
|
29
|
+
legacyReadAccountAddress as readAccountAddress,
|
|
30
|
+
} from '@rango-dev/wallets-core/legacy';
|
|
31
31
|
import BigNumber from 'bignumber.js';
|
|
32
|
+
import { isAddress as isEvmAddress } from 'ethers';
|
|
32
33
|
|
|
33
34
|
import { ZERO } from '../constants/numbers';
|
|
34
35
|
import {
|
|
@@ -86,7 +87,7 @@ export function mapWalletTypesToWalletInfo(
|
|
|
86
87
|
chain?: string
|
|
87
88
|
): ExtendedModalWalletInfo[] {
|
|
88
89
|
return list
|
|
89
|
-
.filter((wallet) => !EXCLUDED_WALLETS.includes(wallet
|
|
90
|
+
.filter((wallet) => !EXCLUDED_WALLETS.includes(wallet))
|
|
90
91
|
.filter((wallet) => {
|
|
91
92
|
const { supportedChains, isContractWallet } = getWalletInfo(wallet);
|
|
92
93
|
|