@openocean.finance/widget 1.0.19 → 1.0.21

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 (144) 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 +11 -7
  6. package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
  7. package/dist/esm/components/AmountInput/AmountInput.style.d.ts +1 -1
  8. package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -1
  9. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +2 -2
  10. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
  11. package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
  12. package/dist/esm/components/AppContainer.d.ts +1 -1
  13. package/dist/esm/components/Avatar/Avatar.style.d.ts +1 -1
  14. package/dist/esm/components/Avatar/SmallAvatar.d.ts +1 -1
  15. package/dist/esm/components/ButtonTertiary.d.ts +1 -1
  16. package/dist/esm/components/Card/CardHeader.d.ts +1 -1
  17. package/dist/esm/components/Card/CardIconButton.d.ts +1 -1
  18. package/dist/esm/components/Card/InputCard.d.ts +1 -1
  19. package/dist/esm/components/ContractComponent/NFT/NFT.style.d.ts +1 -1
  20. package/dist/esm/components/Header/Header.style.d.ts +2 -2
  21. package/dist/esm/components/Header/NavigationTabs.js +2 -0
  22. package/dist/esm/components/Header/NavigationTabs.js.map +1 -1
  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/ServeErrorMessage.d.ts +6 -0
  29. package/dist/esm/components/Messages/ServeErrorMessage.js +10 -0
  30. package/dist/esm/components/Messages/ServeErrorMessage.js.map +1 -0
  31. package/dist/esm/components/Messages/WarningMessages.js +3 -0
  32. package/dist/esm/components/Messages/WarningMessages.js.map +1 -1
  33. package/dist/esm/components/Messages/useMessageQueue.js +10 -0
  34. package/dist/esm/components/Messages/useMessageQueue.js.map +1 -1
  35. package/dist/esm/components/PageContainer.d.ts +1 -1
  36. package/dist/esm/components/PoweredBy/PoweredBy.js +1 -1
  37. package/dist/esm/components/PoweredBy/PoweredBy.js.map +1 -1
  38. package/dist/esm/components/ProgressToNextUpdate.js.map +1 -1
  39. package/dist/esm/components/RouteCard/RouteCard.js.map +1 -1
  40. package/dist/esm/components/Search/SearchInput.style.d.ts +1 -1
  41. package/dist/esm/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
  42. package/dist/esm/components/SendToWallet/SendToWallet.style.d.ts +1 -1
  43. package/dist/esm/components/Skeleton/WidgetSkeleton.style.d.ts +3 -3
  44. package/dist/esm/components/StepActions/StepActions.style.d.ts +1 -1
  45. package/dist/esm/components/StepDivider/StepDivider.style.d.ts +1 -1
  46. package/dist/esm/components/Tabs/Tabs.style.d.ts +2 -2
  47. package/dist/esm/components/TokenList/TokenList.style.d.ts +2 -2
  48. package/dist/esm/components/TransactionDetails.js +9 -7
  49. package/dist/esm/components/TransactionDetails.js.map +1 -1
  50. package/dist/esm/config/defaultChainIds.d.ts +1 -0
  51. package/dist/esm/config/defaultChainIds.js +39 -0
  52. package/dist/esm/config/defaultChainIds.js.map +1 -0
  53. package/dist/esm/config/version.d.ts +1 -1
  54. package/dist/esm/config/version.js +1 -1
  55. package/dist/esm/hooks/useAvailableChains.js +51 -7
  56. package/dist/esm/hooks/useAvailableChains.js.map +1 -1
  57. package/dist/esm/hooks/useChain.d.ts +1 -1
  58. package/dist/esm/hooks/useGasPrice.js +2 -1
  59. package/dist/esm/hooks/useGasPrice.js.map +1 -1
  60. package/dist/esm/hooks/useGasRefuel.d.ts +1 -1
  61. package/dist/esm/hooks/useGasSufficiencyBridge.js +1 -1
  62. package/dist/esm/hooks/useGasSufficiencyBridge.js.map +1 -1
  63. package/dist/esm/hooks/useLanguages.d.ts +2 -2
  64. package/dist/esm/hooks/useRoutes.js +3 -1
  65. package/dist/esm/hooks/useRoutes.js.map +1 -1
  66. package/dist/esm/hooks/useTokenAddressBalance.d.ts +1 -1
  67. package/dist/esm/hooks/useTokens.d.ts +1 -1
  68. package/dist/esm/hooks/useTokens.js.map +1 -1
  69. package/dist/esm/i18n/en.json +3 -3
  70. package/dist/esm/pages/MainPage/MainPage.style.d.ts +1 -1
  71. package/dist/esm/pages/MainPage/ReviewButton.js.map +1 -1
  72. package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js.map +1 -1
  73. package/dist/esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
  74. package/dist/esm/pages/SendToWallet/SendToWalletPage.style.d.ts +7 -7
  75. package/dist/esm/pages/SettingsPage/SettingsCard/SettingCard.style.d.ts +1 -1
  76. package/dist/esm/pages/TransactionPage/StartTransactionButton.js.map +1 -1
  77. package/dist/esm/pages/TransactionPage/StatusBottomSheet.js +1 -1
  78. package/dist/esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
  79. package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.js.map +1 -1
  80. package/dist/esm/pages/TransactionPage/TransactionPage.js +1 -1
  81. package/dist/esm/pages/TransactionPage/TransactionPage.js.map +1 -1
  82. package/dist/esm/providers/WidgetProvider/WidgetProvider.js +1 -1
  83. package/dist/esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
  84. package/dist/esm/services/DebridgeService.js +3 -0
  85. package/dist/esm/services/DebridgeService.js.map +1 -1
  86. package/dist/esm/services/ExecuteRoute.d.ts +1 -2
  87. package/dist/esm/services/ExecuteRoute.js.map +1 -1
  88. package/dist/esm/stores/bookmarks/createBookmarkStore.js.map +1 -1
  89. package/dist/esm/stores/chains/createChainOrderStore.js +1 -1
  90. package/dist/esm/stores/chains/createChainOrderStore.js.map +1 -1
  91. package/dist/esm/stores/form/useFieldController.d.ts +1 -1
  92. package/dist/esm/stores/routes/createRouteExecutionStore.js.map +1 -1
  93. package/dist/esm/stores/routes/useSetExecutableRoute.d.ts +1 -1
  94. package/dist/esm/stores/settings/useSettingsStore.js.map +1 -1
  95. package/dist/esm/stores/useServerErrorStore.d.ts +4 -0
  96. package/dist/esm/stores/useServerErrorStore.js +6 -0
  97. package/dist/esm/stores/useServerErrorStore.js.map +1 -0
  98. package/dist/esm/themes/createTheme.js +1 -1
  99. package/dist/esm/themes/createTheme.js.map +1 -1
  100. package/dist/esm/types/widget.d.ts +4 -0
  101. package/package.json +3 -3
  102. package/src/App.tsx +8 -1
  103. package/src/components/AmountInput/AmountInput.tsx +21 -11
  104. package/src/components/AmountInput/AmountInputEndAdornment.tsx +2 -2
  105. package/src/components/AmountInput/PriceFormHelperText.tsx +1 -1
  106. package/src/components/Header/NavigationTabs.tsx +2 -0
  107. package/src/components/Messages/GasSufficiencyMessageBridge.tsx +2 -0
  108. package/src/components/Messages/PriceImpactHighMessage.tsx +2 -2
  109. package/src/components/Messages/ServeErrorMessage.tsx +31 -0
  110. package/src/components/Messages/WarningMessages.tsx +4 -1
  111. package/src/components/Messages/useMessageQueue.ts +13 -0
  112. package/src/components/PoweredBy/PoweredBy.tsx +1 -1
  113. package/src/components/ProgressToNextUpdate.tsx +1 -1
  114. package/src/components/RouteCard/RouteCard.tsx +0 -1
  115. package/src/components/TransactionDetails.tsx +9 -9
  116. package/src/config/defaultChainIds.ts +38 -0
  117. package/src/config/version.ts +1 -1
  118. package/src/hooks/useAvailableChains.ts +53 -8
  119. package/src/hooks/useGasPrice.ts +2 -1
  120. package/src/hooks/useGasSufficiencyBridge.ts +2 -2
  121. package/src/hooks/useRoutes.ts +3 -1
  122. package/src/hooks/useTokenSearch.ts +1 -1
  123. package/src/hooks/useTokens.ts +3 -3
  124. package/src/i18n/en.json +3 -3
  125. package/src/i18n/i18next.d.ts +30 -0
  126. package/src/index.ts +1 -1
  127. package/src/pages/MainPage/ReviewButton.tsx +1 -1
  128. package/src/pages/SendToWallet/BookmarkAddressSheet.tsx +1 -1
  129. package/src/pages/SendToWallet/SendToWalletPage.tsx +2 -2
  130. package/src/pages/TransactionPage/StartTransactionButton.tsx +1 -1
  131. package/src/pages/TransactionPage/StatusBottomSheet.tsx +1 -1
  132. package/src/pages/TransactionPage/TokenValueBottomSheet.tsx +2 -2
  133. package/src/pages/TransactionPage/TransactionPage.tsx +1 -1
  134. package/src/providers/WidgetProvider/WidgetProvider.tsx +1 -1
  135. package/src/services/DebridgeService.ts +3 -0
  136. package/src/services/ExecuteRoute.ts +2 -2
  137. package/src/stores/bookmarks/createBookmarkStore.ts +7 -7
  138. package/src/stores/chains/createChainOrderStore.ts +2 -2
  139. package/src/stores/routes/createRouteExecutionStore.ts +1 -1
  140. package/src/stores/settings/useSettingsStore.ts +1 -1
  141. package/src/stores/useServerErrorStore.ts +9 -0
  142. package/src/themes/createTheme.ts +1 -1
  143. package/src/types/widget.ts +4 -1
  144. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -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.19'
2
+ export const version = '1.0.21'
@@ -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) {
@@ -20,6 +20,7 @@ import { useIsBatchingSupported } from './useIsBatchingSupported.js'
20
20
  import { useSwapOnly } from './useSwapOnly.js'
21
21
  import { useToken } from './useToken.js'
22
22
  import { useWidgetEvents } from './useWidgetEvents.js'
23
+ import { useServerErrorStore } from '../stores/useServerErrorStore.js'
23
24
 
24
25
  const refetchTime = 60_000
25
26
 
@@ -178,6 +179,7 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
178
179
  signal,
179
180
  }) => {
180
181
  try {
182
+ useServerErrorStore.getState().setError(null)
181
183
  const fromAmount = parseUnits(fromTokenAmount, fromToken!.decimals)
182
184
  const formattedSlippage = slippage
183
185
  ? (Number.parseFloat(slippage) / 100).toString()
@@ -355,7 +357,7 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
355
357
  includedSteps: [],
356
358
  },
357
359
  ],
358
- data: data,
360
+ ...(data as any),
359
361
  }
360
362
  const routes = [route]
361
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,
@@ -1,4 +1,5 @@
1
1
  import { encodeAbiParameters, parseAbiParameters } from 'viem'
2
+ import { useServerErrorStore } from '../stores/useServerErrorStore.js'
2
3
 
3
4
  // Type definitions (can be moved to a separate types file if needed)
4
5
  interface Asset {
@@ -508,6 +509,7 @@ export class DebridgeService {
508
509
  }
509
510
  return { data };
510
511
  } catch (error: any) {
512
+ useServerErrorStore.getState().setError(error.response?.data?.errorMessage || error.message);
511
513
  console.error(
512
514
  'Error getting Debridge quote:',
513
515
  error.response?.data || error.message
@@ -758,6 +760,7 @@ export class DebridgeService {
758
760
  'Error fetching Debridge Solana transaction:',
759
761
  error.response?.data || error.message
760
762
  )
763
+ useServerErrorStore.getState().setError(error.response?.data?.errorMessage || error.message);
761
764
  return null
762
765
  }
763
766
  }
@@ -130,7 +130,7 @@ interface ExecuteRouteOptions {
130
130
  infiniteApproval?: boolean
131
131
  executeInBackground?: boolean
132
132
  account: Account
133
- wagmiConfig: Config
133
+ wagmiConfig: any // Use any to avoid deep type instantiation
134
134
  onDisconnect?: (account: Account) => Promise<void>
135
135
  onOpenWalletMenu?: () => void
136
136
  }
@@ -276,7 +276,7 @@ async function executeEvmSwap(
276
276
  await walletClient.switchChain({ id: targetChainId })
277
277
 
278
278
  // Get updated walletClient after chain switch
279
- walletClient = await getWalletClient(options.wagmiConfig)
279
+ walletClient = await getWalletClient(options.wagmiConfig) as any
280
280
  if (!walletClient || walletClient.chain.id !== targetChainId) {
281
281
  throw new Error('Failed to switch chain')
282
282
  }
@@ -21,7 +21,7 @@ export const createBookmarksStore = ({
21
21
  bookmarks: [],
22
22
  recentWallets: [],
23
23
  getBookmark: (address) =>
24
- get().bookmarks.find((bookmark) => bookmark.address === address),
24
+ (get() as any).bookmarks.find((bookmark) => bookmark.address === address),
25
25
  addBookmark: (bookmark) => {
26
26
  set((state) => ({
27
27
  bookmarks: [bookmark, ...state.bookmarks],
@@ -34,7 +34,7 @@ export const createBookmarksStore = ({
34
34
  ),
35
35
  }))
36
36
  },
37
- getSelectedBookmark: () => get().selectedBookmark,
37
+ getSelectedBookmark: () => (get() as any).selectedBookmark,
38
38
  setSelectedBookmark: (bookmark) => {
39
39
  set((_state) => ({
40
40
  selectedBookmark: bookmark,
@@ -62,20 +62,20 @@ export const createBookmarksStore = ({
62
62
  name: `${namePrefix || 'openocean'}-bookmarks`,
63
63
  version: 0,
64
64
  partialize: (state) => ({
65
- bookmarks: state.bookmarks,
66
- recentWallets: state.recentWallets,
65
+ bookmarks: (state as any).bookmarks,
66
+ recentWallets: (state as any).recentWallets,
67
67
  }),
68
68
  onRehydrateStorage: () => {
69
69
  return (state) => {
70
70
  if (state && toAddress && !toAddress.name) {
71
- const existingBookmark = state.getBookmark(toAddress.address)
71
+ const existingBookmark = (state as any).getBookmark(toAddress.address)
72
72
  if (existingBookmark) {
73
- state.setSelectedBookmark(existingBookmark)
73
+ (state as any).setSelectedBookmark(existingBookmark)
74
74
  }
75
75
  }
76
76
  }
77
77
  },
78
78
  }
79
- ) as StateCreator<BookmarkState, [], [], BookmarkState>,
79
+ ) as unknown as StateCreator<BookmarkState, [], [], BookmarkState>,
80
80
  Object.is
81
81
  )
@@ -80,8 +80,8 @@ export const createChainOrderStore = ({ namePrefix }: PersistStoreProps) =>
80
80
  {
81
81
  name: `${namePrefix || 'openocean'}-widget-chains-order`,
82
82
  version: 2,
83
- partialize: (state) => ({ chainOrder: state.chainOrder }),
83
+ partialize: (state: ChainOrderState) => ({ chainOrder: state?.chainOrder }),
84
84
  }
85
- ) as StateCreator<ChainOrderState, [], [], ChainOrderState>,
85
+ ) as unknown as StateCreator<ChainOrderState, [], [], ChainOrderState>,
86
86
  Object.is
87
87
  )
@@ -184,6 +184,6 @@ export const createRouteExecutionStore = ({ namePrefix }: PersistStoreProps) =>
184
184
  return state
185
185
  },
186
186
  }
187
- ) as StateCreator<RouteExecutionState, [], [], RouteExecutionState>,
187
+ ) as unknown as StateCreator<RouteExecutionState, [], [], RouteExecutionState>,
188
188
  Object.is
189
189
  )
@@ -179,6 +179,6 @@ export const useSettingsStore = createWithEqualityFn<SettingsState>(
179
179
  return persistedState as SettingsState
180
180
  },
181
181
  }
182
- ) as StateCreator<SettingsState, [], [], SettingsState>,
182
+ ) as unknown as StateCreator<SettingsState, [], [], SettingsState>,
183
183
  Object.is
184
184
  )
@@ -0,0 +1,9 @@
1
+ import { create } from 'zustand'
2
+
3
+ export const useServerErrorStore = create<{
4
+ error: string | null
5
+ setError: (msg: string | null) => void
6
+ }>((set) => ({
7
+ error: null,
8
+ setError: (msg) => set({ error: msg }),
9
+ }))
@@ -174,7 +174,7 @@ export const createTheme = (
174
174
  ...(!!ownerState.onClick &&
175
175
  !!rootHover && {
176
176
  '&:hover': {
177
- ...rootHover,
177
+ ...(rootHover && typeof rootHover === 'object' ? rootHover : {}),
178
178
  },
179
179
  }),
180
180
  ...(!ownerState.onClick && {
@@ -221,6 +221,9 @@ export interface WidgetConfig {
221
221
  toChain?: number
222
222
  fromToken?: string
223
223
  toToken?: string
224
+ defaultChain?: number
225
+ defaultFromToken?: string
226
+ defaultToToken?: string
224
227
  toAddress?: ToAddress
225
228
  toAddresses?: ToAddress[]
226
229
  fromAmount?: number | string
@@ -272,7 +275,7 @@ export interface WidgetConfig {
272
275
  explorerUrls?: Record<number, string[]> &
273
276
  Partial<Record<'internal', string[]>>
274
277
  poweredBy?: PoweredByType
275
-
278
+ isDefaultValueEnabled?: boolean
276
279
  /**
277
280
  * Custom labels/badges to show on routes based on specified rules
278
281
  */