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
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions prediction_market_agent_tooling/tools/web3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,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
Loading