@rango-dev/widget-embedded 0.8.1-next.12 → 0.8.1-next.13

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.
@@ -3,7 +3,8 @@ import { WidgetConfig } from '../types';
3
3
  interface PropTypes {
4
4
  supportedWallets: WidgetConfig['wallets'];
5
5
  multiWallets: boolean;
6
+ config?: WidgetConfig;
6
7
  }
7
- export declare function WalletsPage({ supportedWallets, multiWallets }: PropTypes): JSX.Element;
8
+ export declare function WalletsPage({ supportedWallets, multiWallets, config, }: PropTypes): JSX.Element;
8
9
  export {};
9
10
  //# sourceMappingURL=WalletsPage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WalletsPage.d.ts","sourceRoot":"","sources":["../../src/pages/WalletsPage.tsx"],"names":[],"mappings":";AAwBA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,UAAU,SAAS;IACjB,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,YAAY,EAAE,OAAO,CAAC;CACvB;AAyBD,wBAAgB,WAAW,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,EAAE,SAAS,eAyFxE"}
1
+ {"version":3,"file":"WalletsPage.d.ts","sourceRoot":"","sources":["../../src/pages/WalletsPage.tsx"],"names":[],"mappings":";AAwBA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,UAAU,SAAS;IACjB,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAyBD,wBAAgB,WAAW,CAAC,EAC1B,gBAAgB,EAChB,YAAY,EACZ,MAAM,GACP,EAAE,SAAS,eA2FX"}
@@ -125,6 +125,7 @@ export type BlockchainAndTokenConfig = {
125
125
  */
126
126
  export type WidgetConfig = {
127
127
  apiKey: string;
128
+ walletConnectProjectId?: string;
128
129
  affiliate?: WidgeAffiliate;
129
130
  amount?: number;
130
131
  from?: BlockchainAndTokenConfig;
@@ -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;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;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,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,YAAY,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE,CAAC;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;I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EAAE,MAAM,CAAC;IACf,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,wBAAwB,CAAC;IAChC,EAAE,CAAC,EAAE,wBAAwB,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,UAAU,GAAG,iBAAiB,CAAC,EAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC"}
@@ -1,11 +1,14 @@
1
1
  import { ProviderInterface } from '@rango-dev/wallets-core';
2
2
  import { WidgetConfig } from '../types';
3
+ export interface ProvidersOptions {
4
+ walletConnectProjectId?: WidgetConfig['walletConnectProjectId'];
5
+ }
3
6
  /**
4
7
  *
5
8
  * Generate a list of providers by passing a provider name (e.g. metamask) or a custom provider which implemented ProviderInterface.
6
9
  * @returns ProviderInterface[] a list of ProviderInterface
7
10
  *
8
11
  */
9
- export declare function matchAndGenerateProviders(providers: WidgetConfig['wallets']): ProviderInterface[];
10
- export declare function configWalletsToWalletName(config: WidgetConfig['wallets']): string[];
12
+ export declare function matchAndGenerateProviders(providers: WidgetConfig['wallets'], options?: ProvidersOptions): ProviderInterface[];
13
+ export declare function configWalletsToWalletName(config: WidgetConfig['wallets'], options?: ProvidersOptions): string[];
11
14
  //# sourceMappingURL=providers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,GACjC,iBAAiB,EAAE,CAkCrB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,GAC9B,MAAM,EAAE,CAMV"}
1
+ {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB,CAAC,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAC;CACjE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,EAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,iBAAiB,EAAE,CAkCrB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,EAC/B,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,EAAE,CAMV"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.8.1-next.12",
3
+ "version": "0.8.1-next.13",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,11 +19,11 @@
19
19
  "dependencies": {
20
20
  "@lingui/core": "4.2.1",
21
21
  "@lingui/react": "4.2.1",
22
- "@rango-dev/provider-all": "^0.8.1-next.6",
22
+ "@rango-dev/provider-all": "^0.8.1-next.7",
23
23
  "@rango-dev/queue-manager-core": "^0.8.1-next.6",
24
- "@rango-dev/queue-manager-rango-preset": "^0.8.1-next.12",
24
+ "@rango-dev/queue-manager-rango-preset": "^0.8.1-next.13",
25
25
  "@rango-dev/queue-manager-react": "^0.8.1-next.8",
26
- "@rango-dev/ui": "^0.8.1-next.13",
26
+ "@rango-dev/ui": "^0.8.1-next.14",
27
27
  "@rango-dev/wallets-core": "^0.8.1-next.6",
28
28
  "@rango-dev/wallets-shared": "^0.8.1-next.7",
29
29
  "bignumber.js": "^9.1.1",
package/src/Wallets.tsx CHANGED
@@ -12,6 +12,7 @@ import { isEvmBlockchain } from 'rango-sdk';
12
12
  import { useWalletProviders } from './hooks/useWalletProviders';
13
13
  import { WidgetConfig } from './types';
14
14
  import { createContext, useRef } from 'react';
15
+ import { ProvidersOptions } from './utils/providers';
15
16
 
16
17
  type OnConnectHandler = (key: string) => void;
17
18
  interface WidgetContextInterface {
@@ -27,11 +28,12 @@ export const WidgetContext = createContext<WidgetContextInterface>({
27
28
  export function WidgetWallets(
28
29
  props: PropsWithChildren<{
29
30
  providers: WidgetConfig['wallets'];
31
+ options?: ProvidersOptions;
30
32
  onUpdateState?: EventHandler;
31
33
  }>
32
34
  ) {
33
35
  const { blockchains } = useMetaStore.use.meta();
34
- const { providers } = useWalletProviders(props.providers);
36
+ const { providers } = useWalletProviders(props.providers, props?.options);
35
37
  const disconnectWallet = useWalletsStore.use.disconnectWallet();
36
38
  const connectWallet = useWalletsStore.use.connectWallet();
37
39
  const onConnectWalletHandler = useRef<OnConnectHandler>();
package/src/Widget.tsx CHANGED
@@ -77,7 +77,11 @@ export function Main(props: PropsWithChildren<WidgetProps>) {
77
77
  export function Widget(props: PropsWithChildren<WidgetProps>) {
78
78
  if (!props.config?.externalWallets) {
79
79
  return (
80
- <WidgetWallets providers={props.config?.wallets}>
80
+ <WidgetWallets
81
+ providers={props.config?.wallets}
82
+ options={{
83
+ walletConnectProjectId: props.config?.walletConnectProjectId,
84
+ }}>
81
85
  <Main {...props} />
82
86
  </WidgetWallets>
83
87
  );
@@ -55,7 +55,12 @@ export function AppRoutes(props: PropTypes) {
55
55
  },
56
56
  {
57
57
  path: navigationRoutes.settings,
58
- element: <SettingsPage singleTheme= {config?.theme?.singleTheme} supportedSwappers={config?.liquiditySources} />,
58
+ element: (
59
+ <SettingsPage
60
+ singleTheme={config?.theme?.singleTheme}
61
+ supportedSwappers={config?.liquiditySources}
62
+ />
63
+ ),
59
64
  },
60
65
  {
61
66
  path: navigationRoutes.liquiditySources,
@@ -78,12 +83,15 @@ export function AppRoutes(props: PropTypes) {
78
83
  ? true
79
84
  : config.multiWallets
80
85
  }
86
+ config={config}
81
87
  />
82
88
  ),
83
89
  },
84
90
  {
85
91
  path: getAbsolutePath(navigationRoutes.confirmSwap),
86
- element: <ConfirmSwapPage customDestinationEnabled={config?.customDestination}/>,
92
+ element: (
93
+ <ConfirmSwapPage customDestinationEnabled={config?.customDestination} />
94
+ ),
87
95
  },
88
96
  ]);
89
97
  }
@@ -2,16 +2,26 @@ import { ProviderInterface } from '@rango-dev/wallets-core';
2
2
  import { useEffect } from 'react';
3
3
  import { useWalletsStore } from '../store/wallets';
4
4
  import { WidgetConfig } from '../types';
5
- import { matchAndGenerateProviders } from '../utils/providers';
5
+ import {
6
+ matchAndGenerateProviders,
7
+ ProvidersOptions,
8
+ } from '../utils/providers';
6
9
 
7
- export function useWalletProviders(providers: WidgetConfig['wallets']) {
10
+ export function useWalletProviders(
11
+ providers: WidgetConfig['wallets'],
12
+ options?: ProvidersOptions
13
+ ) {
8
14
  const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
9
- let generateProviders: ProviderInterface[] =
10
- matchAndGenerateProviders(undefined);
15
+ let generateProviders: ProviderInterface[] = matchAndGenerateProviders(
16
+ undefined,
17
+ options
18
+ );
11
19
 
12
20
  useEffect(() => {
13
21
  clearConnectedWallet();
14
- generateProviders = matchAndGenerateProviders(providers);
22
+ generateProviders = matchAndGenerateProviders(providers, {
23
+ walletConnectProjectId: options?.walletConnectProjectId,
24
+ });
15
25
  }, [providers]);
16
26
 
17
27
  return {
@@ -28,6 +28,7 @@ import { configWalletsToWalletName } from '../utils/providers';
28
28
  interface PropTypes {
29
29
  supportedWallets: WidgetConfig['wallets'];
30
30
  multiWallets: boolean;
31
+ config?: WidgetConfig;
31
32
  }
32
33
 
33
34
  const ListContainer = styled('div', {
@@ -53,13 +54,19 @@ const AlertContainer = styled('div', {
53
54
 
54
55
  const ALL_SUPPORTED_WALLETS = Object.values(WalletTypes);
55
56
 
56
- export function WalletsPage({ supportedWallets, multiWallets }: PropTypes) {
57
+ export function WalletsPage({
58
+ supportedWallets,
59
+ multiWallets,
60
+ config,
61
+ }: PropTypes) {
57
62
  const { navigateBackFrom } = useNavigateBack();
58
63
  const { state, disconnect, getWalletInfo, connect } = useWallets();
59
64
  const wallets = getlistWallet(
60
65
  state,
61
66
  getWalletInfo,
62
- configWalletsToWalletName(supportedWallets) || ALL_SUPPORTED_WALLETS
67
+ configWalletsToWalletName(supportedWallets, {
68
+ walletConnectProjectId: config?.walletConnectProjectId,
69
+ }) || ALL_SUPPORTED_WALLETS
63
70
  );
64
71
  const walletsRef = useRef<WalletInfo[]>();
65
72
 
@@ -125,6 +125,7 @@ export type BlockchainAndTokenConfig = {
125
125
  */
126
126
  export type WidgetConfig = {
127
127
  apiKey: string;
128
+ walletConnectProjectId?: string;
128
129
  affiliate?: WidgeAffiliate;
129
130
  amount?: number;
130
131
  from?: BlockchainAndTokenConfig;
@@ -1,8 +1,11 @@
1
1
  import { allProviders } from '@rango-dev/provider-all';
2
2
  import { ProviderInterface } from '@rango-dev/wallets-core';
3
- import { WC_PROJECT_ID } from '../constants/widget';
4
3
  import { WidgetConfig } from '../types';
5
4
 
5
+ export interface ProvidersOptions {
6
+ walletConnectProjectId?: WidgetConfig['walletConnectProjectId'];
7
+ }
8
+
6
9
  /**
7
10
  *
8
11
  * Generate a list of providers by passing a provider name (e.g. metamask) or a custom provider which implemented ProviderInterface.
@@ -10,11 +13,12 @@ import { WidgetConfig } from '../types';
10
13
  *
11
14
  */
12
15
  export function matchAndGenerateProviders(
13
- providers: WidgetConfig['wallets']
16
+ providers: WidgetConfig['wallets'],
17
+ options?: ProvidersOptions
14
18
  ): ProviderInterface[] {
15
19
  const all = allProviders({
16
20
  walletconnect2: {
17
- WC_PROJECT_ID: WC_PROJECT_ID,
21
+ WC_PROJECT_ID: options?.walletConnectProjectId || '',
18
22
  },
19
23
  });
20
24
 
@@ -48,9 +52,10 @@ export function matchAndGenerateProviders(
48
52
  }
49
53
 
50
54
  export function configWalletsToWalletName(
51
- config: WidgetConfig['wallets']
55
+ config: WidgetConfig['wallets'],
56
+ options?: ProvidersOptions
52
57
  ): string[] {
53
- const providers = matchAndGenerateProviders(config);
58
+ const providers = matchAndGenerateProviders(config, options);
54
59
  const names = providers.map((provider) => {
55
60
  return provider.config.type;
56
61
  });
@@ -1,2 +0,0 @@
1
- export declare const WC_PROJECT_ID = "f5196d081862c6f2b81c04520ea9301c";
2
- //# sourceMappingURL=widget.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../src/constants/widget.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,qCAAqC,CAAC"}
@@ -1 +0,0 @@
1
- export const WC_PROJECT_ID = 'f5196d081862c6f2b81c04520ea9301c';