diff --git a/crates/facade/src/lib.rs b/crates/facade/src/lib.rs index 7364932..a333f5f 100644 --- a/crates/facade/src/lib.rs +++ b/crates/facade/src/lib.rs @@ -174,4 +174,16 @@ mod timehub_facade; pub mod timehub { pub type Events = crate::timehub_facade::itimehubfacade::ITimehubFacade::ITimehubFacadeEvents; pub type EventPushed = crate::timehub_facade::itimehubfacade::ITimehubFacade::EventPushed; -} \ No newline at end of file + + pub type Calls = crate::timehub_facade::itimehubfacade::ITimehubFacade::ITimehubFacadeCalls; + #[allow(non_camel_case_types)] + pub type pushCall = crate::timehub_facade::itimehubfacade::ITimehubFacade::pushCall; + #[allow(non_camel_case_types)] + pub type getLeafAtCall = crate::timehub_facade::itimehubfacade::ITimehubFacade::getLeafAtCall; + #[allow(non_camel_case_types)] + pub type getRootCall = crate::timehub_facade::itimehubfacade::ITimehubFacade::getRootCall; + #[allow(non_camel_case_types)] + pub type getPeaksCall = crate::timehub_facade::itimehubfacade::ITimehubFacade::getPeaksCall; + #[allow(non_camel_case_types)] + pub type getCountCall = crate::timehub_facade::itimehubfacade::ITimehubFacade::getCountCall; +} diff --git a/crates/facade/src/timehub_facade/itimehubfacade.rs b/crates/facade/src/timehub_facade/itimehubfacade.rs index 1c2e5ca..104bac5 100644 --- a/crates/facade/src/timehub_facade/itimehubfacade.rs +++ b/crates/facade/src/timehub_facade/itimehubfacade.rs @@ -4,12 +4,105 @@ Generated by the following Solidity interface... ```solidity interface ITimehubFacade { event EventPushed(uint256 index, uint256 timestamp, bytes cid); + + function getCount() external view returns (uint64); + function getLeafAt(uint64 index) external view returns (uint64 timestamp, bytes memory witnessed); + function getPeaks() external view returns (bytes[] memory cids); + function getRoot() external view returns (bytes memory cid); + function push(bytes memory cid) external returns (bytes memory root, uint64 index); } ``` ...which was generated by the following JSON ABI: ```json [ + { + "type": "function", + "name": "getCount", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint64", + "internalType": "uint64" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getLeafAt", + "inputs": [ + { + "name": "index", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [ + { + "name": "timestamp", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "witnessed", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getPeaks", + "inputs": [], + "outputs": [ + { + "name": "cids", + "type": "bytes[]", + "internalType": "bytes[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRoot", + "inputs": [], + "outputs": [ + { + "name": "cid", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "push", + "inputs": [ + { + "name": "cid", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "root", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "index", + "type": "uint64", + "internalType": "uint64" + } + ], + "stateMutability": "nonpayable" + }, { "type": "event", "name": "EventPushed", @@ -217,6 +310,834 @@ event EventPushed(uint256 index, uint256 timestamp, bytes cid); } } }; + /**Function with signature `getCount()` and selector `0xa87d942c`. +```solidity +function getCount() external view returns (uint64); +```*/ + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct getCountCall {} + ///Container type for the return parameters of the [`getCount()`](getCountCall) function. + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct getCountReturn { + #[allow(missing_docs)] + pub _0: u64, + } + #[allow( + non_camel_case_types, + non_snake_case, + clippy::pub_underscore_fields, + 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: getCountCall) -> Self { + () + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for getCountCall { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self {} + } + } + } + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = (::alloy_sol_types::sol_data::Uint<64>,); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = (u64,); + #[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: getCountReturn) -> Self { + (value._0,) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for getCountReturn { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { _0: tuple.0 } + } + } + } + #[automatically_derived] + impl alloy_sol_types::SolCall for getCountCall { + type Parameters<'a> = (); + type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; + type Return = getCountReturn; + type ReturnTuple<'a> = (::alloy_sol_types::sol_data::Uint<64>,); + type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; + const SIGNATURE: &'static str = "getCount()"; + const SELECTOR: [u8; 4] = [168u8, 125u8, 148u8, 44u8]; + #[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 `getLeafAt(uint64)` and selector `0x19fa4966`. +```solidity +function getLeafAt(uint64 index) external view returns (uint64 timestamp, bytes memory witnessed); +```*/ + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct getLeafAtCall { + #[allow(missing_docs)] + pub index: u64, + } + ///Container type for the return parameters of the [`getLeafAt(uint64)`](getLeafAtCall) function. + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct getLeafAtReturn { + #[allow(missing_docs)] + pub timestamp: u64, + #[allow(missing_docs)] + pub witnessed: ::alloy_sol_types::private::Bytes, + } + #[allow( + non_camel_case_types, + non_snake_case, + clippy::pub_underscore_fields, + clippy::style + )] + const _: () = { + use ::alloy_sol_types as alloy_sol_types; + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = (::alloy_sol_types::sol_data::Uint<64>,); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = (u64,); + #[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: getLeafAtCall) -> Self { + (value.index,) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for getLeafAtCall { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { index: tuple.0 } + } + } + } + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = ( + ::alloy_sol_types::sol_data::Uint<64>, + ::alloy_sol_types::sol_data::Bytes, + ); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = (u64, ::alloy_sol_types::private::Bytes); + #[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: getLeafAtReturn) -> Self { + (value.timestamp, value.witnessed) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for getLeafAtReturn { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { + timestamp: tuple.0, + witnessed: tuple.1, + } + } + } + } + #[automatically_derived] + impl alloy_sol_types::SolCall for getLeafAtCall { + type Parameters<'a> = (::alloy_sol_types::sol_data::Uint<64>,); + type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; + type Return = getLeafAtReturn; + type ReturnTuple<'a> = ( + ::alloy_sol_types::sol_data::Uint<64>, + ::alloy_sol_types::sol_data::Bytes, + ); + type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; + const SIGNATURE: &'static str = "getLeafAt(uint64)"; + const SELECTOR: [u8; 4] = [25u8, 250u8, 73u8, 102u8]; + #[inline] + fn new<'a>( + tuple: as alloy_sol_types::SolType>::RustType, + ) -> Self { + tuple.into() + } + #[inline] + fn tokenize(&self) -> Self::Token<'_> { + ( + <::alloy_sol_types::sol_data::Uint< + 64, + > as alloy_sol_types::SolType>::tokenize(&self.index), + ) + } + #[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 `getPeaks()` and selector `0x0ae06fba`. +```solidity +function getPeaks() external view returns (bytes[] memory cids); +```*/ + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct getPeaksCall {} + ///Container type for the return parameters of the [`getPeaks()`](getPeaksCall) function. + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct getPeaksReturn { + #[allow(missing_docs)] + pub cids: ::alloy_sol_types::private::Vec<::alloy_sol_types::private::Bytes>, + } + #[allow( + non_camel_case_types, + non_snake_case, + clippy::pub_underscore_fields, + 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: getPeaksCall) -> Self { + () + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for getPeaksCall { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self {} + } + } + } + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = ( + ::alloy_sol_types::sol_data::Array<::alloy_sol_types::sol_data::Bytes>, + ); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = ( + ::alloy_sol_types::private::Vec<::alloy_sol_types::private::Bytes>, + ); + #[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: getPeaksReturn) -> Self { + (value.cids,) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for getPeaksReturn { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { cids: tuple.0 } + } + } + } + #[automatically_derived] + impl alloy_sol_types::SolCall for getPeaksCall { + type Parameters<'a> = (); + type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; + type Return = getPeaksReturn; + type ReturnTuple<'a> = ( + ::alloy_sol_types::sol_data::Array<::alloy_sol_types::sol_data::Bytes>, + ); + type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; + const SIGNATURE: &'static str = "getPeaks()"; + const SELECTOR: [u8; 4] = [10u8, 224u8, 111u8, 186u8]; + #[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 `getRoot()` and selector `0x5ca1e165`. +```solidity +function getRoot() external view returns (bytes memory cid); +```*/ + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct getRootCall {} + ///Container type for the return parameters of the [`getRoot()`](getRootCall) function. + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct getRootReturn { + #[allow(missing_docs)] + pub cid: ::alloy_sol_types::private::Bytes, + } + #[allow( + non_camel_case_types, + non_snake_case, + clippy::pub_underscore_fields, + 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: getRootCall) -> Self { + () + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for getRootCall { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self {} + } + } + } + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = (::alloy_sol_types::sol_data::Bytes,); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = (::alloy_sol_types::private::Bytes,); + #[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: getRootReturn) -> Self { + (value.cid,) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for getRootReturn { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { cid: tuple.0 } + } + } + } + #[automatically_derived] + impl alloy_sol_types::SolCall for getRootCall { + type Parameters<'a> = (); + type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; + type Return = getRootReturn; + type ReturnTuple<'a> = (::alloy_sol_types::sol_data::Bytes,); + type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; + const SIGNATURE: &'static str = "getRoot()"; + const SELECTOR: [u8; 4] = [92u8, 161u8, 225u8, 101u8]; + #[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 `push(bytes)` and selector `0x7dacda03`. +```solidity +function push(bytes memory cid) external returns (bytes memory root, uint64 index); +```*/ + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct pushCall { + #[allow(missing_docs)] + pub cid: ::alloy_sol_types::private::Bytes, + } + ///Container type for the return parameters of the [`push(bytes)`](pushCall) function. + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct pushReturn { + #[allow(missing_docs)] + pub root: ::alloy_sol_types::private::Bytes, + #[allow(missing_docs)] + pub index: u64, + } + #[allow( + non_camel_case_types, + non_snake_case, + clippy::pub_underscore_fields, + clippy::style + )] + const _: () = { + use ::alloy_sol_types as alloy_sol_types; + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = (::alloy_sol_types::sol_data::Bytes,); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = (::alloy_sol_types::private::Bytes,); + #[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: pushCall) -> Self { + (value.cid,) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for pushCall { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { cid: tuple.0 } + } + } + } + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = ( + ::alloy_sol_types::sol_data::Bytes, + ::alloy_sol_types::sol_data::Uint<64>, + ); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = (::alloy_sol_types::private::Bytes, u64); + #[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: pushReturn) -> Self { + (value.root, value.index) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for pushReturn { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { + root: tuple.0, + index: tuple.1, + } + } + } + } + #[automatically_derived] + impl alloy_sol_types::SolCall for pushCall { + type Parameters<'a> = (::alloy_sol_types::sol_data::Bytes,); + type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; + type Return = pushReturn; + type ReturnTuple<'a> = ( + ::alloy_sol_types::sol_data::Bytes, + ::alloy_sol_types::sol_data::Uint<64>, + ); + type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; + const SIGNATURE: &'static str = "push(bytes)"; + const SELECTOR: [u8; 4] = [125u8, 172u8, 218u8, 3u8]; + #[inline] + fn new<'a>( + tuple: as alloy_sol_types::SolType>::RustType, + ) -> Self { + tuple.into() + } + #[inline] + fn tokenize(&self) -> Self::Token<'_> { + ( + <::alloy_sol_types::sol_data::Bytes as alloy_sol_types::SolType>::tokenize( + &self.cid, + ), + ) + } + #[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 [`ITimehubFacade`](self) function calls. + pub enum ITimehubFacadeCalls { + #[allow(missing_docs)] + getCount(getCountCall), + #[allow(missing_docs)] + getLeafAt(getLeafAtCall), + #[allow(missing_docs)] + getPeaks(getPeaksCall), + #[allow(missing_docs)] + getRoot(getRootCall), + #[allow(missing_docs)] + push(pushCall), + } + #[automatically_derived] + impl ITimehubFacadeCalls { + /// 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]] = &[ + [10u8, 224u8, 111u8, 186u8], + [25u8, 250u8, 73u8, 102u8], + [92u8, 161u8, 225u8, 101u8], + [125u8, 172u8, 218u8, 3u8], + [168u8, 125u8, 148u8, 44u8], + ]; + } + #[automatically_derived] + impl alloy_sol_types::SolInterface for ITimehubFacadeCalls { + const NAME: &'static str = "ITimehubFacadeCalls"; + const MIN_DATA_LENGTH: usize = 0usize; + const COUNT: usize = 5usize; + #[inline] + fn selector(&self) -> [u8; 4] { + match self { + Self::getCount(_) => ::SELECTOR, + Self::getLeafAt(_) => { + ::SELECTOR + } + Self::getPeaks(_) => ::SELECTOR, + Self::getRoot(_) => ::SELECTOR, + Self::push(_) => ::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(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 getPeaks( + data: &[u8], + validate: bool, + ) -> alloy_sol_types::Result { + ::abi_decode_raw( + data, + validate, + ) + .map(ITimehubFacadeCalls::getPeaks) + } + getPeaks + }, + { + fn getLeafAt( + data: &[u8], + validate: bool, + ) -> alloy_sol_types::Result { + ::abi_decode_raw( + data, + validate, + ) + .map(ITimehubFacadeCalls::getLeafAt) + } + getLeafAt + }, + { + fn getRoot( + data: &[u8], + validate: bool, + ) -> alloy_sol_types::Result { + ::abi_decode_raw( + data, + validate, + ) + .map(ITimehubFacadeCalls::getRoot) + } + getRoot + }, + { + fn push( + data: &[u8], + validate: bool, + ) -> alloy_sol_types::Result { + ::abi_decode_raw( + data, + validate, + ) + .map(ITimehubFacadeCalls::push) + } + push + }, + { + fn getCount( + data: &[u8], + validate: bool, + ) -> alloy_sol_types::Result { + ::abi_decode_raw( + data, + validate, + ) + .map(ITimehubFacadeCalls::getCount) + } + getCount + }, + ]; + let Ok(idx) = Self::SELECTORS.binary_search(&selector) else { + return Err( + alloy_sol_types::Error::unknown_selector( + ::NAME, + selector, + ), + ); + }; + DECODE_SHIMS[idx](data, validate) + } + #[inline] + fn abi_encoded_size(&self) -> usize { + match self { + Self::getCount(inner) => { + ::abi_encoded_size(inner) + } + Self::getLeafAt(inner) => { + ::abi_encoded_size(inner) + } + Self::getPeaks(inner) => { + ::abi_encoded_size(inner) + } + Self::getRoot(inner) => { + ::abi_encoded_size(inner) + } + Self::push(inner) => { + ::abi_encoded_size(inner) + } + } + } + #[inline] + fn abi_encode_raw(&self, out: &mut alloy_sol_types::private::Vec) { + match self { + Self::getCount(inner) => { + ::abi_encode_raw( + inner, + out, + ) + } + Self::getLeafAt(inner) => { + ::abi_encode_raw( + inner, + out, + ) + } + Self::getPeaks(inner) => { + ::abi_encode_raw( + inner, + out, + ) + } + Self::getRoot(inner) => { + ::abi_encode_raw(inner, out) + } + Self::push(inner) => { + ::abi_encode_raw(inner, out) + } + } + } + } ///Container for all the [`ITimehubFacade`](self) events. pub enum ITimehubFacadeEvents { #[allow(missing_docs)] diff --git a/src/interfaces/facades/ITimehubFacade.sol b/src/interfaces/facades/ITimehubFacade.sol index 32ceddb..0fabae9 100644 --- a/src/interfaces/facades/ITimehubFacade.sol +++ b/src/interfaces/facades/ITimehubFacade.sol @@ -7,4 +7,10 @@ interface ITimehubFacade { /// @param timestamp Event timestamp. /// @param cid Event Cid. event EventPushed(uint256 index, uint256 timestamp, bytes cid); + + function push(bytes memory cid) external returns (bytes memory root, uint64 index); + function getLeafAt(uint64 index) external view returns (uint64 timestamp, bytes memory witnessed); + function getRoot() external view returns (bytes memory cid); + function getPeaks() external view returns (bytes[] memory cids); + function getCount() external view returns (uint64); }