-
Notifications
You must be signed in to change notification settings - Fork 358
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
Add ERC20Burnable preset #252
Add ERC20Burnable preset #252
Conversation
ddf927e
to
80a904c
Compare
@andrew-fleming makes sense. i ended up doing a fresh refactor based on the current state of main |
@koloz193 ahh yeah, the rebasing conflicts must have looked like a nightmare |
yup, once i saw like 10 different files i quickly decided against trying to attempt the rebase |
@koloz193 Ownable is merged! I appreciate your patience, sir 🙏 at your leisure, would you mind updating your branch? |
awesome! will merge in main and clean it up! |
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.
This looks great, sir! Thanks again for doing this :) I left a couple of comments
@view | ||
func owner{ | ||
syscall_ptr: felt*, | ||
pedersen_ptr: HashBuiltin*, | ||
range_check_ptr |
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 think we should move this up and keep it grouped with the Getters
and maybe add an Externals
comment to demarcate the @external
methods for consistency
new_balance = sub_uint(INIT_SUPPLY, AMOUNT) | ||
|
||
execution_info = await erc20.balanceOf(account1.contract_address).invoke() | ||
assert execution_info.result.balance == new_balance |
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.
We should check that account2
's allowance is correctly subtracted here. Just to be thorough, I think we should include additional tests for:
burnFrom
emitsTransfer
eventburnFrom
reverts when burn amount exceeds balanceburnFrom
reverts whenaccount
is the zero address (I believespender
as the zero address is indirectly covered with "insufficient allowance")
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.
good call, ill add these tests in
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.
Thank you, sir! I'm re-reviewing the enumerable PR as well, so hopefully we can get your contributions in soon!
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.
@andrew-fleming added testing for the event. looks like burnFrom
reverts when burn amount exceeds balance is covered by the following test and having account as the zero address results in an underflow error since the zero address cant give any approval
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.
Ah my mistake. Thank you for adding in the event test!
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.
@koloz193 This looks excellent and good to go for me! Thank you so much :)
@andrew-fleming @martriay any update on this 😄 |
This is currently on our project roadmap, just that it's prioritized as "Low". This means we will tackle it whenever we finish higher priority issues, or we reprioritize based on new information. Sorry it's taking so long 🙇. |
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.
): | ||
ERC20.initializer(name, symbol, decimals) | ||
ERC20._mint(recipient, initial_supply) | ||
Ownable.initializer(owner) |
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 is it ownable?
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.
good call, removing ownable
@external | ||
func transferOwnership{ | ||
syscall_ptr: felt*, | ||
pedersen_ptr: HashBuiltin*, | ||
range_check_ptr | ||
}(newOwner: felt): | ||
Ownable.transfer_ownership(newOwner) | ||
return () | ||
end | ||
|
||
@external | ||
func renounceOwnership{ | ||
syscall_ptr: felt*, | ||
pedersen_ptr: HashBuiltin*, | ||
range_check_ptr | ||
}(): | ||
Ownable.renounce_ownership() |
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'm not sure I get why are these needed
assert_event_emitted( | ||
tx_exec_info, | ||
from_address=erc20.contract_address, | ||
name='Transfer', | ||
data=[ | ||
account1.contract_address, | ||
ZERO_ADDRESS, | ||
*AMOUNT | ||
] | ||
) |
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.
what do you think about splitting this into two different tests? that'd be consistent with burn
whose storage effects and emitted events are tested separately
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.
yea easy enough
Hey @koloz193! Do you think you will be able to finish this one off or should we pick it up? Thanks :) |
@martriay yup I'll wrap it up this weekend! |
@koloz193 kind ping (: |
@martriay just pushed the changes, sorry for the delay but ran the tests and it looks good |
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.
Looking good! Requested small changes, plus resolving merge conflicts I think we're good! Thanks again :)
@@ -1,11 +1,12 @@ | |||
# SPDX-License-Identifier: MIT | |||
# OpenZeppelin Cairo Contracts v0.2.1 (token/erc20/presets/ERC20Burnable.cairo) |
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.
# OpenZeppelin Cairo Contracts v0.2.1 (token/erc20/presets/ERC20Burnable.cairo) | |
# OpenZeppelin Cairo Contracts v0.3.1 (token/erc20/presets/ERC20Burnable.cairo) |
I think we need to update this
@@ -19,7 +20,8 @@ func constructor{ | |||
symbol: felt, | |||
decimals: felt, | |||
initial_supply: Uint256, | |||
recipient: felt | |||
recipient: felt, | |||
owner: felt |
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.
owner: felt |
there's no owner anymore
@@ -42,29 +46,32 @@ async def erc20_init(contract_classes): | |||
DECIMALS, | |||
*INIT_SUPPLY, | |||
account1.contract_address, # recipient | |||
account1.contract_address, # owner |
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.
account1.contract_address, # owner |
Amazing! Now there's only the merge conflicts left. |
not anymore 😄 |
Created an erc20 burnable preset from the mocked file and removed the mock since it's no longer needed.
Fixes #237
Depends on: