Giter Club home page Giter Club logo

Comments (4)

taylorjdawson avatar taylorjdawson commented on September 23, 2024

Hello @YaminZheng 👋 If I am understanding correctly you want to use the connectWallet function to autoselect a wallet but there are cases where the label that you pass in, is a wallet that doesn't exist? And therefore you need a way to detect this state and react to it? We will discuss internally whether adding an error is the appropriate response in this case. However, what you can do and what might be a better approach is to check to see if a wallet was connected after trying to auto select the wallet:

import { useOnboard } from "@web3-onboard/vue";

const { connectWallet, connectedWallet } = useOnboard();

const onClickConnect = async () => {
  try {
    await connectWallet({ label: 'a error label', disableModels: true });
    // Here you can add logic if the wallet you wanted to autoSelect wasn't selected
    if(!connectedWallet) {
      console.log('Could not find wallet to auto connect')
    }
  } catch (err) {
    alert('Unknown wallet or other error');
  }
};

from web3-onboard.

YaminZheng avatar YaminZheng commented on September 23, 2024

Sorry, my English is not good, I mean
你不能给每个错误做相同的事情
比如已经打开了一个 metamask 窗口,报错提示应该是去检查你的钱包
如果是用户取消了这个操作,可以不提示任何错误
如果是钱包出了问题,我应该提示他重新下载或刷新页面去操作。
我不知道为何要把这个 catch 在内部处理掉而不给我反馈的任何理由。把错误正确提示来对于用户来说,很值得去做

from web3-onboard.

taylorjdawson avatar taylorjdawson commented on September 23, 2024

Sorry, my English is not good, I mean 你不能给每个错误做相同的事情 比如已经打开了一个 metamask 窗口,报错提示应该是去检查你的钱包 如果是用户取消了这个操作,可以不提示任何错误 如果是钱包出了问题,我应该提示他重新下载或刷新页面去操作。 我不知道为何要把这个 catch 在内部处理掉而不给我反馈的任何理由。把错误正确提示来对于用户来说,很值得去做

@YaminZheng adding this translation for context:
"You can't do the same thing for every error. For example, if a MetaMask window is already open, the error message should be to check your wallet. If the user cancels the operation, you don't need to display any error. If there's a problem with the wallet, I should prompt them to re-download or refresh the page to proceed. I don't know why you would handle this catch internally without giving me any feedback. Providing the correct error message for the user is worth doing."

Are you saying that you are not able to get the provider thrown error? i.e. if metamask throws an error you want to see and be able to catch that error?

from web3-onboard.

YaminZheng avatar YaminZheng commented on September 23, 2024

抱歉,我的英语不好,我的意思是你不能给每个错误做相同的事情比如已经打开了一个元掩码窗口,报错提示应该是检查你的钱包如果是用户取消了这个操作,可以不提示任何错误如果是钱包产生的问题,我应该提示他重新下载或刷新页面操作。我不知道为什么要把这个捕获放在内部处理中而不给我反馈任何理由。为用户提供正确的错误提示,很值得付出

@YaminZheng添加上下文翻译: “你不能对每个错误都做同样的事情。例如,如果 MetaMask 窗口已经打开,错误消息应该是检查你的钱包。如果用户取消操作,你就不会”不需要显示任何错误。如果钱包有问题,我应该提示他们重新下载或刷新页面才能继续。我不知道为什么你会在内部处理这个捕获而不给我任何反馈。提供为用户纠正错误消息是值得做的。”

您是说您无法让提供者抛出错误吗?即,如果元掩码抛出一个错误,您希望看到并能够捕获该错误?

Yes, not just metamask, but any other errors if they exist

from web3-onboard.

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.