@rango-dev/widget-embedded 0.37.0 → 0.37.1-next.1
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/CHANGELOG.md +4 -0
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +1 -1
- package/dist/components/Quote/Quote.types.d.ts +2 -0
- package/dist/components/Quote/Quote.types.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
- package/dist/components/Quotes/Quotes.d.ts.map +1 -1
- package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +2 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
- package/dist/constants/quote.d.ts +10 -0
- package/dist/constants/quote.d.ts.map +1 -1
- package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
- package/dist/containers/Inputs/Inputs.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.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 +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +3 -3
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +6 -4
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
- package/dist/hooks/useFetchApiConfig.d.ts.map +1 -1
- package/dist/hooks/useFetchCustomToken.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +2 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +3 -5
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
- package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +2 -3
- package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/store/app.d.ts +2 -4
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +4 -0
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/slices/types.d.ts +6 -0
- package/dist/store/slices/types.d.ts.map +1 -0
- package/dist/store/slices/wallets.d.ts +80 -0
- package/dist/store/slices/wallets.d.ts.map +1 -0
- package/dist/store/ui.d.ts +4 -0
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/utils/wallets.d.ts +17 -0
- package/dist/store/utils/wallets.d.ts.map +1 -0
- package/dist/types/config.d.ts +6 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/quote.d.ts +8 -17
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +3 -7
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +8 -9
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +5 -6
- package/dist/utils/quote.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +1 -0
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +5 -5
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +12 -14
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +9 -9
- package/src/QueueManager.tsx +17 -11
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -24
- package/src/components/ConfirmWalletsModal/WalletList.tsx +10 -7
- package/src/components/Layout/Layout.tsx +1 -3
- package/src/components/Quote/Quote.tsx +22 -3
- package/src/components/Quote/Quote.types.ts +2 -0
- package/src/components/Quote/QuoteCostDetails.styles.ts +0 -1
- package/src/components/Quote/QuoteCostDetails.tsx +23 -4
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +42 -22
- package/src/components/Quotes/Quotes.tsx +2 -3
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +14 -6
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +26 -13
- package/src/components/TokenList/TokenList.tsx +4 -27
- package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +2 -1
- package/src/components/WalletStatefulConnect/Namespaces.tsx +31 -38
- package/src/components/WalletStatefulConnect/Namespaces.types.tsx +1 -1
- package/src/constants/quote.ts +25 -0
- package/src/containers/ExpandedQuotes/ExpandedQuotes.styles.ts +1 -0
- package/src/containers/ExpandedQuotes/ExpandedQuotes.tsx +1 -1
- package/src/containers/Inputs/Inputs.tsx +20 -7
- package/src/containers/QuoteInfo/QuoteInfo.tsx +3 -9
- package/src/containers/Wallets/Wallets.tsx +82 -16
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +2 -2
- package/src/containers/WidgetInfo/WidgetInfo.tsx +10 -8
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +3 -3
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +29 -66
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +10 -15
- package/src/hooks/useFetchApiConfig.ts +5 -1
- package/src/hooks/useFetchCustomToken.ts +5 -0
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +50 -17
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +3 -5
- package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +7 -6
- package/src/hooks/useSwapInput.ts +3 -11
- package/src/hooks/useWalletList.ts +6 -8
- package/src/hooks/useWalletProviders/useWalletProviders.ts +8 -12
- package/src/index.ts +1 -1
- package/src/pages/ConfirmSwapPage.tsx +7 -15
- package/src/pages/Home.tsx +5 -3
- package/src/pages/SelectSwapItemsPage.tsx +1 -2
- package/src/store/app.ts +4 -4
- package/src/store/quote.ts +3 -13
- package/src/store/slices/config.ts +76 -0
- package/src/store/slices/data.test.ts +23 -1
- package/src/store/slices/data.ts +3 -2
- package/src/store/slices/types.ts +9 -0
- package/src/store/slices/wallets.ts +577 -0
- package/src/store/ui.ts +6 -0
- package/src/store/utils/wallets.ts +111 -0
- package/src/types/config.ts +7 -3
- package/src/types/quote.ts +10 -24
- package/src/types/wallets.ts +3 -7
- package/src/utils/providers.ts +88 -36
- package/src/utils/quote.ts +57 -45
- package/src/utils/settings.ts +4 -0
- package/src/utils/swap.ts +56 -37
- package/src/utils/wallets.ts +76 -141
- package/dist/constants/warnings.d.ts +0 -3
- package/dist/constants/warnings.d.ts.map +0 -1
- package/dist/hooks/useObserveBalanceChanges/index.d.ts +0 -2
- package/dist/hooks/useObserveBalanceChanges/index.d.ts.map +0 -1
- package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts +0 -4
- package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts.map +0 -1
- package/dist/store/wallets.d.ts +0 -66
- package/dist/store/wallets.d.ts.map +0 -1
- package/src/constants/warnings.ts +0 -26
- package/src/hooks/useObserveBalanceChanges/index.ts +0 -1
- package/src/hooks/useObserveBalanceChanges/useObserveBalanceChanges.ts +0 -68
- package/src/store/wallets.ts +0 -268
package/src/store/quote.ts
CHANGED
|
@@ -21,11 +21,7 @@ import {
|
|
|
21
21
|
WidgetEvents,
|
|
22
22
|
} from '../types';
|
|
23
23
|
import { isPositiveNumber } from '../utils/numbers';
|
|
24
|
-
import {
|
|
25
|
-
getQuoteFromTokenUsdPrice,
|
|
26
|
-
getQuoteToTokenUsdPrice,
|
|
27
|
-
} from '../utils/quote';
|
|
28
|
-
import { calcOutputUsdValue } from '../utils/swap';
|
|
24
|
+
import { getUsdInputFrom, getUsdOutputFrom } from '../utils/swap';
|
|
29
25
|
|
|
30
26
|
import createSelectors from './selectors';
|
|
31
27
|
|
|
@@ -137,14 +133,8 @@ export const useQuoteStore = createSelectors(
|
|
|
137
133
|
outputAmount = !!quote?.outputAmount
|
|
138
134
|
? new BigNumber(quote?.outputAmount)
|
|
139
135
|
: null;
|
|
140
|
-
inputUsdValue =
|
|
141
|
-
|
|
142
|
-
getQuoteFromTokenUsdPrice(quote) || state.fromToken?.usdPrice
|
|
143
|
-
);
|
|
144
|
-
outputUsdValue = calcOutputUsdValue(
|
|
145
|
-
quote.outputAmount,
|
|
146
|
-
getQuoteToTokenUsdPrice(quote) || state.toToken?.usdPrice
|
|
147
|
-
);
|
|
136
|
+
inputUsdValue = getUsdInputFrom(quote) ?? ZERO;
|
|
137
|
+
outputUsdValue = getUsdOutputFrom(quote) ?? ZERO;
|
|
148
138
|
}
|
|
149
139
|
return {
|
|
150
140
|
selectedQuote: quote,
|
|
@@ -3,9 +3,31 @@ import type { SettingsSlice } from './settings';
|
|
|
3
3
|
import type { WidgetConfig } from '../../types';
|
|
4
4
|
import type { StateCreatorWithInitialData } from '../app';
|
|
5
5
|
|
|
6
|
+
import { allProviders as getAllProviders } from '@rango-dev/provider-all';
|
|
7
|
+
import { type VersionedProviders } from '@rango-dev/wallets-core';
|
|
8
|
+
|
|
6
9
|
import { cacheService } from '../../services/cacheService';
|
|
10
|
+
import {
|
|
11
|
+
matchAndGenerateProviders,
|
|
12
|
+
type ProvidersOptions,
|
|
13
|
+
} from '../../utils/providers';
|
|
7
14
|
import { matchTokensFromConfigWithMeta } from '../utils';
|
|
8
15
|
|
|
16
|
+
function makeProvidersOptionsFromConfig(
|
|
17
|
+
config: WidgetConfig
|
|
18
|
+
): ProvidersOptions {
|
|
19
|
+
const options: ProvidersOptions = {
|
|
20
|
+
walletConnectProjectId: config?.walletConnectProjectId,
|
|
21
|
+
trezorManifest: config?.trezorManifest,
|
|
22
|
+
tonConnect: config?.tonConnect,
|
|
23
|
+
walletConnectListedDesktopWalletLink:
|
|
24
|
+
config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,
|
|
25
|
+
experimentalWallet: config.features?.experimentalWallet,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return options;
|
|
29
|
+
}
|
|
30
|
+
|
|
9
31
|
export const DEFAULT_CONFIG: WidgetConfig = {
|
|
10
32
|
apiKey: '',
|
|
11
33
|
title: undefined,
|
|
@@ -21,6 +43,9 @@ export const DEFAULT_CONFIG: WidgetConfig = {
|
|
|
21
43
|
manifestUrl:
|
|
22
44
|
'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json',
|
|
23
45
|
},
|
|
46
|
+
features: {
|
|
47
|
+
experimentalWallet: 'enabled',
|
|
48
|
+
},
|
|
24
49
|
};
|
|
25
50
|
|
|
26
51
|
interface IframeConfigs {
|
|
@@ -58,6 +83,31 @@ export interface ConfigSlice {
|
|
|
58
83
|
name: K,
|
|
59
84
|
value: IframeConfigs[K]
|
|
60
85
|
) => void;
|
|
86
|
+
allProviders: VersionedProviders[];
|
|
87
|
+
buildAndSetProviders: () => void;
|
|
88
|
+
getAvailableProviders: () => VersionedProviders[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function generateProviders(config: WidgetConfig) {
|
|
92
|
+
const options = makeProvidersOptionsFromConfig(config);
|
|
93
|
+
const envs = {
|
|
94
|
+
walletconnect2: {
|
|
95
|
+
WC_PROJECT_ID: options?.walletConnectProjectId || '',
|
|
96
|
+
DISABLE_MODAL_AND_OPEN_LINK:
|
|
97
|
+
options?.walletConnectListedDesktopWalletLink,
|
|
98
|
+
},
|
|
99
|
+
selectedProviders: config.wallets,
|
|
100
|
+
trezor: options?.trezorManifest
|
|
101
|
+
? { manifest: options.trezorManifest }
|
|
102
|
+
: undefined,
|
|
103
|
+
tonConnect: options?.tonConnect?.manifestUrl
|
|
104
|
+
? { manifestUrl: options?.tonConnect.manifestUrl }
|
|
105
|
+
: undefined,
|
|
106
|
+
};
|
|
107
|
+
const allProviders = getAllProviders(envs);
|
|
108
|
+
const allBuiltProviders = allProviders.map((build) => build());
|
|
109
|
+
|
|
110
|
+
return allBuiltProviders;
|
|
61
111
|
}
|
|
62
112
|
|
|
63
113
|
export const createConfigSlice: StateCreatorWithInitialData<
|
|
@@ -65,10 +115,15 @@ export const createConfigSlice: StateCreatorWithInitialData<
|
|
|
65
115
|
ConfigSlice & SettingsSlice & DataSlice,
|
|
66
116
|
ConfigSlice
|
|
67
117
|
> = (initialData, set, get) => {
|
|
118
|
+
const allBuiltProviders = generateProviders({
|
|
119
|
+
...DEFAULT_CONFIG,
|
|
120
|
+
...initialData,
|
|
121
|
+
});
|
|
68
122
|
return {
|
|
69
123
|
config: { ...DEFAULT_CONFIG, ...initialData },
|
|
70
124
|
iframe: DEFAULT_IFRAME_CONFIGS,
|
|
71
125
|
campaignMode: DEFAULT_CAMPAIGN_MODE,
|
|
126
|
+
allProviders: allBuiltProviders,
|
|
72
127
|
getLiquiditySources: () => {
|
|
73
128
|
const { config, campaignMode } = get();
|
|
74
129
|
return campaignMode.liquiditySources?.length
|
|
@@ -159,5 +214,26 @@ export const createConfigSlice: StateCreatorWithInitialData<
|
|
|
159
214
|
},
|
|
160
215
|
});
|
|
161
216
|
},
|
|
217
|
+
|
|
218
|
+
buildAndSetProviders: () => {
|
|
219
|
+
const { config } = get();
|
|
220
|
+
const allBuiltProviders = generateProviders(config);
|
|
221
|
+
|
|
222
|
+
set({
|
|
223
|
+
allProviders: allBuiltProviders,
|
|
224
|
+
});
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
getAvailableProviders: () => {
|
|
228
|
+
const { allProviders, config } = get();
|
|
229
|
+
const options = makeProvidersOptionsFromConfig(config);
|
|
230
|
+
|
|
231
|
+
const availableProviders = matchAndGenerateProviders({
|
|
232
|
+
allProviders,
|
|
233
|
+
configWallets: config.wallets,
|
|
234
|
+
options,
|
|
235
|
+
});
|
|
236
|
+
return availableProviders;
|
|
237
|
+
},
|
|
162
238
|
};
|
|
163
239
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WidgetConfig } from '../../types';
|
|
1
2
|
import type { AppStoreState } from '../app';
|
|
2
3
|
import type { EvmBlockchainMeta, Token } from 'rango-sdk';
|
|
3
4
|
|
|
@@ -17,6 +18,27 @@ let appStoreState: AppStoreState;
|
|
|
17
18
|
let customTokens: [Token, Token, Token];
|
|
18
19
|
let rangoBlockchain: EvmBlockchainMeta;
|
|
19
20
|
|
|
21
|
+
const DEFAULT_CONFIG: WidgetConfig = {
|
|
22
|
+
apiKey: '',
|
|
23
|
+
walletConnectProjectId: 'e24844c5deb5193c1c14840a7af6a40b',
|
|
24
|
+
title: undefined,
|
|
25
|
+
multiWallets: true,
|
|
26
|
+
excludeLiquiditySources: true,
|
|
27
|
+
customDestination: true,
|
|
28
|
+
variant: 'default',
|
|
29
|
+
trezorManifest: {
|
|
30
|
+
appUrl: 'https://widget.rango.exchange/',
|
|
31
|
+
email: 'hi+trezorwidget@rango.exchange',
|
|
32
|
+
},
|
|
33
|
+
tonConnect: {
|
|
34
|
+
manifestUrl:
|
|
35
|
+
'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json',
|
|
36
|
+
},
|
|
37
|
+
features: {
|
|
38
|
+
experimentalWallet: 'enabled',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
20
42
|
beforeEach(() => {
|
|
21
43
|
cacheService.clear();
|
|
22
44
|
rangoBlockchain = createEvmBlockchain();
|
|
@@ -60,7 +82,7 @@ beforeEach(() => {
|
|
|
60
82
|
initData._tokensMapByBlockchainName[token.blockchain].push(tokenHash);
|
|
61
83
|
});
|
|
62
84
|
|
|
63
|
-
const appStore = createAppStore();
|
|
85
|
+
const appStore = createAppStore(DEFAULT_CONFIG);
|
|
64
86
|
appStore.setState(initData);
|
|
65
87
|
appStoreState = appStore.getState();
|
|
66
88
|
});
|
package/src/store/slices/data.ts
CHANGED
|
@@ -348,8 +348,9 @@ export const createDataSlice: StateCreator<
|
|
|
348
348
|
{};
|
|
349
349
|
const tokens: Token[] = [];
|
|
350
350
|
const popularTokens: Token[] = response.popularTokens;
|
|
351
|
-
const swappers: SwapperMeta[] = response.swappers
|
|
352
|
-
|
|
351
|
+
const swappers: SwapperMeta[] = response.swappers.filter(
|
|
352
|
+
(swapper) => swapper.enabled
|
|
353
|
+
);
|
|
353
354
|
const blockchainsWithAtLeastOneToken = new Set();
|
|
354
355
|
|
|
355
356
|
response.tokens.forEach((token) => {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ConfigSlice } from './config';
|
|
2
|
+
import type { DataSlice } from './data';
|
|
3
|
+
import type { SettingsSlice } from './settings';
|
|
4
|
+
import type { WalletsSlice } from './wallets';
|
|
5
|
+
|
|
6
|
+
export type AppStoreState = DataSlice &
|
|
7
|
+
ConfigSlice &
|
|
8
|
+
SettingsSlice &
|
|
9
|
+
WalletsSlice;
|