@openocean.finance/widget 1.0.34 → 1.0.35

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.34",
3
+ "version": "1.0.35",
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",
@@ -1,2 +1,2 @@
1
1
  export const name = '@openocean.finance/widget'
2
- export const version = '1.0.34'
2
+ export const version = '1.0.35'
@@ -452,17 +452,25 @@ async function executeEvmSwap(
452
452
  }
453
453
 
454
454
  // Check if current chain matches target chain
455
- const currentChainId = walletClient.chain.id
455
+ console.log(
456
+ 'walletClient',
457
+ walletClient,
458
+ walletClient.chain,
459
+ walletClient.getChainId
460
+ )
461
+ const currentChainId = await walletClient.getChainId()
456
462
  const targetChainId = step.action.fromChainId
457
463
 
458
- if (currentChainId !== targetChainId) {
464
+ if (currentChainId != targetChainId) {
459
465
  try {
460
466
  // Try to switch to target chain
461
467
  await walletClient.switchChain({ id: targetChainId })
462
468
 
463
469
  // Get updated walletClient after chain switch
464
470
  walletClient = (await getWalletClient(options.wagmiConfig)) as any
465
- if (!walletClient || walletClient.chain.id !== targetChainId) {
471
+ const currentChainId2 = await walletClient.getChainId()
472
+
473
+ if (!walletClient || currentChainId2 !== targetChainId) {
466
474
  throw new Error('Failed to switch chain')
467
475
  }
468
476
  } catch (error) {
@@ -549,7 +557,7 @@ async function executeEvmSwap(
549
557
  : BigInt(amount)
550
558
 
551
559
  const hash = await walletClient.writeContract({
552
- chain: walletClient.chain,
560
+ chain: walletClient.chain || undefined,
553
561
  account: walletClient.account,
554
562
  address: step.action.fromToken.address as `0x${string}`,
555
563
  abi: [