diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml
index 40256c4..fd41af0 100644
--- a/.github/workflows/contracts.yml
+++ b/.github/workflows/contracts.yml
@@ -47,4 +47,4 @@ jobs:
run: forge build --sizes
- name: Check bindings are correct
- run: forge bind --bindings-path ./crates/bindings --root ./contracts --crate-name bindings --skip-cargo-toml
+ run: forge bind --bindings-path ./crates/bindings --root ./contracts --crate-name bindings --skip-cargo-toml --alloy
diff --git a/Cargo.toml b/Cargo.toml
index b6c718b..3b56c81 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,8 +1,5 @@
[workspace]
-members = [
- "app",
- "crates/bindings",
-]
+members = ["app", "crates/bindings"]
[workspace.dependencies]
-bindings = { path = "crates/bindings" }
\ No newline at end of file
+foundry-contracts = { path = "crates/bindings" }
diff --git a/app/Cargo.toml b/app/Cargo.toml
index ff47c8e..89b59d9 100644
--- a/app/Cargo.toml
+++ b/app/Cargo.toml
@@ -6,7 +6,10 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-bindings = { workspace = true }
-ethers = { version = "2", default-features = false, features = ["rustls"] }
+foundry-contracts.workspace = true
eyre = "0.6"
-tokio = { version = "1.19", features = ["macros", "rt-multi-thread"] }
\ No newline at end of file
+tokio = { version = "1.19", features = ["macros", "rt-multi-thread"] }
+alloy = { git = "https://github.com/alloy-rs/alloy", features = [
+ "providers",
+ "node-bindings",
+] }
diff --git a/app/src/main.rs b/app/src/main.rs
index cef6aa8..a71c2ad 100644
--- a/app/src/main.rs
+++ b/app/src/main.rs
@@ -1,19 +1,19 @@
-use bindings::counter::Counter;
-
-use ethers::{prelude::Middleware, providers::test_provider::GOERLI, types::Address};
-
+use alloy::{
+ primitives::Address,
+ providers::{builder, Provider},
+};
use eyre::Result;
-use std::sync::Arc;
+use foundry_contracts::counter::Counter;
#[tokio::main]
async fn main() -> Result<()> {
- let provider = GOERLI.provider();
- let provider = Arc::new(provider);
+ let provider = builder().with_recommended_fillers().on_anvil_with_wallet();
let address = "0x0000000000000000000000000000000000000000".parse::
()?;
- let contract = Counter::new(address, provider);
- let blk = contract.client().get_block_number().await?;
+ let _contract = Counter::new(address, provider.clone());
+
+ let blk = provider.get_block_number().await?;
println!("Hello, world! {}", blk);
Ok(())
}
diff --git a/crates/bindings/Cargo.toml b/crates/bindings/Cargo.toml
index ddb0eaa..d1bcde2 100644
--- a/crates/bindings/Cargo.toml
+++ b/crates/bindings/Cargo.toml
@@ -1,10 +1,10 @@
[package]
-name = "bindings"
+name = "foundry-contracts"
version = "0.1.0"
edition = "2021"
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
[dependencies]
-ethers = { version = "2", default-features = false, features = ["abigen"] }
-serde = "1"
+alloy = { git = "https://github.com/alloy-rs/alloy", features = [
+ "sol-types",
+ "contract",
+] }
diff --git a/crates/bindings/src/counter.rs b/crates/bindings/src/counter.rs
index df109ae..5cd3664 100644
--- a/crates/bindings/src/counter.rs
+++ b/crates/bindings/src/counter.rs
@@ -1,340 +1,753 @@
-pub use counter::*;
-/// This module was auto-generated with ethers-rs Abigen.
-/// More information at:
-#[allow(
- clippy::enum_variant_names,
- clippy::too_many_arguments,
- clippy::upper_case_acronyms,
- clippy::type_complexity,
- dead_code,
- non_camel_case_types,
-)]
-pub mod counter {
- #[allow(deprecated)]
- fn __abi() -> ::ethers::core::abi::Abi {
- ::ethers::core::abi::ethabi::Contract {
- constructor: ::core::option::Option::None,
- functions: ::core::convert::From::from([
- (
- ::std::borrow::ToOwned::to_owned("increment"),
- ::std::vec![
- ::ethers::core::abi::ethabi::Function {
- name: ::std::borrow::ToOwned::to_owned("increment"),
- inputs: ::std::vec![],
- outputs: ::std::vec![],
- constant: ::core::option::Option::None,
- state_mutability: ::ethers::core::abi::ethabi::StateMutability::NonPayable,
- },
- ],
- ),
- (
- ::std::borrow::ToOwned::to_owned("number"),
- ::std::vec![
- ::ethers::core::abi::ethabi::Function {
- name: ::std::borrow::ToOwned::to_owned("number"),
- inputs: ::std::vec![],
- outputs: ::std::vec![
- ::ethers::core::abi::ethabi::Param {
- name: ::std::string::String::new(),
- kind: ::ethers::core::abi::ethabi::ParamType::Uint(
- 256usize,
- ),
- internal_type: ::core::option::Option::Some(
- ::std::borrow::ToOwned::to_owned("uint256"),
- ),
- },
- ],
- constant: ::core::option::Option::None,
- state_mutability: ::ethers::core::abi::ethabi::StateMutability::View,
- },
- ],
- ),
- (
- ::std::borrow::ToOwned::to_owned("setNumber"),
- ::std::vec![
- ::ethers::core::abi::ethabi::Function {
- name: ::std::borrow::ToOwned::to_owned("setNumber"),
- inputs: ::std::vec![
- ::ethers::core::abi::ethabi::Param {
- name: ::std::borrow::ToOwned::to_owned("newNumber"),
- kind: ::ethers::core::abi::ethabi::ParamType::Uint(
- 256usize,
- ),
- internal_type: ::core::option::Option::Some(
- ::std::borrow::ToOwned::to_owned("uint256"),
- ),
- },
- ],
- outputs: ::std::vec![],
- constant: ::core::option::Option::None,
- state_mutability: ::ethers::core::abi::ethabi::StateMutability::NonPayable,
- },
- ],
- ),
- ]),
- events: ::std::collections::BTreeMap::new(),
- errors: ::std::collections::BTreeMap::new(),
- receive: false,
- fallback: false,
- }
- }
- ///The parsed JSON ABI of the contract.
- pub static COUNTER_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = ::ethers::contract::Lazy::new(
- __abi,
- );
+/**
+
+Generated by the following Solidity interface...
+```solidity
+interface Counter {
+ function increment() external;
+ function number() external view returns (uint256);
+ function setNumber(uint256 newNumber) external;
+}
+```
+
+...which was generated by the following JSON ABI:
+```json
+[
+ {
+ "type": "function",
+ "name": "increment",
+ "inputs": [],
+ "outputs": [],
+ "stateMutability": "nonpayable"
+ },
+ {
+ "type": "function",
+ "name": "number",
+ "inputs": [],
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256",
+ "internalType": "uint256"
+ }
+ ],
+ "stateMutability": "view"
+ },
+ {
+ "type": "function",
+ "name": "setNumber",
+ "inputs": [
+ {
+ "name": "newNumber",
+ "type": "uint256",
+ "internalType": "uint256"
+ }
+ ],
+ "outputs": [],
+ "stateMutability": "nonpayable"
+ }
+]
+```*/
+#[allow(non_camel_case_types, non_snake_case, clippy::style)]
+pub mod Counter {
+ use super::*;
+ use alloy::sol_types as alloy_sol_types;
+ /// The creation / init bytecode of the contract.
+ ///
+ /// ```text
+ ///0x6080604052348015600e575f80fd5b5060ec8061001b5f395ff3fe6080604052348015600e575f80fd5b5060043610603a575f3560e01c80633fb5c1cb14603e5780638381f58a14604f578063d09de08a146068575b5f80fd5b604d6049366004607d565b5f55565b005b60565f5481565b60405190815260200160405180910390f35b604d5f805490806076836093565b9190505550565b5f60208284031215608c575f80fd5b5035919050565b5f6001820160af57634e487b7160e01b5f52601160045260245ffd5b506001019056fea2646970667358221220923bab332399d9d3bfc630c939ddf237e48f8ce465da25358054259319129dd064736f6c634300081a0033
+ /// ```
#[rustfmt::skip]
- const __BYTECODE: &[u8] = b"`\x80`@R4\x80\x15a\0\x0FW_\x80\xFD[P`\xEC\x80a\0\x1C_9_\xF3\xFE`\x80`@R4\x80\x15`\x0EW_\x80\xFD[P`\x046\x10`:W_5`\xE0\x1C\x80c?\xB5\xC1\xCB\x14`>W\x80c\x83\x81\xF5\x8A\x14`OW\x80c\xD0\x9D\xE0\x8A\x14`hW[_\x80\xFD[`M`I6`\x04`}V[_UV[\0[`V_T\x81V[`@Q\x90\x81R` \x01`@Q\x80\x91\x03\x90\xF3[`M_\x80T\x90\x80`v\x83`\x93V[\x91\x90PUPV[_` \x82\x84\x03\x12\x15`\x8CW_\x80\xFD[P5\x91\x90PV[_`\x01\x82\x01`\xAFWcNH{q`\xE0\x1B_R`\x11`\x04R`$_\xFD[P`\x01\x01\x90V\xFE\xA2dipfsX\"\x12 \xD2\x1Fv\xB1s\xCD\xA24\x16\x05s\xCDN1\xDE^\xBA\x93\xDC^\xE8\xED\xE0\xE1\xF2\x9D\xFE\xAC\x0Bu.\x97dsolcC\0\x08\x17\x003";
- /// The bytecode of the contract.
- pub static COUNTER_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static(
- __BYTECODE,
+ pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
+ b"`\x80`@R4\x80\x15`\x0EW_\x80\xFD[P`\xEC\x80a\0\x1B_9_\xF3\xFE`\x80`@R4\x80\x15`\x0EW_\x80\xFD[P`\x046\x10`:W_5`\xE0\x1C\x80c?\xB5\xC1\xCB\x14`>W\x80c\x83\x81\xF5\x8A\x14`OW\x80c\xD0\x9D\xE0\x8A\x14`hW[_\x80\xFD[`M`I6`\x04`}V[_UV[\0[`V_T\x81V[`@Q\x90\x81R` \x01`@Q\x80\x91\x03\x90\xF3[`M_\x80T\x90\x80`v\x83`\x93V[\x91\x90PUPV[_` \x82\x84\x03\x12\x15`\x8CW_\x80\xFD[P5\x91\x90PV[_`\x01\x82\x01`\xAFWcNH{q`\xE0\x1B_R`\x11`\x04R`$_\xFD[P`\x01\x01\x90V\xFE\xA2dipfsX\"\x12 \x92;\xAB3#\x99\xD9\xD3\xBF\xC60\xC99\xDD\xF27\xE4\x8F\x8C\xE4e\xDA%5\x80T%\x93\x19\x12\x9D\xD0dsolcC\0\x08\x1A\x003",
);
+ /// The runtime bytecode of the contract, as deployed on the network.
+ ///
+ /// ```text
+ ///0x6080604052348015600e575f80fd5b5060043610603a575f3560e01c80633fb5c1cb14603e5780638381f58a14604f578063d09de08a146068575b5f80fd5b604d6049366004607d565b5f55565b005b60565f5481565b60405190815260200160405180910390f35b604d5f805490806076836093565b9190505550565b5f60208284031215608c575f80fd5b5035919050565b5f6001820160af57634e487b7160e01b5f52601160045260245ffd5b506001019056fea2646970667358221220923bab332399d9d3bfc630c939ddf237e48f8ce465da25358054259319129dd064736f6c634300081a0033
+ /// ```
#[rustfmt::skip]
- const __DEPLOYED_BYTECODE: &[u8] = b"`\x80`@R4\x80\x15`\x0EW_\x80\xFD[P`\x046\x10`:W_5`\xE0\x1C\x80c?\xB5\xC1\xCB\x14`>W\x80c\x83\x81\xF5\x8A\x14`OW\x80c\xD0\x9D\xE0\x8A\x14`hW[_\x80\xFD[`M`I6`\x04`}V[_UV[\0[`V_T\x81V[`@Q\x90\x81R` \x01`@Q\x80\x91\x03\x90\xF3[`M_\x80T\x90\x80`v\x83`\x93V[\x91\x90PUPV[_` \x82\x84\x03\x12\x15`\x8CW_\x80\xFD[P5\x91\x90PV[_`\x01\x82\x01`\xAFWcNH{q`\xE0\x1B_R`\x11`\x04R`$_\xFD[P`\x01\x01\x90V\xFE\xA2dipfsX\"\x12 \xD2\x1Fv\xB1s\xCD\xA24\x16\x05s\xCDN1\xDE^\xBA\x93\xDC^\xE8\xED\xE0\xE1\xF2\x9D\xFE\xAC\x0Bu.\x97dsolcC\0\x08\x17\x003";
- /// The deployed bytecode of the contract.
- pub static COUNTER_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static(
- __DEPLOYED_BYTECODE,
+ pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static(
+ b"`\x80`@R4\x80\x15`\x0EW_\x80\xFD[P`\x046\x10`:W_5`\xE0\x1C\x80c?\xB5\xC1\xCB\x14`>W\x80c\x83\x81\xF5\x8A\x14`OW\x80c\xD0\x9D\xE0\x8A\x14`hW[_\x80\xFD[`M`I6`\x04`}V[_UV[\0[`V_T\x81V[`@Q\x90\x81R` \x01`@Q\x80\x91\x03\x90\xF3[`M_\x80T\x90\x80`v\x83`\x93V[\x91\x90PUPV[_` \x82\x84\x03\x12\x15`\x8CW_\x80\xFD[P5\x91\x90PV[_`\x01\x82\x01`\xAFWcNH{q`\xE0\x1B_R`\x11`\x04R`$_\xFD[P`\x01\x01\x90V\xFE\xA2dipfsX\"\x12 \x92;\xAB3#\x99\xD9\xD3\xBF\xC60\xC99\xDD\xF27\xE4\x8F\x8C\xE4e\xDA%5\x80T%\x93\x19\x12\x9D\xD0dsolcC\0\x08\x1A\x003",
);
- pub struct Counter(::ethers::contract::Contract);
- impl ::core::clone::Clone for Counter {
- fn clone(&self) -> Self {
- Self(::core::clone::Clone::clone(&self.0))
- }
- }
- impl ::core::ops::Deref for Counter {
- type Target = ::ethers::contract::Contract;
- fn deref(&self) -> &Self::Target {
- &self.0
+ /**Function with signature `increment()` and selector `0xd09de08a`.
+```solidity
+function increment() external;
+```*/
+ #[allow(non_camel_case_types, non_snake_case)]
+ #[derive(Clone)]
+ pub struct incrementCall {}
+ ///Container type for the return parameters of the [`increment()`](incrementCall) function.
+ #[allow(non_camel_case_types, non_snake_case)]
+ #[derive(Clone)]
+ pub struct incrementReturn {}
+ #[allow(non_camel_case_types, non_snake_case, clippy::style)]
+ const _: () = {
+ use alloy::sol_types as alloy_sol_types;
+ {
+ #[doc(hidden)]
+ type UnderlyingSolTuple<'a> = ();
+ #[doc(hidden)]
+ type UnderlyingRustTuple<'a> = ();
+ #[cfg(test)]
+ #[allow(dead_code, unreachable_patterns)]
+ fn _type_assertion(
+ _t: alloy_sol_types::private::AssertTypeEq,
+ ) {
+ match _t {
+ alloy_sol_types::private::AssertTypeEq::<
+ ::RustType,
+ >(_) => {}
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From for UnderlyingRustTuple<'_> {
+ fn from(value: incrementCall) -> Self {
+ ()
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From> for incrementCall {
+ fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
+ Self {}
+ }
+ }
}
- }
- impl ::core::ops::DerefMut for Counter {
- fn deref_mut(&mut self) -> &mut Self::Target {
- &mut self.0
+ {
+ #[doc(hidden)]
+ type UnderlyingSolTuple<'a> = ();
+ #[doc(hidden)]
+ type UnderlyingRustTuple<'a> = ();
+ #[cfg(test)]
+ #[allow(dead_code, unreachable_patterns)]
+ fn _type_assertion(
+ _t: alloy_sol_types::private::AssertTypeEq,
+ ) {
+ match _t {
+ alloy_sol_types::private::AssertTypeEq::<
+ ::RustType,
+ >(_) => {}
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From for UnderlyingRustTuple<'_> {
+ fn from(value: incrementReturn) -> Self {
+ ()
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From> for incrementReturn {
+ fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
+ Self {}
+ }
+ }
}
- }
- impl ::core::fmt::Debug for Counter {
- fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
- f.debug_tuple(::core::stringify!(Counter)).field(&self.address()).finish()
+ #[automatically_derived]
+ impl alloy_sol_types::SolCall for incrementCall {
+ type Parameters<'a> = ();
+ type Token<'a> = as alloy_sol_types::SolType>::Token<'a>;
+ type Return = incrementReturn;
+ type ReturnTuple<'a> = ();
+ type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>;
+ const SIGNATURE: &'static str = "increment()";
+ const SELECTOR: [u8; 4] = [208u8, 157u8, 224u8, 138u8];
+ #[inline]
+ fn new<'a>(
+ tuple: as alloy_sol_types::SolType>::RustType,
+ ) -> Self {
+ tuple.into()
+ }
+ #[inline]
+ fn tokenize(&self) -> Self::Token<'_> {
+ ()
+ }
+ #[inline]
+ fn abi_decode_returns(
+ data: &[u8],
+ validate: bool,
+ ) -> alloy_sol_types::Result {
+ as alloy_sol_types::SolType>::abi_decode_sequence(data, validate)
+ .map(Into::into)
+ }
}
+ };
+ /**Function with signature `number()` and selector `0x8381f58a`.
+```solidity
+function number() external view returns (uint256);
+```*/
+ #[allow(non_camel_case_types, non_snake_case)]
+ #[derive(Clone)]
+ pub struct numberCall {}
+ ///Container type for the return parameters of the [`number()`](numberCall) function.
+ #[allow(non_camel_case_types, non_snake_case)]
+ #[derive(Clone)]
+ pub struct numberReturn {
+ pub _0: alloy::sol_types::private::U256,
}
- impl Counter {
- /// Creates a new contract instance with the specified `ethers` client at
- /// `address`. The contract derefs to a `ethers::Contract` object.
- pub fn new>(
- address: T,
- client: ::std::sync::Arc,
- ) -> Self {
- Self(
- ::ethers::contract::Contract::new(
- address.into(),
- COUNTER_ABI.clone(),
- client,
- ),
- )
- }
- /// Constructs the general purpose `Deployer` instance based on the provided constructor arguments and sends it.
- /// Returns a new instance of a deployer that returns an instance of this contract after sending the transaction
- ///
- /// Notes:
- /// - If there are no constructor arguments, you should pass `()` as the argument.
- /// - The default poll duration is 7 seconds.
- /// - The default number of confirmations is 1 block.
- ///
- ///
- /// # Example
- ///
- /// Generate contract bindings with `abigen!` and deploy a new contract instance.
- ///
- /// *Note*: this requires a `bytecode` and `abi` object in the `greeter.json` artifact.
- ///
- /// ```ignore
- /// # async fn deploy(client: ::std::sync::Arc) {
- /// abigen!(Greeter, "../greeter.json");
- ///
- /// let greeter_contract = Greeter::deploy(client, "Hello world!".to_string()).unwrap().send().await.unwrap();
- /// let msg = greeter_contract.greet().call().await.unwrap();
- /// # }
- /// ```
- pub fn deploy(
- client: ::std::sync::Arc,
- constructor_args: T,
- ) -> ::core::result::Result<
- ::ethers::contract::builders::ContractDeployer,
- ::ethers::contract::ContractError,
- > {
- let factory = ::ethers::contract::ContractFactory::new(
- COUNTER_ABI.clone(),
- COUNTER_BYTECODE.clone().into(),
- client,
- );
- let deployer = factory.deploy(constructor_args)?;
- let deployer = ::ethers::contract::ContractDeployer::new(deployer);
- Ok(deployer)
- }
- ///Calls the contract's `increment` (0xd09de08a) function
- pub fn increment(&self) -> ::ethers::contract::builders::ContractCall {
- self.0
- .method_hash([208, 157, 224, 138], ())
- .expect("method not found (this should never happen)")
- }
- ///Calls the contract's `number` (0x8381f58a) function
- pub fn number(
- &self,
- ) -> ::ethers::contract::builders::ContractCall {
- self.0
- .method_hash([131, 129, 245, 138], ())
- .expect("method not found (this should never happen)")
+ #[allow(non_camel_case_types, non_snake_case, clippy::style)]
+ const _: () = {
+ use alloy::sol_types as alloy_sol_types;
+ {
+ #[doc(hidden)]
+ type UnderlyingSolTuple<'a> = ();
+ #[doc(hidden)]
+ type UnderlyingRustTuple<'a> = ();
+ #[cfg(test)]
+ #[allow(dead_code, unreachable_patterns)]
+ fn _type_assertion(
+ _t: alloy_sol_types::private::AssertTypeEq,
+ ) {
+ match _t {
+ alloy_sol_types::private::AssertTypeEq::<
+ ::RustType,
+ >(_) => {}
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From for UnderlyingRustTuple<'_> {
+ fn from(value: numberCall) -> Self {
+ ()
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From> for numberCall {
+ fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
+ Self {}
+ }
+ }
}
- ///Calls the contract's `setNumber` (0x3fb5c1cb) function
- pub fn set_number(
- &self,
- new_number: ::ethers::core::types::U256,
- ) -> ::ethers::contract::builders::ContractCall {
- self.0
- .method_hash([63, 181, 193, 203], new_number)
- .expect("method not found (this should never happen)")
+ {
+ #[doc(hidden)]
+ type UnderlyingSolTuple<'a> = (alloy::sol_types::sol_data::Uint<256>,);
+ #[doc(hidden)]
+ type UnderlyingRustTuple<'a> = (alloy::sol_types::private::U256,);
+ #[cfg(test)]
+ #[allow(dead_code, unreachable_patterns)]
+ fn _type_assertion(
+ _t: alloy_sol_types::private::AssertTypeEq,
+ ) {
+ match _t {
+ alloy_sol_types::private::AssertTypeEq::<
+ ::RustType,
+ >(_) => {}
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From for UnderlyingRustTuple<'_> {
+ fn from(value: numberReturn) -> Self {
+ (value._0,)
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From> for numberReturn {
+ fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
+ Self { _0: tuple.0 }
+ }
+ }
}
- }
- impl From<::ethers::contract::Contract>
- for Counter {
- fn from(contract: ::ethers::contract::Contract) -> Self {
- Self::new(contract.address(), contract.client())
+ #[automatically_derived]
+ impl alloy_sol_types::SolCall for numberCall {
+ type Parameters<'a> = ();
+ type Token<'a> = as alloy_sol_types::SolType>::Token<'a>;
+ type Return = numberReturn;
+ type ReturnTuple<'a> = (alloy::sol_types::sol_data::Uint<256>,);
+ type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>;
+ const SIGNATURE: &'static str = "number()";
+ const SELECTOR: [u8; 4] = [131u8, 129u8, 245u8, 138u8];
+ #[inline]
+ fn new<'a>(
+ tuple: as alloy_sol_types::SolType>::RustType,
+ ) -> Self {
+ tuple.into()
+ }
+ #[inline]
+ fn tokenize(&self) -> Self::Token<'_> {
+ ()
+ }
+ #[inline]
+ fn abi_decode_returns(
+ data: &[u8],
+ validate: bool,
+ ) -> alloy_sol_types::Result {
+ as alloy_sol_types::SolType>::abi_decode_sequence(data, validate)
+ .map(Into::into)
+ }
}
+ };
+ /**Function with signature `setNumber(uint256)` and selector `0x3fb5c1cb`.
+```solidity
+function setNumber(uint256 newNumber) external;
+```*/
+ #[allow(non_camel_case_types, non_snake_case)]
+ #[derive(Clone)]
+ pub struct setNumberCall {
+ pub newNumber: alloy::sol_types::private::U256,
}
- ///Container type for all input parameters for the `increment` function with signature `increment()` and selector `0xd09de08a`
- #[derive(
- Clone,
- ::ethers::contract::EthCall,
- ::ethers::contract::EthDisplay,
- serde::Serialize,
- serde::Deserialize,
- Default,
- Debug,
- PartialEq,
- Eq,
- Hash
- )]
- #[ethcall(name = "increment", abi = "increment()")]
- pub struct IncrementCall;
- ///Container type for all input parameters for the `number` function with signature `number()` and selector `0x8381f58a`
- #[derive(
- Clone,
- ::ethers::contract::EthCall,
- ::ethers::contract::EthDisplay,
- serde::Serialize,
- serde::Deserialize,
- Default,
- Debug,
- PartialEq,
- Eq,
- Hash
- )]
- #[ethcall(name = "number", abi = "number()")]
- pub struct NumberCall;
- ///Container type for all input parameters for the `setNumber` function with signature `setNumber(uint256)` and selector `0x3fb5c1cb`
- #[derive(
- Clone,
- ::ethers::contract::EthCall,
- ::ethers::contract::EthDisplay,
- serde::Serialize,
- serde::Deserialize,
- Default,
- Debug,
- PartialEq,
- Eq,
- Hash
- )]
- #[ethcall(name = "setNumber", abi = "setNumber(uint256)")]
- pub struct SetNumberCall {
- pub new_number: ::ethers::core::types::U256,
- }
- ///Container type for all of the contract's call
- #[derive(
- Clone,
- ::ethers::contract::EthAbiType,
- serde::Serialize,
- serde::Deserialize,
- Debug,
- PartialEq,
- Eq,
- Hash
- )]
- pub enum CounterCalls {
- Increment(IncrementCall),
- Number(NumberCall),
- SetNumber(SetNumberCall),
- }
- impl ::ethers::core::abi::AbiDecode for CounterCalls {
- fn decode(
- data: impl AsRef<[u8]>,
- ) -> ::core::result::Result {
- let data = data.as_ref();
- if let Ok(decoded) = ::decode(
- data,
+ ///Container type for the return parameters of the [`setNumber(uint256)`](setNumberCall) function.
+ #[allow(non_camel_case_types, non_snake_case)]
+ #[derive(Clone)]
+ pub struct setNumberReturn {}
+ #[allow(non_camel_case_types, non_snake_case, clippy::style)]
+ const _: () = {
+ use alloy::sol_types as alloy_sol_types;
+ {
+ #[doc(hidden)]
+ type UnderlyingSolTuple<'a> = (alloy::sol_types::sol_data::Uint<256>,);
+ #[doc(hidden)]
+ type UnderlyingRustTuple<'a> = (alloy::sol_types::private::U256,);
+ #[cfg(test)]
+ #[allow(dead_code, unreachable_patterns)]
+ fn _type_assertion(
+ _t: alloy_sol_types::private::AssertTypeEq,
) {
- return Ok(Self::Increment(decoded));
+ match _t {
+ alloy_sol_types::private::AssertTypeEq::<
+ ::RustType,
+ >(_) => {}
+ }
}
- if let Ok(decoded) = ::decode(
- data,
- ) {
- return Ok(Self::Number(decoded));
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From for UnderlyingRustTuple<'_> {
+ fn from(value: setNumberCall) -> Self {
+ (value.newNumber,)
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From> for setNumberCall {
+ fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
+ Self { newNumber: tuple.0 }
+ }
}
- if let Ok(decoded) = ::decode(
- data,
+ }
+ {
+ #[doc(hidden)]
+ type UnderlyingSolTuple<'a> = ();
+ #[doc(hidden)]
+ type UnderlyingRustTuple<'a> = ();
+ #[cfg(test)]
+ #[allow(dead_code, unreachable_patterns)]
+ fn _type_assertion(
+ _t: alloy_sol_types::private::AssertTypeEq,
) {
- return Ok(Self::SetNumber(decoded));
+ match _t {
+ alloy_sol_types::private::AssertTypeEq::<
+ ::RustType,
+ >(_) => {}
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From for UnderlyingRustTuple<'_> {
+ fn from(value: setNumberReturn) -> Self {
+ ()
+ }
+ }
+ #[automatically_derived]
+ #[doc(hidden)]
+ impl ::core::convert::From> for setNumberReturn {
+ fn from(tuple: UnderlyingRustTuple<'_>) -> Self {
+ Self {}
+ }
}
- Err(::ethers::core::abi::Error::InvalidData.into())
}
+ #[automatically_derived]
+ impl alloy_sol_types::SolCall for setNumberCall {
+ type Parameters<'a> = (alloy::sol_types::sol_data::Uint<256>,);
+ type Token<'a> = as alloy_sol_types::SolType>::Token<'a>;
+ type Return = setNumberReturn;
+ type ReturnTuple<'a> = ();
+ type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>;
+ const SIGNATURE: &'static str = "setNumber(uint256)";
+ const SELECTOR: [u8; 4] = [63u8, 181u8, 193u8, 203u8];
+ #[inline]
+ fn new<'a>(
+ tuple: as alloy_sol_types::SolType>::RustType,
+ ) -> Self {
+ tuple.into()
+ }
+ #[inline]
+ fn tokenize(&self) -> Self::Token<'_> {
+ (
+ as alloy_sol_types::SolType>::tokenize(&self.newNumber),
+ )
+ }
+ #[inline]
+ fn abi_decode_returns(
+ data: &[u8],
+ validate: bool,
+ ) -> alloy_sol_types::Result {
+ as alloy_sol_types::SolType>::abi_decode_sequence(data, validate)
+ .map(Into::into)
+ }
+ }
+ };
+ ///Container for all the [`Counter`](self) function calls.
+ pub enum CounterCalls {
+ increment(incrementCall),
+ number(numberCall),
+ setNumber(setNumberCall),
+ }
+ #[automatically_derived]
+ impl CounterCalls {
+ /// All the selectors of this enum.
+ ///
+ /// Note that the selectors might not be in the same order as the variants.
+ /// No guarantees are made about the order of the selectors.
+ ///
+ /// Prefer using `SolInterface` methods instead.
+ pub const SELECTORS: &'static [[u8; 4usize]] = &[
+ [63u8, 181u8, 193u8, 203u8],
+ [131u8, 129u8, 245u8, 138u8],
+ [208u8, 157u8, 224u8, 138u8],
+ ];
}
- impl ::ethers::core::abi::AbiEncode for CounterCalls {
- fn encode(self) -> Vec {
+ #[automatically_derived]
+ impl alloy_sol_types::SolInterface for CounterCalls {
+ const NAME: &'static str = "CounterCalls";
+ const MIN_DATA_LENGTH: usize = 0usize;
+ const COUNT: usize = 3usize;
+ #[inline]
+ fn selector(&self) -> [u8; 4] {
+ match self {
+ Self::increment(_) => {
+ ::SELECTOR
+ }
+ Self::number(_) => ::SELECTOR,
+ Self::setNumber(_) => {
+ ::SELECTOR
+ }
+ }
+ }
+ #[inline]
+ fn selector_at(i: usize) -> ::core::option::Option<[u8; 4]> {
+ Self::SELECTORS.get(i).copied()
+ }
+ #[inline]
+ fn valid_selector(selector: [u8; 4]) -> bool {
+ Self::SELECTORS.binary_search(&selector).is_ok()
+ }
+ #[inline]
+ #[allow(unsafe_code, non_snake_case)]
+ fn abi_decode_raw(
+ selector: [u8; 4],
+ data: &[u8],
+ validate: bool,
+ ) -> alloy_sol_types::Result {
+ static DECODE_SHIMS: &[fn(
+ &[u8],
+ bool,
+ ) -> alloy_sol_types::Result] = &[
+ {
+ fn setNumber(
+ data: &[u8],
+ validate: bool,
+ ) -> alloy_sol_types::Result {
+ ::abi_decode_raw(
+ data,
+ validate,
+ )
+ .map(CounterCalls::setNumber)
+ }
+ setNumber
+ },
+ {
+ fn number(
+ data: &[u8],
+ validate: bool,
+ ) -> alloy_sol_types::Result {
+ ::abi_decode_raw(
+ data,
+ validate,
+ )
+ .map(CounterCalls::number)
+ }
+ number
+ },
+ {
+ fn increment(
+ data: &[u8],
+ validate: bool,
+ ) -> alloy_sol_types::Result {
+ ::abi_decode_raw(
+ data,
+ validate,
+ )
+ .map(CounterCalls::increment)
+ }
+ increment
+ },
+ ];
+ let Ok(idx) = Self::SELECTORS.binary_search(&selector) else {
+ return Err(
+ alloy_sol_types::Error::unknown_selector(
+ ::NAME,
+ selector,
+ ),
+ );
+ };
+ (unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate)
+ }
+ #[inline]
+ fn abi_encoded_size(&self) -> usize {
+ match self {
+ Self::increment(inner) => {
+ ::abi_encoded_size(inner)
+ }
+ Self::number(inner) => {
+ ::abi_encoded_size(inner)
+ }
+ Self::setNumber(inner) => {
+ ::abi_encoded_size(inner)
+ }
+ }
+ }
+ #[inline]
+ fn abi_encode_raw(&self, out: &mut alloy_sol_types::private::Vec) {
match self {
- Self::Increment(element) => {
- ::ethers::core::abi::AbiEncode::encode(element)
+ Self::increment(inner) => {
+ ::abi_encode_raw(
+ inner,
+ out,
+ )
+ }
+ Self::number(inner) => {
+ ::abi_encode_raw(inner, out)
}
- Self::Number(element) => ::ethers::core::abi::AbiEncode::encode(element),
- Self::SetNumber(element) => {
- ::ethers::core::abi::AbiEncode::encode(element)
+ Self::setNumber(inner) => {
+ ::abi_encode_raw(
+ inner,
+ out,
+ )
}
}
}
}
- impl ::core::fmt::Display for CounterCalls {
+ use alloy::contract as alloy_contract;
+ /**Creates a new wrapper around an on-chain [`Counter`](self) contract instance.
+
+See the [wrapper's documentation](`CounterInstance`) for more details.*/
+ #[inline]
+ pub const fn new<
+ T: alloy_contract::private::Transport + ::core::clone::Clone,
+ P: alloy_contract::private::Provider,
+ N: alloy_contract::private::Network,
+ >(
+ address: alloy_sol_types::private::Address,
+ provider: P,
+ ) -> CounterInstance {
+ CounterInstance::::new(address, provider)
+ }
+ /**Deploys this contract using the given `provider` and constructor arguments, if any.
+
+Returns a new instance of the contract, if the deployment was successful.
+
+For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
+ #[inline]
+ pub fn deploy<
+ T: alloy_contract::private::Transport + ::core::clone::Clone,
+ P: alloy_contract::private::Provider,
+ N: alloy_contract::private::Network,
+ >(
+ provider: P,
+ ) -> impl ::core::future::Future<
+ Output = alloy_contract::Result>,
+ > {
+ CounterInstance::::deploy(provider)
+ }
+ /**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
+and constructor arguments, if any.
+
+This is a simple wrapper around creating a `RawCallBuilder` with the data set to
+the bytecode concatenated with the constructor's ABI-encoded arguments.*/
+ #[inline]
+ pub fn deploy_builder<
+ T: alloy_contract::private::Transport + ::core::clone::Clone,
+ P: alloy_contract::private::Provider,
+ N: alloy_contract::private::Network,
+ >(provider: P) -> alloy_contract::RawCallBuilder {
+ CounterInstance::::deploy_builder(provider)
+ }
+ /**A [`Counter`](self) instance.
+
+Contains type-safe methods for interacting with an on-chain instance of the
+[`Counter`](self) contract located at a given `address`, using a given
+provider `P`.
+
+If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!)
+documentation on how to provide it), the `deploy` and `deploy_builder` methods can
+be used to deploy a new instance of the contract.
+
+See the [module-level documentation](self) for all the available methods.*/
+ #[derive(Clone)]
+ pub struct CounterInstance {
+ address: alloy_sol_types::private::Address,
+ provider: P,
+ _network_transport: ::core::marker::PhantomData<(N, T)>,
+ }
+ #[automatically_derived]
+ impl ::core::fmt::Debug for CounterInstance {
+ #[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
- match self {
- Self::Increment(element) => ::core::fmt::Display::fmt(element, f),
- Self::Number(element) => ::core::fmt::Display::fmt(element, f),
- Self::SetNumber(element) => ::core::fmt::Display::fmt(element, f),
+ f.debug_tuple("CounterInstance").field(&self.address).finish()
+ }
+ }
+ /// Instantiation and getters/setters.
+ #[automatically_derived]
+ impl<
+ T: alloy_contract::private::Transport + ::core::clone::Clone,
+ P: alloy_contract::private::Provider,
+ N: alloy_contract::private::Network,
+ > CounterInstance {
+ /**Creates a new wrapper around an on-chain [`Counter`](self) contract instance.
+
+See the [wrapper's documentation](`CounterInstance`) for more details.*/
+ #[inline]
+ pub const fn new(
+ address: alloy_sol_types::private::Address,
+ provider: P,
+ ) -> Self {
+ Self {
+ address,
+ provider,
+ _network_transport: ::core::marker::PhantomData,
}
}
+ /**Deploys this contract using the given `provider` and constructor arguments, if any.
+
+Returns a new instance of the contract, if the deployment was successful.
+
+For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/
+ #[inline]
+ pub async fn deploy(
+ provider: P,
+ ) -> alloy_contract::Result> {
+ let call_builder = Self::deploy_builder(provider);
+ let contract_address = call_builder.deploy().await?;
+ Ok(Self::new(contract_address, call_builder.provider))
+ }
+ /**Creates a `RawCallBuilder` for deploying this contract using the given `provider`
+and constructor arguments, if any.
+
+This is a simple wrapper around creating a `RawCallBuilder` with the data set to
+the bytecode concatenated with the constructor's ABI-encoded arguments.*/
+ #[inline]
+ pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder {
+ alloy_contract::RawCallBuilder::new_raw_deploy(
+ provider,
+ ::core::clone::Clone::clone(&BYTECODE),
+ )
+ }
+ /// Returns a reference to the address.
+ #[inline]
+ pub const fn address(&self) -> &alloy_sol_types::private::Address {
+ &self.address
+ }
+ /// Sets the address.
+ #[inline]
+ pub fn set_address(&mut self, address: alloy_sol_types::private::Address) {
+ self.address = address;
+ }
+ /// Sets the address and returns `self`.
+ pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self {
+ self.set_address(address);
+ self
+ }
+ /// Returns a reference to the provider.
+ #[inline]
+ pub const fn provider(&self) -> &P {
+ &self.provider
+ }
}
- impl ::core::convert::From for CounterCalls {
- fn from(value: IncrementCall) -> Self {
- Self::Increment(value)
+ impl CounterInstance {
+ /// Clones the provider and returns a new instance with the cloned provider.
+ #[inline]
+ pub fn with_cloned_provider(self) -> CounterInstance {
+ CounterInstance {
+ address: self.address,
+ provider: ::core::clone::Clone::clone(&self.provider),
+ _network_transport: ::core::marker::PhantomData,
+ }
}
}
- impl ::core::convert::From for CounterCalls {
- fn from(value: NumberCall) -> Self {
- Self::Number(value)
+ /// Function calls.
+ #[automatically_derived]
+ impl<
+ T: alloy_contract::private::Transport + ::core::clone::Clone,
+ P: alloy_contract::private::Provider,
+ N: alloy_contract::private::Network,
+ > CounterInstance {
+ /// Creates a new call builder using this contract instance's provider and address.
+ ///
+ /// Note that the call can be any function call, not just those defined in this
+ /// contract. Prefer using the other methods for building type-safe contract calls.
+ pub fn call_builder(
+ &self,
+ call: &C,
+ ) -> alloy_contract::SolCallBuilder {
+ alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call)
+ }
+ ///Creates a new call builder for the [`increment`] function.
+ pub fn increment(
+ &self,
+ ) -> alloy_contract::SolCallBuilder {
+ self.call_builder(&incrementCall {})
+ }
+ ///Creates a new call builder for the [`number`] function.
+ pub fn number(&self) -> alloy_contract::SolCallBuilder {
+ self.call_builder(&numberCall {})
+ }
+ ///Creates a new call builder for the [`setNumber`] function.
+ pub fn setNumber(
+ &self,
+ newNumber: alloy::sol_types::private::U256,
+ ) -> alloy_contract::SolCallBuilder {
+ self.call_builder(&setNumberCall { newNumber })
}
}
- impl ::core::convert::From for CounterCalls {
- fn from(value: SetNumberCall) -> Self {
- Self::SetNumber(value)
+ /// Event filters.
+ #[automatically_derived]
+ impl<
+ T: alloy_contract::private::Transport + ::core::clone::Clone,
+ P: alloy_contract::private::Provider,
+ N: alloy_contract::private::Network,
+ > CounterInstance {
+ /// Creates a new event filter using this contract instance's provider and address.
+ ///
+ /// Note that the type can be any event, not just those defined in this contract.
+ /// Prefer using the other methods for building type-safe event filters.
+ pub fn event_filter(
+ &self,
+ ) -> alloy_contract::Event {
+ alloy_contract::Event::new_sol(&self.provider, &self.address)
}
}
- ///Container type for all return fields from the `number` function with signature `number()` and selector `0x8381f58a`
- #[derive(
- Clone,
- ::ethers::contract::EthAbiType,
- ::ethers::contract::EthAbiCodec,
- serde::Serialize,
- serde::Deserialize,
- Default,
- Debug,
- PartialEq,
- Eq,
- Hash
- )]
- pub struct NumberReturn(pub ::ethers::core::types::U256);
}
diff --git a/crates/bindings/src/lib.rs b/crates/bindings/src/lib.rs
index 8623af1..b19b858 100644
--- a/crates/bindings/src/lib.rs
+++ b/crates/bindings/src/lib.rs
@@ -1,5 +1,5 @@
-#![allow(clippy::all)]
-//! This lib contains abigen! generated bindings for solidity contracts.
+#![allow(unused_imports, clippy::all, rustdoc::all)]
+//! This module contains the sol! generated bindings for solidity contracts.
//! This is autogenerated code.
//! Do not manually edit these files.
//! These files may be overwritten by the codegen system at any time.