@lifi/widget 3.13.2 → 3.14.0-beta.0
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/esm/AppDrawer.style.d.ts +1 -1
- package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js +1 -0
- package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js.map +1 -1
- package/dist/esm/components/ActiveTransactions/ActiveTransactions.style.d.ts +1 -1
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -1
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js +2 -2
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
- package/dist/esm/components/ButtonTertiary.d.ts +1 -1
- package/dist/esm/components/ButtonTertiary.js +4 -5
- package/dist/esm/components/ButtonTertiary.js.map +1 -1
- package/dist/esm/components/Card/CardHeader.d.ts +1 -1
- package/dist/esm/components/Card/CardIconButton.d.ts +1 -1
- package/dist/esm/components/Card/CardLabel.js +0 -1
- package/dist/esm/components/Card/CardLabel.js.map +1 -1
- package/dist/esm/components/Header/Header.style.d.ts +1 -1
- package/dist/esm/components/Header/SettingsButton.style.d.ts +1 -1
- package/dist/esm/components/RouteCard/RouteCard.js +13 -4
- package/dist/esm/components/RouteCard/RouteCard.js.map +1 -1
- package/dist/esm/components/RouteCard/getMatchingLabels.d.ts +3 -0
- package/dist/esm/components/RouteCard/getMatchingLabels.js +34 -0
- package/dist/esm/components/RouteCard/getMatchingLabels.js.map +1 -0
- package/dist/esm/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
- package/dist/esm/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/dist/esm/components/Skeleton/WidgetSkeleton.style.d.ts +2 -2
- package/dist/esm/components/Step/CircularProgress.js +2 -1
- package/dist/esm/components/Step/CircularProgress.js.map +1 -1
- package/dist/esm/components/Step/CircularProgress.style.js +13 -2
- package/dist/esm/components/Step/CircularProgress.style.js.map +1 -1
- package/dist/esm/components/Step/Step.js +17 -8
- package/dist/esm/components/Step/Step.js.map +1 -1
- package/dist/esm/components/Step/StepProcess.js +2 -1
- package/dist/esm/components/Step/StepProcess.js.map +1 -1
- package/dist/esm/components/Step/StepTimer.js +2 -1
- package/dist/esm/components/Step/StepTimer.js.map +1 -1
- package/dist/esm/components/TokenList/TokenList.style.d.ts +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/useProcessMessage.js +18 -6
- package/dist/esm/hooks/useProcessMessage.js.map +1 -1
- package/dist/esm/hooks/useRoutes.d.ts +2 -2
- package/dist/esm/hooks/useRoutes.js +99 -58
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/i18n/en.json +14 -10
- package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js +1 -2
- package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js.map +1 -1
- package/dist/esm/pages/SendToWallet/SendToWalletPage.style.d.ts +2 -2
- package/dist/esm/providers/WalletProvider/SDKProviders.js +2 -15
- package/dist/esm/providers/WalletProvider/SDKProviders.js.map +1 -1
- package/dist/esm/stores/routes/useExecutingRoutesIds.js +2 -2
- package/dist/esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
- package/dist/esm/themes/createTheme.js +4 -5
- package/dist/esm/themes/createTheme.js.map +1 -1
- package/dist/esm/types/widget.d.ts +19 -1
- package/dist/esm/types/widget.js.map +1 -1
- package/package.json +12 -13
- package/src/components/ActiveTransactions/ActiveTransactionItem.tsx +1 -0
- package/src/components/BaseTransactionButton/BaseTransactionButton.tsx +3 -3
- package/src/components/ButtonTertiary.tsx +4 -5
- package/src/components/Card/CardLabel.tsx +0 -1
- package/src/components/RouteCard/RouteCard.tsx +19 -6
- package/src/components/RouteCard/getMatchingLabels.ts +53 -0
- package/src/components/Step/CircularProgress.style.tsx +13 -2
- package/src/components/Step/CircularProgress.tsx +2 -1
- package/src/components/Step/Step.tsx +23 -12
- package/src/components/Step/StepProcess.tsx +2 -1
- package/src/components/Step/StepTimer.tsx +3 -1
- package/src/config/version.ts +1 -1
- package/src/hooks/useProcessMessage.ts +24 -5
- package/src/hooks/useRoutes.ts +127 -66
- package/src/i18n/en.json +14 -10
- package/src/pages/SendToWallet/BookmarkAddressSheet.tsx +2 -3
- package/src/providers/WalletProvider/SDKProviders.tsx +2 -16
- package/src/stores/routes/useExecutingRoutesIds.ts +2 -2
- package/src/themes/createTheme.ts +6 -8
- package/src/themes/types.ts +0 -1
- package/src/types/widget.ts +23 -0
- package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.d.ts +0 -8
- package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.js +0 -95
- package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.js.map +0 -1
- package/src/providers/WalletProvider/getSafeMultisigConfig.ts +0 -144
package/src/hooks/useRoutes.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import type { Route,
|
|
2
|
-
import {
|
|
1
|
+
import type { Route, Token } from '@lifi/sdk'
|
|
2
|
+
import {
|
|
3
|
+
LiFiErrorCode,
|
|
4
|
+
convertQuoteToRoute,
|
|
5
|
+
getContractCallsQuote,
|
|
6
|
+
getRelayerQuote,
|
|
7
|
+
getRoutes,
|
|
8
|
+
isEVMPermitStep,
|
|
9
|
+
} from '@lifi/sdk'
|
|
3
10
|
import { useAccount } from '@lifi/wallet-management'
|
|
4
11
|
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
|
5
12
|
import { parseUnits } from 'viem'
|
|
@@ -32,6 +39,7 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
|
|
|
32
39
|
exchanges,
|
|
33
40
|
fee,
|
|
34
41
|
feeConfig,
|
|
42
|
+
useRelayerRoutes,
|
|
35
43
|
} = useWidgetConfig()
|
|
36
44
|
const setExecutableRoute = useSetExecutableRoute()
|
|
37
45
|
const queryClient = useQueryClient()
|
|
@@ -258,27 +266,9 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
|
|
|
258
266
|
contractCallQuote.toolDetails = toolDetails
|
|
259
267
|
}
|
|
260
268
|
|
|
261
|
-
const route: Route =
|
|
262
|
-
id: crypto.randomUUID(),
|
|
263
|
-
fromChainId: contractCallQuote.action.fromChainId,
|
|
264
|
-
fromAmountUSD: contractCallQuote.estimate.fromAmountUSD || '',
|
|
265
|
-
fromAmount: contractCallQuote.action.fromAmount,
|
|
266
|
-
fromToken: contractCallQuote.action.fromToken,
|
|
267
|
-
fromAddress: contractCallQuote.action.fromAddress,
|
|
268
|
-
toChainId: contractCallQuote.action.toChainId,
|
|
269
|
-
toAmountUSD: contractCallQuote.estimate.toAmountUSD || '',
|
|
270
|
-
toAmount: contractCallQuote.estimate.toAmount,
|
|
271
|
-
toAmountMin: contractCallQuote.estimate.toAmountMin,
|
|
272
|
-
toToken: toToken!,
|
|
273
|
-
toAddress:
|
|
274
|
-
contractCallQuote.action.toAddress ||
|
|
275
|
-
contractCallQuote.action.fromAddress,
|
|
276
|
-
gasCostUSD: contractCallQuote.estimate.gasCosts?.[0].amountUSD,
|
|
277
|
-
steps: [contractCallQuote],
|
|
278
|
-
insurance: { state: 'NOT_INSURABLE', feeAmountUsd: '0' },
|
|
279
|
-
}
|
|
269
|
+
const route: Route = convertQuoteToRoute(contractCallQuote)
|
|
280
270
|
|
|
281
|
-
return
|
|
271
|
+
return [route]
|
|
282
272
|
}
|
|
283
273
|
|
|
284
274
|
// Prevent sending a request for the same chain token combinations.
|
|
@@ -286,50 +276,110 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
|
|
|
286
276
|
return
|
|
287
277
|
}
|
|
288
278
|
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
279
|
+
const isObservableRelayerRoute =
|
|
280
|
+
observableRoute?.steps?.some(isEVMPermitStep)
|
|
281
|
+
|
|
282
|
+
const shouldUseMainRoutes =
|
|
283
|
+
!observableRoute || !isObservableRelayerRoute
|
|
284
|
+
const shouldUseRelayerQuote =
|
|
285
|
+
fromAddress &&
|
|
286
|
+
useRelayerRoutes &&
|
|
287
|
+
(!observableRoute || isObservableRelayerRoute)
|
|
288
|
+
|
|
289
|
+
const [routesResult, relayerRouteResult] = await Promise.all([
|
|
290
|
+
shouldUseMainRoutes
|
|
291
|
+
? getRoutes(
|
|
292
|
+
{
|
|
293
|
+
fromAddress,
|
|
294
|
+
fromAmount: fromAmount.toString(),
|
|
295
|
+
fromChainId,
|
|
296
|
+
fromTokenAddress,
|
|
297
|
+
toAddress,
|
|
298
|
+
toChainId,
|
|
299
|
+
toTokenAddress,
|
|
300
|
+
fromAmountForGas:
|
|
301
|
+
enabledRefuel && gasRecommendationFromAmount
|
|
302
|
+
? gasRecommendationFromAmount
|
|
303
|
+
: undefined,
|
|
304
|
+
options: {
|
|
305
|
+
allowSwitchChain:
|
|
306
|
+
subvariant === 'refuel' ? false : allowSwitchChain,
|
|
307
|
+
bridges:
|
|
308
|
+
allowBridges?.length || disabledBridges.length
|
|
309
|
+
? {
|
|
310
|
+
allow: allowBridges,
|
|
311
|
+
deny: disabledBridges.length
|
|
312
|
+
? disabledBridges
|
|
313
|
+
: undefined,
|
|
314
|
+
}
|
|
311
315
|
: undefined,
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
316
|
+
exchanges:
|
|
317
|
+
allowExchanges?.length || disabledExchanges.length
|
|
318
|
+
? {
|
|
319
|
+
allow: allowExchanges,
|
|
320
|
+
deny: disabledExchanges.length
|
|
321
|
+
? disabledExchanges
|
|
322
|
+
: undefined,
|
|
323
|
+
}
|
|
320
324
|
: undefined,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
325
|
+
order: routePriority,
|
|
326
|
+
slippage: formattedSlippage,
|
|
327
|
+
fee: calculatedFee || fee,
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
{ signal }
|
|
331
|
+
)
|
|
332
|
+
: Promise.resolve(null),
|
|
333
|
+
shouldUseRelayerQuote
|
|
334
|
+
? getRelayerQuote(
|
|
335
|
+
{
|
|
336
|
+
fromAddress,
|
|
337
|
+
fromAmount: fromAmount.toString(),
|
|
338
|
+
fromChain: fromChainId,
|
|
339
|
+
fromToken: fromTokenAddress,
|
|
340
|
+
toAddress,
|
|
341
|
+
toChain: toChainId,
|
|
342
|
+
toToken: toTokenAddress,
|
|
343
|
+
fromAmountForGas:
|
|
344
|
+
enabledRefuel && gasRecommendationFromAmount
|
|
345
|
+
? gasRecommendationFromAmount
|
|
346
|
+
: undefined,
|
|
347
|
+
order: routePriority,
|
|
348
|
+
slippage: formattedSlippage,
|
|
349
|
+
fee: calculatedFee || fee,
|
|
350
|
+
...(allowBridges?.length || disabledBridges.length
|
|
351
|
+
? {
|
|
352
|
+
allowBridges: allowBridges,
|
|
353
|
+
denyBridges: disabledBridges.length
|
|
354
|
+
? disabledBridges
|
|
355
|
+
: undefined,
|
|
356
|
+
}
|
|
357
|
+
: undefined),
|
|
358
|
+
...(allowExchanges?.length || disabledExchanges.length
|
|
359
|
+
? {
|
|
360
|
+
allowExchanges: allowExchanges,
|
|
361
|
+
denyExchanges: disabledExchanges.length
|
|
362
|
+
? disabledExchanges
|
|
363
|
+
: undefined,
|
|
364
|
+
}
|
|
365
|
+
: undefined),
|
|
366
|
+
},
|
|
367
|
+
{ signal }
|
|
368
|
+
)
|
|
369
|
+
.then((response) => {
|
|
370
|
+
const quote = {
|
|
371
|
+
...response.data.quote.step,
|
|
372
|
+
...response.data.quote,
|
|
373
|
+
}
|
|
374
|
+
return convertQuoteToRoute(quote)
|
|
375
|
+
})
|
|
376
|
+
.catch(() => null)
|
|
377
|
+
: Promise.resolve(null),
|
|
378
|
+
])
|
|
379
|
+
|
|
380
|
+
if (routesResult?.routes[0] && fromAddress) {
|
|
331
381
|
// Update local tokens cache to keep priceUSD in sync
|
|
332
|
-
const { fromToken, toToken } =
|
|
382
|
+
const { fromToken, toToken } = routesResult.routes[0]
|
|
333
383
|
;[fromToken, toToken].forEach((token) => {
|
|
334
384
|
queryClient.setQueriesData<Token[]>(
|
|
335
385
|
{ queryKey: ['token-balances', fromAddress, token.chainId] },
|
|
@@ -349,8 +399,16 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
|
|
|
349
399
|
)
|
|
350
400
|
})
|
|
351
401
|
}
|
|
352
|
-
|
|
353
|
-
|
|
402
|
+
|
|
403
|
+
const routes = routesResult?.routes ?? []
|
|
404
|
+
|
|
405
|
+
// Add relayer route if available
|
|
406
|
+
if (relayerRouteResult) {
|
|
407
|
+
routes.splice(1, 0, relayerRouteResult)
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
emitter.emit(WidgetEvent.AvailableRoutes, routes)
|
|
411
|
+
return routes
|
|
354
412
|
},
|
|
355
413
|
enabled: isEnabled,
|
|
356
414
|
staleTime: refetchTime,
|
|
@@ -361,6 +419,9 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
|
|
|
361
419
|
)
|
|
362
420
|
},
|
|
363
421
|
retry(failureCount, error: any) {
|
|
422
|
+
if (process.env.NODE_ENV === 'development') {
|
|
423
|
+
console.warn('Route query failed:', { failureCount, error })
|
|
424
|
+
}
|
|
364
425
|
if (failureCount >= 5) {
|
|
365
426
|
return false
|
|
366
427
|
}
|
|
@@ -382,7 +443,7 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
|
|
|
382
443
|
}
|
|
383
444
|
|
|
384
445
|
return {
|
|
385
|
-
routes: data
|
|
446
|
+
routes: data,
|
|
386
447
|
isLoading: isEnabled && isLoading,
|
|
387
448
|
isFetching,
|
|
388
449
|
isFetched,
|
package/src/i18n/en.json
CHANGED
|
@@ -220,9 +220,10 @@
|
|
|
220
220
|
"priceImpact": "Price impact",
|
|
221
221
|
"process": {
|
|
222
222
|
"bridge": {
|
|
223
|
-
"
|
|
223
|
+
"permitRequired": "Sign permit for {{tokenSymbol}}",
|
|
224
|
+
"actionRequired": "Sign bridge transaction",
|
|
224
225
|
"done": "Bridge transaction confirmed",
|
|
225
|
-
"pending": "
|
|
226
|
+
"pending": "Bridge transaction pending",
|
|
226
227
|
"started": "Preparing bridge transaction"
|
|
227
228
|
},
|
|
228
229
|
"checkout": {
|
|
@@ -238,19 +239,21 @@
|
|
|
238
239
|
"refunded": "Bridge transaction refunded"
|
|
239
240
|
},
|
|
240
241
|
"swap": {
|
|
241
|
-
"
|
|
242
|
+
"permitRequired": "Sign permit for {{tokenSymbol}}",
|
|
243
|
+
"actionRequired": "Sign swap transaction",
|
|
242
244
|
"done": "Swap completed",
|
|
243
|
-
"pending": "
|
|
245
|
+
"pending": "Swap transaction pending",
|
|
244
246
|
"started": "Preparing swap transaction"
|
|
245
247
|
},
|
|
246
248
|
"switchChain": {
|
|
247
|
-
"actionRequired": "
|
|
248
|
-
"done": "Chain switched
|
|
249
|
+
"actionRequired": "Confirm chain switch",
|
|
250
|
+
"done": "Chain switched"
|
|
249
251
|
},
|
|
250
252
|
"tokenAllowance": {
|
|
251
|
-
"
|
|
252
|
-
"
|
|
253
|
-
"
|
|
253
|
+
"actionRequired": "Approve {{tokenSymbol}} spending",
|
|
254
|
+
"done": "{{tokenSymbol}} spending approved",
|
|
255
|
+
"pending": "{{tokenSymbol}} approval pending",
|
|
256
|
+
"started": "Preparing approval transaction"
|
|
254
257
|
}
|
|
255
258
|
},
|
|
256
259
|
"quotedAmount": "Quoted amount",
|
|
@@ -278,7 +281,8 @@
|
|
|
278
281
|
"transferId": "Transfer ID",
|
|
279
282
|
"tags": {
|
|
280
283
|
"cheapest": "Best Return",
|
|
281
|
-
"fastest": "Fastest"
|
|
284
|
+
"fastest": "Fastest",
|
|
285
|
+
"gasless": "Gasless"
|
|
282
286
|
},
|
|
283
287
|
"to": "To",
|
|
284
288
|
"tokenOnChain": "{{tokenSymbol}} on {{chainName}}",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Error as ErrorIcon, Info, TurnedIn } from '@mui/icons-material'
|
|
2
|
-
import { LoadingButton } from '@mui/lab'
|
|
3
2
|
import { Button, Typography } from '@mui/material'
|
|
4
3
|
import type { ChangeEvent, MutableRefObject } from 'react'
|
|
5
4
|
import { forwardRef, useState } from 'react'
|
|
@@ -217,7 +216,7 @@ export const BookmarkAddressSheet = forwardRef<
|
|
|
217
216
|
<Button variant="text" onClick={handleCancel} fullWidth>
|
|
218
217
|
{t('button.cancel')}
|
|
219
218
|
</Button>
|
|
220
|
-
<
|
|
219
|
+
<Button
|
|
221
220
|
variant="contained"
|
|
222
221
|
onClick={handleBookmark}
|
|
223
222
|
loading={isValidating}
|
|
@@ -226,7 +225,7 @@ export const BookmarkAddressSheet = forwardRef<
|
|
|
226
225
|
focusRipple
|
|
227
226
|
>
|
|
228
227
|
{t('button.bookmark')}
|
|
229
|
-
</
|
|
228
|
+
</Button>
|
|
230
229
|
</SendToWalletButtonRow>
|
|
231
230
|
</SendToWalletSheetContainer>
|
|
232
231
|
</BottomSheet>
|
|
@@ -5,20 +5,18 @@ import { ChainType, EVM, Solana, UTXO, config } from '@lifi/sdk'
|
|
|
5
5
|
import type { SignerWalletAdapter } from '@solana/wallet-adapter-base'
|
|
6
6
|
import { useWallet } from '@solana/wallet-adapter-react'
|
|
7
7
|
import { useEffect } from 'react'
|
|
8
|
-
import {
|
|
8
|
+
import { useConfig as useWagmiConfig } from 'wagmi'
|
|
9
9
|
import {
|
|
10
10
|
getConnectorClient as getWagmiConnectorClient,
|
|
11
11
|
switchChain,
|
|
12
12
|
} from 'wagmi/actions'
|
|
13
13
|
import { useWidgetConfig } from '../WidgetProvider/WidgetProvider.js'
|
|
14
|
-
import { getSafeMultisigConfig } from './getSafeMultisigConfig.js'
|
|
15
14
|
|
|
16
15
|
export const SDKProviders = () => {
|
|
17
16
|
const { sdkConfig } = useWidgetConfig()
|
|
18
17
|
const { wallet } = useWallet()
|
|
19
18
|
const wagmiConfig = useWagmiConfig()
|
|
20
19
|
const bigmiConfig = useBigmiConfig()
|
|
21
|
-
const account = useAccount({ config: wagmiConfig })
|
|
22
20
|
|
|
23
21
|
useEffect(() => {
|
|
24
22
|
// Configure SDK Providers
|
|
@@ -33,11 +31,6 @@ export const SDKProviders = () => {
|
|
|
33
31
|
(provider) => provider.type === ChainType.UTXO
|
|
34
32
|
)
|
|
35
33
|
if (!hasConfiguredEVMProvider) {
|
|
36
|
-
// TODO: refactor this in favor of EIP-5792: Wallet Call API
|
|
37
|
-
const multisig =
|
|
38
|
-
account.connector?.id === 'safe'
|
|
39
|
-
? getSafeMultisigConfig(account.connector)
|
|
40
|
-
: undefined
|
|
41
34
|
providers.push(
|
|
42
35
|
EVM({
|
|
43
36
|
getWalletClient: () => getWagmiConnectorClient(wagmiConfig),
|
|
@@ -45,7 +38,6 @@ export const SDKProviders = () => {
|
|
|
45
38
|
const chain = await switchChain(wagmiConfig, { chainId })
|
|
46
39
|
return getWagmiConnectorClient(wagmiConfig, { chainId: chain.id })
|
|
47
40
|
},
|
|
48
|
-
multisig,
|
|
49
41
|
})
|
|
50
42
|
)
|
|
51
43
|
}
|
|
@@ -69,13 +61,7 @@ export const SDKProviders = () => {
|
|
|
69
61
|
providers.push(...sdkConfig.providers)
|
|
70
62
|
}
|
|
71
63
|
config.setProviders(providers)
|
|
72
|
-
}, [
|
|
73
|
-
account.connector,
|
|
74
|
-
bigmiConfig,
|
|
75
|
-
sdkConfig?.providers,
|
|
76
|
-
wagmiConfig,
|
|
77
|
-
wallet?.adapter,
|
|
78
|
-
])
|
|
64
|
+
}, [bigmiConfig, sdkConfig?.providers, wagmiConfig, wallet?.adapter])
|
|
79
65
|
|
|
80
66
|
return null
|
|
81
67
|
}
|
|
@@ -18,8 +18,8 @@ export const useExecutingRoutesIds = () => {
|
|
|
18
18
|
)
|
|
19
19
|
.sort(
|
|
20
20
|
(a, b) =>
|
|
21
|
-
(b?.route.steps[0].execution?.process[0]
|
|
22
|
-
(a?.route.steps[0].execution?.process[0]
|
|
21
|
+
(b?.route.steps[0].execution?.process[0]?.startedAt ?? 0) -
|
|
22
|
+
(a?.route.steps[0].execution?.process[0]?.startedAt ?? 0)
|
|
23
23
|
)
|
|
24
24
|
.map(({ route }) => route.id),
|
|
25
25
|
shallow
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { loadingButtonClasses } from '@mui/lab'
|
|
2
|
-
import type {} from '@mui/lab/themeAugmentation'
|
|
3
1
|
import type {
|
|
4
2
|
CSSObject,
|
|
5
3
|
PaletteMode,
|
|
@@ -8,6 +6,7 @@ import type {
|
|
|
8
6
|
} from '@mui/material'
|
|
9
7
|
import {
|
|
10
8
|
alpha,
|
|
9
|
+
buttonClasses,
|
|
11
10
|
createTheme as createMuiTheme,
|
|
12
11
|
css,
|
|
13
12
|
darken,
|
|
@@ -247,19 +246,18 @@ export const createTheme = (
|
|
|
247
246
|
cursor: 'not-allowed',
|
|
248
247
|
pointerEvents: 'auto',
|
|
249
248
|
},
|
|
250
|
-
[`&.${
|
|
249
|
+
[`&.${buttonClasses.loading}.Mui-disabled`]: {
|
|
251
250
|
backgroundColor: primaryMainColor,
|
|
252
251
|
color: contrastButtonColor,
|
|
253
252
|
cursor: 'auto',
|
|
254
253
|
pointerEvents: 'auto',
|
|
255
254
|
},
|
|
256
|
-
[`.${
|
|
255
|
+
[`.${buttonClasses.loadingIndicator}`]: {
|
|
257
256
|
color: contrastButtonColor,
|
|
258
257
|
},
|
|
259
|
-
[`&.${
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
},
|
|
258
|
+
[`&.${buttonClasses.root}.${buttonClasses.loading}`]: {
|
|
259
|
+
color: 'transparent',
|
|
260
|
+
},
|
|
263
261
|
...getStyleOverrides('MuiButton', 'root', widgetTheme, ownerState),
|
|
264
262
|
}),
|
|
265
263
|
text: ({ ownerState }) => ({
|
package/src/themes/types.ts
CHANGED
package/src/types/widget.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
PaletteMode,
|
|
14
14
|
PaletteOptions,
|
|
15
15
|
Shape,
|
|
16
|
+
SxProps,
|
|
16
17
|
Theme,
|
|
17
18
|
} from '@mui/material'
|
|
18
19
|
import type { TypographyOptions } from '@mui/material/styles/createTypography.js'
|
|
@@ -191,6 +192,22 @@ export type WidgetLanguages = {
|
|
|
191
192
|
|
|
192
193
|
export type PoweredByType = 'default' | 'jumper'
|
|
193
194
|
|
|
195
|
+
export interface RouteLabel {
|
|
196
|
+
text: string
|
|
197
|
+
sx?: SxProps<Theme>
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface RouteLabelRule {
|
|
201
|
+
label: RouteLabel
|
|
202
|
+
// Matching criteria
|
|
203
|
+
bridges?: AllowDeny<string>
|
|
204
|
+
exchanges?: AllowDeny<string>
|
|
205
|
+
fromChainId?: number[]
|
|
206
|
+
toChainId?: number[]
|
|
207
|
+
fromTokenAddress?: string[]
|
|
208
|
+
toTokenAddress?: string[]
|
|
209
|
+
}
|
|
210
|
+
|
|
194
211
|
export interface WidgetConfig {
|
|
195
212
|
fromChain?: number
|
|
196
213
|
toChain?: number
|
|
@@ -227,6 +244,7 @@ export interface WidgetConfig {
|
|
|
227
244
|
hiddenUI?: HiddenUIType[]
|
|
228
245
|
requiredUI?: RequiredUIType[]
|
|
229
246
|
useRecommendedRoute?: boolean
|
|
247
|
+
useRelayerRoutes?: boolean
|
|
230
248
|
|
|
231
249
|
walletConfig?: WidgetWalletConfig
|
|
232
250
|
sdkConfig?: WidgetSDKConfig
|
|
@@ -243,6 +261,11 @@ export interface WidgetConfig {
|
|
|
243
261
|
explorerUrls?: Record<number, string[]> &
|
|
244
262
|
Partial<Record<'internal', string[]>>
|
|
245
263
|
poweredBy?: PoweredByType
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Custom labels/badges to show on routes based on specified rules
|
|
267
|
+
*/
|
|
268
|
+
routeLabels?: RouteLabelRule[]
|
|
246
269
|
}
|
|
247
270
|
|
|
248
271
|
export interface FormFieldOptions {
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { MultisigTransaction, MultisigTxDetails } from '@lifi/sdk';
|
|
2
|
-
import type { Connector } from 'wagmi';
|
|
3
|
-
export declare const getSafeMultisigConfig: (connector: Connector) => {
|
|
4
|
-
isMultisigWalletClient: boolean;
|
|
5
|
-
shouldBatchTransactions: boolean;
|
|
6
|
-
sendBatchTransaction: (batchTransactions: MultisigTransaction[]) => Promise<`0x${string}`>;
|
|
7
|
-
getMultisigTransactionDetails: (txHash: string, chainId: number, updateIntermediateStatus?: () => void) => Promise<MultisigTxDetails>;
|
|
8
|
-
};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
var TransactionStatus;
|
|
2
|
-
(function (TransactionStatus) {
|
|
3
|
-
TransactionStatus["AWAITING_CONFIRMATIONS"] = "AWAITING_CONFIRMATIONS";
|
|
4
|
-
TransactionStatus["AWAITING_EXECUTION"] = "AWAITING_EXECUTION";
|
|
5
|
-
TransactionStatus["CANCELLED"] = "CANCELLED";
|
|
6
|
-
TransactionStatus["FAILED"] = "FAILED";
|
|
7
|
-
TransactionStatus["SUCCESS"] = "SUCCESS";
|
|
8
|
-
})(TransactionStatus || (TransactionStatus = {}));
|
|
9
|
-
export const getSafeMultisigConfig = (connector) => {
|
|
10
|
-
const getMultisigTransactionDetails = async (txHash, chainId, updateIntermediateStatus) => {
|
|
11
|
-
const safeAppProvider = (await connector.getProvider());
|
|
12
|
-
const safeProviderSDK = safeAppProvider.sdk;
|
|
13
|
-
const safeTransactionDetails = await safeProviderSDK.txs.getBySafeTxHash(txHash);
|
|
14
|
-
const safeTxHash = safeTransactionDetails.txId;
|
|
15
|
-
const safeApiTransactionResponse = await fetch(`https://safe-client.safe.global/v1/chains/${chainId}/transactions/${safeTxHash}`);
|
|
16
|
-
const safeApiTransactionDetails = await safeApiTransactionResponse.json();
|
|
17
|
-
const nonTerminalStatus = [
|
|
18
|
-
TransactionStatus.SUCCESS,
|
|
19
|
-
TransactionStatus.CANCELLED,
|
|
20
|
-
TransactionStatus.FAILED,
|
|
21
|
-
];
|
|
22
|
-
const isSafeStatusPending = !nonTerminalStatus.includes(safeTransactionDetails.txStatus) &&
|
|
23
|
-
!nonTerminalStatus.includes(safeApiTransactionDetails.txStatus);
|
|
24
|
-
const isAwaitingExecution = [
|
|
25
|
-
safeTransactionDetails.txStatus,
|
|
26
|
-
safeApiTransactionDetails.txStatus,
|
|
27
|
-
].includes(TransactionStatus.AWAITING_EXECUTION);
|
|
28
|
-
if (isAwaitingExecution) {
|
|
29
|
-
updateIntermediateStatus?.();
|
|
30
|
-
}
|
|
31
|
-
if (isSafeStatusPending) {
|
|
32
|
-
await new Promise((resolve) => {
|
|
33
|
-
setTimeout(resolve, 5000);
|
|
34
|
-
});
|
|
35
|
-
return await getMultisigTransactionDetails(txHash, chainId, updateIntermediateStatus);
|
|
36
|
-
}
|
|
37
|
-
if ([
|
|
38
|
-
safeTransactionDetails.txStatus,
|
|
39
|
-
safeApiTransactionDetails.txStatus,
|
|
40
|
-
].includes(TransactionStatus.SUCCESS)) {
|
|
41
|
-
return {
|
|
42
|
-
status: 'DONE',
|
|
43
|
-
txHash: `0x${safeTransactionDetails.txHash?.slice(2)}`,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if ([
|
|
47
|
-
safeTransactionDetails.txStatus,
|
|
48
|
-
safeApiTransactionDetails.txStatus,
|
|
49
|
-
].includes(TransactionStatus.FAILED)) {
|
|
50
|
-
return {
|
|
51
|
-
status: 'FAILED',
|
|
52
|
-
txHash: `0x${safeTransactionDetails.txHash?.slice(2)}`,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if ([
|
|
56
|
-
safeTransactionDetails.txStatus,
|
|
57
|
-
safeApiTransactionDetails.txStatus,
|
|
58
|
-
].includes(TransactionStatus.CANCELLED)) {
|
|
59
|
-
return {
|
|
60
|
-
status: 'CANCELLED',
|
|
61
|
-
txHash: `0x${safeTransactionDetails.txHash?.slice(2)}`,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
if (isSafeStatusPending) {
|
|
65
|
-
return {
|
|
66
|
-
status: 'PENDING',
|
|
67
|
-
txHash: `0x${safeTransactionDetails.txHash?.slice(2)}`,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
status: 'PENDING',
|
|
72
|
-
txHash: `0x${safeTransactionDetails.txHash?.slice(2)}`,
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
const sendBatchTransaction = async (batchTransactions) => {
|
|
76
|
-
const safeAppProvider = (await connector.getProvider());
|
|
77
|
-
const safeProviderSDK = safeAppProvider.sdk;
|
|
78
|
-
try {
|
|
79
|
-
const { safeTxHash } = await safeProviderSDK.txs.send({
|
|
80
|
-
txs: batchTransactions,
|
|
81
|
-
});
|
|
82
|
-
return `0x${safeTxHash.slice(2)}`;
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
throw new Error(error);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
return {
|
|
89
|
-
isMultisigWalletClient: connector?.id === 'safe',
|
|
90
|
-
shouldBatchTransactions: connector?.id === 'safe',
|
|
91
|
-
sendBatchTransaction,
|
|
92
|
-
getMultisigTransactionDetails,
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
//# sourceMappingURL=getSafeMultisigConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3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