@lifi/widget 3.32.0 → 3.32.2

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/esm/config/constants.d.ts +1 -1
  3. package/dist/esm/config/constants.js +1 -1
  4. package/dist/esm/config/constants.js.map +1 -1
  5. package/dist/esm/config/version.d.ts +1 -1
  6. package/dist/esm/config/version.js +1 -1
  7. package/dist/esm/hooks/useExplorer.js +2 -2
  8. package/dist/esm/hooks/useExplorer.js.map +1 -1
  9. package/dist/esm/hooks/useFilteredByTokenBalances.js +1 -0
  10. package/dist/esm/hooks/useFilteredByTokenBalances.js.map +1 -1
  11. package/dist/esm/i18n/bn.json +4 -2
  12. package/dist/esm/i18n/de.json +4 -2
  13. package/dist/esm/i18n/es.json +4 -2
  14. package/dist/esm/i18n/fr.json +4 -2
  15. package/dist/esm/i18n/hi.json +4 -2
  16. package/dist/esm/i18n/id.json +4 -2
  17. package/dist/esm/i18n/it.json +4 -2
  18. package/dist/esm/i18n/ja.json +4 -2
  19. package/dist/esm/i18n/ko.json +4 -2
  20. package/dist/esm/i18n/pl.json +4 -2
  21. package/dist/esm/i18n/pt.json +4 -2
  22. package/dist/esm/i18n/th.json +4 -2
  23. package/dist/esm/i18n/tr.json +4 -2
  24. package/dist/esm/i18n/uk.json +4 -2
  25. package/dist/esm/i18n/vi.json +4 -2
  26. package/dist/esm/i18n/zh.json +4 -2
  27. package/dist/esm/pages/TransactionDetailsPage/TransactionDetailsPage.js +14 -2
  28. package/dist/esm/pages/TransactionDetailsPage/TransactionDetailsPage.js.map +1 -1
  29. package/dist/esm/pages/TransactionDetailsPage/TransferIdCard.d.ts +2 -1
  30. package/dist/esm/pages/TransactionDetailsPage/TransferIdCard.js +3 -9
  31. package/dist/esm/pages/TransactionDetailsPage/TransferIdCard.js.map +1 -1
  32. package/dist/esm/types/widget.d.ts +2 -3
  33. package/dist/esm/utils/converters.js +5 -0
  34. package/dist/esm/utils/converters.js.map +1 -1
  35. package/dist/esm/utils/format.js +6 -1
  36. package/dist/esm/utils/format.js.map +1 -1
  37. package/package.json +4 -5
  38. package/package.json.tmp +3 -4
  39. package/src/config/constants.ts +1 -1
  40. package/src/config/version.ts +1 -1
  41. package/src/hooks/useExplorer.ts +2 -2
  42. package/src/hooks/useFilteredByTokenBalances.ts +1 -0
  43. package/src/i18n/bn.json +4 -2
  44. package/src/i18n/de.json +4 -2
  45. package/src/i18n/es.json +4 -2
  46. package/src/i18n/fr.json +4 -2
  47. package/src/i18n/hi.json +4 -2
  48. package/src/i18n/id.json +4 -2
  49. package/src/i18n/it.json +4 -2
  50. package/src/i18n/ja.json +4 -2
  51. package/src/i18n/ko.json +4 -2
  52. package/src/i18n/pl.json +4 -2
  53. package/src/i18n/pt.json +4 -2
  54. package/src/i18n/th.json +4 -2
  55. package/src/i18n/tr.json +4 -2
  56. package/src/i18n/uk.json +4 -2
  57. package/src/i18n/vi.json +4 -2
  58. package/src/i18n/zh.json +4 -2
  59. package/src/pages/TransactionDetailsPage/TransactionDetailsPage.tsx +25 -5
  60. package/src/pages/TransactionDetailsPage/TransferIdCard.tsx +8 -13
  61. package/src/types/widget.ts +2 -2
  62. package/src/utils/converters.ts +5 -0
  63. package/src/utils/format.ts +7 -1
@@ -5,28 +5,21 @@ import { useTranslation } from 'react-i18next'
5
5
  import { Card } from '../../components/Card/Card.js'
6
6
  import { CardIconButton } from '../../components/Card/CardIconButton.js'
7
7
  import { CardTitle } from '../../components/Card/CardTitle.js'
8
- import { useExplorer } from '../../hooks/useExplorer.js'
9
8
 
10
9
  interface TransferIdCardProps {
11
10
  transferId: string
11
+ txLink?: string
12
12
  }
13
13
 
14
- const getTxHash = (transferId: string) =>
15
- transferId.indexOf('_') !== -1
16
- ? transferId.substring(0, transferId.indexOf('_'))
17
- : transferId
18
-
19
- export const TransferIdCard = ({ transferId }: TransferIdCardProps) => {
14
+ export const TransferIdCard = ({ transferId, txLink }: TransferIdCardProps) => {
20
15
  const { t } = useTranslation()
21
- const { getTransactionLink } = useExplorer()
22
16
 
23
17
  const copyTransferId = async () => {
24
18
  await navigator.clipboard.writeText(transferId)
25
19
  }
26
20
 
27
21
  const openTransferIdInExplorer = () => {
28
- const txHash = getTxHash(transferId)
29
- window.open(getTransactionLink({ txHash }), '_blank')
22
+ window.open(txLink, '_blank')
30
23
  }
31
24
 
32
25
  return (
@@ -49,9 +42,11 @@ export const TransferIdCard = ({ transferId }: TransferIdCardProps) => {
49
42
  <CardIconButton size="small" onClick={copyTransferId}>
50
43
  <ContentCopyRounded fontSize="inherit" />
51
44
  </CardIconButton>
52
- <CardIconButton size="small" onClick={openTransferIdInExplorer}>
53
- <OpenInNew fontSize="inherit" />
54
- </CardIconButton>
45
+ {txLink ? (
46
+ <CardIconButton size="small" onClick={openTransferIdInExplorer}>
47
+ <OpenInNew fontSize="inherit" />
48
+ </CardIconButton>
49
+ ) : null}
55
50
  </Box>
56
51
  </Box>
57
52
  <Typography
@@ -21,12 +21,12 @@ import type {
21
21
  Theme,
22
22
  } from '@mui/material'
23
23
  import type { TypographyVariantsOptions } from '@mui/material/styles'
24
- import type { Config as PortoConfig } from 'porto/Porto'
25
24
  import type { CSSProperties, FC, ReactNode, RefObject } from 'react'
26
25
  import type {
27
26
  BaseAccountParameters,
28
27
  CoinbaseWalletParameters,
29
28
  MetaMaskParameters,
29
+ PortoParameters,
30
30
  WalletConnectParameters,
31
31
  } from 'wagmi/connectors'
32
32
  import type {
@@ -142,7 +142,7 @@ export interface WidgetWalletConfig {
142
142
  coinbase?: CoinbaseWalletParameters
143
143
  metaMask?: MetaMaskParameters
144
144
  baseAccount?: BaseAccountParameters
145
- porto?: Partial<PortoConfig>
145
+ porto?: Partial<PortoParameters>
146
146
  /**
147
147
  * Determines whether the widget should provide partial wallet management functionality.
148
148
  *
@@ -30,6 +30,7 @@ const buildProcessFromTxHistory = (tx: FullStatusData): Process[] => {
30
30
  startedAt: sending.timestamp ?? Date.now(),
31
31
  message: '',
32
32
  status: processStatus,
33
+ chainId: sending.chainId,
33
34
  txHash: sending.txHash,
34
35
  txLink: sending.txLink,
35
36
  doneAt: receiving.timestamp ?? Date.now(),
@@ -45,6 +46,7 @@ const buildProcessFromTxHistory = (tx: FullStatusData): Process[] => {
45
46
  startedAt: sending.timestamp ?? Date.now(),
46
47
  message: '',
47
48
  status: processStatus, // can be FAILED
49
+ chainId: sending.chainId,
48
50
  txHash: sending.txHash,
49
51
  txLink: sending.txLink,
50
52
  doneAt: sending.timestamp,
@@ -57,6 +59,7 @@ const buildProcessFromTxHistory = (tx: FullStatusData): Process[] => {
57
59
  substatus,
58
60
  substatusMessage: '',
59
61
  doneAt: receiving.timestamp ?? Date.now(),
62
+ chainId: receiving.chainId,
60
63
  txHash: receiving.txHash,
61
64
  txLink: receiving.txLink,
62
65
  },
@@ -211,6 +214,8 @@ export const buildRouteFromTxHistory = (
211
214
  fromAmount: sending.amount,
212
215
  toAmount: receiving.amount,
213
216
  toToken: receiving.token,
217
+ internalTxLink: tx.lifiExplorerLink,
218
+ externalTxLink: tx.bridgeExplorerLink,
214
219
  gasCosts: [
215
220
  {
216
221
  amount: sending.gasAmount,
@@ -54,7 +54,11 @@ export function formatInputAmount(
54
54
  return amount
55
55
  }
56
56
  let formattedAmount = amount.trim().replaceAll(',', '.')
57
- if (formattedAmount.startsWith('.')) {
57
+ if (
58
+ returnInitial &&
59
+ formattedAmount.startsWith('.') &&
60
+ !Number.parseFloat(formattedAmount)
61
+ ) {
58
62
  formattedAmount = `0${formattedAmount}`
59
63
  }
60
64
  const parsedAmount = Number.parseFloat(formattedAmount)
@@ -66,6 +70,8 @@ export function formatInputAmount(
66
70
  }
67
71
  if (returnInitial) {
68
72
  return formattedAmount
73
+ } else if (formattedAmount.startsWith('.')) {
74
+ formattedAmount = `0${formattedAmount}`
69
75
  }
70
76
  let [integer, fraction = ''] = formattedAmount.split('.')
71
77
  if (decimals !== null && fraction.length > decimals) {