@rango-dev/widget-embedded 0.17.1-next.26 → 0.17.1-next.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/containers/App/App.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +9 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +8 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
- package/dist/hooks/useLanguage.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/ThemePage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +37 -1
- package/dist/store/AppStore.d.ts.map +1 -1
- package/dist/store/app.d.ts +39 -2
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts +39 -0
- package/dist/store/slices/settings.d.ts.map +1 -0
- package/dist/types/config.d.ts +28 -9
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +4 -1
- package/dist/utils/settings.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/HeaderButtons/HomeButtons.tsx +28 -18
- package/src/components/Layout/Layout.tsx +11 -1
- package/src/components/NoResult/NoResult.tsx +2 -5
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +2 -2
- package/src/components/Slippage/Slippage.tsx +3 -5
- package/src/containers/App/App.tsx +1 -4
- package/src/containers/Wallets/Wallets.tsx +6 -1
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +20 -1
- package/src/containers/WidgetInfo/WidgetInfo.tsx +15 -1
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +8 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +4 -4
- package/src/hooks/useLanguage.ts +2 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +2 -2
- package/src/hooks/useSwapInput.ts +4 -4
- package/src/hooks/useSyncStoresWithConfig.ts +1 -2
- package/src/hooks/useTheme.ts +4 -5
- package/src/pages/ConfirmSwapPage.tsx +2 -3
- package/src/pages/LiquiditySourcePage.tsx +3 -3
- package/src/pages/SettingsPage.tsx +22 -11
- package/src/pages/ThemePage.tsx +2 -3
- package/src/store/AppStore.tsx +7 -1
- package/src/store/app.ts +31 -5
- package/src/store/slices/settings.ts +168 -0
- package/src/types/config.ts +38 -8
- package/src/utils/settings.ts +11 -5
- package/dist/store/settings.d.ts +0 -83
- package/dist/store/settings.d.ts.map +0 -1
- package/src/store/settings.ts +0 -161
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAqD5E,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAqD5E,wBAAgB,eAAe,sBA2S9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiquiditySourcePage.d.ts","sourceRoot":"","sources":["../../src/pages/LiquiditySourcePage.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LiquiditySourcePage.d.ts","sourceRoot":"","sources":["../../src/pages/LiquiditySourcePage.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAexC,UAAU,SAAS;IACjB,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;CACrC;AAED,wBAAgB,mBAAmB,CAAC,EAAE,UAAU,EAAE,EAAE,SAAS,qBAqH5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SettingsPage.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SettingsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SettingsPage.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,wBAAgB,YAAY,sBA2K3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemePage.d.ts","sourceRoot":"","sources":["../../src/pages/ThemePage.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,wBAAgB,SAAS,
|
|
1
|
+
{"version":3,"file":"ThemePage.d.ts","sourceRoot":"","sources":["../../src/pages/ThemePage.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,wBAAgB,SAAS,sBAiExB"}
|
package/dist/store/AppStore.d.ts
CHANGED
|
@@ -4,7 +4,43 @@ import React from 'react';
|
|
|
4
4
|
type AppStoreProviderProps = PropsWithChildren<{
|
|
5
5
|
config?: WidgetConfig;
|
|
6
6
|
}>;
|
|
7
|
-
export declare const AppStoreContext: React.Context<import("zustand").UseBoundStore<import("zustand").StoreApi<import("./app").AppStoreState
|
|
7
|
+
export declare const AppStoreContext: React.Context<import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<import("./app").AppStoreState>, "persist"> & {
|
|
8
|
+
persist: {
|
|
9
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<import("./app").AppStoreState, {
|
|
10
|
+
theme: import("./slices/settings").ThemeMode;
|
|
11
|
+
language: "en" | "es" | "ja" | "fr";
|
|
12
|
+
affiliatePercent: number | null;
|
|
13
|
+
affiliateRef: string | null;
|
|
14
|
+
affiliateWallets: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
} | null;
|
|
17
|
+
slippage: number;
|
|
18
|
+
customSlippage: number | null;
|
|
19
|
+
infiniteApprove: boolean;
|
|
20
|
+
preferredBlockchains: string[];
|
|
21
|
+
disabledLiquiditySources: string[];
|
|
22
|
+
}>>) => void;
|
|
23
|
+
clearStorage: () => void;
|
|
24
|
+
rehydrate: () => void | Promise<void>;
|
|
25
|
+
hasHydrated: () => boolean;
|
|
26
|
+
onHydrate: (fn: (state: import("./app").AppStoreState) => void) => () => void;
|
|
27
|
+
onFinishHydration: (fn: (state: import("./app").AppStoreState) => void) => () => void;
|
|
28
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<import("./app").AppStoreState, {
|
|
29
|
+
theme: import("./slices/settings").ThemeMode;
|
|
30
|
+
language: "en" | "es" | "ja" | "fr";
|
|
31
|
+
affiliatePercent: number | null;
|
|
32
|
+
affiliateRef: string | null;
|
|
33
|
+
affiliateWallets: {
|
|
34
|
+
[key: string]: string;
|
|
35
|
+
} | null;
|
|
36
|
+
slippage: number;
|
|
37
|
+
customSlippage: number | null;
|
|
38
|
+
infiniteApprove: boolean;
|
|
39
|
+
preferredBlockchains: string[];
|
|
40
|
+
disabledLiquiditySources: string[];
|
|
41
|
+
}>>;
|
|
42
|
+
};
|
|
43
|
+
}> | null>;
|
|
8
44
|
export declare function useAppStore(): import("./app").AppStoreState;
|
|
9
45
|
export declare function AppStoreProvider(props: AppStoreProviderProps): React.JSX.Element;
|
|
10
46
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppStore.d.ts","sourceRoot":"","sources":["../../src/store/AppStore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,
|
|
1
|
+
{"version":3,"file":"AppStore.d.ts","sourceRoot":"","sources":["../../src/store/AppStore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAuD,MAAM,OAAO,CAAC;AAK5E,KAAK,qBAAqB,GAAG,iBAAiB,CAAC;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC;AAE1E,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAAuC,CAAC;AAEpE,wBAAgB,WAAW,kCAc1B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,qBAY5D"}
|
package/dist/store/app.d.ts
CHANGED
|
@@ -1,8 +1,45 @@
|
|
|
1
1
|
import type { ConfigSlice } from './slices/config';
|
|
2
2
|
import type { DataSlice } from './slices/data';
|
|
3
|
+
import type { SettingsSlice } from './slices/settings';
|
|
3
4
|
import type { WidgetConfig } from '../types';
|
|
4
5
|
import type { StateCreator } from 'zustand';
|
|
5
6
|
export type StateCreatorWithInitialData<T extends Partial<WidgetConfig>, R extends Record<string, unknown>, V extends Record<string, unknown>> = (initialData: T | undefined, ...rest: Parameters<StateCreator<R, [], [], V>>) => ReturnType<StateCreator<R, [], [], V>>;
|
|
6
|
-
export type AppStoreState = DataSlice & ConfigSlice;
|
|
7
|
-
export declare function createAppStore(initialData?: WidgetConfig): import("zustand").UseBoundStore<import("zustand").StoreApi<AppStoreState
|
|
7
|
+
export type AppStoreState = DataSlice & ConfigSlice & SettingsSlice;
|
|
8
|
+
export declare function createAppStore(initialData?: WidgetConfig): import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<AppStoreState>, "persist"> & {
|
|
9
|
+
persist: {
|
|
10
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<AppStoreState, {
|
|
11
|
+
theme: import("./slices/settings").ThemeMode;
|
|
12
|
+
language: "en" | "es" | "ja" | "fr";
|
|
13
|
+
affiliatePercent: number | null;
|
|
14
|
+
affiliateRef: string | null;
|
|
15
|
+
affiliateWallets: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
} | null;
|
|
18
|
+
slippage: number;
|
|
19
|
+
customSlippage: number | null;
|
|
20
|
+
infiniteApprove: boolean;
|
|
21
|
+
preferredBlockchains: string[];
|
|
22
|
+
disabledLiquiditySources: string[];
|
|
23
|
+
}>>) => void;
|
|
24
|
+
clearStorage: () => void;
|
|
25
|
+
rehydrate: () => void | Promise<void>;
|
|
26
|
+
hasHydrated: () => boolean;
|
|
27
|
+
onHydrate: (fn: (state: AppStoreState) => void) => () => void;
|
|
28
|
+
onFinishHydration: (fn: (state: AppStoreState) => void) => () => void;
|
|
29
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<AppStoreState, {
|
|
30
|
+
theme: import("./slices/settings").ThemeMode;
|
|
31
|
+
language: "en" | "es" | "ja" | "fr";
|
|
32
|
+
affiliatePercent: number | null;
|
|
33
|
+
affiliateRef: string | null;
|
|
34
|
+
affiliateWallets: {
|
|
35
|
+
[key: string]: string;
|
|
36
|
+
} | null;
|
|
37
|
+
slippage: number;
|
|
38
|
+
customSlippage: number | null;
|
|
39
|
+
infiniteApprove: boolean;
|
|
40
|
+
preferredBlockchains: string[];
|
|
41
|
+
disabledLiquiditySources: string[];
|
|
42
|
+
}>>;
|
|
43
|
+
};
|
|
44
|
+
}>;
|
|
8
45
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/store/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/store/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/store/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAS5C,MAAM,MAAM,2BAA2B,CACrC,CAAC,SAAS,OAAO,CAAC,YAAY,CAAC,EAC/B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC/B,CACF,WAAW,EAAE,CAAC,GAAG,SAAS,EAC1B,GAAG,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,KAC5C,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,aAAa,CAAC;AAEpE,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BxD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ConfigSlice } from './config';
|
|
2
|
+
import type { WidgetConfig } from '../../types';
|
|
3
|
+
import type { SwapperMeta } from 'rango-sdk';
|
|
4
|
+
import type { StateCreator } from 'zustand';
|
|
5
|
+
import { type Language } from '@rango-dev/ui';
|
|
6
|
+
export type ThemeMode = 'auto' | 'dark' | 'light';
|
|
7
|
+
export interface SettingsSlice {
|
|
8
|
+
theme: ThemeMode;
|
|
9
|
+
language: Language;
|
|
10
|
+
disabledLiquiditySources: string[];
|
|
11
|
+
/** Keeping a history of blockchains that user has selected (in Swap process) */
|
|
12
|
+
preferredBlockchains: string[];
|
|
13
|
+
slippage: number;
|
|
14
|
+
customSlippage: number | null;
|
|
15
|
+
infiniteApprove: boolean;
|
|
16
|
+
affiliateRef: string | null;
|
|
17
|
+
affiliatePercent: number | null;
|
|
18
|
+
affiliateWallets: {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
} | null;
|
|
21
|
+
setSlippage: (slippage: number) => void;
|
|
22
|
+
setCustomSlippage: (customSlippage: number | null) => void;
|
|
23
|
+
toggleInfiniteApprove: () => void;
|
|
24
|
+
toggleLiquiditySource: (name: string) => void;
|
|
25
|
+
setTheme: (theme: ThemeMode) => void;
|
|
26
|
+
setLanguage: (language: Language) => void;
|
|
27
|
+
toggleAllLiquiditySources: (swappers: SwapperMeta[], shouldReset?: boolean) => void;
|
|
28
|
+
setAffiliateRef: (affiliateRef: string | null) => void;
|
|
29
|
+
setAffiliatePercent: (affiliatePercent: number | null) => void;
|
|
30
|
+
setAffiliateWallets: (affiliateWallets: {
|
|
31
|
+
[key: string]: string;
|
|
32
|
+
} | null) => void;
|
|
33
|
+
addPreferredBlockchain: (blockchain: string) => void;
|
|
34
|
+
updateSettings: (config: WidgetConfig) => void;
|
|
35
|
+
}
|
|
36
|
+
export declare const createSettingsSlice: StateCreator<SettingsSlice & ConfigSlice, [
|
|
37
|
+
], [
|
|
38
|
+
], SettingsSlice>;
|
|
39
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../src/store/slices/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQ9C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,gFAAgF;IAChF,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAEnD,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,iBAAiB,EAAE,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3D,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC,WAAW,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC1C,yBAAyB,EAAE,CACzB,QAAQ,EAAE,WAAW,EAAE,EACvB,WAAW,CAAC,EAAE,OAAO,KAClB,IAAI,CAAC;IACV,eAAe,EAAE,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,mBAAmB,EAAE,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/D,mBAAmB,EAAE,CACnB,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,KAC/C,IAAI,CAAC;IACV,sBAAsB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAChD;AAED,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAC5C,aAAa,GAAG,WAAW,EAC3B;CAAE,EACF;CAAE,EACF,aAAa,CAoHb,CAAC"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -86,14 +86,27 @@ export type BlockchainAndTokenConfig = {
|
|
|
86
86
|
tokens?: Asset[];
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
|
-
* `
|
|
89
|
+
* `Features`
|
|
90
90
|
*
|
|
91
|
-
* @property {
|
|
92
|
-
|
|
91
|
+
* @property {'visible' | 'hidden'} [theme]
|
|
92
|
+
* - The visibility state for the theme feature. Optional property.
|
|
93
|
+
*
|
|
94
|
+
* @property {'visible' | 'hidden'} [language]
|
|
95
|
+
* - The visibility state for the language feature. Optional property.
|
|
96
|
+
*
|
|
97
|
+
* @property {'disabled' | 'enabled'} [experimentalRoute]
|
|
98
|
+
* - The enablement state for the experimental route feature. Optional property.
|
|
99
|
+
*
|
|
100
|
+
* @property {'visible' | 'hidden'} [connectWalletButton]
|
|
101
|
+
* - The visibility state for the connect wallet button feature. Optional property.
|
|
102
|
+
*
|
|
103
|
+
* @property {'visible' | 'hidden'} [notification]
|
|
104
|
+
* - The visibility state for the notification feature. Optional property.
|
|
105
|
+
*
|
|
106
|
+
* @property {'visible' | 'hidden'} [liquiditySource]
|
|
107
|
+
* - The visibility state for the liquiditySource feature. Optional property.
|
|
93
108
|
*/
|
|
94
|
-
type
|
|
95
|
-
routing?: boolean;
|
|
96
|
-
};
|
|
109
|
+
export type Features = Partial<Record<'theme' | 'language' | 'connectWalletButton' | 'notification' | 'liquiditySource', 'visible' | 'hidden'>> & Partial<Record<'experimentalRoute', 'disabled' | 'enabled'>>;
|
|
97
110
|
/**
|
|
98
111
|
* The type WidgetConfig defines the configuration options for a widget, including API key, affiliate
|
|
99
112
|
* reference, amount, blockchain and token configurations, liquidity sources, wallet types, language,
|
|
@@ -133,7 +146,14 @@ type ExperimentalFeatures = {
|
|
|
133
146
|
* you could use to pin tokens of your choice to the top of the token list.
|
|
134
147
|
* @property {boolean} enableNewLiquiditySources - The `enableNewLiquiditySources` property is a boolean value that when you
|
|
135
148
|
* set it to true, whenever a new liquidity source is added, it will be added to your list as well.
|
|
136
|
-
* @property {
|
|
149
|
+
* @property {Features} features - An optional object for configuring the visibility or enablement of various features.
|
|
150
|
+
* Keys include:
|
|
151
|
+
* - 'notification': Visibility state for the notification icon.
|
|
152
|
+
* - 'theme': Visibility state for the theme.
|
|
153
|
+
* - 'liquiditySource': Visibility state for liquidity source.
|
|
154
|
+
* - 'connectWalletButton': Visibility state for the wallet connect icon.
|
|
155
|
+
* - 'language': Visibility state for the language.
|
|
156
|
+
* - 'experimentalRoute': Enablement state for the experimental route.
|
|
137
157
|
*/
|
|
138
158
|
export type WidgetConfig = {
|
|
139
159
|
apiKey: string;
|
|
@@ -152,7 +172,6 @@ export type WidgetConfig = {
|
|
|
152
172
|
externalWallets?: boolean;
|
|
153
173
|
pinnedTokens?: Asset[];
|
|
154
174
|
enableNewLiquiditySources?: boolean;
|
|
155
|
-
|
|
175
|
+
features?: Features;
|
|
156
176
|
};
|
|
157
|
-
export {};
|
|
158
177
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC;AAClD,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,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,YAAY,CAAC;QAAC,IAAI,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CAClB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"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"}
|
package/dist/utils/settings.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Features } from '../types';
|
|
1
2
|
import type { SwapperMeta } from 'rango-sdk';
|
|
2
3
|
export type LiquiditySourceType = 'BRIDGE' | 'AGGREGATOR' | 'DEX';
|
|
3
4
|
export type UniqueSwappersGroupType = {
|
|
@@ -7,6 +8,8 @@ export type UniqueSwappersGroupType = {
|
|
|
7
8
|
type: LiquiditySourceType;
|
|
8
9
|
selected: boolean;
|
|
9
10
|
};
|
|
10
|
-
export declare function getUniqueSwappersGroups(swappers: SwapperMeta[]): UniqueSwappersGroupType[];
|
|
11
|
+
export declare function getUniqueSwappersGroups(swappers: SwapperMeta[], disabledLiquiditySources: string[]): UniqueSwappersGroupType[];
|
|
11
12
|
export declare function sortLiquiditySourcesByGroupTitle(a: SwapperMeta, b: SwapperMeta): 1 | -1 | 0;
|
|
13
|
+
export declare function isFeatureHidden(feature: keyof Features, features?: Features): boolean;
|
|
14
|
+
export declare function isFeatureEnabled(feature: keyof Features, features?: Features): boolean;
|
|
12
15
|
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/utils/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/utils/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,YAAY,GAAG,KAAK,CAAC;AAElE,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,WAAW,EAAE,EACvB,wBAAwB,EAAE,MAAM,EAAE,GACjC,uBAAuB,EAAE,CAqC3B;AAED,wBAAgB,gCAAgC,CAC9C,CAAC,EAAE,WAAW,EACd,CAAC,EAAE,WAAW,cAWf;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,QAAQ,EAAE,QAAQ,CAAC,EAAE,QAAQ,WAE3E;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,QAAQ,EAAE,QAAQ,CAAC,EAAE,QAAQ,WAE5E"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
} from '@rango-dev/ui';
|
|
12
12
|
import React from 'react';
|
|
13
13
|
|
|
14
|
+
import { useAppStore } from '../../store/AppStore';
|
|
14
15
|
import { getContainer } from '../../utils/common';
|
|
16
|
+
import { isFeatureHidden } from '../../utils/settings';
|
|
15
17
|
import { NotificationContent } from '../NotificationContent';
|
|
16
18
|
|
|
17
19
|
import { HeaderButton } from './HeaderButtons.styles';
|
|
@@ -26,6 +28,12 @@ export function HomeButtons(props: HomeButtonsPropTypes) {
|
|
|
26
28
|
onClickNotifications,
|
|
27
29
|
} = props;
|
|
28
30
|
|
|
31
|
+
const {
|
|
32
|
+
config: { features },
|
|
33
|
+
} = useAppStore();
|
|
34
|
+
|
|
35
|
+
const isNotificationsHidden = isFeatureHidden('notification', features);
|
|
36
|
+
|
|
29
37
|
return (
|
|
30
38
|
<>
|
|
31
39
|
<Tooltip
|
|
@@ -41,25 +49,27 @@ export function HomeButtons(props: HomeButtonsPropTypes) {
|
|
|
41
49
|
</HeaderButton>
|
|
42
50
|
</Tooltip>
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
side="top"
|
|
47
|
-
content={i18n.t('Notifications')}>
|
|
48
|
-
<Popover
|
|
49
|
-
align="center"
|
|
50
|
-
collisionBoundary={layoutRef}
|
|
51
|
-
collisionPadding={{ right: 20, left: 20 }}
|
|
52
|
+
{!isNotificationsHidden && (
|
|
53
|
+
<Tooltip
|
|
52
54
|
container={getContainer()}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
side="top"
|
|
56
|
+
content={i18n.t('Notifications')}>
|
|
57
|
+
<Popover
|
|
58
|
+
align="center"
|
|
59
|
+
collisionBoundary={layoutRef}
|
|
60
|
+
collisionPadding={{ right: 20, left: 20 }}
|
|
61
|
+
container={getContainer()}
|
|
62
|
+
content={<NotificationContent />}>
|
|
63
|
+
<HeaderButton
|
|
64
|
+
size="small"
|
|
65
|
+
variant="ghost"
|
|
66
|
+
onClick={onClickNotifications}>
|
|
67
|
+
<NotificationsIcon size={18} color="black" />
|
|
68
|
+
<UnreadNotificationsBadge />
|
|
69
|
+
</HeaderButton>
|
|
70
|
+
</Popover>
|
|
71
|
+
</Tooltip>
|
|
72
|
+
)}
|
|
63
73
|
<Tooltip
|
|
64
74
|
container={getContainer()}
|
|
65
75
|
side="top"
|
|
@@ -5,9 +5,11 @@ import { BottomLogo, Divider, Header } from '@rango-dev/ui';
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { useNavigateBack } from '../../hooks/useNavigateBack';
|
|
8
|
+
import { useAppStore } from '../../store/AppStore';
|
|
8
9
|
import { useUiStore } from '../../store/ui';
|
|
9
10
|
import { useWalletsStore } from '../../store/wallets';
|
|
10
11
|
import { getContainer } from '../../utils/common';
|
|
12
|
+
import { isFeatureHidden } from '../../utils/settings';
|
|
11
13
|
import { BackButton, CancelButton, WalletButton } from '../HeaderButtons';
|
|
12
14
|
|
|
13
15
|
import { Container, Content, Footer } from './Layout.styles';
|
|
@@ -22,6 +24,14 @@ function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
|
|
|
22
24
|
fixedHeight = true,
|
|
23
25
|
} = props;
|
|
24
26
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
27
|
+
const {
|
|
28
|
+
config: { features },
|
|
29
|
+
} = useAppStore();
|
|
30
|
+
|
|
31
|
+
const isConnectWalletHidden = isFeatureHidden(
|
|
32
|
+
'connectWalletButton',
|
|
33
|
+
features
|
|
34
|
+
);
|
|
25
35
|
|
|
26
36
|
const connectWalletsButtonDisabled =
|
|
27
37
|
useUiStore.use.connectWalletsButtonDisabled();
|
|
@@ -44,7 +54,7 @@ function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
|
|
|
44
54
|
suffix={
|
|
45
55
|
<>
|
|
46
56
|
{header.suffix}
|
|
47
|
-
{header.onWallet && (
|
|
57
|
+
{header.onWallet && !isConnectWalletHidden && (
|
|
48
58
|
<WalletButton
|
|
49
59
|
container={getContainer()}
|
|
50
60
|
onClick={onConnectWallet}
|
|
@@ -12,17 +12,14 @@ import React from 'react';
|
|
|
12
12
|
|
|
13
13
|
import { errorMessages } from '../../constants/errors';
|
|
14
14
|
import { useAppStore } from '../../store/AppStore';
|
|
15
|
-
import { useSettingsStore } from '../../store/settings';
|
|
16
15
|
|
|
17
16
|
import { makeInfo } from './NoResult.helpers';
|
|
18
17
|
import { Container, Footer, PrefixIcon } from './NoResult.styles';
|
|
19
18
|
|
|
20
19
|
export function NoResult(props: PropTypes) {
|
|
21
20
|
const { fetch, error } = props;
|
|
22
|
-
const disabledLiquiditySources =
|
|
23
|
-
|
|
24
|
-
const toggleAllLiquiditySources =
|
|
25
|
-
useSettingsStore.use.toggleAllLiquiditySources();
|
|
21
|
+
const disabledLiquiditySources = useAppStore().disabledLiquiditySources;
|
|
22
|
+
const toggleAllLiquiditySources = useAppStore().toggleAllLiquiditySources;
|
|
26
23
|
|
|
27
24
|
const swappers = useAppStore().swappers();
|
|
28
25
|
|
|
@@ -9,7 +9,7 @@ import React from 'react';
|
|
|
9
9
|
import { useNavigate } from 'react-router-dom';
|
|
10
10
|
|
|
11
11
|
import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
12
|
-
import {
|
|
12
|
+
import { useAppStore } from '../../store/AppStore';
|
|
13
13
|
import { QuoteWarningType } from '../../types';
|
|
14
14
|
import { getContainer } from '../../utils/common';
|
|
15
15
|
|
|
@@ -21,7 +21,7 @@ type PropsTypes = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export function SlippageWarningModal(props: PropsTypes) {
|
|
24
|
-
const { customSlippage, slippage } =
|
|
24
|
+
const { customSlippage, slippage } = useAppStore();
|
|
25
25
|
const { open, onClose, onConfirm, warning } = props;
|
|
26
26
|
const navigate = useNavigate();
|
|
27
27
|
const userSlippage = customSlippage ?? slippage;
|
|
@@ -14,17 +14,15 @@ import {
|
|
|
14
14
|
MIN_SLIPPGAE,
|
|
15
15
|
SLIPPAGES,
|
|
16
16
|
} from '../../constants/swapSettings';
|
|
17
|
-
import {
|
|
17
|
+
import { useAppStore } from '../../store/AppStore';
|
|
18
18
|
import { getContainer } from '../../utils/common';
|
|
19
19
|
|
|
20
20
|
import { BaseContainer, Head, SlippageChipsContainer } from './Slippage.styles';
|
|
21
21
|
import { SlippageTooltipContent } from './SlippageTooltipContent';
|
|
22
22
|
|
|
23
23
|
export function Slippage() {
|
|
24
|
-
const slippage =
|
|
25
|
-
|
|
26
|
-
const customSlippage = useSettingsStore.use.customSlippage();
|
|
27
|
-
const setCustomSlippage = useSettingsStore.use.setCustomSlippage();
|
|
24
|
+
const { slippage, setSlippage, customSlippage, setCustomSlippage } =
|
|
25
|
+
useAppStore();
|
|
28
26
|
|
|
29
27
|
return (
|
|
30
28
|
<BaseContainer>
|
|
@@ -11,7 +11,6 @@ import { useLanguage } from '../../hooks/useLanguage';
|
|
|
11
11
|
import { useTheme } from '../../hooks/useTheme';
|
|
12
12
|
import { useAppStore } from '../../store/AppStore';
|
|
13
13
|
import { useNotificationStore } from '../../store/notification';
|
|
14
|
-
import { useSettingsStore } from '../../store/settings';
|
|
15
14
|
import { WidgetContext } from '../Wallets';
|
|
16
15
|
|
|
17
16
|
import { MainContainer } from './App.styles';
|
|
@@ -19,7 +18,7 @@ import { MainContainer } from './App.styles';
|
|
|
19
18
|
export function Main() {
|
|
20
19
|
globalFont();
|
|
21
20
|
|
|
22
|
-
const {
|
|
21
|
+
const { config } = useAppStore();
|
|
23
22
|
const { activeTheme } = useTheme(config?.theme || {});
|
|
24
23
|
const { activeLanguage, changeLanguage } = useLanguage();
|
|
25
24
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
@@ -28,8 +27,6 @@ export function Main() {
|
|
|
28
27
|
const widgetContext = useContext(WidgetContext);
|
|
29
28
|
|
|
30
29
|
useEffect(() => {
|
|
31
|
-
void fetchMeta().catch();
|
|
32
|
-
void useSettingsStore.persist.rehydrate();
|
|
33
30
|
void useNotificationStore.persist.rehydrate();
|
|
34
31
|
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
35
32
|
}, []);
|
|
@@ -28,7 +28,7 @@ export const WidgetContext = createContext<WidgetContextInterface>({
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
function Main(props: PropsWithChildren<PropTypes>) {
|
|
31
|
-
const { updateConfig } = useAppStore();
|
|
31
|
+
const { updateConfig, updateSettings, fetch: fetchMeta } = useAppStore();
|
|
32
32
|
const blockchains = useAppStore().blockchains();
|
|
33
33
|
const tokens = useAppStore().tokens();
|
|
34
34
|
const walletOptions: ProvidersOptions = {
|
|
@@ -39,9 +39,14 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
39
39
|
const onConnectWalletHandler = useRef<OnConnectHandler>();
|
|
40
40
|
useSyncStoresWithConfig();
|
|
41
41
|
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
void fetchMeta().catch(console.log);
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
42
46
|
useEffect(() => {
|
|
43
47
|
if (props.config) {
|
|
44
48
|
updateConfig(props.config);
|
|
49
|
+
updateSettings(props.config);
|
|
45
50
|
}
|
|
46
51
|
}, [props.config]);
|
|
47
52
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { Meta } from '../../store/quote';
|
|
1
2
|
import type { Manager } from '@rango-dev/queue-manager-core';
|
|
2
3
|
import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
3
4
|
|
|
4
5
|
import {
|
|
6
|
+
cancelSwap,
|
|
5
7
|
getCurrentBlockchainOfOrNull,
|
|
6
8
|
getCurrentStep,
|
|
7
9
|
getRelatedWalletOrNull,
|
|
@@ -9,11 +11,17 @@ import {
|
|
|
9
11
|
|
|
10
12
|
import { getPendingSwaps } from '../../utils/queue';
|
|
11
13
|
|
|
14
|
+
interface WidgetHistoryActions {
|
|
15
|
+
retrySwap: (pendingSwap: PendingSwap, meta: Meta) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
export class WidgetHistory {
|
|
13
19
|
private manager: Manager | undefined;
|
|
20
|
+
private actions: WidgetHistoryActions;
|
|
14
21
|
|
|
15
|
-
constructor(manager: Manager | undefined) {
|
|
22
|
+
constructor(manager: Manager | undefined, actions: WidgetHistoryActions) {
|
|
16
23
|
this.manager = manager;
|
|
24
|
+
this.actions = actions;
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
public getAllSwaps() {
|
|
@@ -32,6 +40,17 @@ export class WidgetHistory {
|
|
|
32
40
|
return this.getCurrentStepInfo(swap).network;
|
|
33
41
|
}
|
|
34
42
|
|
|
43
|
+
public retry(swap: PendingSwap, meta: Meta) {
|
|
44
|
+
return this.actions.retrySwap(swap, meta);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public cancel(id: string) {
|
|
48
|
+
const queue = this.manager?.get(id);
|
|
49
|
+
if (queue) {
|
|
50
|
+
cancelSwap(queue);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
35
54
|
private getCurrentStepInfo(swap: PendingSwap) {
|
|
36
55
|
const currentStep = getCurrentStep(swap);
|
|
37
56
|
return {
|
|
@@ -3,6 +3,8 @@ import type { WidgetInfoContextInterface } from './WidgetInfo.types';
|
|
|
3
3
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
4
4
|
import React, { createContext, useContext } from 'react';
|
|
5
5
|
|
|
6
|
+
import { useAppStore } from '../../store/AppStore';
|
|
7
|
+
import { useQuoteStore } from '../../store/quote';
|
|
6
8
|
import { useWalletsStore } from '../../store/wallets';
|
|
7
9
|
import { calculateWalletUsdValue } from '../../utils/wallets';
|
|
8
10
|
|
|
@@ -14,11 +16,17 @@ export const WidgetInfoContext = createContext<
|
|
|
14
16
|
|
|
15
17
|
export function WidgetInfo(props: React.PropsWithChildren) {
|
|
16
18
|
const { manager } = useManager();
|
|
17
|
-
const
|
|
19
|
+
const retrySwap = useQuoteStore.use.retry();
|
|
20
|
+
const history = new WidgetHistory(manager, { retrySwap });
|
|
18
21
|
const details = useWalletsStore.use.connectedWallets();
|
|
19
22
|
const isLoading = useWalletsStore.use.loading();
|
|
20
23
|
const totalBalance = calculateWalletUsdValue(details);
|
|
21
24
|
const refetch = useWalletsStore.use.getWalletsDetails();
|
|
25
|
+
const blockchains = useAppStore().blockchains();
|
|
26
|
+
const tokens = useAppStore().tokens();
|
|
27
|
+
const swappers = useAppStore().swappers();
|
|
28
|
+
const loadingStatus = useAppStore().fetchStatus;
|
|
29
|
+
|
|
22
30
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
23
31
|
const value = {
|
|
24
32
|
history,
|
|
@@ -28,6 +36,12 @@ export function WidgetInfo(props: React.PropsWithChildren) {
|
|
|
28
36
|
totalBalance,
|
|
29
37
|
refetch,
|
|
30
38
|
},
|
|
39
|
+
meta: {
|
|
40
|
+
blockchains,
|
|
41
|
+
tokens,
|
|
42
|
+
swappers,
|
|
43
|
+
loadingStatus,
|
|
44
|
+
},
|
|
31
45
|
};
|
|
32
46
|
|
|
33
47
|
return (
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { WidgetHistory } from './WidgetInfo.helpers';
|
|
2
|
+
import type { FetchStatus } from '../../store/slices/data';
|
|
2
3
|
import type { ConnectedWallet } from '../../store/wallets';
|
|
3
4
|
import type { Wallet } from '../../types';
|
|
4
|
-
import type { Token } from 'rango-sdk';
|
|
5
|
+
import type { BlockchainMeta, SwapperMeta, Token } from 'rango-sdk';
|
|
5
6
|
|
|
6
7
|
export interface WidgetInfoContextInterface {
|
|
7
8
|
history: WidgetHistory;
|
|
@@ -11,4 +12,10 @@ export interface WidgetInfoContextInterface {
|
|
|
11
12
|
isLoading: boolean;
|
|
12
13
|
refetch: (accounts: Wallet[], tokens: Token[]) => void;
|
|
13
14
|
};
|
|
15
|
+
meta: {
|
|
16
|
+
blockchains: BlockchainMeta[];
|
|
17
|
+
tokens: Token[];
|
|
18
|
+
swappers: SwapperMeta[];
|
|
19
|
+
loadingStatus: FetchStatus;
|
|
20
|
+
};
|
|
14
21
|
}
|
|
@@ -7,8 +7,8 @@ import { useEffect } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { useAppStore } from '../../store/AppStore';
|
|
9
9
|
import { useQuoteStore } from '../../store/quote';
|
|
10
|
-
import { useSettingsStore } from '../../store/settings';
|
|
11
10
|
import { useWalletsStore } from '../../store/wallets';
|
|
11
|
+
import { isFeatureEnabled } from '../../utils/settings';
|
|
12
12
|
import { createQuoteRequestBody, getWalletsForNewSwap } from '../../utils/swap';
|
|
13
13
|
import { useFetchQuote } from '../useFetchQuote';
|
|
14
14
|
|
|
@@ -36,11 +36,11 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
36
36
|
affiliateRef,
|
|
37
37
|
affiliateWallets,
|
|
38
38
|
disabledLiquiditySources,
|
|
39
|
-
} =
|
|
39
|
+
} = useAppStore();
|
|
40
40
|
const { connectedWallets } = useWalletsStore();
|
|
41
41
|
const blockchains = useAppStore().blockchains();
|
|
42
42
|
const tokens = useAppStore().tokens();
|
|
43
|
-
const {
|
|
43
|
+
const { features } = useAppStore().config;
|
|
44
44
|
const { enableNewLiquiditySources } = useAppStore().config;
|
|
45
45
|
|
|
46
46
|
const userSlippage = customSlippage || slippage;
|
|
@@ -78,7 +78,7 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
78
78
|
initialQuote: initialQuote ?? undefined,
|
|
79
79
|
destination: customDestination,
|
|
80
80
|
});
|
|
81
|
-
if (
|
|
81
|
+
if (isFeatureEnabled('experimentalRoute', features)) {
|
|
82
82
|
requestBody.experimental = true;
|
|
83
83
|
}
|
|
84
84
|
let currentQuote: BestRouteResponse;
|