Skip to content

Commit

Permalink
fix: safe tx gas price should be zero (#52)
Browse files Browse the repository at this point in the history
* fix: safe tx gas price should be zero

* fix: install deps from github

* test: remove meaningless test

* lint: unused import
  • Loading branch information
banteg authored Jun 10, 2024
1 parent c01d411 commit 4889ed7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 34 deletions.
4 changes: 2 additions & 2 deletions ape-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ ethereum:

dependencies:
- name: safe-contracts
npm: "@gnosis.pm/safe-contracts"
version: 1.3.0
github: safe-global/safe-smart-account
version: v1.3.0
config_override:
compile:
exclude:
Expand Down
12 changes: 2 additions & 10 deletions ape_safe/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ape.managers.accounts import AccountManager, TestAccountManager
from ape.types import AddressType, HexBytes, MessageSignature
from ape.utils import ZERO_ADDRESS, cached_property
from ape_ethereum.transactions import StaticFeeTransaction, TransactionType
from ape_ethereum.transactions import TransactionType
from eip712.common import create_safe_tx_def
from eth_account.messages import encode_defunct
from eth_utils import keccak, to_bytes, to_int
Expand Down Expand Up @@ -348,22 +348,14 @@ def create_safe_tx(self, txn: Optional[TransactionAPI] = None, **safe_tx_kwargs)
Returns:
:class:`~ape_safe.client.SafeTx`: The Safe Transaction to be used.
"""
gas_price = safe_tx_kwargs.get(
"gas_price", safe_tx_kwargs.get("gasPrice", safe_tx_kwargs.get("gas"))
)
if gas_price is None and isinstance(txn, StaticFeeTransaction):
gas_price = txn.gas_price or 0
elif gas_price is None:
gas_price = 0

safe_tx = {
"to": txn.receiver if txn else self.address, # Self-call, e.g. rejection
"value": txn.value if txn else 0,
"data": (txn.data or b"") if txn else b"",
"nonce": self.new_nonce if txn is None or txn.nonce is None else txn.nonce,
"operation": 0,
"safeTxGas": 0,
"gasPrice": gas_price,
"gasPrice": 0,
"gasToken": ZERO_ADDRESS,
"refundReceiver": ZERO_ADDRESS,
}
Expand Down
22 changes: 0 additions & 22 deletions tests/integration/test_pending_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,6 @@ def test_propose(runner, cli, one_safe, receiver, chain):
assert one_safe.next_nonce == nonce_at_start


def test_propose_with_gas_price(runner, cli, one_safe, receiver, chain):
cmd = (
"pending",
"propose",
"--to",
receiver.address,
"--value",
"1",
"--gas-price",
chain.provider.gas_price + 1,
"--network",
chain.provider.network_choice,
)
result = runner.invoke(cli, cmd, catch_exceptions=False, input=f"{one_safe.alias}\n")
assert result.exit_code == 0
safe_tx_hash = result.output.split("Proposed transaction '")[-1].split("'")[0].strip()

# Verify gas price was used.
tx = one_safe.client.transactions[safe_tx_hash]
assert tx.gas_price > 0


def test_propose_with_sender(runner, cli, one_safe, receiver, chain, foundry):
# First, fund the safe so the tx does not fail.
receiver.transfer(one_safe, "1 ETH")
Expand Down

0 comments on commit 4889ed7

Please sign in to comment.