axon_abi/
image_cell_abi.rs

1pub use image_cell_contract::*;
2/// This module was auto-generated with ethers-rs Abigen.
3/// More information at: <https://github.com/gakonst/ethers-rs>
4#[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 image_cell_contract {
13    use std::prelude::v1::*;
14
15    #[rustfmt::skip]
16    const __ABI: &str = "[\n  {\n    \"inputs\": [\n      {\n        \"components\": [\n          {\n            \"components\": [\n              {\n                \"internalType\": \"bytes32\",\n                \"name\": \"txHash\",\n                \"type\": \"bytes32\"\n              },\n              {\n                \"internalType\": \"uint32\",\n                \"name\": \"index\",\n                \"type\": \"uint32\"\n              }\n            ],\n            \"internalType\": \"struct CkbType.OutPoint[]\",\n            \"name\": \"txInputs\",\n            \"type\": \"tuple[]\"\n          },\n          {\n            \"components\": [\n              {\n                \"internalType\": \"bytes32\",\n                \"name\": \"txHash\",\n                \"type\": \"bytes32\"\n              },\n              {\n                \"internalType\": \"uint32\",\n                \"name\": \"index\",\n                \"type\": \"uint32\"\n              }\n            ],\n            \"internalType\": \"struct CkbType.OutPoint[]\",\n            \"name\": \"txOutputs\",\n            \"type\": \"tuple[]\"\n          }\n        ],\n        \"internalType\": \"struct ImageCell.BlockRollBlack[]\",\n        \"name\": \"blocks\",\n        \"type\": \"tuple[]\"\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\": \"uint64\",\n            \"name\": \"blockNumber\",\n            \"type\": \"uint64\"\n          },\n          {\n            \"components\": [\n              {\n                \"internalType\": \"bytes32\",\n                \"name\": \"txHash\",\n                \"type\": \"bytes32\"\n              },\n              {\n                \"internalType\": \"uint32\",\n                \"name\": \"index\",\n                \"type\": \"uint32\"\n              }\n            ],\n            \"internalType\": \"struct CkbType.OutPoint[]\",\n            \"name\": \"txInputs\",\n            \"type\": \"tuple[]\"\n          },\n          {\n            \"components\": [\n              {\n                \"components\": [\n                  {\n                    \"internalType\": \"bytes32\",\n                    \"name\": \"txHash\",\n                    \"type\": \"bytes32\"\n                  },\n                  {\n                    \"internalType\": \"uint32\",\n                    \"name\": \"index\",\n                    \"type\": \"uint32\"\n                  }\n                ],\n                \"internalType\": \"struct CkbType.OutPoint\",\n                \"name\": \"outPoint\",\n                \"type\": \"tuple\"\n              },\n              {\n                \"components\": [\n                  {\n                    \"internalType\": \"uint64\",\n                    \"name\": \"capacity\",\n                    \"type\": \"uint64\"\n                  },\n                  {\n                    \"components\": [\n                      {\n                        \"internalType\": \"bytes32\",\n                        \"name\": \"codeHash\",\n                        \"type\": \"bytes32\"\n                      },\n                      {\n                        \"internalType\": \"enum CkbType.ScriptHashType\",\n                        \"name\": \"hashType\",\n                        \"type\": \"uint8\"\n                      },\n                      {\n                        \"internalType\": \"bytes\",\n                        \"name\": \"args\",\n                        \"type\": \"bytes\"\n                      }\n                    ],\n                    \"internalType\": \"struct CkbType.Script\",\n                    \"name\": \"lock\",\n                    \"type\": \"tuple\"\n                  },\n                  {\n                    \"components\": [\n                      {\n                        \"internalType\": \"bytes32\",\n                        \"name\": \"codeHash\",\n                        \"type\": \"bytes32\"\n                      },\n                      {\n                        \"internalType\": \"enum CkbType.ScriptHashType\",\n                        \"name\": \"hashType\",\n                        \"type\": \"uint8\"\n                      },\n                      {\n                        \"internalType\": \"bytes\",\n                        \"name\": \"args\",\n                        \"type\": \"bytes\"\n                      }\n                    ],\n                    \"internalType\": \"struct CkbType.Script[]\",\n                    \"name\": \"type_\",\n                    \"type\": \"tuple[]\"\n                  }\n                ],\n                \"internalType\": \"struct CkbType.CellOutput\",\n                \"name\": \"output\",\n                \"type\": \"tuple\"\n              },\n              {\n                \"internalType\": \"bytes\",\n                \"name\": \"data\",\n                \"type\": \"bytes\"\n              }\n            ],\n            \"internalType\": \"struct CkbType.CellInfo[]\",\n            \"name\": \"txOutputs\",\n            \"type\": \"tuple[]\"\n          }\n        ],\n        \"internalType\": \"struct ImageCell.BlockUpdate[]\",\n        \"name\": \"blocks\",\n        \"type\": \"tuple[]\"\n      }\n    ],\n    \"name\": \"update\",\n    \"outputs\": [],\n    \"stateMutability\": \"view\",\n    \"type\": \"function\"\n  }\n]\n";
17    /// The parsed JSON ABI of the contract.
18    pub static IMAGECELLCONTRACT_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 ImageCellContract<M>(::ethers::contract::Contract<M>);
23    impl<M> ::core::clone::Clone for ImageCellContract<M> {
24        fn clone(&self) -> Self {
25            Self(::core::clone::Clone::clone(&self.0))
26        }
27    }
28    impl<M> ::core::ops::Deref for ImageCellContract<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 ImageCellContract<M> {
36        fn deref_mut(&mut self) -> &mut Self::Target {
37            &mut self.0
38        }
39    }
40    impl<M> ::core::fmt::Debug for ImageCellContract<M> {
41        fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
42            f.debug_tuple(stringify!(ImageCellContract))
43                .field(&self.address())
44                .finish()
45        }
46    }
47    impl<M: ::ethers::providers::Middleware> ImageCellContract<M> {
48        /// Creates a new contract instance with the specified `ethers` client
49        /// at `address`. The contract derefs to a `ethers::Contract`
50        /// object.
51        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                IMAGECELLCONTRACT_ABI.clone(),
58                client,
59            ))
60        }
61
62        /// Calls the contract's `rollback` (0x08c17228) function
63        pub fn rollback(
64            &self,
65            blocks: ::std::vec::Vec<BlockRollback>,
66        ) -> ::ethers::contract::builders::ContractCall<M, ()> {
67            self.0
68                .method_hash([8, 193, 114, 40], blocks)
69                .expect("method not found (this should never happen)")
70        }
71
72        /// Calls the contract's `setState` (0xac9f0222) function
73        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        /// Calls the contract's `update` (0xafa74e04) function
83        pub fn update(
84            &self,
85            blocks: ::std::vec::Vec<BlockUpdate>,
86        ) -> ::ethers::contract::builders::ContractCall<M, ()> {
87            self.0
88                .method_hash([175, 167, 78, 4], blocks)
89                .expect("method not found (this should never happen)")
90        }
91    }
92    impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>>
93        for ImageCellContract<M>
94    {
95        fn from(contract: ::ethers::contract::Contract<M>) -> Self {
96            Self::new(contract.address(), contract.client())
97        }
98    }
99    /// Container type for all input parameters for the `rollback` function with
100    /// signature `rollback(((bytes32,uint32)[],(bytes32,uint32)[])[])` and
101    /// selector `0x08c17228`
102    #[derive(
103        Clone,
104        ::ethers::contract::EthCall,
105        ::ethers::contract::EthDisplay,
106        Default,
107        Debug,
108        PartialEq,
109        Eq,
110        Hash,
111    )]
112    #[ethcall(
113        name = "rollback",
114        abi = "rollback(((bytes32,uint32)[],(bytes32,uint32)[])[])"
115    )]
116    pub struct RollbackCall {
117        pub blocks: ::std::vec::Vec<BlockRollback>,
118    }
119    /// Container type for all input parameters for the `setState` function with
120    /// signature `setState(bool)` and selector `0xac9f0222`
121    #[derive(
122        Clone,
123        ::ethers::contract::EthCall,
124        ::ethers::contract::EthDisplay,
125        Default,
126        Debug,
127        PartialEq,
128        Eq,
129        Hash,
130    )]
131    #[ethcall(name = "setState", abi = "setState(bool)")]
132    pub struct SetStateCall {
133        pub allow_read: bool,
134    }
135    /// Container type for all input parameters for the `update` function with
136    /// signature `update((uint64,(bytes32,uint32)[],((bytes32,uint32),(uint64,
137    /// (bytes32,uint8,bytes),(bytes32,uint8,bytes)[]),bytes)[])[])` and
138    /// selector `0xafa74e04`
139    #[derive(
140        Clone,
141        ::ethers::contract::EthCall,
142        ::ethers::contract::EthDisplay,
143        Default,
144        Debug,
145        PartialEq,
146        Eq,
147        Hash,
148    )]
149    #[ethcall(
150        name = "update",
151        abi = "update((uint64,(bytes32,uint32)[],((bytes32,uint32),(uint64,(bytes32,uint8,bytes),(bytes32,uint8,bytes)[]),bytes)[])[])"
152    )]
153    pub struct UpdateCall {
154        pub blocks: ::std::vec::Vec<BlockUpdate>,
155    }
156    /// Container type for all of the contract's call
157    #[derive(Clone, ::ethers::contract::EthAbiType, Debug, PartialEq, Eq, Hash)]
158    pub enum ImageCellContractCalls {
159        Rollback(RollbackCall),
160        SetState(SetStateCall),
161        Update(UpdateCall),
162    }
163    impl ::ethers::core::abi::AbiDecode for ImageCellContractCalls {
164        fn decode(
165            data: impl AsRef<[u8]>,
166        ) -> ::core::result::Result<Self, ::ethers::core::abi::AbiError> {
167            let data = data.as_ref();
168            if let Ok(decoded) = <RollbackCall as ::ethers::core::abi::AbiDecode>::decode(data) {
169                return Ok(Self::Rollback(decoded));
170            }
171            if let Ok(decoded) = <SetStateCall as ::ethers::core::abi::AbiDecode>::decode(data) {
172                return Ok(Self::SetState(decoded));
173            }
174            if let Ok(decoded) = <UpdateCall as ::ethers::core::abi::AbiDecode>::decode(data) {
175                return Ok(Self::Update(decoded));
176            }
177            Err(::ethers::core::abi::Error::InvalidData.into())
178        }
179    }
180    impl ::ethers::core::abi::AbiEncode for ImageCellContractCalls {
181        fn encode(self) -> Vec<u8> {
182            match self {
183                Self::Rollback(element) => ::ethers::core::abi::AbiEncode::encode(element),
184                Self::SetState(element) => ::ethers::core::abi::AbiEncode::encode(element),
185                Self::Update(element) => ::ethers::core::abi::AbiEncode::encode(element),
186            }
187        }
188    }
189    impl ::core::fmt::Display for ImageCellContractCalls {
190        fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
191            match self {
192                Self::Rollback(element) => ::core::fmt::Display::fmt(element, f),
193                Self::SetState(element) => ::core::fmt::Display::fmt(element, f),
194                Self::Update(element) => ::core::fmt::Display::fmt(element, f),
195            }
196        }
197    }
198    impl ::core::convert::From<RollbackCall> for ImageCellContractCalls {
199        fn from(value: RollbackCall) -> Self {
200            Self::Rollback(value)
201        }
202    }
203    impl ::core::convert::From<SetStateCall> for ImageCellContractCalls {
204        fn from(value: SetStateCall) -> Self {
205            Self::SetState(value)
206        }
207    }
208    impl ::core::convert::From<UpdateCall> for ImageCellContractCalls {
209        fn from(value: UpdateCall) -> Self {
210            Self::Update(value)
211        }
212    }
213    /// `CellInfo((bytes32,uint32),(uint64,(bytes32,uint8,bytes),(bytes32,uint8,
214    /// bytes)[]),bytes)`
215    #[derive(
216        Clone,
217        ::ethers::contract::EthAbiType,
218        ::ethers::contract::EthAbiCodec,
219        Default,
220        Debug,
221        PartialEq,
222        Eq,
223        Hash,
224    )]
225    pub struct CellInfo {
226        pub out_point: OutPoint,
227        pub output:    CellOutput,
228        pub data:      ::ethers::core::types::Bytes,
229    }
230    /// `CellOutput(uint64,(bytes32,uint8,bytes),(bytes32,uint8,bytes)[])`
231    #[derive(
232        Clone,
233        ::ethers::contract::EthAbiType,
234        ::ethers::contract::EthAbiCodec,
235        Default,
236        Debug,
237        PartialEq,
238        Eq,
239        Hash,
240    )]
241    pub struct CellOutput {
242        pub capacity: u64,
243        pub lock:     Script,
244        pub type_:    ::std::vec::Vec<Script>,
245    }
246    /// `OutPoint(bytes32,uint32)`
247    #[derive(
248        Clone,
249        ::ethers::contract::EthAbiType,
250        ::ethers::contract::EthAbiCodec,
251        Default,
252        Debug,
253        PartialEq,
254        Eq,
255        Hash,
256    )]
257    pub struct OutPoint {
258        pub tx_hash: [u8; 32],
259        pub index:   u32,
260    }
261    /// `Script(bytes32,uint8,bytes)`
262    #[derive(
263        Clone,
264        ::ethers::contract::EthAbiType,
265        ::ethers::contract::EthAbiCodec,
266        Default,
267        Debug,
268        PartialEq,
269        Eq,
270        Hash,
271    )]
272    pub struct Script {
273        pub code_hash: [u8; 32],
274        pub hash_type: u8,
275        pub args:      ::ethers::core::types::Bytes,
276    }
277    /// `BlockRollBlack((bytes32,uint32)[],(bytes32,uint32)[])`
278    #[derive(
279        Clone,
280        ::ethers::contract::EthAbiType,
281        ::ethers::contract::EthAbiCodec,
282        Default,
283        Debug,
284        PartialEq,
285        Eq,
286        Hash,
287    )]
288    pub struct BlockRollback {
289        pub tx_inputs:  ::std::vec::Vec<OutPoint>,
290        pub tx_outputs: ::std::vec::Vec<OutPoint>,
291    }
292    /// `BlockUpdate(uint64,(bytes32,uint32)[],((bytes32,uint32),(uint64,
293    /// (bytes32,uint8,bytes),(bytes32,uint8,bytes)[]),bytes)[])`
294    #[derive(
295        Clone,
296        ::ethers::contract::EthAbiType,
297        ::ethers::contract::EthAbiCodec,
298        Default,
299        Debug,
300        PartialEq,
301        Eq,
302        Hash,
303    )]
304    pub struct BlockUpdate {
305        pub block_number: u64,
306        pub tx_inputs:    ::std::vec::Vec<OutPoint>,
307        pub tx_outputs:   ::std::vec::Vec<CellInfo>,
308    }
309}