Skip to content

Commit

Permalink
Merge branch 'master' into more_assets
Browse files Browse the repository at this point in the history
  • Loading branch information
mehul0698 authored Mar 21, 2019
2 parents 2393efa + 9c87441 commit 9d7937f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/app/local.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ GITHUB_API_TOKEN=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_APP_NAME=

INFURA_USE_V3=True
2 changes: 2 additions & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@

# Web3
WEB3_HTTP_PROVIDER = env('WEB3_HTTP_PROVIDER', default='https://rinkeby.infura.io')
INFURA_USE_V3 = env.bool('INFURA_USE_V3', False)
INFURA_V3_PROJECT_ID = env('INFURA_V3_PROJECT_ID', default='1e0a90928efe4bb78bb1eeceb8aacc27')

# COLO Coin
COLO_ACCOUNT_ADDRESS = env('COLO_ACCOUNT_ADDRESS', default='') # TODO
Expand Down
6 changes: 5 additions & 1 deletion app/dashboard/tests/test_dashboard_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""
from unittest.mock import patch

from django.conf import settings
from django.test.client import RequestFactory

from dashboard.utils import (
Expand All @@ -42,7 +43,10 @@ def test_get_web3():
assert isinstance(web3_provider, Web3)
assert len(web3_provider.providers) == 1
assert isinstance(web3_provider.providers[0], HTTPProvider)
assert web3_provider.providers[0].endpoint_uri == f'https://{network}.infura.io'
if settings.INFURA_USE_V3:
assert web3_provider.providers[0].endpoint_uri == f'https://{network}.infura.io/v3/{settings.INFURA_V3_PROJECT_ID}'
else:
assert web3_provider.providers[0].endpoint_uri == f'https://{network}.infura.io'

@staticmethod
def test_get_bounty_contract():
Expand Down
11 changes: 9 additions & 2 deletions app/dashboard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,16 @@ def get_web3(network, sockets=False):
"""
if network in ['mainnet', 'rinkeby', 'ropsten']:
if sockets:
provider = WebsocketProvider(f'wss://{network}.infura.io/ws')
if settings.INFURA_USE_V3:
provider = WebsocketProvider(f'wss://{network}.infura.io/ws/v3/{settings.INFURA_V3_PROJECT_ID}')
else:
provider = WebsocketProvider(f'wss://{network}.infura.io/ws')
else:
provider = HTTPProvider(f'https://{network}.infura.io')
if settings.INFURA_USE_V3:
provider = HTTPProvider(f'https://{network}.infura.io/v3/{settings.INFURA_V3_PROJECT_ID}')
else:
provider = HTTPProvider(f'https://{network}.infura.io')

w3 = Web3(provider)
if network == 'rinkeby':
w3.middleware_stack.inject(geth_poa_middleware, layer=0)
Expand Down
2 changes: 2 additions & 0 deletions docs/ENVIRONMENT_VARIABLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ The below environment variables are useful for overwriting [Django Silk](https:/
| Variable | Description | Type | Default |
| --- | --- | --- | --- |
| WEB3_HTTP_PROVIDER | The Web3 HTTP provider URI to be used. | `str` | https://rinkeby.infura.io |
| INFURA_USE_V3 | Use new API | `bool` | False |
| INFURA_V3_PROJECT_ID | Infura Project ID | `str` | 1e0a90928efe4bb78bb1eeceb8aacc27 |

## VSCode Remote Debugging

Expand Down

0 comments on commit 9d7937f

Please sign in to comment.