-
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
contract permissioned/less hybdrid validation for game_end #15
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Important Auto Review SkippedReview was skipped due to path filters Files ignored due to path filters (6)
You can disable this status message by setting the WalkthroughThe recent update enhances the Prudent Pots contract with a 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.
Actionable comments posted: 3
Out of diff range and nitpick comments (2)
contracts/prudent-pots/src/execute.rs (1)
Line range hint
158-158
: Ensure fee deduction logic is optimized to prevent unnecessary calculations.- let fee = amount.multiply_ratio(game_config.fee_reallocation, 100u128); - let net_amount = amount.checked_sub(fee)?; + let net_amount = amount.checked_sub(amount.multiply_ratio(game_config.fee_reallocation, 100u128))?;contracts/prudent-pots/src/helpers/game_end.rs (1)
Line range hint
173-243
: Complex raffle processing logic could be simplified for better readability and maintainability.- // TODO: Early return here if there is no raffle - // if raffle.nft_id && addr is none and denom_prize is_zero() return all default values. + // Simplify raffle processing by consolidating conditions and early returns
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (10)
- contracts/prudent-pots/src/contract.rs (3 hunks)
- contracts/prudent-pots/src/execute.rs (7 hunks)
- contracts/prudent-pots/src/helpers/game_end.rs (10 hunks)
- contracts/prudent-pots/src/helpers/validate.rs (4 hunks)
- contracts/prudent-pots/src/msg.rs (2 hunks)
- contracts/prudent-pots/src/state.rs (1 hunks)
- contracts/prudent-pots/src/tests/distribute_tokens.rs (1 hunks)
- contracts/prudent-pots/src/tests/instantiate.rs (1 hunks)
- contracts/prudent-pots/src/tests/integration/fixtures.rs (3 hunks)
- contracts/prudent-pots/src/tests/integration/update_config.rs (2 hunks)
Additional comments not posted (10)
contracts/prudent-pots/src/state.rs (1)
14-14
: Addition ofgame_end_threshold
aligns with the PR's objectives to enhance game end logic.contracts/prudent-pots/src/tests/integration/update_config.rs (1)
25-25
: Proper inclusion ofgame_end_threshold
in configuration update tests.contracts/prudent-pots/src/tests/instantiate.rs (1)
22-22
: Correct initialization ofgame_end_threshold
in game setup for tests.contracts/prudent-pots/src/msg.rs (1)
24-24
: Inclusion ofgame_end_threshold
inExecuteMsg
allows external configuration updates.contracts/prudent-pots/src/tests/distribute_tokens.rs (1)
68-70
: Adjustments in test to match updated function signature ofget_distribution_send_msgs
.contracts/prudent-pots/src/contract.rs (1)
Line range hint
77-91
: Handling ofgame_end_threshold
inexecute
function enables dynamic updates to game end configuration.contracts/prudent-pots/src/helpers/validate.rs (1)
28-61
: Addition ofvalidate_is_contract_admin_game_end
implements hybrid validation logic for game end.contracts/prudent-pots/src/tests/integration/fixtures.rs (1)
123-123
: Correct initialization ofgame_end_threshold
in integration test fixtures.Also applies to: 196-196
contracts/prudent-pots/src/execute.rs (1)
207-207
: Correctly added admin validation for game end.contracts/prudent-pots/src/helpers/game_end.rs (1)
Line range hint
25-98
: Updated function signature and logic for preparing the next game correctly.
if let Some(game_end_threshold) = game_end_threshold { | ||
game_config.game_end_threshold = game_end_threshold; | ||
} |
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.
Add validation for game_end_threshold
to ensure it's within an acceptable range.
+ if let Some(game_end_threshold) = game_end_threshold {
+ if game_end_threshold < 1 || game_end_threshold > 10000 {
+ return Err(ContractError::InvalidInput {});
+ }
+ game_config.game_end_threshold = game_end_threshold;
+ }
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.
if let Some(game_end_threshold) = game_end_threshold { | |
game_config.game_end_threshold = game_end_threshold; | |
} | |
if let Some(game_end_threshold) = game_end_threshold { | |
if game_end_threshold < 1 || game_end_threshold > 10000 { | |
return Err(ContractError::InvalidInput {}); | |
} | |
game_config.game_end_threshold = game_end_threshold; | |
} |
// TODO: Decide if we want the prizes to be part of whitelisted cw721_addrs in GameConfig, | ||
// or if the whitelist should jsut be the ones that gives minBid discount eligibility |
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.
Consider simplifying the raffle prize logic to improve maintainability.
- // TODO: Decide if we want the prizes to be part of whitelisted cw721_addrs in GameConfig,
- // or if the whitelist should just be the ones that gives minBid discount eligibility
+ // Simplify raffle prize logic by consolidating prize conditions
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.
// TODO: Decide if we want the prizes to be part of whitelisted cw721_addrs in GameConfig, | |
// or if the whitelist should jsut be the ones that gives minBid discount eligibility | |
// Simplify raffle prize logic by consolidating prize conditions |
// Reset player allocations for the next game, and first bidder | ||
PLAYER_ALLOCATIONS.clear(deps.storage); | ||
FIRST_BIDDER.clear(deps.storage); |
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.
Consider adding comments to explain the purpose of clearing player allocations and the first bidder.
+ // Clear player allocations to reset the game state for the next round
PLAYER_ALLOCATIONS.clear(deps.storage);
+ // Clear the first bidder information as part of game reset
FIRST_BIDDER.clear(deps.storage);
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.
// Reset player allocations for the next game, and first bidder | |
PLAYER_ALLOCATIONS.clear(deps.storage); | |
FIRST_BIDDER.clear(deps.storage); | |
// Reset player allocations for the next game, and first bidder | |
// Clear player allocations to reset the game state for the next round | |
PLAYER_ALLOCATIONS.clear(deps.storage); | |
// Clear the first bidder information as part of game reset | |
FIRST_BIDDER.clear(deps.storage); |
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.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- .github/workflows/ci.yml (1 hunks)
Additional comments not posted (2)
.github/workflows/ci.yml (2)
Line range hint
1-30
: Thebuild-and-test
job configuration looks good and follows best practices for setting up Rust projects on GitHub Actions.
42-45
: Ensure the Docker volume mounts are correctly configured for caching. The use of$(basename "$(pwd)")_cache
for the source volume might not behave as expected if the working directory's name contains spaces or special characters. Consider using a simpler, more predictable naming convention for the cache volume.- --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target + --mount type=volume,source="workspace_cache",target=/target
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.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (5)
Cargo.lock
is excluded by!**/*.lock
,!**/*.lock
schema/prudent-pots.json
is excluded by!**/*.json
schema/raw/execute.json
is excluded by!**/*.json
schema/raw/instantiate.json
is excluded by!**/*.json
schema/raw/response_to_game_config.json
is excluded by!**/*.json
Files selected for processing (10)
- .gitignore (2 hunks)
- contracts/prudent-pots/src/contract.rs (3 hunks)
- contracts/prudent-pots/src/execute.rs (9 hunks)
- contracts/prudent-pots/src/helpers/game_end.rs (10 hunks)
- contracts/prudent-pots/src/helpers/validate.rs (5 hunks)
- contracts/prudent-pots/src/msg.rs (2 hunks)
- contracts/prudent-pots/src/state.rs (2 hunks)
- contracts/prudent-pots/src/tests/instantiate.rs (1 hunks)
- contracts/prudent-pots/src/tests/integration/fixtures.rs (3 hunks)
- contracts/prudent-pots/src/tests/integration/update_config.rs (2 hunks)
Files skipped from review due to trivial changes (1)
- .gitignore
Files skipped from review as they are similar to previous changes (9)
- contracts/prudent-pots/src/contract.rs
- contracts/prudent-pots/src/execute.rs
- contracts/prudent-pots/src/helpers/game_end.rs
- contracts/prudent-pots/src/helpers/validate.rs
- contracts/prudent-pots/src/msg.rs
- contracts/prudent-pots/src/state.rs
- contracts/prudent-pots/src/tests/instantiate.rs
- contracts/prudent-pots/src/tests/integration/fixtures.rs
- contracts/prudent-pots/src/tests/integration/update_config.rs
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.
Actionable comments posted: 1
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- contracts/prudent-pots/src/contract.rs (4 hunks)
- contracts/prudent-pots/src/msg.rs (3 hunks)
- contracts/prudent-pots/src/query.rs (2 hunks)
Additional comments not posted (3)
contracts/prudent-pots/src/msg.rs (2)
24-27
: Addition ofgame_end_threshold
enhances game configuration flexibility.
119-122
: Addition ofPlayerReallocationsResponse
supports new player reallocation queries.contracts/prudent-pots/src/contract.rs (1)
Line range hint
78-96
: Enhancements toExecuteMsg::UpdateConfig
support new game configuration options.
pub fn query_player_reallocations( | ||
deps: Deps, | ||
address: String, | ||
) -> StdResult<PlayerReallocationsResponse> { | ||
// Attempt to load player reallocations count. If not found, return an deafult PlayerReallocations count 0. | ||
let reallocations = PLAYER_REALLOCATIONS | ||
.may_load(deps.storage, address)? | ||
.unwrap_or_default(); | ||
|
||
Ok(PlayerReallocationsResponse { reallocations }) | ||
} |
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.
Implementation of player reallocations querying supports new functionality. Consider clarifying the comment in line 77 to specify what the default count is.
- // Attempt to load player reallocations count. If not found, return an deafult PlayerReallocations count 0.
+ // Attempt to load player reallocations count. If not found, return a default PlayerReallocations count of 0.
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.
pub fn query_player_reallocations( | |
deps: Deps, | |
address: String, | |
) -> StdResult<PlayerReallocationsResponse> { | |
// Attempt to load player reallocations count. If not found, return an deafult PlayerReallocations count 0. | |
let reallocations = PLAYER_REALLOCATIONS | |
.may_load(deps.storage, address)? | |
.unwrap_or_default(); | |
Ok(PlayerReallocationsResponse { reallocations }) | |
} | |
pub fn query_player_reallocations( | |
deps: Deps, | |
address: String, | |
) -> StdResult<PlayerReallocationsResponse> { | |
// Attempt to load player reallocations count. If not found, return a default PlayerReallocations count of 0. | |
let reallocations = PLAYER_REALLOCATIONS | |
.may_load(deps.storage, address)? | |
.unwrap_or_default(); | |
Ok(PlayerReallocationsResponse { reallocations }) | |
} |
No description provided.