Skip to content

Commit

Permalink
Increment JSON-RPC ID for JsonRpcProviders for environments that unsa…
Browse files Browse the repository at this point in the history
…fely manage callbacks (#489).
  • Loading branch information
ricmoo committed Apr 18, 2019
1 parent 04c92bb commit c93b489
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src.ts/providers/json-rpc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ function getLowerCase(value: string): string {

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 {
readonly provider: JsonRpcProvider;
private _index: number;
Expand Down Expand Up @@ -250,7 +255,7 @@ export class JsonRpcProvider extends BaseProvider {
let request = {
method: method,
params: params,
id: 42,
id: (_nextId++),
jsonrpc: "2.0"
};

Expand Down

0 comments on commit c93b489

Please sign in to comment.