Skip to content

Commit 0af7d9e

Browse files
committed
Remove aurora specific config from SDK
1 parent 1522416 commit 0af7d9e

File tree

12 files changed

+62
-149
lines changed

12 files changed

+62
-149
lines changed

packages/sdk/python/human-protocol-sdk/human_protocol_sdk/escrow/escrow_client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_w3_with_priv_key(priv_key: str):
7171
from web3.middleware import ExtraDataToPOAMiddleware
7272
from web3.types import TxParams
7373

74-
from human_protocol_sdk.utils import validate_url, apply_tx_defaults
74+
from human_protocol_sdk.utils import validate_url
7575
from human_protocol_sdk.decorators import requires_signer
7676

7777
LOG = logging.getLogger("human_protocol_sdk.escrow")
@@ -263,7 +263,7 @@ def get_w3_with_priv_key(priv_key: str):
263263
try:
264264
tx_hash = self.factory_contract.functions.createEscrow(
265265
token_address, job_requester_id
266-
).transact(apply_tx_defaults(self.w3, tx_options))
266+
).transact(tx_options)
267267
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
268268
event = next(
269269
(
@@ -362,7 +362,7 @@ def get_w3_with_priv_key(priv_key: str):
362362
escrow_config.exchange_oracle_fee,
363363
escrow_config.manifest,
364364
escrow_config.hash,
365-
).transact(apply_tx_defaults(self.w3, tx_options))
365+
).transact(tx_options)
366366
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
367367
event = next(
368368
(
@@ -450,7 +450,7 @@ def get_w3_with_priv_key(priv_key: str):
450450
escrow_config.manifest,
451451
escrow_config.hash,
452452
)
453-
.transact(apply_tx_defaults(self.w3, tx_options))
453+
.transact(tx_options)
454454
)
455455
self.w3.eth.wait_for_transaction_receipt(tx_hash)
456456
except Exception as e:
@@ -515,7 +515,7 @@ def get_w3_with_priv_key(priv_key: str):
515515
try:
516516
tx_hash = token_contract.functions.transfer(
517517
escrow_address, amount
518-
).transact(apply_tx_defaults(self.w3, tx_options))
518+
).transact(tx_options)
519519
self.w3.eth.wait_for_transaction_receipt(tx_hash)
520520
except Exception as e:
521521
handle_error(e, EscrowClientError)
@@ -592,10 +592,10 @@ def get_w3_with_priv_key(priv_key: str):
592592
if funds_to_reserve is not None:
593593
tx_hash = contract.functions.storeResults(
594594
url, hash, funds_to_reserve
595-
).transact(apply_tx_defaults(self.w3, tx_options))
595+
).transact(tx_options)
596596
else:
597597
tx_hash = contract.functions.storeResults(url, hash).transact(
598-
apply_tx_defaults(self.w3, tx_options)
598+
tx_options
599599
)
600600
self.w3.eth.wait_for_transaction_receipt(tx_hash)
601601
except Exception as e:
@@ -657,7 +657,7 @@ def get_w3_with_priv_key(priv_key: str):
657657
tx_hash = (
658658
self._get_escrow_contract(escrow_address)
659659
.functions.complete()
660-
.transact(apply_tx_defaults(self.w3, tx_options))
660+
.transact(tx_options)
661661
)
662662
self.w3.eth.wait_for_transaction_receipt(tx_hash)
663663
except Exception as e:
@@ -749,7 +749,7 @@ def get_w3_with_priv_key(priv_key: str):
749749
final_results_hash,
750750
payout_id,
751751
force_complete,
752-
).transact(apply_tx_defaults(self.w3, tx_options))
752+
).transact(tx_options)
753753
else:
754754
tx_id = payout_id
755755
tx_hash = contract.functions.bulkPayOut(
@@ -759,7 +759,7 @@ def get_w3_with_priv_key(priv_key: str):
759759
final_results_hash,
760760
tx_id,
761761
force_complete,
762-
).transact(apply_tx_defaults(self.w3, tx_options))
762+
).transact(tx_options)
763763
self.w3.eth.wait_for_transaction_receipt(tx_hash)
764764
except Exception as e:
765765
error_text = str(e) or ""
@@ -987,7 +987,7 @@ def get_w3_with_priv_key(priv_key: str):
987987
tx_hash = (
988988
self._get_escrow_contract(escrow_address)
989989
.functions.requestCancellation()
990-
.transact(apply_tx_defaults(self.w3, tx_options))
990+
.transact(tx_options)
991991
)
992992
self.w3.eth.wait_for_transaction_receipt(tx_hash)
993993
except Exception as e:
@@ -1046,7 +1046,7 @@ def get_w3_with_priv_key(priv_key: str):
10461046
tx_hash = (
10471047
self._get_escrow_contract(escrow_address)
10481048
.functions.cancel()
1049-
.transact(apply_tx_defaults(self.w3, tx_options))
1049+
.transact(tx_options)
10501050
)
10511051
self.w3.eth.wait_for_transaction_receipt(tx_hash)
10521052
except Exception as e:
@@ -1114,7 +1114,7 @@ def get_w3_with_priv_key(priv_key: str):
11141114
tx_hash = (
11151115
self._get_escrow_contract(escrow_address)
11161116
.functions.withdraw(token_address)
1117-
.transact(apply_tx_defaults(self.w3, tx_options))
1117+
.transact(tx_options)
11181118
)
11191119
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
11201120

packages/sdk/python/human-protocol-sdk/human_protocol_sdk/kvstore/kvstore_client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def get_w3_with_priv_key(priv_key: str):
5252
"""
5353

5454
import logging
55-
import os
5655
from typing import List, Optional
5756

5857
import requests
@@ -63,7 +62,6 @@ def get_w3_with_priv_key(priv_key: str):
6362
get_kvstore_interface,
6463
handle_error,
6564
validate_url,
66-
apply_tx_defaults,
6765
)
6866
from web3 import Web3
6967
from web3.middleware import ExtraDataToPOAMiddleware
@@ -160,7 +158,7 @@ def get_w3_with_priv_key(priv_key: str):
160158

161159
try:
162160
tx_hash = self.kvstore_contract.functions.set(key, value).transact(
163-
apply_tx_defaults(self.w3, tx_options)
161+
tx_options
164162
)
165163
self.w3.eth.wait_for_transaction_receipt(tx_hash)
166164
except Exception as e:
@@ -217,7 +215,7 @@ def get_w3_with_priv_key(priv_key: str):
217215

218216
try:
219217
tx_hash = self.kvstore_contract.functions.setBulk(keys, values).transact(
220-
apply_tx_defaults(self.w3, tx_options)
218+
tx_options
221219
)
222220
self.w3.eth.wait_for_transaction_receipt(tx_hash)
223221
except Exception as e:
@@ -276,7 +274,7 @@ def get_w3_with_priv_key(priv_key: str):
276274
try:
277275
tx_hash = self.kvstore_contract.functions.setBulk(
278276
[key, key + "_hash"], [url, content_hash]
279-
).transact(apply_tx_defaults(self.w3, tx_options))
277+
).transact(tx_options)
280278
self.w3.eth.wait_for_transaction_receipt(tx_hash)
281279
except Exception as e:
282280
handle_error(e, KVStoreClientError)

packages/sdk/python/human-protocol-sdk/human_protocol_sdk/staking/staking_client.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def get_w3_with_priv_key(priv_key: str):
6868
get_factory_interface,
6969
get_staking_interface,
7070
handle_error,
71-
apply_tx_defaults,
7271
)
7372

7473
LOG = logging.getLogger("human_protocol_sdk.staking")
@@ -176,7 +175,7 @@ def get_w3_with_priv_key(priv_key: str):
176175
try:
177176
tx_hash = self.hmtoken_contract.functions.approve(
178177
self.network["staking_address"], amount
179-
).transact(apply_tx_defaults(self.w3, tx_options))
178+
).transact(tx_options)
180179
self.w3.eth.wait_for_transaction_receipt(tx_hash)
181180
except Exception as e:
182181
handle_error(e, StakingClientError)
@@ -227,9 +226,7 @@ def get_w3_with_priv_key(priv_key: str):
227226
if amount <= 0:
228227
raise StakingClientError("Amount to stake must be greater than 0")
229228
try:
230-
tx_hash = self.staking_contract.functions.stake(amount).transact(
231-
apply_tx_defaults(self.w3, tx_options)
232-
)
229+
tx_hash = self.staking_contract.functions.stake(amount).transact(tx_options)
233230
self.w3.eth.wait_for_transaction_receipt(tx_hash)
234231
except Exception as e:
235232
handle_error(e, StakingClientError)
@@ -279,7 +276,7 @@ def get_w3_with_priv_key(priv_key: str):
279276
raise StakingClientError("Amount to unstake must be greater than 0")
280277
try:
281278
tx_hash = self.staking_contract.functions.unstake(amount).transact(
282-
apply_tx_defaults(self.w3, tx_options)
279+
tx_options
283280
)
284281
self.w3.eth.wait_for_transaction_receipt(tx_hash)
285282
except Exception as e:
@@ -324,9 +321,7 @@ def get_w3_with_priv_key(priv_key: str):
324321
"""
325322

326323
try:
327-
tx_hash = self.staking_contract.functions.withdraw().transact(
328-
apply_tx_defaults(self.w3, tx_options)
329-
)
324+
tx_hash = self.staking_contract.functions.withdraw().transact(tx_options)
330325
self.w3.eth.wait_for_transaction_receipt(tx_hash)
331326
except Exception as e:
332327
handle_error(e, StakingClientError)
@@ -395,7 +390,7 @@ def get_w3_with_priv_key(priv_key: str):
395390
try:
396391
tx_hash = self.staking_contract.functions.slash(
397392
slasher, staker, escrow_address, amount
398-
).transact(apply_tx_defaults(self.w3, tx_options))
393+
).transact(tx_options)
399394
self.w3.eth.wait_for_transaction_receipt(tx_hash)
400395
except Exception as e:
401396
handle_error(e, StakingClientError)

packages/sdk/python/human-protocol-sdk/human_protocol_sdk/utils.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -324,22 +324,3 @@ def validate_json(data: str) -> bool:
324324
return True
325325
except (ValueError, TypeError):
326326
return False
327-
328-
329-
def apply_tx_defaults(w3: Web3, tx_options: Optional[TxParams]) -> TxParams:
330-
"""Apply network specific default transaction parameters.
331-
332-
Aurora networks enforce a fixed gas price. We always override any user supplied
333-
gasPrice with DEFAULT_AURORA_GAS_PRICE when on Aurora Testnet.
334-
EIP-1559 fields are removed to avoid conflicts.
335-
336-
:param w3: Web3 instance (used to read chain id)
337-
:param tx_options: Original transaction options (can be None)
338-
:return: Mutated tx options with enforced defaults
339-
"""
340-
opts: TxParams = dict(tx_options) if tx_options else {}
341-
if w3.eth.chain_id == ChainId.AURORA_TESTNET.value:
342-
opts["gasPrice"] = DEFAULT_AURORA_GAS_PRICE
343-
opts.pop("maxFeePerGas", None)
344-
opts.pop("maxPriorityFeePerGas", None)
345-
return opts

packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/escrow/test_escrow_client.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def test_create_escrow(self):
384384
self.escrow.factory_contract.functions.createEscrow.assert_called_once_with(
385385
token_address, job_requester_id
386386
)
387-
mock_create.transact.assert_called_once_with({})
387+
mock_create.transact.assert_called_once_with(None)
388388
self.escrow.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
389389
"tx_hash"
390390
)
@@ -500,7 +500,7 @@ def test_create_fund_and_setup_escrow(self):
500500
escrow_config.manifest,
501501
escrow_config.hash,
502502
)
503-
mock_create.transact.assert_called_once_with({})
503+
mock_create.transact.assert_called_once_with(None)
504504
self.escrow.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
505505
"tx_hash"
506506
)
@@ -647,7 +647,7 @@ def test_setup(self):
647647
escrow_config.manifest,
648648
escrow_config.hash,
649649
)
650-
mock_setup.transact.assert_called_once_with({})
650+
mock_setup.transact.assert_called_once_with(None)
651651
self.escrow.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
652652
"tx_hash"
653653
)
@@ -828,7 +828,7 @@ def test_fund(self):
828828
mock_token_contract.functions.transfer.assert_called_once_with(
829829
escrow_address, amount
830830
)
831-
mock_transfer.transact.assert_called_once_with({})
831+
mock_transfer.transact.assert_called_once_with(None)
832832
self.escrow.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
833833
"tx_hash"
834834
)
@@ -909,7 +909,7 @@ def test_store_results(self):
909909

910910
self.escrow._get_escrow_contract.assert_called_once_with(escrow_address)
911911
mock_contract.functions.storeResults.assert_called_once_with(url, hash)
912-
mock_store.transact.assert_called_once_with({})
912+
mock_store.transact.assert_called_once_with(None)
913913
self.escrow.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
914914
"tx_hash"
915915
)
@@ -1038,7 +1038,7 @@ def test_store_results_with_funds_to_reserve_positive(self):
10381038
mock_contract.functions.storeResults.assert_called_once_with(
10391039
url, hash, funds_to_reserve
10401040
)
1041-
mock_store.transact.assert_called_once_with({})
1041+
mock_store.transact.assert_called_once_with(None)
10421042

10431043
def test_store_results_with_funds_to_reserve_zero_allows_empty(self):
10441044
mock_contract = MagicMock()
@@ -1119,7 +1119,7 @@ def test_bulk_payout(self):
11191119
mock_contract.functions.bulkPayOut.assert_called_once_with(
11201120
recipients, amounts, final_results_url, final_results_hash, txId, True
11211121
)
1122-
mock_bulk.transact.assert_called_once_with({})
1122+
mock_bulk.transact.assert_called_once_with(None)
11231123
self.escrow.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
11241124
"tx_hash"
11251125
)
@@ -1580,7 +1580,7 @@ def test_complete(self):
15801580

15811581
self.escrow._get_escrow_contract.assert_called_once_with(escrow_address)
15821582
mock_contract.functions.complete.assert_called_once_with()
1583-
mock_complete.transact.assert_called_once_with({})
1583+
mock_complete.transact.assert_called_once_with(None)
15841584
self.escrow.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
15851585
"tx_hash"
15861586
)
@@ -1675,7 +1675,7 @@ def test_request_cancellation(self):
16751675

16761676
self.escrow._get_escrow_contract.assert_called_once_with(escrow_address)
16771677
mock_contract.functions.requestCancellation.assert_called_once_with()
1678-
mock_request.transact.assert_called_once_with({})
1678+
mock_request.transact.assert_called_once_with(None)
16791679
self.assertIsNone(result)
16801680

16811681
def test_request_cancellation_invalid_address(self):
@@ -1759,7 +1759,7 @@ def test_cancel(self):
17591759
self.assertIsNone(result)
17601760
self.escrow._get_escrow_contract.assert_called_once_with(escrow_address)
17611761
mock_contract.functions.cancel.assert_called_once_with()
1762-
mock_cancel.transact.assert_called_once_with({})
1762+
mock_cancel.transact.assert_called_once_with(None)
17631763
self.escrow.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
17641764
"tx_hash"
17651765
)
@@ -1869,7 +1869,7 @@ def test_withdraw(self):
18691869

18701870
self.escrow._get_escrow_contract.assert_called_once_with(escrow_address)
18711871
mock_contract.functions.withdraw.assert_called_once_with(token_address)
1872-
mock_withdraw.transact.assert_called_once_with({})
1872+
mock_withdraw.transact.assert_called_once_with(None)
18731873
self.escrow.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
18741874
"tx_hash"
18751875
)

packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/kvstore/test_kvstore_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_set(self):
7878
self.kvstore.set(key, value)
7979

8080
self.kvstore.kvstore_contract.functions.set.assert_called_once_with(key, value)
81-
mock_set.transact.assert_called_once_with({})
81+
mock_set.transact.assert_called_once_with(None)
8282
self.kvstore.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
8383
"tx_hash"
8484
)
@@ -140,7 +140,7 @@ def test_set_bulk(self):
140140
self.kvstore.kvstore_contract.functions.setBulk.assert_called_once_with(
141141
keys, values
142142
)
143-
mock_set_bulk.transact.assert_called_once_with({})
143+
mock_set_bulk.transact.assert_called_once_with(None)
144144
self.kvstore.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
145145
"tx_hash"
146146
)
@@ -226,7 +226,7 @@ def test_set_file_url_and_hash(self):
226226
self.kvstore.kvstore_contract.functions.setBulk.assert_called_once_with(
227227
["url", "url_hash"], [url, content_hash]
228228
)
229-
mock_set_bulk.transact.assert_called_once_with({})
229+
mock_set_bulk.transact.assert_called_once_with(None)
230230
self.kvstore.w3.eth.wait_for_transaction_receipt.assert_called_once_with(
231231
"tx_hash"
232232
)
@@ -255,7 +255,7 @@ def test_set_file_url_and_hash_with_key(self):
255255
["linkedin_url", "linkedin_url_hash"], [url, content_hash]
256256
)
257257

258-
mock_set_bulk.transact.assert_called_once_with({})
258+
mock_set_bulk.transact.assert_called_once_with(None)
259259
self.kvstore.w3.eth.wait_for_transaction_receipt.assert_called_once_with
260260

261261
def test_set_file_url_and_hash_invalid_url(self):

0 commit comments

Comments
 (0)