@rango-dev/widget-embedded 0.1.20-next.2 → 0.1.20-next.4
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/hooks/useConfirmSwap.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/pages/ConfirmSwapPage.d.ts +3 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +4 -0
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +2 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +3 -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 +6 -6
- package/src/components/AppRoutes.tsx +1 -1
- package/src/hooks/useConfirmSwap.ts +4 -1
- package/src/pages/ConfirmSwapPage.tsx +47 -18
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":";AAqCA,wBAAgB,eAAe,CAAC,EAC9B,wBAAwB,GACzB,EAAE;IACD,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,eA8MA"}
|
package/dist/store/wallets.d.ts
CHANGED
|
@@ -21,12 +21,14 @@ export interface ConnectedWallet extends Wallet {
|
|
|
21
21
|
interface WalletsStore {
|
|
22
22
|
connectedWallets: ConnectedWallet[];
|
|
23
23
|
selectedWallets: Wallet[];
|
|
24
|
+
customDestination: string;
|
|
24
25
|
connectWallet: (accounts: Wallet[]) => void;
|
|
25
26
|
disconnectWallet: (walletType: WalletType) => void;
|
|
26
27
|
initSelectedWallets: () => void;
|
|
27
28
|
setSelectedWallet: (wallet: SelectableWallet) => void;
|
|
28
29
|
clearConnectedWallet: () => void;
|
|
29
30
|
getOneOfWalletsDetails: (account: Wallet) => void;
|
|
31
|
+
setCustomDestination: (customDestination: string) => void;
|
|
30
32
|
}
|
|
31
33
|
export declare const useWalletsStore: {
|
|
32
34
|
(): WalletsStore;
|
|
@@ -43,12 +45,14 @@ export declare const useWalletsStore: {
|
|
|
43
45
|
use: {
|
|
44
46
|
connectedWallets: () => ConnectedWallet[];
|
|
45
47
|
selectedWallets: () => Wallet[];
|
|
48
|
+
customDestination: () => string;
|
|
46
49
|
connectWallet: () => (accounts: Wallet[]) => void;
|
|
47
50
|
disconnectWallet: () => (walletType: WalletType) => void;
|
|
48
51
|
initSelectedWallets: () => () => void;
|
|
49
52
|
setSelectedWallet: () => (wallet: SelectableWallet) => void;
|
|
50
53
|
clearConnectedWallet: () => () => void;
|
|
51
54
|
getOneOfWalletsDetails: () => (account: Wallet) => void;
|
|
55
|
+
setCustomDestination: () => (customDestination: string) => void;
|
|
52
56
|
};
|
|
53
57
|
};
|
|
54
58
|
export declare const fetchingBalanceSelector: (state: WalletsStore) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/store/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAgBvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,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@ export type BlockchainAndTokenConfig = {
|
|
|
90
90
|
* include values like `"metamask"`, `"kepler"`, or `"phantom"`.
|
|
91
91
|
* @property {boolean} multiWallets - The `multiWallets` property is a boolean value that indicates
|
|
92
92
|
* whether the widget should allow the user to select multiple wallets for the transaction.
|
|
93
|
-
* @property {boolean}
|
|
93
|
+
* @property {boolean} customDestination - A boolean value indicating whether the user can input a custom
|
|
94
94
|
* address for the transaction. If set to true, the widget will allow the user to input a custom
|
|
95
95
|
* address for the destination.
|
|
96
96
|
* @property {string} language - The language property is an optional string that specifies the
|
|
@@ -109,7 +109,7 @@ export type WidgetConfig = {
|
|
|
109
109
|
liquiditySources?: string[];
|
|
110
110
|
wallets?: WalletType[];
|
|
111
111
|
multiWallets?: boolean;
|
|
112
|
-
|
|
112
|
+
customDestination?: boolean;
|
|
113
113
|
language?: string;
|
|
114
114
|
theme?: WidgetTheme;
|
|
115
115
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAA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,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC"}
|
package/dist/utils/swap.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare function getMinRequiredSlippage(route: BestRouteResponse): string
|
|
|
26
26
|
export declare function hasProperSlippage(userSlippage: string, minRequiredSlippage: string | null): boolean;
|
|
27
27
|
export declare function hasEnoughBalance(route: BestRouteResponse, selectedWallets: Wallet[]): boolean;
|
|
28
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;
|
|
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
30
|
export declare function getWalletsForNewSwap(selectedWallets: Wallet[]): {
|
|
31
31
|
[p: string]: {
|
|
32
32
|
address: string;
|
|
@@ -48,4 +48,6 @@ export declare function getSwapMessages(pendingSwap: PendingSwap, currentStep: P
|
|
|
48
48
|
};
|
|
49
49
|
export declare function getLastConvertedTokenInFailedSwap(pendingSwap: PendingSwap): ConvertedToken;
|
|
50
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":["../../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,
|
|
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;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAiB1E;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI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E,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/wallets.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare function getlistWallet(getState: (type: WalletType) => WalletStat
|
|
|
10
10
|
export declare function walletAndSupportedChainsNames(supportedChains: BlockchainMeta[]): Network[] | null;
|
|
11
11
|
export declare function prepareAccountsForWalletStore(wallet: WalletType, accounts: string[], evmBasedChains: string[], supportedChainNames: Network[] | null): Wallet[];
|
|
12
12
|
export declare function getRequiredChains(route: BestRouteResponse | null): string[];
|
|
13
|
-
export declare function getSelectableWallets(connectedWallets: ConnectedWallet[], selectedWallets: Wallet[], getWalletInfo: (type: WalletType) => WalletInfo): SelectableWallet[];
|
|
13
|
+
export declare function getSelectableWallets(connectedWallets: ConnectedWallet[], selectedWallets: Wallet[], getWalletInfo: (type: WalletType) => WalletInfo, destinationChain?: string): SelectableWallet[];
|
|
14
14
|
export declare function getBalanceFromWallet(connectedWallets: ConnectedWallet[], chain: string, symbol: string, address: string | null): TokenBalance | null;
|
|
15
15
|
export declare function isAccountAndWalletMatched(account: Wallet, connectedWallet: ConnectedWallet): boolean;
|
|
16
16
|
export declare function makeBalanceFor(wallet: Wallet, retrivedBalance: WalletDetail, tokens: Token[]): ConnectedWallet;
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,UAAU,EAAE,GACjB,eAAe,EAAE,CAoBnB;AAED,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,cAAc,EAAE,GAChC,OAAO,EAAE,GAAG,IAAI,CAQlB;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,MAAM,EAAE,EACxB,mBAAmB,EAAE,OAAO,EAAE,GAAG,IAAI,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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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.1.20-next.
|
|
3
|
+
"version": "0.1.20-next.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@rango-dev/provider-all": "^0.1.22-next.2",
|
|
21
21
|
"@rango-dev/queue-manager-core": "^0.1.15-next.2",
|
|
22
|
-
"@rango-dev/queue-manager-rango-preset": "^0.1.15-next.
|
|
23
|
-
"@rango-dev/queue-manager-react": "^0.1.14-next.
|
|
24
|
-
"@rango-dev/ui": "^0.1.16-next.
|
|
25
|
-
"@rango-dev/wallets-core": "^0.1.16-next.
|
|
26
|
-
"@rango-dev/wallets-shared": "^0.1.15-next.
|
|
22
|
+
"@rango-dev/queue-manager-rango-preset": "^0.1.15-next.3",
|
|
23
|
+
"@rango-dev/queue-manager-react": "^0.1.14-next.3",
|
|
24
|
+
"@rango-dev/ui": "^0.1.16-next.3",
|
|
25
|
+
"@rango-dev/wallets-core": "^0.1.16-next.3",
|
|
26
|
+
"@rango-dev/wallets-shared": "^0.1.15-next.2",
|
|
27
27
|
"bignumber.js": "^9.1.1",
|
|
28
28
|
"copy-to-clipboard": "^3.3.3",
|
|
29
29
|
"dayjs": "^1.11.7",
|
|
@@ -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 {
|
|
@@ -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
|
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: [],
|
package/src/types/config.ts
CHANGED
|
@@ -91,7 +91,7 @@ export type BlockchainAndTokenConfig = {
|
|
|
91
91
|
* include values like `"metamask"`, `"kepler"`, or `"phantom"`.
|
|
92
92
|
* @property {boolean} multiWallets - The `multiWallets` property is a boolean value that indicates
|
|
93
93
|
* whether the widget should allow the user to select multiple wallets for the transaction.
|
|
94
|
-
* @property {boolean}
|
|
94
|
+
* @property {boolean} customDestination - A boolean value indicating whether the user can input a custom
|
|
95
95
|
* address for the transaction. If set to true, the widget will allow the user to input a custom
|
|
96
96
|
* address for the destination.
|
|
97
97
|
* @property {string} language - The language property is an optional string that specifies the
|
|
@@ -110,7 +110,7 @@ export type WidgetConfig = {
|
|
|
110
110
|
liquiditySources?: string[];
|
|
111
111
|
wallets?: WalletType[];
|
|
112
112
|
multiWallets?: boolean;
|
|
113
|
-
|
|
113
|
+
customDestination?: boolean;
|
|
114
114
|
language?: string;
|
|
115
115
|
theme?: WidgetTheme;
|
|
116
116
|
};
|
package/src/utils/common.ts
CHANGED
package/src/utils/swap.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { numberToString } from './numbers';
|
|
|
12
12
|
import { WalletType } from '@rango-dev/wallets-shared';
|
|
13
13
|
import { getRequiredBalanceOfWallet } from './routing';
|
|
14
14
|
import { getRequiredChains } from './wallets';
|
|
15
|
-
import { LoadingStatus } from '../store/meta';
|
|
15
|
+
import { LoadingStatus, useMetaStore } from '../store/meta';
|
|
16
16
|
import { ConvertedToken, SwapButtonState, Wallet } from '../types';
|
|
17
17
|
import {
|
|
18
18
|
PendingSwapNetworkStatus,
|
|
@@ -317,7 +317,8 @@ export function createBestRouteRequestBody(
|
|
|
317
317
|
disabledLiquiditySources: string[],
|
|
318
318
|
slippage: number,
|
|
319
319
|
affiliateRef: string | null,
|
|
320
|
-
initialRoute?: BestRouteResponse
|
|
320
|
+
initialRoute?: BestRouteResponse,
|
|
321
|
+
destination?: string
|
|
321
322
|
): BestRouteRequest {
|
|
322
323
|
const selectedWalletsMap = selectedWallets.reduce(
|
|
323
324
|
(
|
|
@@ -370,6 +371,7 @@ export function createBestRouteRequestBody(
|
|
|
370
371
|
symbol: toToken.symbol,
|
|
371
372
|
},
|
|
372
373
|
connectedWallets,
|
|
374
|
+
destination: destination || undefined,
|
|
373
375
|
selectedWallets: selectedWalletsMap,
|
|
374
376
|
swapperGroups: disabledLiquiditySources,
|
|
375
377
|
swappersGroupsExclude: true,
|
|
@@ -561,3 +563,37 @@ export function shouldRetrySwap(pendingSwap: PendingSwap) {
|
|
|
561
563
|
new Date().getTime() - parseInt(pendingSwap.finishTime) < 4 * 3600 * 1000
|
|
562
564
|
);
|
|
563
565
|
}
|
|
566
|
+
export function isValidCustomDestination(
|
|
567
|
+
blockchain: string,
|
|
568
|
+
address: string
|
|
569
|
+
): boolean {
|
|
570
|
+
const blockchains = useMetaStore.getState().meta.blockchains;
|
|
571
|
+
const regex =
|
|
572
|
+
blockchains.find((chain) => chain.name === blockchain)?.addressPatterns ||
|
|
573
|
+
[];
|
|
574
|
+
return regex.filter((r) => new RegExp(r).test(address)).length > 0;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export function confirmSwapDisabled(
|
|
578
|
+
fetching: boolean,
|
|
579
|
+
destinationChain: string,
|
|
580
|
+
customDestination: string,
|
|
581
|
+
bestRoute: BestRouteResponse | null,
|
|
582
|
+
selectedWallets: Wallet[]
|
|
583
|
+
) {
|
|
584
|
+
return (
|
|
585
|
+
fetching ||
|
|
586
|
+
(!destinationChain &&
|
|
587
|
+
!requiredWallets(bestRoute).every((chain) =>
|
|
588
|
+
selectedWallets.map((wallet) => wallet.chain).includes(chain)
|
|
589
|
+
)) ||
|
|
590
|
+
(!!destinationChain && !customDestination) ||
|
|
591
|
+
(!!destinationChain &&
|
|
592
|
+
!!customDestination &&
|
|
593
|
+
!requiredWallets(bestRoute)
|
|
594
|
+
.filter((chain) => chain !== destinationChain)
|
|
595
|
+
.every((chain) =>
|
|
596
|
+
selectedWallets.map((wallet) => wallet.chain).includes(chain)
|
|
597
|
+
))
|
|
598
|
+
);
|
|
599
|
+
}
|
package/src/utils/wallets.ts
CHANGED
|
@@ -168,21 +168,27 @@ type Blockchain = { name: string; accounts: ConnectedWallet[] };
|
|
|
168
168
|
export function getSelectableWallets(
|
|
169
169
|
connectedWallets: ConnectedWallet[],
|
|
170
170
|
selectedWallets: Wallet[],
|
|
171
|
-
getWalletInfo: (type: WalletType) => WalletInfo
|
|
171
|
+
getWalletInfo: (type: WalletType) => WalletInfo,
|
|
172
|
+
destinationChain?: string
|
|
172
173
|
): SelectableWallet[] {
|
|
173
|
-
const selectableWallets
|
|
174
|
-
(connectedWallet) =>
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
174
|
+
const selectableWallets = connectedWallets.map(
|
|
175
|
+
(connectedWallet: ConnectedWallet) => {
|
|
176
|
+
return {
|
|
177
|
+
address: connectedWallet.address,
|
|
178
|
+
walletType: connectedWallet.walletType,
|
|
179
|
+
chain: connectedWallet.chain,
|
|
180
|
+
image: getWalletInfo(connectedWallet.walletType).img,
|
|
181
|
+
name: getWalletInfo(connectedWallet.walletType).name,
|
|
182
|
+
selected:
|
|
183
|
+
destinationChain === connectedWallet.chain
|
|
184
|
+
? false
|
|
185
|
+
: !!selectedWallets.find(
|
|
186
|
+
(selectedWallet) =>
|
|
187
|
+
selectedWallet.chain === connectedWallet.chain &&
|
|
188
|
+
selectedWallet.walletType === connectedWallet.walletType
|
|
189
|
+
),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
186
192
|
);
|
|
187
193
|
|
|
188
194
|
return selectableWallets;
|