@rango-dev/widget-embedded 0.1.20-next.0 → 0.1.20-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/QueueManager.d.ts +3 -3
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/Widget.d.ts +8 -0
- package/dist/Widget.d.ts.map +1 -0
- package/dist/components/AppRouter.d.ts +7 -7
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +7 -7
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BottomLogo.d.ts +2 -2
- package/dist/components/BottomLogo.d.ts.map +1 -1
- package/dist/components/ChangeSlippageButton.d.ts +2 -2
- package/dist/components/ChangeSlippageButton.d.ts.map +1 -1
- package/dist/components/ConfirmSwapErrors.d.ts +3 -3
- package/dist/components/ConfirmSwapErrors.d.ts.map +1 -1
- package/dist/components/ConfirmSwapWarnings.d.ts +2 -2
- package/dist/components/ConfirmSwapWarnings.d.ts.map +1 -1
- package/dist/components/Footer.d.ts +111 -111
- package/dist/components/Footer.d.ts.map +1 -1
- package/dist/components/HeaderButtons.d.ts +6 -6
- package/dist/components/HeaderButtons.d.ts.map +1 -1
- package/dist/components/Layout.d.ts +6 -6
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/PercentageChange.d.ts +8 -8
- package/dist/components/PercentageChange.d.ts.map +1 -1
- package/dist/components/RoutesOverview.d.ts +119 -119
- package/dist/components/RoutesOverview.d.ts.map +1 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts +119 -119
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -1
- package/dist/components/SwitchFromAndTo.d.ts +3 -3
- package/dist/components/SwitchFromAndTo.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts +17 -17
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/components/TokenPreview.d.ts +20 -20
- package/dist/components/TokenPreview.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +1 -1
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/warnings/BalanceErrors.d.ts +6 -6
- package/dist/components/warnings/BalanceErrors.d.ts.map +1 -1
- package/dist/components/warnings/ConfirmSwapExtraMessages.d.ts +6 -6
- package/dist/components/warnings/ConfirmSwapExtraMessages.d.ts.map +1 -1
- package/dist/components/warnings/HighSlippageWarning.d.ts +6 -6
- package/dist/components/warnings/HighSlippageWarning.d.ts.map +1 -1
- package/dist/components/warnings/MinRequiredSlippage.d.ts +6 -6
- package/dist/components/warnings/MinRequiredSlippage.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +3 -3
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/constants/navigationRoutes.d.ts +13 -13
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/numbers.d.ts +2 -2
- package/dist/constants/numbers.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +7 -7
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/constants/swapSettings.d.ts +5 -5
- package/dist/constants/swapSettings.d.ts.map +1 -1
- package/dist/globalStyles.d.ts +1 -1
- package/dist/globalStyles.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap.d.ts +10 -10
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useNavigateBack.d.ts +3 -3
- package/dist/hooks/useNavigateBack.d.ts.map +1 -1
- package/dist/hooks/usePrevious.d.ts +1 -1
- package/dist/hooks/usePrevious.d.ts.map +1 -1
- package/dist/hooks/useSelectLanguage.d.ts +4 -4
- package/dist/hooks/useSelectLanguage.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +30 -4
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/i18n.d.ts +2 -2
- package/dist/i18n.d.ts.map +1 -1
- package/dist/index.d.ts +5 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -8
- package/dist/index.js.map +7 -0
- package/dist/mockData/pendingSwap.d.ts +1 -1
- package/dist/mockData/pendingSwap.d.ts.map +1 -1
- package/dist/pages/ConfirmSwapPage.d.ts +4 -2
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/HistoryPage.d.ts +2 -2
- package/dist/pages/HistoryPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts +2 -2
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcesPage.d.ts +6 -6
- package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
- package/dist/pages/SelectChainPage.d.ts +7 -7
- package/dist/pages/SelectChainPage.d.ts.map +1 -1
- package/dist/pages/SelectTokenPage.d.ts +14 -14
- package/dist/pages/SelectTokenPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +7 -7
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts +2 -2
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +8 -8
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/services/httpService.d.ts +3 -3
- package/dist/services/httpService.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts +67 -31
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/meta.d.ts +17 -8
- package/dist/store/meta.d.ts.map +1 -1
- package/dist/store/selectors.d.ts +10 -10
- package/dist/store/selectors.d.ts.map +1 -1
- package/dist/store/settings.d.ts +55 -18
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/store/ui.d.ts +22 -1
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +59 -33
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +114 -114
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/routing.d.ts +57 -57
- package/dist/types/routing.d.ts.map +1 -1
- package/dist/types/swap.d.ts +16 -16
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +6 -6
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/common.d.ts +3 -3
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +6 -6
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/date.d.ts +2 -2
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +13 -13
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/queue.d.ts +3 -3
- package/dist/utils/queue.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +17 -17
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +52 -50
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +3 -3
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +27 -27
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +15 -22
- package/src/QueueManager.tsx +5 -4
- package/src/{index.tsx → Widget.tsx} +1 -8
- package/src/components/AppRouter.tsx +4 -0
- package/src/components/AppRoutes.tsx +1 -1
- package/src/hooks/useConfirmSwap.ts +4 -1
- package/src/index.ts +18 -0
- package/src/pages/ConfirmSwapPage.tsx +47 -18
- package/src/pages/SwapDetailsPage.tsx +14 -9
- package/src/store/wallets.ts +8 -1
- package/src/types/config.ts +2 -2
- package/src/utils/common.ts +2 -0
- package/src/utils/swap.ts +38 -2
- package/src/utils/wallets.ts +20 -14
- package/dist/widget-embedded.cjs.development.js +0 -3401
- package/dist/widget-embedded.cjs.development.js.map +0 -1
- package/dist/widget-embedded.cjs.production.min.js +0 -3401
- package/dist/widget-embedded.cjs.production.min.js.map +0 -1
- package/dist/widget-embedded.esm.js +0 -3392
- package/dist/widget-embedded.esm.js.map +0 -1
package/dist/utils/swap.d.ts
CHANGED
|
@@ -1,51 +1,53 @@
|
|
|
1
|
-
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { BestRouteRequest, BestRouteResponse, RecommendedSlippage, SwapResult, Token } from 'rango-sdk';
|
|
3
|
-
import { ConnectedWallet } from '../store/wallets';
|
|
4
|
-
import { WalletType } from '@rango-dev/wallets-shared';
|
|
5
|
-
import { LoadingStatus } from '../store/meta';
|
|
6
|
-
import { ConvertedToken, SwapButtonState, Wallet } from '../types';
|
|
7
|
-
import { PendingSwapStep } from '@rango-dev/queue-manager-rango-preset';
|
|
8
|
-
import { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
9
|
-
export declare function getOutputRatio(inputUsdValue: BigNumber, outputUsdValue: BigNumber):
|
|
10
|
-
export declare function outputRatioHasWarning(inputUsdValue: BigNumber, outputRatio: BigNumber | 0): boolean;
|
|
11
|
-
export declare function hasLimitError(bestRoute: BestRouteResponse | null): boolean;
|
|
12
|
-
export declare function LimitErrorMessage(bestRoute: BestRouteResponse | null): {
|
|
13
|
-
swap: SwapResult | null;
|
|
14
|
-
fromAmountRangeError: string;
|
|
15
|
-
recommendation: string;
|
|
16
|
-
};
|
|
17
|
-
export declare function getSwapButtonState(loadingMetaStatus: LoadingStatus, connectedWallets: ConnectedWallet[], loading: boolean, bestRoute: BestRouteResponse | null, hasLimitError: boolean, highValueLoss: boolean, priceImpactCanNotBeComputed: boolean, needsToWarnEthOnPath: boolean, inputAmount: string): SwapButtonState;
|
|
18
|
-
export declare function canComputePriceImpact(bestRoute: BestRouteResponse | null, inputAmount: string, inputUsdValue: BigNumber, outputUsdValue: BigNumber): boolean;
|
|
19
|
-
export declare function requiredWallets(route: BestRouteResponse | null): string[];
|
|
20
|
-
export declare const getUsdPrice: (blockchain: string, symbol: string, address: string | null, allTokens: Token[]) => number | null;
|
|
21
|
-
export declare function getUsdFeeOfStep(step: SwapResult, allTokens: Token[]): BigNumber;
|
|
22
|
-
export declare function getTotalFeeInUsd(bestRoute: BestRouteResponse | null, allTokens: Token[]): BigNumber | null;
|
|
23
|
-
export declare function hasHighFee(totalFeeInUsd: BigNumber | null): boolean;
|
|
24
|
-
export declare function hasSlippageError(slippages: (RecommendedSlippage | null)[] | undefined): boolean;
|
|
25
|
-
export declare function getMinRequiredSlippage(route: BestRouteResponse): string | null;
|
|
26
|
-
export declare function hasProperSlippage(userSlippage: string, minRequiredSlippage: string | null): boolean;
|
|
27
|
-
export declare function hasEnoughBalance(route: BestRouteResponse, selectedWallets: Wallet[]): boolean;
|
|
28
|
-
export declare function hasEnoughBalanceAndProperSlippage(route: BestRouteResponse, selectedWallets: Wallet[], userSlippage: string, minRequiredSlippage: string | null): boolean;
|
|
29
|
-
export declare function createBestRouteRequestBody(fromToken: Token, toToken: Token, inputAmount: string, wallets: ConnectedWallet[], selectedWallets: Wallet[], disabledLiquiditySources: string[], slippage: number, affiliateRef: string | null, initialRoute?: BestRouteResponse): BestRouteRequest;
|
|
30
|
-
export declare function getWalletsForNewSwap(selectedWallets: Wallet[]): {
|
|
31
|
-
[p: string]: {
|
|
32
|
-
address: string;
|
|
33
|
-
walletType: WalletType;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export declare function getRouteOutputAmount(route: BestRouteResponse | null): string | null;
|
|
37
|
-
export declare function getPercentageChange(oldValue: string | number | null, newValue: string | number | null): BigNumber | null;
|
|
38
|
-
export declare function isOutputAmountChangedALot(oldRoute: BestRouteResponse, newRoute: BestRouteResponse): boolean;
|
|
39
|
-
export declare function getBalanceWarnings(route: BestRouteResponse, selectedWallets: Wallet[]): string[];
|
|
40
|
-
export declare function calcOutputUsdValue(outputAmount?: string, tokenPrice?: number | null): BigNumber;
|
|
41
|
-
export declare function isNetworkStatusInWarningState(pendingSwapStep: PendingSwapStep | null): boolean;
|
|
42
|
-
export declare function getSwapMessages(pendingSwap: PendingSwap, currentStep: PendingSwapStep | null): {
|
|
43
|
-
shortMessage: string;
|
|
44
|
-
detailedMessage: {
|
|
45
|
-
content: string;
|
|
46
|
-
long: boolean;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
export declare function getLastConvertedTokenInFailedSwap(pendingSwap: PendingSwap): ConvertedToken;
|
|
50
|
-
export declare function shouldRetrySwap(pendingSwap: PendingSwap): boolean;
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { BestRouteRequest, BestRouteResponse, RecommendedSlippage, SwapResult, Token } from 'rango-sdk';
|
|
3
|
+
import { ConnectedWallet } from '../store/wallets';
|
|
4
|
+
import { WalletType } from '@rango-dev/wallets-shared';
|
|
5
|
+
import { LoadingStatus } from '../store/meta';
|
|
6
|
+
import { ConvertedToken, SwapButtonState, Wallet } from '../types';
|
|
7
|
+
import { PendingSwapStep } from '@rango-dev/queue-manager-rango-preset';
|
|
8
|
+
import { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
9
|
+
export declare function getOutputRatio(inputUsdValue: BigNumber, outputUsdValue: BigNumber): 0 | BigNumber;
|
|
10
|
+
export declare function outputRatioHasWarning(inputUsdValue: BigNumber, outputRatio: BigNumber | 0): boolean;
|
|
11
|
+
export declare function hasLimitError(bestRoute: BestRouteResponse | null): boolean;
|
|
12
|
+
export declare function LimitErrorMessage(bestRoute: BestRouteResponse | null): {
|
|
13
|
+
swap: SwapResult | null;
|
|
14
|
+
fromAmountRangeError: string;
|
|
15
|
+
recommendation: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function getSwapButtonState(loadingMetaStatus: LoadingStatus, connectedWallets: ConnectedWallet[], loading: boolean, bestRoute: BestRouteResponse | null, hasLimitError: boolean, highValueLoss: boolean, priceImpactCanNotBeComputed: boolean, needsToWarnEthOnPath: boolean, inputAmount: string): SwapButtonState;
|
|
18
|
+
export declare function canComputePriceImpact(bestRoute: BestRouteResponse | null, inputAmount: string, inputUsdValue: BigNumber, outputUsdValue: BigNumber): boolean;
|
|
19
|
+
export declare function requiredWallets(route: BestRouteResponse | null): string[];
|
|
20
|
+
export declare const getUsdPrice: (blockchain: string, symbol: string, address: string | null, allTokens: Token[]) => number | null;
|
|
21
|
+
export declare function getUsdFeeOfStep(step: SwapResult, allTokens: Token[]): BigNumber;
|
|
22
|
+
export declare function getTotalFeeInUsd(bestRoute: BestRouteResponse | null, allTokens: Token[]): BigNumber | null;
|
|
23
|
+
export declare function hasHighFee(totalFeeInUsd: BigNumber | null): boolean;
|
|
24
|
+
export declare function hasSlippageError(slippages: (RecommendedSlippage | null)[] | undefined): boolean;
|
|
25
|
+
export declare function getMinRequiredSlippage(route: BestRouteResponse): string | null;
|
|
26
|
+
export declare function hasProperSlippage(userSlippage: string, minRequiredSlippage: string | null): boolean;
|
|
27
|
+
export declare function hasEnoughBalance(route: BestRouteResponse, selectedWallets: Wallet[]): boolean;
|
|
28
|
+
export declare function hasEnoughBalanceAndProperSlippage(route: BestRouteResponse, selectedWallets: Wallet[], userSlippage: string, minRequiredSlippage: string | null): boolean;
|
|
29
|
+
export declare function createBestRouteRequestBody(fromToken: Token, toToken: Token, inputAmount: string, wallets: ConnectedWallet[], selectedWallets: Wallet[], disabledLiquiditySources: string[], slippage: number, affiliateRef: string | null, initialRoute?: BestRouteResponse, destination?: string): BestRouteRequest;
|
|
30
|
+
export declare function getWalletsForNewSwap(selectedWallets: Wallet[]): {
|
|
31
|
+
[p: string]: {
|
|
32
|
+
address: string;
|
|
33
|
+
walletType: WalletType;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export declare function getRouteOutputAmount(route: BestRouteResponse | null): string | null;
|
|
37
|
+
export declare function getPercentageChange(oldValue: string | number | null, newValue: string | number | null): BigNumber | null;
|
|
38
|
+
export declare function isOutputAmountChangedALot(oldRoute: BestRouteResponse, newRoute: BestRouteResponse): boolean;
|
|
39
|
+
export declare function getBalanceWarnings(route: BestRouteResponse, selectedWallets: Wallet[]): string[];
|
|
40
|
+
export declare function calcOutputUsdValue(outputAmount?: string, tokenPrice?: number | null): BigNumber;
|
|
41
|
+
export declare function isNetworkStatusInWarningState(pendingSwapStep: PendingSwapStep | null): boolean;
|
|
42
|
+
export declare function getSwapMessages(pendingSwap: PendingSwap, currentStep: PendingSwapStep | null): {
|
|
43
|
+
shortMessage: string;
|
|
44
|
+
detailedMessage: {
|
|
45
|
+
content: string;
|
|
46
|
+
long: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export declare function getLastConvertedTokenInFailedSwap(pendingSwap: PendingSwap): ConvertedToken;
|
|
50
|
+
export declare function shouldRetrySwap(pendingSwap: PendingSwap): boolean;
|
|
51
|
+
export declare function isValidCustomDestination(blockchain: string, address: string): boolean;
|
|
52
|
+
export declare function confirmSwapDisabled(fetching: boolean, destinationChain: string, customDestination: string, bestRoute: BestRouteResponse | null, selectedWallets: Wallet[]): boolean;
|
|
51
53
|
//# sourceMappingURL=swap.d.ts.map
|
package/dist/utils/swap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../src/utils/swap.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,KAAK,EACN,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,aAAa,EAAgB,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAEL,eAAe,EAChB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAGpE,wBAAgB,cAAc,CAC5B,aAAa,EAAE,SAAS,EACxB,cAAc,EAAE,SAAS,iBAI1B;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,SAAS,EACxB,WAAW,EAAE,SAAS,GAAG,CAAC,WAQ3B;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ED,wBAAgB,kBAAkB,CAChC,YAAY,CAAC,EAAE,MAAM,EACrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,aAK3B;AAED,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,GAAG,IAAI,GACtC,OAAO,CAMT;AAED,wBAAgB,eAAe,CAC7B,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,eAAe,GAAG,IAAI,GAClC;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;CACrD,CAoCA;AAED,wBAAgB,iCAAiC,CAC/C,WAAW,EAAE,WAAW,GACvB,cAAc,CAkBhB;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,WAMvD;AACD,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAMT;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,OAAO,EACjB,gBAAgB,EAAE,MAAM,EACxB,iBAAiB,EAAE,MAAM,EACzB,SAAS,EAAE,iBAAiB,GAAG,IAAI,EACnC,eAAe,EAAE,MAAM,EAAE,WAiB1B"}
|
package/dist/utils/time.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
2
|
-
export declare function timeSince(timeMillis: number): string;
|
|
3
|
-
export declare function getSwapDate(pendingSwap: PendingSwap): string;
|
|
1
|
+
import { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
2
|
+
export declare function timeSince(timeMillis: number): string;
|
|
3
|
+
export declare function getSwapDate(pendingSwap: PendingSwap): string;
|
|
4
4
|
//# sourceMappingURL=time.d.ts.map
|
package/dist/utils/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/utils/time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAqCpD;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,WAAW,UAInD"}
|
package/dist/utils/wallets.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { Network, WalletState, WalletType, WalletInfo, WalletTypes } from '@rango-dev/wallets-shared';
|
|
2
|
-
import { WalletInfo as ModalWalletInfo, WalletState as WalletStatus, SelectableWallet } from '@rango-dev/ui';
|
|
3
|
-
import { BestRouteResponse, BlockchainMeta, Token, WalletDetail } from 'rango-sdk';
|
|
4
|
-
import { ConnectedWallet, TokenBalance } from '../store/wallets';
|
|
5
|
-
import { TokenWithBalance } from '../pages/SelectTokenPage';
|
|
6
|
-
import { Wallet } from '../types';
|
|
7
|
-
export declare function getStateWallet(state: WalletState): WalletStatus;
|
|
8
|
-
export declare const excludedWallets: WalletTypes[];
|
|
9
|
-
export declare function getlistWallet(getState: (type: WalletType) => WalletState, getWalletInfo: (type: WalletType) => WalletInfo, list: WalletType[]): ModalWalletInfo[];
|
|
10
|
-
export declare function walletAndSupportedChainsNames(supportedChains: BlockchainMeta[]): Network[] | null;
|
|
11
|
-
export declare function prepareAccountsForWalletStore(wallet: WalletType, accounts: string[], evmBasedChains: string[], supportedChainNames: Network[] | null): Wallet[];
|
|
12
|
-
export declare function getRequiredChains(route: BestRouteResponse | null): string[];
|
|
13
|
-
export declare function getSelectableWallets(connectedWallets: ConnectedWallet[], selectedWallets: Wallet[], getWalletInfo: (type: WalletType) => WalletInfo): SelectableWallet[];
|
|
14
|
-
export declare function getBalanceFromWallet(connectedWallets: ConnectedWallet[], chain: string, symbol: string, address: string | null): TokenBalance | null;
|
|
15
|
-
export declare function isAccountAndWalletMatched(account: Wallet, connectedWallet: ConnectedWallet): boolean;
|
|
16
|
-
export declare function makeBalanceFor(wallet: Wallet, retrivedBalance: WalletDetail, tokens: Token[]): ConnectedWallet;
|
|
17
|
-
export declare function resetConnectedWalletState(connectedWallet: ConnectedWallet): ConnectedWallet;
|
|
18
|
-
export declare const calculateWalletUsdValue: (connectedWallet: ConnectedWallet[]) => string;
|
|
19
|
-
export declare const sortTokens: (tokens: TokenWithBalance[]) => TokenWithBalance[];
|
|
20
|
-
export declare const getUsdPrice: (blockchain: string, symbol: string, address: string | null, allTokens: Token[]) => number | null;
|
|
21
|
-
export declare const isExperimentalChain: (blockchains: BlockchainMeta[], wallet: string) => boolean;
|
|
22
|
-
export declare const getKeplrCompatibleConnectedWallets: (selectableWallets: SelectableWallet[]) => WalletType[];
|
|
23
|
-
export declare function getTokensWithBalance(tokens: TokenWithBalance[], connectedWallets: ConnectedWallet[]): TokenWithBalance[];
|
|
24
|
-
export declare function getSortedTokens(chain: BlockchainMeta | null, tokens: Token[], connectedWallets: ConnectedWallet[], otherChainTokens: TokenWithBalance[]): TokenWithBalance[];
|
|
25
|
-
export declare function tokensAreEqual(tokenA: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null, tokenB: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null): boolean;
|
|
26
|
-
export declare function getDefaultToken(sortedTokens: TokenWithBalance[], otherToken: TokenWithBalance | null): TokenWithBalance;
|
|
27
|
-
export declare function sortWalletsBasedOnState(wallets: ModalWalletInfo[]): ModalWalletInfo[];
|
|
1
|
+
import { Network, WalletState, WalletType, WalletInfo, WalletTypes } from '@rango-dev/wallets-shared';
|
|
2
|
+
import { WalletInfo as ModalWalletInfo, WalletState as WalletStatus, SelectableWallet } from '@rango-dev/ui';
|
|
3
|
+
import { BestRouteResponse, BlockchainMeta, Token, WalletDetail } from 'rango-sdk';
|
|
4
|
+
import { ConnectedWallet, TokenBalance } from '../store/wallets';
|
|
5
|
+
import { TokenWithBalance } from '../pages/SelectTokenPage';
|
|
6
|
+
import { Wallet } from '../types';
|
|
7
|
+
export declare function getStateWallet(state: WalletState): WalletStatus;
|
|
8
|
+
export declare const excludedWallets: WalletTypes[];
|
|
9
|
+
export declare function getlistWallet(getState: (type: WalletType) => WalletState, getWalletInfo: (type: WalletType) => WalletInfo, list: WalletType[]): ModalWalletInfo[];
|
|
10
|
+
export declare function walletAndSupportedChainsNames(supportedChains: BlockchainMeta[]): Network[] | null;
|
|
11
|
+
export declare function prepareAccountsForWalletStore(wallet: WalletType, accounts: string[], evmBasedChains: string[], supportedChainNames: Network[] | null): Wallet[];
|
|
12
|
+
export declare function getRequiredChains(route: BestRouteResponse | null): string[];
|
|
13
|
+
export declare function getSelectableWallets(connectedWallets: ConnectedWallet[], selectedWallets: Wallet[], getWalletInfo: (type: WalletType) => WalletInfo, destinationChain?: string): SelectableWallet[];
|
|
14
|
+
export declare function getBalanceFromWallet(connectedWallets: ConnectedWallet[], chain: string, symbol: string, address: string | null): TokenBalance | null;
|
|
15
|
+
export declare function isAccountAndWalletMatched(account: Wallet, connectedWallet: ConnectedWallet): boolean;
|
|
16
|
+
export declare function makeBalanceFor(wallet: Wallet, retrivedBalance: WalletDetail, tokens: Token[]): ConnectedWallet;
|
|
17
|
+
export declare function resetConnectedWalletState(connectedWallet: ConnectedWallet): ConnectedWallet;
|
|
18
|
+
export declare const calculateWalletUsdValue: (connectedWallet: ConnectedWallet[]) => string;
|
|
19
|
+
export declare const sortTokens: (tokens: TokenWithBalance[]) => TokenWithBalance[];
|
|
20
|
+
export declare const getUsdPrice: (blockchain: string, symbol: string, address: string | null, allTokens: Token[]) => number | null;
|
|
21
|
+
export declare const isExperimentalChain: (blockchains: BlockchainMeta[], wallet: string) => boolean;
|
|
22
|
+
export declare const getKeplrCompatibleConnectedWallets: (selectableWallets: SelectableWallet[]) => WalletType[];
|
|
23
|
+
export declare function getTokensWithBalance(tokens: TokenWithBalance[], connectedWallets: ConnectedWallet[]): TokenWithBalance[];
|
|
24
|
+
export declare function getSortedTokens(chain: BlockchainMeta | null, tokens: Token[], connectedWallets: ConnectedWallet[], otherChainTokens: TokenWithBalance[]): TokenWithBalance[];
|
|
25
|
+
export declare function tokensAreEqual(tokenA: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null, tokenB: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null): boolean;
|
|
26
|
+
export declare function getDefaultToken(sortedTokens: TokenWithBalance[], otherToken: TokenWithBalance | null): TokenWithBalance;
|
|
27
|
+
export declare function sortWalletsBasedOnState(wallets: ModalWalletInfo[]): ModalWalletInfo[];
|
|
28
28
|
//# sourceMappingURL=wallets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,OAAO,EACP,WAAW,EACX,UAAU,EAEV,UAAU,EACV,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,UAAU,IAAI,eAAe,EAC7B,WAAW,IAAI,YAAY,EAC3B,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,KAAK,EACL,YAAY,EACb,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAW/D;AAED,eAAO,MAAM,eAAe,eAAqB,CAAC;AAElD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,WAAW,EAC3C,aAAa,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,EAC/C,IAAI,E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MAAM,GAAG,IAQX,CAAC;AACF,eAAO,MAAM,mBAAmB,gBACjB,cAAc,EAAE,UACrB,MAAM,KACb,OAOF,CAAC;AAEF,eAAO,MAAM,kCAAkC,sBAC1B,gBAAgB,EAAE,KACpC,UAAU,EAUZ,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,gBAAgB,EAAE,EAC1B,gBAAgB,EAAE,eAAe,EAAE,GAClC,gBAAgB,EAAE,CAiCpB;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,GAAG,IAAI,EAC5B,MAAM,EAAE,KAAK,EAAE,EACf,gBAAgB,EAAE,eAAe,EAAE,EACnC,gBAAgB,EAAE,gBAAgB,EAAE,GACnC,gBAAgB,EAAE,CAOpB;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC,GAAG,IAAI,EAC/D,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC,GAAG,IAAI,WAOhE;AAED,wBAAgB,eAAe,CAC7B,YAAY,EAAE,gBAAgB,EAAE,EAChC,UAAU,EAAE,gBAAgB,GAAG,IAAI,GAClC,gBAAgB,CAQlB;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,EAAE,GACzB,eAAe,EAAE,CAcnB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.1.20-next.
|
|
3
|
+
"version": "0.1.20-next.10",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"typings": "dist/index.d.ts",
|
|
7
8
|
"files": [
|
|
@@ -10,27 +11,19 @@
|
|
|
10
11
|
],
|
|
11
12
|
"browserslist": "> 0.5%, last 2 versions, not dead",
|
|
12
13
|
"scripts": {
|
|
13
|
-
"build": "
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"pre-commit": "tsdx lint"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"prettier": {
|
|
21
|
-
"printWidth": 80,
|
|
22
|
-
"semi": true,
|
|
23
|
-
"singleQuote": true,
|
|
24
|
-
"trailingComma": "es5"
|
|
14
|
+
"build": "node ../../scripts/build/command.mjs --path widget/embedded",
|
|
15
|
+
"clean": "rimraf dist",
|
|
16
|
+
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
17
|
+
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
|
|
25
18
|
},
|
|
26
19
|
"dependencies": {
|
|
27
|
-
"@rango-dev/provider-all": "^0.1.22-next.
|
|
28
|
-
"@rango-dev/queue-manager-core": "^0.1.
|
|
29
|
-
"@rango-dev/queue-manager-rango-preset": "^0.1.
|
|
30
|
-
"@rango-dev/queue-manager-react": "^0.1.
|
|
31
|
-
"@rango-dev/ui": "^0.1.16-next.
|
|
32
|
-
"@rango-dev/wallets-core": "^0.1.16-next.
|
|
33
|
-
"@rango-dev/wallets-shared": "^0.1.
|
|
20
|
+
"@rango-dev/provider-all": "^0.1.22-next.7",
|
|
21
|
+
"@rango-dev/queue-manager-core": "^0.1.15-next.4",
|
|
22
|
+
"@rango-dev/queue-manager-rango-preset": "^0.1.15-next.8",
|
|
23
|
+
"@rango-dev/queue-manager-react": "^0.1.14-next.5",
|
|
24
|
+
"@rango-dev/ui": "^0.1.16-next.9",
|
|
25
|
+
"@rango-dev/wallets-core": "^0.1.16-next.6",
|
|
26
|
+
"@rango-dev/wallets-shared": "^0.1.15-next.5",
|
|
34
27
|
"bignumber.js": "^9.1.1",
|
|
35
28
|
"copy-to-clipboard": "^3.3.3",
|
|
36
29
|
"dayjs": "^1.11.7",
|
|
@@ -40,8 +33,8 @@
|
|
|
40
33
|
"immer": "^9.0.19",
|
|
41
34
|
"mitt": "^3.0.0",
|
|
42
35
|
"parcel": "^2.8.0",
|
|
43
|
-
"rango-sdk": "^0.1.
|
|
44
|
-
"rango-types": "^0.1.
|
|
36
|
+
"rango-sdk": "^0.1.29",
|
|
37
|
+
"rango-types": "^0.1.38",
|
|
45
38
|
"react-i18next": "^12.2.0",
|
|
46
39
|
"react-router-dom": "^6.8.0",
|
|
47
40
|
"values.js": "2.1.1",
|
package/src/QueueManager.tsx
CHANGED
|
@@ -18,7 +18,7 @@ import { walletAndSupportedChainsNames } from './utils/wallets';
|
|
|
18
18
|
import { isEvmBlockchain } from 'rango-sdk';
|
|
19
19
|
import { getConfig } from './utils/configs';
|
|
20
20
|
|
|
21
|
-
function QueueManager(props: PropsWithChildren
|
|
21
|
+
function QueueManager(props: PropsWithChildren) {
|
|
22
22
|
const {
|
|
23
23
|
providers,
|
|
24
24
|
getSigners,
|
|
@@ -59,7 +59,7 @@ function QueueManager(props: PropsWithChildren<{}>) {
|
|
|
59
59
|
const allBlockchains = blockchains
|
|
60
60
|
.filter((blockchain) => blockchain.enabled)
|
|
61
61
|
.reduce(
|
|
62
|
-
(blockchainsObj, blockchain) => (
|
|
62
|
+
(blockchainsObj: any, blockchain) => (
|
|
63
63
|
(blockchainsObj[blockchain.name] = blockchain), blockchainsObj
|
|
64
64
|
),
|
|
65
65
|
{}
|
|
@@ -103,10 +103,12 @@ function QueueManager(props: PropsWithChildren<{}>) {
|
|
|
103
103
|
},
|
|
104
104
|
getSigners,
|
|
105
105
|
//todo: remove Network type
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
106
107
|
//@ts-ignore
|
|
107
108
|
wallets,
|
|
108
109
|
providers: allProviders,
|
|
109
110
|
switchNetwork,
|
|
111
|
+
canSwitchNetworkTo,
|
|
110
112
|
connect,
|
|
111
113
|
state,
|
|
112
114
|
isMobileWallet,
|
|
@@ -120,8 +122,7 @@ function QueueManager(props: PropsWithChildren<{}>) {
|
|
|
120
122
|
onPersistedDataLoaded={(manager) => {
|
|
121
123
|
checkWaitingForNetworkChange(manager);
|
|
122
124
|
}}
|
|
123
|
-
isPaused={false}
|
|
124
|
-
>
|
|
125
|
+
isPaused={false}>
|
|
125
126
|
{props.children}
|
|
126
127
|
</ManagerProvider>
|
|
127
128
|
);
|
|
@@ -15,12 +15,7 @@ import { Layout } from './components/Layout';
|
|
|
15
15
|
import { globalFont } from './globalStyles';
|
|
16
16
|
import { useTheme } from './hooks/useTheme';
|
|
17
17
|
import { isEvmBlockchain } from 'rango-sdk';
|
|
18
|
-
import {
|
|
19
|
-
WidgetTheme,
|
|
20
|
-
WidgetConfig,
|
|
21
|
-
WidgetColors,
|
|
22
|
-
BlockchainAndTokenConfig,
|
|
23
|
-
} from './types';
|
|
18
|
+
import { WidgetConfig } from './types';
|
|
24
19
|
import useSelectLanguage from './hooks/useSelectLanguage';
|
|
25
20
|
import './i18n';
|
|
26
21
|
import QueueManager from './QueueManager';
|
|
@@ -28,8 +23,6 @@ import { useUiStore } from './store/ui';
|
|
|
28
23
|
import { navigationRoutes } from './constants/navigationRoutes';
|
|
29
24
|
import { initConfig } from './utils/configs';
|
|
30
25
|
|
|
31
|
-
export { WidgetConfig, WidgetTheme, WidgetColors, BlockchainAndTokenConfig };
|
|
32
|
-
|
|
33
26
|
export type WidgetProps = {
|
|
34
27
|
config?: WidgetConfig;
|
|
35
28
|
};
|
|
@@ -5,6 +5,7 @@ import { WalletType } from '@rango-dev/wallets-shared';
|
|
|
5
5
|
import { isEvmBlockchain } from 'rango-types';
|
|
6
6
|
import { UpdateUrl } from './UpdateUrl';
|
|
7
7
|
import { useMetaStore } from '../store/meta';
|
|
8
|
+
import { useWallets } from '@rango-dev/wallets-core';
|
|
8
9
|
|
|
9
10
|
export function AppRouter({
|
|
10
11
|
children,
|
|
@@ -17,6 +18,7 @@ export function AppRouter({
|
|
|
17
18
|
const isRouterInContext = useInRouterContext();
|
|
18
19
|
const Router = isRouterInContext ? Fragment : MemoryRouter;
|
|
19
20
|
const { blockchains } = useMetaStore.use.meta();
|
|
21
|
+
const { canSwitchNetworkTo } = useWallets();
|
|
20
22
|
|
|
21
23
|
const evmChains = blockchains.filter(isEvmBlockchain);
|
|
22
24
|
|
|
@@ -25,7 +27,9 @@ export function AppRouter({
|
|
|
25
27
|
clearDisconnectedWallet: props.clearDisconnectedWallet,
|
|
26
28
|
disconnectedWallet: props.disconnectedWallet,
|
|
27
29
|
evmChains,
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
28
31
|
notifier: () => {},
|
|
32
|
+
canSwitchNetworkTo,
|
|
29
33
|
});
|
|
30
34
|
|
|
31
35
|
return (
|
|
@@ -52,6 +52,8 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
52
52
|
const affiliateRef = useSettingsStore.use.affiliateRef();
|
|
53
53
|
|
|
54
54
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
55
|
+
const destination = useWalletsStore.use.customDestination();
|
|
56
|
+
|
|
55
57
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
56
58
|
const meta = useMetaStore.use.meta();
|
|
57
59
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
@@ -113,7 +115,8 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
113
115
|
disabledLiquiditySources,
|
|
114
116
|
userSlippage,
|
|
115
117
|
affiliateRef,
|
|
116
|
-
initialRoute
|
|
118
|
+
initialRoute,
|
|
119
|
+
destination
|
|
117
120
|
);
|
|
118
121
|
|
|
119
122
|
try {
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WidgetTheme,
|
|
3
|
+
WidgetConfig,
|
|
4
|
+
WidgetColors,
|
|
5
|
+
BlockchainAndTokenConfig,
|
|
6
|
+
} from './types';
|
|
7
|
+
import { WidgetProps, Widget } from './Widget';
|
|
8
|
+
import { WalletType } from '@rango-dev/wallets-shared';
|
|
9
|
+
|
|
10
|
+
export type {
|
|
11
|
+
WidgetConfig,
|
|
12
|
+
WalletType,
|
|
13
|
+
WidgetTheme,
|
|
14
|
+
WidgetColors,
|
|
15
|
+
BlockchainAndTokenConfig,
|
|
16
|
+
WidgetProps,
|
|
17
|
+
};
|
|
18
|
+
export { Widget };
|
|
@@ -10,7 +10,11 @@ import {
|
|
|
10
10
|
getSelectableWallets,
|
|
11
11
|
isExperimentalChain,
|
|
12
12
|
} from '../utils/wallets';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
confirmSwapDisabled,
|
|
15
|
+
getTotalFeeInUsd,
|
|
16
|
+
isValidCustomDestination,
|
|
17
|
+
} from '../utils/swap';
|
|
14
18
|
import { numberToString } from '../utils/numbers';
|
|
15
19
|
import { useMetaStore } from '../store/meta';
|
|
16
20
|
import { Network, WalletType } from '@rango-dev/wallets-shared';
|
|
@@ -31,7 +35,11 @@ import { ConfirmSwapExtraMessages } from '../components/warnings/ConfirmSwapExtr
|
|
|
31
35
|
import { getBestRouteStatus } from '../utils/routing';
|
|
32
36
|
import { PercentageChange } from '../components/PercentageChange';
|
|
33
37
|
|
|
34
|
-
export function ConfirmSwapPage(
|
|
38
|
+
export function ConfirmSwapPage({
|
|
39
|
+
customDestinationEnabled,
|
|
40
|
+
}: {
|
|
41
|
+
customDestinationEnabled?: boolean;
|
|
42
|
+
}) {
|
|
35
43
|
const navigate = useNavigate();
|
|
36
44
|
const { navigateBackFrom } = useNavigateBack();
|
|
37
45
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
@@ -42,6 +50,8 @@ export function ConfirmSwapPage() {
|
|
|
42
50
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
43
51
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
44
52
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
53
|
+
const customDestination = useWalletsStore.use.customDestination();
|
|
54
|
+
const setCustomDestination = useWalletsStore.use.setCustomDestination();
|
|
45
55
|
const initSelectedWallets = useWalletsStore.use.initSelectedWallets();
|
|
46
56
|
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
47
57
|
const slippage = useSettingsStore.use.slippage();
|
|
@@ -54,6 +64,7 @@ export function ConfirmSwapPage() {
|
|
|
54
64
|
fetchingBestRoute,
|
|
55
65
|
!!fetchingBestRouteError
|
|
56
66
|
);
|
|
67
|
+
const [destinationChain, setDestinationChain] = useState<string>('');
|
|
57
68
|
|
|
58
69
|
const { manager } = useManager();
|
|
59
70
|
const {
|
|
@@ -66,15 +77,10 @@ export function ConfirmSwapPage() {
|
|
|
66
77
|
const selectedSlippage = customSlippage || slippage;
|
|
67
78
|
|
|
68
79
|
const showHighSlippageWarning = !errors.find(
|
|
69
|
-
error => error.type === ConfirmSwapErrorTypes.INSUFFICIENT_SLIPPAGE
|
|
80
|
+
(error) => error.type === ConfirmSwapErrorTypes.INSUFFICIENT_SLIPPAGE
|
|
70
81
|
);
|
|
71
82
|
|
|
72
83
|
const { getWalletInfo, connect } = useWallets();
|
|
73
|
-
const confirmDisabled =
|
|
74
|
-
fetchingBestRoute ||
|
|
75
|
-
!requiredWallets(bestRoute).every(chain =>
|
|
76
|
-
selectedWallets.map(wallet => wallet.chain).includes(chain)
|
|
77
|
-
);
|
|
78
84
|
|
|
79
85
|
const firstStep = bestRoute?.result?.swaps[0];
|
|
80
86
|
const lastStep =
|
|
@@ -84,20 +90,27 @@ export function ConfirmSwapPage() {
|
|
|
84
90
|
const toAmount = numberToString(lastStep?.toAmount, 4, 6);
|
|
85
91
|
useEffect(() => {
|
|
86
92
|
initSelectedWallets();
|
|
93
|
+
if (!!customDestination) {
|
|
94
|
+
setCustomDestination('');
|
|
95
|
+
}
|
|
87
96
|
}, []);
|
|
97
|
+
const lastStepToBlockchain =
|
|
98
|
+
bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to.blockchain;
|
|
99
|
+
const isWalletRequired = !!bestRoute?.result?.swaps.find(
|
|
100
|
+
(swap) => swap.from.blockchain === lastStepToBlockchain
|
|
101
|
+
);
|
|
88
102
|
|
|
89
103
|
const selectableWallets = getSelectableWallets(
|
|
90
104
|
connectedWallets,
|
|
91
105
|
selectedWallets,
|
|
92
|
-
getWalletInfo
|
|
106
|
+
getWalletInfo,
|
|
107
|
+
isWalletRequired ? '' : destinationChain
|
|
93
108
|
);
|
|
94
109
|
|
|
95
110
|
const handleConnectChain = (wallet: string) => {
|
|
96
111
|
const network = wallet as Network;
|
|
97
|
-
getKeplrCompatibleConnectedWallets(
|
|
98
|
-
|
|
99
|
-
).forEach((compatibleWallet: WalletType) =>
|
|
100
|
-
connect?.(compatibleWallet, network)
|
|
112
|
+
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(
|
|
113
|
+
(compatibleWallet: WalletType) => connect?.(compatibleWallet, network)
|
|
101
114
|
);
|
|
102
115
|
};
|
|
103
116
|
|
|
@@ -107,9 +120,15 @@ export function ConfirmSwapPage() {
|
|
|
107
120
|
<ConfirmSwap
|
|
108
121
|
requiredWallets={getRequiredChains(bestRoute)}
|
|
109
122
|
selectableWallets={selectableWallets}
|
|
123
|
+
setCustomDestination={setCustomDestination}
|
|
124
|
+
customDestination={customDestination}
|
|
125
|
+
customDestinationEnabled={customDestinationEnabled}
|
|
126
|
+
isValidCustomDestination={isValidCustomDestination}
|
|
127
|
+
checkedDestination={!!destinationChain}
|
|
128
|
+
setDestinationChain={setDestinationChain}
|
|
110
129
|
onBack={navigateBackFrom.bind(null, navigationRoutes.confirmSwap)}
|
|
111
130
|
onConfirm={async () => {
|
|
112
|
-
confirmSwap?.().then(async swap => {
|
|
131
|
+
confirmSwap?.().then(async (swap) => {
|
|
113
132
|
if (swap) {
|
|
114
133
|
try {
|
|
115
134
|
await manager?.create(
|
|
@@ -130,10 +149,20 @@ export function ConfirmSwapPage() {
|
|
|
130
149
|
}
|
|
131
150
|
});
|
|
132
151
|
}}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
152
|
+
isWalletRequired={isWalletRequired}
|
|
153
|
+
onChange={(wallet) => setSelectedWallet(wallet)}
|
|
154
|
+
confirmDisabled={
|
|
155
|
+
loadingMetaStatus !== 'success' ||
|
|
156
|
+
confirmSwapDisabled(
|
|
157
|
+
fetchingBestRoute,
|
|
158
|
+
destinationChain,
|
|
159
|
+
customDestination,
|
|
160
|
+
bestRoute,
|
|
161
|
+
selectableWallets
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
handleConnectChain={(wallet) => handleConnectChain(wallet)}
|
|
165
|
+
isExperimentalChain={(wallet) =>
|
|
137
166
|
getKeplrCompatibleConnectedWallets(selectableWallets).length > 0
|
|
138
167
|
? isExperimentalChain(blockchains, wallet)
|
|
139
168
|
: false
|
|
@@ -24,14 +24,12 @@ import {
|
|
|
24
24
|
isNetworkStatusInWarningState,
|
|
25
25
|
shouldRetrySwap,
|
|
26
26
|
} from '../utils/swap';
|
|
27
|
-
//@ts-ignore
|
|
28
|
-
import { t } from 'i18next';
|
|
29
27
|
import { SwapDetailsPlaceholder } from '../components/SwapDetailsPlaceholder';
|
|
30
28
|
import { getFormatedPendingSwap } from '../utils/routing';
|
|
31
29
|
|
|
32
30
|
export function SwapDetailsPage() {
|
|
33
31
|
const selectedSwapRequestId = useUiStore.use.selectedSwapRequestId();
|
|
34
|
-
const { canSwitchNetworkTo, connect } = useWallets();
|
|
32
|
+
const { canSwitchNetworkTo, connect, getWalletInfo } = useWallets();
|
|
35
33
|
const retry = useBestRouteStore.use.retry();
|
|
36
34
|
const navigate = useNavigate();
|
|
37
35
|
const { navigateBackFrom } = useNavigateBack();
|
|
@@ -44,6 +42,7 @@ export function SwapDetailsPage() {
|
|
|
44
42
|
);
|
|
45
43
|
|
|
46
44
|
const onCancel = () => {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
47
46
|
const swap = manager?.get(selectedSwap?.id!);
|
|
48
47
|
if (swap) cancelSwap(swap);
|
|
49
48
|
};
|
|
@@ -77,14 +76,20 @@ export function SwapDetailsPage() {
|
|
|
77
76
|
|
|
78
77
|
const shouldRetry = shouldRetrySwap(swap);
|
|
79
78
|
|
|
80
|
-
const
|
|
81
|
-
!!
|
|
82
|
-
|
|
79
|
+
const isMobileWallet = (walletType: string): boolean =>
|
|
80
|
+
!!getWalletInfo(walletType)?.mobileWallet;
|
|
81
|
+
|
|
82
|
+
const showSwitchNetwork =
|
|
83
83
|
currentStepNetworkStatus ===
|
|
84
84
|
PendingSwapNetworkStatus.WaitingForNetworkChange &&
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
!!currentStepBlockchain &&
|
|
86
|
+
!!currentStepWallet?.walletType &&
|
|
87
|
+
(isMobileWallet(currentStepWallet.walletType) ||
|
|
88
|
+
canSwitchNetworkTo(currentStepWallet.walletType, currentStepBlockchain));
|
|
89
|
+
|
|
90
|
+
const switchNetwork = showSwitchNetwork
|
|
91
|
+
? connect.bind(null, currentStepWallet.walletType, currentStepBlockchain)
|
|
92
|
+
: undefined;
|
|
88
93
|
|
|
89
94
|
const lastConvertedTokenInFailedSwap =
|
|
90
95
|
getLastConvertedTokenInFailedSwap(swap);
|
package/src/store/wallets.ts
CHANGED
|
@@ -39,12 +39,14 @@ export interface ConnectedWallet extends Wallet {
|
|
|
39
39
|
interface WalletsStore {
|
|
40
40
|
connectedWallets: ConnectedWallet[];
|
|
41
41
|
selectedWallets: Wallet[];
|
|
42
|
+
customDestination: string;
|
|
42
43
|
connectWallet: (accounts: Wallet[]) => void;
|
|
43
44
|
disconnectWallet: (walletType: WalletType) => void;
|
|
44
45
|
initSelectedWallets: () => void;
|
|
45
46
|
setSelectedWallet: (wallet: SelectableWallet) => void;
|
|
46
47
|
clearConnectedWallet: () => void;
|
|
47
48
|
getOneOfWalletsDetails: (account: Wallet) => void;
|
|
49
|
+
setCustomDestination: (customDestination: string) => void;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
export const useWalletsStore = createSelectors(
|
|
@@ -52,6 +54,7 @@ export const useWalletsStore = createSelectors(
|
|
|
52
54
|
subscribeWithSelector((set, get) => ({
|
|
53
55
|
connectedWallets: [],
|
|
54
56
|
selectedWallets: [],
|
|
57
|
+
customDestination: '',
|
|
55
58
|
connectWallet: (accounts) => {
|
|
56
59
|
const getOneOfWalletsDetails = get().getOneOfWalletsDetails;
|
|
57
60
|
set((state) => ({
|
|
@@ -92,6 +95,7 @@ export const useWalletsStore = createSelectors(
|
|
|
92
95
|
const anyWalletSelected = !!state.selectedWallets.find(
|
|
93
96
|
(wallet) => wallet.chain === chain
|
|
94
97
|
);
|
|
98
|
+
|
|
95
99
|
if (!anyWalletSelected) {
|
|
96
100
|
const firstWalletWithMatchedChain = connectedWallets.find(
|
|
97
101
|
(wallet) => wallet.chain === chain
|
|
@@ -118,7 +122,10 @@ export const useWalletsStore = createSelectors(
|
|
|
118
122
|
walletType: wallet.walletType,
|
|
119
123
|
}),
|
|
120
124
|
})),
|
|
121
|
-
|
|
125
|
+
setCustomDestination: (customDestination) =>
|
|
126
|
+
set(() => ({
|
|
127
|
+
customDestination,
|
|
128
|
+
})),
|
|
122
129
|
clearConnectedWallet: () =>
|
|
123
130
|
set(() => ({
|
|
124
131
|
connectedWallets: [],
|