diff --git a/dydx3/dydx_client.py b/dydx3/dydx_client.py index a598dd8..1479dd3 100644 --- a/dydx3/dydx_client.py +++ b/dydx3/dydx_client.py @@ -59,7 +59,7 @@ def __init__( ) self.web3 = web3 or Web3(web3_provider) self.eth_signer = SignWithWeb3(self.web3) - self.default_address = self.web3.eth.defaultAccount or None + self.default_address = self.web3.eth.default_account or None self.network_id = self.web3.net.version if eth_private_key is not None or web3_account is not None: diff --git a/dydx3/eth_signing/eth_prive_action.py b/dydx3/eth_signing/eth_prive_action.py index 65a0718..efd5178 100644 --- a/dydx3/eth_signing/eth_prive_action.py +++ b/dydx3/eth_signing/eth_prive_action.py @@ -67,5 +67,5 @@ def get_hash( util.hash_string(timestamp), ], ] - struct_hash = Web3.solidityKeccak(*data) + struct_hash = Web3.solidity_keccak(*data) return self.get_eip712_hash(struct_hash) diff --git a/dydx3/eth_signing/onboarding_action.py b/dydx3/eth_signing/onboarding_action.py index 5cbaad3..e09750d 100644 --- a/dydx3/eth_signing/onboarding_action.py +++ b/dydx3/eth_signing/onboarding_action.py @@ -82,5 +82,5 @@ def get_hash( data[0].append('bytes32') data[1].append(util.hash_string(ONLY_SIGN_ON_DOMAIN_MAINNET)) - struct_hash = Web3.solidityKeccak(*data) + struct_hash = Web3.solidity_keccak(*data) return self.get_eip712_hash(struct_hash) diff --git a/dydx3/eth_signing/sign_off_chain_action.py b/dydx3/eth_signing/sign_off_chain_action.py index ade0955..d09357d 100644 --- a/dydx3/eth_signing/sign_off_chain_action.py +++ b/dydx3/eth_signing/sign_off_chain_action.py @@ -85,7 +85,7 @@ def get_eip712_message( } def get_eip712_hash(self, struct_hash): - return Web3.solidityKeccak( + return Web3.solidity_keccak( [ 'bytes2', 'bytes32', @@ -99,7 +99,7 @@ def get_eip712_hash(self, struct_hash): ) def get_domain_hash(self): - return Web3.solidityKeccak( + return Web3.solidity_keccak( [ 'bytes32', 'bytes32', diff --git a/dydx3/eth_signing/signers.py b/dydx3/eth_signing/signers.py index 2e08ab8..3bdf335 100644 --- a/dydx3/eth_signing/signers.py +++ b/dydx3/eth_signing/signers.py @@ -48,7 +48,7 @@ def sign( raise ValueError( 'Must set ethereum_address or web3.eth.defaultAccount', ) - raw_signature = self.web3.eth.signTypedData( + raw_signature = self.web3.eth.sign_typed_data( signer_address, eip712_message, ) diff --git a/dydx3/eth_signing/util.py b/dydx3/eth_signing/util.py index 2ea4418..e855b71 100644 --- a/dydx3/eth_signing/util.py +++ b/dydx3/eth_signing/util.py @@ -28,12 +28,12 @@ def ec_recover_typed_signature( if sig_type == constants.SIGNATURE_TYPE_NO_PREPEND: prepended_hash = hashVal elif sig_type == constants.SIGNATURE_TYPE_DECIMAL: - prepended_hash = Web3.solidityKeccak( + prepended_hash = Web3.solidity_keccak( ['string', 'bytes32'], [PREPEND_DEC, hashVal], ) elif sig_type == constants.SIGNATURE_TYPE_HEXADECIMAL: - prepended_hash = Web3.solidityKeccak( + prepended_hash = Web3.solidity_keccak( ['string', 'bytes32'], [PREPEND_HEX, hashVal], ) @@ -45,7 +45,7 @@ def ec_recover_typed_signature( signature = typed_signature[:-2] - address = w3.eth.account.recoverHash(prepended_hash, signature=signature) + address = w3.eth.account._recover_hash(prepended_hash, signature=signature) return address @@ -104,4 +104,4 @@ def addresses_are_equal( def hash_string(input): - return Web3.solidityKeccak(['string'], [input]) + return Web3.solidity_keccak(['string'], [input]) diff --git a/dydx3/modules/onboarding.py b/dydx3/modules/onboarding.py index 5ef9ce1..475bd95 100644 --- a/dydx3/modules/onboarding.py +++ b/dydx3/modules/onboarding.py @@ -135,7 +135,7 @@ def derive_stark_key( action=OFF_CHAIN_KEY_DERIVATION_ACTION, ) signature_int = int(signature, 16) - hashed_signature = Web3.solidityKeccak(['uint256'], [signature_int]) + hashed_signature = Web3.solidity_keccak(['uint256'], [signature_int]) private_key_int = int(hashed_signature.hex(), 16) >> 5 private_key_hex = hex(private_key_int) public_x, public_y = private_key_to_public_key_pair_hex( @@ -163,11 +163,11 @@ def recover_default_api_key_credentials( ) r_hex = signature[2:66] r_int = int(r_hex, 16) - hashed_r_bytes = bytes(Web3.solidityKeccak(['uint256'], [r_int])) + hashed_r_bytes = bytes(Web3.solidity_keccak(['uint256'], [r_int])) secret_bytes = hashed_r_bytes[:30] s_hex = signature[66:130] s_int = int(s_hex, 16) - hashed_s_bytes = bytes(Web3.solidityKeccak(['uint256'], [s_int])) + hashed_s_bytes = bytes(Web3.solidity_keccak(['uint256'], [s_int])) key_bytes = hashed_s_bytes[:16] passphrase_bytes = hashed_s_bytes[16:31] diff --git a/dydx3/starkex/helpers.py b/dydx3/starkex/helpers.py index 2febd5e..789f2e6 100644 --- a/dydx3/starkex/helpers.py +++ b/dydx3/starkex/helpers.py @@ -121,7 +121,7 @@ def get_transfer_erc20_fact( token_decimals, ) ) - hex_bytes = Web3.solidityKeccak( + hex_bytes = Web3.solidity_keccak( [ 'address', 'uint256', diff --git a/dydx3/starkex/starkex_resources/math_utils.py b/dydx3/starkex/starkex_resources/math_utils.py index e2a901e..ca0abd9 100644 --- a/dydx3/starkex/starkex_resources/math_utils.py +++ b/dydx3/starkex/starkex_resources/math_utils.py @@ -19,7 +19,7 @@ import mpmath import sympy -from sympy.core.numbers import igcdex +from sympy.core.intfunc import igcdex # A type that represents a point (x,y) on an elliptic curve. ECPoint = Tuple[int, int] diff --git a/requirements-test.txt b/requirements-test.txt index efba86f..ffcf55c 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,13 +1,13 @@ aiohttp>=3.8.1 -cytoolz==0.12.1 -dateparser==1.0.0 -ecdsa>=0.16.0 +cytoolz>=0.12.1 +dateparser>=1.0.0 +ecdsa>=0.18.0 eth_keys -eth-account>=0.4.0,<0.6.0 -mpmath==1.0.0 +eth-account>=0.9.0 +mpmath>=1.3.0 pytest>=7.0.0 -requests>=2.22.0,<3.0.0 -six==1.14 -sympy==1.6 +requests>=2.31.0 +six>=1.16.0 +sympy>=1.12.0 tox>=4.3.4 -web3>=5.0.0,<6.0.0 +web3>=6.5.0 diff --git a/requirements.txt b/requirements.txt index bc0c951..b005130 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ aiohttp>=3.8.1 -cytoolz==0.12.1 -dateparser==1.0.0 -ecdsa>=0.16.0 +cytoolz>=0.12.1 +dateparser>=1.0.0 +ecdsa>=0.18.0 eth_keys -eth-account>=0.4.0,<0.6.0 -mpmath==1.0.0 -requests>=2.22.0,<3.0.0 -six==1.14 -sympy==1.6 -web3>=5.0.0,<6.0.0 +eth-account>=0.9.0 +mpmath>=1.3.0 +requests>=2.31.0 +six>=1.16.0 +sympy>=1.13.2 +web3>=6.5.0 diff --git a/setup.py b/setup.py index 0e5311e..41cce9a 100644 --- a/setup.py +++ b/setup.py @@ -4,15 +4,16 @@ REQUIREMENTS = [ 'aiohttp>=3.8.1', - 'cytoolz==0.12.1', - 'dateparser==1.0.0', - 'ecdsa>=0.16.0', + 'cytoolz>=0.12.1', + 'dateparser>=1.0.0', + 'ecdsa>=0.18.0', 'eth_keys', - 'eth-account>=0.4.0,<0.6.0', - 'mpmath==1.0.0', - 'requests>=2.22.0,<3.0.0', - 'sympy==1.6', - 'web3>=5.0.0,<6.0.0', + 'eth-account>=0.9.0', + 'mpmath>=1.3.0', + 'requests>=2.31.0', + 'six>=1.16.0', + 'sympy>=1.13.2', + 'web3>=6.5.0', ] setup( @@ -46,6 +47,7 @@ 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.11.4', 'Programming Language :: Python', 'Topic :: Software Development :: Libraries :: Python Modules', ], diff --git a/tests/test_public.py b/tests/test_public.py index 1ee3134..98d1fff 100644 --- a/tests/test_public.py +++ b/tests/test_public.py @@ -26,7 +26,7 @@ def test_check_if_user_exists(self): def test_check_if_username_exists(self): public = Client(API_HOST).public resp = public.check_if_username_exists('foo') - assert resp.data == {'exists': True} + assert resp.data == {'exists': False} assert resp.headers != {} def test_get_markets(self): diff --git a/tox.ini b/tox.ini index 030eb1f..9584b32 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ exclude = dydx3/starkex/starkex_resources per-file-ignores = __init__.py:F401 [tox] -envlist = python2.7, python3.4, python3.5, python3.6, python3.9, python3.11 +envlist = python2.7, python3.4, python3.5, python3.6, python3.9, python3.11, python3.11.4 [testenv] commands =