Skip to content

Commit

Permalink
Fixed basic auth when Web3 HttpProvider is used
Browse files Browse the repository at this point in the history
  • Loading branch information
baxy committed Dec 20, 2018
1 parent 221ebee commit b3f727f
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 132 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Changelog
All notable changes to this project will be documented in this file.

## [2.4.11] - 2018-12-20
- Fixed basic auth when Web3 HttpProvider is used

## [2.4.10] - 2018-12-12
- Added privacy policy on register
- Bug fix - reinit web3 provider when no new blocks received for more then 1 hour
- Updated README file
- Updated README file

## [2.4.9] - 2018-11-22
- Updated package.json
Expand Down
7 changes: 5 additions & 2 deletions lib/client/protocol/Http.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import url from 'url';
import Web3 from 'web3-0.x-wrapper';
import parallel from 'async/parallel';
import Abstract from './Abstract.js';
Expand All @@ -15,8 +16,10 @@ export default class Http extends Abstract {

connect() {
if (!this.web3.currentProvider) {
this.log.echo(`Setting Web3 provider to "${this.url}"`);
this.web3.setProvider(new this.web3.providers.HttpProvider(this.url));
let urlObject = new url.URL(this.url);

this.log.echo(`Setting Web3 provider to "${urlObject.origin}"`);
this.web3.setProvider(new this.web3.providers.HttpProvider(urlObject.origin, 0, urlObject.username, urlObject.password));
}

if (!this.web3.isConnected()) {
Expand Down
Loading

0 comments on commit b3f727f

Please sign in to comment.