@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.
- package/package.json +5 -6
- package/src/components/AmountInput/AmountInput.tsx +1 -1
- package/src/components/AmountInput/PriceFormHelperText.tsx +13 -13
- package/src/components/Avatar/TokenAvatar.tsx +1 -1
- package/src/components/ChainSelect/ChainSelect.tsx +1 -1
- package/src/components/ChainSelect/useChainSelect.ts +1 -1
- package/src/components/ContractComponent/ItemPrice.tsx +1 -1
- package/src/components/ContractComponent/NFT/types.ts +1 -1
- package/src/components/Messages/WarningMessages.tsx +5 -5
- package/src/components/Messages/useMessageQueue.ts +1 -1
- package/src/components/RouteCard/RouteCard.tsx +2 -2
- package/src/components/RouteCard/RouteCardEssentials.tsx +1 -1
- package/src/components/RouteCard/getMatchingLabels.ts +1 -1
- package/src/components/RouteCard/types.ts +1 -1
- package/src/components/Routes/RoutesExpanded.tsx +1 -1
- package/src/components/Step/CircularProgress.style.tsx +1 -1
- package/src/components/Step/CircularProgress.tsx +1 -1
- package/src/components/Step/DestinationWalletAddress.tsx +2 -2
- package/src/components/Step/Step.tsx +6 -3
- package/src/components/Step/StepList.tsx +1 -1
- package/src/components/Step/StepProcess.tsx +2 -2
- package/src/components/StepActions/StepActions.tsx +5 -5
- package/src/components/StepActions/StepFees.tsx +2 -2
- package/src/components/StepActions/types.ts +3 -3
- package/src/components/Timer/RouteTimer.tsx +1 -1
- package/src/components/Timer/StepTimer.tsx +5 -5
- package/src/components/Token/Token.tsx +9 -7
- package/src/components/TokenList/TokenListItem.tsx +1 -1
- package/src/components/TokenList/types.ts +1 -1
- package/src/components/TokenRate/TokenRate.tsx +1 -1
- package/src/components/TransactionDetails.tsx +1 -1
- package/src/config/coinbase.ts +1 -1
- package/src/config/metaMask.ts +1 -1
- package/src/hooks/useAddressValidation.ts +2 -2
- package/src/hooks/useAvailableChains.ts +2 -2
- package/src/hooks/useChains.ts +1 -1
- package/src/hooks/useExplorer.ts +4 -2
- package/src/hooks/useFromTokenSufficiency.ts +1 -1
- package/src/hooks/useGasRecommendation.ts +4 -1
- package/src/hooks/useGasSufficiency.ts +7 -3
- package/src/hooks/useInitializer.ts +1 -1
- package/src/hooks/useIsBatchingSupported.ts +2 -2
- package/src/hooks/useIsCompatibleDestinationAccount.ts +1 -1
- package/src/hooks/useIsContractAddress.ts +1 -1
- package/src/hooks/useProcessMessage.ts +23 -23
- package/src/hooks/useRouteExecution.ts +5 -2
- package/src/hooks/useRoutes.ts +4 -4
- package/src/hooks/useToAddressRequirements.ts +1 -1
- package/src/hooks/useToAddressReset.ts +1 -1
- package/src/hooks/useTokenBalance.ts +5 -1
- package/src/hooks/useTokenBalances.ts +1 -1
- package/src/hooks/useTokenSearch.ts +5 -2
- package/src/hooks/useTokens.ts +6 -5
- package/src/hooks/useTools.ts +1 -1
- package/src/hooks/useTransactionDetails.ts +2 -2
- package/src/hooks/useTransactionHistory.ts +8 -2
- package/src/index.ts +2 -2
- package/src/pages/MainPage/MainWarningMessages.tsx +1 -1
- package/src/pages/RoutesPage/RoutesPage.tsx +1 -1
- package/src/pages/SelectChainPage/SelectChainPage.tsx +1 -1
- package/src/pages/SelectEnabledToolsPage.tsx +1 -1
- package/src/pages/SettingsPage/RoutePrioritySettings.tsx +1 -1
- package/src/pages/TransactionDetailsPage/TransactionDetailsPage.tsx +7 -4
- package/src/pages/TransactionDetailsPage/TransferIdCard.tsx +1 -1
- package/src/pages/TransactionHistoryPage/TransactionHistoryItem.tsx +2 -2
- package/src/pages/TransactionHistoryPage/TransactionHistoryPage.tsx +1 -1
- package/src/pages/TransactionPage/ExchangeRateBottomSheet.tsx +1 -1
- package/src/pages/TransactionPage/TokenValueBottomSheet.tsx +2 -2
- package/src/pages/TransactionPage/TransactionPage.tsx +1 -1
- package/src/pages/TransactionPage/types.ts +1 -1
- package/src/providers/WalletProvider/EVMProvider.tsx +1 -1
- package/src/providers/WalletProvider/SDKProviders.tsx +8 -2
- package/src/providers/WalletProvider/SVMProvider.tsx +1 -1
- package/src/providers/WalletProvider/UTXOProvider.tsx +1 -1
- package/src/providers/WalletProvider/useExternalWalletProvider.ts +1 -1
- package/src/providers/WidgetProvider/WidgetProvider.tsx +2 -2
- package/src/services/ExecuteRoute.ts +34 -22
- package/src/stores/form/types.ts +1 -1
- package/src/stores/routes/createRouteExecutionStore.ts +1 -1
- package/src/stores/routes/types.ts +1 -1
- package/src/stores/routes/utils.ts +1 -1
- package/src/stores/settings/types.ts +1 -1
- package/src/types/events.ts +6 -1
- package/src/types/token.ts +1 -1
- package/src/types/widget.ts +10 -10
- package/src/utils/chainType.ts +1 -1
- package/src/utils/converters.ts +2 -2
- package/src/utils/fees.ts +6 -1
- package/src/utils/getPriceImpact.ts +1 -1
- /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
|
|
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:
|
|
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:
|
|
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(
|
|
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:
|
|
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(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
|
192
|
+
let allowance = 0n
|
|
183
193
|
try {
|
|
184
|
-
|
|
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(
|
|
215
|
+
console.error('Failed to read allowance:', error)
|
|
206
216
|
// Log additional context
|
|
207
|
-
console.error(
|
|
208
|
-
console.error(
|
|
209
|
-
console.error(
|
|
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 =
|
|
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(
|
package/src/stores/form/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Route, RouteExtended } from '@
|
|
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'
|
package/src/types/events.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
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'
|
package/src/types/token.ts
CHANGED
package/src/types/widget.ts
CHANGED
|
@@ -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,
|
package/src/utils/chainType.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isUTXOAddress } from '@bigmi/core'
|
|
2
|
-
import { ChainId, ChainType, isSVMAddress } from '@
|
|
2
|
+
import { ChainId, ChainType, isSVMAddress } from '@openocean.finance/widget-sdk'
|
|
3
3
|
import { isAddress as isEVMAddress } from 'viem'
|
|
4
4
|
|
|
5
5
|
const chainTypeAddressValidation = {
|
package/src/utils/converters.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
Substatus,
|
|
8
8
|
TokenAmount,
|
|
9
9
|
ToolsResponse,
|
|
10
|
-
} from '@
|
|
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: '
|
|
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 {
|
|
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 {
|
|
File without changes
|