Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please throw errors coming from wallet as they are #543

Open
delivan opened this issue Dec 5, 2024 · 1 comment
Open

Please throw errors coming from wallet as they are #543

delivan opened this issue Dec 5, 2024 · 1 comment

Comments

@delivan
Copy link

delivan commented Dec 5, 2024

Currently, when connect is called and an error is returned from the wallet, a dapp receives only a UserRejectedRequestError object. However, the reasons for errors returned by the wallet are more diverse.

async connect(_args: ConnectArgs = {}): Promise<ConnectorData> {
this.ensureWallet();
if (!this._wallet) {
throw new ConnectorNotFoundError();
}
let accounts: string[];
try {
accounts = await this.request({
type: "wallet_requestAccounts",
});
} catch {
throw new UserRejectedRequestError();
}
if (!accounts) {
throw new UserRejectedRequestError();
}

To allow the DApp to handle errors appropriately based on their specific cause, I propose that the wallet return the original error to a dapp.

@fracek
Copy link
Contributor

fracek commented Dec 13, 2024

I agree with this, but it will also be a breaking change. Will do that in v4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants