Skip to content
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8051a84
add initial files
onurinanc Jun 5, 2025
a6a3be9
implement erc6909 add one mint test
onurinanc Jun 5, 2025
d0ee57e
complete erc6909 unit tests
onurinanc Jun 6, 2025
58c07e5
finish supply extension and related motsu tests
onurinanc Jun 6, 2025
4140384
remove redundant
onurinanc Jun 9, 2025
5b45733
add Erc6909Example and Erc6909TokenSupplyExample
onurinanc Jun 9, 2025
b56e569
fmt
onurinanc Jun 9, 2025
513781c
add abi for erc6909 and erc6909-supply example and a mint test
onurinanc Jun 9, 2025
6463d84
fix mint test and add mints_invalid_receiver
onurinanc Jun 9, 2025
de57e8d
typo name
onurinanc Jun 9, 2025
e6761f5
complete erc6909 integration tests
onurinanc Jun 9, 2025
058c82d
add erc6909-supply integrations tests
onurinanc Jun 9, 2025
d859809
add comment & fmt all
onurinanc Jun 9, 2025
6781c92
fix errors
onurinanc Jun 9, 2025
dfe4e7f
fix
onurinanc Jun 9, 2025
de65d99
fix tests
onurinanc Jun 9, 2025
c0f55d5
fix test
onurinanc Jun 9, 2025
e395d59
fix erc6909-supply tests
onurinanc Jun 9, 2025
d354361
fix
onurinanc Jun 9, 2025
4c7fdb2
fix test
onurinanc Jun 9, 2025
23b6d83
add bench for erc6909
onurinanc Jun 9, 2025
976569b
add bench for erc6909 token supply
onurinanc Jun 9, 2025
fdadc2a
update cargo for CI
onurinanc Aug 7, 2025
e09cc02
Merge branch 'main' into feature/ERC6909
bidzyyys Aug 7, 2025
e05e7d0
apply requested changes
onurinanc Aug 7, 2025
a2e3fcd
merge changelog
onurinanc Aug 7, 2025
25220f1
fmt
onurinanc Aug 7, 2025
0b6266f
change FixedBytes<4> to B32
onurinanc Aug 7, 2025
d80ea4a
fix ancora
onurinanc Aug 7, 2025
2bd8e3a
add a test case covering ERC6909InvalidReceiver
onurinanc Aug 13, 2025
7f5926c
fix CHANGELOG
onurinanc Aug 13, 2025
13bbd20
update ERC-6909 ancora
onurinanc Aug 13, 2025
a509961
fmt
onurinanc Aug 13, 2025
1faf35e
remove unnecessary files
onurinanc Aug 13, 2025
2801d86
fix erc6909 ancora
onurinanc Aug 13, 2025
d2c0d06
Merge branch 'main' into feature/ERC6909
bidzyyys Aug 20, 2025
6f2df5c
Merge branch 'main' into feature/ERC6909
bidzyyys Sep 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
644 changes: 343 additions & 301 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ members = [
"examples/erc1155-metadata-uri",
"examples/erc1155-supply",
"examples/erc4626",
"examples/erc6909",
"examples/erc6909-supply",
"examples/safe-erc20",
"examples/merkle-proofs",
"examples/ownable",
Expand Down Expand Up @@ -57,6 +59,8 @@ default-members = [
"examples/erc1155-metadata-uri",
"examples/erc1155-supply",
"examples/erc4626",
"examples/erc6909",
"examples/erc6909-supply",
"examples/safe-erc20",
"examples/merkle-proofs",
"examples/ownable",
Expand Down
84 changes: 84 additions & 0 deletions benches/src/erc6909.rs
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
}
62 changes: 62 additions & 0 deletions benches/src/erc6909_supply.rs
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
}
2 changes: 2 additions & 0 deletions benches/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub mod erc1155;
pub mod erc1155_metadata_uri;
pub mod erc1155_supply;
pub mod erc20;
pub mod erc6909;
pub mod erc6909_supply;
pub mod erc721;
pub mod merkle_proofs;
pub mod ownable;
Expand Down
3 changes: 2 additions & 1 deletion benches/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use benches::{
access_control, erc1155, erc1155_metadata_uri, erc20, erc721,
access_control, erc1155, erc1155_metadata_uri, erc20, erc6909, erc721,
merkle_proofs, ownable, pedersen, poseidon, poseidon_asm_sol, poseidon_sol,
report::BenchmarkReport,
};
Expand All @@ -16,6 +16,7 @@ async fn main() -> eyre::Result<()> {
ownable::bench().boxed(),
erc1155::bench().boxed(),
erc1155_metadata_uri::bench().boxed(),
erc6909::bench().boxed(),
pedersen::bench().boxed(),
poseidon_sol::bench().boxed(),
poseidon_asm_sol::bench().boxed(),
Expand Down
4 changes: 4 additions & 0 deletions contracts/src/token/erc6909/extensions/mod.rs
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};
Loading
Loading