ethcontract_common/
lib.rs

1#![deny(missing_docs, unsafe_code)]
2
3//! Crate for common times shared between the `ethcontract` runtime crate as and
4//! the `ethcontract-derive` crate.
5
6pub mod abiext;
7pub mod artifact;
8pub mod bytecode;
9pub mod contract;
10pub mod errors;
11pub mod hash;
12
13pub use crate::abiext::FunctionExt;
14pub use crate::bytecode::Bytecode;
15pub use crate::contract::Contract;
16pub use ethabi::{self as abi, Contract as Abi};
17use serde::{Deserialize, Serialize};
18pub use web3::types::Address;
19pub use web3::types::H256 as TransactionHash;
20
21/// Information about when a contract instance was deployed
22#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
23#[serde(untagged)]
24pub enum DeploymentInformation {
25    /// The block at which the contract was deployed
26    BlockNumber(u64),
27    /// The transaction hash at which the contract was deployed
28    TransactionHash(TransactionHash),
29}
30
31impl From<u64> for DeploymentInformation {
32    fn from(block: u64) -> Self {
33        Self::BlockNumber(block)
34    }
35}
36
37impl From<TransactionHash> for DeploymentInformation {
38    fn from(hash: TransactionHash) -> Self {
39        Self::TransactionHash(hash)
40    }
41}