@rango-dev/widget-embedded 0.17.1-next.16 → 0.17.1-next.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/containers/App/App.d.ts.map +1 -1
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/types/config.d.ts +14 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +1 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/QueueManager.tsx +1 -0
- package/src/components/NotificationContent/NotificationContent.tsx +2 -1
- package/src/constants/index.ts +1 -0
- package/src/containers/App/App.tsx +1 -9
- package/src/containers/WidgetProvider/WidgetProvider.tsx +10 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +4 -2
- package/src/hooks/useSwapInput.ts +5 -1
- package/src/services/httpService.ts +1 -1
- package/src/types/config.ts +15 -0
- package/src/utils/configs.ts +2 -1
package/dist/types/config.d.ts
CHANGED
|
@@ -85,12 +85,22 @@ export type BlockchainAndTokenConfig = {
|
|
|
85
85
|
blockchains?: string[];
|
|
86
86
|
tokens?: Asset[];
|
|
87
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* `ExperimentalFeatures`
|
|
90
|
+
*
|
|
91
|
+
* @property {boolean} routing
|
|
92
|
+
*- This property is optional and sets experimental in quote api.
|
|
93
|
+
*/
|
|
94
|
+
type ExperimentalFeatures = {
|
|
95
|
+
routing?: boolean;
|
|
96
|
+
};
|
|
88
97
|
/**
|
|
89
98
|
* The type WidgetConfig defines the configuration options for a widget, including API key, affiliate
|
|
90
99
|
* reference, amount, blockchain and token configurations, liquidity sources, wallet types, language,
|
|
91
100
|
* and theme.
|
|
92
101
|
*
|
|
93
102
|
* @property {string} apiKey - The API key used to communicate with Rango API
|
|
103
|
+
* @property {string} apiUrl - The API url used to set custom API url
|
|
94
104
|
* @property {WidgetAffiliate} affiliate - If you want to charge users fee per transaction, you should
|
|
95
105
|
* pass `WidgetAffiliate` including affiliateRef, affiliatePercent, and affiliateWallets.
|
|
96
106
|
* @property {number} amount - The default input amount.
|
|
@@ -123,9 +133,11 @@ export type BlockchainAndTokenConfig = {
|
|
|
123
133
|
* you could use to pin tokens of your choice to the top of the token list.
|
|
124
134
|
* @property {boolean} enableNewLiquiditySources - The `enableNewLiquiditySources` property is a boolean value that when you
|
|
125
135
|
* set it to true, whenever a new liquidity source is added, it will be added to your list as well.
|
|
136
|
+
* @property {ExperimentalFeatures} experimental - The `experimental` property is an optional object that specifies some experimental features.
|
|
126
137
|
*/
|
|
127
138
|
export type WidgetConfig = {
|
|
128
139
|
apiKey: string;
|
|
140
|
+
apiUrl?: string;
|
|
129
141
|
walletConnectProjectId?: string;
|
|
130
142
|
affiliate?: WidgetAffiliate;
|
|
131
143
|
amount?: number;
|
|
@@ -140,5 +152,7 @@ export type WidgetConfig = {
|
|
|
140
152
|
externalWallets?: boolean;
|
|
141
153
|
pinnedTokens?: Asset[];
|
|
142
154
|
enableNewLiquiditySources?: boolean;
|
|
155
|
+
experimental?: ExperimentalFeatures;
|
|
143
156
|
};
|
|
157
|
+
export {};
|
|
144
158
|
//# 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,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AAE,oBAAoB,CAAC;CACrC,CAAC"}
|
package/dist/utils/configs.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/utils/configs.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/utils/configs.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,OAAO,UAE5C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,OAAO,EAAE,KAAK,EAAE,GAAG,OAIxD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,OAAO,WAS9C;AAED,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C,eAAO,MAAM,uBAAuB,iBAAiB,CAAC"}
|
package/package.json
CHANGED
package/src/QueueManager.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import { useNavigate } from 'react-router-dom';
|
|
12
12
|
|
|
13
|
+
import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
13
14
|
import { useAppStore } from '../../store/AppStore';
|
|
14
15
|
import { useNotificationStore } from '../../store/notification';
|
|
15
16
|
import { useUiStore } from '../../store/ui';
|
|
@@ -34,7 +35,7 @@ export function NotificationContent() {
|
|
|
34
35
|
|
|
35
36
|
const handleOnClick = (requestId: Notification['requestId']) => {
|
|
36
37
|
setSelectedSwap(requestId);
|
|
37
|
-
navigate(`${requestId}`);
|
|
38
|
+
navigate(`${navigationRoutes.swaps}/${requestId}`);
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
return (
|
package/src/constants/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
2
2
|
|
|
3
3
|
import { I18nManager } from '@rango-dev/ui';
|
|
4
|
-
import React, { useContext, useEffect,
|
|
4
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
5
5
|
|
|
6
6
|
import { AppRouter } from '../../components/AppRouter';
|
|
7
7
|
import { AppRoutes } from '../../components/AppRoutes';
|
|
@@ -12,7 +12,6 @@ import { useTheme } from '../../hooks/useTheme';
|
|
|
12
12
|
import { useAppStore } from '../../store/AppStore';
|
|
13
13
|
import { useNotificationStore } from '../../store/notification';
|
|
14
14
|
import { useSettingsStore } from '../../store/settings';
|
|
15
|
-
import { initConfig } from '../../utils/configs';
|
|
16
15
|
import { WidgetContext } from '../Wallets';
|
|
17
16
|
|
|
18
17
|
import { MainContainer } from './App.styles';
|
|
@@ -28,13 +27,6 @@ export function Main() {
|
|
|
28
27
|
const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
|
|
29
28
|
const widgetContext = useContext(WidgetContext);
|
|
30
29
|
|
|
31
|
-
useMemo(() => {
|
|
32
|
-
if (config?.apiKey) {
|
|
33
|
-
initConfig({
|
|
34
|
-
API_KEY: config?.apiKey,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}, [config]);
|
|
38
30
|
useEffect(() => {
|
|
39
31
|
void fetchMeta().catch();
|
|
40
32
|
void useSettingsStore.persist.rehydrate();
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import type { PropTypes } from './WidgetProvider.types';
|
|
2
2
|
import type { PropsWithChildren } from 'react';
|
|
3
3
|
|
|
4
|
-
import React from 'react';
|
|
4
|
+
import React, { useMemo } from 'react';
|
|
5
5
|
|
|
6
|
+
import { DEFAULT_BASE_URL, RANGO_PUBLIC_API_KEY } from '../../constants';
|
|
6
7
|
import QueueManager from '../../QueueManager';
|
|
8
|
+
import { initConfig } from '../../utils/configs';
|
|
7
9
|
import { WidgetWallets } from '../Wallets';
|
|
8
10
|
import { WidgetInfo } from '../WidgetInfo';
|
|
9
11
|
|
|
10
12
|
export function WidgetProvider(props: PropsWithChildren<PropTypes>) {
|
|
11
13
|
const { onUpdateState, config } = props;
|
|
14
|
+
|
|
15
|
+
useMemo(() => {
|
|
16
|
+
initConfig({
|
|
17
|
+
API_KEY: config?.apiKey || RANGO_PUBLIC_API_KEY,
|
|
18
|
+
BASE_URL: config?.apiUrl || DEFAULT_BASE_URL,
|
|
19
|
+
});
|
|
20
|
+
}, [config]);
|
|
12
21
|
return (
|
|
13
22
|
<WidgetWallets config={config} onUpdateState={onUpdateState}>
|
|
14
23
|
<QueueManager apiKey={config.apiKey}>
|
|
@@ -42,7 +42,7 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
42
42
|
const { connectedWallets } = useWalletsStore();
|
|
43
43
|
const blockchains = useAppStore().blockchains();
|
|
44
44
|
const tokens = useAppStore().tokens();
|
|
45
|
-
|
|
45
|
+
const { experimental } = useAppStore().config;
|
|
46
46
|
const userSlippage = customSlippage || slippage;
|
|
47
47
|
|
|
48
48
|
const { fetch: fetchQuote, cancelFetch, loading } = useFetchQuote();
|
|
@@ -77,7 +77,9 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
77
77
|
initialQuote: initialQuote,
|
|
78
78
|
destination: customDestination,
|
|
79
79
|
});
|
|
80
|
-
|
|
80
|
+
if (experimental?.routing) {
|
|
81
|
+
requestBody.experimental = true;
|
|
82
|
+
}
|
|
81
83
|
let currentQuote: BestRouteResponse;
|
|
82
84
|
try {
|
|
83
85
|
currentQuote = await fetchQuote(requestBody).then((response) =>
|
|
@@ -33,7 +33,8 @@ type UseSwapInput = {
|
|
|
33
33
|
*/
|
|
34
34
|
export function useSwapInput(): UseSwapInput {
|
|
35
35
|
const { fetch: fetchQuote, cancelFetch } = useFetchQuote();
|
|
36
|
-
const { liquiditySources, enableNewLiquiditySources } =
|
|
36
|
+
const { liquiditySources, enableNewLiquiditySources, experimental } =
|
|
37
|
+
useAppStore().config;
|
|
37
38
|
const tokens = useAppStore().tokens();
|
|
38
39
|
const {
|
|
39
40
|
fromToken,
|
|
@@ -86,6 +87,9 @@ export function useSwapInput(): UseSwapInput {
|
|
|
86
87
|
affiliatePercent,
|
|
87
88
|
affiliateWallets,
|
|
88
89
|
});
|
|
90
|
+
if (experimental?.routing) {
|
|
91
|
+
requestBody.experimental = true;
|
|
92
|
+
}
|
|
89
93
|
fetchQuote(requestBody)
|
|
90
94
|
.then((res) => {
|
|
91
95
|
setLoading(false);
|
package/src/types/config.ts
CHANGED
|
@@ -85,12 +85,23 @@ export type BlockchainAndTokenConfig = {
|
|
|
85
85
|
tokens?: Asset[];
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* `ExperimentalFeatures`
|
|
90
|
+
*
|
|
91
|
+
* @property {boolean} routing
|
|
92
|
+
*- This property is optional and sets experimental in quote api.
|
|
93
|
+
*/
|
|
94
|
+
type ExperimentalFeatures = {
|
|
95
|
+
routing?: boolean;
|
|
96
|
+
};
|
|
97
|
+
|
|
88
98
|
/**
|
|
89
99
|
* The type WidgetConfig defines the configuration options for a widget, including API key, affiliate
|
|
90
100
|
* reference, amount, blockchain and token configurations, liquidity sources, wallet types, language,
|
|
91
101
|
* and theme.
|
|
92
102
|
*
|
|
93
103
|
* @property {string} apiKey - The API key used to communicate with Rango API
|
|
104
|
+
* @property {string} apiUrl - The API url used to set custom API url
|
|
94
105
|
* @property {WidgetAffiliate} affiliate - If you want to charge users fee per transaction, you should
|
|
95
106
|
* pass `WidgetAffiliate` including affiliateRef, affiliatePercent, and affiliateWallets.
|
|
96
107
|
* @property {number} amount - The default input amount.
|
|
@@ -123,9 +134,12 @@ export type BlockchainAndTokenConfig = {
|
|
|
123
134
|
* you could use to pin tokens of your choice to the top of the token list.
|
|
124
135
|
* @property {boolean} enableNewLiquiditySources - The `enableNewLiquiditySources` property is a boolean value that when you
|
|
125
136
|
* set it to true, whenever a new liquidity source is added, it will be added to your list as well.
|
|
137
|
+
* @property {ExperimentalFeatures} experimental - The `experimental` property is an optional object that specifies some experimental features.
|
|
126
138
|
*/
|
|
139
|
+
|
|
127
140
|
export type WidgetConfig = {
|
|
128
141
|
apiKey: string;
|
|
142
|
+
apiUrl?: string;
|
|
129
143
|
walletConnectProjectId?: string;
|
|
130
144
|
affiliate?: WidgetAffiliate;
|
|
131
145
|
amount?: number;
|
|
@@ -140,4 +154,5 @@ export type WidgetConfig = {
|
|
|
140
154
|
externalWallets?: boolean;
|
|
141
155
|
pinnedTokens?: Asset[];
|
|
142
156
|
enableNewLiquiditySources?: boolean;
|
|
157
|
+
experimental?: ExperimentalFeatures;
|
|
143
158
|
};
|
package/src/utils/configs.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { RANGO_PUBLIC_API_KEY } from '../constants';
|
|
|
2
2
|
|
|
3
3
|
export interface Configs {
|
|
4
4
|
API_KEY: string;
|
|
5
|
+
BASE_URL?: string;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
let configs: Configs = {
|
|
@@ -9,7 +10,7 @@ let configs: Configs = {
|
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export function getConfig(name: keyof Configs) {
|
|
12
|
-
return configs[name];
|
|
13
|
+
return configs[name] || '';
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export function setConfig(name: keyof Configs, value: any) {
|