Show two possible formats of Escrow sample code #3241
Draft
+242
−72
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.
This is an experiment to collect feedback on preferred formats for sample code.
It creates two alternative code samples for sending a time-based escrow:
send-timed-escrow-linear.js
puts as much action as possible at the top level of the file, so that it resolves in a very linear order. This lends itself well to tutorials that have numbered steps, and the control flow is simply "top to bottom".send-timed-escrow-functions.js
splits the action up into several functions and uses amain()
function to call them. This shows the overall control flow first, and compartmentalizes the steps so that the parameters required at each step are more obvious. It's also a little closer to something you could import as a library/module. This lends itself more to a tutorial with a "code walkthrough" rather than numbered steps.The third and fourth options, not presented here, are:
verify_credential.js
that parses user input for values instead of using hard-coded values.Currently we are inclined towards options 1 or 2 because they are easier to write and have fewer distractions from the XRPL-specific parts of the code.