Increment JSON-RPC ID for JsonRpcProviders for environments that unsafely manage callbacks (#489).

This commit is contained in:
Richard Moore 2019-04-18 13:49:37 +02:00
parent 04c92bb8d5
commit c93b48920e
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295

View File

@ -50,6 +50,11 @@ function getLowerCase(value: string): string {
const _constructorGuard = {}; const _constructorGuard = {};
// Some environments (Trust Wallet and company) use a global map
// to track JSON-RPC ID, so we try to keep IDs unique across all
// connections. See #489.
let _nextId = 42;
export class JsonRpcSigner extends Signer { export class JsonRpcSigner extends Signer {
readonly provider: JsonRpcProvider; readonly provider: JsonRpcProvider;
private _index: number; private _index: number;
@ -250,7 +255,7 @@ export class JsonRpcProvider extends BaseProvider {
let request = { let request = {
method: method, method: method,
params: params, params: params,
id: 42, id: (_nextId++),
jsonrpc: "2.0" jsonrpc: "2.0"
}; };