From b69f43bc6f35da881ca7a0c8ccc5fda92edd076d Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 2 Feb 2024 03:10:40 -0500 Subject: [PATCH] Assert BrowserProvider receives an EIP-1193 provider to fail early when passing undefined ethereum object. --- src.ts/providers/provider-browser.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src.ts/providers/provider-browser.ts b/src.ts/providers/provider-browser.ts index 6f95a60335..8b45957625 100644 --- a/src.ts/providers/provider-browser.ts +++ b/src.ts/providers/provider-browser.ts @@ -49,6 +49,8 @@ export class BrowserProvider extends JsonRpcApiPollingProvider { * %%network%%. */ constructor(ethereum: Eip1193Provider, network?: Networkish) { + assertArgument(ethereum && ethereum.request, "invalid EIP-1193 provider", "ethereum", ethereum); + super(network, { batchMaxCount: 1 }); this.#request = async (method: string, params: Array | Record) => {