-
Notifications
You must be signed in to change notification settings - Fork 328
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 directory structure #350
Merged
martriay
merged 30 commits into
OpenZeppelin:main
from
andrew-fleming:refactor-structure
Jul 23, 2022
Merged
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
6294925
add lib and preset dirs
andrew-fleming d154923
remove underscore from names, finish init reorganization
andrew-fleming 850030a
fix mock names, adjusted paths
andrew-fleming 751ea89
update branch Merge branch 'main' of https://github.com/andrew-flemin…
andrew-fleming eec911c
update paths in tests
andrew-fleming ad2b4ab
update attribution
andrew-fleming 208a673
Rename safemath.cairo to SafeMath.cairo
andrew-fleming 05b78a3
Rename initializable.cairo to Initializable.cairo
andrew-fleming ea9966f
Rename pausable.cairo to Pausable.cairo
andrew-fleming 9588959
update version in attribution
andrew-fleming 845ac1b
update branch Merge branch 'main' of https://github.com/andrew-flemin…
andrew-fleming 3396b07
update branch Merge branch 'main' of https://github.com/andrew-flemin…
andrew-fleming 1a6a6a5
update branch, fix paths
andrew-fleming a88af6a
add conventions to CONTRIBUTING.md
andrew-fleming 3de6caa
update names and paths in docs
andrew-fleming 87dc199
fix paths in code snippets
andrew-fleming b0d59f8
rename libs to lib
andrew-fleming 2d03060
Apply suggestions from code review
andrew-fleming 66fc6c4
Update CONTRIBUTING.md
andrew-fleming cc573e5
update link paths
andrew-fleming 58fb80d
update structure
andrew-fleming 0128e7e
fix compilation msg and import snippet
andrew-fleming d849fde
update branch
andrew-fleming cc9ccfb
Apply suggestions from code review
andrew-fleming a551c45
fix paths, move ERC721Holder
andrew-fleming 7686794
remove upgrades dir
andrew-fleming 8a22da1
fix pin
andrew-fleming 1984e9d
update branch
andrew-fleming 5cd09ad
update paths for proxy
andrew-fleming 678093f
update links and code block imports
andrew-fleming 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
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 |
---|---|---|
|
@@ -10,9 +10,9 @@ The ERC20 token standard is a specification for [fungible tokens](https://docs.o | |
- [Extensibility](#extensibility) | ||
- [Presets](#presets) | ||
- [ERC20 (basic)](#erc20-basic) | ||
- [ERC20_Mintable](#erc20_mintable) | ||
- [ERC20_Pausable](#erc20_pausable) | ||
- [ERC20_Upgradeable](#erc20_upgradeable) | ||
- [ERC20Mintable](#erc20mintable) | ||
- [ERC20Pausable](#erc20pausable) | ||
- [ERC20Upgradeable](#erc20upgradeable) | ||
Comment on lines
+13
to
+15
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. what a lovely race condition with #396 |
||
- [API Specification](#api-specification) | ||
- [Methods](#methods) | ||
- [`name`](#name) | ||
|
@@ -100,7 +100,7 @@ To create a token you need to deploy it like this: | |
|
||
```python | ||
erc20 = await starknet.deploy( | ||
"contracts/token/ERC20.cairo", | ||
"openzeppelin/token/erc20/presets/ERC20.cairo", | ||
constructor_calldata=[ | ||
str_to_felt("Token"), # name | ||
str_to_felt("TKN"), # symbol | ||
|
@@ -127,7 +127,7 @@ await signer.send_transaction(account, erc20.contract_address, 'transfer', [reci | |
|
||
## Extensibility | ||
|
||
ERC20 contracts can be extended by following the [extensibility pattern](../docs/Extensibility.md#the-pattern). The basic idea behind integrating the pattern is to import the requisite ERC20 methods from the ERC20 library and incorporate the extended logic thereafter. For example, let's say you wanted to implement a pausing mechanism. The contract should first import the ERC20 methods and the extended logic from the [pausable library](../src/openzeppelin/security/pausable.cairo) i.e. `Pausable_pause`, `Pausable_unpause`. Next, the contract should expose the methods with the extended logic therein like this: | ||
ERC20 contracts can be extended by following the [extensibility pattern](../docs/Extensibility.md#the-pattern). The basic idea behind integrating the pattern is to import the requisite ERC20 methods from the ERC20 library and incorporate the extended logic thereafter. For example, let's say you wanted to implement a pausing mechanism. The contract should first import the ERC20 methods and the extended logic from the [pausable library](../src/openzeppelin/security/pausable/library.cairo) i.e. `Pausable_pause`, `Pausable_unpause`. Next, the contract should expose the methods with the extended logic therein like this: | ||
|
||
```python | ||
@external | ||
|
@@ -136,8 +136,8 @@ func transfer{ | |
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}(recipient: felt, amount: Uint256) -> (success: felt): | ||
Pausable_when_not_paused() # imported extended logic | ||
ERC20_transfer(recipient, amount) # imported library method | ||
Pausable.when_not_paused() # imported extended logic | ||
ERC20.transfer(recipient, amount) # imported library method | ||
return (TRUE) | ||
end | ||
``` | ||
|
@@ -158,19 +158,19 @@ The following contract presets are ready to deploy and can be used as-is for qui | |
|
||
### ERC20 (basic) | ||
|
||
The [`ERC20`](../src/openzeppelin/token/erc20/ERC20.cairo) preset offers a quick and easy setup for deploying a basic ERC20 token. | ||
The [`ERC20`](../src/openzeppelin/token/erc20/presets/ERC20.cairo) preset offers a quick and easy setup for deploying a basic ERC20 token. | ||
|
||
### ERC20_Mintable | ||
### ERC20Mintable | ||
|
||
The [`ERC20_Mintable`](../src/openzeppelin/token/erc20/ERC20_Mintable.cairo) preset allows the contract owner to mint new tokens. | ||
The [`ERC20Mintable`](../src/openzeppelin/token/erc20/presets/ERC20Mintable.cairo) preset allows the contract owner to mint new tokens. | ||
|
||
### ERC20_Pausable | ||
### ERC20Pausable | ||
|
||
The [`ERC20_Pausable`](../src/openzeppelin/token/erc20/ERC20_Pausable.cairo) preset allows the contract owner to pause/unpause all state-modifying methods i.e. `transfer`, `approve`, etc. This preset proves useful for scenarios such as preventing trades until the end of an evaluation period and having an emergency switch for freezing all token transfers in the event of a large bug. | ||
The [`ERC20Pausable`](../src/openzeppelin/token/erc20/presets/ERC20Pausable.cairo) preset allows the contract owner to pause/unpause all state-modifying methods i.e. `transfer`, `approve`, etc. This preset proves useful for scenarios such as preventing trades until the end of an evaluation period and having an emergency switch for freezing all token transfers in the event of a large bug. | ||
|
||
### ERC20_Upgradeable | ||
### ERC20Upgradeable | ||
|
||
The [`ERC20_Upgradeable`](../src/openzeppelin/token/erc20/ERC20_Upgradeable.cairo) preset allows the contract owner to upgrade a contract by deploying a new ERC20 implementation contract while also maintaing the contract's state. This preset proves useful for scenarios such as eliminating bugs and adding new features. For more on upgradeability, see [Contract upgrades](Proxies.md#contract-upgrades). | ||
The [`ERC20Upgradeable`](../src/openzeppelin/token/erc20/presets/ERC20Upgradeable.cairo) preset allows the contract owner to upgrade a contract by deploying a new ERC20 implementation contract while also maintaing the contract's state. This preset proves useful for scenarios such as eliminating bugs and adding new features. For more on upgradeability, see [Contract upgrades](Proxies.md#contract-upgrades). | ||
|
||
## API Specification | ||
|
||
|
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.
why python?
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.
The linter expects a language with the code block. Python is an arbitrary solution since this is just a visual aid