Skip to content
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

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

FelixGibson
Copy link

No description provided.

@FelixGibson
Copy link
Author

@princearoragithub @0xChicken1 Do you have time to review this?

Copy link

@0xChicken1 0xChicken1 left a 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

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?

Copy link
Author

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 {

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

https://github.com/jediswaplabs/JediSwap/blob/31-upgrade-to-cairo-10/src/PairC1.cairo#L129-L132

Copy link
Author

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 {

Choose a reason for hiding this comment

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

Camelcase here too

Copy link
Author

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 {

Choose a reason for hiding this comment

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

Copy link
Author

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 {

Choose a reason for hiding this comment

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

Copy link
Author

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 {

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,

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

Copy link
Author

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) {}

Choose a reason for hiding this comment

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

Copy link
Author

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]

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?

Copy link
Author

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.

cur_epoch_time += RATE_REDUCTION_TIME.into();
};
return to_mint;

Choose a reason for hiding this comment

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

Nit: extra 2 lines

Copy link
Author

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.

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.

2 participants