kernel-eth-client/src/provider.ts

20 lines
557 B
TypeScript
Raw Normal View History

2023-03-27 12:54:11 +00:00
import { Eip1193Provider, ethers } from "ethers";
import { createClient, EthClient } from "./client.js";
export class Provider implements Eip1193Provider {
private client: EthClient = createClient();
public async request(args: RequestArguments): Promise<unknown> {
return this.client.method(args.method, args.params);
}
}
interface RequestArguments {
readonly method: string;
readonly params?: readonly unknown[] | object;
}
export function createProvider(): ethers.BrowserProvider {
return new ethers.BrowserProvider(new Provider());
}