Skip to content

Commit

Permalink
Merge 1df683a into 3f01e6f
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] committed Jul 11, 2022
2 parents 3f01e6f + 1df683a commit ae41de6
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 68 deletions.
16 changes: 8 additions & 8 deletions gnosis/eth/ethereum_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def batch_call(

payload = {
"to": contract_function.address,
"data": contract_function.buildTransaction(params)["data"],
"data": contract_function.build_transaction(params)["data"],
"output_type": [
output["type"] for output in contract_function.abi["outputs"]
],
Expand Down Expand Up @@ -395,7 +395,7 @@ def batch_call_same_function(

contract_function.address = NULL_ADDRESS # It's required by web3.py
params: TxParams = {"gas": Wei(0), "gasPrice": Wei(0)}
data = contract_function.buildTransaction(params)["data"]
data = contract_function.build_transaction(params)["data"]
output_type = [output["type"] for output in contract_function.abi["outputs"]]
fn_name = contract_function.fn_name

Expand Down Expand Up @@ -537,15 +537,15 @@ def get_balances(

def get_name(self, erc20_address: str) -> str:
erc20 = get_erc20_contract(self.w3, erc20_address)
data = erc20.functions.name().buildTransaction(
data = erc20.functions.name().build_transaction(
{"gas": Wei(0), "gasPrice": Wei(0)}
)["data"]
result = self.w3.eth.call({"to": erc20_address, "data": data})
return decode_string_or_bytes32(result)

def get_symbol(self, erc20_address: str) -> str:
erc20 = get_erc20_contract(self.w3, erc20_address)
data = erc20.functions.symbol().buildTransaction(
data = erc20.functions.symbol().build_transaction(
{"gas": Wei(0), "gasPrice": Wei(0)}
)["data"]
result = self.w3.eth.call({"to": erc20_address, "data": data})
Expand All @@ -570,9 +570,9 @@ def get_info(self, erc20_address: str) -> Erc20Info:
"gasPrice": Wei(0),
} # Prevent executing tx, we are just interested on `data`
datas = [
erc20.functions.name().buildTransaction(params)["data"],
erc20.functions.symbol().buildTransaction(params)["data"],
erc20.functions.decimals().buildTransaction(params)["data"],
erc20.functions.name().build_transaction(params)["data"],
erc20.functions.symbol().build_transaction(params)["data"],
erc20.functions.decimals().build_transaction(params)["data"],
]
payload = [
{
Expand Down Expand Up @@ -804,7 +804,7 @@ def send_tokens(
if gas:
tx_options["gas"] = Wei(gas)

tx = erc20.functions.transfer(to, amount).buildTransaction(tx_options)
tx = erc20.functions.transfer(to, amount).build_transaction(tx_options)
return self.ethereum_client.send_unsigned_transaction(
tx, private_key=private_key
)
Expand Down
4 changes: 3 additions & 1 deletion gnosis/eth/multicall.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def deploy_contract(
:return: deployed contract address
"""
contract = cls.get_contract(cls, ethereum_client.w3)
tx = contract.constructor().buildTransaction({"from": deployer_account.address})
tx = contract.constructor().build_transaction(
{"from": deployer_account.address}
)

tx_hash = ethereum_client.send_unsigned_transaction(
tx, private_key=deployer_account.key
Expand Down
4 changes: 2 additions & 2 deletions gnosis/eth/oracles/oracles.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ def _get_balances_using_batching(
}
erc20 = get_erc20_contract(self.w3, token_address)
params = {"gas": 0, "gasPrice": 0}
decimals_data = erc20.functions.decimals().buildTransaction(params)["data"]
decimals_data = erc20.functions.decimals().build_transaction(params)["data"]
token_balance_data = erc20.functions.balanceOf(
uniswap_exchange_address
).buildTransaction(params)["data"]
).build_transaction(params)["data"]
datas = [decimals_data, token_balance_data]
payload_calls = [
{
Expand Down
16 changes: 8 additions & 8 deletions gnosis/eth/tests/test_ethereum_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ def test_get_total_transfer_history(self):
self.send_tx(
erc20_contract.functions.transfer(
account_1.address, amount // 2
).buildTransaction({"from": owner_account.address}),
).build_transaction({"from": owner_account.address}),
owner_account,
)
self.send_tx(
erc20_contract.functions.transfer(
account_3.address, amount // 2
).buildTransaction({"from": owner_account.address}),
).build_transaction({"from": owner_account.address}),
owner_account,
)
logs = self.ethereum_client.erc20.get_total_transfer_history(
Expand All @@ -266,7 +266,7 @@ def test_get_total_transfer_history(self):
self.send_tx(
erc20_contract.functions.transfer(
account_2.address, amount // 2
).buildTransaction({"from": account_1.address}),
).build_transaction({"from": account_1.address}),
account_1,
)
# Test `token_address` and `to_block` parameters
Expand Down Expand Up @@ -314,26 +314,26 @@ def test_get_transfer_history(self):
self.send_tx(
erc20_contract.functions.transfer(
receiver_account.address, amount // 2
).buildTransaction({"from": owner_account.address}),
).build_transaction({"from": owner_account.address}),
owner_account,
)
self.send_tx(
erc20_contract.functions.transfer(
receiver2_account.address, amount // 2
).buildTransaction({"from": owner_account.address}),
).build_transaction({"from": owner_account.address}),
owner_account,
)

self.send_tx(
erc20_contract.functions.transfer(
receiver3_account.address, amount // 4
).buildTransaction({"from": receiver_account.address}),
).build_transaction({"from": receiver_account.address}),
receiver_account,
)
self.send_tx(
erc20_contract.functions.transfer(
receiver3_account.address, amount // 4
).buildTransaction({"from": receiver2_account.address}),
).build_transaction({"from": receiver2_account.address}),
receiver2_account,
)

Expand Down Expand Up @@ -867,7 +867,7 @@ def test_estimate_gas_with_erc20(self):
erc20_contract = self.deploy_example_erc20(amount_tokens, from_)
transfer_tx = erc20_contract.functions.transfer(
to, amount_to_send
).buildTransaction({"from": from_})
).build_transaction({"from": from_})
data = transfer_tx["data"]

# Ganache does not cares about all this anymore
Expand Down
4 changes: 2 additions & 2 deletions gnosis/eth/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_generate_address2_with_proxy(self):
nonce = self.w3.eth.get_transaction_count(
deployer_account.address, block_identifier="pending"
)
tx = proxy_factory_contract.constructor().buildTransaction(
tx = proxy_factory_contract.constructor().build_transaction(
{"nonce": nonce, "from": deployer_account.address}
)
signed_tx = deployer_account.sign_transaction(tx)
Expand All @@ -64,7 +64,7 @@ def test_generate_address2_with_proxy(self):
master_copy = Account.create().address
tx = proxy_factory_contract.functions.createProxyWithNonce(
master_copy, initializer, salt_nonce
).buildTransaction(
).build_transaction(
{
"nonce": nonce + 1,
"from": deployer_account.address,
Expand Down
2 changes: 1 addition & 1 deletion gnosis/eth/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def deploy_erc20(
erc20_contract = get_example_erc20_contract(w3)
tx = erc20_contract.constructor(
name, symbol, decimals, owner, amount
).buildTransaction(
).build_transaction(
{
"nonce": w3.eth.get_transaction_count(
account.address, block_identifier="pending"
Expand Down
6 changes: 4 additions & 2 deletions gnosis/safe/multi_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ def deploy_contract(
:return: deployed contract address
"""
contract = get_multi_send_contract(ethereum_client.w3)
tx = contract.constructor().buildTransaction({"from": deployer_account.address})
tx = contract.constructor().build_transaction(
{"from": deployer_account.address}
)

tx_hash = ethereum_client.send_unsigned_transaction(
tx, private_key=deployer_account.key
Expand Down Expand Up @@ -262,4 +264,4 @@ def build_tx_data(self, multi_send_txs: List[MultiSendTx]) -> bytes:
encoded_multisend_data = b"".join([x.encoded_data for x in multi_send_txs])
return multisend_contract.functions.multiSend(
encoded_multisend_data
).buildTransaction({"gas": 1, "gasPrice": 1})["data"]
).build_transaction({"gas": 1, "gasPrice": 1})["data"]
8 changes: 5 additions & 3 deletions gnosis/safe/proxy_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def _deploy_proxy_factory_contract(
deployer_account: LocalAccount,
contract: Contract,
) -> EthereumTxSent:
tx = contract.constructor().buildTransaction({"from": deployer_account.address})
tx = contract.constructor().build_transaction(
{"from": deployer_account.address}
)

tx_hash = ethereum_client.send_unsigned_transaction(
tx, private_key=deployer_account.key
Expand Down Expand Up @@ -162,7 +164,7 @@ def deploy_proxy_contract(
if gas is not None:
tx_parameters["gas"] = gas

tx = create_proxy_fn.buildTransaction(tx_parameters)
tx = create_proxy_fn.build_transaction(tx_parameters)
# Auto estimation of gas does not work. We use a little more gas just in case
tx["gas"] = tx["gas"] + 50000
tx_hash = self.ethereum_client.send_unsigned_transaction(
Expand Down Expand Up @@ -209,7 +211,7 @@ def deploy_proxy_contract_with_nonce(
if nonce is not None:
tx_parameters["nonce"] = nonce

tx = create_proxy_fn.buildTransaction(tx_parameters)
tx = create_proxy_fn.build_transaction(tx_parameters)
# Auto estimation of gas does not work. We use a little more gas just in case
tx["gas"] = tx["gas"] + 50000
tx_hash = self.ethereum_client.send_unsigned_transaction(
Expand Down
20 changes: 10 additions & 10 deletions gnosis/safe/safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def create(
payment,
payment_receiver,
)
.buildTransaction({"gas": Wei(1), "gasPrice": Wei(1)})["data"]
.build_transaction({"gas": Wei(1), "gasPrice": Wei(1)})["data"]
)

if proxy_factory_address:
Expand All @@ -157,7 +157,7 @@ def create(
proxy_contract = get_delegate_constructor_proxy_contract(ethereum_client.w3)
tx = proxy_contract.constructor(
master_copy_address, initializer
).buildTransaction({"from": deployer_account.address})
).build_transaction({"from": deployer_account.address})
tx["gas"] = tx["gas"] * 100000
tx_hash = ethereum_client.send_unsigned_transaction(
tx, private_key=deployer_account.key
Expand Down Expand Up @@ -185,7 +185,7 @@ def _deploy_master_contract(
:return: deployed contract address
"""
safe_contract = contract_fn(ethereum_client.w3)
constructor_tx = safe_contract.constructor().buildTransaction()
constructor_tx = safe_contract.constructor().build_transaction()
tx_hash = ethereum_client.send_unsigned_transaction(
constructor_tx, private_key=deployer_account.key
)
Expand Down Expand Up @@ -221,7 +221,7 @@ def deploy_compatibility_fallback_handler(
contract = get_compatibility_fallback_handler_V1_3_0_contract(
ethereum_client.w3
)
constructor_tx = contract.constructor().buildTransaction()
constructor_tx = contract.constructor().build_transaction()
tx_hash = ethereum_client.send_unsigned_transaction(
constructor_tx, private_key=deployer_account.key
)
Expand Down Expand Up @@ -287,7 +287,7 @@ def deploy_master_contract_v1_0_0(
"""

safe_contract = get_safe_V1_0_0_contract(ethereum_client.w3)
constructor_data = safe_contract.constructor().buildTransaction({"gas": 0})[
constructor_data = safe_contract.constructor().build_transaction({"gas": 0})[
"data"
]
initializer_data = safe_contract.functions.setup(
Expand All @@ -302,7 +302,7 @@ def deploy_master_contract_v1_0_0(
NULL_ADDRESS, # Payment token
0, # Payment
NULL_ADDRESS, # Refund receiver
).buildTransaction({"to": NULL_ADDRESS})["data"]
).build_transaction({"to": NULL_ADDRESS})["data"]

ethereum_tx_sent = ethereum_client.deploy_and_initialize_contract(
deployer_account, constructor_data, HexBytes(initializer_data)
Expand All @@ -327,7 +327,7 @@ def deploy_master_contract_v0_0_1(
"""

safe_contract = get_safe_V0_0_1_contract(ethereum_client.w3)
constructor_data = safe_contract.constructor().buildTransaction({"gas": 0})[
constructor_data = safe_contract.constructor().build_transaction({"gas": 0})[
"data"
]
initializer_data = safe_contract.functions.setup(
Expand All @@ -339,7 +339,7 @@ def deploy_master_contract_v0_0_1(
2, # Threshold. Maximum security
NULL_ADDRESS, # Address for optional DELEGATE CALL
b"", # Data for optional DELEGATE CALL
).buildTransaction({"to": NULL_ADDRESS})["data"]
).build_transaction({"to": NULL_ADDRESS})["data"]

ethereum_tx_sent = ethereum_client.deploy_and_initialize_contract(
deployer_account, constructor_data, HexBytes(initializer_data)
Expand Down Expand Up @@ -577,7 +577,7 @@ def estimate_tx_base_gas(
gas_token,
refund_receiver,
signatures,
).buildTransaction({"gas": 1, "gasPrice": 1})["data"]
).build_transaction({"gas": 1, "gasPrice": 1})["data"]
)

# If nonce == 0, nonce storage has to be initialized
Expand Down Expand Up @@ -654,7 +654,7 @@ def parse_revert_data(result: bytes) -> int:
tx = (
self.get_contract()
.functions.requiredTxGas(to, value, data, operation)
.buildTransaction(
.build_transaction(
{
"from": safe_address,
"gas": 0, # Don't call estimate
Expand Down
8 changes: 4 additions & 4 deletions gnosis/safe/safe_create2_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def _estimate_gas(
# Estimate the contract deployment. We cannot estimate the refunding, as the safe address has not any fund
gas: int = self.proxy_factory_contract.functions.createProxyWithNonce(
self.master_copy_address, initializer, salt_nonce
).estimateGas()
).estimate_gas()

# It's not very relevant if is 1 or 9999
payment: int = 1
Expand All @@ -264,7 +264,7 @@ def _estimate_gas(
# try:
# gas += get_erc20_contract(self.w3,
# payment_token).functions.transfer(payment_receiver,
# payment).estimateGas({'from':
# payment).estimate_gas({'from':
# payment_token})
# except ValueError as exc:
# raise InvalidERC20Token from exc
Expand Down Expand Up @@ -296,7 +296,7 @@ def _get_initial_setup_safe_data(
payment_token,
payment,
payment_receiver,
).buildTransaction(empty_params)["data"]
).build_transaction(empty_params)["data"]
)
elif self.safe_version == "1.0.0":
return HexBytes(
Expand All @@ -308,7 +308,7 @@ def _get_initial_setup_safe_data(
payment_token,
payment,
payment_receiver,
).buildTransaction(empty_params)["data"]
).build_transaction(empty_params)["data"]
)
else:
raise ValueError("Safe version must be 1.3.0, 1.1.1 or 1.0.0")
8 changes: 4 additions & 4 deletions gnosis/safe/safe_creation_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _build_proxy_contract_creation_tx(
"""
return self._build_proxy_contract_creation_constructor(
master_copy, initializer, funder, payment_token, payment
).buildTransaction(
).build_transaction(
{
"gas": gas,
"gasPrice": gas_price,
Expand Down Expand Up @@ -295,7 +295,7 @@ def _estimate_gas(
# Estimate the contract deployment. We cannot estimate the refunding, as the safe address has not any fund
gas: int = self._build_proxy_contract_creation_constructor(
master_copy, initializer, funder, payment_token, 0
).estimateGas()
).estimate_gas()

# We estimate the refund as a new tx
if payment_token == NULL_ADDRESS:
Expand All @@ -309,7 +309,7 @@ def _estimate_gas(
gas += (
get_erc20_contract(self.w3, payment_token)
.functions.transfer(funder, 1)
.estimateGas({"from": payment_token})
.estimate_gas({"from": payment_token})
)
except ValueError as exc:
if "transfer amount exceeds balance" in str(exc):
Expand All @@ -327,7 +327,7 @@ def _get_initial_setup_safe_data(self, owners: List[str], threshold: int) -> byt
NULL_ADDRESS, # Contract address for optional delegate call
b"", # Data payload for optional delegate call
)
.buildTransaction(
.build_transaction(
{
"gas": 1,
"gasPrice": 1,
Expand Down
4 changes: 2 additions & 2 deletions gnosis/safe/safe_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def sorted_signers(self):
@property
def w3_tx(self):
"""
:return: Web3 contract tx prepared for `call`, `transact` or `buildTransaction`
:return: Web3 contract tx prepared for `call`, `transact` or `build_transaction`
"""
return self.contract.functions.execTransaction(
self.to,
Expand Down Expand Up @@ -394,7 +394,7 @@ def execute(
if tx_nonce is not None:
tx_parameters["nonce"] = tx_nonce

self.tx = self.w3_tx.buildTransaction(tx_parameters)
self.tx = self.w3_tx.build_transaction(tx_parameters)
self.tx["gas"] = Wei(
tx_gas or (max(self.tx["gas"] + 75000, self.recommended_gas()))
)
Expand Down
Loading

0 comments on commit ae41de6

Please sign in to comment.