Skip to content
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 Cadence random in range & commit-reveal helper contract + Cadence tests #23

Merged
merged 11 commits into from
Oct 10, 2024

Conversation

sisyphusSmiling
Copy link
Contributor

@sisyphusSmiling sisyphusSmiling commented Oct 2, 2024

Closes: #2

ℹ️ These changes will require a redeployment of CoinToss.cdc to Testnet and an update to Xorshift128plus on Testnet & Mainnet.

Description

  • Adds test coverage for Cadence coin toss implementation
  • Adds RandomConsumer.cdc contract for generic commit-reveal support & random in range
    • This implementation is largely a Cadence port of the existing CadenceRandomConsumer.sol including public random in range util functions.
    • The big benefit here is that consumers no longer need to think about using a PRG as it's abstracted away into the RandomConsumer.cdc contract.
  • Updates CoinToss.cdc to implement the new RandomConsumer.cdc contract and its defined constructs

Copy link
Member

@joshuahannan joshuahannan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly just comments about error messages. Let me know if you disagree with any of them

contracts/CoinToss.cdc Outdated Show resolved Hide resolved
contracts/CoinToss.cdc Outdated Show resolved Hide resolved
contracts/CoinToss.cdc Outdated Show resolved Hide resolved
contracts/CoinToss.cdc Outdated Show resolved Hide resolved
contracts/RandomConsumer.cdc Outdated Show resolved Hide resolved
contracts/RandomConsumer.cdc Outdated Show resolved Hide resolved
contracts/RandomConsumer.cdc Outdated Show resolved Hide resolved
contracts/RandomConsumer.cdc Outdated Show resolved Hide resolved
contracts/RandomConsumer.cdc Outdated Show resolved Hide resolved
contracts/RandomConsumer.cdc Outdated Show resolved Hide resolved
@sisyphusSmiling
Copy link
Contributor Author

Thanks for all the suggestions @joshuahannan!

@sisyphusSmiling sisyphusSmiling marked this pull request as ready for review October 2, 2024 18:08
@sisyphusSmiling sisyphusSmiling requested a review from a team as a code owner October 2, 2024 18:08
Copy link
Collaborator

@tarakby tarakby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful examples, thanks for adding them 🙏🏼
I left minor comments below

contracts/RandomConsumer.cdc Outdated Show resolved Hide resolved
contracts/RandomConsumer.cdc Show resolved Hide resolved
contracts/RandomConsumer.cdc Show resolved Hide resolved
contracts/RandomConsumer.cdc Show resolved Hide resolved
Co-authored-by: Tarak Ben Youssef <[email protected]>
@sisyphusSmiling sisyphusSmiling merged commit 8d47d83 into main Oct 10, 2024
3 checks passed
@sisyphusSmiling sisyphusSmiling deleted the gio/cadence-random-range branch October 10, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

CoinToss contract tests
3 participants