@@ -218,10 +218,10 @@ def test_contract_constructor_build_transaction_no_constructor(
218218 w3 , math_contract_factory , address_conversion_func
219219):
220220 txn_hash = math_contract_factory .constructor ().transact (
221- {"from" : address_conversion_func (w3 .eth .accounts [ 0 ] )}
221+ {"from" : address_conversion_func (w3 .eth .default_account )}
222222 )
223223 txn = w3 .eth .get_transaction (txn_hash )
224- nonce = w3 .eth .get_transaction_count (w3 .eth .accounts [ 0 ] )
224+ nonce = w3 .eth .get_transaction_count (w3 .eth .default_account )
225225 unsent_txn = math_contract_factory .constructor ().build_transaction ({"nonce" : nonce })
226226 assert txn ["input" ] == HexBytes (unsent_txn ["data" ])
227227
@@ -235,10 +235,10 @@ def test_contract_constructor_build_transaction_without_arguments(
235235 w3 , math_contract_factory , address_conversion_func
236236):
237237 txn_hash = math_contract_factory .constructor ().transact (
238- {"from" : address_conversion_func (w3 .eth .accounts [ 0 ] )}
238+ {"from" : address_conversion_func (w3 .eth .default_account )}
239239 )
240240 txn = w3 .eth .get_transaction (txn_hash )
241- nonce = w3 .eth .get_transaction_count (w3 .eth .accounts [ 0 ] )
241+ nonce = w3 .eth .get_transaction_count (w3 .eth .default_account )
242242 unsent_txn = math_contract_factory .constructor ().build_transaction ({"nonce" : nonce })
243243 assert txn ["input" ] == HexBytes (unsent_txn ["data" ])
244244
@@ -266,10 +266,10 @@ def test_contract_constructor_build_transaction_with_arguments(
266266):
267267 txn_hash = non_strict_contract_with_constructor_args_factory .constructor (
268268 * constructor_args , ** constructor_kwargs
269- ).transact ({"from" : address_conversion_func (w3_non_strict_abi .eth .accounts [ 0 ] )})
269+ ).transact ({"from" : address_conversion_func (w3_non_strict_abi .eth .default_account )})
270270 txn = w3_non_strict_abi .eth .get_transaction (txn_hash )
271271 nonce = w3_non_strict_abi .eth .get_transaction_count (
272- w3_non_strict_abi .eth .accounts [ 0 ]
272+ w3_non_strict_abi .eth .default_account
273273 )
274274 unsent_txn = non_strict_contract_with_constructor_args_factory .constructor (
275275 * constructor_args , ** constructor_kwargs
@@ -523,12 +523,11 @@ async def test_async_contract_constructor_build_transaction_to_field_error(
523523async def test_async_contract_constructor_build_transaction_no_constructor (
524524 async_w3 , async_math_contract_factory , address_conversion_func
525525):
526- async_w3_accounts = await async_w3 .eth .accounts
527526 txn_hash = await async_math_contract_factory .constructor ().transact (
528- {"from" : address_conversion_func (async_w3_accounts [ 0 ] )}
527+ {"from" : address_conversion_func (async_w3 . eth . default_account )}
529528 )
530529 txn = await async_w3 .eth .get_transaction (txn_hash )
531- nonce = await async_w3 .eth .get_transaction_count (async_w3_accounts [ 0 ] )
530+ nonce = await async_w3 .eth .get_transaction_count (async_w3 . eth . default_account )
532531 unsent_txn = await async_math_contract_factory .constructor ().build_transaction (
533532 {"nonce" : nonce }
534533 )
@@ -544,12 +543,11 @@ async def test_async_contract_constructor_build_transaction_no_constructor(
544543async def test_async_contract_constructor_build_transaction_without_arguments (
545544 async_w3 , async_math_contract_factory , address_conversion_func
546545):
547- async_w3_accounts = await async_w3 .eth .accounts
548546 txn_hash = await async_math_contract_factory .constructor ().transact (
549- {"from" : address_conversion_func (async_w3_accounts [ 0 ] )}
547+ {"from" : address_conversion_func (async_w3 . eth . default_account )}
550548 )
551549 txn = await async_w3 .eth .get_transaction (txn_hash )
552- nonce = await async_w3 .eth .get_transaction_count (async_w3_accounts [ 0 ] )
550+ nonce = await async_w3 .eth .get_transaction_count (async_w3 . eth . default_account )
553551 unsent_txn = await async_math_contract_factory .constructor ().build_transaction (
554552 {"nonce" : nonce }
555553 )
@@ -578,15 +576,20 @@ async def test_async_contract_constructor_build_transaction_with_arguments(
578576 constructor_kwargs ,
579577 address_conversion_func ,
580578):
581- async_w3_accounts = await async_w3_non_strict_abi .eth .accounts
582579 txn_hash = (
583580 await async_non_strict_constructor_with_args_contract_factory .constructor (
584581 * constructor_args , ** constructor_kwargs
585- ).transact ({"from" : address_conversion_func (async_w3_accounts [0 ])})
582+ ).transact (
583+ {
584+ "from" : address_conversion_func (
585+ async_w3_non_strict_abi .eth .default_account
586+ )
587+ }
588+ )
586589 )
587590 txn = await async_w3_non_strict_abi .eth .get_transaction (txn_hash )
588591 nonce = await async_w3_non_strict_abi .eth .get_transaction_count (
589- async_w3_accounts [ 0 ]
592+ async_w3_non_strict_abi . eth . default_account
590593 )
591594 unsent_txn = (
592595 await async_non_strict_constructor_with_args_contract_factory .constructor (
0 commit comments