@rango-dev/widget-embedded 0.22.2-next.1 → 0.22.3

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +1 -3
  3. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
  4. package/dist/constants/searchParams.d.ts +0 -1
  5. package/dist/constants/searchParams.d.ts.map +1 -1
  6. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
  7. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  8. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
  9. package/dist/index.js +2 -2
  10. package/dist/index.js.map +3 -3
  11. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  12. package/dist/pages/SettingsPage.d.ts.map +1 -1
  13. package/dist/store/app.d.ts +1 -1
  14. package/dist/store/app.d.ts.map +1 -1
  15. package/dist/store/slices/config.d.ts +3 -13
  16. package/dist/store/slices/config.d.ts.map +1 -1
  17. package/dist/store/slices/data.d.ts.map +1 -1
  18. package/dist/utils/settings.d.ts +1 -1
  19. package/package.json +8 -7
  20. package/src/components/NoResult/NoResult.tsx +1 -1
  21. package/src/components/SettingsContainer/SettingsContainer.style.ts +0 -7
  22. package/src/constants/searchParams.ts +0 -5
  23. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +1 -1
  24. package/src/hooks/useSwapInput.ts +6 -8
  25. package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +4 -26
  26. package/src/pages/ConfirmSwapPage.tsx +1 -1
  27. package/src/pages/LiquiditySourcePage.tsx +4 -9
  28. package/src/pages/SettingsPage.tsx +2 -49
  29. package/src/store/app.ts +2 -2
  30. package/src/store/slices/config.ts +5 -56
  31. package/src/store/slices/data.ts +3 -12
@@ -1 +1 @@
1
- {"version":3,"file":"LiquiditySourcePage.d.ts","sourceRoot":"","sources":["../../src/pages/LiquiditySourcePage.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAcxC,UAAU,SAAS;IACjB,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;CACrC;AAED,wBAAgB,mBAAmB,CAAC,EAAE,UAAU,EAAE,EAAE,SAAS,qBA6H5D"}
1
+ {"version":3,"file":"LiquiditySourcePage.d.ts","sourceRoot":"","sources":["../../src/pages/LiquiditySourcePage.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAcxC,UAAU,SAAS;IACjB,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;CACrC;AAED,wBAAgB,mBAAmB,CAAC,EAAE,UAAU,EAAE,EAAE,SAAS,qBAwH5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SettingsPage.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,MAAM,OAAO,CAAC;AAoB1B,wBAAgB,YAAY,sBA+M3B"}
1
+ {"version":3,"file":"SettingsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SettingsPage.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,wBAAgB,YAAY,sBA4K3B"}
@@ -3,7 +3,7 @@ import type { DataSlice } from './slices/data';
3
3
  import type { SettingsSlice } from './slices/settings';
4
4
  import type { WidgetConfig } from '../types';
5
5
  import type { StateCreator } from 'zustand';
6
- export type StateCreatorWithInitialData<T extends Partial<WidgetConfig>, R extends Partial<AppStoreState>, V extends Partial<AppStoreState>> = (initialData: T | undefined, ...rest: Parameters<StateCreator<R, [], [], V>>) => ReturnType<StateCreator<R, [], [], V>>;
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>>;
7
7
  export type AppStoreState = DataSlice & ConfigSlice & SettingsSlice;
8
8
  export declare function createAppStore(initialData?: WidgetConfig): import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<AppStoreState>, "persist"> & {
9
9
  persist: {
@@ -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,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,OAAO,CAAC,aAAa,CAAC,EAChC,CAAC,SAAS,OAAO,CAAC,aAAa,CAAC,IAC9B,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"}
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"}
@@ -1,27 +1,17 @@
1
- import type { SettingsSlice } from './settings';
2
1
  import type { WidgetConfig } from '../../types';
3
2
  import type { StateCreatorWithInitialData } from '../app';
4
3
  export declare const DEFAULT_CONFIG: WidgetConfig;
5
4
  interface IframeConfigs {
6
5
  clientUrl?: string;
7
6
  }
8
- interface CampaignMode {
9
- liquiditySources?: string[];
10
- }
11
- export interface ConfigSlice {
7
+ export type ConfigSlice = {
12
8
  config: WidgetConfig;
13
- campaignMode: CampaignMode;
14
- isInCampaignMode: () => boolean;
15
- getLiquiditySources: () => string[];
16
- getDisabledLiquiditySources: () => string[];
17
- excludeLiquiditySources: () => boolean;
18
9
  updateConfig: (config: WidgetConfig) => void;
19
- updateCampaignMode: <K extends keyof CampaignMode>(name: K, value: CampaignMode[K]) => void;
20
10
  iframe: {
21
11
  clientUrl?: string;
22
12
  };
23
13
  updateIframe: <K extends keyof IframeConfigs>(name: K, value: IframeConfigs[K]) => void;
24
- }
25
- export declare const createConfigSlice: StateCreatorWithInitialData<WidgetConfig, ConfigSlice & SettingsSlice, ConfigSlice>;
14
+ };
15
+ export declare const createConfigSlice: StateCreatorWithInitialData<WidgetConfig, ConfigSlice, ConfigSlice>;
26
16
  export {};
27
17
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/store/slices/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAE1D,eAAO,MAAM,cAAc,EAAE,YAM5B,CAAC;AAEF,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,YAAY;IACpB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAUD,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,YAAY,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,gBAAgB,EAAE,MAAM,OAAO,CAAC;IAChC,mBAAmB,EAAE,MAAM,MAAM,EAAE,CAAC;IACpC,2BAA2B,EAAE,MAAM,MAAM,EAAE,CAAC;IAC5C,uBAAuB,EAAE,MAAM,OAAO,CAAC;IACvC,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7C,kBAAkB,EAAE,CAAC,CAAC,SAAS,MAAM,YAAY,EAC/C,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,KACnB,IAAI,CAAC;IAEV,MAAM,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC,SAAS,MAAM,aAAa,EAC1C,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KACpB,IAAI,CAAC;CACX;AAED,eAAO,MAAM,iBAAiB,EAAE,2BAA2B,CACzD,YAAY,EACZ,WAAW,GAAG,aAAa,EAC3B,WAAW,CA+DZ,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/store/slices/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAE1D,eAAO,MAAM,cAAc,EAAE,YAM5B,CAAC;AAEF,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,MAAM,MAAM,WAAW,GAAG;IAExB,MAAM,EAAE,YAAY,CAAC;IACrB,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAG7C,MAAM,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC,SAAS,MAAM,aAAa,EAC1C,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KACpB,IAAI,CAAC;CACX,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,2BAA2B,CACzD,YAAY,EACZ,WAAW,EACX,WAAW,CA6BZ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/store/slices/data.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQ5C,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;CACjC,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;IAE/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC3D,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,cAAc,EAAE,KAAK,EAAE,CAAC;IACxB,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,cAAc,EAAE,CAAC;IAC/D,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;IAC5C,QAAQ,EAAE,MAAM,WAAW,EAAE,CAAC;IAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,KAAK,OAAO,CAAC;IAEzE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,eAAe,EAAE,YAAY,CACxC,SAAS,GAAG,WAAW,EACvB;CAAE,EACF;CAAE,EACF,SAAS,CA+MT,CAAC"}
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/store/slices/data.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQ5C,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;CACjC,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;IAE/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC3D,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,cAAc,EAAE,KAAK,EAAE,CAAC;IACxB,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,cAAc,EAAE,CAAC;IAC/D,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;IAC5C,QAAQ,EAAE,MAAM,WAAW,EAAE,CAAC;IAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,KAAK,OAAO,CAAC;IAEzE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,eAAe,EAAE,YAAY,CACxC,SAAS,GAAG,WAAW,EACvB;CAAE,EACF;CAAE,EACF,SAAS,CAsMT,CAAC"}
@@ -9,7 +9,7 @@ export type UniqueSwappersGroupType = {
9
9
  selected: boolean;
10
10
  };
11
11
  export declare function getUniqueSwappersGroups(swappers: SwapperMeta[], disabledLiquiditySources: string[]): UniqueSwappersGroupType[];
12
- export declare function sortLiquiditySourcesByGroupTitle(a: SwapperMeta, b: SwapperMeta): 1 | 0 | -1;
12
+ export declare function sortLiquiditySourcesByGroupTitle(a: SwapperMeta, b: SwapperMeta): 0 | 1 | -1;
13
13
  export declare function isFeatureHidden(feature: keyof Features, features?: Features): boolean;
14
14
  export declare function isFeatureEnabled(feature: keyof Features, features?: Features): boolean;
15
15
  //# sourceMappingURL=settings.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.22.2-next.1",
3
+ "version": "0.22.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -21,16 +21,17 @@
21
21
  "dependencies": {
22
22
  "@lingui/core": "4.2.1",
23
23
  "@lingui/react": "4.2.1",
24
- "@rango-dev/provider-all": "^0.26.0",
24
+ "@rango-dev/provider-all": "^0.27.0",
25
25
  "@rango-dev/queue-manager-core": "^0.25.0",
26
- "@rango-dev/queue-manager-rango-preset": "^0.26.0",
26
+ "@rango-dev/queue-manager-rango-preset": "^0.27.0",
27
27
  "@rango-dev/queue-manager-react": "^0.25.0",
28
- "@rango-dev/ui": "^0.28.1-next.1",
29
- "@rango-dev/wallets-react": "^0.12.0",
30
- "@rango-dev/wallets-shared": "^0.26.0",
28
+ "@rango-dev/ui": "^0.28.1",
29
+ "@rango-dev/wallets-react": "^0.13.0",
30
+ "@rango-dev/wallets-shared": "^0.27.0",
31
31
  "bignumber.js": "^9.1.1",
32
32
  "copy-to-clipboard": "^3.3.3",
33
33
  "dayjs": "^1.11.7",
34
+ "ethers": "^5.7.2",
34
35
  "immer": "^9.0.19",
35
36
  "mitt": "^3.0.0",
36
37
  "rango-sdk": "^0.1.44",
@@ -47,4 +48,4 @@
47
48
  "publishConfig": {
48
49
  "access": "public"
49
50
  }
50
- }
51
+ }
@@ -18,7 +18,7 @@ import { Container, Footer, PrefixIcon } from './NoResult.styles';
18
18
 
19
19
  export function NoResult(props: PropTypes) {
20
20
  const { fetch, error } = props;
21
- const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
21
+ const disabledLiquiditySources = useAppStore().disabledLiquiditySources;
22
22
  const toggleAllLiquiditySources = useAppStore().toggleAllLiquiditySources;
23
23
 
24
24
  const swappers = useAppStore().swappers();
@@ -6,13 +6,6 @@ export const LiquiditySourceList = styled('ul', {
6
6
  listStyle: 'none',
7
7
  height: '100%',
8
8
  overflowY: 'auto',
9
- variants: {
10
- disabled: {
11
- true: {
12
- pointerEvents: 'none',
13
- },
14
- },
15
- },
16
9
  });
17
10
 
18
11
  export const LiquiditySourceSuffix = styled('div', {
@@ -5,11 +5,6 @@ export enum SearchParams {
5
5
  TO_TOKEN = 'toToken',
6
6
  FROM_AMOUNT = 'fromAmount',
7
7
  AUTO_CONNECT = 'autoConnect',
8
- /*
9
- * dApps can transmit liquidity sources as a search parameter,
10
- * and these take precedence over widget configurations
11
- */
12
- LIQUIDITY_SOURCES = 'liquiditySources',
13
8
  // iframe environments
14
9
  CLIENT_URL = 'clientUrl',
15
10
  }
@@ -35,8 +35,8 @@ export function useConfirmSwap(): ConfirmSwap {
35
35
  affiliatePercent,
36
36
  affiliateRef,
37
37
  affiliateWallets,
38
+ disabledLiquiditySources,
38
39
  } = useAppStore();
39
- const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
40
40
  const { connectedWallets } = useWalletsStore();
41
41
  const blockchains = useAppStore().blockchains();
42
42
  const tokens = useAppStore().tokens();
@@ -40,7 +40,8 @@ type UseSwapInput = {
40
40
  */
41
41
  export function useSwapInput(): UseSwapInput {
42
42
  const { fetch: fetchQuote, cancelFetch } = useFetchQuote();
43
- const { enableNewLiquiditySources, features } = useAppStore().config;
43
+ const { liquiditySources, enableNewLiquiditySources, features } =
44
+ useAppStore().config;
44
45
  const tokens = useAppStore().tokens();
45
46
  const {
46
47
  fromToken,
@@ -57,12 +58,9 @@ export function useSwapInput(): UseSwapInput {
57
58
  affiliatePercent,
58
59
  affiliateRef,
59
60
  affiliateWallets,
61
+ disabledLiquiditySources,
60
62
  fetchStatus,
61
63
  } = useAppStore();
62
- const liquiditySources = useAppStore().getLiquiditySources();
63
- const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
64
- const excludeLiquiditySources = useAppStore().excludeLiquiditySources();
65
-
66
64
  const [loading, setLoading] = useState(true);
67
65
  const [error, setError] = useState<QuoteError | null>(null);
68
66
  const [warning, setWarning] = useState<QuoteWarning | null>(null);
@@ -101,7 +99,7 @@ export function useSwapInput(): UseSwapInput {
101
99
  fromToken,
102
100
  toToken,
103
101
  inputAmount,
104
- liquiditySources: liquiditySources,
102
+ liquiditySources,
105
103
  excludeLiquiditySources,
106
104
  disabledLiquiditySources,
107
105
  slippage,
@@ -172,7 +170,7 @@ export function useSwapInput(): UseSwapInput {
172
170
  fromToken,
173
171
  toToken,
174
172
  liquiditySources,
175
- excludeLiquiditySources,
173
+ excludeLiquiditySources: enableNewLiquiditySources,
176
174
  disabledLiquiditySources,
177
175
  slippage: userSlippage,
178
176
  affiliateRef,
@@ -206,7 +204,7 @@ export function useSwapInput(): UseSwapInput {
206
204
  fromToken,
207
205
  toToken,
208
206
  liquiditySources,
209
- excludeLiquiditySources,
207
+ excludeLiquiditySources: enableNewLiquiditySources,
210
208
  disabledLiquiditySources,
211
209
  slippage: userSlippage,
212
210
  affiliateRef,
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef } from 'react';
1
+ import { useEffect } from 'react';
2
2
  import {
3
3
  useInRouterContext,
4
4
  useLocation,
@@ -33,9 +33,7 @@ export function useSyncUrlAndStore() {
33
33
  const blockchains = useAppStore().blockchains();
34
34
  const tokens = useAppStore().tokens();
35
35
  const isInRouterContext = useInRouterContext();
36
- const { updateIframe, updateCampaignMode } = useAppStore();
37
- const campaignMode = useAppStore().isInCampaignMode();
38
- const liquiditySourcesParamsRef = useRef<string>();
36
+ const { updateIframe } = useAppStore();
39
37
 
40
38
  const getUrlSearchParams = () => {
41
39
  const fromAmount = searchParams.get(SearchParams.FROM_AMOUNT);
@@ -45,7 +43,6 @@ export function useSyncUrlAndStore() {
45
43
  const toToken = searchParams.get(SearchParams.TO_TOKEN);
46
44
  const autoConnect = searchParams.get(SearchParams.AUTO_CONNECT);
47
45
  const clientUrl = searchParams.get(SearchParams.CLIENT_URL);
48
- const liquiditySources = searchParams.get(SearchParams.LIQUIDITY_SOURCES);
49
46
 
50
47
  return {
51
48
  fromAmount,
@@ -55,7 +52,6 @@ export function useSyncUrlAndStore() {
55
52
  toToken,
56
53
  autoConnect,
57
54
  clientUrl,
58
- liquiditySources,
59
55
  };
60
56
  };
61
57
 
@@ -81,9 +77,6 @@ export function useSyncUrlAndStore() {
81
77
  [SearchParams.FROM_AMOUNT]: inputAmount,
82
78
  [SearchParams.AUTO_CONNECT]: autoConnect ?? undefined,
83
79
  [SearchParams.CLIENT_URL]: clientUrl ?? undefined,
84
- [SearchParams.LIQUIDITY_SOURCES]: campaignMode
85
- ? liquiditySourcesParamsRef.current
86
- : undefined,
87
80
  });
88
81
  }
89
82
  }, [
@@ -93,24 +86,16 @@ export function useSyncUrlAndStore() {
93
86
  fromToken,
94
87
  toBlockchain,
95
88
  toToken,
96
- campaignMode,
97
89
  ]);
98
90
 
99
91
  useEffect(() => {
100
92
  if (!isInRouterContext) {
101
93
  return;
102
94
  }
103
-
104
95
  const searchParams = getUrlSearchParams();
105
-
106
- if (!liquiditySourcesParamsRef.current && searchParams.liquiditySources) {
107
- liquiditySourcesParamsRef.current = searchParams.liquiditySources;
108
- }
109
-
110
96
  if (searchParams.fromAmount) {
111
97
  setInputAmount(searchParams.fromAmount);
112
98
  }
113
-
114
99
  if (fetchMetaStatus === 'success') {
115
100
  const fromBlockchain = blockchains.find(
116
101
  (blockchain) => blockchain.name === searchParams.fromBlockchain
@@ -128,7 +113,6 @@ export function useSyncUrlAndStore() {
128
113
  searchParams.toToken,
129
114
  toBlockchain ?? null
130
115
  );
131
-
132
116
  if (!!fromBlockchain) {
133
117
  setFromBlockchain(fromBlockchain);
134
118
  if (!!fromToken) {
@@ -141,7 +125,6 @@ export function useSyncUrlAndStore() {
141
125
  });
142
126
  }
143
127
  }
144
-
145
128
  if (!!toBlockchain) {
146
129
  setToBlockchain(toBlockchain);
147
130
  if (!!toToken) {
@@ -154,14 +137,9 @@ export function useSyncUrlAndStore() {
154
137
  }
155
138
  }, [fetchMetaStatus]);
156
139
 
140
+ // We run this only once, because if the app is embedded into an iframe, the data in url for iframe will not change.
157
141
  useEffect(() => {
158
- const { clientUrl, liquiditySources } = getUrlSearchParams();
159
- // We run this only once, because if the app is embedded into an iframe, the data in url for iframe will not change.
142
+ const { clientUrl } = getUrlSearchParams();
160
143
  updateIframe('clientUrl', clientUrl || undefined);
161
-
162
- updateCampaignMode(
163
- 'liquiditySources',
164
- liquiditySources?.split(',') ?? undefined
165
- );
166
144
  }, []);
167
145
  }
@@ -88,7 +88,7 @@ export function ConfirmSwapPage() {
88
88
  const showWalletsOnInit = !quoteWalletsConfirmed;
89
89
  const [showWallets, setShowWallets] = useState(false);
90
90
  const { isActiveTab } = useUiStore();
91
- const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
91
+ const disabledLiquiditySources = useAppStore().disabledLiquiditySources;
92
92
  const prevDisabledLiquiditySources = useRef(disabledLiquiditySources);
93
93
  const { manager } = useManager();
94
94
  const {
@@ -33,10 +33,9 @@ interface PropTypes {
33
33
  export function LiquiditySourcePage({ sourceType }: PropTypes) {
34
34
  const fetchStatus = useAppStore().fetchStatus;
35
35
  const swappers = useAppStore().swappers();
36
- const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
36
+ const disabledLiquiditySources = useAppStore().disabledLiquiditySources;
37
37
  const [searchedFor, setSearchedFor] = useState<string>('');
38
38
  const toggleLiquiditySource = useAppStore().toggleLiquiditySource;
39
- const campaignMode = useAppStore().isInCampaignMode();
40
39
  const supportedUniqueSwappersGroups: Array<UniqueSwappersGroupType> =
41
40
  getUniqueSwappersGroups(swappers, disabledLiquiditySources);
42
41
 
@@ -74,12 +73,8 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
74
73
  const { selected, groupTitle, logo } = sourceItem;
75
74
  return {
76
75
  start: <Image src={logo} size={22} type="circular" />,
77
- onClick: () => {
78
- if (!campaignMode) {
79
- toggleLiquiditySource(groupTitle);
80
- }
81
- },
82
- end: <Checkbox checked={selected} disabled={campaignMode} />,
76
+ onClick: () => toggleLiquiditySource(groupTitle),
77
+ end: <Checkbox checked={selected} />,
83
78
  title: (
84
79
  <Typography variant="title" size="xmedium">
85
80
  {i18n.t(groupTitle)}
@@ -136,7 +131,7 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
136
131
  </NotFoundContainer>
137
132
  ) : (
138
133
  fetchStatus === 'success' && (
139
- <LiquiditySourceList disabled={campaignMode}>
134
+ <LiquiditySourceList>
140
135
  {filteredList.map((sourceItem) => {
141
136
  return (
142
137
  <React.Fragment key={sourceItem.id}>
@@ -1,50 +1,35 @@
1
1
  import { i18n } from '@lingui/core';
2
2
  import {
3
- Alert,
4
- Button,
5
3
  ChevronRightIcon,
6
4
  Divider,
7
5
  InfoIcon,
8
6
  List,
9
7
  ListItemButton,
10
8
  Skeleton,
11
- styled,
12
9
  Switch,
13
10
  Tooltip,
14
11
  Typography,
15
12
  } from '@rango-dev/ui';
16
13
  import React from 'react';
17
- import {
18
- useInRouterContext,
19
- useNavigate,
20
- useSearchParams,
21
- } from 'react-router-dom';
14
+ import { useNavigate } from 'react-router-dom';
22
15
 
23
16
  import { Layout, PageContainer } from '../components/Layout';
24
17
  import { Slippage } from '../components/Slippage';
25
18
  import { SlippageTooltipContainer as TooltipContainer } from '../components/Slippage/Slippage.styles';
26
19
  import { navigationRoutes } from '../constants/navigationRoutes';
27
- import { SearchParams } from '../constants/searchParams';
28
20
  import { useAppStore } from '../store/AppStore';
29
21
  import { getContainer } from '../utils/common';
30
22
  import { getUniqueSwappersGroups, isFeatureHidden } from '../utils/settings';
31
23
 
32
- const ResetAction = styled('div', {
33
- paddingLeft: '$8',
34
- });
35
-
36
24
  export function SettingsPage() {
37
25
  const navigate = useNavigate();
38
26
  const { theme } = useAppStore().config;
39
27
  const fetchStatus = useAppStore().fetchStatus;
40
28
  const swappers = useAppStore().swappers();
41
- const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
29
+ const disabledLiquiditySources = useAppStore().disabledLiquiditySources;
42
30
  const {
43
31
  config: { features },
44
- isInCampaignMode,
45
- updateCampaignMode,
46
32
  } = useAppStore();
47
- const campaignMode = isInCampaignMode();
48
33
  const isThemeHidden = isFeatureHidden('theme', features);
49
34
 
50
35
  const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
@@ -192,44 +177,12 @@ export function SettingsPage() {
192
177
  }
193
178
  settingItems.push(infiniteApprovalItem);
194
179
 
195
- const [, setSearchParams] = useSearchParams();
196
- const isRouterInContext = useInRouterContext();
197
-
198
- const onClick = () => {
199
- if (isRouterInContext && campaignMode) {
200
- setSearchParams(
201
- (prev) => {
202
- prev.delete(SearchParams.LIQUIDITY_SOURCES);
203
- return prev;
204
- },
205
- { replace: true }
206
- );
207
- updateCampaignMode('liquiditySources', undefined);
208
- }
209
- };
210
-
211
180
  return (
212
181
  <Layout
213
182
  header={{
214
183
  title: i18n.t('Settings'),
215
184
  }}>
216
185
  <PageContainer>
217
- {campaignMode && (
218
- <Alert
219
- type="info"
220
- variant="alarm"
221
- title={i18n.t(
222
- "Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"
223
- )}
224
- action={
225
- <ResetAction>
226
- <Button type="secondary" size="small" onClick={onClick}>
227
- Reset
228
- </Button>
229
- </ResetAction>
230
- }
231
- />
232
- )}
233
186
  <Slippage />
234
187
  <List
235
188
  type={
package/src/store/app.ts CHANGED
@@ -13,8 +13,8 @@ import { createSettingsSlice } from './slices/settings';
13
13
 
14
14
  export type StateCreatorWithInitialData<
15
15
  T extends Partial<WidgetConfig>,
16
- R extends Partial<AppStoreState>,
17
- V extends Partial<AppStoreState>
16
+ R extends Record<string, unknown>,
17
+ V extends Record<string, unknown>
18
18
  > = (
19
19
  initialData: T | undefined,
20
20
  ...rest: Parameters<StateCreator<R, [], [], V>>
@@ -1,4 +1,3 @@
1
- import type { SettingsSlice } from './settings';
2
1
  import type { WidgetConfig } from '../../types';
3
2
  import type { StateCreatorWithInitialData } from '../app';
4
3
 
@@ -14,70 +13,31 @@ interface IframeConfigs {
14
13
  clientUrl?: string;
15
14
  }
16
15
 
17
- interface CampaignMode {
18
- liquiditySources?: string[];
19
- }
20
-
21
16
  const DEFAULT_IFRAME_CONFIGS: IframeConfigs = {
22
17
  clientUrl: undefined,
23
18
  };
24
19
 
25
- const DEFAULT_CAMPAIGN_MODE: CampaignMode = {
26
- liquiditySources: undefined,
27
- };
28
-
29
- export interface ConfigSlice {
20
+ export type ConfigSlice = {
30
21
  // What user can set directly.
31
22
  config: WidgetConfig;
32
- campaignMode: CampaignMode;
33
- isInCampaignMode: () => boolean;
34
- getLiquiditySources: () => string[];
35
- getDisabledLiquiditySources: () => string[];
36
- excludeLiquiditySources: () => boolean;
37
23
  updateConfig: (config: WidgetConfig) => void;
38
- updateCampaignMode: <K extends keyof CampaignMode>(
39
- name: K,
40
- value: CampaignMode[K]
41
- ) => void;
42
- // What we are setting based on environments.
24
+
25
+ // What we are setting based on enviroments.
43
26
  iframe: { clientUrl?: string };
44
27
  updateIframe: <K extends keyof IframeConfigs>(
45
28
  name: K,
46
29
  value: IframeConfigs[K]
47
30
  ) => void;
48
- }
31
+ };
49
32
 
50
33
  export const createConfigSlice: StateCreatorWithInitialData<
51
34
  WidgetConfig,
52
- ConfigSlice & SettingsSlice,
35
+ ConfigSlice,
53
36
  ConfigSlice
54
37
  > = (initialData, set, get) => {
55
38
  return {
56
39
  config: { ...DEFAULT_CONFIG, ...initialData },
57
40
  iframe: DEFAULT_IFRAME_CONFIGS,
58
- campaignMode: DEFAULT_CAMPAIGN_MODE,
59
- getLiquiditySources: () => {
60
- const { config, campaignMode } = get();
61
- return campaignMode.liquiditySources?.length
62
- ? campaignMode.liquiditySources
63
- : config.liquiditySources ?? [];
64
- },
65
- getDisabledLiquiditySources: () => {
66
- const { disabledLiquiditySources, campaignMode } = get();
67
- return campaignMode.liquiditySources?.length
68
- ? []
69
- : disabledLiquiditySources;
70
- },
71
- excludeLiquiditySources: () => {
72
- const { config, campaignMode } = get();
73
- return campaignMode.liquiditySources?.length
74
- ? false
75
- : !!config.enableNewLiquiditySources;
76
- },
77
- isInCampaignMode: () => {
78
- const { campaignMode } = get();
79
- return !!campaignMode.liquiditySources?.length;
80
- },
81
41
 
82
42
  // Actions
83
43
  updateConfig: (nextConfig: WidgetConfig) => {
@@ -91,17 +51,6 @@ export const createConfigSlice: StateCreatorWithInitialData<
91
51
  });
92
52
  },
93
53
 
94
- updateCampaignMode: (name, value) => {
95
- const currentCampaignMode = get().campaignMode;
96
-
97
- set({
98
- campaignMode: {
99
- ...currentCampaignMode,
100
- [name]: value,
101
- },
102
- });
103
- },
104
-
105
54
  updateIframe: (name, value) => {
106
55
  const currentIframeConfig = get().iframe;
107
56
 
@@ -168,18 +168,9 @@ export const createDataSlice: StateCreator<
168
168
  return pinned;
169
169
  },
170
170
  swappers: () => {
171
- const { config, campaignMode } = get();
172
-
173
- const campaignModeLiquiditySource = campaignMode.liquiditySources?.length
174
- ? campaignMode.liquiditySources
175
- : null;
176
-
177
- const liquiditySources =
178
- campaignModeLiquiditySource ?? config.liquiditySources;
179
-
180
- const enableNewLiquiditySources = campaignModeLiquiditySource
181
- ? false
182
- : config.enableNewLiquiditySources;
171
+ const {
172
+ config: { enableNewLiquiditySources, liquiditySources },
173
+ } = get();
183
174
 
184
175
  /*
185
176
  * If the enableNewLiquiditySources flag is set to true, we return all swappers that are not included in the config.