diff --git a/crates/relayer/src/chain/axon.rs b/crates/relayer/src/chain/axon.rs index ff61f567a..29841354f 100644 --- a/crates/relayer/src/chain/axon.rs +++ b/crates/relayer/src/chain/axon.rs @@ -43,9 +43,7 @@ use ibc_proto::{ use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, clients::ics07_axon::{ - client_state::AxonClientState, - consensus_state::AxonConsensusState, - header::{AxonHeader, AXON_HEADER_TYPE_URL}, + client_state::AxonClientState, consensus_state::AxonConsensusState, header::AxonHeader, light_block::AxonLightBlock, }, core::{ @@ -1190,7 +1188,8 @@ impl AxonChain { let cell_process_manager = CellProcessManager::new( self.rt.clone(), &self.config.emitter_ckb_url.to_string(), - self.client.clone(), + self.chain_id, + self.contract_provider()?, self.config.emitter_scan_start_block_number, ); @@ -1198,7 +1197,6 @@ impl AxonChain { self.config.id.clone(), self.config.websocket_addr.clone(), self.config.contract_address, - // header_receiver, self.rt.clone(), ibc_cache.clone(), cell_process_manager, @@ -1388,24 +1386,6 @@ impl AxonChain { create_client::TYPE_URL => { convert!(self, msg, MsgCreateClient, create_client) } - // TODO: this update_client uses Hermes internal message to handle the Axon-specific function, - // so maybe there is possibility to create a new one to do so - update_client::TYPE_URL => { - let msg = update_client::MsgUpdateClient::from_any(msg) - .map_err(|e| Error::protobuf_decode(update_client::TYPE_URL.to_string(), e))?; - let bytes = msg.header.value.as_slice(); - let type_url = msg.header.type_url; - let to = match type_url.as_str() { - AXON_HEADER_TYPE_URL => self.config.ckb_light_client_contract_address, - "CELL_TYPE_URL" => self.config.image_cell_contract_address, - type_url => { - return Err(Error::other_error(format!("unknown type_url {type_url}"))) - } - }; - let tx = TransactionRequest::new().to(to).data(bytes.to_vec()); - self.rt - .block_on(async { Ok(self.client.send_transaction(tx, None).await?.await?) }) - } // connection conn_open_init::TYPE_URL => { convert!(self, msg, MsgConnectionOpenInit, connection_open_init) diff --git a/crates/relayer/src/chain/axon/contract/abi/ImageCellContract.json b/crates/relayer/src/chain/axon/contract/abi/ImageCellContract.json new file mode 100644 index 000000000..e9d629355 --- /dev/null +++ b/crates/relayer/src/chain/axon/contract/abi/ImageCellContract.json @@ -0,0 +1,189 @@ +{ + "contractName": "image_cell_contract", + "abi": [ + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "index", + "type": "uint32" + } + ], + "internalType": "struct CkbType.OutPoint[]", + "name": "txInputs", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "index", + "type": "uint32" + } + ], + "internalType": "struct CkbType.OutPoint[]", + "name": "txOutputs", + "type": "tuple[]" + } + ], + "internalType": "struct ImageCell.BlockRollBlack[]", + "name": "blocks", + "type": "tuple[]" + } + ], + "name": "rollback", + "outputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "allowRead", + "type": "bool" + } + ], + "name": "setState", + "outputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "blockNumber", + "type": "uint64" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "index", + "type": "uint32" + } + ], + "internalType": "struct CkbType.OutPoint[]", + "name": "txInputs", + "type": "tuple[]" + }, + { + "components": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "index", + "type": "uint32" + } + ], + "internalType": "struct CkbType.OutPoint", + "name": "outPoint", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "capacity", + "type": "uint64" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "codeHash", + "type": "bytes32" + }, + { + "internalType": "enum CkbType.ScriptHashType", + "name": "hashType", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "args", + "type": "bytes" + } + ], + "internalType": "struct CkbType.Script", + "name": "lock", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "codeHash", + "type": "bytes32" + }, + { + "internalType": "enum CkbType.ScriptHashType", + "name": "hashType", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "args", + "type": "bytes" + } + ], + "internalType": "struct CkbType.Script[]", + "name": "type_", + "type": "tuple[]" + } + ], + "internalType": "struct CkbType.CellOutput", + "name": "output", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct CkbType.CellInfo[]", + "name": "txOutputs", + "type": "tuple[]" + } + ], + "internalType": "struct ImageCell.BlockUpdate[]", + "name": "blocks", + "type": "tuple[]" + } + ], + "name": "update", + "outputs": [], + "stateMutability": "view", + "type": "function" + } + ] +} diff --git a/crates/relayer/src/chain/axon/contract/abi/LightClientContract.json b/crates/relayer/src/chain/axon/contract/abi/LightClientContract.json new file mode 100644 index 000000000..998d00b52 --- /dev/null +++ b/crates/relayer/src/chain/axon/contract/abi/LightClientContract.json @@ -0,0 +1,106 @@ +{ + "contractName": "ckb_light_client_contract", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "blockHashs", + "type": "bytes32[]" + } + ], + "name": "rollback", + "outputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "allowRead", + "type": "bool" + } + ], + "name": "setState", + "outputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "version", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "compactTarget", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "number", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "epoch", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "parentHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "transactionsRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "proposalsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "unclesHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "dao", + "type": "bytes32" + }, + { + "internalType": "uint128", + "name": "nonce", + "type": "uint128" + }, + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "internalType": "struct CkbType.Header[]", + "name": "headers", + "type": "tuple[]" + } + ], + "name": "update", + "outputs": [], + "stateMutability": "view", + "type": "function" + } + ] +} diff --git a/crates/relayer/src/chain/axon/contract/OwnableIBCHandler.json b/crates/relayer/src/chain/axon/contract/abi/OwnableIBCHandler.json similarity index 100% rename from crates/relayer/src/chain/axon/contract/OwnableIBCHandler.json rename to crates/relayer/src/chain/axon/contract/abi/OwnableIBCHandler.json diff --git a/crates/relayer/src/chain/axon/contract/ckb_light_client.rs b/crates/relayer/src/chain/axon/contract/ckb_light_client.rs new file mode 100644 index 000000000..a136be6e3 --- /dev/null +++ b/crates/relayer/src/chain/axon/contract/ckb_light_client.rs @@ -0,0 +1,302 @@ +pub use ckb_light_client_contract::*; +/// 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 ckb_light_client_contract { + const _: () = { + ::core::include_bytes!("abi/LightClientContract.json",); + }; + #[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("rollback"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("rollback"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("blockHashs"), + kind: ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ), + ), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes32[]"), + ), + },], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("setState"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("setState"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("allowRead"), + kind: ::ethers::core::abi::ethabi::ParamType::Bool, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bool"), + ), + },], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("update"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("update"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("headers"), + kind: ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Tuple(::std::vec![ + ::ethers::core::abi::ethabi::ParamType::Uint(32usize), + ::ethers::core::abi::ethabi::ParamType::Uint(32usize), + ::ethers::core::abi::ethabi::ParamType::Uint(64usize), + ::ethers::core::abi::ethabi::ParamType::Uint(64usize), + ::ethers::core::abi::ethabi::ParamType::Uint(64usize), + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::Uint(128usize), + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ],), + ), + ), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("struct CkbType.Header[]"), + ), + },], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ]), + events: ::std::collections::BTreeMap::new(), + errors: ::std::collections::BTreeMap::new(), + receive: false, + fallback: false, + } + } + ///The parsed JSON ABI of the contract. + pub static CKB_LIGHT_CLIENT_CONTRACT_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = + ::ethers::contract::Lazy::new(__abi); + pub struct ckb_light_client_contract(::ethers::contract::Contract); + impl ::core::clone::Clone for ckb_light_client_contract { + fn clone(&self) -> Self { + Self(::core::clone::Clone::clone(&self.0)) + } + } + impl ::core::ops::Deref for ckb_light_client_contract { + type Target = ::ethers::contract::Contract; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + impl ::core::ops::DerefMut for ckb_light_client_contract { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + impl ::core::fmt::Debug for ckb_light_client_contract { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_tuple(::core::stringify!(ckb_light_client_contract)) + .field(&self.address()) + .finish() + } + } + impl ckb_light_client_contract { + /// 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(), + CKB_LIGHT_CLIENT_CONTRACT_ABI.clone(), + client, + )) + } + ///Calls the contract's `rollback` (0xd32a2285) function + pub fn rollback( + &self, + block_hashs: ::std::vec::Vec<[u8; 32]>, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([211, 42, 34, 133], block_hashs) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `setState` (0xac9f0222) function + pub fn set_state( + &self, + allow_read: bool, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([172, 159, 2, 34], allow_read) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `update` (0x2b196cf3) function + pub fn update( + &self, + headers: ::std::vec::Vec
, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([43, 25, 108, 243], headers) + .expect("method not found (this should never happen)") + } + } + impl From<::ethers::contract::Contract> + for ckb_light_client_contract + { + fn from(contract: ::ethers::contract::Contract) -> Self { + Self::new(contract.address(), contract.client()) + } + } + ///Container type for all input parameters for the `rollback` function with signature `rollback(bytes32[])` and selector `0xd32a2285` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "rollback", abi = "rollback(bytes32[])")] + pub struct RollbackCall { + pub block_hashs: ::std::vec::Vec<[u8; 32]>, + } + ///Container type for all input parameters for the `setState` function with signature `setState(bool)` and selector `0xac9f0222` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "setState", abi = "setState(bool)")] + pub struct SetStateCall { + pub allow_read: bool, + } + ///Container type for all input parameters for the `update` function with signature `update((uint32,uint32,uint64,uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32,uint128,bytes32)[])` and selector `0x2b196cf3` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall( + name = "update", + abi = "update((uint32,uint32,uint64,uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32,uint128,bytes32)[])" + )] + pub struct UpdateCall { + pub headers: ::std::vec::Vec
, + } + ///Container type for all of the contract's call + #[derive(Clone, ::ethers::contract::EthAbiType, Debug, PartialEq, Eq, Hash)] + pub enum ckb_light_client_contractCalls { + Rollback(RollbackCall), + SetState(SetStateCall), + Update(UpdateCall), + } + impl ::ethers::core::abi::AbiDecode for ckb_light_client_contractCalls { + fn decode( + data: impl AsRef<[u8]>, + ) -> ::core::result::Result { + let data = data.as_ref(); + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Rollback(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::SetState(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Update(decoded)); + } + Err(::ethers::core::abi::Error::InvalidData.into()) + } + } + impl ::ethers::core::abi::AbiEncode for ckb_light_client_contractCalls { + fn encode(self) -> Vec { + match self { + Self::Rollback(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::SetState(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Update(element) => ::ethers::core::abi::AbiEncode::encode(element), + } + } + } + impl ::core::fmt::Display for ckb_light_client_contractCalls { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Self::Rollback(element) => ::core::fmt::Display::fmt(element, f), + Self::SetState(element) => ::core::fmt::Display::fmt(element, f), + Self::Update(element) => ::core::fmt::Display::fmt(element, f), + } + } + } + impl ::core::convert::From for ckb_light_client_contractCalls { + fn from(value: RollbackCall) -> Self { + Self::Rollback(value) + } + } + impl ::core::convert::From for ckb_light_client_contractCalls { + fn from(value: SetStateCall) -> Self { + Self::SetState(value) + } + } + impl ::core::convert::From for ckb_light_client_contractCalls { + fn from(value: UpdateCall) -> Self { + Self::Update(value) + } + } + ///`Header(uint32,uint32,uint64,uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32,uint128,bytes32)` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct Header { + pub version: u32, + pub compact_target: u32, + pub timestamp: u64, + pub number: u64, + pub epoch: u64, + pub parent_hash: [u8; 32], + pub transactions_root: [u8; 32], + pub proposals_hash: [u8; 32], + pub uncles_hash: [u8; 32], + pub dao: [u8; 32], + pub nonce: u128, + pub block_hash: [u8; 32], + } +} diff --git a/crates/relayer/src/chain/axon/contract/generate.rs b/crates/relayer/src/chain/axon/contract/ibc_handler.rs similarity index 99% rename from crates/relayer/src/chain/axon/contract/generate.rs rename to crates/relayer/src/chain/axon/contract/ibc_handler.rs index 4ab11930b..2e0f99b87 100644 --- a/crates/relayer/src/chain/axon/contract/generate.rs +++ b/crates/relayer/src/chain/axon/contract/ibc_handler.rs @@ -11,7 +11,7 @@ pub use ownable_ibc_handler::*; )] pub mod ownable_ibc_handler { const _: () = { - ::core::include_bytes!("OwnableIBCHandler.json",); + ::core::include_bytes!("abi/OwnableIBCHandler.json",); }; #[allow(deprecated)] fn __abi() -> ::ethers::core::abi::Abi { diff --git a/crates/relayer/src/chain/axon/contract/image_cell.rs b/crates/relayer/src/chain/axon/contract/image_cell.rs new file mode 100644 index 000000000..7c336c640 --- /dev/null +++ b/crates/relayer/src/chain/axon/contract/image_cell.rs @@ -0,0 +1,452 @@ +pub use image_cell_contract::*; +/// 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 image_cell_contract { + const _: () = { + ::core::include_bytes!("abi/ImageCellContract.json",); + }; + #[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("rollback"), + ::std::vec![ + ::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("rollback"), + inputs: ::std::vec![ + ::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("blocks"), + kind: ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::Uint(32usize), + ], + ), + ), + ), + ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::Uint(32usize), + ], + ), + ), + ), + ], + ), + ), + ), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned( + "struct ImageCell.BlockRollBlack[]", + ), + ), + }, + ], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + }, + ], + ), + ( + ::std::borrow::ToOwned::to_owned("setState"), + ::std::vec![ + ::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("setState"), + inputs: ::std::vec![ + ::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("allowRead"), + kind: ::ethers::core::abi::ethabi::ParamType::Bool, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bool"), + ), + }, + ], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + }, + ], + ), + ( + ::std::borrow::ToOwned::to_owned("update"), + ::std::vec![ + ::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("update"), + inputs: ::std::vec![ + ::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("blocks"), + kind: ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers::core::abi::ethabi::ParamType::Uint(64usize), + ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::Uint(32usize), + ], + ), + ), + ), + ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers::core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::Uint(32usize), + ], + ), + ::ethers::core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers::core::abi::ethabi::ParamType::Uint(64usize), + ::ethers::core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::Uint(8usize), + ::ethers::core::abi::ethabi::ParamType::Bytes, + ], + ), + ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers::core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers::core::abi::ethabi::ParamType::Uint(8usize), + ::ethers::core::abi::ethabi::ParamType::Bytes, + ], + ), + ), + ), + ], + ), + ::ethers::core::abi::ethabi::ParamType::Bytes, + ], + ), + ), + ), + ], + ), + ), + ), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned( + "struct ImageCell.BlockUpdate[]", + ), + ), + }, + ], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + }, + ], + ), + ]), + events: ::std::collections::BTreeMap::new(), + errors: ::std::collections::BTreeMap::new(), + receive: false, + fallback: false, + } + } + ///The parsed JSON ABI of the contract. + pub static IMAGE_CELL_CONTRACT_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = + ::ethers::contract::Lazy::new(__abi); + pub struct image_cell_contract(::ethers::contract::Contract); + impl ::core::clone::Clone for image_cell_contract { + fn clone(&self) -> Self { + Self(::core::clone::Clone::clone(&self.0)) + } + } + impl ::core::ops::Deref for image_cell_contract { + type Target = ::ethers::contract::Contract; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + impl ::core::ops::DerefMut for image_cell_contract { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + impl ::core::fmt::Debug for image_cell_contract { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_tuple(::core::stringify!(image_cell_contract)) + .field(&self.address()) + .finish() + } + } + impl image_cell_contract { + /// 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(), + IMAGE_CELL_CONTRACT_ABI.clone(), + client, + )) + } + ///Calls the contract's `rollback` (0x08c17228) function + pub fn rollback( + &self, + blocks: ::std::vec::Vec, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([8, 193, 114, 40], blocks) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `setState` (0xac9f0222) function + pub fn set_state( + &self, + allow_read: bool, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([172, 159, 2, 34], allow_read) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `update` (0xafa74e04) function + pub fn update( + &self, + blocks: ::std::vec::Vec, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([175, 167, 78, 4], blocks) + .expect("method not found (this should never happen)") + } + } + impl From<::ethers::contract::Contract> + for image_cell_contract + { + fn from(contract: ::ethers::contract::Contract) -> Self { + Self::new(contract.address(), contract.client()) + } + } + ///Container type for all input parameters for the `rollback` function with signature `rollback(((bytes32,uint32)[],(bytes32,uint32)[])[])` and selector `0x08c17228` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall( + name = "rollback", + abi = "rollback(((bytes32,uint32)[],(bytes32,uint32)[])[])" + )] + pub struct RollbackCall { + pub blocks: ::std::vec::Vec, + } + ///Container type for all input parameters for the `setState` function with signature `setState(bool)` and selector `0xac9f0222` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "setState", abi = "setState(bool)")] + pub struct SetStateCall { + pub allow_read: bool, + } + ///Container type for all input parameters for the `update` function with signature `update((uint64,(bytes32,uint32)[],((bytes32,uint32),(uint64,(bytes32,uint8,bytes),(bytes32,uint8,bytes)[]),bytes)[])[])` and selector `0xafa74e04` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall( + name = "update", + abi = "update((uint64,(bytes32,uint32)[],((bytes32,uint32),(uint64,(bytes32,uint8,bytes),(bytes32,uint8,bytes)[]),bytes)[])[])" + )] + pub struct UpdateCall { + pub blocks: ::std::vec::Vec, + } + ///Container type for all of the contract's call + #[derive(Clone, ::ethers::contract::EthAbiType, Debug, PartialEq, Eq, Hash)] + pub enum image_cell_contractCalls { + Rollback(RollbackCall), + SetState(SetStateCall), + Update(UpdateCall), + } + impl ::ethers::core::abi::AbiDecode for image_cell_contractCalls { + fn decode( + data: impl AsRef<[u8]>, + ) -> ::core::result::Result { + let data = data.as_ref(); + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Rollback(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::SetState(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Update(decoded)); + } + Err(::ethers::core::abi::Error::InvalidData.into()) + } + } + impl ::ethers::core::abi::AbiEncode for image_cell_contractCalls { + fn encode(self) -> Vec { + match self { + Self::Rollback(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::SetState(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Update(element) => ::ethers::core::abi::AbiEncode::encode(element), + } + } + } + impl ::core::fmt::Display for image_cell_contractCalls { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Self::Rollback(element) => ::core::fmt::Display::fmt(element, f), + Self::SetState(element) => ::core::fmt::Display::fmt(element, f), + Self::Update(element) => ::core::fmt::Display::fmt(element, f), + } + } + } + impl ::core::convert::From for image_cell_contractCalls { + fn from(value: RollbackCall) -> Self { + Self::Rollback(value) + } + } + impl ::core::convert::From for image_cell_contractCalls { + fn from(value: SetStateCall) -> Self { + Self::SetState(value) + } + } + impl ::core::convert::From for image_cell_contractCalls { + fn from(value: UpdateCall) -> Self { + Self::Update(value) + } + } + ///`CellInfo((bytes32,uint32),(uint64,(bytes32,uint8,bytes),(bytes32,uint8,bytes)[]),bytes)` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct CellInfo { + pub out_point: OutPoint, + pub output: CellOutput, + pub data: ::ethers::core::types::Bytes, + } + ///`CellOutput(uint64,(bytes32,uint8,bytes),(bytes32,uint8,bytes)[])` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct CellOutput { + pub capacity: u64, + pub lock: Script, + pub type_: ::std::vec::Vec