-
Notifications
You must be signed in to change notification settings - Fork 72
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
refactor: N-02 Code Clarity Suggestions #588
Changes from 8 commits
52e7dd4
710d79d
7087210
8fc30db
b0fc678
8b3b361
5039ded
83d8248
35d439b
1b5ccea
4a01e00
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
use starknet::{ContractAddress, contract_address_const}; | ||
use starknet::ContractAddress; | ||
|
||
// Ideally, ContractAddress would impl Default in the corelib. | ||
impl ContractAddressDefault of Default<ContractAddress> { | ||
fn default() -> ContractAddress { | ||
contract_address_const::<0>() | ||
Zeroable::zero() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,15 +32,12 @@ mod MerkleWhitelistVotingStrategy { | |
params: Span<felt252>, // [root: felt252] | ||
user_params: Span<felt252>, // [leaf: Leaf, proof: Array<felt252>] | ||
) -> u256 { | ||
let cache = user_params; // cache | ||
let mut params = params; | ||
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. you can add 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. oh nice, updated. think there some other situations where we can do this. will have a look |
||
let mut user_params = user_params; | ||
|
||
let mut leaf_raw = cache.slice(0, LEAF_SIZE); | ||
let leaf = Serde::<Leaf>::deserialize(ref leaf_raw).unwrap(); | ||
|
||
let mut proofs_raw = cache.slice(LEAF_SIZE, cache.len() - LEAF_SIZE); | ||
let proofs = Serde::<Array<felt252>>::deserialize(ref proofs_raw).unwrap(); | ||
|
||
let root = *params.at(0); // no need to deserialize because it's a simple value | ||
let root = Serde::<felt252>::deserialize(ref params).unwrap(); | ||
let (leaf, proofs) = Serde::<(Leaf, Array<felt252>)>::deserialize(ref user_params) | ||
.unwrap(); | ||
|
||
assert(leaf.address == voter, 'Leaf and voter mismatch'); | ||
merkle::assert_valid_proof(root, leaf, proofs.span()); | ||
|
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 did this, what do you think 73a9269 ?
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.
yeah thanks, that makes a lot of sense.