-
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
Open
yashm001
wants to merge
22
commits into
main
Choose a base branch
from
4-update-to-new-pattern-in-cairo-20
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
bbe6302
initial commit
yashm001 6b50345
Update Master.cairo
yashm001 d0e4dc7
Update Master.cairo
yashm001 0f59c82
fixes some bugs
yashm001 86abc61
Update lib.cairo
yashm001 835a4b6
added guildSBT
yashm001 0d2b67c
updated array storage
yashm001 3fc84ea
replace " with ' in error message
yashm001 4e0334b
added erc721 impl
yashm001 6c2317c
Update GuildSBT.cairo
yashm001 fb37fa8
updated master design
yashm001 372707f
added tests
yashm001 2ca72e1
Update GuildSBT.cairo
yashm001 dd12ede
Update Master_approach1.cairo
yashm001 dcba23c
making sbt non transferable
yashm001 d0a3a09
resolves fixes
yashm001 7ff8515
review changes
yashm001 7e81d60
Delete target directory
yashm001 513f948
generalised get points functions
yashm001 c8e534b
added more getter function
yashm001 dddf050
added attribution contract
yashm001 e84717c
added test for attribution contract
yashm001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,8 @@ | |
// @notice SBT contract to give out to contributor | ||
|
||
use starknet::ContractAddress; | ||
use array::{Array, ArrayTrait, SpanTrait}; | ||
use serde::Serde; | ||
use traits::{Into, TryInto}; | ||
use array::Array; | ||
|
||
|
||
#[starknet::interface] | ||
trait IMaster<T> { | ||
|
@@ -22,6 +21,7 @@ trait IGuildSBT<TContractState> { | |
fn tokenURI(self: @TContractState, token_id: u256) -> Span<felt252>; | ||
fn tokenURI_from_contributor(self: @TContractState, contributor: ContractAddress) -> Span<felt252>; | ||
fn get_master(self: @TContractState) -> ContractAddress; | ||
fn get_next_token_id(self: @TContractState) -> u256; | ||
fn get_contribution_tier(self: @TContractState, contributor: ContractAddress) -> u32; | ||
fn get_contribution_levels(self: @TContractState) -> Array<u32>; | ||
fn get_number_of_levels(self: @TContractState) -> u32; | ||
|
@@ -143,6 +143,10 @@ mod GuildSBT { | |
self._master.read() | ||
} | ||
|
||
fn get_next_token_id(self: @ContractState) -> u256 { | ||
self._next_token_id.read() | ||
} | ||
|
||
|
||
fn get_contribution_tier(self: @ContractState, contributor: ContractAddress) -> u32 { | ||
let master = self._master.read(); | ||
|
@@ -195,13 +199,13 @@ mod GuildSBT { | |
let balance = erc721_self.balance_of(:account); | ||
assert (balance == 0, 'ALREADY_MINTED'); | ||
|
||
self._token_type.write(account, token_type); | ||
let master = self._master.read(); | ||
let masterDispatcher = IMasterDispatcher { contract_address: master }; | ||
let points = masterDispatcher.get_dev_points(account); | ||
let tier = InternalImpl::_get_contribution_tier(@self, points); | ||
|
||
assert (tier != 0, 'NOT_ENOUGH_POINTS'); | ||
self._token_type.write(account, token_type); | ||
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); | ||
|
@@ -232,10 +236,6 @@ mod GuildSBT { | |
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
#[generate_trait] | ||
|
@@ -249,12 +249,12 @@ mod GuildSBT { | |
let mut current_index = 0_u32; | ||
let contribution_levels = self._contribution_levels.read(); | ||
loop { | ||
if (current_index == contribution_levels.len() - 1) { | ||
break true; | ||
if (current_index == contribution_levels.len()) { | ||
break; | ||
} | ||
|
||
if (points < *contribution_levels[current_index]) { | ||
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. shouldn't it be 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. its correct as per the logic |
||
break true; | ||
break; | ||
} | ||
|
||
current_index += 1; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod test_deployment; | ||
mod test_migrate_points; | ||
mod test_mint; | ||
mod test_update_contribution_points; | ||
mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Have you considered adding events on
_wallet_of_owner
and_token_type
write?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.
I don't think its necessary
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.
as transfer/mint event take care of
_wallet_of_owner
update and don't think it is necessary to index_token_type