Skip to content

Commit

Permalink
Updated experimental Eip1193Bridge to support final EIP-1193 API.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Apr 20, 2021
1 parent 51f0e1a commit 2911659
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/experimental/src.ts/eip1193-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ export class Eip1193Bridge extends EventEmitter {
ethers.utils.defineReadOnly(this, "provider", provider || null);
}

request(request: { method: string, params?: Array<any>}): Promise<any> {
return this.send(request.method, request.params || []);
}

async send(method: string, params?: Array<any>): Promise<any> {
function throwUnsupported(message: string): never {
return logger.throwError("eth_sign requires a signer", ethers.utils.Logger.errors.UNSUPPORTED_OPERATION, {
return logger.throwError(message, ethers.utils.Logger.errors.UNSUPPORTED_OPERATION, {
method: method,
params: params
});
Expand Down Expand Up @@ -125,7 +129,7 @@ export class Eip1193Bridge extends EventEmitter {

case "eth_sendTransaction": {
if (!this.signer) {
return throwUnsupported("eth_sign requires an account");
return throwUnsupported("eth_sendTransaction requires an account");
}

const req = ethers.providers.JsonRpcProvider.hexlifyTransaction(params[0]);
Expand Down

0 comments on commit 2911659

Please sign in to comment.