-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add script for betting on omen #4
Conversation
WalkthroughThis update introduces a new script, Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files ignored due to path filters (2)
mypy.ini
is excluded by:!**/*.ini
pyproject.toml
is excluded by:!**/*.toml
Files selected for processing (1)
- scripts/bet_omen.py (1 hunks)
Additional comments: 1
scripts/bet_omen.py (1)
- 85-86: The script initialization is correctly set up to run the
typer
app. No issues found here.
@app.command() | ||
def buy( | ||
amount: str = typer.Option(), | ||
from_address: str = typer.Option(), | ||
from_private_key: str = typer.Option(), | ||
market_id: str = typer.Option(), | ||
outcome: str = typer.Option(), | ||
auto_deposit: bool = typer.Option(False), | ||
) -> None: | ||
""" | ||
Helper script to place a bet on Omen, usage: | ||
|
||
```bash | ||
python scripts/bet_omen.py buy \ | ||
--amount 0.01 \ | ||
--from-address your-address \ | ||
--from-private-key your-private-key \ | ||
--market-id some-market-id \ | ||
--outcome one-of-the-outcomes | ||
``` | ||
|
||
Market ID can be found easily in the URL: https://aiomen.eth.limo/#/0x86376012a5185f484ec33429cadfa00a8052d9d4 | ||
""" | ||
market = get_market(market_id) | ||
omen_buy_outcome_tx( | ||
amount=xdai_type(amount), | ||
from_address=verify_address(from_address), | ||
from_private_key=PrivateKey(from_private_key), | ||
market=market, | ||
outcome=outcome, | ||
auto_deposit=auto_deposit, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buy
function lacks input validation for amount
, market_id
, and outcome
. Ensure inputs are sanitized and validated to prevent injection attacks or errors.
+ if not amount.isdigit():
+ raise ValueError("Amount must be a numeric value.")
+ if not market_id.isalnum():
+ raise ValueError("Market ID must be alphanumeric.")
+ if not outcome.isalnum():
+ raise ValueError("Outcome must be alphanumeric.")
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
@app.command() | |
def buy( | |
amount: str = typer.Option(), | |
from_address: str = typer.Option(), | |
from_private_key: str = typer.Option(), | |
market_id: str = typer.Option(), | |
outcome: str = typer.Option(), | |
auto_deposit: bool = typer.Option(False), | |
) -> None: | |
""" | |
Helper script to place a bet on Omen, usage: | |
```bash | |
python scripts/bet_omen.py buy \ | |
--amount 0.01 \ | |
--from-address your-address \ | |
--from-private-key your-private-key \ | |
--market-id some-market-id \ | |
--outcome one-of-the-outcomes | |
``` | |
Market ID can be found easily in the URL: https://aiomen.eth.limo/#/0x86376012a5185f484ec33429cadfa00a8052d9d4 | |
""" | |
market = get_market(market_id) | |
omen_buy_outcome_tx( | |
amount=xdai_type(amount), | |
from_address=verify_address(from_address), | |
from_private_key=PrivateKey(from_private_key), | |
market=market, | |
outcome=outcome, | |
auto_deposit=auto_deposit, | |
) | |
@app.command() | |
def buy( | |
amount: str = typer.Option(), | |
from_address: str = typer.Option(), | |
from_private_key: str = typer.Option(), | |
market_id: str = typer.Option(), | |
outcome: str = typer.Option(), | |
auto_deposit: bool = typer.Option(False), | |
) -> None: | |
""" | |
Helper script to place a bet on Omen, usage: | |
```bash | |
python scripts/bet_omen.py buy \ | |
--amount 0.01 \ | |
--from-address your-address \ | |
--from-private-key your-private-key \ | |
--market-id some-market-id \ | |
--outcome one-of-the-outcomes | |
``` | |
Market ID can be found easily in the URL: https://aiomen.eth.limo/#/0x86376012a5185f484ec33429cadfa00a8052d9d4 | |
""" | |
if not amount.isdigit(): | |
raise ValueError("Amount must be a numeric value.") | |
if not market_id.isalnum(): | |
raise ValueError("Market ID must be alphanumeric.") | |
if not outcome.isalnum(): | |
raise ValueError("Outcome must be alphanumeric.") | |
market = get_market(market_id) | |
omen_buy_outcome_tx( | |
amount=xdai_type(amount), | |
from_address=verify_address(from_address), | |
from_private_key=PrivateKey(from_private_key), | |
market=market, | |
outcome=outcome, | |
auto_deposit=auto_deposit, | |
) |
@app.command() | ||
def sell( | ||
amount: str = typer.Option(), | ||
from_address: str = typer.Option(), | ||
from_private_key: str = typer.Option(), | ||
market_id: str = typer.Option(), | ||
outcome: str = typer.Option(), | ||
auto_withdraw: bool = typer.Option(False), | ||
) -> None: | ||
""" | ||
Helper script to sell outcome of an existing bet on Omen, usage: | ||
|
||
```bash | ||
python scripts/bet_omen.py sell \ | ||
--amount 0.01 \ | ||
--from-address your-address \ | ||
--from-private-key your-private-key \ | ||
--market-id some-market-id \ | ||
--outcome one-of-the-outcomes | ||
``` | ||
|
||
Market ID can be found easily in the URL: https://aiomen.eth.limo/#/0x86376012a5185f484ec33429cadfa00a8052d9d4 | ||
""" | ||
market = get_market(market_id) | ||
omen_sell_outcome_tx( | ||
amount=xdai_type(amount), | ||
from_address=verify_address(from_address), | ||
from_private_key=PrivateKey(from_private_key), | ||
market=market, | ||
outcome=outcome, | ||
auto_withdraw=auto_withdraw, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the buy
function, the sell
function also lacks input validation for amount
, market_id
, and outcome
. Apply the same input validation here to ensure data integrity and security.
+ if not amount.isdigit():
+ raise ValueError("Amount must be a numeric value.")
+ if not market_id.isalnum():
+ raise ValueError("Market ID must be alphanumeric.")
+ if not outcome.isalnum():
+ raise ValueError("Outcome must be alphanumeric.")
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
@app.command() | |
def sell( | |
amount: str = typer.Option(), | |
from_address: str = typer.Option(), | |
from_private_key: str = typer.Option(), | |
market_id: str = typer.Option(), | |
outcome: str = typer.Option(), | |
auto_withdraw: bool = typer.Option(False), | |
) -> None: | |
""" | |
Helper script to sell outcome of an existing bet on Omen, usage: | |
```bash | |
python scripts/bet_omen.py sell \ | |
--amount 0.01 \ | |
--from-address your-address \ | |
--from-private-key your-private-key \ | |
--market-id some-market-id \ | |
--outcome one-of-the-outcomes | |
``` | |
Market ID can be found easily in the URL: https://aiomen.eth.limo/#/0x86376012a5185f484ec33429cadfa00a8052d9d4 | |
""" | |
market = get_market(market_id) | |
omen_sell_outcome_tx( | |
amount=xdai_type(amount), | |
from_address=verify_address(from_address), | |
from_private_key=PrivateKey(from_private_key), | |
market=market, | |
outcome=outcome, | |
auto_withdraw=auto_withdraw, | |
) | |
@app.command() | |
def sell( | |
amount: str = typer.Option(), | |
from_address: str = typer.Option(), | |
from_private_key: str = typer.Option(), | |
market_id: str = typer.Option(), | |
outcome: str = typer.Option(), | |
auto_withdraw: bool = typer.Option(False), | |
) -> None: | |
""" | |
Helper script to sell outcome of an existing bet on Omen, usage: | |
```bash | |
python scripts/bet_omen.py sell \ | |
--amount 0.01 \ | |
--from-address your-address \ | |
--from-private-key your-private-key \ | |
--market-id some-market-id \ | |
--outcome one-of-the-outcomes | |
``` | |
Market ID can be found easily in the URL: https://aiomen.eth.limo/#/0x86376012a5185f484ec33429cadfa00a8052d9d4 | |
""" | |
if not amount.isdigit(): | |
raise ValueError("Amount must be a numeric value.") | |
if not market_id.isalnum(): | |
raise ValueError("Market ID must be alphanumeric.") | |
if not outcome.isalnum(): | |
raise ValueError("Outcome must be alphanumeric.") | |
market = get_market(market_id) | |
omen_sell_outcome_tx( | |
amount=xdai_type(amount), | |
from_address=verify_address(from_address), | |
from_private_key=PrivateKey(from_private_key), | |
market=market, | |
outcome=outcome, | |
auto_withdraw=auto_withdraw, | |
) |
Summary by CodeRabbit