-
Notifications
You must be signed in to change notification settings - Fork 0
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
update to new pattern in cairo2 #5
base: main
Are you sure you want to change the base?
Changes from 1 commit
bbe6302
6b50345
d0e4dc7
0f59c82
86abc61
835a4b6
0d2b67c
3fc84ea
4e0334b
6c2317c
fb37fa8
372707f
2ca72e1
dd12ede
dcba23c
d0a3a09
7ff8515
7e81d60
513f948
c8e534b
dddf050
e84717c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,11 +73,7 @@ trait IGuild<T> { | |
trait IMaster<TContractState> { | ||
// view functions | ||
fn get_contributions_points(self: @TContractState, contributor: ContractAddress) -> Contribution; | ||
fn get_dev_points(self: @TContractState, contributor: ContractAddress) -> u32; | ||
fn get_design_points(self: @TContractState, contributor: ContractAddress) -> u32; | ||
fn get_problem_solving_points(self: @TContractState, contributor: ContractAddress) -> u32; | ||
fn get_marcom_points(self: @TContractState, contributor: ContractAddress) -> u32; | ||
fn get_research_points(self: @TContractState, contributor: ContractAddress) -> u32; | ||
fn get_guild_points(self: @TContractState, contributor: ContractAddress, guild: felt252) -> u32; | ||
fn get_last_update_id(self: @TContractState) -> u32; | ||
fn get_last_update_time(self: @TContractState) -> u64; | ||
fn get_migartion_queued_state(self: @TContractState, hash: felt252 ) -> bool; | ||
|
@@ -88,6 +84,8 @@ trait IMaster<TContractState> { | |
fn get_research_guild_SBT(self: @TContractState) -> ContractAddress; | ||
fn get_total_contribution(self: @TContractState, month_id: u32) -> TotalMonthlyContribution; | ||
fn get_contributions_data(self: @TContractState, contributor: ContractAddress, guild: felt252) -> Array<u32>; | ||
fn get_guild_total_contribution(self: @TContractState, month_id: u32, guild: felt252) -> u32; | ||
|
||
|
||
// external functions | ||
fn update_contibutions(ref self: TContractState, month_id: u32, contributions: Array::<MonthlyContribution>); | ||
|
@@ -204,33 +202,50 @@ mod Master { | |
self._total_contribution.read(month_id) | ||
} | ||
|
||
fn get_contributions_data(self: @ContractState, contributor: ContractAddress, guild: felt252) -> Array<u32> { | ||
self._contributions_data.read((contributor, guild)) | ||
} | ||
|
||
fn get_dev_points(self: @ContractState, contributor: ContractAddress) -> u32 { | ||
let contribution: Contribution = self._contributions.read(contributor); | ||
contribution.dev | ||
} | ||
|
||
fn get_design_points(self: @ContractState, contributor: ContractAddress) -> u32 { | ||
let contribution = self._contributions.read(contributor); | ||
contribution.design | ||
} | ||
|
||
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
if(guild == 'dev') { | ||
self._total_contribution.read(month_id).dev | ||
} | ||
else if(guild == 'design') { | ||
self._total_contribution.read(month_id).design | ||
} | ||
else if(guild == 'problem_solving') { | ||
self._total_contribution.read(month_id).problem_solving | ||
} | ||
else if(guild == 'marcom') { | ||
self._total_contribution.read(month_id).marcom | ||
} | ||
else if(guild == 'research') { | ||
self._total_contribution.read(month_id).research | ||
} | ||
else { | ||
0 | ||
} | ||
} | ||
|
||
fn get_marcom_points(self: @ContractState, contributor: ContractAddress) -> u32 { | ||
let contribution = self._contributions.read(contributor); | ||
contribution.marcom | ||
fn get_contributions_data(self: @ContractState, contributor: ContractAddress, guild: felt252) -> Array<u32> { | ||
self._contributions_data.read((contributor, guild)) | ||
} | ||
|
||
fn get_research_points(self: @ContractState, contributor: ContractAddress) -> u32 { | ||
let contribution = self._contributions.read(contributor); | ||
contribution.research | ||
fn get_guild_points(self: @ContractState, contributor: ContractAddress, guild: felt252) -> u32 { | ||
if(guild == 'dev') { | ||
self._contributions.read(contributor).dev | ||
} | ||
else if(guild == 'design') { | ||
self._contributions.read(contributor).design | ||
} | ||
else if(guild == 'problem_solving') { | ||
self._contributions.read(contributor).problem_solving | ||
} | ||
else if(guild == 'marcom') { | ||
self._contributions.read(contributor).marcom | ||
} | ||
else if(guild == 'research') { | ||
self._contributions.read(contributor).research | ||
} | ||
else { | ||
0 | ||
} | ||
} | ||
|
||
fn get_last_update_id(self: @ContractState) -> u32 { | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indents are not needed. Should be inline with |
||
contribution_data.append(new_guild_score); | ||
contribution_data.append(new_contribution_score); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you create a test for this case? We missed it |
||
|
||
self._contributions_data.write((contributor, guild), contribution_data); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ mod master; | |
mod access; | ||
mod storage; | ||
mod guildSBT; | ||
mod array; | ||
mod array; | ||
mod salary; |
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.
Since it's only for a dev guild contract what do you think about changing the name also? Like DevGuildSBT
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.
Its just a temporary name