-
Notifications
You must be signed in to change notification settings - Fork 298
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
feat: Example card game #2135
feat: Example card game #2135
Conversation
} | ||
|
||
#[aztec(private)] | ||
fn joinGame( |
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.
We should avoid camelCase
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.
ok!
|
]); | ||
|
||
expect((await contract.methods.view_game(GAME_ID).view({ from: firstPlayer })) as Game).toMatchObject({ | ||
players: [ |
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.
:D nice technique
Honourary CGAM member |
yarn-project/noir-contracts/src/contracts/card_game_contract/Nargo.toml
Outdated
Show resolved
Hide resolved
} | ||
|
||
fn compute_deck_strength<N>(cards: [Card; N]) -> Field { | ||
cards.fold(0, |acc, card: Card| { |
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.
"Come to noir we have for loops"
we write this
} | ||
|
||
const cardToField = (card: Card): bigint => { | ||
return card.strength + card.points * 65536n; |
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.
side q:
longer term, is this something that should be handled by a generated typescript class?
also i think there is prover system abstraction leaking through (modulus/overflow is proving system dependent?)
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.
Nah this is only because our macros dont' support arrays of structs yet as arguments to contract functions, when that's updated we don't need to pack the card into a field, we can just pass a card struct
What do you mean about the modulus/overflow? the fact that we can pack the card (32 bits) into a single field? For aztec we can safely assume that we'll always have bn254 I think 🤔
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.
ahh OK got it!
ohh right for modulus I forgot aztec has the pinned backend vs "regular" noir. i was thinking if points got really big we could maybe have overflow (in some setting besides the test)
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.
wow a lot more complex than the private token contract!
🤖 I have created a release *beep* *boop* --- <details><summary>aztec-packages: 0.5.2</summary> ## [0.5.2](aztec-packages-v0.5.2...aztec-packages-v0.5.2) (2023-09-08) ### Features * Example card game ([#2135](#2135)) ([9084b89](9084b89)) ### Bug Fixes * **tests:** Increase test timeout ([#2144](#2144)) ([7da9615](7da9615)) ### Miscellaneous * **build:** Updated release please config ([#2142](#2142)) ([e119c4f](e119c4f)) * Release 0.5.2 ([f76b53c](f76b53c)) </details> <details><summary>barretenberg.js: 0.5.2</summary> ## [0.5.2](barretenberg.js-v0.5.2...barretenberg.js-v0.5.2) (2023-09-08) ### Miscellaneous * Release 0.5.2 ([f76b53c](f76b53c)) </details> <details><summary>barretenberg: 0.5.2</summary> ## [0.5.2](barretenberg-v0.5.2...barretenberg-v0.5.2) (2023-09-08) ### Miscellaneous * Release 0.5.2 ([f76b53c](f76b53c)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- <details><summary>aztec-packages: 0.5.2</summary> ## [0.5.2](AztecProtocol/aztec-packages@aztec-packages-v0.5.2...aztec-packages-v0.5.2) (2023-09-08) ### Features * Example card game ([#2135](AztecProtocol/aztec-packages#2135)) ([9084b89](AztecProtocol/aztec-packages@9084b89)) ### Bug Fixes * **tests:** Increase test timeout ([#2144](AztecProtocol/aztec-packages#2144)) ([7da9615](AztecProtocol/aztec-packages@7da9615)) ### Miscellaneous * **build:** Updated release please config ([#2142](AztecProtocol/aztec-packages#2142)) ([e119c4f](AztecProtocol/aztec-packages@e119c4f)) * Release 0.5.2 ([f76b53c](AztecProtocol/aztec-packages@f76b53c)) </details> <details><summary>barretenberg.js: 0.5.2</summary> ## [0.5.2](AztecProtocol/aztec-packages@barretenberg.js-v0.5.2...barretenberg.js-v0.5.2) (2023-09-08) ### Miscellaneous * Release 0.5.2 ([f76b53c](AztecProtocol/aztec-packages@f76b53c)) </details> <details><summary>barretenberg: 0.5.2</summary> ## [0.5.2](AztecProtocol/aztec-packages@barretenberg-v0.5.2...barretenberg-v0.5.2) (2023-09-08) ### Miscellaneous * Release 0.5.2 ([f76b53c](AztecProtocol/aztec-packages@f76b53c)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- <details><summary>aztec-packages: 0.6.1</summary> ## [0.6.1](aztec-packages-v0.5.2...aztec-packages-v0.6.1) (2023-09-08) ### Features * Example card game ([#2135](#2135)) ([9084b89](9084b89)) ### Bug Fixes * **tests:** Increase test timeout ([#2144](#2144)) ([7da9615](7da9615)) * Work around intermittent wasm webkit issue ([#2140](#2140)) ([a9b0934](a9b0934)) ### Miscellaneous * **build:** Updated release please config ([#2142](#2142)) ([e119c4f](e119c4f)) * **build:** Updated version check ([#2145](#2145)) ([4ed5f05](4ed5f05)) * **master:** Release 0.5.2 ([#2141](#2141)) ([451aad6](451aad6)) * Release 0.5.2 ([f76b53c](f76b53c)) * Release 0.6.1 ([1bd1a79](1bd1a79)) </details> <details><summary>barretenberg.js: 0.6.1</summary> ## [0.6.1](barretenberg.js-v0.5.2...barretenberg.js-v0.6.1) (2023-09-08) ### Miscellaneous * **master:** Release 0.5.2 ([#2141](#2141)) ([451aad6](451aad6)) * Release 0.5.2 ([f76b53c](f76b53c)) * Release 0.6.1 ([1bd1a79](1bd1a79)) </details> <details><summary>barretenberg: 0.6.1</summary> ## [0.6.1](barretenberg-v0.5.2...barretenberg-v0.6.1) (2023-09-08) ### Bug Fixes * Work around intermittent wasm webkit issue ([#2140](#2140)) ([a9b0934](a9b0934)) ### Miscellaneous * **master:** Release 0.5.2 ([#2141](#2141)) ([451aad6](451aad6)) * Release 0.5.2 ([f76b53c](f76b53c)) * Release 0.6.1 ([1bd1a79](1bd1a79)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- <details><summary>aztec-packages: 0.6.1</summary> ## [0.6.1](AztecProtocol/aztec-packages@aztec-packages-v0.5.2...aztec-packages-v0.6.1) (2023-09-08) ### Features * Example card game ([#2135](AztecProtocol/aztec-packages#2135)) ([9084b89](AztecProtocol/aztec-packages@9084b89)) ### Bug Fixes * **tests:** Increase test timeout ([#2144](AztecProtocol/aztec-packages#2144)) ([7da9615](AztecProtocol/aztec-packages@7da9615)) * Work around intermittent wasm webkit issue ([#2140](AztecProtocol/aztec-packages#2140)) ([a9b0934](AztecProtocol/aztec-packages@a9b0934)) ### Miscellaneous * **build:** Updated release please config ([#2142](AztecProtocol/aztec-packages#2142)) ([e119c4f](AztecProtocol/aztec-packages@e119c4f)) * **build:** Updated version check ([#2145](AztecProtocol/aztec-packages#2145)) ([4ed5f05](AztecProtocol/aztec-packages@4ed5f05)) * **master:** Release 0.5.2 ([#2141](AztecProtocol/aztec-packages#2141)) ([451aad6](AztecProtocol/aztec-packages@451aad6)) * Release 0.5.2 ([f76b53c](AztecProtocol/aztec-packages@f76b53c)) * Release 0.6.1 ([1bd1a79](AztecProtocol/aztec-packages@1bd1a79)) </details> <details><summary>barretenberg.js: 0.6.1</summary> ## [0.6.1](AztecProtocol/aztec-packages@barretenberg.js-v0.5.2...barretenberg.js-v0.6.1) (2023-09-08) ### Miscellaneous * **master:** Release 0.5.2 ([#2141](AztecProtocol/aztec-packages#2141)) ([451aad6](AztecProtocol/aztec-packages@451aad6)) * Release 0.5.2 ([f76b53c](AztecProtocol/aztec-packages@f76b53c)) * Release 0.6.1 ([1bd1a79](AztecProtocol/aztec-packages@1bd1a79)) </details> <details><summary>barretenberg: 0.6.1</summary> ## [0.6.1](AztecProtocol/aztec-packages@barretenberg-v0.5.2...barretenberg-v0.6.1) (2023-09-08) ### Bug Fixes * Work around intermittent wasm webkit issue ([#2140](AztecProtocol/aztec-packages#2140)) ([a9b0934](AztecProtocol/aztec-packages@a9b0934)) ### Miscellaneous * **master:** Release 0.5.2 ([#2141](AztecProtocol/aztec-packages#2141)) ([451aad6](AztecProtocol/aztec-packages@451aad6)) * Release 0.5.2 ([f76b53c](AztecProtocol/aztec-packages@f76b53c)) * Release 0.6.1 ([1bd1a79](AztecProtocol/aztec-packages@1bd1a79)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Resolves #1463
Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.