Skip to content

Comments

update to new pattern in cairo2#5

Open
yashm001 wants to merge 22 commits intomainfrom
4-update-to-new-pattern-in-cairo-20
Open

update to new pattern in cairo2#5
yashm001 wants to merge 22 commits intomainfrom
4-update-to-new-pattern-in-cairo-20

Conversation

@yashm001
Copy link
Collaborator

No description provided.

@yashm001 yashm001 linked an issue Oct 13, 2023 that may be closed by this pull request
let owner = erc721_self.owner_of(:token_id);
let master = self._master.read();
let masterDispatcher = IMasterDispatcher { contract_address: master };
// @notice this is a sample SBT contract for dev guild, update the next line before deploying other guild

Choose a reason for hiding this comment

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

Since it's only for a dev guild contract what do you think about changing the name also? Like DevGuildSBT

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its just a temporary name

assert (tier != 0, 'NOT_ENOUGH_POINTS');
let token_id = self._next_token_id.read();
erc721_self._mint(to: account, token_id: token_id.into());
self._wallet_of_owner.write(account, token_id);

Choose a reason for hiding this comment

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

Have you considered adding events on _wallet_of_owner and _token_type write?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think its necessary

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as transfer/mint event take care of _wallet_of_owner update and don't think it is necessary to index _token_type

@@ -0,0 +1,97 @@
use array::{Array, ArrayTrait, SpanTrait};

Choose a reason for hiding this comment

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

Test a case when a contribution_levels arr = [100] and a user collected 100 dev points. The tier should be 1 in this situation. I guess it returns 0 right now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

100 dev points return tier 1 only.

assert (tier1 == 1, 'invalid tier1');

let tier2 = guildSBT_dispatcher.get_contribution_tier(user2());
assert (tier2 == 2, 'invalid tier2');

Choose a reason for hiding this comment

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

I'd suggest testing all four tiers for all guilds (since the logic for each of them is not in the same place like in a general function)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

have generalised the function

@FelixGibson
Copy link

The code is pretty good. Two little suggestions.

  1. the target dir is a compiled target, is it necessary to be part of the code?
  2. The file name is better to be lower case. It's not a big deal but many cairo code follow this code style.

fn get_problem_solving_points(self: @ContractState, contributor: ContractAddress) -> u32 {
let contribution = self._contributions.read(contributor);
contribution.problem_solving
fn get_guild_total_contribution(self: @ContractState, month_id: u32, guild: felt252) -> u32 {

Choose a reason for hiding this comment

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

Question - how detailed should tests be? If very then we might want to test get_guild_total_contribution and get_guild_points functions for every guild in a specific test.

let mut contribution_data = self._contributions_data.read((contributor, guild));
contribution_data.append(month_id);
contribution_data.append(new_guild_score);
contribution_data.append(new_contribution_score);

Choose a reason for hiding this comment

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

Could you create a test for this case? We missed it

@@ -390,7 +405,7 @@ mod Master {
if(new_contribution_score != 0) {
let mut contribution_data = self._contributions_data.read((contributor, guild));
contribution_data.append(month_id);

Choose a reason for hiding this comment

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

Indents are not needed. Should be inline with let mut contribution_data

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.

update to new pattern in cairo 2.0

3 participants