Skip to content

Commit

Permalink
fix: issues with sign_transaction() (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
merc1er authored Sep 1, 2022
1 parent e25f3ce commit 9513404
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
25 changes: 12 additions & 13 deletions ape_trezor/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from trezorlib.client import TrezorClient as LibTrezorClient # type: ignore
from trezorlib.client import get_default_client # type: ignore
from trezorlib.exceptions import PinException, TrezorFailure # type: ignore
from trezorlib.messages import TransactionType # type: ignore
from trezorlib.tools import parse_path as parse_hdpath # type: ignore
from trezorlib.transport import TransportException # type: ignore

Expand Down Expand Up @@ -111,32 +110,32 @@ def sign_personal_message(self, message: bytes) -> Tuple[int, bytes, bytes]:
def sign_transaction(self, txn: Dict[Any, Any]) -> Tuple[int, bytes, bytes]:
tx_type = txn["type"]

if isinstance(tx_type, TransactionType.STATIC):
if tx_type == "0x00": # Static transaction type
tuple_reply = ethereum.sign_tx(
self.client,
parse_hdpath(self._account_hd_path.path),
nonce=txn["nonce"],
gas_price=txn["gas_price"],
gas_limit=txn["gas_limit"],
to=txn["receiver"],
gas_price=txn["maxFeePerGas"],
gas_limit=txn["gas"],
to=txn.get("receiver"),
value=txn["value"],
data=txn.get("data"),
chain_id=txn.get("chain_id"),
chain_id=txn.get("chainId"),
tx_type=tx_type,
)
elif isinstance(tx_type, TransactionType.DYNAMIC):
elif tx_type == "0x02": # Dynamic transaction type
tuple_reply = ethereum.sign_tx_eip1559(
self.client,
parse_hdpath(self._account_hd_path.path),
nonce=txn["nonce"],
gas_limit=txn["gas_limit"],
to=txn["receiver"],
gas_limit=txn["gas"],
to=txn.get("receiver"),
value=txn["value"],
data=txn.get("data"),
chain_id=txn["chain_id"],
max_gas_fee=txn["max_fee"],
max_priority_fee=txn["max_priority_fee"],
access_list=txn.get("access_list"),
chain_id=txn["chainId"],
max_gas_fee=txn["maxFeePerGas"],
max_priority_fee=txn["maxPriorityFeePerGas"],
access_list=txn.get("accessList"),
)
else:
raise TrezorAccountException(f"Message type {tx_type} is not supported.")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
install_requires=[
"importlib-metadata ; python_version<'3.8'",
"eth-ape>=0.4.0,<0.5.0",
"eth-account>=0.5.6,<0.6.0",
"eth-account", # Use same version as eth-ape
"eth-typing>=2.2.2",
"click>=8.1.0",
"trezor>=0.13.0",
Expand Down

0 comments on commit 9513404

Please sign in to comment.