-
Notifications
You must be signed in to change notification settings - Fork 0
Multiple roulette bets #45
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ndencies This commit completes two improvement plan tasks and updates the tracking document: Task 5 - Enforce code-style & linting (PARTIALLY DONE): - Remove spurious 'ci' dependency from package.json - The 'ci' package was unused and added unnecessary bloat - GitHub Actions CI already provides all needed CI functionality Task 7 - Optimise Roulette.sol for gas & clarity (COMPLETED): - Convert wheel array from memory allocation to constant storage - Add comprehensive NatSpec documentation for _addToSet function - Add @dev comment explaining the COMPLETE_WHEEL_SET constant - This optimization saves gas by avoiding memory allocation on each function call - Maintains 100% backward compatibility - no test updates required IMPROVEMENT_PLAN.md updates: - Update task statuses to reflect completed work - Add detailed progress tracking with checkmarks - Fix summary counts to accurately reflect current state - Add comprehensive task descriptions and next steps Technical details: - COMPLETE_WHEEL_SET: uint8[38] private constant containing wheel numbers 0-37 - _addToSet function now uses constant instead of memory array - All public API remains unchanged, ensuring no breaking changes - Gas optimization: constant storage vs memory allocation - Documentation: Added @dev and @param NatSpec comments Files changed: - contracts/Roulette.sol: Gas optimization and documentation - package.json: Remove unused ci dependency - IMPROVEMENT_PLAN.md: Update task tracking and status
- Combine original plan with critique and improvements - Add complete smart contract bet logic for all roulette bet types - Include security measures (reentrancy protection, input validation) - Add individual bet removal functionality - Include comprehensive testing strategy - Add performance optimizations and error handling - Organize into clear, actionable phases
…dds validation, security, and individual bet removal. Removes single-bet restriction. Updates tests and snapshots.
CONTRACT OPTIMIZATION: - Optimized Roulette.sol contract to reduce size from >24KB to deployable size - Replaced string comparisons and loops with efficient mappings and bit operations - Changed PendingBet struct from string betName to bytes32 betType for gas efficiency - Added _initializeBetTypes() function to set up bet type mappings at deployment - Replaced _validateBetName() and _getBetMultiplier() functions with mapping lookups - Optimized _isRed() function to use mapping instead of array iteration FRONTEND-BACKEND COMPATIBILITY: - Updated blockchainWrapper.js to handle new bytes32 betType structure - Added hash-to-string conversion in getPendingBets() for frontend compatibility - Updated event definitions to match new contract structure (BetPlaced emits bytes32) - Modified Roulette.js event handlers to accept betType instead of betName - Maintained backward compatibility by converting betType hashes back to bet names INSUFFICIENT TOKEN BALANCE FIX: - Added comprehensive debugging throughout the application - Identified root cause: Roulette contract starts with 0 tokens, can't pay winnings - Added getRouletteContractTokenBalance() function to monitor contract liquidity - Added fundRouletteContract() function to transfer tokens from house to contract - Enhanced HouseInfo.js with contract balance display and funding button - Added pre-flight checks in Roulette.js to verify contract has sufficient balance - Added detailed error logging and debugging console messages DEBUGGING ENHANCEMENTS: - Added comprehensive console logging to all blockchain interactions - Enhanced error handling with detailed error information - Added balance checks before wager execution - Added transaction monitoring and status updates - Improved user feedback with specific error messages The contract now deploys successfully and the application can handle bet placement and wager execution without insufficient token balance errors. Users can fund the contract through the House Info panel to ensure sufficient liquidity.
…iables, functions, and imports; update useEffect dependencies; comment out unused contract balance logic. Build now completes with no warnings.
… contract tests. All tests now pass.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.