feat: replace HelloWorld with GuessTheNumber #98
Merged
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.
Fixes theahaco/scaffold-stellar#165
The HelloWorld contract is so simple as to be obtuse. It's confusing in its pointlessness. And it doesn't show off anything interesting about blockchain programming.
GuessTheNumber represents a most-basic starting point for a contract that can show some interesting blockchain functionality. Already, it shows:
add_impl_typeand#[internal]to contracttraits stellar/rs-soroban-sdk#1522)This represents the probable starting point for the contract. In its current state, it has many purposeful ommissions/shortcomings. These will be fixed via an onboarding tutorial, with steps roughly as:
Remove
unwrapinguess, since it causes error if admin did not yet callreset. Walk learner through:after_deployscript to see this error in actionset_number)resetand__constructorunwrapwith anexpectguessis currently a view call; no authentication is needed. This means that people do not need to be signed in and there would be no way to pay them. The first thing to do is require authentication; see feat: addguesserarg #101 for an example.No XLM is currently owned by contract or awarded to winning guess; need to require XLM transfer from admin in
resetas well as nominal fee to callguess(which gets added to pot). With upcoming Stellar Registry functionality, we would like this to look like:Those
is_errchecks are bad! Introduce#[contracterror], returnResult<bool, Error>, flatten in the errors from the XLM cross-contract call into this contract's errors, and do thex.transfercalls with question marks to automatically unwrap the results (rust docs).Inspect contract storage (for example, via block explorer) to see stored number; need to obfuscate with fun crypto tricks (how???)
Ideally, this tutorial replaces the main Stellar Developer Docs > Build tutorial, but could also live in Aha-maintained docs (a gitbook? Scaffold Stellar docs?) or possibly in the UI of the app itself