@openocean.finance/widget 1.0.20 → 1.0.22

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 (149) hide show
  1. package/dist/esm/App.js +3 -1
  2. package/dist/esm/App.js.map +1 -1
  3. package/dist/esm/AppDrawer.style.d.ts +1 -1
  4. package/dist/esm/components/ActiveTransactions/ActiveTransactions.style.d.ts +2 -2
  5. package/dist/esm/components/AmountInput/AmountInput.js +12 -8
  6. package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
  7. package/dist/esm/components/AmountInput/AmountInput.style.d.ts +3 -3
  8. package/dist/esm/components/AmountInput/AmountInput.style.js +2 -2
  9. package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -1
  10. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +2 -2
  11. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
  12. package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
  13. package/dist/esm/components/AppContainer.d.ts +1 -1
  14. package/dist/esm/components/Avatar/Avatar.style.d.ts +1 -1
  15. package/dist/esm/components/Avatar/SmallAvatar.d.ts +1 -1
  16. package/dist/esm/components/ButtonTertiary.d.ts +1 -1
  17. package/dist/esm/components/Card/CardHeader.d.ts +1 -1
  18. package/dist/esm/components/Card/CardIconButton.d.ts +1 -1
  19. package/dist/esm/components/Card/InputCard.d.ts +1 -1
  20. package/dist/esm/components/ChainSelect/useChainSelect.d.ts +1 -2
  21. package/dist/esm/components/ContractComponent/NFT/NFT.style.d.ts +1 -1
  22. package/dist/esm/components/Header/Header.style.d.ts +2 -2
  23. package/dist/esm/components/Header/SettingsButton.style.d.ts +2 -2
  24. package/dist/esm/components/ListItem/ListItem.d.ts +1 -1
  25. package/dist/esm/components/Messages/GasSufficiencyMessageBridge.js +2 -1
  26. package/dist/esm/components/Messages/GasSufficiencyMessageBridge.js.map +1 -1
  27. package/dist/esm/components/Messages/PriceImpactHighMessage.js.map +1 -1
  28. package/dist/esm/components/Messages/WarningMessages.js.map +1 -1
  29. package/dist/esm/components/PageContainer.d.ts +1 -1
  30. package/dist/esm/components/PoweredBy/PoweredBy.js +1 -1
  31. package/dist/esm/components/PoweredBy/PoweredBy.js.map +1 -1
  32. package/dist/esm/components/ProgressToNextUpdate.js.map +1 -1
  33. package/dist/esm/components/RouteCard/RouteCard.js.map +1 -1
  34. package/dist/esm/components/Search/SearchInput.style.d.ts +1 -1
  35. package/dist/esm/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
  36. package/dist/esm/components/SendToWallet/SendToWallet.style.d.ts +1 -1
  37. package/dist/esm/components/Skeleton/WidgetSkeleton.style.d.ts +3 -3
  38. package/dist/esm/components/Step/StepList.d.ts +1 -1
  39. package/dist/esm/components/StepActions/StepActions.style.d.ts +1 -1
  40. package/dist/esm/components/StepDivider/StepDivider.style.d.ts +1 -1
  41. package/dist/esm/components/Tabs/Tabs.style.d.ts +2 -2
  42. package/dist/esm/components/TokenList/TokenList.style.d.ts +2 -2
  43. package/dist/esm/components/TransactionDetails.js +9 -7
  44. package/dist/esm/components/TransactionDetails.js.map +1 -1
  45. package/dist/esm/config/defaultChainIds.d.ts +1 -0
  46. package/dist/esm/config/defaultChainIds.js +39 -0
  47. package/dist/esm/config/defaultChainIds.js.map +1 -0
  48. package/dist/esm/config/version.d.ts +1 -1
  49. package/dist/esm/config/version.js +1 -1
  50. package/dist/esm/hooks/useAvailableChains.d.ts +1 -1
  51. package/dist/esm/hooks/useAvailableChains.js +51 -7
  52. package/dist/esm/hooks/useAvailableChains.js.map +1 -1
  53. package/dist/esm/hooks/useChain.d.ts +1 -1
  54. package/dist/esm/hooks/useChains.d.ts +1 -1
  55. package/dist/esm/hooks/useGasPrice.js +2 -1
  56. package/dist/esm/hooks/useGasPrice.js.map +1 -1
  57. package/dist/esm/hooks/useGasRecommendation.d.ts +1 -1
  58. package/dist/esm/hooks/useGasRefuel.d.ts +3 -3
  59. package/dist/esm/hooks/useGasSufficiency.d.ts +1 -1
  60. package/dist/esm/hooks/useGasSufficiencyBridge.js +1 -1
  61. package/dist/esm/hooks/useGasSufficiencyBridge.js.map +1 -1
  62. package/dist/esm/hooks/useIsBatchingSupported.d.ts +1 -1
  63. package/dist/esm/hooks/useLanguages.d.ts +2 -2
  64. package/dist/esm/hooks/useRouteExecution.d.ts +1 -1
  65. package/dist/esm/hooks/useRoutes.d.ts +3 -3
  66. package/dist/esm/hooks/useRoutes.js +2 -2
  67. package/dist/esm/hooks/useRoutes.js.map +1 -1
  68. package/dist/esm/hooks/useToAddressRequirements.d.ts +2 -2
  69. package/dist/esm/hooks/useTokenAddressBalance.d.ts +1 -1
  70. package/dist/esm/hooks/useTokenBalance.d.ts +1 -1
  71. package/dist/esm/hooks/useTokenBalances.d.ts +1 -1
  72. package/dist/esm/hooks/useTokens.d.ts +1 -1
  73. package/dist/esm/hooks/useTokens.js.map +1 -1
  74. package/dist/esm/hooks/useTools.d.ts +1 -2
  75. package/dist/esm/hooks/useTransactionDetails.d.ts +1 -2
  76. package/dist/esm/hooks/useTransactionHistory.d.ts +0 -1
  77. package/dist/esm/i18n/en.json +3 -3
  78. package/dist/esm/pages/MainPage/MainPage.style.d.ts +1 -1
  79. package/dist/esm/pages/MainPage/ReviewButton.js.map +1 -1
  80. package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js.map +1 -1
  81. package/dist/esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
  82. package/dist/esm/pages/SendToWallet/SendToWalletPage.style.d.ts +7 -7
  83. package/dist/esm/pages/SettingsPage/SettingsCard/SettingCard.style.d.ts +1 -1
  84. package/dist/esm/pages/TransactionPage/StartTransactionButton.js.map +1 -1
  85. package/dist/esm/pages/TransactionPage/StatusBottomSheet.js +1 -1
  86. package/dist/esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
  87. package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.js.map +1 -1
  88. package/dist/esm/pages/TransactionPage/TransactionPage.js +1 -1
  89. package/dist/esm/pages/TransactionPage/TransactionPage.js.map +1 -1
  90. package/dist/esm/providers/WidgetProvider/WidgetProvider.js +1 -1
  91. package/dist/esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
  92. package/dist/esm/services/DebridgeService.js +1 -1
  93. package/dist/esm/services/DebridgeService.js.map +1 -1
  94. package/dist/esm/services/ExecuteRoute.d.ts +1 -2
  95. package/dist/esm/services/ExecuteRoute.js.map +1 -1
  96. package/dist/esm/stores/bookmarks/createBookmarkStore.js.map +1 -1
  97. package/dist/esm/stores/chains/createChainOrderStore.js +1 -1
  98. package/dist/esm/stores/chains/createChainOrderStore.js.map +1 -1
  99. package/dist/esm/stores/form/useFieldController.d.ts +1 -1
  100. package/dist/esm/stores/routes/createRouteExecutionStore.js.map +1 -1
  101. package/dist/esm/stores/routes/useExecutingRoutesIds.d.ts +1 -1
  102. package/dist/esm/stores/routes/useSetExecutableRoute.d.ts +1 -1
  103. package/dist/esm/stores/routes/utils.d.ts +6 -6
  104. package/dist/esm/stores/settings/useSettingsStore.js.map +1 -1
  105. package/dist/esm/themes/createTheme.js +1 -1
  106. package/dist/esm/themes/createTheme.js.map +1 -1
  107. package/dist/esm/types/widget.d.ts +4 -0
  108. package/dist/esm/utils/chainType.d.ts +5 -5
  109. package/dist/tsconfig.tsbuildinfo +1 -1
  110. package/package.json +3 -3
  111. package/src/App.tsx +8 -1
  112. package/src/components/AmountInput/AmountInput.style.tsx +2 -2
  113. package/src/components/AmountInput/AmountInput.tsx +25 -12
  114. package/src/components/AmountInput/AmountInputEndAdornment.tsx +2 -2
  115. package/src/components/AmountInput/PriceFormHelperText.tsx +1 -1
  116. package/src/components/Messages/GasSufficiencyMessageBridge.tsx +2 -0
  117. package/src/components/Messages/PriceImpactHighMessage.tsx +2 -2
  118. package/src/components/Messages/WarningMessages.tsx +1 -1
  119. package/src/components/PoweredBy/PoweredBy.tsx +1 -1
  120. package/src/components/ProgressToNextUpdate.tsx +1 -1
  121. package/src/components/RouteCard/RouteCard.tsx +0 -1
  122. package/src/components/TransactionDetails.tsx +9 -9
  123. package/src/config/defaultChainIds.ts +38 -0
  124. package/src/config/version.ts +1 -1
  125. package/src/hooks/useAvailableChains.ts +53 -8
  126. package/src/hooks/useGasPrice.ts +2 -1
  127. package/src/hooks/useGasSufficiencyBridge.ts +2 -2
  128. package/src/hooks/useRoutes.ts +2 -2
  129. package/src/hooks/useTokenSearch.ts +1 -1
  130. package/src/hooks/useTokens.ts +3 -3
  131. package/src/i18n/en.json +3 -3
  132. package/src/i18n/i18next.d.ts +30 -0
  133. package/src/index.ts +1 -1
  134. package/src/pages/MainPage/ReviewButton.tsx +1 -1
  135. package/src/pages/SendToWallet/BookmarkAddressSheet.tsx +1 -1
  136. package/src/pages/SendToWallet/SendToWalletPage.tsx +2 -2
  137. package/src/pages/TransactionPage/StartTransactionButton.tsx +1 -1
  138. package/src/pages/TransactionPage/StatusBottomSheet.tsx +1 -1
  139. package/src/pages/TransactionPage/TokenValueBottomSheet.tsx +2 -2
  140. package/src/pages/TransactionPage/TransactionPage.tsx +1 -1
  141. package/src/providers/WidgetProvider/WidgetProvider.tsx +1 -1
  142. package/src/services/DebridgeService.ts +1 -1
  143. package/src/services/ExecuteRoute.ts +2 -2
  144. package/src/stores/bookmarks/createBookmarkStore.ts +7 -7
  145. package/src/stores/chains/createChainOrderStore.ts +2 -2
  146. package/src/stores/routes/createRouteExecutionStore.ts +1 -1
  147. package/src/stores/settings/useSettingsStore.ts +1 -1
  148. package/src/themes/createTheme.ts +1 -1
  149. package/src/types/widget.ts +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/widget",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "Openocean Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
@@ -47,8 +47,8 @@
47
47
  "@mui/icons-material": "6.0.2",
48
48
  "@mui/material": "^6.4.8",
49
49
  "@mui/system": "^6.4.8",
50
- "@openocean.finance/wallet-management": "^1.0.9",
51
- "@openocean.finance/widget-sdk": "^1.0.6",
50
+ "@openocean.finance/wallet-management": "^1.0.11",
51
+ "@openocean.finance/widget-sdk": "^1.0.8",
52
52
  "@solana/wallet-adapter-base": "^0.9.24",
53
53
  "@solana/web3.js": "^1.98.0",
54
54
  "@tanstack/react-virtual": "^3.13.4",
package/src/App.tsx CHANGED
@@ -8,7 +8,14 @@ import type { WidgetConfig, WidgetProps } from './types/widget.js'
8
8
 
9
9
  export const App = forwardRef<WidgetDrawer, WidgetProps>((props, ref) => {
10
10
  const config: WidgetConfig = useMemo(() => {
11
- const config = { ...props, ...props.config }
11
+ const widgetConfig = { ...props, ...props.config }
12
+ const {
13
+ fromChain = widgetConfig.defaultChain,
14
+ fromToken = widgetConfig.defaultFromToken,
15
+ toChain = widgetConfig.defaultChain,
16
+ toToken = widgetConfig.defaultToToken,
17
+ } = widgetConfig
18
+ const config = { ...widgetConfig, fromChain, fromToken, toChain, toToken }
12
19
  if (config.variant === 'drawer') {
13
20
  config.theme = {
14
21
  ...config.theme,
@@ -6,8 +6,8 @@ import {
6
6
  styled,
7
7
  } from '@mui/material'
8
8
 
9
- export const maxInputFontSize = 24
10
- export const minInputFontSize = 14
9
+ export const maxInputFontSize = 22
10
+ export const minInputFontSize = 12
11
11
 
12
12
  export const FormContainer = styled(Box)(({ theme }) => ({
13
13
  display: 'flex',
@@ -80,17 +80,30 @@ export const AmountInputBase: React.FC<
80
80
  const amountKey = FormKeyHelper.getAmountKey(formType)
81
81
  const { onChange, onBlur, value } = useFieldController({ name: amountKey })
82
82
  inputValue = value || ''
83
- if (formType === 'to') {
84
- const { routes } = useRoutes()
85
- if (routes) {
86
- const router = routes[0] || { toAmount: 0, toToken: { decimals: 18 } }
87
- inputValue = formatTokenAmount(
88
- BigInt(router.toAmount),
89
- router.toToken.decimals
90
- )
91
- inputValue = t('format.tokenAmount', {
92
- value: inputValue,
93
- })
83
+
84
+
85
+ const {
86
+ routes,
87
+ isLoading,
88
+ isFetching,
89
+ isFetched,
90
+ dataUpdatedAt,
91
+ refetchTime,
92
+ refetch,
93
+ } = useRoutes()
94
+
95
+ if(formType === 'to'){
96
+ const router = routes?.[0]
97
+ if (
98
+ router &&
99
+ router.toAmount !== undefined &&
100
+ router.toAmount !== null &&
101
+ router.toToken &&
102
+ typeof router.toToken.decimals === 'number'
103
+ ) {
104
+ inputValue = String(formatTokenAmount(BigInt(router.toAmount), router.toToken.decimals))
105
+ } else {
106
+ inputValue = ''
94
107
  }
95
108
  }
96
109
 
@@ -116,7 +129,7 @@ export const AmountInputBase: React.FC<
116
129
  if (ref.current) {
117
130
  fitInputText(maxInputFontSize, minInputFontSize, ref.current)
118
131
  }
119
- }, [value])
132
+ }, [value, inputValue, routes])
120
133
 
121
134
  const title =
122
135
  subvariant === 'custom'
@@ -127,7 +127,7 @@ export const AmountInputEndAdornment = ({ formType }: FormTypeProps) => {
127
127
  (1.15 * Number(prependedOperatingExpenseCost)).toString()
128
128
  )
129
129
  )
130
- if (chain?.nativeToken.address === fromTokenAddress) {
130
+ if (chain?.nativeToken?.address === fromTokenAddress) {
131
131
  if (fromChainId === 1151111081099710) {
132
132
  gas += 15000000n + (8157120n + 4000000n + 890880n)
133
133
  } else if (fromChainId === 8453) {
@@ -138,7 +138,7 @@ export const AmountInputEndAdornment = ({ formType }: FormTypeProps) => {
138
138
 
139
139
  if (state === 'swap' || fromChainId === toChainId) {
140
140
  if (
141
- chain?.nativeToken.address === fromTokenAddress &&
141
+ chain?.nativeToken?.address === fromTokenAddress &&
142
142
  data?.recommended
143
143
  ) {
144
144
  gas = BigInt(data.recommended.amount) / 2n
@@ -47,7 +47,7 @@ export const PriceFormHelperTextBase: React.FC<
47
47
  BigInt(router.toAmount),
48
48
  router.toToken.decimals
49
49
  )
50
- toTokenPrice = formatTokenPrice(toAmount, router.toToken.priceUSD)
50
+ toTokenPrice = formatTokenPrice(toAmount, (router.toToken as any).priceUSD)
51
51
  }
52
52
  } else {
53
53
  }
@@ -1,6 +1,7 @@
1
1
  import { type BoxProps, Typography } from '@mui/material'
2
2
  import { useTranslation } from 'react-i18next'
3
3
  import { AlertMessage } from './AlertMessage.js'
4
+ import { Warning as WarningIcon } from '@mui/icons-material'
4
5
 
5
6
  interface GasSufficiencyMessageProps extends BoxProps {
6
7
  // insufficientGas?: GasSufficiency[]
@@ -12,6 +13,7 @@ export const GasSufficiencyMessageBridge: React.FC<
12
13
  const { t } = useTranslation()
13
14
  return (
14
15
  <AlertMessage
16
+ icon={<WarningIcon />}
15
17
  severity="warning"
16
18
  title={
17
19
  <Typography
@@ -16,10 +16,10 @@ export const PriceImpactHighMessage: React.FC<PriceImpactHighMessageProps> = ({
16
16
  ...props
17
17
  }) => {
18
18
  const acknowledged = useStorePriceImpactAcknowledged(
19
- (state) => state.priceImpactAcknowledged
19
+ (state) => (state as any).priceImpactAcknowledged
20
20
  )
21
21
  const setAcknowledged = useStorePriceImpactAcknowledged(
22
- (state) => state.setPriceImpactAcknowledged
22
+ (state) => (state as any).setPriceImpactAcknowledged
23
23
  )
24
24
 
25
25
  const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
@@ -25,7 +25,7 @@ export const WarningMessages: React.FC<WarningMessagesProps> = ({
25
25
  }) => {
26
26
  const { messages, hasMessages } = useMessageQueue(route, allowInteraction)
27
27
  const setPriceImpactAcknowledged = useStorePriceImpactAcknowledged(
28
- (state) => state.setPriceImpactAcknowledged
28
+ (state) => (state as any).setPriceImpactAcknowledged
29
29
  )
30
30
  const getMessage = () => {
31
31
  switch (messages[0]?.id) {
@@ -25,7 +25,7 @@ export const PoweredBy: React.FC = () => {
25
25
  flex: 1,
26
26
  display: 'flex',
27
27
  alignItems: 'flex-end',
28
- justifyContent: 'flex-end',
28
+ justifyContent: 'center',
29
29
  }}
30
30
  >
31
31
  <Tooltip title={`v${version}`} enterDelay={1000}>
@@ -43,7 +43,7 @@ export const ProgressToNextUpdate: React.FC<
43
43
  <Tooltip
44
44
  title={
45
45
  <Trans
46
- i18nKey="tooltip.progressToNextUpdate"
46
+ i18nKey={"tooltip.progressToNextUpdate" as any}
47
47
  values={{
48
48
  value: getSecondsToUpdate(updatedAt, timeToUpdate),
49
49
  }}
@@ -37,7 +37,6 @@ export const RouteCard: React.FC<
37
37
  e.stopPropagation()
38
38
  setCardExpanded((expanded) => !expanded)
39
39
  }
40
-
41
40
  const token: TokenAmount =
42
41
  subvariant === 'custom' && subvariantOptions?.custom !== 'deposit'
43
42
  ? { ...route.fromToken, amount: BigInt(route.fromAmount) }
@@ -34,7 +34,7 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
34
34
  const { chain } = useChain(fromChainId)
35
35
  const [state] = useSplitSubvariantStore((storeState) => [storeState.state])
36
36
  const isBradge = route ? fromChainId !== toChainId : state === 'bridge'
37
- const { token } = useToken(fromChainId, chain?.nativeToken.address)
37
+ const { token } = useToken(fromChainId, chain?.nativeToken?.address)
38
38
  const { gasPrice } = useGasPrice(fromChainId?.toString() || '')
39
39
 
40
40
  if (!route) {
@@ -61,7 +61,7 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
61
61
  fromAmountMin: 0,
62
62
  estimatedGas: 0,
63
63
  steps: [],
64
- }
64
+ } as unknown as RouteExtended
65
65
  }
66
66
  const toggleCard = () => {
67
67
  setCardExpanded((cardExpanded) => !cardExpanded)
@@ -69,16 +69,18 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
69
69
 
70
70
  let gasCostUSD = 0
71
71
  const feeCosts = []
72
- const estimatedGas = route?.estimatedGas || route?.data?.estimatedGas
72
+ const combinedFeesUSD = gasCostUSD + feeCosts.reduce((sum, fee) => sum + fee.costUSD, 0)
73
+ const feeCostUSD = feeCosts.reduce((sum, fee) => sum + fee.costUSD, 0)
74
+ const estimatedGas = (route as any)?.estimatedGas || (route as any)?.data?.estimatedGas
73
75
  if (token && gasPrice && estimatedGas) {
74
76
  const d = 10 ** token.decimals
75
77
  gasCostUSD =
76
78
  Number(token.priceUSD) * ((Number(gasPrice) * Number(estimatedGas)) / d)
77
79
  }
78
- if (isBradge && route?.data?.prependedOperatingExpenseCost) {
80
+ if (isBradge && (route as any)?.data?.prependedOperatingExpenseCost) {
79
81
  const decimals = 10 ** route.fromToken.decimals
80
82
  gasCostUSD =
81
- (route.data.prependedOperatingExpenseCost / decimals) *
83
+ ((route as any).data.prependedOperatingExpenseCost / decimals) *
82
84
  Number(route.fromToken.priceUSD)
83
85
  }
84
86
 
@@ -225,13 +227,11 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
225
227
  <Typography variant="body2" color="text.secondary">
226
228
  {t('main.fees.provider')}
227
229
  </Typography>
228
- <Typography variant="body2" sx={{ fontWeight: 600 }}>
229
- {feeCostUSD
230
+ {feeCostUSD
230
231
  ? t('format.currency', {
231
232
  value: feeCostUSD,
232
233
  })
233
234
  : '--'}
234
- </Typography>
235
235
  </Box>
236
236
  ) : null}
237
237
  {showIntegratorFeeCollectionDetails ? (
@@ -336,7 +336,7 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
336
336
  value: formatTokenAmount(
337
337
  typeof route.toAmountMin === 'string' &&
338
338
  !route.toAmountMin.includes('e')
339
- ? BigInt(Math.floor(route.toAmountMin))
339
+ ? BigInt(Math.floor(Number(route.toAmountMin)))
340
340
  : BigInt(0),
341
341
  route.toToken.decimals
342
342
  ),
@@ -0,0 +1,38 @@
1
+ export const DEFAULT_CHAIN_IDS = [
2
+ 1, // Ethereum Mainnet
3
+ 56, // BNB Chain
4
+ 42161, // Arbitrum
5
+ 10, // Optimism
6
+ 324, // zkSync Era
7
+ 137, // Polygon Mainnet
8
+ 43114, // Avalanche
9
+ 250, // Fantom
10
+ 146, // Sonic
11
+ 80094, // Berachain
12
+ 8453, // Base
13
+ 59144, // Linea Mainnet
14
+ 534352, // Scroll
15
+ 81457, // Blast
16
+ 34443, // Mode
17
+ 5000, // Mantle
18
+ 130, // UniChain
19
+ 14, // Flare
20
+ 1923, // Swellchain
21
+ 169, // Manta Pacific
22
+ 1101, // Polygon zkEVM
23
+ 40, // Telos
24
+ 100, // Gnosis Mainnet
25
+ 30, // Rootstock
26
+ 2222, // Kava
27
+ 1329, // Sei
28
+ 1088, // Metis
29
+ 204, // opBNB
30
+ 42220, // Celo
31
+ 1625, // Gravity
32
+ 33139, // ApeChain
33
+ 25, // Cronos Mainnet
34
+ 1313161554, // Aurora Mainnet
35
+ 1285, // Moonriver
36
+ 1666600000, // Harmony Mainnet
37
+ 10143, // Monad Testnet
38
+ ];
@@ -1,2 +1,2 @@
1
1
  export const name = '@openocean.finance/widget'
2
- export const version = '1.0.20'
2
+ export const version = '1.0.22'
@@ -4,13 +4,15 @@ import { useQuery } from '@tanstack/react-query'
4
4
  import { useCallback } from 'react'
5
5
  import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'
6
6
  import { isItemAllowed } from '../utils/item.js'
7
+ import { CoinKey } from '../index.js'
8
+ import { DEFAULT_CHAIN_IDS } from '../config/defaultChainIds.js';
7
9
 
8
10
  export type GetChainById = (
9
11
  chainId?: number,
10
12
  chains?: ExtendedChain[]
11
13
  ) => ExtendedChain | undefined
12
14
 
13
- const supportedChainTypes = [ChainType.EVM, ChainType.SVM, ChainType.UTXO]
15
+ const supportedChainTypes: ChainType[] = [ChainType.EVM, ChainType.SVM, ChainType.UTXO]
14
16
 
15
17
  export const useAvailableChains = (chainTypes?: ChainType[]) => {
16
18
  const { chains } = useWidgetConfig()
@@ -30,11 +32,57 @@ export const useAvailableChains = (chainTypes?: ChainType[]) => {
30
32
  // providers.length > 0 ? providers : supportedChainTypes
31
33
  .filter((chainType) => isItemAllowed(chainType, chainTypesConfig))
32
34
 
33
- const availableChains = await getChains({
34
- chainTypes: chainTypes || chainTypesRequest,
35
+ let availableChains = await getChains()
36
+ // allow chains "starknet","aptos","near","ont","sui",
37
+ const allowedChainsIds = chains?.allow?.length ? chains.allow : DEFAULT_CHAIN_IDS;
38
+ const allowedChains = availableChains.filter((chain) => {
39
+ if (allowedChainsIds.indexOf(chain.id) >= 0) {
40
+ return true
41
+ }
42
+ return false
35
43
  })
36
- config.setChains(availableChains)
37
- return availableChains
44
+ /*
45
+ allowedChains.push({
46
+ "key":"eth",
47
+ "chainType":ChainType.EVM,
48
+ "name":"Ethereum",
49
+ "coin":CoinKey.WETH,
50
+ "id":1,
51
+ "mainnet":true,
52
+ "logoURI":"https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/ethereum.svg",
53
+ "tokenlistUrl":"https://gateway.ipfs.io/ipns/tokens.uniswap.org",
54
+ "multicallAddress":"0xcA11bde05977b3631167028862bE2a173976CA11",
55
+ "relayerSupported":false,
56
+ "metamask":{
57
+ "chainId":"0x1",
58
+ "blockExplorerUrls":["https://etherscan.io/"],
59
+ "chainName":"Ethereum Mainnet",
60
+ "nativeCurrency":{
61
+ "name":"ETH",
62
+ "symbol":"ETH",
63
+ "decimals":18
64
+ },
65
+ "rpcUrls":[
66
+ "https://ethereum-rpc.publicnode.com",
67
+ "https://eth.drpc.org"
68
+ ]
69
+ },
70
+ "nativeToken":{
71
+ "address":"0x0000000000000000000000000000000000000000",
72
+ "chainId":1,"symbol":
73
+ "ETH","decimals":18,
74
+ "name":"ETH",
75
+ "coinKey":"ETH",
76
+ "logoURI":"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png",
77
+ "priceUSD":"3804.11"
78
+ },
79
+ "diamondAddress":"0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE",
80
+ "permit2":"0x000000000022D473030F116dDEE9F6B43aC78BA3",
81
+ "permit2Proxy":"0x89c6340B1a1f4b25D36cd8B063D49045caF3f818"
82
+ })
83
+ */
84
+ config.setChains(allowedChains)
85
+ return allowedChains
38
86
  },
39
87
  refetchInterval: 300_000,
40
88
  staleTime: 300_000,
@@ -46,9 +94,6 @@ export const useAvailableChains = (chainTypes?: ChainType[]) => {
46
94
  return
47
95
  }
48
96
  const chain = chains?.find((chain) => chain.id === chainId)
49
- // if (!chain) {
50
- // throw new Error('Chain not found or chainId is invalid.');
51
- // }
52
97
  return chain
53
98
  },
54
99
  [data]
@@ -13,8 +13,9 @@ export const useGasPrice = (chainName: string) => {
13
13
  queryKey: ['gasPrice'],
14
14
  queryFn: () => OpenOceanService.getGasPrice(chainName.toLowerCase()),
15
15
  })
16
+ const _gasPrice = data?.[gasKey[gasPrice || 'Normal']]
16
17
  return {
17
- gasPrice: data?.[gasKey[gasPrice || 'Normal']],
18
+ gasPrice: _gasPrice && _gasPrice.maxFeePerGas,
18
19
  isLoading,
19
20
  }
20
21
  }
@@ -49,13 +49,13 @@ export const useGasSufficiencyBridge = (route?: RouteExtended) => {
49
49
 
50
50
  if (route.fromChainId !== route.toChainId) {
51
51
  const prependedOperatingExpenseCost =
52
- route.data.prependedOperatingExpenseCost || 0n
52
+ (route as any).data.prependedOperatingExpenseCost || 0n
53
53
  let gas = BigInt(
54
54
  Number.parseInt(
55
55
  (1.1 * Number(prependedOperatingExpenseCost)).toString()
56
56
  )
57
57
  )
58
- if (chain?.nativeToken.address === fromTokenAddress) {
58
+ if (chain?.nativeToken?.address === fromTokenAddress) {
59
59
  if (fromChainId === 1151111081099710) {
60
60
  gas += 15000000n + (8157120n + 4000000n + 890880n)
61
61
  } else if (fromChainId === 8453) {
@@ -340,7 +340,7 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
340
340
  (isDebridge
341
341
  ? data?.to
342
342
  : '0x6352a56caadC4F1E25CD6c75970Fa768A3304e64'),
343
- executionDuration: data?.executionDuration || 300_000,
343
+ executionDuration: data?.executionDuration || Math.floor(Math.random() * 20) + 40,
344
344
  tool: isDebridge ? 'debridge' : 'openocean',
345
345
  feeCosts: data?.feeCosts || [
346
346
  {
@@ -357,7 +357,7 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
357
357
  includedSteps: [],
358
358
  },
359
359
  ],
360
- data: data,
360
+ ...(data as any),
361
361
  }
362
362
  const routes = [route]
363
363
  emitter.emit(WidgetEvent.AvailableRoutes, routes)
@@ -1,4 +1,4 @@
1
- import type { TokensRee } from '@openocean.finance/widget-sdk'
1
+ import type { TokensResponse } from '@openocean.finance/widget-sdk'
2
2
  import { useQuery, useQueryClient } from '@tanstack/react-query'
3
3
  import { OpenOceanService } from '../services/OpenOceanService.js'
4
4
  import type { TokenAmount } from '../types/token.js'
@@ -86,11 +86,11 @@ export const useTokens = (selectedChainId?: number) => {
86
86
  token[tokenType] = true
87
87
  // Check if this token exists in the filteredTokensMap and add priceUSD if it does
88
88
  const matchingFilteredToken = filteredTokensMap.get(token.address)
89
- if (matchingFilteredToken?.priceUSD) {
90
- token.priceUSD = matchingFilteredToken.priceUSD
89
+ if ((matchingFilteredToken as any)?.priceUSD) {
90
+ (token as any).priceUSD = (matchingFilteredToken as any).priceUSD
91
91
  }
92
92
  if (!token.logoURI && matchingFilteredToken) {
93
- token.logoURI = matchingFilteredToken.logoURI
93
+ (token as any).logoURI = (matchingFilteredToken as any).logoURI
94
94
  }
95
95
  return token as TokenAmount
96
96
  })
package/src/i18n/en.json CHANGED
@@ -61,8 +61,8 @@
61
61
  "deposit": "Deposit",
62
62
  "depositDetails": "Deposit details",
63
63
  "depositTo": "Deposit to",
64
- "exchange": "Exchange",
65
- "from": "Exchange from",
64
+ "exchange": "Swap",
65
+ "from": "Swap from",
66
66
  "gas": "Gas",
67
67
  "payWith": "Pay with",
68
68
  "receive": "Receive",
@@ -73,7 +73,7 @@
73
73
  "sendToWallet": "Send to wallet",
74
74
  "settings": "Settings",
75
75
  "swap": "Swap",
76
- "to": "Exchange to",
76
+ "to": "Swap to",
77
77
  "transactionDetails": "Transaction details",
78
78
  "transactionHistory": "Transaction history",
79
79
  "walletConnected": "Wallet connected",
@@ -1,10 +1,40 @@
1
+ import 'i18next'
2
+ import 'react-i18next'
1
3
  import en from './en.json' with { type: 'json' }
2
4
 
3
5
  const defaultResource = { translation: en }
4
6
 
7
+ // Completely override i18next module
5
8
  declare module 'i18next' {
6
9
  interface CustomTypeOptions {
7
10
  defaultNS: 'translation'
8
11
  resources: typeof defaultResource
12
+ keySeparator?: false
13
+ }
14
+
15
+ // Override the t function to accept any string
16
+ function t(key: string, options?: any): string;
17
+
18
+ // Override TFunction type
19
+ type TFunction = (key: string, options?: any) => string;
20
+ }
21
+
22
+ // Completely override react-i18next module
23
+ declare module 'react-i18next' {
24
+ // Override useTranslation hook
25
+ function useTranslation(): {
26
+ t: (key: string, options?: any) => string
27
+ i18n: any
28
+ ready: boolean
29
+ // ...other hooks
30
+ }
31
+
32
+ // Override TFunction type
33
+ type TFunction = (key: string, options?: any) => string;
34
+
35
+ // Override other related types
36
+ interface UseTranslationOptions {
37
+ keyPrefix?: string
38
+ ns?: string | string[]
9
39
  }
10
40
  }
package/src/index.ts CHANGED
@@ -28,4 +28,4 @@ export { getPriceImpact } from './utils/getPriceImpact.js'
28
28
  export { percentFormatter } from './utils/percentFormatter.js'
29
29
  export { compactNumberFormatter } from './utils/compactNumberFormatter.js'
30
30
  export { currencyExtendedFormatter } from './utils/currencyExtendedFormatter.js'
31
- export { navigationRoutes } from './utils/navigationRoutes.js'
31
+ export { navigationRoutes } from './utils/navigationRoutes.js'
@@ -26,7 +26,7 @@ export const ReviewButton: React.FC = () => {
26
26
 
27
27
  const { messages } = useMessageQueue(currentRoute)
28
28
  const priceImpactAcknowledged = useStorePriceImpactAcknowledged(
29
- (state) => state.priceImpactAcknowledged
29
+ (state) => (state as any).priceImpactAcknowledged
30
30
  )
31
31
 
32
32
  let hasMessages = messages.length > 0
@@ -54,7 +54,7 @@ export const BookmarkAddressSheet = forwardRef<
54
54
  const validateWithAddressFromInput = async () => {
55
55
  const validationResult = await validateAddress({ value: address })
56
56
  if (!validationResult.isValid) {
57
- setError({ type: 'address', message: validationResult.error })
57
+ setError({ type: 'address', message: (validationResult as any).error })
58
58
  return
59
59
  }
60
60
 
@@ -97,7 +97,7 @@ export const SendToWalletPage = () => {
97
97
  })
98
98
  setIsDoneButtonLoading(false)
99
99
  if (!validationResult.isValid) {
100
- setErrorMessage(validationResult.error)
100
+ setErrorMessage((validationResult as any).error)
101
101
  return
102
102
  }
103
103
 
@@ -159,7 +159,7 @@ export const SendToWalletPage = () => {
159
159
  })
160
160
  bookmarkAddressSheetRef.current?.open()
161
161
  } else {
162
- setErrorMessage(validationResult.error)
162
+ setErrorMessage((validationResult as any).error)
163
163
  }
164
164
  }
165
165
 
@@ -13,7 +13,7 @@ export const StartTransactionButton: React.FC<StartTransactionButtonProps> = ({
13
13
  }) => {
14
14
  const { messages, isLoading } = useMessageQueue(route)
15
15
  const priceImpactAcknowledged = useStorePriceImpactAcknowledged(
16
- (state) => state.priceImpactAcknowledged
16
+ (state) => (state as any).priceImpactAcknowledged
17
17
  )
18
18
 
19
19
  let hasMessages = messages.length > 0
@@ -56,7 +56,7 @@ export const StatusBottomSheet: React.FC<RouteExecution> = ({
56
56
  useEffect(() => {
57
57
  const hasSuccessFlag = hasEnumFlag(status, RouteExecutionStatus.Done)
58
58
  const hasFailedFlag = hasEnumFlag(status, RouteExecutionStatus.Failed)
59
- if ((hasSuccessFlag || hasFailedFlag) && !ref.current?.isOpen()) {
59
+ if ((hasSuccessFlag || hasFailedFlag) && !(ref.current?.isOpen?.() as unknown as boolean)) {
60
60
  ref.current?.open()
61
61
  }
62
62
  }, [status])
@@ -58,10 +58,10 @@ const TokenValueBottomSheetContent: React.FC<TokenValueBottomSheetProps> = ({
58
58
  const toAmountUSD = Number.parseFloat(route.toAmountUSD)
59
59
  const hasGaslessSupport = route.steps.some(isGaslessStep)
60
60
 
61
- if (isBradge && route?.data?.prependedOperatingExpenseCost) {
61
+ if (isBradge && (route as any)?.data?.prependedOperatingExpenseCost) {
62
62
  const decimals = 10 ** route.fromToken.decimals
63
63
  gasCostUSD =
64
- (route.data.prependedOperatingExpenseCost / decimals) *
64
+ ((route as any).data.prependedOperatingExpenseCost / decimals) *
65
65
  Number(route.fromToken.priceUSD)
66
66
  }
67
67
 
@@ -109,7 +109,7 @@ export const TransactionPage: React.FC = () => {
109
109
  }
110
110
 
111
111
  const handleExecuteRoute = () => {
112
- if (tokenValueBottomSheetRef.current?.isOpen()) {
112
+ if (tokenValueBottomSheetRef.current?.isOpen?.() as unknown as boolean) {
113
113
  const { gasCostUSD, feeCostUSD } = getAccumulatedFeeCostsBreakdown(route)
114
114
  const fromAmountUSD = Number.parseFloat(route.fromAmountUSD)
115
115
  const toAmountUSD = Number.parseFloat(route.toAmountUSD)
@@ -45,7 +45,7 @@ export const WidgetProvider: React.FC<
45
45
  integrator: widgetConfig.integrator ?? window?.location.hostname,
46
46
  routeOptions: {
47
47
  fee: widgetConfig.feeConfig?.fee || widgetConfig.fee,
48
- referrer: widgetConfig.referrer,
48
+ referrer: widgetConfig.referrer?.address,
49
49
  order: widgetConfig.routePriority,
50
50
  slippage: widgetConfig.slippage,
51
51
  ...widgetConfig.sdkConfig?.routeOptions,
@@ -482,7 +482,7 @@ export class DebridgeService {
482
482
  // Estimate details
483
483
  approveContract: to, // Approval needed for the Debridge contract
484
484
  // executionDuration: approximateFulfillmentDelay ? approximateFulfillmentDelay * 1000 : 300000, // Convert seconds to ms? Needs verification. Defaulting to 5min.
485
- executionDuration: 300_000, // Hardcoding 5min for now, Debridge delay unit unclear.
485
+ executionDuration: 0, // Hardcoding 5min for now, Debridge delay unit unclear.
486
486
  // Fee details
487
487
  feeCosts: finalFeeToken
488
488
  ? [