-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into clean-magic-values
- Loading branch information
Showing
18 changed files
with
2,067 additions
and
2 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use alloy::{ | ||
network::{AnyNetwork, EthereumWallet}, | ||
primitives::Address, | ||
providers::ProviderBuilder, | ||
sol, | ||
sol_types::SolCall, | ||
uint, | ||
}; | ||
use e2e::{receipt, Account}; | ||
|
||
use crate::{ | ||
report::{ContractReport, FunctionReport}, | ||
CacheOpt, | ||
}; | ||
|
||
sol!( | ||
#[sol(rpc)] | ||
contract Erc1155Supply { | ||
function mint(address to, uint256 id, uint256 amount, bytes memory data) external; | ||
function totalSupply(uint256 id) external view returns (uint256); | ||
function totalSupply() external view returns (uint256); | ||
function exists(uint256 id) external view returns (bool); | ||
} | ||
); | ||
|
||
pub async fn bench() -> eyre::Result<ContractReport> { | ||
let reports = run_with(CacheOpt::None).await?; | ||
let report = reports | ||
.into_iter() | ||
.try_fold(ContractReport::new("Erc1155Supply"), ContractReport::add)?; | ||
|
||
let cached_reports = run_with(CacheOpt::Bid(0)).await?; | ||
let report = cached_reports | ||
.into_iter() | ||
.try_fold(report, ContractReport::add_cached)?; | ||
|
||
Ok(report) | ||
} | ||
|
||
pub async fn run_with( | ||
cache_opt: CacheOpt, | ||
) -> 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 = Erc1155Supply::new(contract_addr, &alice_wallet); | ||
|
||
let token = uint!(1_U256); | ||
let value = uint!(100_U256); | ||
|
||
// IMPORTANT: Order matters! | ||
use Erc1155Supply::*; | ||
#[rustfmt::skip] | ||
let receipts = vec![ | ||
(mintCall::SIGNATURE, receipt!(contract.mint(alice_addr, token, value, vec![].into()))?), | ||
(existsCall::SIGNATURE, receipt!(contract.exists(token))?), | ||
(totalSupply_0Call::SIGNATURE, receipt!(contract.totalSupply_0(token))?), | ||
(totalSupply_1Call::SIGNATURE, receipt!(contract.totalSupply_1())?), | ||
]; | ||
|
||
receipts | ||
.into_iter() | ||
.map(FunctionReport::new) | ||
.collect::<eyre::Result<Vec<_>>>() | ||
} | ||
|
||
async fn deploy( | ||
account: &Account, | ||
cache_opt: CacheOpt, | ||
) -> eyre::Result<Address> { | ||
crate::deploy(account, "erc1155-supply", None, cache_opt).await | ||
} |
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
//! Common extensions to the ERC-1155 standard. | ||
pub mod burnable; | ||
pub mod metadata_uri; | ||
pub mod supply; | ||
pub mod uri_storage; | ||
|
||
pub use burnable::IErc1155Burnable; | ||
pub use metadata_uri::{Erc1155MetadataUri, IErc1155MetadataUri}; | ||
pub use supply::{Erc1155Supply, IErc1155Supply}; | ||
pub use uri_storage::Erc1155UriStorage; |
Oops, something went wrong.