Skip to content

Commit e31dc16

Browse files
author
konichuvak
committed
Upgrades web3.py version in requirements
1 parent d9be2be commit e31dc16

File tree

13 files changed

+32
-32
lines changed

13 files changed

+32
-32
lines changed

dydx3/dydx_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(
5959
)
6060
self.web3 = web3 or Web3(web3_provider)
6161
self.eth_signer = SignWithWeb3(self.web3)
62-
self.default_address = self.web3.eth.defaultAccount or None
62+
self.default_address = self.web3.eth.default_account or None
6363
self.network_id = self.web3.net.version
6464

6565
if eth_private_key is not None or web3_account is not None:

dydx3/eth_signing/eth_prive_action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ def get_hash(
6767
util.hash_string(timestamp),
6868
],
6969
]
70-
struct_hash = Web3.solidityKeccak(*data)
70+
struct_hash = Web3.solidity_keccak(*data)
7171
return self.get_eip712_hash(struct_hash)

dydx3/eth_signing/onboarding_action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@ def get_hash(
8282
data[0].append('bytes32')
8383
data[1].append(util.hash_string(ONLY_SIGN_ON_DOMAIN_MAINNET))
8484

85-
struct_hash = Web3.solidityKeccak(*data)
85+
struct_hash = Web3.solidity_keccak(*data)
8686
return self.get_eip712_hash(struct_hash)

dydx3/eth_signing/sign_off_chain_action.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def get_eip712_message(
8585
}
8686

8787
def get_eip712_hash(self, struct_hash):
88-
return Web3.solidityKeccak(
88+
return Web3.solidity_keccak(
8989
[
9090
'bytes2',
9191
'bytes32',
@@ -99,7 +99,7 @@ def get_eip712_hash(self, struct_hash):
9999
)
100100

101101
def get_domain_hash(self):
102-
return Web3.solidityKeccak(
102+
return Web3.solidity_keccak(
103103
[
104104
'bytes32',
105105
'bytes32',

dydx3/eth_signing/signers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ def sign(
4343
message_hash, # Ignored.
4444
opt_signer_address,
4545
):
46-
signer_address = opt_signer_address or self.web3.eth.defaultAccount
46+
signer_address = opt_signer_address or self.web3.eth.default_account
4747
if not signer_address:
4848
raise ValueError(
4949
'Must set ethereum_address or web3.eth.defaultAccount',
5050
)
51-
raw_signature = self.web3.eth.signTypedData(
51+
raw_signature = self.web3.eth.sign_typed_data(
5252
signer_address,
5353
eip712_message,
5454
)

dydx3/eth_signing/util.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@ def ec_recover_typed_signature(
2828
if sig_type == constants.SIGNATURE_TYPE_NO_PREPEND:
2929
prepended_hash = hashVal
3030
elif sig_type == constants.SIGNATURE_TYPE_DECIMAL:
31-
prepended_hash = Web3.solidityKeccak(
31+
prepended_hash = Web3.solidity_keccak(
3232
['string', 'bytes32'],
3333
[PREPEND_DEC, hashVal],
3434
)
3535
elif sig_type == constants.SIGNATURE_TYPE_HEXADECIMAL:
36-
prepended_hash = Web3.solidityKeccak(
36+
prepended_hash = Web3.solidity_keccak(
3737
['string', 'bytes32'],
3838
[PREPEND_HEX, hashVal],
3939
)
4040
else:
41-
raise Exception('Invalid signature type: ' + sig_type)
41+
raise Exception('Invalid signature type: ' + str(sig_type))
4242

4343
if not prepended_hash:
4444
raise Exception('Invalid hash: ' + hashVal)
4545

4646
signature = typed_signature[:-2]
4747

48-
address = w3.eth.account.recoverHash(prepended_hash, signature=signature)
48+
address = w3.eth.account._recover_hash(prepended_hash, signature=signature)
4949
return address
5050

5151

@@ -104,4 +104,4 @@ def addresses_are_equal(
104104

105105

106106
def hash_string(input):
107-
return Web3.solidityKeccak(['string'], [input])
107+
return Web3.solidity_keccak(['string'], [input])

dydx3/modules/eth.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def get_exchange_contract(
8484
self.network_id,
8585
)
8686
)
87-
contract_address = Web3.toChecksumAddress(contract_address)
87+
contract_address = Web3.to_checksum_address(contract_address)
8888
return self.get_contract(contract_address, STARKWARE_PERPETUALS_ABI)
8989

9090
def get_token_contract(
@@ -101,7 +101,7 @@ def get_token_contract(
101101
self.network_id,
102102
)
103103
)
104-
token_address = Web3.toChecksumAddress(token_address)
104+
token_address = Web3.to_checksum_address(token_address)
105105
return self.get_contract(token_address, ERC20_ABI)
106106

107107
def send_eth_transaction(
@@ -123,7 +123,7 @@ def send_eth_transaction(
123123
if 'gasPrice' not in options:
124124
try:
125125
options['gasPrice'] = (
126-
self.web3.eth.gasPrice + DEFAULT_GAS_PRICE_ADDITION
126+
self.web3.eth.gas_price + DEFAULT_GAS_PRICE_ADDITION
127127
)
128128
except Exception:
129129
options['gasPrice'] = DEFAULT_GAS_PRICE
@@ -140,7 +140,7 @@ def send_eth_transaction(
140140

141141
signed = self.sign_tx(method, options)
142142
try:
143-
tx_hash = self.web3.eth.sendRawTransaction(signed.rawTransaction)
143+
tx_hash = self.web3.eth.send_raw_transaction(signed.rawTransaction)
144144
except ValueError as error:
145145
while (
146146
auto_detect_nonce and
@@ -152,7 +152,7 @@ def send_eth_transaction(
152152
try:
153153
options['nonce'] += 1
154154
signed = self.sign_tx(method, options)
155-
tx_hash = self.web3.eth.sendRawTransaction(
155+
tx_hash = self.web3.eth.send_raw_transaction(
156156
signed.rawTransaction,
157157
)
158158
except ValueError as inner_error:
@@ -173,7 +173,7 @@ def get_next_nonce(
173173
):
174174
if self._next_nonce_for_address.get(ethereum_address) is None:
175175
self._next_nonce_for_address[ethereum_address] = (
176-
self.web3.eth.getTransactionCount(ethereum_address)
176+
self.web3.eth.get_transaction_count(ethereum_address)
177177
)
178178
return self._next_nonce_for_address[ethereum_address]
179179

@@ -205,7 +205,7 @@ def wait_for_tx(
205205
206206
:raises: TransactionReverted
207207
'''
208-
tx_receipt = self.web3.eth.waitForTransactionReceipt(tx_hash)
208+
tx_receipt = self.web3.eth.wait_for_transaction_receipt(tx_hash)
209209
if tx_receipt['status'] == 0:
210210
raise TransactionReverted(tx_receipt)
211211

@@ -400,7 +400,7 @@ def transfer_eth(
400400
options=dict(
401401
send_options,
402402
to=to_address,
403-
value=Web3.toWei(human_amount, 'ether'),
403+
value=Web3.to_wei(human_amount, 'ether'),
404404
),
405405
)
406406

@@ -512,8 +512,8 @@ def get_eth_balance(
512512
'owner was not provided, and no default address is set',
513513
)
514514

515-
wei_balance = self.web3.eth.getBalance(owner)
516-
return Web3.fromWei(wei_balance, 'ether')
515+
wei_balance = self.web3.eth.get_eth_balance(owner)
516+
return Web3.from_wei(wei_balance, 'ether')
517517

518518
def get_token_balance(
519519
self,

dydx3/modules/onboarding.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def derive_stark_key(
135135
action=OFF_CHAIN_KEY_DERIVATION_ACTION,
136136
)
137137
signature_int = int(signature, 16)
138-
hashed_signature = Web3.solidityKeccak(['uint256'], [signature_int])
138+
hashed_signature = Web3.solidity_keccak(['uint256'], [signature_int])
139139
private_key_int = int(hashed_signature.hex(), 16) >> 5
140140
private_key_hex = hex(private_key_int)
141141
public_x, public_y = private_key_to_public_key_pair_hex(
@@ -163,11 +163,11 @@ def recover_default_api_key_credentials(
163163
)
164164
r_hex = signature[2:66]
165165
r_int = int(r_hex, 16)
166-
hashed_r_bytes = bytes(Web3.solidityKeccak(['uint256'], [r_int]))
166+
hashed_r_bytes = bytes(Web3.solidity_keccak(['uint256'], [r_int]))
167167
secret_bytes = hashed_r_bytes[:30]
168168
s_hex = signature[66:130]
169169
s_int = int(s_hex, 16)
170-
hashed_s_bytes = bytes(Web3.solidityKeccak(['uint256'], [s_int]))
170+
hashed_s_bytes = bytes(Web3.solidity_keccak(['uint256'], [s_int]))
171171
key_bytes = hashed_s_bytes[:16]
172172
passphrase_bytes = hashed_s_bytes[16:31]
173173

dydx3/starkex/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def get_transfer_erc20_fact(
121121
token_decimals,
122122
)
123123
)
124-
hex_bytes = Web3.solidityKeccak(
124+
hex_bytes = Web3.solidity_keccak(
125125
[
126126
'address',
127127
'uint256',
File renamed without changes.

0 commit comments

Comments
 (0)