Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move sendTransaction -> send_transaction #1878

Merged
merged 1 commit into from Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/contracts.rst
Expand Up @@ -219,7 +219,7 @@ Each Contract Factory exposes the following methods.
Construct and deploy a contract by sending a new public transaction.

If provided ``transaction`` should be a dictionary conforming to the
``web3.eth.sendTransaction(transaction)`` method. This value may not
``web3.eth.send_transaction(transaction)`` method. This value may not
contain the keys ``data`` or ``to``.

If the contract takes constructor parameters they should be provided as
Expand Down Expand Up @@ -273,7 +273,7 @@ Each Contract Factory exposes the following methods.
If any of the ``args`` specified in the ABI are an ``address`` type, they
will accept ENS names.

Returns the transaction dictionary that you can pass to sendTransaction method.
Returns the transaction dictionary that you can pass to send_transaction method.

.. code-block:: python

Expand All @@ -282,7 +282,7 @@ Each Contract Factory exposes the following methods.
'chainId': None
}
>>> contract_data = token_contract.constructor(web3.eth.coinbase, 12345).buildTransaction(transaction)
>>> web3.eth.sendTransaction(contract_data)
>>> web3.eth.send_transaction(contract_data)

.. _contract_createFilter:

Expand Down Expand Up @@ -333,7 +333,7 @@ Each Contract Factory exposes the following methods.
Construct and send a transaction to deploy the contract.

If provided ``transaction`` should be a dictionary conforming to the
``web3.eth.sendTransaction(transaction)`` method. This value may not
``web3.eth.send_transaction(transaction)`` method. This value may not
contain the keys ``data`` or ``to``.

If the contract takes constructor arguments they should be provided as a
Expand Down Expand Up @@ -758,7 +758,7 @@ Methods

The end portion of this function call ``transact(transaction)`` takes a
single parameter which should be a python dictionary conforming to
the same format as the ``web3.eth.sendTransaction(transaction)`` method.
the same format as the ``web3.eth.send_transaction(transaction)`` method.
This dictionary may not contain the keys ``data``.

If any of the ``args`` or ``kwargs`` specified in the ABI are an ``address`` type, they
Expand Down Expand Up @@ -882,7 +882,7 @@ Methods
>>> math_contract.functions.increment(5).buildTransaction({'nonce': web3.eth.get_transaction_count('0xF5...')})

Returns a transaction dictionary. This transaction dictionary can then be sent using
:meth:`~web3.eth.Eth.sendTransaction`.
:meth:`~web3.eth.Eth.send_transaction`.

Additionally, the dictionary may be used for offline transaction signing using
:meth:`~web3.eth.account.Account.signTransaction`.
Expand Down
4 changes: 2 additions & 2 deletions docs/examples.rst
Expand Up @@ -178,7 +178,7 @@ Making transactions

There are a few options for making transactions:

- :meth:`~web3.eth.Eth.sendTransaction`
- :meth:`~web3.eth.Eth.send_transaction`

Use this method if:
- you want to send ether from one account to another.
Expand All @@ -198,7 +198,7 @@ There are a few options for making transactions:
- :meth:`~web3.middleware.construct_sign_and_send_raw_middleware`

Use this middleware if:
- you want to automate signing when using ``w3.eth.sendTransaction`` or ``ContractFunctions``.
- you want to automate signing when using ``w3.eth.send_transaction`` or ``ContractFunctions``.

.. NOTE:: The location of your keys (e.g., local or hosted) will have implications on these methods. Read about the differences :ref:`here <eth-account>`.

Expand Down
2 changes: 1 addition & 1 deletion docs/middleware.rst
Expand Up @@ -39,7 +39,7 @@ AttributeDict
.. py:method:: web3.middleware.name_to_address_middleware

This middleware converts Ethereum Name Service (ENS) names into the
address that the name points to. For example :meth:`~web3.Eth.sendTransaction` will
address that the name points to. For example :meth:`w3.eth.send_transaction <web3.eth.Eth.send_transaction>` will
accept .eth names in the 'from' and 'to' fields.

.. note::
Expand Down
4 changes: 2 additions & 2 deletions docs/node.rst
Expand Up @@ -62,8 +62,8 @@ work around this issue is to use a hosted node.
The most popular hosted node option is `Infura <infura.io>`_.
You can connect to it as if it were a local node,
with a few caveats. It cannot (and *should not*) host private keys for
you, meaning that some common methods like :meth:`w3.eth.sendTransaction()
<web3.eth.Eth.sendTransaction>` are not directly available. To send transactions
you, meaning that some common methods like :meth:`w3.eth.send_transaction()
<web3.eth.Eth.send_transaction>` are not directly available. To send transactions
to a hosted node, read about :ref:`eth-account`.

Once you decide what node option you want, you need to choose which network to connect to.
Expand Down
4 changes: 2 additions & 2 deletions docs/overview.rst
Expand Up @@ -157,7 +157,7 @@ Making Transactions
-------------------

The most common use cases will be satisfied with
:meth:`sendTransaction <web3.eth.Eth.sendTransaction>` or the combination of
:meth:`send_transaction <web3.eth.Eth.send_transaction>` or the combination of
:meth:`signTransaction <web3.eth.Eth.signTransaction>` and
:meth:`sendRawTransaction <web3.eth.Eth.sendRawTransaction>`.

Expand All @@ -170,7 +170,7 @@ The most common use cases will be satisfied with
API
^^^

- :meth:`web3.eth.sendTransaction() <web3.eth.Eth.sendTransaction>`
- :meth:`web3.eth.send_transaction() <web3.eth.Eth.send_transaction>`
- :meth:`web3.eth.signTransaction() <web3.eth.Eth.signTransaction>`
- :meth:`web3.eth.sendRawTransaction() <web3.eth.Eth.sendRawTransaction>`
- :meth:`web3.eth.replaceTransaction() <web3.eth.Eth.replaceTransaction>`
Expand Down
4 changes: 2 additions & 2 deletions docs/web3.eth.account.rst
Expand Up @@ -24,13 +24,13 @@ Local Private Key
before sending them to your node.
You must use :meth:`~web3.eth.Eth.sendRawTransaction`
when working with local keys, instead of
:meth:`~web3.eth.Eth.sendTransaction` .
:meth:`~web3.eth.Eth.send_transaction` .

Hosted Private Key
This is a common way to use accounts with local nodes.
Each account returned by :attr:`w3.eth.accounts <web3.eth.Eth.accounts>`
has a hosted private key stored in your node.
This allows you to use :meth:`~web3.eth.Eth.sendTransaction`.
This allows you to use :meth:`~web3.eth.Eth.send_transaction`.


.. WARNING::
Expand Down
19 changes: 12 additions & 7 deletions docs/web3.eth.rst
Expand Up @@ -697,7 +697,7 @@ The following methods are available on the ``web3.eth`` namespace.
:meth:`~web3.eth.Eth.get_transaction_count()`


.. py:method:: Eth.sendTransaction(transaction)
.. py:method:: Eth.send_transaction(transaction)

* Delegates to ``eth_sendTransaction`` RPC Method

Expand Down Expand Up @@ -731,9 +731,13 @@ The following methods are available on the ``web3.eth`` namespace.

.. code-block:: python

>>> web3.eth.sendTransaction({'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'from': web3.eth.coinbase, 'value': 12345})
>>> web3.eth.send_transaction({'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'from': web3.eth.coinbase, 'value': 12345})
'0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331'

.. py:method:: Eth.sendTransaction(transaction)

.. warning:: Deprecated: This property is deprecated in favor of
:attr:`~web3.eth.Eth.send_transaction`

.. py:method:: Eth.signTransaction(transaction)

Expand Down Expand Up @@ -787,7 +791,7 @@ The following methods are available on the ``web3.eth`` namespace.
The ``transaction_hash`` must be the hash of a pending transaction.

The ``new_transaction`` parameter should be a dictionary with transaction fields
as required by :meth:`~web3.eth.Eth.sendTransaction`. It will be used to entirely
as required by :meth:`~web3.eth.Eth.send_transaction`. It will be used to entirely
replace the transaction of ``transaction_hash`` without using any of the pending
transaction's values.

Expand All @@ -808,7 +812,7 @@ The following methods are available on the ``web3.eth`` namespace.

.. code-block:: python

>>> tx = web3.eth.sendTransaction({
>>> tx = web3.eth.send_transaction({
'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
'from': web3.eth.coinbase,
'value': 1000
Expand All @@ -828,7 +832,7 @@ The following methods are available on the ``web3.eth`` namespace.
Sends a transaction that modifies the transaction with ``transaction_hash``.

``transaction_params`` are keyword arguments that correspond to valid transaction
parameters as required by :meth:`~web3.eth.Eth.sendTransaction`. The parameter values
parameters as required by :meth:`~web3.eth.Eth.send_transaction`. The parameter values
will override the pending transaction's values to create the replacement transaction
to send.

Expand All @@ -838,7 +842,7 @@ The following methods are available on the ``web3.eth`` namespace.

.. code-block:: python

>>> tx = web3.eth.sendTransaction({
>>> tx = web3.eth.send_transaction({
'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
'from': web3.eth.coinbase,
'value': 1000
Expand Down Expand Up @@ -897,7 +901,7 @@ The following methods are available on the ``web3.eth`` namespace.
on the blockchain. Returns the return value of the executed contract.

The ``transaction`` parameter is handled in the same manner as the
:meth:`~web3.eth.Eth.sendTransaction()` method.
:meth:`~web3.eth.Eth.send_transaction()` method.

.. code-block:: python

Expand Down Expand Up @@ -1190,3 +1194,4 @@ Contracts
Future calls to ``Eth.contract()`` will then default to ``contractFactoryClass``.

An example of an alternative Contract Factory is ``ConciseContract``.

6 changes: 3 additions & 3 deletions ens/main.py
Expand Up @@ -141,7 +141,7 @@ def setup_address(
:param str address: name will point to this address, in checksum format. If ``None``,
erase the record. If not specified, name will point to the owner's address.
:param dict transact: the transaction configuration, like in
:meth:`~web3.eth.Eth.sendTransaction`
:meth:`~web3.eth.Eth.send_transaction`
:raises InvalidName: if ``name`` has invalid syntax
:raises UnauthorizedError: if ``'from'`` in `transact` does not own `name`
"""
Expand Down Expand Up @@ -175,7 +175,7 @@ def setup_name(
:param str name: ENS name that address will point to
:param str address: to set up, in checksum format
:param dict transact: the transaction configuration, like in
:meth:`~web3.eth.sendTransaction`
:meth:`~web3.eth.send_transaction`
:raises AddressMismatch: if the name does not already point to the address
:raises InvalidName: if `name` has invalid syntax
:raises UnauthorizedError: if ``'from'`` in `transact` does not own `name`
Expand Down Expand Up @@ -270,7 +270,7 @@ def setup_owner(
:param new_owner: account that will own `name`. If ``None``, set owner to empty addr.
If not specified, name will point to the parent domain owner's address.
:param dict transact: the transaction configuration, like in
:meth:`~web3.eth.Eth.sendTransaction`
:meth:`~web3.eth.Eth.send_transaction`
:raises InvalidName: if `name` has invalid syntax
:raises UnauthorizedError: if ``'from'`` in `transact` does not own `name`
:returns: the new owner's address
Expand Down
1 change: 1 addition & 0 deletions newsfragments/1878.feature.rst
@@ -0,0 +1 @@
Add ``w3.eth.send_transaction``, deprecate ``w3.eth.sendTransaction``
2 changes: 1 addition & 1 deletion tests/core/contracts/test_contract_call_interface.py
Expand Up @@ -535,7 +535,7 @@ def test_call_receive_fallback_function(web3,
assert initial_value == ''
to = {'to': contract.address}
merged = {**to, **tx_params}
web3.eth.sendTransaction(merged)
web3.eth.send_transaction(merged)
final_value = call(contract=contract, contract_function='getText')
assert final_value == expected

Expand Down
6 changes: 3 additions & 3 deletions tests/core/contracts/test_contract_constructor.py
Expand Up @@ -189,7 +189,7 @@ def test_contract_constructor_build_transaction_no_constructor(
unsent_txn = MathContract.constructor().buildTransaction({'nonce': nonce})
assert txn['data'] == unsent_txn['data']

new_txn_hash = web3.eth.sendTransaction(unsent_txn)
new_txn_hash = web3.eth.send_transaction(unsent_txn)
new_txn = web3.eth.get_transaction(new_txn_hash)
assert new_txn['data'] == unsent_txn['data']
assert new_txn['nonce'] == nonce
Expand All @@ -207,7 +207,7 @@ def test_contract_constructor_build_transaction_with_constructor_without_argumen
unsent_txn = MathContract.constructor().buildTransaction({'nonce': nonce})
assert txn['data'] == unsent_txn['data']

new_txn_hash = web3.eth.sendTransaction(unsent_txn)
new_txn_hash = web3.eth.send_transaction(unsent_txn)
new_txn = web3.eth.get_transaction(new_txn_hash)
assert new_txn['data'] == unsent_txn['data']
assert new_txn['nonce'] == nonce
Expand Down Expand Up @@ -238,7 +238,7 @@ def test_contract_constructor_build_transaction_with_constructor_with_argument(
*constructor_args, **constructor_kwargs).buildTransaction({'nonce': nonce})
assert txn['data'] == unsent_txn['data']

new_txn_hash = web3.eth.sendTransaction(unsent_txn)
new_txn_hash = web3.eth.send_transaction(unsent_txn)
new_txn = web3.eth.get_transaction(new_txn_hash)
assert new_txn['data'] == unsent_txn['data']
assert new_txn['nonce'] == nonce
8 changes: 4 additions & 4 deletions tests/core/eth-module/test_default_account_api.py
Expand Up @@ -11,7 +11,7 @@ def test_uses_default_account_when_set(web3, extra_accounts,
web3.eth.default_account = extra_accounts[2]
assert web3.eth.default_account == extra_accounts[2]

txn_hash = web3.eth.sendTransaction({
txn_hash = web3.eth.send_transaction({
"to": extra_accounts[1],
"value": 1234,
})
Expand All @@ -30,7 +30,7 @@ def test_uses_defaultAccount_when_set_with_warning(web3, extra_accounts,
with pytest.warns(DeprecationWarning):
assert web3.eth.defaultAccount == extra_accounts[2]

txn_hash = web3.eth.sendTransaction({
txn_hash = web3.eth.send_transaction({
"to": extra_accounts[1],
"value": 1234,
})
Expand All @@ -44,7 +44,7 @@ def test_uses_defaultAccount_when_set_with_warning(web3, extra_accounts,
def test_uses_given_from_address_when_provided(web3, extra_accounts,
wait_for_transaction):
web3.eth.default_account = extra_accounts[2]
txn_hash = web3.eth.sendTransaction({
txn_hash = web3.eth.send_transaction({
"from": extra_accounts[5],
"to": extra_accounts[1],
"value": 1234,
Expand All @@ -64,7 +64,7 @@ def test_uses_given_from_address_when_provided_with_warning(web3, extra_accounts
with pytest.warns(DeprecationWarning):
assert web3.eth.defaultAccount == extra_accounts[2]

txn_hash = web3.eth.sendTransaction({
txn_hash = web3.eth.send_transaction({
"from": extra_accounts[5],
"to": extra_accounts[1],
"value": 1234,
Expand Down
10 changes: 5 additions & 5 deletions tests/core/eth-module/test_transactions.py
Expand Up @@ -35,12 +35,12 @@ def test_send_transaction_with_valid_chain_id(web3, make_chain_id, expect_succes
'chainId': make_chain_id(web3),
}
if expect_success:
txn_hash = web3.eth.sendTransaction(transaction)
txn_hash = web3.eth.send_transaction(transaction)
receipt = web3.eth.waitForTransactionReceipt(txn_hash, timeout=RECEIPT_TIMEOUT)
assert receipt.get('blockNumber') is not None
else:
with pytest.raises(ValidationError) as exc_info:
web3.eth.sendTransaction(transaction)
web3.eth.send_transaction(transaction)

assert 'chain ID' in str(exc_info.value)

Expand Down Expand Up @@ -69,7 +69,7 @@ def test_send_transaction_with_invalid_ens_names(web3, to, _from):
}

with pytest.raises(NameNotFound):
web3.eth.sendTransaction(transaction)
web3.eth.send_transaction(transaction)


def test_send_transaction_with_ens_names(web3):
Expand All @@ -83,7 +83,7 @@ def test_send_transaction_with_ens_names(web3):
'from': 'registered-name-2.eth',
}

txn_hash = web3.eth.sendTransaction(transaction)
txn_hash = web3.eth.send_transaction(transaction)
receipt = web3.eth.waitForTransactionReceipt(txn_hash, timeout=RECEIPT_TIMEOUT)
assert receipt.get('blockNumber') is not None

Expand All @@ -95,7 +95,7 @@ def test_wait_for_missing_receipt(web3):

def test_unmined_transaction_wait_for_receipt(web3):
web3.middleware_onion.add(unmined_receipt_simulator_middleware)
txn_hash = web3.eth.sendTransaction({
txn_hash = web3.eth.send_transaction({
'from': web3.eth.coinbase,
'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
'value': 123457
Expand Down
Expand Up @@ -21,12 +21,12 @@ def test_sync_filter_against_pending_transactions(web3_empty,

txn_filter = web3.eth.filter("pending")

txn_1_hash = web3.eth.sendTransaction({
txn_1_hash = web3.eth.send_transaction({
'from': web3.eth.coinbase,
'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
'value': 12345,
})
txn_2_hash = web3.eth.sendTransaction({
txn_2_hash = web3.eth.send_transaction({
'from': web3.eth.coinbase,
'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
'value': 54321,
Expand Down Expand Up @@ -58,12 +58,12 @@ def test_async_filter_against_pending_transactions(web3_empty,
txn_filter = web3.eth.filter("pending")
txn_filter.watch(seen_txns.append)

txn_1_hash = web3.eth.sendTransaction({
txn_1_hash = web3.eth.send_transaction({
'from': web3.eth.coinbase,
'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
'value': 12345,
})
txn_2_hash = web3.eth.sendTransaction({
txn_2_hash = web3.eth.send_transaction({
'from': web3.eth.coinbase,
'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
'value': 54321,
Expand Down
4 changes: 2 additions & 2 deletions tests/core/filtering/test_filters_against_many_blocks.py
Expand Up @@ -20,15 +20,15 @@ def pad_with_transactions(w3):
_from = accounts[random.randint(0, len(accounts) - 1)]
_to = accounts[random.randint(0, len(accounts) - 1)]
value = 50 + tx_count
w3.eth.sendTransaction({'from': _from, 'to': _to, 'value': value})
w3.eth.send_transaction({'from': _from, 'to': _to, 'value': value})


def single_transaction(w3):
accounts = w3.eth.accounts
_from = accounts[random.randint(0, len(accounts) - 1)]
_to = accounts[random.randint(0, len(accounts) - 1)]
value = 50
tx_hash = w3.eth.sendTransaction({'from': _from, 'to': _to, 'value': value})
tx_hash = w3.eth.send_transaction({'from': _from, 'to': _to, 'value': value})
return tx_hash


Expand Down