Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade web3py version libraries #8

Merged
merged 1 commit into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions nevermined_sdk_py/nevermined/agreements.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def create(self, did, index, agreement_id,
else:
raise Exception('The agreement could not be created. Review the index of your service.')

if agreement_template.get_agreement_consumer(agreement_id) is not None:
if agreement_template.get_agreement_consumer(agreement_id) != '0x0000000000000000000000000000000000000000':
raise OceanServiceAgreementExists(
f'Service agreement {agreement_id} already exists, cannot reuse '
f'the same agreement id.')
Expand Down Expand Up @@ -278,7 +278,7 @@ def create_direct(self, did, index, agreement_id,
else:
raise Exception('The agreement could not be created. Review the index of your service.')

if agreement_template.get_agreement_consumer(agreement_id) is not None:
if agreement_template.get_agreement_consumer(agreement_id) != '0x0000000000000000000000000000000000000000':
raise OceanServiceAgreementExists(
f'Service agreement {agreement_id} already exists, cannot reuse '
f'the same agreement id.')
Expand Down
4 changes: 2 additions & 2 deletions nevermined_sdk_py/nevermined/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get(self, account):
:return: hex str the token generated/signed by account
"""
_message, _time = self._get_message_and_time()
msg_hash = Web3Provider.get_web3().sha3(text=_message)
msg_hash = Web3Provider.get_web3().keccak(text=_message)
try:
prefixed_msg_hash = self._keeper.sign_hash(
add_ethereum_prefix_and_hash_msg(msg_hash), account)
Expand All @@ -79,7 +79,7 @@ def check(self, token):
return '0x0'

message = self._get_message(timestamp)
address = self._keeper.personal_ec_recover(Web3Provider.get_web3().sha3(text=message), sig)
address = self._keeper.personal_ec_recover(Web3Provider.get_web3().keccak(text=message), sig)
return Web3Provider.get_web3().toChecksumAddress(address)

def store(self, account):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
'pyopenssl',
'PyJWT', # not jwt
'PyYAML==4.2b4',
'common-utils-py==0.2.0',
'contracts-lib-py==0.2.0',
'common-utils-py==0.2.1',
'contracts-lib-py==0.2.3',
'ocean-secret-store-client==0.0.1',
'requests==2.21.0',
'deprecated',
Expand Down
6 changes: 3 additions & 3 deletions tests/nevermined/test_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from common_utils_py.agreements.service_factory import ServiceDescriptor
from common_utils_py.agreements.service_types import ServiceTypes, ServiceTypesIndices
from common_utils_py.did import DID
from contracts_lib_py.exceptions import OceanDIDNotFound
from contracts_lib_py.exceptions import DIDNotFound
from contracts_lib_py.web3_provider import Web3Provider

from tests.resources.helper_functions import (get_algorithm_ddo, get_computing_metadata,
Expand Down Expand Up @@ -69,12 +69,12 @@ def test_resolve_did(publisher_instance, metadata):

# Can't resolve unregistered asset
unregistered_did = DID.did({"0": "0x00112233445566"})
with pytest.raises(OceanDIDNotFound):
with pytest.raises(DIDNotFound):
publisher_instance.assets.resolve(unregistered_did)

# Raise error on bad did
invalid_did = "did:nv:0123456789"
with pytest.raises(OceanDIDNotFound):
with pytest.raises(DIDNotFound):
publisher_instance.assets.resolve(invalid_did)
publisher_instance.assets.retire(did)

Expand Down