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

Allow to accept bytes in send_xdai_to, add chainId to tx params #568

Merged
merged 3 commits into from
Dec 4, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions prediction_market_agent_tooling/tools/web3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ def _prepare_tx_params(
from_checksummed = Web3.to_checksum_address(tx_params_new["from"])
tx_params_new["nonce"] = web3.eth.get_transaction_count(from_checksummed)

if not tx_params_new.get("chainId"):
tx_params_new["chainId"] = web3.eth.chain_id
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if access_list is not None:
tx_params_new["accessList"] = access_list

Expand Down Expand Up @@ -297,15 +300,19 @@ def send_xdai_to(
from_private_key: PrivateKey,
to_address: ChecksumAddress,
value: Wei,
data_text: Optional[str] = None,
data_text: Optional[str | bytes] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
) -> TxReceipt:
from_address = private_key_to_public_key(from_private_key)

tx_params_new: TxParams = {"value": value, "to": to_address}
if data_text is not None:
tx_params_new["data"] = Web3.to_bytes(text=data_text)
tx_params_new["data"] = (
Web3.to_bytes(text=data_text)
if not isinstance(data_text, bytes)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zlib will return bytes, so it can be just used here

else data_text
)
if tx_params:
tx_params_new.update(tx_params)
tx_params_new = _prepare_tx_params(web3, from_address, tx_params=tx_params_new)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "prediction-market-agent-tooling"
version = "0.57.4"
version = "0.57.5"
description = "Tools to benchmark, deploy and monitor prediction market agents."
authors = ["Gnosis"]
readme = "README.md"
Expand Down
Loading