@openocean.finance/widget 1.0.39 → 1.0.40

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/widget",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
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",
@@ -40,25 +40,25 @@
40
40
  "openocean"
41
41
  ],
42
42
  "dependencies": {
43
+ "@across-protocol/app-sdk": "^0.2.0",
43
44
  "@bigmi/client": "^0.1.1",
44
45
  "@bigmi/core": "^0.1.1",
46
+ "@defuse-protocol/one-click-sdk-typescript": "^0.1.2",
45
47
  "@emotion/react": "^11.14.0",
46
48
  "@emotion/styled": "^11.14.0",
49
+ "@lifi/sdk": "^3.6.8",
50
+ "@mayanfinance/swap-sdk": "^11.0.1",
47
51
  "@mui/icons-material": "6.0.2",
48
52
  "@mui/material": "^6.4.8",
49
53
  "@mui/system": "^6.4.8",
50
- "@openocean.finance/wallet-management": "^1.0.12",
51
- "@openocean.finance/widget-sdk": "^1.0.10",
52
- "@across-protocol/app-sdk": "^0.2.0",
54
+ "@openocean.finance/wallet-management": "^1.0.13",
55
+ "@openocean.finance/widget-sdk": "^1.0.11",
53
56
  "@near-wallet-selector/react-hook": "^9.0.0",
54
57
  "@reservoir0x/relay-sdk": "^2.4.0",
55
- "@lifi/sdk": "^3.6.8",
56
- "@mayanfinance/swap-sdk": "^11.0.1",
57
- "@defuse-protocol/one-click-sdk-typescript": "^0.1.2",
58
+ "@reservoir0x/relay-solana-wallet-adapter": "^2.0.5",
58
59
  "@solana/wallet-adapter-base": "^0.9.24",
59
60
  "@solana/web3.js": "^1.98.0",
60
61
  "@tanstack/react-virtual": "^3.13.4",
61
- "@reservoir0x/relay-solana-wallet-adapter": "^2.0.5",
62
62
  "ethers": "^6.13.5",
63
63
  "i18next": "^24.2.3",
64
64
  "microdiff": "^1.5.0",
@@ -37,4 +37,5 @@ export const DEFAULT_CHAIN_IDS = [
37
37
  10143, // Monad Testnet
38
38
  1151111081099710, // Solana
39
39
  999, // HyperEvm
40
+ 9745, // Plasma
40
41
  ];
@@ -1,2 +1,2 @@
1
1
  export const name = '@openocean.finance/widget'
2
- export const version = '1.0.39'
2
+ export const version = '1.0.40'
@@ -41,10 +41,6 @@ const mappingChain: Record<string, ChainName> = {
41
41
  }
42
42
 
43
43
  export class MayanAdapter extends BaseSwapAdapter {
44
- constructor() {
45
- super()
46
- }
47
-
48
44
  getName(): string {
49
45
  return 'Mayan'
50
46
  }
@@ -60,6 +56,9 @@ export class MayanAdapter extends BaseSwapAdapter {
60
56
  }
61
57
 
62
58
  async getQuote(params: EvmQuoteParams): Promise<NormalizedQuote> {
59
+ if (params.fromChain === ChainId.SOL) {
60
+ throw new Error('No quotes found')
61
+ }
63
62
  const quoteParams = {
64
63
  amount: +formatUnits(BigInt(params.amount), params.fromToken.decimals),
65
64
  fromToken: params.fromToken.isNative
@@ -119,40 +118,63 @@ export class MayanAdapter extends BaseSwapAdapter {
119
118
  { quote }: Quote,
120
119
  walletClient: WalletClient
121
120
  ): Promise<NormalizedTxResponse> {
122
- const account = walletClient.account?.address
123
- if (!account) throw new Error('WalletClient account is not defined')
124
-
125
- const res = getSwapFromEvmTxPayload(
126
- quote.rawQuote as MayanQuote,
127
- account,
128
- quote.quoteParams.recipient,
129
- { evm: CROSS_CHAIN_FEE_RECEIVER },
130
- account,
131
- quote.quoteParams.fromChain,
132
- null,
133
- null
134
- )
121
+ const account: any = quote.quoteParams.sender
122
+ if (!account) {
123
+ throw new Error('WalletClient account is not defined')
124
+ }
135
125
 
136
- if (res.to && res.value && res.data) {
137
- const tx = await walletClient.sendTransaction({
138
- chain: undefined,
126
+ if (!quote.quoteParams.fromChain) {
127
+ throw new Error(`Invalid fromChain: ${quote.quoteParams.fromChain}`)
128
+ }
129
+ const fromChain =
130
+ quote.quoteParams.fromChain === ChainId.SOL
131
+ ? 'solana'
132
+ : quote.quoteParams.fromChain
133
+
134
+ if (fromChain === 'solana') {
135
+ // const res = getSwapSolana({
136
+ // amountIn64: quote.quoteParams.amount,
137
+ // fromToken: quote.quoteParams.fromToken,
138
+ // minMiddleAmount: 0,
139
+ // middleToken: quote.quoteParams.toToken,
140
+ // userWallet: account,
141
+ // slippageBps: quote.quoteParams.slippage,
142
+ // referrerAddress: CROSS_CHAIN_FEE_RECEIVER,
143
+ // })
144
+ // debugger
145
+ } else {
146
+ const res = getSwapFromEvmTxPayload(
147
+ quote.rawQuote as MayanQuote,
148
+ account,
149
+ quote.quoteParams.recipient,
150
+ { evm: CROSS_CHAIN_FEE_RECEIVER },
139
151
  account,
140
- to: res.to as `0x${string}`,
141
- value: BigInt(res.value),
142
- data: res.data as `0x${string}`,
143
- })
144
- return {
145
- sender: quote.quoteParams.sender,
146
- id: tx, // specific id for each provider
147
- sourceTxHash: tx,
148
- adapter: this.getName(),
149
- sourceChain: quote.quoteParams.fromChain,
150
- targetChain: quote.quoteParams.toChain,
151
- inputAmount: quote.quoteParams.amount,
152
- outputAmount: quote.outputAmount.toString(),
153
- sourceToken: quote.quoteParams.fromToken,
154
- targetToken: quote.quoteParams.toToken,
155
- timestamp: new Date().getTime(),
152
+ fromChain,
153
+ null,
154
+ null
155
+ )
156
+ if (res.to && res.value && res.data) {
157
+ const tx = await walletClient.sendTransaction({
158
+ chain: undefined,
159
+ account: account as `0x${string}`,
160
+ to: res.to as `0x${string}`,
161
+ value: BigInt(res.value),
162
+ data: res.data as `0x${string}`,
163
+ kzg: undefined,
164
+ })
165
+ return {
166
+ sender: quote.quoteParams.sender,
167
+ id: tx, // specific id for each provider
168
+ sourceTxHash: tx,
169
+ adapter: this.getName(),
170
+ sourceChain: quote.quoteParams.fromChain,
171
+ targetChain: quote.quoteParams.toChain,
172
+ inputAmount: quote.quoteParams.amount,
173
+ outputAmount: quote.outputAmount.toString(),
174
+ sourceToken: quote.quoteParams.fromToken,
175
+ targetToken: quote.quoteParams.toToken,
176
+ timestamp: new Date().getTime(),
177
+ }
156
178
  }
157
179
  }
158
180
 
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  export type * from '@openocean.finance/widget-sdk'
2
3
  export { ChainType, ChainId, CoinKey } from '@openocean.finance/widget-sdk'
3
4
  export { App as OpenOceanWidget } from './App.js'
@@ -28,4 +29,4 @@ export { getPriceImpact } from './utils/getPriceImpact.js'
28
29
  export { percentFormatter } from './utils/percentFormatter.js'
29
30
  export { compactNumberFormatter } from './utils/compactNumberFormatter.js'
30
31
  export { currencyExtendedFormatter } from './utils/currencyExtendedFormatter.js'
31
- export { navigationRoutes } from './utils/navigationRoutes.js'
32
+ export { navigationRoutes } from './utils/navigationRoutes.js'
@@ -13,7 +13,7 @@ import {
13
13
  isRouteRefunded,
14
14
  } from './utils.js'
15
15
 
16
- const replaceBigInts = (obj: any): any => {
16
+ const replaceBigInts = (obj: any, visited = new WeakSet()): any => {
17
17
  if (obj === null || obj === undefined) {
18
18
  return obj
19
19
  }
@@ -22,14 +22,28 @@ const replaceBigInts = (obj: any): any => {
22
22
  return obj.toString()
23
23
  }
24
24
 
25
+ // 检查循环引用
26
+ if (typeof obj === 'object' && visited.has(obj)) {
27
+ return '[Circular Reference]'
28
+ }
29
+
25
30
  if (Array.isArray(obj)) {
26
- return obj.map(replaceBigInts)
31
+ visited.add(obj)
32
+ const result = obj.map((item) => replaceBigInts(item, visited))
33
+ visited.delete(obj)
34
+ return result
27
35
  }
28
36
 
29
37
  if (typeof obj === 'object') {
30
- return Object.fromEntries(
31
- Object.entries(obj).map(([key, value]) => [key, replaceBigInts(value)])
38
+ visited.add(obj)
39
+ const result = Object.fromEntries(
40
+ Object.entries(obj).map(([key, value]) => [
41
+ key,
42
+ replaceBigInts(value, visited),
43
+ ])
32
44
  )
45
+ visited.delete(obj)
46
+ return result
33
47
  }
34
48
 
35
49
  return obj