Comments (4)
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.
Sorry, my English is not good, I mean
你不能给每个错误做相同的事情
比如已经打开了一个 metamask 窗口,报错提示应该是去检查你的钱包
如果是用户取消了这个操作,可以不提示任何错误
如果是钱包出了问题,我应该提示他重新下载或刷新页面去操作。
我不知道为何要把这个 catch 在内部处理掉而不给我反馈的任何理由。把错误正确提示来对于用户来说,很值得去做
from web3-onboard.
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添加上下文翻译: “你不能对每个错误都做同样的事情。例如,如果 MetaMask 窗口已经打开,错误消息应该是检查你的钱包。如果用户取消操作,你就不会”不需要显示任何错误。如果钱包有问题,我应该提示他们重新下载或刷新页面才能继续。我不知道为什么你会在内部处理这个捕获而不给我任何反馈。提供为用户纠正错误消息是值得做的。”
您是说您无法让提供者抛出错误吗?即,如果元掩码抛出一个错误,您希望看到并能够捕获该错误?
Yes, not just metamask, but any other errors if they exist
from web3-onboard.
Related Issues (20)
- still gets walletConnect V1 deprecated warnings HOT 2
- [Feature]: Use ethers v6 HOT 2
- [Bug] Onboard wallet modal ios chrome when trying to connect HOT 1
- Web3Onboard Walletconnect - Failed to publish payload, please try again HOT 4
- WalletConnect fails to connect when both icon and logo are large SVGs HOT 2
- wallectConnect not working HOT 5
- CORS issue with Ledger HOT 6
- disableModals doesn't work with WalletConnect HOT 1
- Uncaught TypeError: Failed to resolve module specifier "@web3-onboard/core". Relative references must start with either "/", "./", or "../". HOT 1
- Error: To use QR modal, please install @walletconnect/modal package HOT 2
- WalletConnect demo not working HOT 2
- My project
- ERROR in ./node_modules/@web3-onboard/core/dist/Index-a8f5e52f.js | Module parse failed: Unexpected token (2148:140) | Vue2 + Nuxt HOT 5
- state is not defined ReferenceError: state is not defined
- UI attempts to display even when not connected
- Update Onboard Ledger Connect Kit deps HOT 2
- Import error in Angular with @web3-onboard/walletconnect
- [Feature]:
- Coinbase Connect issue with blacklisting Dapp HOT 1
- [Bug] MetaMaskSDK `extensionOnly: true` breaks the connecting to MetaMask HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web3-onboard.