-
Notifications
You must be signed in to change notification settings - Fork 2
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
scaffold template and implement ERC20JDI contract #1
base: main
Are you sure you want to change the base?
Conversation
@princearoragithub @0xChicken1 Do you have time to review this? |
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.
Overall, looks pretty good. Some comments on syntax and javadocs
Had a question for @princearoragithub, it seems like we want to use camel case for all ERC20 interfaces, but snake case for all other functions?
_start_epoch_time::write( | ||
(get_block_timestamp().into() + INFLATION_DELAY - RATE_REDUCTION_TIME).into() | ||
); | ||
_mining_epoch::write(u256_from_felt252(0)); // different from curve |
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.
Why set it differently from Curve? Curve is -1 right?
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.
yes, since cairo1 currently does not support signed integer yet. I think we can start from 0.
} | ||
|
||
#[view] | ||
fn total_supply() -> u256 { |
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.
For consistency with Jediswap ERC20 interface, we can use camel case
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.
actually I think we should use snake case in order to follow the standard.
There's a dissussion about this in starknet forum: https://community.starknet.io/t/the-great-interface-migration/92107
} | ||
|
||
#[view] | ||
fn balance_of(account: ContractAddress) -> u256 { |
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.
Camelcase here too
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.
same as above
} | ||
|
||
#[external] | ||
fn transfer_from(sender: ContractAddress, recipient: ContractAddress, amount: u256) -> bool { |
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.
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.
same as above
} | ||
|
||
#[external] | ||
fn increase_allowance(spender: ContractAddress, added_value: u256) -> bool { |
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.
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.
same as above
} | ||
|
||
#[external] | ||
fn decrease_allowance(spender: ContractAddress, subtracted_value: u256) -> bool { |
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.
|
||
struct Storage { | ||
// Special address | ||
_minter: ContractAddress, |
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.
Could you add javadocs for each of the variables in the struct?
Similar to here: https://github.com/jediswaplabs/JediSwap/blob/31-upgrade-to-cairo-10/src/PairC1.cairo#L53-L64
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.
Thanks for review. I've added.
const INFLATION_DELAY: felt252 = 86400; // one day | ||
|
||
#[event] | ||
fn UpdateMiningParameters(time: u64, rate: u256, supply: u256) {} |
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.
Add javadocs to events similar to here: https://github.com/jediswaplabs/JediSwap/blob/31-upgrade-to-cairo-10/src/PairC1.cairo#L66-L68
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.
thanks. I've added this.
_start_epoch_supply::write(initial_supply); | ||
} | ||
|
||
#[view] |
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.
Could you add javadocs to all the functions that don't have it to keep consistent with Jediswap's other repos?
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.
Thanks for review. I've added.
src/erc20_jedi.cairo
Outdated
cur_epoch_time += RATE_REDUCTION_TIME.into(); | ||
}; | ||
return to_mint; | ||
|
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.
Nit: extra 2 lines
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.
Thanks for review. I've fixed it.
No description provided.