@lifi/widget 3.21.3 → 3.22.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/CHANGELOG.md +20 -0
- package/dist/esm/AppProvider.js +2 -3
- package/dist/esm/AppProvider.js.map +1 -1
- package/dist/esm/components/AppContainer.js +23 -22
- package/dist/esm/components/AppContainer.js.map +1 -1
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js +12 -7
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
- package/dist/esm/components/BaseTransactionButton/types.d.ts +2 -0
- package/dist/esm/components/ChainSelect/ChainSelect.js +3 -1
- package/dist/esm/components/ChainSelect/ChainSelect.js.map +1 -1
- package/dist/esm/components/ChainSelect/ChainSelect.style.d.ts +3 -1
- package/dist/esm/components/ChainSelect/ChainSelect.style.js +23 -9
- package/dist/esm/components/ChainSelect/ChainSelect.style.js.map +1 -1
- package/dist/esm/components/Messages/MissingRouteRequiredAccountMessage.d.ts +8 -0
- package/dist/esm/components/Messages/MissingRouteRequiredAccountMessage.js +20 -0
- package/dist/esm/components/Messages/MissingRouteRequiredAccountMessage.js.map +1 -0
- package/dist/esm/components/Messages/WarningMessages.js +3 -0
- package/dist/esm/components/Messages/WarningMessages.js.map +1 -1
- package/dist/esm/components/Messages/useMessageQueue.js +15 -4
- package/dist/esm/components/Messages/useMessageQueue.js.map +1 -1
- package/dist/esm/components/RouteCard/RouteCard.js +3 -3
- package/dist/esm/components/RouteCard/RouteCard.js.map +1 -1
- package/dist/esm/components/TokenList/TokenListItem.js +2 -2
- package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/hooks/useAvailableChains.js +3 -2
- package/dist/esm/hooks/useAvailableChains.js.map +1 -1
- package/dist/esm/hooks/useExplorer.d.ts +0 -1
- package/dist/esm/hooks/useExplorer.js +26 -31
- package/dist/esm/hooks/useExplorer.js.map +1 -1
- package/dist/esm/hooks/useFromTokenSufficiency.js +4 -1
- package/dist/esm/hooks/useFromTokenSufficiency.js.map +1 -1
- package/dist/esm/hooks/useGasRecommendation.js +9 -1
- package/dist/esm/hooks/useGasRecommendation.js.map +1 -1
- package/dist/esm/hooks/useGasSufficiency.js +50 -16
- package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
- package/dist/esm/hooks/useIsBatchingSupported.js +8 -1
- package/dist/esm/hooks/useIsBatchingSupported.js.map +1 -1
- package/dist/esm/hooks/useIsContractAddress.js +1 -1
- package/dist/esm/hooks/useIsContractAddress.js.map +1 -1
- package/dist/esm/hooks/useRouteExecution.js +10 -4
- package/dist/esm/hooks/useRouteExecution.js.map +1 -1
- package/dist/esm/hooks/useRouteRequiredAccountConnection.d.ts +10 -0
- package/dist/esm/hooks/useRouteRequiredAccountConnection.js +45 -0
- package/dist/esm/hooks/useRouteRequiredAccountConnection.js.map +1 -0
- package/dist/esm/hooks/useRoutes.d.ts +1 -1
- package/dist/esm/hooks/useRoutes.js +13 -4
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/hooks/useToAddressRequirements.d.ts +1 -1
- package/dist/esm/hooks/useToAddressRequirements.js +6 -5
- package/dist/esm/hooks/useToAddressRequirements.js.map +1 -1
- package/dist/esm/hooks/useTokenBalance.js +12 -3
- package/dist/esm/hooks/useTokenBalance.js.map +1 -1
- package/dist/esm/hooks/useTokenBalances.js +4 -1
- package/dist/esm/hooks/useTokenBalances.js.map +1 -1
- package/dist/esm/hooks/useTokenSearch.js +5 -2
- package/dist/esm/hooks/useTokenSearch.js.map +1 -1
- package/dist/esm/hooks/useTokens.js +3 -2
- package/dist/esm/hooks/useTokens.js.map +1 -1
- package/dist/esm/hooks/useTools.js +3 -2
- package/dist/esm/hooks/useTools.js.map +1 -1
- package/dist/esm/hooks/useTransactionDetails.js +9 -4
- package/dist/esm/hooks/useTransactionDetails.js.map +1 -1
- package/dist/esm/hooks/useTransactionHistory.js +7 -1
- package/dist/esm/hooks/useTransactionHistory.js.map +1 -1
- package/dist/esm/i18n/en.json +6 -4
- package/dist/esm/pages/MainPage/ReviewButton.js +1 -1
- package/dist/esm/pages/MainPage/ReviewButton.js.map +1 -1
- package/dist/esm/pages/TransactionPage/StartTransactionButton.js +1 -1
- package/dist/esm/pages/TransactionPage/StartTransactionButton.js.map +1 -1
- package/dist/esm/pages/TransactionPage/StatusBottomSheet.js +26 -43
- package/dist/esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
- package/dist/esm/pages/TransactionPage/StatusBottomSheet.style.d.ts +0 -1
- package/dist/esm/pages/TransactionPage/StatusBottomSheet.style.js +4 -11
- package/dist/esm/pages/TransactionPage/StatusBottomSheet.style.js.map +1 -1
- package/dist/esm/providers/QueryClientProvider.d.ts +2 -0
- package/dist/esm/providers/QueryClientProvider.js +9 -0
- package/dist/esm/providers/QueryClientProvider.js.map +1 -0
- package/dist/esm/providers/WalletProvider/SuiBaseProvider.js +3 -8
- package/dist/esm/providers/WalletProvider/SuiBaseProvider.js.map +1 -1
- package/dist/esm/stores/form/FormStore.js +5 -12
- package/dist/esm/stores/form/FormStore.js.map +1 -1
- package/dist/esm/stores/form/useFormRef.js +1 -7
- package/dist/esm/stores/form/useFormRef.js.map +1 -1
- package/dist/esm/types/widget.d.ts +6 -1
- package/dist/esm/utils/queries.d.ts +1 -0
- package/dist/esm/utils/queries.js +2 -0
- package/dist/esm/utils/queries.js.map +1 -0
- package/dist/esm/utils/timer.js +8 -1
- package/dist/esm/utils/timer.js.map +1 -1
- package/package.json +11 -11
- package/package.json.tmp +10 -10
- package/src/AppProvider.tsx +2 -3
- package/src/components/AppContainer.tsx +24 -23
- package/src/components/BaseTransactionButton/BaseTransactionButton.tsx +15 -6
- package/src/components/BaseTransactionButton/types.ts +3 -0
- package/src/components/ChainSelect/ChainSelect.style.tsx +25 -9
- package/src/components/ChainSelect/ChainSelect.tsx +4 -1
- package/src/components/Messages/MissingRouteRequiredAccountMessage.tsx +44 -0
- package/src/components/Messages/WarningMessages.tsx +9 -0
- package/src/components/Messages/useMessageQueue.ts +17 -4
- package/src/components/RouteCard/RouteCard.tsx +3 -3
- package/src/components/TokenList/TokenListItem.tsx +2 -2
- package/src/config/version.ts +1 -1
- package/src/hooks/useAvailableChains.ts +4 -2
- package/src/hooks/useExplorer.ts +35 -36
- package/src/hooks/useFromTokenSufficiency.ts +4 -1
- package/src/hooks/useGasRecommendation.ts +9 -1
- package/src/hooks/useGasSufficiency.ts +76 -22
- package/src/hooks/useIsBatchingSupported.ts +9 -1
- package/src/hooks/useIsContractAddress.ts +1 -1
- package/src/hooks/useRouteExecution.ts +10 -4
- package/src/hooks/useRouteRequiredAccountConnection.ts +58 -0
- package/src/hooks/useRoutes.ts +13 -7
- package/src/hooks/useToAddressRequirements.ts +6 -5
- package/src/hooks/useTokenBalance.ts +12 -3
- package/src/hooks/useTokenBalances.ts +4 -1
- package/src/hooks/useTokenSearch.ts +5 -2
- package/src/hooks/useTokens.ts +3 -2
- package/src/hooks/useTools.ts +3 -2
- package/src/hooks/useTransactionDetails.ts +13 -4
- package/src/hooks/useTransactionHistory.ts +7 -1
- package/src/i18n/en.json +6 -4
- package/src/pages/MainPage/ReviewButton.tsx +1 -0
- package/src/pages/TransactionPage/StartTransactionButton.tsx +1 -0
- package/src/pages/TransactionPage/StatusBottomSheet.style.tsx +4 -12
- package/src/pages/TransactionPage/StatusBottomSheet.tsx +47 -77
- package/src/providers/QueryClientProvider.tsx +20 -0
- package/src/providers/WalletProvider/SuiBaseProvider.tsx +3 -9
- package/src/stores/form/FormStore.tsx +4 -15
- package/src/stores/form/useFormRef.ts +1 -8
- package/src/types/widget.ts +10 -2
- package/src/utils/queries.ts +2 -0
- package/src/utils/timer.ts +8 -1
|
@@ -52,23 +52,15 @@ export const IconCircle = styled(Box, {
|
|
|
52
52
|
return {
|
|
53
53
|
backgroundColor: `rgba(${color} / ${alphaValue})`,
|
|
54
54
|
borderRadius: '50%',
|
|
55
|
-
width:
|
|
56
|
-
height:
|
|
55
|
+
width: 72,
|
|
56
|
+
height: 72,
|
|
57
57
|
display: 'grid',
|
|
58
58
|
position: 'relative',
|
|
59
59
|
placeItems: 'center',
|
|
60
60
|
'& > svg': {
|
|
61
61
|
color: `color-mix(in srgb, rgb(${color}) ${(1 - darkenValue) * 100}%, black)`,
|
|
62
|
-
width:
|
|
63
|
-
height:
|
|
62
|
+
width: 36,
|
|
63
|
+
height: 36,
|
|
64
64
|
},
|
|
65
65
|
}
|
|
66
66
|
})
|
|
67
|
-
|
|
68
|
-
export const MessageSkeletonContainer = styled(Box)(({ theme }) => ({
|
|
69
|
-
display: 'flex',
|
|
70
|
-
flexDirection: 'column',
|
|
71
|
-
height: 64,
|
|
72
|
-
gap: theme.spacing(0.5),
|
|
73
|
-
paddingTop: theme.spacing(1),
|
|
74
|
-
}))
|
|
@@ -2,17 +2,18 @@ import Done from '@mui/icons-material/Done'
|
|
|
2
2
|
import ErrorRounded from '@mui/icons-material/ErrorRounded'
|
|
3
3
|
import InfoRounded from '@mui/icons-material/InfoRounded'
|
|
4
4
|
import WarningRounded from '@mui/icons-material/WarningRounded'
|
|
5
|
-
import { Box, Button,
|
|
5
|
+
import { Box, Button, Typography } from '@mui/material'
|
|
6
6
|
import { useCallback, useEffect, useRef } from 'react'
|
|
7
7
|
import { useTranslation } from 'react-i18next'
|
|
8
8
|
import { BottomSheet } from '../../components/BottomSheet/BottomSheet.js'
|
|
9
9
|
import type { BottomSheetBase } from '../../components/BottomSheet/types.js'
|
|
10
|
+
import { Card } from '../../components/Card/Card.js'
|
|
11
|
+
import { CardTitle } from '../../components/Card/CardTitle.js'
|
|
10
12
|
import { Token } from '../../components/Token/Token.js'
|
|
11
13
|
import { useAvailableChains } from '../../hooks/useAvailableChains.js'
|
|
12
14
|
import { useNavigateBack } from '../../hooks/useNavigateBack.js'
|
|
13
15
|
import { getProcessMessage } from '../../hooks/useProcessMessage.js'
|
|
14
16
|
import { useSetContentHeight } from '../../hooks/useSetContentHeight.js'
|
|
15
|
-
import { useTokenBalance } from '../../hooks/useTokenBalance.js'
|
|
16
17
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
17
18
|
import { useFieldActions } from '../../stores/form/useFieldActions.js'
|
|
18
19
|
import {
|
|
@@ -23,24 +24,12 @@ import { getSourceTxHash } from '../../stores/routes/utils.js'
|
|
|
23
24
|
import { hasEnumFlag } from '../../utils/enum.js'
|
|
24
25
|
import { formatTokenAmount } from '../../utils/format.js'
|
|
25
26
|
import { navigationRoutes } from '../../utils/navigationRoutes.js'
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
CenterContainer,
|
|
29
|
-
IconCircle,
|
|
30
|
-
MessageSkeletonContainer,
|
|
31
|
-
} from './StatusBottomSheet.style.js'
|
|
27
|
+
import { CenterContainer, IconCircle } from './StatusBottomSheet.style.js'
|
|
32
28
|
|
|
33
29
|
interface StatusBottomSheetContentProps extends RouteExecution {
|
|
34
30
|
onClose(): void
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
const MessageSkeleton = () => (
|
|
38
|
-
<MessageSkeletonContainer>
|
|
39
|
-
<Skeleton height={24} variant="text" width="92%" />
|
|
40
|
-
<Skeleton height={24} variant="text" width="56%" />
|
|
41
|
-
</MessageSkeletonContainer>
|
|
42
|
-
)
|
|
43
|
-
|
|
44
33
|
export const StatusBottomSheet: React.FC<RouteExecution> = ({
|
|
45
34
|
status,
|
|
46
35
|
route,
|
|
@@ -97,11 +86,6 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
97
86
|
),
|
|
98
87
|
}
|
|
99
88
|
|
|
100
|
-
const { token, refetch, refetchNewBalance } = useTokenBalance(
|
|
101
|
-
route.toAddress,
|
|
102
|
-
toToken
|
|
103
|
-
)
|
|
104
|
-
|
|
105
89
|
const cleanFields = () => {
|
|
106
90
|
setFieldValue('fromAmount', '')
|
|
107
91
|
setFieldValue('toAmount', '')
|
|
@@ -160,7 +144,7 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
160
144
|
|
|
161
145
|
let title: string | undefined
|
|
162
146
|
let primaryMessage: string | undefined
|
|
163
|
-
let
|
|
147
|
+
let failedMessage: string | undefined
|
|
164
148
|
let handlePrimaryButton = handleDone
|
|
165
149
|
switch (status) {
|
|
166
150
|
case RouteExecutionStatus.Done: {
|
|
@@ -170,14 +154,6 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
170
154
|
`success.title.${subvariantOptions?.custom ?? 'checkout'}Successful`
|
|
171
155
|
)
|
|
172
156
|
: t(`success.title.${transactionType}Successful`)
|
|
173
|
-
if (token) {
|
|
174
|
-
primaryMessage = t('success.message.exchangeSuccessful', {
|
|
175
|
-
amount: formatTokenAmount(token.amount, token.decimals),
|
|
176
|
-
tokenSymbol: token.symbol,
|
|
177
|
-
chainName: getChainById(toToken.chainId)?.name,
|
|
178
|
-
walletAddress: shortenAddress(route.toAddress),
|
|
179
|
-
})
|
|
180
|
-
}
|
|
181
157
|
handlePrimaryButton = handleDone
|
|
182
158
|
break
|
|
183
159
|
}
|
|
@@ -187,14 +163,6 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
187
163
|
tool: route.steps.at(-1)?.toolDetails.name,
|
|
188
164
|
tokenSymbol: route.steps.at(-1)?.action.toToken.symbol,
|
|
189
165
|
})
|
|
190
|
-
if (token) {
|
|
191
|
-
secondaryMessage = t('success.message.exchangeSuccessful', {
|
|
192
|
-
amount: formatTokenAmount(token.amount, token.decimals),
|
|
193
|
-
tokenSymbol: token.symbol,
|
|
194
|
-
chainName: getChainById(toToken.chainId)?.name,
|
|
195
|
-
walletAddress: shortenAddress(route.toAddress),
|
|
196
|
-
})
|
|
197
|
-
}
|
|
198
166
|
handlePrimaryButton = handlePartialDone
|
|
199
167
|
break
|
|
200
168
|
}
|
|
@@ -204,14 +172,6 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
204
172
|
tool: route.steps.at(-1)?.toolDetails.name,
|
|
205
173
|
tokenSymbol: route.steps.at(-1)?.action.toToken.symbol,
|
|
206
174
|
})
|
|
207
|
-
if (token) {
|
|
208
|
-
secondaryMessage = t('success.message.exchangeSuccessful', {
|
|
209
|
-
amount: formatTokenAmount(token.amount, token.decimals),
|
|
210
|
-
tokenSymbol: token.symbol,
|
|
211
|
-
chainName: getChainById(toToken.chainId)?.name,
|
|
212
|
-
walletAddress: shortenAddress(route.toAddress),
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
175
|
break
|
|
216
176
|
}
|
|
217
177
|
case RouteExecutionStatus.Failed: {
|
|
@@ -226,7 +186,7 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
226
186
|
}
|
|
227
187
|
const processMessage = getProcessMessage(t, getChainById, step, process)
|
|
228
188
|
title = processMessage.title
|
|
229
|
-
|
|
189
|
+
failedMessage = processMessage.message
|
|
230
190
|
handlePrimaryButton = handleClose
|
|
231
191
|
break
|
|
232
192
|
}
|
|
@@ -234,14 +194,6 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
234
194
|
break
|
|
235
195
|
}
|
|
236
196
|
|
|
237
|
-
useEffect(() => {
|
|
238
|
-
const hasSuccessFlag = hasEnumFlag(status, RouteExecutionStatus.Done)
|
|
239
|
-
if (hasSuccessFlag) {
|
|
240
|
-
refetchNewBalance()
|
|
241
|
-
refetch()
|
|
242
|
-
}
|
|
243
|
-
}, [refetch, refetchNewBalance, status])
|
|
244
|
-
|
|
245
197
|
const showContractComponent =
|
|
246
198
|
subvariant === 'custom' &&
|
|
247
199
|
hasEnumFlag(status, RouteExecutionStatus.Done) &&
|
|
@@ -289,36 +241,54 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
289
241
|
</CenterContainer>
|
|
290
242
|
{showContractComponent ? (
|
|
291
243
|
contractCompactComponent || contractSecondaryComponent
|
|
292
|
-
) : (
|
|
293
|
-
<CenterContainer>
|
|
294
|
-
{hasEnumFlag(status, RouteExecutionStatus.Done) ? (
|
|
295
|
-
<Token token={toToken} py={1} disableDescription />
|
|
296
|
-
) : null}
|
|
297
|
-
</CenterContainer>
|
|
298
|
-
)}
|
|
299
|
-
{!showContractComponent ? (
|
|
300
|
-
primaryMessage ? (
|
|
301
|
-
<Typography
|
|
302
|
-
sx={{
|
|
303
|
-
py: 1,
|
|
304
|
-
}}
|
|
305
|
-
>
|
|
306
|
-
{primaryMessage}
|
|
307
|
-
</Typography>
|
|
308
|
-
) : (
|
|
309
|
-
<MessageSkeleton />
|
|
310
|
-
)
|
|
311
|
-
) : null}
|
|
312
|
-
{secondaryMessage ? (
|
|
244
|
+
) : hasEnumFlag(status, RouteExecutionStatus.Failed) && failedMessage ? (
|
|
313
245
|
<Typography
|
|
314
246
|
sx={{
|
|
315
247
|
py: 1,
|
|
316
248
|
}}
|
|
317
249
|
>
|
|
318
|
-
{
|
|
250
|
+
{failedMessage}
|
|
319
251
|
</Typography>
|
|
252
|
+
) : hasEnumFlag(status, RouteExecutionStatus.Done) ? (
|
|
253
|
+
<Box
|
|
254
|
+
sx={{
|
|
255
|
+
display: 'flex',
|
|
256
|
+
flexDirection: 'column',
|
|
257
|
+
gap: 2,
|
|
258
|
+
marginTop: 2,
|
|
259
|
+
marginBottom: VcComponent ? 2 : 3,
|
|
260
|
+
}}
|
|
261
|
+
>
|
|
262
|
+
<Card
|
|
263
|
+
sx={{
|
|
264
|
+
display: 'flex',
|
|
265
|
+
flexDirection: 'column',
|
|
266
|
+
gap: 2,
|
|
267
|
+
padding: 2,
|
|
268
|
+
}}
|
|
269
|
+
>
|
|
270
|
+
<CardTitle sx={{ padding: 0 }}>
|
|
271
|
+
{hasEnumFlag(status, RouteExecutionStatus.Refunded)
|
|
272
|
+
? t('header.refunded')
|
|
273
|
+
: t('header.received')}
|
|
274
|
+
</CardTitle>
|
|
275
|
+
<Token token={toToken} disableDescription={false} />
|
|
276
|
+
{primaryMessage && (
|
|
277
|
+
<Typography
|
|
278
|
+
sx={{
|
|
279
|
+
color: 'text.secondary',
|
|
280
|
+
fontSize: '12px',
|
|
281
|
+
lineHeight: '16px',
|
|
282
|
+
fontWeight: 500,
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
{primaryMessage}
|
|
286
|
+
</Typography>
|
|
287
|
+
)}
|
|
288
|
+
</Card>
|
|
289
|
+
{VcComponent ? <VcComponent route={route} /> : null}
|
|
290
|
+
</Box>
|
|
320
291
|
) : null}
|
|
321
|
-
{VcComponent ? <VcComponent route={route} /> : null}
|
|
322
292
|
<Box sx={{ display: 'flex', marginTop: 2, gap: 1.5 }}>
|
|
323
293
|
{hasEnumFlag(status, RouteExecutionStatus.Done) ? (
|
|
324
294
|
<Button variant="text" onClick={handleSeeDetails} fullWidth>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
QueryClientContext as TanstackQueryClientContext,
|
|
3
|
+
QueryClientProvider as TanstackQueryClientProvider,
|
|
4
|
+
} from '@tanstack/react-query'
|
|
5
|
+
import { useContext } from 'react'
|
|
6
|
+
import type { PropsWithChildren } from 'react'
|
|
7
|
+
import { queryClient } from '../config/queryClient'
|
|
8
|
+
|
|
9
|
+
export const QueryClientProvider: React.FC<PropsWithChildren> = ({
|
|
10
|
+
children,
|
|
11
|
+
}) => {
|
|
12
|
+
const existingQueryClient = useContext(TanstackQueryClientContext)
|
|
13
|
+
return existingQueryClient ? (
|
|
14
|
+
children
|
|
15
|
+
) : (
|
|
16
|
+
<TanstackQueryClientProvider client={queryClient}>
|
|
17
|
+
{children}
|
|
18
|
+
</TanstackQueryClientProvider>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -13,17 +13,11 @@ export const SuiBaseProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
|
13
13
|
|
|
14
14
|
const config = useMemo(() => {
|
|
15
15
|
const sui = chains?.find((chain) => chain.id === ChainId.SUI)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})
|
|
20
|
-
}
|
|
16
|
+
return createNetworkConfig({
|
|
17
|
+
mainnet: { url: sui?.metamask?.rpcUrls[0] ?? getFullnodeUrl('mainnet') },
|
|
18
|
+
})
|
|
21
19
|
}, [chains])
|
|
22
20
|
|
|
23
|
-
if (!config?.networkConfig) {
|
|
24
|
-
return null
|
|
25
|
-
}
|
|
26
|
-
|
|
27
21
|
return (
|
|
28
22
|
<SuiClientProvider networks={config.networkConfig} defaultNetwork="mainnet">
|
|
29
23
|
<WalletProvider
|
|
@@ -2,7 +2,6 @@ import type { PropsWithChildren } from 'react'
|
|
|
2
2
|
import { useMemo, useRef } from 'react'
|
|
3
3
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
4
4
|
import type { FormRef, ToAddress } from '../../types/widget.js'
|
|
5
|
-
import { HiddenUI } from '../../types/widget.js'
|
|
6
5
|
import { FormStoreContext } from './FormStoreContext.js'
|
|
7
6
|
import { FormUpdater } from './FormUpdater.js'
|
|
8
7
|
import { createFormStore, formDefaultValues } from './createFormStore.js'
|
|
@@ -14,8 +13,7 @@ const initialiseDefaultValues = (
|
|
|
14
13
|
defaultValues: Partial<DefaultValues>,
|
|
15
14
|
fromAmount?: number | string,
|
|
16
15
|
toAmount?: number | string,
|
|
17
|
-
toAddress?: ToAddress
|
|
18
|
-
hiddenToAddress?: boolean
|
|
16
|
+
toAddress?: ToAddress
|
|
19
17
|
) => ({
|
|
20
18
|
...formDefaultValues,
|
|
21
19
|
...defaultValues,
|
|
@@ -26,9 +24,7 @@ const initialiseDefaultValues = (
|
|
|
26
24
|
(typeof toAmount === 'number' ? toAmount?.toPrecision() : toAmount) ||
|
|
27
25
|
formDefaultValues.toAmount,
|
|
28
26
|
// Prevent setting address when the field is hidden
|
|
29
|
-
toAddress:
|
|
30
|
-
? formDefaultValues.toAddress
|
|
31
|
-
: toAddress?.address || formDefaultValues.toAddress,
|
|
27
|
+
toAddress: toAddress?.address || formDefaultValues.toAddress,
|
|
32
28
|
})
|
|
33
29
|
|
|
34
30
|
interface FormStoreProviderProps extends PropsWithChildren {
|
|
@@ -49,14 +45,11 @@ export const FormStoreProvider: React.FC<FormStoreProviderProps> = ({
|
|
|
49
45
|
fromAmount,
|
|
50
46
|
toAmount,
|
|
51
47
|
toAddress,
|
|
52
|
-
hiddenUI,
|
|
53
48
|
formUpdateKey,
|
|
54
49
|
} = widgetConfig
|
|
55
50
|
|
|
56
51
|
const storeRef = useRef<FormStoreStore>(null)
|
|
57
52
|
|
|
58
|
-
const hiddenToAddress = hiddenUI?.includes(HiddenUI.ToAddress)
|
|
59
|
-
|
|
60
53
|
const configHasFromChain = Object.hasOwn(widgetConfig, 'fromChain')
|
|
61
54
|
const configHasFromToken = Object.hasOwn(widgetConfig, 'fromToken')
|
|
62
55
|
const configHasFromAmount = Object.hasOwn(widgetConfig, 'fromAmount')
|
|
@@ -93,9 +86,7 @@ export const FormStoreProvider: React.FC<FormStoreProviderProps> = ({
|
|
|
93
86
|
...(configHasToToken ? { toToken } : undefined),
|
|
94
87
|
...(configHasToAddress
|
|
95
88
|
? {
|
|
96
|
-
toAddress:
|
|
97
|
-
? formDefaultValues.toAddress
|
|
98
|
-
: toAddress?.address || formDefaultValues.toAddress,
|
|
89
|
+
toAddress: toAddress?.address || formDefaultValues.toAddress,
|
|
99
90
|
}
|
|
100
91
|
: undefined),
|
|
101
92
|
}),
|
|
@@ -104,7 +95,6 @@ export const FormStoreProvider: React.FC<FormStoreProviderProps> = ({
|
|
|
104
95
|
toAmount,
|
|
105
96
|
fromChain,
|
|
106
97
|
fromToken,
|
|
107
|
-
hiddenToAddress,
|
|
108
98
|
toAddress,
|
|
109
99
|
toChain,
|
|
110
100
|
toToken,
|
|
@@ -126,8 +116,7 @@ export const FormStoreProvider: React.FC<FormStoreProviderProps> = ({
|
|
|
126
116
|
reactiveFormValues,
|
|
127
117
|
fromAmount,
|
|
128
118
|
toAmount,
|
|
129
|
-
toAddress
|
|
130
|
-
hiddenToAddress
|
|
119
|
+
toAddress
|
|
131
120
|
)
|
|
132
121
|
)
|
|
133
122
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { useImperativeHandle } from 'react'
|
|
2
|
-
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
3
2
|
import { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'
|
|
4
3
|
import { formDefaultValues } from '../../stores/form/createFormStore.js'
|
|
5
4
|
import { useSendToWalletActions } from '../../stores/settings/useSendToWalletStore.js'
|
|
6
5
|
import type { FormRef } from '../../types/widget.js'
|
|
7
|
-
import { HiddenUI } from '../../types/widget.js'
|
|
8
6
|
import type { FormStoreStore, GenericFormValue } from './types.js'
|
|
9
7
|
|
|
10
8
|
export const useFormRef = (formStore: FormStoreStore, formRef?: FormRef) => {
|
|
11
9
|
const { setSendToWallet } = useSendToWalletActions()
|
|
12
10
|
const { setSelectedBookmark } = useBookmarkActions()
|
|
13
|
-
const { hiddenUI } = useWidgetConfig()
|
|
14
11
|
|
|
15
12
|
useImperativeHandle(
|
|
16
13
|
formRef,
|
|
@@ -25,10 +22,6 @@ export const useFormRef = (formStore: FormStoreStore, formRef?: FormRef) => {
|
|
|
25
22
|
(typeof value === 'number' ? value?.toPrecision() : value) ||
|
|
26
23
|
formDefaultValues.toAmount,
|
|
27
24
|
toAddress: (value) => {
|
|
28
|
-
if (hiddenUI?.includes(HiddenUI.ToAddress)) {
|
|
29
|
-
return formDefaultValues.toAddress
|
|
30
|
-
}
|
|
31
|
-
|
|
32
25
|
const isToAddressObj = typeof value !== 'string'
|
|
33
26
|
|
|
34
27
|
const address =
|
|
@@ -68,6 +61,6 @@ export const useFormRef = (formStore: FormStoreStore, formRef?: FormRef) => {
|
|
|
68
61
|
},
|
|
69
62
|
}
|
|
70
63
|
},
|
|
71
|
-
[formStore,
|
|
64
|
+
[formStore, setSendToWallet, setSelectedBookmark]
|
|
72
65
|
)
|
|
73
66
|
}
|
package/src/types/widget.ts
CHANGED
|
@@ -240,6 +240,14 @@ export interface RouteLabelRule {
|
|
|
240
240
|
toTokenAddress?: string[]
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
export type ExplorerUrl =
|
|
244
|
+
| string
|
|
245
|
+
| {
|
|
246
|
+
url: string
|
|
247
|
+
txPath?: string
|
|
248
|
+
addressPath?: string
|
|
249
|
+
}
|
|
250
|
+
|
|
243
251
|
export interface WidgetConfig {
|
|
244
252
|
fromChain?: number
|
|
245
253
|
toChain?: number
|
|
@@ -291,8 +299,8 @@ export interface WidgetConfig {
|
|
|
291
299
|
tokens?: WidgetTokens
|
|
292
300
|
languages?: WidgetLanguages
|
|
293
301
|
languageResources?: LanguageResources
|
|
294
|
-
explorerUrls?: Record<number,
|
|
295
|
-
Partial<Record<'internal',
|
|
302
|
+
explorerUrls?: Record<number, ExplorerUrl[]> &
|
|
303
|
+
Partial<Record<'internal', ExplorerUrl[]>>
|
|
296
304
|
poweredBy?: PoweredByType
|
|
297
305
|
|
|
298
306
|
/**
|
package/src/utils/timer.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const formatTimer = ({
|
|
|
12
12
|
locale?: string
|
|
13
13
|
}): string => {
|
|
14
14
|
if (typeof (Intl as any).DurationFormat === 'function') {
|
|
15
|
-
|
|
15
|
+
const time = new (Intl as any).DurationFormat(locale, {
|
|
16
16
|
style: 'digital',
|
|
17
17
|
hours: '2-digit',
|
|
18
18
|
hoursDisplay: 'auto',
|
|
@@ -22,6 +22,13 @@ export const formatTimer = ({
|
|
|
22
22
|
minutes,
|
|
23
23
|
seconds,
|
|
24
24
|
})
|
|
25
|
+
// This handles a fixed bug with Webkit, and Safari
|
|
26
|
+
// https://github.com/WebKit/WebKit/pull/38357
|
|
27
|
+
// https://developer.apple.com/documentation/safari-release-notes/safari-18_4-release-notes#JavaScript
|
|
28
|
+
//
|
|
29
|
+
// Since most users haven't updated their browsers yet, they would have this issue
|
|
30
|
+
// it should be safe to remove the check after a while.
|
|
31
|
+
return time.replace(/^:, /, '')
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
return ''
|