@rango-dev/widget-embedded 0.17.1-next.4 → 0.17.1-next.6
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 +2 -1
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/Wallets.d.ts +1 -0
- package/dist/Wallets.d.ts.map +1 -1
- package/dist/Widget.d.ts +1 -1
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +0 -2
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +1 -6
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +0 -2
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -4
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +1 -6
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts +1 -6
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts +1 -2
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +1 -6
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +1 -8
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +59 -0
- package/dist/store/AppStore.d.ts.map +1 -0
- package/dist/store/app.d.ts +12 -6
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/quote.d.ts +14 -7
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/settings.d.ts +3 -2
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +3 -2
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +3 -0
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +5 -4
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +5 -5
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +3 -2
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +4 -3
- 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 +6 -6
- package/src/QueueManager.tsx +14 -14
- package/src/Wallets.tsx +35 -15
- package/src/Widget.tsx +11 -25
- package/src/components/AppRouter.tsx +3 -5
- package/src/components/AppRoutes.tsx +6 -39
- package/src/components/BlockchainList/BlockchainList.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +4 -4
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -14
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +0 -2
- package/src/components/ConfirmWalletsModal/WalletList.tsx +6 -5
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
- package/src/components/NoResult/NoResult.tsx +4 -1
- package/src/components/NotificationContent/NotificationContent.tsx +3 -2
- package/src/components/Quote/Quote.tsx +2 -4
- package/src/components/SwapDetails/SwapDetails.tsx +5 -6
- package/src/components/TokenList/TokenList.tsx +6 -7
- package/src/components/UpdateUrl.tsx +20 -14
- package/src/components/WidgetEvents.tsx +7 -4
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +5 -5
- package/src/hooks/useSwapInput.ts +6 -4
- package/src/hooks/useSyncStoresWithConfig.ts +20 -17
- package/src/hooks/useWalletList.ts +3 -5
- package/src/pages/ConfirmSwapPage.tsx +1 -9
- package/src/pages/Home.tsx +7 -7
- package/src/pages/LiquiditySourcePage.tsx +22 -31
- package/src/pages/SelectBlockchainPage.tsx +4 -5
- package/src/pages/SelectSwapItemsPage.tsx +5 -5
- package/src/pages/SettingsPage.tsx +8 -12
- package/src/pages/SwapDetailsPage.tsx +3 -3
- package/src/pages/WalletsPage.tsx +4 -11
- package/src/store/AppStore.tsx +35 -0
- package/src/store/app.ts +20 -5
- package/src/store/quote.ts +26 -22
- package/src/store/settings.ts +7 -4
- package/src/store/slices/config.ts +25 -15
- package/src/store/slices/data.ts +64 -29
- package/src/store/wallets.ts +11 -8
- package/src/types/config.ts +5 -5
- package/src/utils/settings.ts +8 -7
- package/src/utils/swap.ts +14 -16
- package/src/utils/wallets.ts +27 -15
- package/dist/store/meta.d.ts +0 -23
- package/dist/store/meta.d.ts.map +0 -1
- package/src/store/meta.ts +0 -39
package/src/utils/swap.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
-
import type {
|
|
2
|
+
import type { FetchStatus } from '../store/slices/data';
|
|
3
3
|
import type { ConnectedWallet } from '../store/wallets';
|
|
4
4
|
import type {
|
|
5
5
|
ConvertedToken,
|
|
@@ -35,7 +35,6 @@ import {
|
|
|
35
35
|
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
36
36
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
37
37
|
} from '../constants/routing';
|
|
38
|
-
import { useMetaStore } from '../store/meta';
|
|
39
38
|
import { ButtonState } from '../types';
|
|
40
39
|
|
|
41
40
|
import { removeDuplicateFrom } from './common';
|
|
@@ -181,7 +180,7 @@ export function getLimitErrorMessage(quote: BestRouteResponse): {
|
|
|
181
180
|
}
|
|
182
181
|
|
|
183
182
|
export function getSwapButtonState(
|
|
184
|
-
loadingMetaStatus:
|
|
183
|
+
loadingMetaStatus: FetchStatus,
|
|
185
184
|
connectedWallets: ConnectedWallet[],
|
|
186
185
|
loading: boolean,
|
|
187
186
|
quote: BestRouteResponse | null,
|
|
@@ -441,6 +440,8 @@ export function createQuoteRequestBody(params: {
|
|
|
441
440
|
inputAmount: string;
|
|
442
441
|
wallets?: Wallet[];
|
|
443
442
|
selectedWallets?: Wallet[];
|
|
443
|
+
liquiditySources?: string[];
|
|
444
|
+
excludeLiquiditySources?: boolean;
|
|
444
445
|
disabledLiquiditySources: string[];
|
|
445
446
|
slippage: number;
|
|
446
447
|
affiliateRef: string | null;
|
|
@@ -456,6 +457,8 @@ export function createQuoteRequestBody(params: {
|
|
|
456
457
|
wallets,
|
|
457
458
|
selectedWallets,
|
|
458
459
|
disabledLiquiditySources,
|
|
460
|
+
liquiditySources,
|
|
461
|
+
excludeLiquiditySources,
|
|
459
462
|
slippage,
|
|
460
463
|
affiliateRef,
|
|
461
464
|
affiliatePercent,
|
|
@@ -531,13 +534,18 @@ export function createQuoteRequestBody(params: {
|
|
|
531
534
|
selectedWallets: selectedWalletsMap ?? {},
|
|
532
535
|
slippage: slippage.toString(),
|
|
533
536
|
...(destination && { destination: destination }),
|
|
534
|
-
...(
|
|
535
|
-
swapperGroups: disabledLiquiditySources,
|
|
537
|
+
...(excludeLiquiditySources && {
|
|
538
|
+
swapperGroups: disabledLiquiditySources.concat(liquiditySources ?? []),
|
|
536
539
|
swappersGroupsExclude: true,
|
|
537
540
|
}),
|
|
541
|
+
...(!excludeLiquiditySources && {
|
|
542
|
+
swapperGroups: liquiditySources?.filter(
|
|
543
|
+
(liquiditySource) => !disabledLiquiditySources.includes(liquiditySource)
|
|
544
|
+
),
|
|
545
|
+
swappersGroupsExclude: false,
|
|
546
|
+
}),
|
|
538
547
|
...(checkPrerequisites && { blockchains: filteredBlockchains }),
|
|
539
548
|
};
|
|
540
|
-
|
|
541
549
|
return requestBody;
|
|
542
550
|
}
|
|
543
551
|
|
|
@@ -744,16 +752,6 @@ export function shouldRetrySwap(pendingSwap: PendingSwap) {
|
|
|
744
752
|
new Date().getTime() - parseInt(pendingSwap.finishTime) < 4 * 3600 * 1000
|
|
745
753
|
);
|
|
746
754
|
}
|
|
747
|
-
export function isValidCustomDestination(
|
|
748
|
-
blockchain: string,
|
|
749
|
-
address: string
|
|
750
|
-
): boolean {
|
|
751
|
-
const blockchains = useMetaStore.getState().meta.blockchains;
|
|
752
|
-
const regex =
|
|
753
|
-
blockchains.find((chain) => chain.name === blockchain)?.addressPatterns ||
|
|
754
|
-
[];
|
|
755
|
-
return regex.filter((r) => new RegExp(r).test(address)).length > 0;
|
|
756
|
-
}
|
|
757
755
|
|
|
758
756
|
export function confirmSwapDisabled(
|
|
759
757
|
fetching: boolean,
|
package/src/utils/wallets.ts
CHANGED
|
@@ -55,8 +55,11 @@ export function mapWalletTypesToWalletInfo(
|
|
|
55
55
|
return list
|
|
56
56
|
.filter((wallet) => !EXCLUDED_WALLETS.includes(wallet as WalletTypes))
|
|
57
57
|
.filter((wallet) => {
|
|
58
|
-
const { supportedChains,
|
|
59
|
-
|
|
58
|
+
const { supportedChains, isContractWallet } = getWalletInfo(wallet);
|
|
59
|
+
const { installed, network } = getState(wallet);
|
|
60
|
+
const filterContractWallets =
|
|
61
|
+
isContractWallet && (!installed || (!!chain && network !== chain));
|
|
62
|
+
if (filterContractWallets) {
|
|
60
63
|
return false;
|
|
61
64
|
}
|
|
62
65
|
if (chain) {
|
|
@@ -97,7 +100,8 @@ export function prepareAccountsForWalletStore(
|
|
|
97
100
|
wallet: WalletType,
|
|
98
101
|
accounts: string[],
|
|
99
102
|
evmBasedChains: string[],
|
|
100
|
-
supportedChainNames: Network[] | null
|
|
103
|
+
supportedChainNames: Network[] | null,
|
|
104
|
+
isContractWallet: boolean
|
|
101
105
|
): Wallet[] {
|
|
102
106
|
const result: Wallet[] = [];
|
|
103
107
|
|
|
@@ -151,21 +155,29 @@ export function prepareAccountsForWalletStore(
|
|
|
151
155
|
|
|
152
156
|
// If it's an evm network, we will add the address to all the evm chains.
|
|
153
157
|
if (isEvmBasedChain || isUnknownAndEvmBased) {
|
|
154
|
-
|
|
155
|
-
* all evm chains are not supported in wallets, so we are adding
|
|
156
|
-
* only to those that are supported by wallet.
|
|
157
|
-
*/
|
|
158
|
-
const evmChainsSupportedByWallet = supportedBlockchains.filter((chain) =>
|
|
159
|
-
evmBasedChains.includes(chain)
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
evmChainsSupportedByWallet.forEach((network) => {
|
|
158
|
+
if (isContractWallet) {
|
|
163
159
|
/*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
160
|
+
* for contract wallets like Safe wallet, we should add only account for the
|
|
161
|
+
* current connected blockchain not all of the supported blockchains
|
|
166
162
|
*/
|
|
167
163
|
addAccount(network, address.toLowerCase());
|
|
168
|
-
}
|
|
164
|
+
} else {
|
|
165
|
+
/*
|
|
166
|
+
* all evm chains are not supported in wallets, so we are adding
|
|
167
|
+
* only to those that are supported by wallet.
|
|
168
|
+
*/
|
|
169
|
+
const evmChainsSupportedByWallet = supportedBlockchains.filter(
|
|
170
|
+
(chain) => evmBasedChains.includes(chain)
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
evmChainsSupportedByWallet.forEach((network) => {
|
|
174
|
+
/*
|
|
175
|
+
* EVM addresses are not case sensitive.
|
|
176
|
+
* Some wallets like Binance-chain return some letters in uppercase which produces bugs in our wallet state.
|
|
177
|
+
*/
|
|
178
|
+
addAccount(network, address.toLowerCase());
|
|
179
|
+
});
|
|
180
|
+
}
|
|
169
181
|
} else {
|
|
170
182
|
addAccount(network, address);
|
|
171
183
|
}
|
package/dist/store/meta.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
|
-
import type { MetaResponse } from 'rango-sdk';
|
|
3
|
-
export type LoadingStatus = 'loading' | 'success' | 'failed';
|
|
4
|
-
export interface MetaState {
|
|
5
|
-
meta: MetaResponse & {
|
|
6
|
-
tokens: TokenWithBalance[];
|
|
7
|
-
};
|
|
8
|
-
loadingStatus: LoadingStatus;
|
|
9
|
-
fetchMeta: () => Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export declare const useMetaStore: {
|
|
12
|
-
(): MetaState;
|
|
13
|
-
<U>(selector: (state: MetaState) => U, equals?: ((a: U, b: U) => boolean) | undefined): U;
|
|
14
|
-
} & import("zustand").StoreApi<MetaState> & {
|
|
15
|
-
use: {
|
|
16
|
-
meta: () => MetaResponse & {
|
|
17
|
-
tokens: TokenWithBalance[];
|
|
18
|
-
};
|
|
19
|
-
loadingStatus: () => LoadingStatus;
|
|
20
|
-
fetchMeta: () => () => Promise<void>;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=meta.d.ts.map
|
package/dist/store/meta.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/store/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAO9C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE7D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,YAAY,GAAG;QAAE,MAAM,EAAE,gBAAgB,EAAE,CAAA;KAAE,CAAC;IACpD,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,YAAY;;;;;;oBALQ,gBAAgB,EAAE;;;+BAEhC,QAAQ,IAAI,CAAC;;CAyB/B,CAAC"}
|
package/src/store/meta.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
|
-
import type { MetaResponse } from 'rango-sdk';
|
|
3
|
-
|
|
4
|
-
import { create } from 'zustand';
|
|
5
|
-
|
|
6
|
-
import { useAppStore } from './app';
|
|
7
|
-
import createSelectors from './selectors';
|
|
8
|
-
|
|
9
|
-
export type LoadingStatus = 'loading' | 'success' | 'failed';
|
|
10
|
-
|
|
11
|
-
export interface MetaState {
|
|
12
|
-
meta: MetaResponse & { tokens: TokenWithBalance[] };
|
|
13
|
-
loadingStatus: LoadingStatus;
|
|
14
|
-
fetchMeta: () => Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const useMetaStore = createSelectors(
|
|
18
|
-
create<MetaState>()((set) => ({
|
|
19
|
-
meta: { blockchains: [], popularTokens: [], swappers: [], tokens: [] },
|
|
20
|
-
loadingStatus: 'loading',
|
|
21
|
-
fetchMeta: async () => {
|
|
22
|
-
try {
|
|
23
|
-
await useAppStore.getState().fetch();
|
|
24
|
-
|
|
25
|
-
const state = useAppStore.getState();
|
|
26
|
-
const response: MetaResponse = {
|
|
27
|
-
blockchains: state.blockchains(),
|
|
28
|
-
tokens: state.tokens(),
|
|
29
|
-
popularTokens: state._popularTokens,
|
|
30
|
-
swappers: state._swappers,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
set({ meta: response, loadingStatus: 'success' });
|
|
34
|
-
} catch (error) {
|
|
35
|
-
set({ loadingStatus: 'failed' });
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
}))
|
|
39
|
-
);
|