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

Feat: Adding proc fold, its endpoint and its unit test #13

Merged
merged 14 commits into from
May 10, 2024

Conversation

Created-for-a-purpose
Copy link
Collaborator

No description provided.

use.miden::account

# const.CURRNET_TURN_PLAYER_PUB_KEY_INDEX=63

Copy link
Member

Choose a reason for hiding this comment

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

We can delete this file since we are not using it anywhere.

@@ -173,10 +173,10 @@ fn construct_game_constructor_storage(
];
player_pub_keys.extend(player_slots);

slot_index += 8; // since the mid 9 elements would cover the player stats and initially all those values are zero
slot_index += 13; // since the mid 9 elements would cover the player stats and initially all those values are zero
Copy link
Member

Choose a reason for hiding this comment

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

Can you hardcode this different in constant, And name it something suitable.

@@ -64,6 +69,13 @@ pub struct PlayCallTransactionData {
target_account_id: AccountId,
}

#[derive(Clone)]
pub struct PlayFoldTransactionData {
Copy link
Member

Choose a reason for hiding this comment

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

Shall we start moving types to types library crate ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes ig

RpoDigest::new([Felt::from(next_turn_index), Felt::ZERO, Felt::ZERO, Felt::ZERO])
);
}

async fn fund_account(client: &mut AzeClient, account_id: AccountId, faucet_account_id: AccountId) {
Copy link
Member

Choose a reason for hiding this comment

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

why are we minting two notes here to same account id ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This func is also used by test_cards_dist, where two notes need to be minted as there are two players to whom cards are being distributed.

Comment on lines +552 to +562
assert_eq!(
game_account_storage.get_item(fold_index),
RpoDigest::new([Felt::from(1 as u8), Felt::ZERO, Felt::ZERO, Felt::ZERO])
);

let next_turn_index = slot_data.current_turn_index() + 13;
// check next turn index
assert_eq!(
game_account_storage.get_item(CURRENT_TURN_INDEX_SLOT),
RpoDigest::new([Felt::from(next_turn_index), Felt::ZERO, Felt::ZERO, Felt::ZERO])
);
Copy link
Member

Choose a reason for hiding this comment

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

We might need few more assertions ig, but i think it's fine for now.

# => [no_of_players, next_turn_index]

# Calculate last_player_index = 52 + 13 * no_of_players + 0
push.13 mul
Copy link
Member

Choose a reason for hiding this comment

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

Since 52 and 13 would always remain fixed so can you create constants for storing these values. Or use them if you have already created one.

Copy link
Member

@nlok5923 nlok5923 left a comment

Choose a reason for hiding this comment

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

LGTM :)

@nlok5923 nlok5923 merged commit 03a3481 into main May 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants