Skip to content
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

feat: block type enum #480

Merged
merged 11 commits into from
Sep 7, 2023
Prev Previous commit
Next Next commit
fix: lint
  • Loading branch information
Autoparallel committed Sep 7, 2023
commit e4ab78e773c175309ab8e29f23076f857f02d678
168 changes: 79 additions & 89 deletions arbiter-core/src/bindings/block_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use block_info::*;
clippy::upper_case_acronyms,
clippy::type_complexity,
dead_code,
non_camel_case_types,
non_camel_case_types
)]
pub mod block_info {
#[allow(deprecated)]
Expand All @@ -17,47 +17,35 @@ pub mod block_info {
functions: ::core::convert::From::from([
(
::std::borrow::ToOwned::to_owned("getBlockNumber"),
::std::vec![
::ethers::core::abi::ethabi::Function {
name: ::std::borrow::ToOwned::to_owned("getBlockNumber"),
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::vec![::ethers::core::abi::ethabi::Function {
name: ::std::borrow::ToOwned::to_owned("getBlockNumber"),
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("getBlockTimestamp"),
::std::vec![
::ethers::core::abi::ethabi::Function {
name: ::std::borrow::ToOwned::to_owned("getBlockTimestamp"),
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::vec![::ethers::core::abi::ethabi::Function {
name: ::std::borrow::ToOwned::to_owned("getBlockTimestamp"),
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,
},],
),
]),
events: ::std::collections::BTreeMap::new(),
Expand All @@ -66,22 +54,19 @@ pub mod block_info {
fallback: false,
}
}
///The parsed JSON ABI of the contract.
pub static BLOCKINFO_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = ::ethers::contract::Lazy::new(
__abi,
);
/// The parsed JSON ABI of the contract.
pub static BLOCKINFO_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> =
::ethers::contract::Lazy::new(__abi);
#[rustfmt::skip]
const __BYTECODE: &[u8] = b"`\x80\x80`@R4a\0\x19W`@Qa\x01\xA5\x90\x81a\0g\x829\xF3[bF\x1B\xCD`\xE5\x1B\x81R` `\x04\x82\x01R`\"`$\x82\x01R\x7FEther sent to non-payable functi`D\x82\x01Ra7\xB7`\xF1\x1B`d\x82\x01R`\x84\x90\xFD\xFE`\x80`@R`\x046\x10\x15a\0qW[`@QbF\x1B\xCD`\xE5\x1B\x81R` `\x04\x82\x01R`5`$\x82\x01R\x7FContract does not have fallback `D\x82\x01Rtnor receive functions`X\x1B`d\x82\x01R`\x84\x90\xFD[`\x005`\xE0\x1C\x80cB\xCB\xB1\\\x14a\0\xA9Wcyk\x89\xB9\x03a\0\x0EW4a\0\xA4Wa\0\x9A6a\x01\x11V[` `@QB\x81R\xF3[a\0\xC1V[4a\0\xC1Wa\0\xB76a\x01\x11V[` `@QC\x81R\xF3[`@QbF\x1B\xCD`\xE5\x1B\x81R` `\x04\x82\x01R`\"`$\x82\x01R\x7FEther sent to non-payable functi`D\x82\x01Ra7\xB7`\xF1\x1B`d\x82\x01R`\x84\x90\xFD[`\0\x90`\x03\x19\x01\x12a\x01\x1FWV[`@QbF\x1B\xCD`\xE5\x1B\x81R` `\x04\x82\x01R`\"`$\x82\x01R\x7FABI decoding: tuple data too sho`D\x82\x01Ra\x1C\x9D`\xF2\x1B`d\x82\x01R`\x84\x90\xFD\xFE\xA2dipfsX\"\x12 \xF7\xAD\x12 \x0E\xBD/\x87\xEF\x8DoY6\xE2\xD1\xEF1m\x1FLsJ\xC2\x85\x1E\xDAn\x9Bj\xDF\xC3hdsolcC\0\x08\x13\x003";
/// The bytecode of the contract.
pub static BLOCKINFO_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static(
__BYTECODE,
);
pub static BLOCKINFO_BYTECODE: ::ethers::core::types::Bytes =
::ethers::core::types::Bytes::from_static(__BYTECODE);
#[rustfmt::skip]
const __DEPLOYED_BYTECODE: &[u8] = b"`\x80`@R`\x046\x10\x15a\0qW[`@QbF\x1B\xCD`\xE5\x1B\x81R` `\x04\x82\x01R`5`$\x82\x01R\x7FContract does not have fallback `D\x82\x01Rtnor receive functions`X\x1B`d\x82\x01R`\x84\x90\xFD[`\x005`\xE0\x1C\x80cB\xCB\xB1\\\x14a\0\xA9Wcyk\x89\xB9\x03a\0\x0EW4a\0\xA4Wa\0\x9A6a\x01\x11V[` `@QB\x81R\xF3[a\0\xC1V[4a\0\xC1Wa\0\xB76a\x01\x11V[` `@QC\x81R\xF3[`@QbF\x1B\xCD`\xE5\x1B\x81R` `\x04\x82\x01R`\"`$\x82\x01R\x7FEther sent to non-payable functi`D\x82\x01Ra7\xB7`\xF1\x1B`d\x82\x01R`\x84\x90\xFD[`\0\x90`\x03\x19\x01\x12a\x01\x1FWV[`@QbF\x1B\xCD`\xE5\x1B\x81R` `\x04\x82\x01R`\"`$\x82\x01R\x7FABI decoding: tuple data too sho`D\x82\x01Ra\x1C\x9D`\xF2\x1B`d\x82\x01R`\x84\x90\xFD\xFE\xA2dipfsX\"\x12 \xF7\xAD\x12 \x0E\xBD/\x87\xEF\x8DoY6\xE2\xD1\xEF1m\x1FLsJ\xC2\x85\x1E\xDAn\x9Bj\xDF\xC3hdsolcC\0\x08\x13\x003";
/// The deployed bytecode of the contract.
pub static BLOCKINFO_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static(
__DEPLOYED_BYTECODE,
);
pub static BLOCKINFO_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes =
::ethers::core::types::Bytes::from_static(__DEPLOYED_BYTECODE);
pub struct BlockInfo<M>(::ethers::contract::Contract<M>);
impl<M> ::core::clone::Clone for BlockInfo<M> {
fn clone(&self) -> Self {
Expand All @@ -101,38 +86,44 @@ pub mod block_info {
}
impl<M> ::core::fmt::Debug for BlockInfo<M> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_tuple(::core::stringify!(BlockInfo)).field(&self.address()).finish()
f.debug_tuple(::core::stringify!(BlockInfo))
.field(&self.address())
.finish()
}
}
impl<M: ::ethers::providers::Middleware> BlockInfo<M> {
/// Creates a new contract instance with the specified `ethers` client at
/// `address`. The contract derefs to a `ethers::Contract` object.
/// Creates a new contract instance with the specified `ethers` client
/// at `address`. The contract derefs to a `ethers::Contract`
/// object.
pub fn new<T: Into<::ethers::core::types::Address>>(
address: T,
client: ::std::sync::Arc<M>,
) -> Self {
Self(
::ethers::contract::Contract::new(
address.into(),
BLOCKINFO_ABI.clone(),
client,
),
)
Self(::ethers::contract::Contract::new(
address.into(),
BLOCKINFO_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
/// 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.
/// - 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.
/// Generate contract bindings with `abigen!` and deploy a new contract
/// instance.
///
/// *Note*: this requires a `bytecode` and `abi` object in the `greeter.json` artifact.
/// *Note*: this requires a `bytecode` and `abi` object in the
/// `greeter.json` artifact.
///
/// ```ignore
/// # async fn deploy<M: ethers::providers::Middleware>(client: ::std::sync::Arc<M>) {
Expand All @@ -158,15 +149,15 @@ pub mod block_info {
let deployer = ::ethers::contract::ContractDeployer::new(deployer);
Ok(deployer)
}
///Calls the contract's `getBlockNumber` (0x42cbb15c) function
/// Calls the contract's `getBlockNumber` (0x42cbb15c) function
pub fn get_block_number(
&self,
) -> ::ethers::contract::builders::ContractCall<M, ::ethers::core::types::U256> {
self.0
.method_hash([66, 203, 177, 92], ())
.expect("method not found (this should never happen)")
}
///Calls the contract's `getBlockTimestamp` (0x796b89b9) function
/// Calls the contract's `getBlockTimestamp` (0x796b89b9) function
pub fn get_block_timestamp(
&self,
) -> ::ethers::contract::builders::ContractCall<M, ::ethers::core::types::U256> {
Expand All @@ -175,13 +166,13 @@ pub mod block_info {
.expect("method not found (this should never happen)")
}
}
impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>>
for BlockInfo<M> {
impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>> for BlockInfo<M> {
fn from(contract: ::ethers::contract::Contract<M>) -> Self {
Self::new(contract.address(), contract.client())
}
}
///Container type for all input parameters for the `getBlockNumber` function with signature `getBlockNumber()` and selector `0x42cbb15c`
/// Container type for all input parameters for the `getBlockNumber`
/// function with signature `getBlockNumber()` and selector `0x42cbb15c`
#[derive(
Clone,
::ethers::contract::EthCall,
Expand All @@ -190,11 +181,12 @@ pub mod block_info {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
#[ethcall(name = "getBlockNumber", abi = "getBlockNumber()")]
pub struct GetBlockNumberCall;
///Container type for all input parameters for the `getBlockTimestamp` function with signature `getBlockTimestamp()` and selector `0x796b89b9`
/// Container type for all input parameters for the `getBlockTimestamp`
/// function with signature `getBlockTimestamp()` and selector `0x796b89b9`
#[derive(
Clone,
::ethers::contract::EthCall,
Expand All @@ -203,11 +195,11 @@ pub mod block_info {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
#[ethcall(name = "getBlockTimestamp", abi = "getBlockTimestamp()")]
pub struct GetBlockTimestampCall;
///Container type for all of the contract's call
/// Container type for all of the contract's call
#[derive(Clone, ::ethers::contract::EthAbiType, Debug, PartialEq, Eq, Hash)]
pub enum BlockInfoCalls {
GetBlockNumber(GetBlockNumberCall),
Expand All @@ -218,14 +210,14 @@ pub mod block_info {
data: impl AsRef<[u8]>,
) -> ::core::result::Result<Self, ::ethers::core::abi::AbiError> {
let data = data.as_ref();
if let Ok(decoded)
= <GetBlockNumberCall as ::ethers::core::abi::AbiDecode>::decode(data) {
if let Ok(decoded) =
<GetBlockNumberCall as ::ethers::core::abi::AbiDecode>::decode(data)
{
return Ok(Self::GetBlockNumber(decoded));
}
if let Ok(decoded)
= <GetBlockTimestampCall as ::ethers::core::abi::AbiDecode>::decode(
data,
) {
if let Ok(decoded) =
<GetBlockTimestampCall as ::ethers::core::abi::AbiDecode>::decode(data)
{
return Ok(Self::GetBlockTimestamp(decoded));
}
Err(::ethers::core::abi::Error::InvalidData.into())
Expand All @@ -234,12 +226,8 @@ pub mod block_info {
impl ::ethers::core::abi::AbiEncode for BlockInfoCalls {
fn encode(self) -> Vec<u8> {
match self {
Self::GetBlockNumber(element) => {
::ethers::core::abi::AbiEncode::encode(element)
}
Self::GetBlockTimestamp(element) => {
::ethers::core::abi::AbiEncode::encode(element)
}
Self::GetBlockNumber(element) => ::ethers::core::abi::AbiEncode::encode(element),
Self::GetBlockTimestamp(element) => ::ethers::core::abi::AbiEncode::encode(element),
}
}
}
Expand All @@ -261,7 +249,8 @@ pub mod block_info {
Self::GetBlockTimestamp(value)
}
}
///Container type for all return fields from the `getBlockNumber` function with signature `getBlockNumber()` and selector `0x42cbb15c`
/// Container type for all return fields from the `getBlockNumber` function
/// with signature `getBlockNumber()` and selector `0x42cbb15c`
#[derive(
Clone,
::ethers::contract::EthAbiType,
Expand All @@ -270,10 +259,11 @@ pub mod block_info {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
pub struct GetBlockNumberReturn(pub ::ethers::core::types::U256);
///Container type for all return fields from the `getBlockTimestamp` function with signature `getBlockTimestamp()` and selector `0x796b89b9`
/// Container type for all return fields from the `getBlockTimestamp`
/// function with signature `getBlockTimestamp()` and selector `0x796b89b9`
#[derive(
Clone,
::ethers::contract::EthAbiType,
Expand All @@ -282,7 +272,7 @@ pub mod block_info {
Debug,
PartialEq,
Eq,
Hash
Hash,
)]
pub struct GetBlockTimestampReturn(pub ::ethers::core::types::U256);
}
Loading