From 63c99a3b76d6148964efd4efb5eabc21eb140214 Mon Sep 17 00:00:00 2001 From: Severin Bretscher Date: Sun, 3 Sep 2023 15:20:17 +0200 Subject: [PATCH 1/8] Elevate upper version constraints of affected packages and include python 3.11.4 definition in corresponding files --- requirements-test.txt | 4 ++-- requirements.txt | 4 ++-- setup.py | 5 +++-- tox.ini | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index efba86f..f69bc63 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -3,11 +3,11 @@ cytoolz==0.12.1 dateparser==1.0.0 ecdsa>=0.16.0 eth_keys -eth-account>=0.4.0,<0.6.0 +eth-account>=0.4.0,<=0.9.0 mpmath==1.0.0 pytest>=7.0.0 requests>=2.22.0,<3.0.0 six==1.14 sympy==1.6 tox>=4.3.4 -web3>=5.0.0,<6.0.0 +web3>=5.0.0,<=6.9.0 diff --git a/requirements.txt b/requirements.txt index bc0c951..9e671eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,9 +3,9 @@ cytoolz==0.12.1 dateparser==1.0.0 ecdsa>=0.16.0 eth_keys -eth-account>=0.4.0,<0.6.0 +eth-account>=0.4.0,<=0.9.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 +web3>=5.0.0,<=6.9.0 diff --git a/setup.py b/setup.py index a648d5b..b74f63b 100644 --- a/setup.py +++ b/setup.py @@ -8,11 +8,11 @@ 'dateparser==1.0.0', 'ecdsa>=0.16.0', 'eth_keys', - 'eth-account>=0.4.0,<0.6.0', + 'eth-account>=0.4.0,<=0.9.0', 'mpmath==1.0.0', 'requests>=2.22.0,<3.0.0', 'sympy==1.6', - 'web3>=5.0.0,<6.0.0', + 'web3>=5.0.0,<=6.9.0', ] setup( @@ -46,6 +46,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/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 = From 64f4871f1c799e6bcbde473757ce3f65bd21f21b Mon Sep 17 00:00:00 2001 From: Severin Bretscher Date: Sun, 3 Sep 2023 15:22:52 +0200 Subject: [PATCH 2/8] Change deprecated camelCase function names to snake_case as demanded by upgraded packages --- dydx3/dydx_client.py | 2 +- dydx3/eth_signing/eth_prive_action.py | 2 +- dydx3/eth_signing/onboarding_action.py | 2 +- dydx3/eth_signing/sign_off_chain_action.py | 4 ++-- dydx3/eth_signing/signers.py | 2 +- dydx3/eth_signing/util.py | 8 ++++---- dydx3/modules/onboarding.py | 6 +++--- dydx3/starkex/helpers.py | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) 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', From b47e03625a5511465f98273daacbf3db37c9ef9c Mon Sep 17 00:00:00 2001 From: Severin Bretscher Date: Tue, 24 Oct 2023 23:45:22 +0200 Subject: [PATCH 3/8] Increase version of sympy. --- requirements.txt | 2 +- setup.py | 2 +- tests/test_public.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 9e671eb..2e4fd54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,5 +7,5 @@ eth-account>=0.4.0,<=0.9.0 mpmath==1.0.0 requests>=2.22.0,<3.0.0 six==1.14 -sympy==1.6 +sympy<=1.12.0 web3>=5.0.0,<=6.9.0 diff --git a/setup.py b/setup.py index b74f63b..e03ce70 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ 'eth-account>=0.4.0,<=0.9.0', 'mpmath==1.0.0', 'requests>=2.22.0,<3.0.0', - 'sympy==1.6', + 'sympy<=1.12.0', 'web3>=5.0.0,<=6.9.0', ] diff --git a/tests/test_public.py b/tests/test_public.py index 98d1fff..696cba3 100644 --- a/tests/test_public.py +++ b/tests/test_public.py @@ -25,7 +25,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') + resp = public.check_if_username_exists('fuchur') assert resp.data == {'exists': False} assert resp.headers != {} From dca93782ca879f90852d0534e191fc5fee6a0dd7 Mon Sep 17 00:00:00 2001 From: Severin Bretscher Date: Wed, 25 Oct 2023 20:18:01 +0200 Subject: [PATCH 4/8] Modify sympy constraints. --- requirements-test.txt | 2 +- requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index f69bc63..91c3e51 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -8,6 +8,6 @@ mpmath==1.0.0 pytest>=7.0.0 requests>=2.22.0,<3.0.0 six==1.14 -sympy==1.6 +sympy>=1.12.0 tox>=4.3.4 web3>=5.0.0,<=6.9.0 diff --git a/requirements.txt b/requirements.txt index 2e4fd54..84a7dc0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,5 +7,5 @@ eth-account>=0.4.0,<=0.9.0 mpmath==1.0.0 requests>=2.22.0,<3.0.0 six==1.14 -sympy<=1.12.0 +sympy>=1.12.0 web3>=5.0.0,<=6.9.0 diff --git a/setup.py b/setup.py index e03ce70..296d673 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ 'eth-account>=0.4.0,<=0.9.0', 'mpmath==1.0.0', 'requests>=2.22.0,<3.0.0', - 'sympy<=1.12.0', + 'sympy>=1.12.0', 'web3>=5.0.0,<=6.9.0', ] From 228f272d853a8d904bb6ce8b30255cf97fa4a92d Mon Sep 17 00:00:00 2001 From: Severin Bretscher Date: Fri, 27 Oct 2023 17:24:30 +0200 Subject: [PATCH 5/8] Elevate multiple dependency constraints to ensure compatibility with V4 requirements. --- requirements-test.txt | 16 ++++++++-------- requirements.txt | 16 ++++++++-------- setup.py | 15 ++++++++------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index 91c3e51..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.9.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 +requests>=2.31.0 +six>=1.16.0 sympy>=1.12.0 tox>=4.3.4 -web3>=5.0.0,<=6.9.0 +web3>=6.5.0 diff --git a/requirements.txt b/requirements.txt index 84a7dc0..b000afc 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.9.0 -mpmath==1.0.0 -requests>=2.22.0,<3.0.0 -six==1.14 +eth-account>=0.9.0 +mpmath>=1.3.0 +requests>=2.31.0 +six>=1.16.0 sympy>=1.12.0 -web3>=5.0.0,<=6.9.0 +web3>=6.5.0 diff --git a/setup.py b/setup.py index 296d673..a13eaf9 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.9.0', - 'mpmath==1.0.0', - 'requests>=2.22.0,<3.0.0', + 'eth-account>=0.9.0', + 'mpmath>=1.3.0', + 'requests>=2.31.0', + 'six>=1.16.0', 'sympy>=1.12.0', - 'web3>=5.0.0,<=6.9.0', + 'web3>=6.5.0', ] setup( From 5df493dea7d8c7c9470432132c0c38d0c5059d8d Mon Sep 17 00:00:00 2001 From: sirEven Date: Mon, 11 Dec 2023 18:53:32 +0100 Subject: [PATCH 6/8] Make failing test derived from Sepolia commit green again (test_check_if_username_exists()). --- tests/test_public.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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): From 254eabef805d82e506c2b6c217ed8d6375adb320 Mon Sep 17 00:00:00 2001 From: sirEven Date: Tue, 10 Sep 2024 23:08:06 +0200 Subject: [PATCH 7/8] Update dependencies. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b000afc..b005130 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,5 +7,5 @@ eth-account>=0.9.0 mpmath>=1.3.0 requests>=2.31.0 six>=1.16.0 -sympy>=1.12.0 +sympy>=1.13.2 web3>=6.5.0 From 6b1fa62a3bafe47064f2098bfe2c2808c351c841 Mon Sep 17 00:00:00 2001 From: sirEven Date: Tue, 10 Sep 2024 23:47:56 +0200 Subject: [PATCH 8/8] Fix import error, adapt setup.py version of sympy. --- dydx3/starkex/starkex_resources/math_utils.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/setup.py b/setup.py index 3308301..41cce9a 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ 'mpmath>=1.3.0', 'requests>=2.31.0', 'six>=1.16.0', - 'sympy>=1.12.0', + 'sympy>=1.13.2', 'web3>=6.5.0', ]