Skip to content

Commit

Permalink
forward sendTransaction requests to provider
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvlathey committed Sep 18, 2022
1 parent feafd61 commit de5bccb
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/chrome/impersonator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EventEmitter } from "events";
import { Provider, StaticJsonRpcProvider } from "@ethersproject/providers";
import { StaticJsonRpcProvider } from "@ethersproject/providers";
import { hexValue } from "@ethersproject/bytes";
import { Logger } from "@ethersproject/logger";

Expand All @@ -12,7 +12,7 @@ class ImpersonatorProvider extends EventEmitter {
isMetaMask = true;

private address: string;
private provider: Provider;
private provider: StaticJsonRpcProvider;
private chainId: number;

constructor(chainId: number, rpcUrl: string, address: string) {
Expand Down Expand Up @@ -124,7 +124,7 @@ class ImpersonatorProvider extends EventEmitter {
return throwUnsupported("personal_sign not supported");
}
case "eth_sendTransaction": {
return throwUnsupported("eth_sendTransaction not supported");
break;
}
// unchanged from Eip1193Bridge
case "eth_gasPrice": {
Expand Down Expand Up @@ -219,13 +219,9 @@ class ImpersonatorProvider extends EventEmitter {
break;
}

// If our provider supports send, maybe it can do a better job?
if ((this as any).provider.send) {
const result = await (this as any).provider.send(method, params);
return coerce(result);
}

return throwUnsupported(`unsupported method: ${method}`);
// @ts-ignore
const result = await this.provider.send(method, params);
return coerce(result);
}
}

Expand Down

0 comments on commit de5bccb

Please sign in to comment.