diff --git a/clients/js/src/provider.ts b/clients/js/src/provider.ts index 1287f5ab..639872a8 100644 --- a/clients/js/src/provider.ts +++ b/clients/js/src/provider.ts @@ -85,10 +85,10 @@ export function isWrappedEthereumProvider

( * @param options (optional) Re-use parameters from other providers * @returns Sapphire wrapped provider */ -export async function wrapEthereumProvider

( +export function wrapEthereumProvider

( upstream: P, - options?: SapphireWrapConfig, -): Promise

{ + options?: SapphireWrapOptions, +): P { if (isWrappedEthereumProvider(upstream)) { return upstream; } @@ -104,7 +104,7 @@ export async function wrapEthereumProvider

( // if we do this, don't then re-wrap the send() function // only wrap the send() function if there was a request() function - const request = await makeSapphireRequestFn(upstream, filled_options); + const request = makeSapphireRequestFn(upstream, filled_options); const hooks: Record = { request }; // We prefer a request() method, but a provider may expose a send() method @@ -208,21 +208,20 @@ export function isCallDataPublicKeyQuery(params?: object | readonly unknown[]) { * @param options * @returns */ -export async function makeSapphireRequestFn( +export function makeSapphireRequestFn( provider: EIP2696_EthereumProvider, options?: SapphireWrapOptions, -): Promise { +): EIP2696_EthereumProvider['request'] { if (isWrappedRequestFn(provider.request)) { return provider.request; } const filled_options = fillOptions(options); - const snapId = filled_options.enableSapphireSnap + const f = async (args: EIP1193_RequestArguments) => { + const snapId = filled_options.enableSapphireSnap ? await detectSapphireSnap(provider) : undefined; - - const f = async (args: EIP1193_RequestArguments) => { const cipher = await filled_options.fetcher.cipher(provider); const { method, params } = args;