1#[allow(dead_code)]
2pub mod ownable_mock {
3 # [rustfmt :: skip] use ethcontract as ethcontract ;
4 #[doc = "Generated by `ethcontract`"]
5 #[derive(Clone)]
6 pub struct Contract {
7 methods: Methods,
8 }
9 impl Contract {
10 #[doc = r" Retrieves the raw contract instance used to generate the type safe"]
11 #[doc = r" API for this contract."]
12 pub fn raw_contract() -> &'static self::ethcontract::Contract {
13 use self::ethcontract::common::artifact::truffle::TruffleLoader;
14 use self::ethcontract::private::lazy_static;
15 use self::ethcontract::Contract;
16 lazy_static! {
17 pub static ref CONTRACT: Contract = {
18 # [allow (unused_mut)] let mut contract = TruffleLoader :: new () . load_contract_from_str ("{\"contractName\":\"OwnableMock\",\"abi\":[{\"type\":\"function\",\"name\":\"isOwner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"constant\":true,\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"constant\":true,\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"constant\":false,\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\"}],\"outputs\":[],\"constant\":false,\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true}],\"anonymous\":false}],\"bytecode\":\"608060405260006100146100b760201b60201c565b9050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3506100bf565b600033905090565b6104f8806100ce6000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063715018a6146100515780638da5cb5b1461005b5780638f32d59b146100a5578063f2fde38b146100c7575b600080fd5b61005961010b565b005b610063610244565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100ad61026d565b604051808215151515815260200191505060405180910390f35b610109600480360360208110156100dd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506102cb565b005b61011361026d565b610185576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166102af610351565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b6102d361026d565b610345576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61034e81610359565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156103df576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061049e6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a265627a7a72315820cdf5dd40ae5d0eecf24d9a9cb167874c262de7feb314991e9844da219ea05e1f64736f6c63430005110032\",\"networks\":{},\"devdoc\":{\"details\":null,\"methods\":{}},\"userdoc\":{\"details\":null,\"methods\":{}}}") . expect ("valid contract JSON") ;
19 contract
20 };
21 }
22 &CONTRACT
23 }
24 #[doc = r" Creates a new contract instance with the specified `web3`"]
25 #[doc = r" provider at the given `Address`."]
26 #[doc = r""]
27 #[doc = r" Note that this does not verify that a contract with a matching"]
28 #[doc = r" `Abi` is actually deployed at the given address."]
29 pub fn at<F, B, T>(
30 web3: &self::ethcontract::web3::api::Web3<T>,
31 address: self::ethcontract::Address,
32 ) -> Self
33 where
34 F: std::future::Future<
35 Output = Result<self::ethcontract::json::Value, self::ethcontract::web3::Error>,
36 > + Send
37 + 'static,
38 B: std::future::Future<
39 Output = Result<
40 Vec<Result<self::ethcontract::json::Value, self::ethcontract::web3::Error>>,
41 self::ethcontract::web3::Error,
42 >,
43 > + Send
44 + 'static,
45 T: self::ethcontract::web3::Transport<Out = F>
46 + self::ethcontract::web3::BatchTransport<Batch = B>
47 + Send
48 + Sync
49 + 'static,
50 {
51 Contract::with_deployment_info(web3, address, None)
52 }
53 #[doc = r" Creates a new contract instance with the specified `web3` provider with"]
54 #[doc = r" the given `Abi` at the given `Address` and an optional transaction hash."]
55 #[doc = r" This hash is used to retrieve contract related information such as the"]
56 #[doc = r" creation block (which is useful for fetching all historic events)."]
57 #[doc = r""]
58 #[doc = r" Note that this does not verify that a contract with a matching `Abi` is"]
59 #[doc = r" actually deployed at the given address nor that the transaction hash,"]
60 #[doc = r" when provided, is actually for this contract deployment."]
61 pub fn with_deployment_info<F, B, T>(
62 web3: &self::ethcontract::web3::api::Web3<T>,
63 address: self::ethcontract::Address,
64 deployment_information: Option<ethcontract::common::DeploymentInformation>,
65 ) -> Self
66 where
67 F: std::future::Future<
68 Output = Result<self::ethcontract::json::Value, self::ethcontract::web3::Error>,
69 > + Send
70 + 'static,
71 B: std::future::Future<
72 Output = Result<
73 Vec<Result<self::ethcontract::json::Value, self::ethcontract::web3::Error>>,
74 self::ethcontract::web3::Error,
75 >,
76 > + Send
77 + 'static,
78 T: self::ethcontract::web3::Transport<Out = F>
79 + self::ethcontract::web3::BatchTransport<Batch = B>
80 + Send
81 + Sync
82 + 'static,
83 {
84 use self::ethcontract::transport::DynTransport;
85 use self::ethcontract::web3::api::Web3;
86 use self::ethcontract::Instance;
87 let transport = DynTransport::new(web3.transport().clone());
88 let web3 = Web3::new(transport);
89 let abi = Self::raw_contract().abi.clone();
90 let instance = Instance::with_deployment_info(web3, abi, address, deployment_information);
91 Contract::from_raw(instance)
92 }
93 #[doc = r" Creates a contract from a raw instance."]
94 fn from_raw(instance: self::ethcontract::dyns::DynInstance) -> Self {
95 let methods = Methods { instance };
96 Contract { methods }
97 }
98 #[doc = r" Returns the contract address being used by this instance."]
99 pub fn address(&self) -> self::ethcontract::Address {
100 self.raw_instance().address()
101 }
102 #[doc = r" Returns the deployment information of the contract"]
103 #[doc = r" if it is known, `None` otherwise."]
104 pub fn deployment_information(&self) -> Option<ethcontract::common::DeploymentInformation> {
105 self.raw_instance().deployment_information()
106 }
107 #[doc = r" Returns a reference to the default method options used by this"]
108 #[doc = r" contract."]
109 pub fn defaults(&self) -> &self::ethcontract::contract::MethodDefaults {
110 &self.raw_instance().defaults
111 }
112 #[doc = r" Returns a mutable reference to the default method options used"]
113 #[doc = r" by this contract."]
114 pub fn defaults_mut(&mut self) -> &mut self::ethcontract::contract::MethodDefaults {
115 &mut self.raw_instance_mut().defaults
116 }
117 #[doc = r" Returns a reference to the raw runtime instance used by this"]
118 #[doc = r" contract."]
119 pub fn raw_instance(&self) -> &self::ethcontract::dyns::DynInstance {
120 &self.methods.instance
121 }
122 #[doc = r" Returns a mutable reference to the raw runtime instance used by"]
123 #[doc = r" this contract."]
124 fn raw_instance_mut(&mut self) -> &mut self::ethcontract::dyns::DynInstance {
125 &mut self.methods.instance
126 }
127 }
128 impl std::fmt::Debug for Contract {
129 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
130 f.debug_tuple(stringify!(OwnableMock))
131 .field(&self.address())
132 .finish()
133 }
134 }
135 impl Contract {
136 #[doc = "Generated by `ethcontract`"]
137 #[allow(clippy::too_many_arguments)]
138 pub fn builder<F, B, T>(
139 web3: &self::ethcontract::web3::api::Web3<T>,
140 ) -> self::ethcontract::dyns::DynDeployBuilder<Self>
141 where
142 F: std::future::Future<
143 Output = Result<self::ethcontract::json::Value, self::ethcontract::web3::Error>,
144 > + Send
145 + 'static,
146 B: std::future::Future<
147 Output = Result<
148 Vec<Result<self::ethcontract::json::Value, self::ethcontract::web3::Error>>,
149 self::ethcontract::web3::Error,
150 >,
151 > + Send
152 + 'static,
153 T: self::ethcontract::web3::Transport<Out = F>
154 + self::ethcontract::web3::BatchTransport<Batch = B>
155 + Send
156 + Sync
157 + 'static,
158 {
159 use self::ethcontract::contract::DeployBuilder;
160 use self::ethcontract::dyns::DynTransport;
161 use self::ethcontract::web3::api::Web3;
162 let transport = DynTransport::new(web3.transport().clone());
163 let web3 = Web3::new(transport);
164 let bytecode = Self::raw_contract().bytecode.clone();
165 DeployBuilder::new(web3, bytecode, ()).expect("valid deployment args")
166 }
167 }
168 impl self::ethcontract::contract::Deploy<self::ethcontract::dyns::DynTransport> for Contract {
169 type Context = self::ethcontract::common::Bytecode;
170 fn bytecode(cx: &Self::Context) -> &self::ethcontract::common::Bytecode {
171 cx
172 }
173 fn abi(_: &Self::Context) -> &self::ethcontract::common::Abi {
174 &Self::raw_contract().abi
175 }
176 fn from_deployment(
177 web3: self::ethcontract::dyns::DynWeb3,
178 address: self::ethcontract::Address,
179 transaction_hash: self::ethcontract::H256,
180 _: Self::Context,
181 ) -> Self {
182 Self::with_deployment_info(&web3, address, Some(transaction_hash.into()))
183 }
184 }
185 impl Contract {
186 #[doc = r" Returns an object that allows accessing typed method signatures."]
187 pub fn signatures() -> Signatures {
188 Signatures
189 }
190 #[doc = r" Retrieves a reference to type containing all the generated"]
191 #[doc = r" contract methods. This can be used for methods where the name"]
192 #[doc = r" would collide with a common method (like `at` or `deployed`)."]
193 pub fn methods(&self) -> &Methods {
194 &self.methods
195 }
196 }
197 #[doc = r" Type containing signatures for all methods for generated contract type."]
198 #[derive(Clone, Copy)]
199 pub struct Signatures;
200 impl Signatures {
201 #[doc = "Returns signature for method `isOwner():(bool)`."]
202 #[allow(clippy::type_complexity)]
203 pub fn is_owner(&self) -> self::ethcontract::contract::Signature<(), bool> {
204 self::ethcontract::contract::Signature::new([143, 50, 213, 155])
205 }
206 #[doc = "Returns signature for method `owner():(address)`."]
207 #[allow(clippy::type_complexity)]
208 pub fn owner(&self) -> self::ethcontract::contract::Signature<(), self::ethcontract::Address> {
209 self::ethcontract::contract::Signature::new([141, 165, 203, 91])
210 }
211 #[doc = "Returns signature for method `renounceOwnership()`."]
212 #[allow(clippy::type_complexity)]
213 pub fn renounce_ownership(&self) -> self::ethcontract::contract::Signature<(), ()> {
214 self::ethcontract::contract::Signature::new([113, 80, 24, 166])
215 }
216 #[doc = "Returns signature for method `transferOwnership(address)`."]
217 #[allow(clippy::type_complexity)]
218 pub fn transfer_ownership(
219 &self,
220 ) -> self::ethcontract::contract::Signature<(self::ethcontract::Address,), ()> {
221 self::ethcontract::contract::Signature::new([242, 253, 227, 139])
222 }
223 }
224 #[doc = r" Type containing all contract methods for generated contract type."]
225 #[derive(Clone)]
226 pub struct Methods {
227 instance: self::ethcontract::dyns::DynInstance,
228 }
229 #[allow(clippy::too_many_arguments, clippy::type_complexity)]
230 impl Methods {
231 #[doc = "Generated by `ethcontract`"]
232 pub fn is_owner(&self) -> self::ethcontract::dyns::DynViewMethodBuilder<bool> {
233 self
234 .instance
235 .view_method([143, 50, 213, 155], ())
236 .expect("generated call")
237 }
238 #[doc = "Generated by `ethcontract`"]
239 pub fn owner(
240 &self,
241 ) -> self::ethcontract::dyns::DynViewMethodBuilder<self::ethcontract::Address> {
242 self
243 .instance
244 .view_method([141, 165, 203, 91], ())
245 .expect("generated call")
246 }
247 #[doc = "Generated by `ethcontract`"]
248 pub fn renounce_ownership(&self) -> self::ethcontract::dyns::DynMethodBuilder<()> {
249 self
250 .instance
251 .method([113, 80, 24, 166], ())
252 .expect("generated call")
253 }
254 #[doc = "Generated by `ethcontract`"]
255 pub fn transfer_ownership(
256 &self,
257 new_owner: self::ethcontract::Address,
258 ) -> self::ethcontract::dyns::DynMethodBuilder<()> {
259 self
260 .instance
261 .method([242, 253, 227, 139], (new_owner,))
262 .expect("generated call")
263 }
264 }
265 impl std::ops::Deref for Contract {
266 type Target = Methods;
267 fn deref(&self) -> &Self::Target {
268 &self.methods
269 }
270 }
271 #[doc = r" Module containing all generated data models for this contract's"]
272 #[doc = r" events."]
273 pub mod event_data {
274 use super::ethcontract;
275 #[derive(Clone, Debug, Default, Eq, PartialEq, serde :: Deserialize, serde :: Serialize)]
276 pub struct OwnershipTransferred {
277 pub previous_owner: self::ethcontract::Address,
278 pub new_owner: self::ethcontract::Address,
279 }
280 impl OwnershipTransferred {
281 #[doc = r" Retrieves the signature for the event this data corresponds to."]
282 #[doc = r" This signature is the Keccak-256 hash of the ABI signature of"]
283 #[doc = r" this event."]
284 pub fn signature() -> self::ethcontract::H256 {
285 self::ethcontract::H256([
286 139, 224, 7, 156, 83, 22, 89, 20, 19, 68, 205, 31, 208, 164, 242, 132, 25, 73, 127, 151,
287 34, 163, 218, 175, 227, 180, 24, 111, 107, 100, 87, 224,
288 ])
289 }
290 #[doc = r" Retrieves the ABI signature for the event this data corresponds"]
291 #[doc = r" to. For this event the value should always be:"]
292 #[doc = r""]
293 #[doc = "`OwnershipTransferred(address,address)`"]
294 pub fn abi_signature() -> &'static str {
295 "OwnershipTransferred(address,address)"
296 }
297 }
298 impl self::ethcontract::tokens::Tokenize for OwnershipTransferred {
299 fn from_token(
300 token: self::ethcontract::common::abi::Token,
301 ) -> Result<Self, self::ethcontract::tokens::Error> {
302 let (previous_owner, new_owner) = self::ethcontract::tokens::Tokenize::from_token(token)?;
303 Ok(OwnershipTransferred {
304 previous_owner,
305 new_owner,
306 })
307 }
308 fn into_token(self) -> self::ethcontract::common::abi::Token {
309 unimplemented!("events are only decoded, not encoded")
310 }
311 }
312 }
313 impl Contract {
314 #[doc = r" Retrieves a handle to a type containing for creating event"]
315 #[doc = r" streams for all the contract events."]
316 pub fn events(&self) -> Events<'_> {
317 Events {
318 instance: self.raw_instance(),
319 }
320 }
321 }
322 pub struct Events<'a> {
323 instance: &'a self::ethcontract::dyns::DynInstance,
324 }
325 impl Events<'_> {
326 #[doc = r" Generated by `ethcontract`."]
327 pub fn ownership_transferred(&self) -> self::event_builders::OwnershipTransferredBuilder {
328 self::event_builders::OwnershipTransferredBuilder(
329 self
330 .instance
331 .event(self::ethcontract::H256([
332 139, 224, 7, 156, 83, 22, 89, 20, 19, 68, 205, 31, 208, 164, 242, 132, 25, 73, 127,
333 151, 34, 163, 218, 175, 227, 180, 24, 111, 107, 100, 87, 224,
334 ]))
335 .expect("generated event filter"),
336 )
337 }
338 }
339 #[doc = r" Module containing the generated event stream builders with type safe"]
340 #[doc = r" filter methods for this contract's events."]
341 pub mod event_builders {
342 use super::ethcontract;
343 use super::event_data;
344 #[doc = "A builder for creating a filtered stream of `OwnershipTransferred` events."]
345 pub struct OwnershipTransferredBuilder(
346 #[doc = r" The inner event builder."]
347 pub self::ethcontract::dyns::DynEventBuilder<self::event_data::OwnershipTransferred>,
348 );
349 impl OwnershipTransferredBuilder {
350 #[doc = r" Sets the starting block from which to stream logs for."]
351 #[doc = r""]
352 #[doc = r" If left unset defaults to the latest block."]
353 #[allow(clippy::wrong_self_convention)]
354 pub fn from_block(mut self, block: self::ethcontract::BlockNumber) -> Self {
355 self.0 = (self.0).from_block(block);
356 self
357 }
358 #[doc = r" Sets the last block from which to stream logs for."]
359 #[doc = r""]
360 #[doc = r" If left unset defaults to the streaming until the end of days."]
361 #[allow(clippy::wrong_self_convention)]
362 pub fn to_block(mut self, block: self::ethcontract::BlockNumber) -> Self {
363 self.0 = (self.0).to_block(block);
364 self
365 }
366 #[doc = r" Limits the number of events that can be retrieved by this filter."]
367 #[doc = r""]
368 #[doc = r" Note that this parameter is non-standard."]
369 pub fn limit(mut self, value: usize) -> Self {
370 self.0 = (self.0).limit(value);
371 self
372 }
373 #[doc = r" Sets the polling interval. This is used as the interval between"]
374 #[doc = r" consecutive `eth_getFilterChanges` calls to get filter updates."]
375 pub fn poll_interval(mut self, value: std::time::Duration) -> Self {
376 self.0 = (self.0).poll_interval(value);
377 self
378 }
379 #[doc = "Adds a filter for the previousOwner event parameter."]
380 pub fn previous_owner(
381 mut self,
382 topic: self::ethcontract::Topic<self::ethcontract::Address>,
383 ) -> Self {
384 self.0 = (self.0).topic0(topic);
385 self
386 }
387 #[doc = "Adds a filter for the newOwner event parameter."]
388 pub fn new_owner(
389 mut self,
390 topic: self::ethcontract::Topic<self::ethcontract::Address>,
391 ) -> Self {
392 self.0 = (self.0).topic1(topic);
393 self
394 }
395 #[doc = r" Returns a future that resolves with a collection of all existing"]
396 #[doc = r" logs matching the builder parameters."]
397 pub async fn query(
398 self,
399 ) -> std::result::Result<
400 std::vec::Vec<self::ethcontract::Event<self::event_data::OwnershipTransferred>>,
401 self::ethcontract::errors::EventError,
402 > {
403 (self.0).query().await
404 }
405 #[doc = r" Creates an event stream from the current event builder."]
406 pub fn stream(
407 self,
408 ) -> impl self::ethcontract::futures::stream::Stream<
409 Item = std::result::Result<
410 self::ethcontract::StreamEvent<self::event_data::OwnershipTransferred>,
411 self::ethcontract::errors::EventError,
412 >,
413 > {
414 (self.0).stream()
415 }
416 }
417 }
418 impl Contract {
419 #[doc = r" Returns a log stream with all events."]
420 pub fn all_events(&self) -> self::ethcontract::dyns::DynAllEventsBuilder<Event> {
421 self::ethcontract::dyns::DynAllEventsBuilder::new(
422 self.raw_instance().web3(),
423 self.address(),
424 self.deployment_information(),
425 )
426 }
427 }
428 #[doc = r" A contract event."]
429 #[derive(Clone, Debug, Eq, PartialEq, serde :: Deserialize, serde :: Serialize)]
430 pub enum Event {
431 OwnershipTransferred(self::event_data::OwnershipTransferred),
432 }
433 impl self::ethcontract::contract::ParseLog for Event {
434 fn parse_log(
435 log: self::ethcontract::RawLog,
436 ) -> Result<Self, self::ethcontract::errors::ExecutionError> {
437 let standard_event = log . topics . get (0) . copied () . map (| topic | match topic { self :: ethcontract :: H256 ([139 , 224 , 7 , 156 , 83 , 22 , 89 , 20 , 19 , 68 , 205 , 31 , 208 , 164 , 242 , 132 , 25 , 73 , 127 , 151 , 34 , 163 , 218 , 175 , 227 , 180 , 24 , 111 , 107 , 100 , 87 , 224]) => Ok (Event :: OwnershipTransferred (log . clone () . decode (Contract :: raw_contract () . abi . event ("OwnershipTransferred") . expect ("generated event decode")) ?)) , _ => Err (self :: ethcontract :: errors :: ExecutionError :: from (self :: ethcontract :: common :: abi :: Error :: InvalidData)) , }) ;
438 if let Some(Ok(data)) = standard_event {
439 return Ok(data);
440 }
441 Err(self::ethcontract::errors::ExecutionError::from(
442 self::ethcontract::common::abi::Error::InvalidData,
443 ))
444 }
445 }
446}
447pub use self::ownable_mock::Contract as OwnableMock;