Updated signature for JsonRpcProvider.send to match EIP-1193.
This commit is contained in:
parent
375bd15594
commit
b962b59ab7
@ -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
|
// @TODO: Create a connection to the IPC path and use filters instead of polling for block
|
||||||
|
|
||||||
send(method: string, params: any): Promise<any> {
|
send(method: string, params: Array<any>): Promise<any> {
|
||||||
// This method is very simple right now. We create a new socket
|
// This method is very simple right now. We create a new socket
|
||||||
// connection each time, which may be slower, but the main
|
// connection each time, which may be slower, but the main
|
||||||
// advantage we are aiming for now is security. This simplifies
|
// advantage we are aiming for now is security. This simplifies
|
||||||
|
@ -290,7 +290,7 @@ export class JsonRpcProvider extends BaseProvider {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
send(method: string, params: any): Promise<any> {
|
send(method: string, params: Array<any>): Promise<any> {
|
||||||
let request = {
|
let request = {
|
||||||
method: method,
|
method: method,
|
||||||
params: params,
|
params: params,
|
||||||
|
@ -19,14 +19,6 @@ export type AsyncSendable = {
|
|||||||
send?: (request: any, callback: (error: any, response: any) => void) => void
|
send?: (request: any, callback: (error: any, response: any) => void) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@TODO
|
|
||||||
utils.defineProperty(Web3Signer, "onchange", {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
export class Web3Provider extends JsonRpcProvider {
|
export class Web3Provider extends JsonRpcProvider {
|
||||||
readonly provider: AsyncSendable;
|
readonly provider: AsyncSendable;
|
||||||
private _sendAsync: (request: any, callback: (error: any, response: any) => void) => void;
|
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);
|
logger.throwArgumentError("invalid web3Provider", "web3Provider", web3Provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
defineReadOnly(this, "provider", web3Provider);
|
defineReadOnly(this, "provider", web3Provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
send(method: string, params: any): Promise<any> {
|
send(method: string, params: Array<any>): Promise<any> {
|
||||||
|
|
||||||
// Metamask complains about eth_sign (and on some versions hangs)
|
// Metamask complains about eth_sign (and on some versions hangs)
|
||||||
if (method == "eth_sign" && this.provider.isMetaMask) {
|
if (method == "eth_sign" && this.provider.isMetaMask) {
|
||||||
@ -65,7 +57,7 @@ export class Web3Provider extends JsonRpcProvider {
|
|||||||
const request = {
|
const request = {
|
||||||
method: method,
|
method: method,
|
||||||
params: params,
|
params: params,
|
||||||
id: 42,
|
id: (this._nextId++),
|
||||||
jsonrpc: "2.0"
|
jsonrpc: "2.0"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user