-
Notifications
You must be signed in to change notification settings - Fork 73
feat: add ERC-6909 Token and Supply extension #777
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
Open
onurinanc
wants to merge
58
commits into
OpenZeppelin:main
Choose a base branch
from
onurinanc:feature/ERC6909
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
8051a84
add initial files
onurinanc a6a3be9
implement erc6909 add one mint test
onurinanc d0ee57e
complete erc6909 unit tests
onurinanc 58c07e5
finish supply extension and related motsu tests
onurinanc 4140384
remove redundant
onurinanc 5b45733
add Erc6909Example and Erc6909TokenSupplyExample
onurinanc b56e569
fmt
onurinanc 513781c
add abi for erc6909 and erc6909-supply example and a mint test
onurinanc 6463d84
fix mint test and add mints_invalid_receiver
onurinanc de57e8d
typo name
onurinanc e6761f5
complete erc6909 integration tests
onurinanc 058c82d
add erc6909-supply integrations tests
onurinanc d859809
add comment & fmt all
onurinanc 6781c92
fix errors
onurinanc dfe4e7f
fix
onurinanc de65d99
fix tests
onurinanc c0f55d5
fix test
onurinanc e395d59
fix erc6909-supply tests
onurinanc d354361
fix
onurinanc 4c7fdb2
fix test
onurinanc 23b6d83
add bench for erc6909
onurinanc 976569b
add bench for erc6909 token supply
onurinanc fdadc2a
update cargo for CI
onurinanc e09cc02
Merge branch 'main' into feature/ERC6909
bidzyyys e05e7d0
apply requested changes
onurinanc a2e3fcd
merge changelog
onurinanc 25220f1
fmt
onurinanc 0b6266f
change FixedBytes<4> to B32
onurinanc d80ea4a
fix ancora
onurinanc 2bd8e3a
add a test case covering ERC6909InvalidReceiver
onurinanc 7f5926c
fix CHANGELOG
onurinanc 13bbd20
update ERC-6909 ancora
onurinanc a509961
fmt
onurinanc 1faf35e
remove unnecessary files
onurinanc 2801d86
fix erc6909 ancora
onurinanc d2c0d06
Merge branch 'main' into feature/ERC6909
bidzyyys 6f2df5c
Merge branch 'main' into feature/ERC6909
bidzyyys c60c89d
Merge branch 'main' into feature/ERC6909
bidzyyys ea7ae4a
Merge branch 'main' into feature/ERC6909
bidzyyys a2d792f
fix clippy lints
qalisander 831732b
remove unused imports
qalisander a4fb409
fix clippy lints
qalisander 7dc0876
Merge remote-tracking branch 'origin/main' into feature/ERC6909
qalisander 33a8a94
update documentation link
qalisander a1f3486
exclude method error from codecov
qalisander e57db14
update docs of token_supply
qalisander 8e3b527
add llm mcp generated unit tests
qalisander 335102a
fix mints_rejects_overflow test
qalisander 813831b
Merge remote-tracking branch 'origin/main' into feature/ERC6909
qalisander 04440c5
revert Cargo.lock
qalisander 9c7ebe6
ref: apply suggestions from code review
bidzyyys 01b7f68
update erc6909 docs
qalisander 8713f1a
use 0.3.0 version for ERC6909 docs
qalisander 9dd9798
update erc6909.adoc example
qalisander d6bfec3
update styling and docs
qalisander 48933ef
add panic check for _update function and related panic docs
qalisander 48c23f9
add link to ERC-6909 standard
qalisander ea1619e
remove unused import
qalisander 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| use alloy::{ | ||
| network::{AnyNetwork, EthereumWallet}, | ||
| primitives::Address, | ||
| providers::ProviderBuilder, | ||
| sol, | ||
| sol_types::SolCall, | ||
| uint, | ||
| }; | ||
| use e2e::{receipt, Account}; | ||
|
|
||
| use crate::{ | ||
| report::{ContractReport, FunctionReport}, | ||
| Opt, | ||
| }; | ||
|
|
||
| sol!( | ||
| #[sol(rpc)] | ||
| contract Erc6909 { | ||
| function balanceOf(address owner, uint256 id) external view returns (uint256 balance); | ||
| function allowance(address owner, address spender, uint256 id) external view returns (uint256 allowance); | ||
| function isOperator(address owner, address spender) external view returns (bool approved); | ||
| function approve(address spender, uint256 id, uint256 amount) external returns (bool); | ||
| function setOperator(address spender, bool approved) external returns (bool); | ||
| function transfer(address receiver, uint256 id, uint256 amount) external returns (bool); | ||
| function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool); | ||
| function mint(address to, uint256 id, uint256 amount) external; | ||
| function burn(address from, uint256 id, uint256 amount) external; | ||
| } | ||
| ); | ||
|
|
||
| pub async fn bench() -> eyre::Result<ContractReport> { | ||
| ContractReport::generate("Erc6909", run).await | ||
| } | ||
|
|
||
| pub async fn run(cache_opt: Opt) -> eyre::Result<Vec<FunctionReport>> { | ||
| let alice = Account::new().await?; | ||
| let alice_addr = alice.address(); | ||
| let alice_wallet = ProviderBuilder::new() | ||
| .network::<AnyNetwork>() | ||
| .with_recommended_fillers() | ||
| .wallet(EthereumWallet::from(alice.signer.clone())) | ||
| .on_http(alice.url().parse()?); | ||
|
|
||
| let bob = Account::new().await?; | ||
| let bob_addr = bob.address(); | ||
| let bob_wallet = ProviderBuilder::new() | ||
| .network::<AnyNetwork>() | ||
| .with_recommended_fillers() | ||
| .wallet(EthereumWallet::from(bob.signer.clone())) | ||
| .on_http(bob.url().parse()?); | ||
|
|
||
| let contract_addr = deploy(&alice, cache_opt).await?; | ||
|
|
||
| let contract = Erc6909::new(contract_addr, &alice_wallet); | ||
| let contract_bob = Erc6909::new(contract_addr, &bob_wallet); | ||
|
|
||
| let token_id = uint!(1_U256); | ||
| let amount = uint!(100_U256); | ||
| let one = uint!(1_U256); | ||
|
|
||
| // IMPORTANT: Order matters! | ||
| use Erc6909::*; | ||
| #[rustfmt::skip] | ||
| let receipts = vec![ | ||
| (mintCall::SIGNATURE, receipt!(contract.mint(alice_addr, token_id, amount))?), | ||
| (balanceOfCall::SIGNATURE, receipt!(contract.balanceOf(alice_addr, token_id))?), | ||
| (allowanceCall::SIGNATURE, receipt!(contract.allowance(alice_addr, bob_addr, token_id))?), | ||
| (isOperatorCall::SIGNATURE, receipt!(contract.isOperator(alice_addr, bob_addr))?), | ||
| (setOperatorCall::SIGNATURE, receipt!(contract.setOperator(bob_addr, true))?), | ||
| (transferCall::SIGNATURE, receipt!(contract.transfer(bob_addr, token_id, one))?), | ||
| (approveCall::SIGNATURE, receipt!(contract.approve(bob_addr, token_id, one))?), | ||
| (transferFromCall::SIGNATURE, receipt!(contract_bob.transferFrom(alice_addr, bob_addr, token_id, one))?), | ||
| (burnCall::SIGNATURE, receipt!(contract.burn(alice_addr, token_id, one))?), | ||
| ]; | ||
|
|
||
| receipts | ||
| .into_iter() | ||
| .map(FunctionReport::new) | ||
| .collect::<eyre::Result<Vec<_>>>() | ||
| } | ||
|
|
||
| async fn deploy(account: &Account, cache_opt: Opt) -> eyre::Result<Address> { | ||
| crate::deploy(account, "erc6909", None, cache_opt).await | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| use alloy::{ | ||
| network::{AnyNetwork, EthereumWallet}, | ||
| primitives::Address, | ||
| providers::ProviderBuilder, | ||
| sol, | ||
| sol_types::SolCall, | ||
| uint, | ||
| }; | ||
| use e2e::{receipt, Account}; | ||
|
|
||
| use crate::{ | ||
| report::{ContractReport, FunctionReport}, | ||
| Opt, | ||
| }; | ||
|
|
||
| sol!( | ||
| #[sol(rpc)] | ||
| contract Erc6909TokenSupply { | ||
| function totalSupply(uint256 id) external view returns (uint256 totalSupply); | ||
| function mint(address to, uint256 id, uint256 amount) external; | ||
| function burn(address from, uint256 id, uint256 amount) external; | ||
| } | ||
| ); | ||
|
|
||
| pub async fn bench() -> eyre::Result<ContractReport> { | ||
| ContractReport::generate("Erc6909TokenSupply", run).await | ||
| } | ||
|
|
||
| pub async fn run(cache_opt: Opt) -> eyre::Result<Vec<FunctionReport>> { | ||
| let alice = Account::new().await?; | ||
| let alice_addr = alice.address(); | ||
| let alice_wallet = ProviderBuilder::new() | ||
| .network::<AnyNetwork>() | ||
| .with_recommended_fillers() | ||
| .wallet(EthereumWallet::from(alice.signer.clone())) | ||
| .on_http(alice.url().parse()?); | ||
|
|
||
| let contract_addr = deploy(&alice, cache_opt).await?; | ||
|
|
||
| let contract = Erc6909TokenSupply::new(contract_addr, &alice_wallet); | ||
|
|
||
| let token_id = uint!(1_U256); | ||
| let amount = uint!(100_U256); | ||
|
|
||
| // IMPORTANT: Order matters! | ||
| use Erc6909TokenSupply::*; | ||
| #[rustfmt::skip] | ||
| let receipts = vec![ | ||
| (mintCall::SIGNATURE, receipt!(contract.mint(alice_addr, token_id, amount))?), | ||
| (totalSupplyCall::SIGNATURE, receipt!(contract.totalSupply(token_id))?), | ||
| (burnCall::SIGNATURE, receipt!(contract.burn(alice_addr, token_id, amount))?), | ||
| ]; | ||
|
|
||
| receipts | ||
| .into_iter() | ||
| .map(FunctionReport::new) | ||
| .collect::<eyre::Result<Vec<_>>>() | ||
| } | ||
|
|
||
| async fn deploy(account: &Account, cache_opt: Opt) -> eyre::Result<Address> { | ||
| crate::deploy(account, "erc6909-supply", None, cache_opt).await | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| //! Common extensions to the ERC-6909 standard. | ||
| pub mod token_supply; | ||
|
|
||
| pub use token_supply::{Erc6909TokenSupply, IErc6909TokenSupply}; |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.