@@ -3,10 +3,11 @@ import { assertArgument } from "../utils/index.js";
33import { JsonRpcApiPollingProvider } from "./provider-jsonrpc.js" ;
44
55import type {
6+ JsonRpcApiProviderOptions ,
67 JsonRpcError , JsonRpcPayload , JsonRpcResult ,
78 JsonRpcSigner
89} from "./provider-jsonrpc.js" ;
9- import type { Networkish } from "./network.js" ;
10+ import type { Network , Networkish } from "./network.js" ;
1011
1112/**
1213 * The interface to an [[link-eip-1193]] provider, which is a standard
@@ -35,6 +36,13 @@ export type DebugEventBrowserProvider = {
3536 error : Error
3637} ;
3738
39+ export type BrowserProviderOptions = {
40+ polling ?: boolean ;
41+ staticNetwork ?: null | boolean | Network ;
42+
43+ cacheTimeout ?: number ;
44+ pollingInterval ?: number ;
45+ } ;
3846
3947/**
4048 * A **BrowserProvider** is intended to wrap an injected provider which
@@ -48,10 +56,15 @@ export class BrowserProvider extends JsonRpcApiPollingProvider {
4856 * Connnect to the %%ethereum%% provider, optionally forcing the
4957 * %%network%%.
5058 */
51- constructor ( ethereum : Eip1193Provider , network ?: Networkish ) {
59+ constructor ( ethereum : Eip1193Provider , network ?: Networkish , _options ?: BrowserProviderOptions ) {
60+ // Copy the options
61+ const options : JsonRpcApiProviderOptions = Object . assign ( { } ,
62+ ( ( _options != null ) ? _options : { } ) ,
63+ { batchMaxCount : 1 } ) ;
64+
5265 assertArgument ( ethereum && ethereum . request , "invalid EIP-1193 provider" , "ethereum" , ethereum ) ;
5366
54- super ( network , { batchMaxCount : 1 } ) ;
67+ super ( network , options ) ;
5568
5669 this . #request = async ( method : string , params : Array < any > | Record < string , any > ) => {
5770 const payload = { method, params } ;
0 commit comments