eth-provider
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -36,6 +36,6 @@ const EventEmitter = require('events') | ||
this.connection.on('close', (summary) => { | ||
this.connection.on('close', () => { | ||
this.connected = false | ||
this.emit('close') | ||
if (!this.closing) this.refresh() | ||
if (!this.closing) return this.refresh() | ||
this.close() | ||
}) | ||
@@ -77,3 +77,3 @@ | ||
this.closing = true | ||
if (this.connection) { | ||
if (this.connection && !this.connection.closed) { | ||
this.connection.close() // Let event bubble from here | ||
@@ -84,2 +84,3 @@ } else { | ||
clearTimeout(this.connectTimer) | ||
clearTimeout(this.setupTimer) | ||
} | ||
@@ -93,5 +94,5 @@ | ||
if (this.inSetup) { | ||
setTimeout(() => this.send(payload), 100) | ||
this.setupTimer = setTimeout(() => this.send(payload), 100) | ||
} else if (this.connection.closed) { | ||
this.error(payload, 'Not connected') | ||
this.error(payload, 'Not connected', 4900) | ||
} else { | ||
@@ -98,0 +99,0 @@ this.connection.send(payload) |
@@ -30,2 +30,4 @@ const EventEmitter = require('events') | ||
if (err) return this.emit('error', err) | ||
this.connected = true | ||
this.emit('connect') | ||
this.send({ jsonrpc: '2.0', id: 1, method: 'eth_pollSubscriptions', params: [this.pollId, 'immediate'] }, (err, response) => { | ||
@@ -36,4 +38,2 @@ if (!err) { | ||
} | ||
this.connected = true | ||
this.emit('connect') | ||
}) | ||
@@ -40,0 +40,0 @@ }) |
@@ -64,3 +64,7 @@ const EventEmitter = require('events') | ||
} else { | ||
this.socket.write(JSON.stringify(Object.assign({}, payload))) | ||
try { | ||
this.socket.write(JSON.stringify(Object.assign({}, payload))) | ||
} catch (e) { | ||
this.error(payload, e.message) | ||
} | ||
} | ||
@@ -67,0 +71,0 @@ } |
{ | ||
"name": "eth-provider", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "A Universal Ethereum Provider", | ||
@@ -8,3 +8,3 @@ "browser": "browser.js", | ||
"scripts": { | ||
"test": "standard && npm run test:web3:v0 && npm run test:web3:v1 && npm run test:frame && npm run test:endpoints && npm run test:eip1193", | ||
"test": "standard --fix && npm run test:web3:v0 && npm run test:web3:v1 && npm run test:frame && npm run test:endpoints && npm run test:eip1193", | ||
"test:web3": "npm run test:web3:v0 && npm run test:web3:latest", | ||
@@ -29,10 +29,10 @@ "test:web3:v0": "npm install web3@0.20.7 && mocha test/web3-v0.x.js", | ||
"dependencies": { | ||
"ethereum-provider": "0.1.1", | ||
"ethereum-provider": "0.1.2", | ||
"oboe": "2.1.5", | ||
"uuid": "8.1.0", | ||
"ws": "7.3.0", | ||
"uuid": "8.3.0", | ||
"ws": "7.3.1", | ||
"xhr2-cookies": "1.1.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "7.2.0", | ||
"mocha": "8.1.3", | ||
"standard": "14.3.4", | ||
@@ -39,0 +39,0 @@ "web3": "^1.2.8" |
@@ -11,3 +11,3 @@ /* globals describe it */ | ||
assert(chainId) | ||
}) | ||
}).timeout(45 * 1000) | ||
@@ -18,3 +18,3 @@ it('should return accounts', async () => { | ||
assert(accounts) | ||
}) | ||
}).timeout(45 * 1000) | ||
@@ -26,3 +26,3 @@ it('should return accounts (again)', async () => { | ||
it('should pass on accountChance', done => { | ||
it('should pass on accountChange', done => { | ||
ethereum.once('accountsChanged', accounts => { | ||
@@ -29,0 +29,0 @@ assert(Array.isArray(accounts)) |
@@ -39,3 +39,3 @@ /* globals describe it */ | ||
}) | ||
}) | ||
}).timeout(45 * 1000) | ||
it('should error due to being closed', done => { | ||
@@ -42,0 +42,0 @@ web3http.eth.getAccounts().then().catch(err => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
548580
919
+ Addedethereum-provider@0.1.2(transitive)
+ Addeduuid@8.3.0(transitive)
+ Addedws@7.3.1(transitive)
- Removedethereum-provider@0.1.1(transitive)
- Removeduuid@8.1.0(transitive)
- Removedws@7.3.0(transitive)
Updatedethereum-provider@0.1.2
Updateduuid@8.3.0
Updatedws@7.3.1