Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dydx3/dydx_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion dydx3/eth_signing/eth_prive_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion dydx3/eth_signing/onboarding_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions dydx3/eth_signing/sign_off_chain_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_eip712_message(
}

def get_eip712_hash(self, struct_hash):
return Web3.solidityKeccak(
return Web3.solidity_keccak(
[
'bytes2',
'bytes32',
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion dydx3/eth_signing/signers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
8 changes: 4 additions & 4 deletions dydx3/eth_signing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)
Expand All @@ -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


Expand Down Expand Up @@ -104,4 +104,4 @@ def addresses_are_equal(


def hash_string(input):
return Web3.solidityKeccak(['string'], [input])
return Web3.solidity_keccak(['string'], [input])
6 changes: 3 additions & 3 deletions dydx3/modules/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion dydx3/starkex/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get_transfer_erc20_fact(
token_decimals,
)
)
hex_bytes = Web3.solidityKeccak(
hex_bytes = Web3.solidity_keccak(
[
'address',
'uint256',
Expand Down
2 changes: 1 addition & 1 deletion dydx3/starkex/starkex_resources/math_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
18 changes: 9 additions & 9 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -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
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
18 changes: 10 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_public.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down