@openocean.finance/widget 1.0.1 → 1.0.3

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 (90) hide show
  1. package/package.json +5 -6
  2. package/src/components/AmountInput/AmountInput.tsx +1 -1
  3. package/src/components/AmountInput/PriceFormHelperText.tsx +13 -13
  4. package/src/components/Avatar/TokenAvatar.tsx +1 -1
  5. package/src/components/ChainSelect/ChainSelect.tsx +1 -1
  6. package/src/components/ChainSelect/useChainSelect.ts +1 -1
  7. package/src/components/ContractComponent/ItemPrice.tsx +1 -1
  8. package/src/components/ContractComponent/NFT/types.ts +1 -1
  9. package/src/components/Messages/WarningMessages.tsx +5 -5
  10. package/src/components/Messages/useMessageQueue.ts +1 -1
  11. package/src/components/RouteCard/RouteCard.tsx +2 -2
  12. package/src/components/RouteCard/RouteCardEssentials.tsx +1 -1
  13. package/src/components/RouteCard/getMatchingLabels.ts +1 -1
  14. package/src/components/RouteCard/types.ts +1 -1
  15. package/src/components/Routes/RoutesExpanded.tsx +1 -1
  16. package/src/components/Step/CircularProgress.style.tsx +1 -1
  17. package/src/components/Step/CircularProgress.tsx +1 -1
  18. package/src/components/Step/DestinationWalletAddress.tsx +2 -2
  19. package/src/components/Step/Step.tsx +6 -3
  20. package/src/components/Step/StepList.tsx +1 -1
  21. package/src/components/Step/StepProcess.tsx +2 -2
  22. package/src/components/StepActions/StepActions.tsx +5 -5
  23. package/src/components/StepActions/StepFees.tsx +2 -2
  24. package/src/components/StepActions/types.ts +3 -3
  25. package/src/components/Timer/RouteTimer.tsx +1 -1
  26. package/src/components/Timer/StepTimer.tsx +5 -5
  27. package/src/components/Token/Token.tsx +9 -7
  28. package/src/components/TokenList/TokenListItem.tsx +1 -1
  29. package/src/components/TokenList/types.ts +1 -1
  30. package/src/components/TokenRate/TokenRate.tsx +1 -1
  31. package/src/components/TransactionDetails.tsx +1 -1
  32. package/src/config/coinbase.ts +1 -1
  33. package/src/config/metaMask.ts +1 -1
  34. package/src/hooks/useAddressValidation.ts +2 -2
  35. package/src/hooks/useAvailableChains.ts +2 -2
  36. package/src/hooks/useChains.ts +1 -1
  37. package/src/hooks/useExplorer.ts +4 -2
  38. package/src/hooks/useFromTokenSufficiency.ts +1 -1
  39. package/src/hooks/useGasRecommendation.ts +4 -1
  40. package/src/hooks/useGasSufficiency.ts +7 -3
  41. package/src/hooks/useInitializer.ts +1 -1
  42. package/src/hooks/useIsBatchingSupported.ts +2 -2
  43. package/src/hooks/useIsCompatibleDestinationAccount.ts +1 -1
  44. package/src/hooks/useIsContractAddress.ts +1 -1
  45. package/src/hooks/useProcessMessage.ts +23 -23
  46. package/src/hooks/useRouteExecution.ts +5 -2
  47. package/src/hooks/useRoutes.ts +4 -4
  48. package/src/hooks/useToAddressRequirements.ts +1 -1
  49. package/src/hooks/useToAddressReset.ts +1 -1
  50. package/src/hooks/useTokenBalance.ts +5 -1
  51. package/src/hooks/useTokenBalances.ts +1 -1
  52. package/src/hooks/useTokenSearch.ts +5 -2
  53. package/src/hooks/useTokens.ts +6 -5
  54. package/src/hooks/useTools.ts +1 -1
  55. package/src/hooks/useTransactionDetails.ts +2 -2
  56. package/src/hooks/useTransactionHistory.ts +8 -2
  57. package/src/index.ts +2 -2
  58. package/src/pages/MainPage/MainWarningMessages.tsx +1 -1
  59. package/src/pages/RoutesPage/RoutesPage.tsx +1 -1
  60. package/src/pages/SelectChainPage/SelectChainPage.tsx +1 -1
  61. package/src/pages/SelectEnabledToolsPage.tsx +1 -1
  62. package/src/pages/SettingsPage/RoutePrioritySettings.tsx +1 -1
  63. package/src/pages/TransactionDetailsPage/TransactionDetailsPage.tsx +7 -4
  64. package/src/pages/TransactionDetailsPage/TransferIdCard.tsx +1 -1
  65. package/src/pages/TransactionHistoryPage/TransactionHistoryItem.tsx +2 -2
  66. package/src/pages/TransactionHistoryPage/TransactionHistoryPage.tsx +1 -1
  67. package/src/pages/TransactionPage/ExchangeRateBottomSheet.tsx +1 -1
  68. package/src/pages/TransactionPage/TokenValueBottomSheet.tsx +2 -2
  69. package/src/pages/TransactionPage/TransactionPage.tsx +1 -1
  70. package/src/pages/TransactionPage/types.ts +1 -1
  71. package/src/providers/WalletProvider/EVMProvider.tsx +1 -1
  72. package/src/providers/WalletProvider/SDKProviders.tsx +8 -2
  73. package/src/providers/WalletProvider/SVMProvider.tsx +1 -1
  74. package/src/providers/WalletProvider/UTXOProvider.tsx +1 -1
  75. package/src/providers/WalletProvider/useExternalWalletProvider.ts +1 -1
  76. package/src/providers/WidgetProvider/WidgetProvider.tsx +2 -2
  77. package/src/services/ExecuteRoute.ts +34 -22
  78. package/src/stores/form/types.ts +1 -1
  79. package/src/stores/routes/createRouteExecutionStore.ts +1 -1
  80. package/src/stores/routes/types.ts +1 -1
  81. package/src/stores/routes/utils.ts +1 -1
  82. package/src/stores/settings/types.ts +1 -1
  83. package/src/types/events.ts +6 -1
  84. package/src/types/token.ts +1 -1
  85. package/src/types/widget.ts +10 -10
  86. package/src/utils/chainType.ts +1 -1
  87. package/src/utils/converters.ts +2 -2
  88. package/src/utils/fees.ts +6 -1
  89. package/src/utils/getPriceImpact.ts +1 -1
  90. /package/src/icons/{lifi.ts → openocean.ts} +0 -0
@@ -1,5 +1,10 @@
1
- import type { ExecutionStatus, LiFiStep, Process, Route } from '@lifi/sdk'
2
1
  import type { Account } from '@openocean.finance/wallet-management'
2
+ import type {
3
+ ExecutionStatus,
4
+ OpenOceanStep,
5
+ Process,
6
+ Route,
7
+ } from '@openocean.finance/widget-sdk'
3
8
  import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js'
4
9
  import type { Config } from 'wagmi'
5
10
  import { getPublicClient, getWalletClient } from 'wagmi/actions'
@@ -22,7 +27,7 @@ interface ExecuteRouteOptions {
22
27
  onOpenWalletMenu?: () => void
23
28
  }
24
29
 
25
- interface ExtendedLiFiStep extends LiFiStep {
30
+ interface ExtendedOpenOceanStep extends OpenOceanStep {
26
31
  execution?: {
27
32
  status: ExecutionStatus
28
33
  process: Process[]
@@ -33,7 +38,7 @@ interface ExtendedLiFiStep extends LiFiStep {
33
38
  }
34
39
 
35
40
  interface ExtendedRoute extends Route {
36
- steps: ExtendedLiFiStep[]
41
+ steps: ExtendedOpenOceanStep[]
37
42
  data: {
38
43
  prependedOperatingExpenseCost: string
39
44
  }
@@ -41,7 +46,7 @@ interface ExtendedRoute extends Route {
41
46
 
42
47
  // Execute Solana transaction
43
48
  async function executeSolanaSwap(
44
- step: ExtendedLiFiStep,
49
+ step: ExtendedOpenOceanStep,
45
50
  options: ExecuteRouteOptions,
46
51
  process: Process,
47
52
  route: ExtendedRoute
@@ -63,13 +68,15 @@ async function executeSolanaSwap(
63
68
  transaction = Transaction.from(hexToUint8Array(txData))
64
69
  }
65
70
  } else {
66
- transaction = VersionedTransaction.deserialize(hexToUint8Array(txData.slice(2)))
71
+ transaction = VersionedTransaction.deserialize(
72
+ hexToUint8Array(txData.slice(2))
73
+ )
67
74
  // Create connection instance
68
75
  connection = new Connection(
69
76
  'https://burned-practical-bird.solana-mainnet.quiknode.pro/33f4786133c252415e194b29ee69ffc7671480ab'
70
77
  )
71
- const { blockhash } = await connection.getLatestBlockhash();
72
- transaction.message.recentBlockhash = blockhash;
78
+ const { blockhash } = await connection.getLatestBlockhash()
79
+ transaction.message.recentBlockhash = blockhash
73
80
  }
74
81
 
75
82
  // Check signTransaction method exists
@@ -84,7 +91,6 @@ async function executeSolanaSwap(
84
91
  throw new Error('Failed to sign transaction')
85
92
  }
86
93
 
87
-
88
94
  // Serialize signed transaction
89
95
  const serializedTransaction = signedTx.serialize({
90
96
  verifySignatures: false,
@@ -136,7 +142,7 @@ async function executeSolanaSwap(
136
142
 
137
143
  // Execute EVM transaction
138
144
  async function executeEvmSwap(
139
- step: ExtendedLiFiStep,
145
+ step: ExtendedOpenOceanStep,
140
146
  options: ExecuteRouteOptions,
141
147
  process: Process,
142
148
  route: ExtendedRoute
@@ -168,20 +174,24 @@ async function executeEvmSwap(
168
174
  throw new Error('Public client not found')
169
175
  }
170
176
 
171
- console.log('Current Chain:', publicClient.chain?.id, publicClient.chain?.name);
172
- console.log('Token Address:', step.action.fromToken.address);
173
- console.log('Token Chain ID:', step.action.fromToken.chainId);
174
- console.log('Owner Address:', walletClient.account.address);
175
- console.log('Spender Address:', step.estimate.approvalAddress);
177
+ console.log(
178
+ 'Current Chain:',
179
+ publicClient.chain?.id,
180
+ publicClient.chain?.name
181
+ )
182
+ console.log('Token Address:', step.action.fromToken.address)
183
+ console.log('Token Chain ID:', step.action.fromToken.chainId)
184
+ console.log('Owner Address:', walletClient.account.address)
185
+ console.log('Spender Address:', step.estimate.approvalAddress)
176
186
 
177
187
  // Check token approval
178
188
  if (
179
189
  step.action.fromToken.address !==
180
190
  '0x0000000000000000000000000000000000000000'
181
191
  ) {
182
- let allowance: bigint = 0n;
192
+ let allowance = 0n
183
193
  try {
184
- allowance = (await publicClient.readContract({
194
+ allowance = (await publicClient.readContract({
185
195
  address: step.action.fromToken.address as `0x${string}`,
186
196
  abi: [
187
197
  {
@@ -200,18 +210,20 @@ async function executeEvmSwap(
200
210
  walletClient.account.address,
201
211
  step.estimate.approvalAddress as `0x${string}`,
202
212
  ],
203
- })) as bigint;
213
+ })) as bigint
204
214
  } catch (error) {
205
- console.error("Failed to read allowance:", error);
215
+ console.error('Failed to read allowance:', error)
206
216
  // Log additional context
207
- console.error("Context - Step:", JSON.stringify(step, null, 2));
208
- console.error("Context - Route:", JSON.stringify(route, null, 2));
209
- console.error("Context - Public Client Chain:", publicClient.chain);
217
+ console.error('Context - Step:', JSON.stringify(step, null, 2))
218
+ console.error('Context - Route:', JSON.stringify(route, null, 2))
219
+ console.error('Context - Public Client Chain:', publicClient.chain)
210
220
  // Re-throw the error or handle it appropriately
211
221
  // throw new Error(`Failed to read allowance for token ${step.action.fromToken.address}: ${error instanceof Error ? error.message : String(error)}`);
212
222
  }
213
223
 
214
- const amount = BigInt(step.action.fromAmount) + BigInt(route?.data?.prependedOperatingExpenseCost || '0');
224
+ const amount =
225
+ BigInt(step.action.fromAmount) +
226
+ BigInt(route?.data?.prependedOperatingExpenseCost || '0')
215
227
  if (allowance < BigInt(amount)) {
216
228
  const approvalAmount = options.infiniteApproval
217
229
  ? BigInt(
@@ -1,4 +1,4 @@
1
- import type { ContractCall } from '@lifi/sdk'
1
+ import type { ContractCall } from '@openocean.finance/widget-sdk'
2
2
  import type { StoreApi } from 'zustand'
3
3
  import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional'
4
4
 
@@ -1,4 +1,4 @@
1
- import type { Route, RouteExtended } from '@lifi/sdk'
1
+ import type { Route, RouteExtended } from '@openocean.finance/widget-sdk'
2
2
  import type { StateCreator } from 'zustand'
3
3
  import { persist } from 'zustand/middleware'
4
4
  import { createWithEqualityFn } from 'zustand/traditional'
@@ -1,4 +1,4 @@
1
- import type { Route, RouteExtended } from '@lifi/sdk'
1
+ import type { Route, RouteExtended } from '@openocean.finance/widget-sdk'
2
2
 
3
3
  export interface RouteExecution {
4
4
  route: RouteExtended
@@ -1,4 +1,4 @@
1
- import type { Process, RouteExtended } from '@lifi/sdk'
1
+ import type { Process, RouteExtended } from '@openocean.finance/widget-sdk'
2
2
  import microdiff from 'microdiff'
3
3
 
4
4
  export const isRouteDone = (route: RouteExtended) => {
@@ -1,4 +1,4 @@
1
- import type { Order } from '@lifi/sdk'
1
+ import type { Order } from '@openocean.finance/widget-sdk'
2
2
  import type { PropsWithChildren } from 'react'
3
3
  import type { StoreApi } from 'zustand'
4
4
  import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional'
@@ -1,4 +1,9 @@
1
- import type { ChainId, ChainType, Process, Route } from '@lifi/sdk'
1
+ import type {
2
+ ChainId,
3
+ ChainType,
4
+ Process,
5
+ Route,
6
+ } from '@openocean.finance/widget-sdk'
2
7
  import type { DefaultValues } from '../stores/form/types.js'
3
8
  import type { SettingsProps } from '../stores/settings/types.js'
4
9
  import type { NavigationRouteType } from '../utils/navigationRoutes.js'
@@ -1,4 +1,4 @@
1
- import type { TokenAmount as SDKTokenAmount } from '@lifi/sdk'
1
+ import type { TokenAmount as SDKTokenAmount } from '@openocean.finance/widget-sdk'
2
2
 
3
3
  export interface TokenAmount extends SDKTokenAmount {
4
4
  featured?: boolean
@@ -1,13 +1,3 @@
1
- import type {
2
- BaseToken,
3
- ChainType,
4
- ContractCall,
5
- Order,
6
- RouteOptions,
7
- SDKConfig,
8
- StaticToken,
9
- Token,
10
- } from '@lifi/sdk'
11
1
  import type {
12
2
  Components,
13
3
  PaletteMode,
@@ -17,6 +7,16 @@ import type {
17
7
  Theme,
18
8
  } from '@mui/material'
19
9
  import type { TypographyOptions } from '@mui/material/styles/createTypography.js'
10
+ import type {
11
+ BaseToken,
12
+ ChainType,
13
+ ContractCall,
14
+ Order,
15
+ RouteOptions,
16
+ SDKConfig,
17
+ StaticToken,
18
+ Token,
19
+ } from '@openocean.finance/widget-sdk'
20
20
  import type {
21
21
  CSSProperties,
22
22
  MutableRefObject,
@@ -1,5 +1,5 @@
1
1
  import { isUTXOAddress } from '@bigmi/core'
2
- import { ChainId, ChainType, isSVMAddress } from '@lifi/sdk'
2
+ import { ChainId, ChainType, isSVMAddress } from '@openocean.finance/widget-sdk'
3
3
  import { isAddress as isEVMAddress } from 'viem'
4
4
 
5
5
  const chainTypeAddressValidation = {
@@ -7,7 +7,7 @@ import type {
7
7
  Substatus,
8
8
  TokenAmount,
9
9
  ToolsResponse,
10
- } from '@lifi/sdk'
10
+ } from '@openocean.finance/widget-sdk'
11
11
  import type { RouteExecution } from '../stores/routes/types.js'
12
12
  import { formatTokenPrice } from './format.js'
13
13
 
@@ -146,7 +146,7 @@ export const buildRouteFromTxHistory = (
146
146
  steps: [
147
147
  {
148
148
  id: crypto.randomUUID(),
149
- type: 'lifi',
149
+ type: 'openocean',
150
150
  tool: tx.tool,
151
151
  toolDetails: usedTool,
152
152
  action: {
package/src/utils/fees.ts CHANGED
@@ -1,4 +1,9 @@
1
- import type { FeeCost, GasCost, RouteExtended, Token } from '@lifi/sdk'
1
+ import type {
2
+ FeeCost,
3
+ GasCost,
4
+ RouteExtended,
5
+ Token,
6
+ } from '@openocean.finance/widget-sdk'
2
7
  import { formatTokenPrice } from './format.js'
3
8
 
4
9
  export interface FeesBreakdown {
@@ -1,4 +1,4 @@
1
- import type { Token } from '@lifi/sdk'
1
+ import type { Token } from '@openocean.finance/widget-sdk'
2
2
  import { formatTokenPrice } from './format.js'
3
3
 
4
4
  interface GetPriceImpractProps {
File without changes