Giter Site home page Giter Site logo

vue3 walletManagement error about widget HOT 10 CLOSED

vic-x avatar vic-x commented on August 14, 2024
vue3 walletManagement error

from widget.

Comments (10)

vic-x avatar vic-x commented on August 14, 2024 1

@chybisov Thank you so much for taking care of this for me。I have updated to the latest installation package and the problem has been solved。 🙏

from widget.

chybisov avatar chybisov commented on August 14, 2024

@vic-x could you please provide a reproducible example/screen recording/more detailed steps to reproduce?

from widget.

vic-x avatar vic-x commented on August 14, 2024

@vic-x您能否提供可重现的示例/屏幕录像/更详细的重现步骤?

cf176f6e764a080c8e9bb26c8e39e872_0_1682585552.mp4

from widget.

chybisov avatar chybisov commented on August 14, 2024

Vue3 configures walletManagement. When clicking 'swap', the chain selected by the wallet is different from the chain selected by the current exchange. Switch the chain first, and an error will be reported after the operation is successful.

image

walletManagement: { connect: async () => { connectWallet() }, disconnect: disconnect, switchChain: async chainId => { await SwitchNetwork({ chainId: chainId }) }, addToken: addToken, addChain: addChain, signer: Signer }

@vic-x thanks for the video! Closely reviewing your code example I noticed you don't return Signer object from switchChain function. If you take a look at the types it's required to return Promise<Signer>:

export interface WidgetWalletManagement {
  connect(): Promise<Signer>;
  disconnect(): Promise<void>;
  switchChain?(chainId: number): Promise<Signer>;
  addToken?(token: StaticToken, chainId: number): Promise<void>;
  addChain?(chainId: number): Promise<boolean>;
  signer?: Signer;
}

Try changing your code example to:

walletManagement: {
  connect: async () => {
    return connectWallet()
  },
  disconnect: disconnect,
  switchChain: async chainId => {
    return SwitchNetwork({
      chainId: chainId
    })
  },
  addToken: addToken,
  addChain: addChain,
  signer: Signer
}

from widget.

vic-x avatar vic-x commented on August 14, 2024

Vue3 配置钱包管理。点击“切换”时,钱包选择的链与当前交易所选择的链不同。先切换链,运行成功后会报错。
图像
walletManagement: { connect: async () => { connectWallet() }, disconnect: 断开连接, switchChain: async chainId => { await SwitchNetwork({ chainId: chainId }) }, addToken: addToken, addChain: addChain, signer: Signer }

@vic-x感谢视频!仔细查看您的代码示例,我注意到您没有Signer从函数返回对象switchChain。如果您查看需要返回的类型Promise<Signer>

export interface WidgetWalletManagement {
  connect(): Promise<Signer>;
  disconnect(): Promise<void>;
  switchChain?(chainId: number): Promise<Signer>;
  addToken?(token: StaticToken, chainId: number): Promise<void>;
  addChain?(chainId: number): Promise<boolean>;
  signer?: Signer;
}

尝试将您的代码示例更改为:

walletManagement: {
  connect: async () => {
    return connectWallet()
  },
  disconnect: disconnect,
  switchChain: async chainId => {
    return SwitchNetwork({
      chainId: chainId
    })
  },
  addToken: addToken,
  addChain: addChain,
  signer: Signer
}

@chybisov Thank you for your reply, but I still have problems after I modified it. I use @wagmi/core to link wallets, switch chains, and get Signer;

The following is the modified code

walletManagement: {
connect: async () => {
connectWallet(connector, chainId.value)
const Signer = await fetchSigner()
return markRaw(Signer)
},
disconnect: disconnect,
switchChain: async chainId => {
await SwitchNetwork({
chainId: chainId
})
const Signer = await fetchSigner({ chainId: chainId })
return markRaw(Signer)
},
addToken: addToken,
addChain: addChain,
signer: markRaw(Signer)
},

from widget.

chybisov avatar chybisov commented on August 14, 2024

@vic-x hard to say from this code example what went wrong, it looks fine. Can you please share a reproducible example so I can debug it?

from widget.

vic-x avatar vic-x commented on August 14, 2024

@vic-x hard to say from this code example what went wrong, it looks fine. Can you please share a reproducible example so I can debug it?

@chybisov
I wrote a demo, you can view it at https://github.com/vic-x/lifi-demo

from widget.

chybisov avatar chybisov commented on August 14, 2024

@vic-x thank you for the demo. We will investigate it and come back to you 🙂

from widget.

vic-x avatar vic-x commented on August 14, 2024

@chybisov

from widget.

chybisov avatar chybisov commented on August 14, 2024

@vic-x It took a while to figure out, but the fix is released in v2.0.0-beta.10.

from widget.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.