ethers-etherscan: derive debug, clone and copy (#1634)

* ethers-etherscan: derive debug, clone and copy

Derive Debug, Clone and Copy on all appropriate Structs and Enums.

* Update changelog
This commit is contained in:
Jacob 2022-08-24 20:50:29 +01:00 committed by GitHub
parent b1124441ec
commit b71e6ad00b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 18 deletions

View File

@ -83,6 +83,7 @@
- Add Arithmetic Shift Right operation for I256 [#1323](https://github.com/gakonst/ethers-rs/issues/1323) - Add Arithmetic Shift Right operation for I256 [#1323](https://github.com/gakonst/ethers-rs/issues/1323)
- [#1535](https://github.com/gakonst/ethers-rs/pull/1535) Add support to Aurora and Aurora testnet networks. - [#1535](https://github.com/gakonst/ethers-rs/pull/1535) Add support to Aurora and Aurora testnet networks.
- [#1632](https://github.com/gakonst/ethers-rs/pull/1632) Re-export `H32` from `ethabi`. - [#1632](https://github.com/gakonst/ethers-rs/pull/1632) Re-export `H32` from `ethabi`.
- [#1634](https://github.com/gakonst/ethers-rs/pull/1634) Derive missing `Clone`, `Copy` and `Debug` impls in ethers-etherscan.
## ethers-contract-abigen ## ethers-contract-abigen

View File

@ -11,7 +11,7 @@ use std::{
}; };
/// The raw response from the balance-related API endpoints /// The raw response from the balance-related API endpoints
#[derive(Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct AccountBalance { pub struct AccountBalance {
pub account: Address, pub account: Address,
pub balance: String, pub balance: String,
@ -139,7 +139,7 @@ mod hex_string {
/// ///
/// Transactions from the Genesis block may contain fields that do not conform to the expected /// Transactions from the Genesis block may contain fields that do not conform to the expected
/// types. /// types.
#[derive(Debug)] #[derive(Clone, Debug)]
pub enum GenesisOption<T> { pub enum GenesisOption<T> {
None, None,
Genesis, Genesis,
@ -169,7 +169,7 @@ impl<T> GenesisOption<T> {
} }
/// The raw response from the transaction list API endpoint /// The raw response from the transaction list API endpoint
#[derive(Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct NormalTransaction { pub struct NormalTransaction {
pub is_error: String, pub is_error: String,
@ -211,7 +211,7 @@ pub struct NormalTransaction {
} }
/// The raw response from the internal transaction list API endpoint /// The raw response from the internal transaction list API endpoint
#[derive(Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct InternalTransaction { pub struct InternalTransaction {
#[serde(deserialize_with = "deserialize_stringified_block_number")] #[serde(deserialize_with = "deserialize_stringified_block_number")]
@ -239,7 +239,7 @@ pub struct InternalTransaction {
} }
/// The raw response from the ERC20 transfer list API endpoint /// The raw response from the ERC20 transfer list API endpoint
#[derive(Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ERC20TokenTransferEvent { pub struct ERC20TokenTransferEvent {
#[serde(deserialize_with = "deserialize_stringified_block_number")] #[serde(deserialize_with = "deserialize_stringified_block_number")]
@ -274,7 +274,7 @@ pub struct ERC20TokenTransferEvent {
} }
/// The raw response from the ERC721 transfer list API endpoint /// The raw response from the ERC721 transfer list API endpoint
#[derive(Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ERC721TokenTransferEvent { pub struct ERC721TokenTransferEvent {
#[serde(deserialize_with = "deserialize_stringified_block_number")] #[serde(deserialize_with = "deserialize_stringified_block_number")]
@ -309,7 +309,7 @@ pub struct ERC721TokenTransferEvent {
} }
/// The raw response from the ERC1155 transfer list API endpoint /// The raw response from the ERC1155 transfer list API endpoint
#[derive(Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ERC1155TokenTransferEvent { pub struct ERC1155TokenTransferEvent {
#[serde(deserialize_with = "deserialize_stringified_block_number")] #[serde(deserialize_with = "deserialize_stringified_block_number")]
@ -344,7 +344,7 @@ pub struct ERC1155TokenTransferEvent {
} }
/// The raw response from the mined blocks API endpoint /// The raw response from the mined blocks API endpoint
#[derive(Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct MinedBlock { pub struct MinedBlock {
#[serde(deserialize_with = "deserialize_stringified_block_number")] #[serde(deserialize_with = "deserialize_stringified_block_number")]
@ -354,6 +354,7 @@ pub struct MinedBlock {
} }
/// The pre-defined block parameter for balance API endpoints /// The pre-defined block parameter for balance API endpoints
#[derive(Clone, Copy, Debug)]
pub enum Tag { pub enum Tag {
Earliest, Earliest,
Pending, Pending,
@ -377,6 +378,7 @@ impl Default for Tag {
} }
/// The list sorting preference /// The list sorting preference
#[derive(Clone, Copy, Debug)]
pub enum Sort { pub enum Sort {
Asc, Asc,
Desc, Desc,
@ -392,6 +394,7 @@ impl Display for Sort {
} }
/// Common optional arguments for the transaction or event list API endpoints /// Common optional arguments for the transaction or event list API endpoints
#[derive(Clone, Copy, Debug)]
pub struct TxListParams { pub struct TxListParams {
start_block: u64, start_block: u64,
end_block: u64, end_block: u64,
@ -425,6 +428,7 @@ impl From<TxListParams> for HashMap<&'static str, String> {
} }
/// Options for querying internal transactions /// Options for querying internal transactions
#[derive(Clone, Debug)]
pub enum InternalTxQueryOption { pub enum InternalTxQueryOption {
ByAddress(Address), ByAddress(Address),
ByTransactionHash(H256), ByTransactionHash(H256),
@ -432,6 +436,7 @@ pub enum InternalTxQueryOption {
} }
/// Options for querying ERC20 or ERC721 token transfers /// Options for querying ERC20 or ERC721 token transfers
#[derive(Clone, Debug)]
pub enum TokenQueryOption { pub enum TokenQueryOption {
ByAddress(Address), ByAddress(Address),
ByContract(Address), ByContract(Address),
@ -460,6 +465,7 @@ impl TokenQueryOption {
} }
/// The pre-defined block type for retrieving mined blocks /// The pre-defined block type for retrieving mined blocks
#[derive(Copy, Clone, Debug)]
pub enum BlockType { pub enum BlockType {
CanonicalBlocks, CanonicalBlocks,
Uncles, Uncles,

View File

@ -139,7 +139,7 @@ impl Default for CodeFormat {
} }
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(transparent)] #[serde(transparent)]
pub struct ContractMetadata { pub struct ContractMetadata {
pub items: Vec<Metadata>, pub items: Vec<Metadata>,
@ -154,12 +154,12 @@ impl IntoIterator for ContractMetadata {
} }
} }
#[derive(Deserialize)] #[derive(Deserialize, Clone, Debug)]
struct EtherscanSourceEntry { struct EtherscanSourceEntry {
content: String, content: String,
} }
#[derive(Deserialize)] #[derive(Deserialize, Clone, Debug)]
struct EtherscanSourceJsonMetadata { struct EtherscanSourceJsonMetadata {
sources: HashMap<String, EtherscanSourceEntry>, sources: HashMap<String, EtherscanSourceEntry>,
} }
@ -217,7 +217,7 @@ impl ContractMetadata {
} }
/// Etherscan contract metadata /// Etherscan contract metadata
#[derive(Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Metadata { pub struct Metadata {
#[serde(rename = "SourceCode")] #[serde(rename = "SourceCode")]
pub source_code: String, pub source_code: String,

View File

@ -7,7 +7,7 @@ use ethers_core::types::U256;
use crate::{Client, EtherscanError, Response, Result}; use crate::{Client, EtherscanError, Response, Result};
#[derive(Deserialize)] #[derive(Deserialize, Clone, Debug)]
#[serde(rename_all = "PascalCase")] #[serde(rename_all = "PascalCase")]
pub struct GasOracle { pub struct GasOracle {
#[serde(deserialize_with = "deserialize_number_from_string")] #[serde(deserialize_with = "deserialize_number_from_string")]

View File

@ -399,7 +399,7 @@ pub enum ResponseData<T> {
} }
/// The type that gets serialized as query /// The type that gets serialized as query
#[derive(Debug, Serialize)] #[derive(Clone, Debug, Serialize)]
struct Query<'a, T: Serialize> { struct Query<'a, T: Serialize> {
apikey: Cow<'a, str>, apikey: Cow<'a, str>,
module: Cow<'a, str>, module: Cow<'a, str>,

View File

@ -4,13 +4,13 @@ use std::{
path::{Component, Path, PathBuf}, path::{Component, Path, PathBuf},
}; };
#[derive(Debug)] #[derive(Clone, Debug)]
pub struct SourceTreeEntry { pub struct SourceTreeEntry {
pub path: PathBuf, pub path: PathBuf,
pub contents: String, pub contents: String,
} }
#[derive(Debug)] #[derive(Clone, Debug)]
pub struct SourceTree { pub struct SourceTree {
pub entries: Vec<SourceTreeEntry>, pub entries: Vec<SourceTreeEntry>,
} }

View File

@ -4,14 +4,14 @@ use serde::Deserialize;
use crate::{Client, EtherscanError, Response, Result}; use crate::{Client, EtherscanError, Response, Result};
#[derive(Deserialize)] #[derive(Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct ContractExecutionStatus { struct ContractExecutionStatus {
is_error: String, is_error: String,
err_description: String, err_description: String,
} }
#[derive(Deserialize)] #[derive(Deserialize, Clone, Debug)]
struct TransactionReceiptStatus { struct TransactionReceiptStatus {
status: String, status: String,
} }