Skip to content

Commit

Permalink
Allow to accept bytes in send_xdai_to
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii committed Dec 4, 2024
1 parent 5d466c4 commit 5a1f7a9
Showing 1 changed file with 6 additions and 2 deletions.
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)
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

0 comments on commit 5a1f7a9

Please sign in to comment.