Skip to content

Commit

Permalink
Remove unnecessary suppressUnauthorized option
Browse files Browse the repository at this point in the history
The `suppressUnauthorized` option has been removed from the type
signature of the `getAccounts` parameter accepted by the `wallet`
middleware.

This option was added in #116 to fix an extension bug, but it was never
used in practice. The linked extension change used the wrong parameter
name (`suppressUnauthorizedError`), so this was always unset. We didn't
notice because it also wasn't needed to fix the bug; the
`resemblesAddress` condition added in that same PR was sufficient.
  • Loading branch information
Gudahtt committed Feb 10, 2023
1 parent ce20d95 commit b96ee30
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ export interface TypedMessageParams extends MessageParams {
}

export interface WalletMiddlewareOptions {
getAccounts: (
req: JsonRpcRequest<unknown>,
options?: {
suppressUnauthorized?: boolean;
},
) => Promise<string[]>;
getAccounts: (req: JsonRpcRequest<unknown>) => Promise<string[]>;
processDecryptMessage?: (
msgParams: MessageParams,
req: JsonRpcRequest<unknown>,
Expand Down Expand Up @@ -383,12 +378,9 @@ export function createWalletMiddleware({
address.length > 0 &&
resemblesAddress(address)
) {
// ensure address is included in provided accounts. `suppressUnauthorized: false` is passed to `getAccounts`
// so that an "unauthorized" error is thrown if the requester does not have the `eth_accounts`
// Ensure that an "unauthorized" error is thrown if the requester does not have the `eth_accounts`
// permission.
const accounts: string[] = await getAccounts(req, {
suppressUnauthorized: false,
});
const accounts = await getAccounts(req);
const normalizedAccounts: string[] = accounts.map((_address) =>
_address.toLowerCase(),
);
Expand Down

0 comments on commit b96ee30

Please sign in to comment.