From b962b59ab72e67bc4566a361964e42cf1b791025 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Mon, 10 Feb 2020 15:39:38 -0500 Subject: [PATCH] Updated signature for JsonRpcProvider.send to match EIP-1193. --- packages/providers/src.ts/ipc-provider.ts | 2 +- packages/providers/src.ts/json-rpc-provider.ts | 2 +- packages/providers/src.ts/web3-provider.ts | 14 +++----------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/providers/src.ts/ipc-provider.ts b/packages/providers/src.ts/ipc-provider.ts index 5bb279e3a..878549aab 100644 --- a/packages/providers/src.ts/ipc-provider.ts +++ b/packages/providers/src.ts/ipc-provider.ts @@ -29,7 +29,7 @@ export class IpcProvider extends JsonRpcProvider { // @TODO: Create a connection to the IPC path and use filters instead of polling for block - send(method: string, params: any): Promise { + send(method: string, params: Array): Promise { // This method is very simple right now. We create a new socket // connection each time, which may be slower, but the main // advantage we are aiming for now is security. This simplifies diff --git a/packages/providers/src.ts/json-rpc-provider.ts b/packages/providers/src.ts/json-rpc-provider.ts index 2321756a3..48c1c3ef0 100644 --- a/packages/providers/src.ts/json-rpc-provider.ts +++ b/packages/providers/src.ts/json-rpc-provider.ts @@ -290,7 +290,7 @@ export class JsonRpcProvider extends BaseProvider { }); } - send(method: string, params: any): Promise { + send(method: string, params: Array): Promise { let request = { method: method, params: params, diff --git a/packages/providers/src.ts/web3-provider.ts b/packages/providers/src.ts/web3-provider.ts index 035a19020..c4e3b08a7 100644 --- a/packages/providers/src.ts/web3-provider.ts +++ b/packages/providers/src.ts/web3-provider.ts @@ -19,14 +19,6 @@ export type AsyncSendable = { send?: (request: any, callback: (error: any, response: any) => void) => void } -/* -@TODO -utils.defineProperty(Web3Signer, "onchange", { - -}); - -*/ - export class Web3Provider extends JsonRpcProvider { readonly provider: AsyncSendable; private _sendAsync: (request: any, callback: (error: any, response: any) => void) => void; @@ -45,14 +37,14 @@ export class Web3Provider extends JsonRpcProvider { } } - if (!web3Provider || !this._sendAsync) { + if (!this._sendAsync) { logger.throwArgumentError("invalid web3Provider", "web3Provider", web3Provider); } defineReadOnly(this, "provider", web3Provider); } - send(method: string, params: any): Promise { + send(method: string, params: Array): Promise { // Metamask complains about eth_sign (and on some versions hangs) if (method == "eth_sign" && this.provider.isMetaMask) { @@ -65,7 +57,7 @@ export class Web3Provider extends JsonRpcProvider { const request = { method: method, params: params, - id: 42, + id: (this._nextId++), jsonrpc: "2.0" };