1pub use ckb_light_client_contract::*;
2#[allow(
5 clippy::enum_variant_names,
6 clippy::too_many_arguments,
7 clippy::upper_case_acronyms,
8 clippy::type_complexity,
9 dead_code,
10 non_camel_case_types
11)]
12pub mod ckb_light_client_contract {
13 use std::prelude::v1::*;
14
15 #[rustfmt::skip]
16 const __ABI: &str = "[\n {\n \"inputs\": [\n {\n \"internalType\": \"bytes32[]\",\n \"name\": \"blockHashes\",\n \"type\": \"bytes32[]\"\n }\n ],\n \"name\": \"rollback\",\n \"outputs\": [],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"allowRead\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"setState\",\n \"outputs\": [],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"components\": [\n {\n \"internalType\": \"uint32\",\n \"name\": \"version\",\n \"type\": \"uint32\"\n },\n {\n \"internalType\": \"uint32\",\n \"name\": \"compactTarget\",\n \"type\": \"uint32\"\n },\n {\n \"internalType\": \"uint64\",\n \"name\": \"timestamp\",\n \"type\": \"uint64\"\n },\n {\n \"internalType\": \"uint64\",\n \"name\": \"number\",\n \"type\": \"uint64\"\n },\n {\n \"internalType\": \"uint64\",\n \"name\": \"epoch\",\n \"type\": \"uint64\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"parentHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"transactionsRoot\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"proposalsHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"extraHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"dao\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"uint128\",\n \"name\": \"nonce\",\n \"type\": \"uint128\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"extension\",\n \"type\": \"bytes\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"blockHash\",\n \"type\": \"bytes32\"\n }\n ],\n \"internalType\": \"struct CkbType.Header[]\",\n \"name\": \"headers\",\n \"type\": \"tuple[]\"\n }\n ],\n \"name\": \"update\",\n \"outputs\": [],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n }\n]\n";
17 pub static CKBLIGHTCLIENTCONTRACT_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> =
19 ::ethers::contract::Lazy::new(|| {
20 ::ethers::core::utils::__serde_json::from_str(__ABI).expect("ABI is always valid")
21 });
22 pub struct CkbLightClientContract<M>(::ethers::contract::Contract<M>);
23 impl<M> ::core::clone::Clone for CkbLightClientContract<M> {
24 fn clone(&self) -> Self {
25 Self(::core::clone::Clone::clone(&self.0))
26 }
27 }
28 impl<M> ::core::ops::Deref for CkbLightClientContract<M> {
29 type Target = ::ethers::contract::Contract<M>;
30
31 fn deref(&self) -> &Self::Target {
32 &self.0
33 }
34 }
35 impl<M> ::core::ops::DerefMut for CkbLightClientContract<M> {
36 fn deref_mut(&mut self) -> &mut Self::Target {
37 &mut self.0
38 }
39 }
40 impl<M> ::core::fmt::Debug for CkbLightClientContract<M> {
41 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
42 f.debug_tuple(stringify!(CkbLightClientContract))
43 .field(&self.address())
44 .finish()
45 }
46 }
47 impl<M: ::ethers::providers::Middleware> CkbLightClientContract<M> {
48 pub fn new<T: Into<::ethers::core::types::Address>>(
52 address: T,
53 client: ::std::sync::Arc<M>,
54 ) -> Self {
55 Self(::ethers::contract::Contract::new(
56 address.into(),
57 CKBLIGHTCLIENTCONTRACT_ABI.clone(),
58 client,
59 ))
60 }
61
62 pub fn rollback(
64 &self,
65 block_hashes: ::std::vec::Vec<[u8; 32]>,
66 ) -> ::ethers::contract::builders::ContractCall<M, ()> {
67 self.0
68 .method_hash([211, 42, 34, 133], block_hashes)
69 .expect("method not found (this should never happen)")
70 }
71
72 pub fn set_state(
74 &self,
75 allow_read: bool,
76 ) -> ::ethers::contract::builders::ContractCall<M, ()> {
77 self.0
78 .method_hash([172, 159, 2, 34], allow_read)
79 .expect("method not found (this should never happen)")
80 }
81
82 pub fn update(
84 &self,
85 headers: ::std::vec::Vec<Header>,
86 ) -> ::ethers::contract::builders::ContractCall<M, ()> {
87 self.0
88 .method_hash([93, 78, 132, 66], headers)
89 .expect("method not found (this should never happen)")
90 }
91 }
92 impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>>
93 for CkbLightClientContract<M>
94 {
95 fn from(contract: ::ethers::contract::Contract<M>) -> Self {
96 Self::new(contract.address(), contract.client())
97 }
98 }
99 #[derive(
102 Clone,
103 ::ethers::contract::EthCall,
104 ::ethers::contract::EthDisplay,
105 Default,
106 Debug,
107 PartialEq,
108 Eq,
109 Hash,
110 )]
111 #[ethcall(name = "rollback", abi = "rollback(bytes32[])")]
112 pub struct RollbackCall {
113 pub block_hashes: ::std::vec::Vec<[u8; 32]>,
114 }
115 #[derive(
118 Clone,
119 ::ethers::contract::EthCall,
120 ::ethers::contract::EthDisplay,
121 Default,
122 Debug,
123 PartialEq,
124 Eq,
125 Hash,
126 )]
127 #[ethcall(name = "setState", abi = "setState(bool)")]
128 pub struct SetStateCall {
129 pub allow_read: bool,
130 }
131 #[derive(Clone, ::ethers::contract::EthCall, ::ethers::contract::EthDisplay)]
136 #[ethcall(
137 name = "update",
138 abi = "update((uint32,uint32,uint64,uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32,uint128,bytes,bytes32)[])"
139 )]
140 pub struct UpdateCall {
141 pub headers: ::std::vec::Vec<Header>,
142 }
143 #[derive(Clone, ::ethers::contract::EthAbiType)]
145 pub enum CkbLightClientContractCalls {
146 Rollback(RollbackCall),
147 SetState(SetStateCall),
148 Update(UpdateCall),
149 }
150 impl ::ethers::core::abi::AbiDecode for CkbLightClientContractCalls {
151 fn decode(
152 data: impl AsRef<[u8]>,
153 ) -> ::core::result::Result<Self, ::ethers::core::abi::AbiError> {
154 let data = data.as_ref();
155 if let Ok(decoded) = <RollbackCall as ::ethers::core::abi::AbiDecode>::decode(data) {
156 return Ok(Self::Rollback(decoded));
157 }
158 if let Ok(decoded) = <SetStateCall as ::ethers::core::abi::AbiDecode>::decode(data) {
159 return Ok(Self::SetState(decoded));
160 }
161 if let Ok(decoded) = <UpdateCall as ::ethers::core::abi::AbiDecode>::decode(data) {
162 return Ok(Self::Update(decoded));
163 }
164 Err(::ethers::core::abi::Error::InvalidData.into())
165 }
166 }
167 impl ::ethers::core::abi::AbiEncode for CkbLightClientContractCalls {
168 fn encode(self) -> Vec<u8> {
169 match self {
170 Self::Rollback(element) => ::ethers::core::abi::AbiEncode::encode(element),
171 Self::SetState(element) => ::ethers::core::abi::AbiEncode::encode(element),
172 Self::Update(element) => ::ethers::core::abi::AbiEncode::encode(element),
173 }
174 }
175 }
176 impl ::core::fmt::Display for CkbLightClientContractCalls {
177 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
178 match self {
179 Self::Rollback(element) => ::core::fmt::Display::fmt(element, f),
180 Self::SetState(element) => ::core::fmt::Display::fmt(element, f),
181 Self::Update(element) => ::core::fmt::Display::fmt(element, f),
182 }
183 }
184 }
185 impl ::core::convert::From<RollbackCall> for CkbLightClientContractCalls {
186 fn from(value: RollbackCall) -> Self {
187 Self::Rollback(value)
188 }
189 }
190 impl ::core::convert::From<SetStateCall> for CkbLightClientContractCalls {
191 fn from(value: SetStateCall) -> Self {
192 Self::SetState(value)
193 }
194 }
195 impl ::core::convert::From<UpdateCall> for CkbLightClientContractCalls {
196 fn from(value: UpdateCall) -> Self {
197 Self::Update(value)
198 }
199 }
200 #[derive(
203 Clone,
204 ::ethers::contract::EthAbiType,
205 ::ethers::contract::EthAbiCodec,
206 Default,
207 Debug,
208 PartialEq,
209 Eq,
210 Hash,
211 )]
212 pub struct Header {
213 pub version: u32,
214 pub compact_target: u32,
215 pub timestamp: u64,
216 pub number: u64,
217 pub epoch: u64,
218 pub parent_hash: [u8; 32],
219 pub transactions_root: [u8; 32],
220 pub proposals_hash: [u8; 32],
221 pub extra_hash: [u8; 32],
222 pub dao: [u8; 32],
223 pub nonce: u128,
224 pub extension: ::ethers::core::types::Bytes,
225 pub block_hash: [u8; 32],
226 }
227}