apibara/starknet-react

Please throw errors coming from wallet as they are

Opened this issue · 1 comments

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.

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