Skip to content

Commit

Permalink
Added experimental EipWrappedProvider.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Feb 10, 2020
1 parent b962b59 commit 944600d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions packages/experimental/src.ts/eip-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"use strict";

import { ethers } from "ethers";

import { version } from "./_version";

const logger = new ethers.utils.Logger(version);

//import { Networkish } from "@ethersproject/networks";
//import { defineReadOnly } from "@ethersproject/properties";

//import { Logger } from "@ethersproject/logger";
//import { version } from "./_version";
//const logger = new Logger(version);

//import { JsonRpcProvider } from "./json-rpc-provider";


// Exported Types
export interface Eip1193Provider {
send: (message: string, params?: Array<any>) => Promise<any>;
on(eventName: string, listener: (...args: Array<any>) => void): this;
}


export class EipWrappedProvider extends ethers.providers.JsonRpcProvider {
readonly provider: Eip1193Provider;

constructor(provider: Eip1193Provider, network?: ethers.providers.Networkish) {
logger.checkNew(new.target, EipWrappedProvider);

super("eip1193:/\/", network);

ethers.utils.defineReadOnly(this, "provider", provider);
}

send(method: string, params: any): Promise<any> {
return this.provider.send(method, params);
}
}

0 comments on commit 944600d

Please sign in to comment.