From 7088ed7b36cc594bc0999eb2cda928e1f300410b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Mon, 6 May 2024 20:21:08 +0200 Subject: [PATCH 1/2] Address compiler warnings --- src/api/mod.rs | 2 +- src/api/routes.rs | 3 --- src/chain_list.rs | 1 - src/main.rs | 1 - src/p2p.rs | 7 +++---- src/premints/metadata.rs | 23 ----------------------- src/premints/mod.rs | 1 - src/premints/zora_premint/erc20v1.rs | 1 - src/premints/zora_premint/rules.rs | 5 ----- src/rules.rs | 2 +- src/run.rs | 3 +-- src/storage.rs | 2 +- 12 files changed, 7 insertions(+), 44 deletions(-) delete mode 100644 src/premints/metadata.rs diff --git a/src/api/mod.rs b/src/api/mod.rs index 898570e..46c3bd9 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -44,7 +44,7 @@ impl AppState { } } -pub fn router_with_defaults(config: &Config) -> Router { +pub fn router_with_defaults(_config: &Config) -> Router { Router::new() .route("/health", get(routes::health)) .route("/list-all", get(routes::list_all)) diff --git a/src/api/routes.rs b/src/api/routes.rs index 03ee499..4faef2a 100644 --- a/src/api/routes.rs +++ b/src/api/routes.rs @@ -1,10 +1,7 @@ -use std::path::Display; - use axum::extract::{Path, Query, State}; use axum::http::StatusCode; use axum::Json; use const_hex::ToHexExt; -use itertools::Itertools; use libp2p::autonat::NatStatus; use serde::Serialize; use sqlx::{Executor, Row}; diff --git a/src/chain_list.rs b/src/chain_list.rs index 563a494..8fe5eed 100644 --- a/src/chain_list.rs +++ b/src/chain_list.rs @@ -1,4 +1,3 @@ -use alloy::network::Network; use alloy::providers::{ProviderBuilder, RootProvider}; use alloy::pubsub::PubSubFrontend; use alloy::rpc::client::WsConnect; diff --git a/src/main.rs b/src/main.rs index 51fbfb0..c0d7163 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,6 @@ use mintpool::rules::RulesEngine; use mintpool::run::{start_p2p_services, start_watch_chain}; use mintpool::stdin::watch_stdin; use tokio::signal::unix::{signal, SignalKind}; -use tracing_subscriber::EnvFilter; #[tokio::main] async fn main() -> eyre::Result<()> { diff --git a/src/p2p.rs b/src/p2p.rs index 7391a5b..056ba65 100644 --- a/src/p2p.rs +++ b/src/p2p.rs @@ -1,6 +1,4 @@ use std::borrow::Cow; -use std::collections::HashMap; -use std::hash::Hasher; use std::time::Duration; use eyre::WrapErr; @@ -34,8 +32,8 @@ use crate::multi_ticker::MultiTicker; use crate::multiaddr_ext::MultiaddrExt; use crate::storage::QueryOptions; use crate::types::{ - claims_topic_hashes, InclusionClaim, MintpoolNodeInfo, PeerInclusionClaim, Premint, - PremintName, PremintTypes, + claims_topic_hashes, InclusionClaim, MintpoolNodeInfo, PeerInclusionClaim, PremintName, + PremintTypes, }; #[derive(NetworkBehaviour)] @@ -853,6 +851,7 @@ impl SwarmController { Ok(()) } + #[allow(dead_code)] fn gossip_unsubscribe(&mut self, topic: &IdentTopic) -> eyre::Result<()> { let b = self.swarm.behaviour_mut(); diff --git a/src/premints/metadata.rs b/src/premints/metadata.rs deleted file mode 100644 index 184f8a1..0000000 --- a/src/premints/metadata.rs +++ /dev/null @@ -1,23 +0,0 @@ -use serde::{Deserialize, Serialize}; -use serde_json::{Map, Value}; - -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct ERC721Metadata { - pub name: String, - pub description: String, - pub image: String, -} - -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct ERC1155Metadata { - pub name: String, - pub description: String, - pub image: String, - pub decimals: u64, - pub properties: Map, -} - -enum TokenMetadata { - ERC721(ERC721Metadata), - ERC1155(ERC1155Metadata), -} diff --git a/src/premints/mod.rs b/src/premints/mod.rs index 4ee9891..d93e6dc 100644 --- a/src/premints/mod.rs +++ b/src/premints/mod.rs @@ -1,2 +1 @@ -pub mod metadata; pub mod zora_premint; diff --git a/src/premints/zora_premint/erc20v1.rs b/src/premints/zora_premint/erc20v1.rs index 8e032f9..5d2c591 100644 --- a/src/premints/zora_premint/erc20v1.rs +++ b/src/premints/zora_premint/erc20v1.rs @@ -2,7 +2,6 @@ use crate::{implement_zora_premint_traits, typed_rule}; use alloy::primitives::Address; use crate::premints::zora_premint::contract::IZoraPremintERC20V1; -use crate::premints::zora_premint::contract::IZoraPremintV2::IZoraPremintV2Errors; use crate::rules::Rule; use crate::storage::Reader; diff --git a/src/premints/zora_premint/rules.rs b/src/premints/zora_premint/rules.rs index b68e197..e3ec2df 100644 --- a/src/premints/zora_premint/rules.rs +++ b/src/premints/zora_premint/rules.rs @@ -1,8 +1,3 @@ -use crate::premints::zora_premint::v2::V2; -use crate::rules::Rule; -use crate::storage::Reader; -use crate::typed_rule; -use crate::types::PremintTypes; #[macro_export] macro_rules! zora_premint_rules { ($namespace:tt, $typ:ty, $version:literal) => { diff --git a/src/rules.rs b/src/rules.rs index 26731f6..91f49ef 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -9,7 +9,7 @@ use serde::{Serialize, Serializer}; use crate::chain_list::{ChainListProvider, CHAINS}; use crate::config::Config; -use crate::storage::{PremintStorage, Reader}; +use crate::storage::Reader; use crate::types::PremintTypes; #[derive(Debug, PartialEq, Eq, Clone)] diff --git a/src/run.rs b/src/run.rs index 2f13939..468083e 100644 --- a/src/run.rs +++ b/src/run.rs @@ -1,5 +1,4 @@ use alloy::hex; -use libp2p::identity; use libp2p::identity::Keypair; use std::time::Duration; use tracing::{info_span, Instrument}; @@ -10,7 +9,7 @@ use crate::config::{BootNodes, ChainInclusionMode, Config}; use crate::controller::{Controller, ControllerCommands, ControllerInterface}; use crate::p2p::SwarmController; use crate::rules::RulesEngine; -use crate::storage::{PremintStorage, Reader}; +use crate::storage::PremintStorage; use crate::types::Premint; /// Starts the libp2p swarm, the controller, and the checkers if applicable, then wires them all up. diff --git a/src/storage.rs b/src/storage.rs index 3c60516..ce5b8cf 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -9,7 +9,7 @@ use sqlx::Row; use sqlx::{QueryBuilder, Sqlite, SqlitePool}; use crate::config::Config; -use crate::types::{InclusionClaim, Premint, PremintName, PremintTypes}; +use crate::types::{InclusionClaim, PremintName, PremintTypes}; async fn init_db(config: &Config) -> SqlitePool { let expect_msg = From 3da5ce21399741eb7aacb0cb126a528bfc7a66a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Tue, 7 May 2024 15:13:03 +0200 Subject: [PATCH 2/2] Address test code warnings --- src/config.rs | 2 +- src/rules.rs | 8 +++++--- src/storage.rs | 2 +- tests/common/factories.rs | 2 +- tests/common/mod.rs | 4 ++++ tests/e2e_test.rs | 4 +--- tests/p2p_test.rs | 4 ++-- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/config.rs b/src/config.rs index e798186..c90ce29 100644 --- a/src/config.rs +++ b/src/config.rs @@ -202,7 +202,7 @@ pub fn init() -> Config { #[cfg(test)] mod test { - use crate::config::{BootNodes, ChainInclusionMode, Config}; + use crate::config::{BootNodes, Config}; use std::env; use std::str::FromStr; diff --git a/src/rules.rs b/src/rules.rs index 91f49ef..9ac8386 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -171,6 +171,9 @@ impl RuleContext { } } +#[cfg(test)] +use crate::storage::PremintStorage; + #[cfg(test)] impl RuleContext { pub async fn test_default() -> Self { @@ -482,8 +485,8 @@ mod test { } async fn simple_rule( - item: &PremintTypes, - context: &RuleContext, + _item: &PremintTypes, + _context: &RuleContext, ) -> eyre::Result { Ok(Accept) } @@ -546,7 +549,6 @@ mod test { #[tokio::test] async fn test_typed_rules_engine() { let (mut engine, storage) = test_rules_engine().await; - let context = RuleContext::test_default().await; let rule: Box> = typed_rule!(PremintTypes::Simple, simple_typed_rule); diff --git a/src/storage.rs b/src/storage.rs index ce5b8cf..389570a 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -334,7 +334,7 @@ mod test { use crate::storage::{ list_all, list_all_with_options, PremintStorage, QueryOptions, Reader, Writer, }; - use crate::types::{InclusionClaim, Premint, PremintTypes}; + use crate::types::{InclusionClaim, PremintTypes}; #[tokio::test] async fn test_insert_and_get() { diff --git a/tests/common/factories.rs b/tests/common/factories.rs index f0cdef1..e200390 100644 --- a/tests/common/factories.rs +++ b/tests/common/factories.rs @@ -1,4 +1,4 @@ -use alloy::primitives::{Address, U256}; +use alloy::primitives::Address; use mintpool::types::SimplePremint; use rand::{Rng, RngCore}; diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 56cbc99..148f3a7 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,4 +1,6 @@ pub mod factories; + +#[allow(dead_code)] pub mod mintpool_build { use mintpool::config::Config; use mintpool::controller::{ControllerCommands, ControllerInterface}; @@ -105,6 +107,7 @@ pub mod mintpool_build { } } +#[allow(dead_code)] pub mod helpers { use mintpool::controller::ControllerCommands; use mintpool::types::PremintTypes; @@ -126,6 +129,7 @@ pub mod helpers { } } +#[allow(dead_code)] pub mod asserts { pub async fn expect_n_connections(ctl: &mintpool::controller::ControllerInterface, n: usize) { let state = ctl diff --git a/tests/e2e_test.rs b/tests/e2e_test.rs index f7b8c49..fbb02fe 100644 --- a/tests/e2e_test.rs +++ b/tests/e2e_test.rs @@ -14,7 +14,7 @@ use alloy::signers::wallet::LocalWallet; use alloy::signers::Signer; use alloy::sol_types::{SolCall, SolValue}; use alloy::transports::{RpcError, TransportErrorKind}; -use mintpool::config::{BootNodes, ChainInclusionMode, Config}; +use mintpool::config::{ChainInclusionMode, Config}; use mintpool::controller::{ControllerCommands, DBQuery}; use mintpool::premints::zora_premint::contract::IZoraPremintV2::MintArguments; use mintpool::premints::zora_premint::contract::{IZoraPremintV2, PREMINT_FACTORY_ADDR}; @@ -23,8 +23,6 @@ use mintpool::rules::RulesEngine; use mintpool::run; use mintpool::types::PremintTypes; use std::env; -use std::fmt::Debug; -use std::str::FromStr; use std::time::Duration; /// This test does the full round trip lifecycle of a premint diff --git a/tests/p2p_test.rs b/tests/p2p_test.rs index 2a9383a..e53d9b2 100644 --- a/tests/p2p_test.rs +++ b/tests/p2p_test.rs @@ -55,7 +55,7 @@ async fn test_list_all_premints() { let nodes = mintpool_build::gen_fully_connected_swarm(2310, num_nodes).await; let (first, nodes) = mintpool_build::split_first_rest(nodes).await; - let (snd, rcv) = tokio::sync::oneshot::channel(); + let (snd, _rcv) = tokio::sync::oneshot::channel(); first .send_command(Broadcast { message: PremintTypes::ZoraV2(Default::default()), @@ -63,7 +63,7 @@ async fn test_list_all_premints() { }) .await .unwrap(); - let (snd, rcv) = tokio::sync::oneshot::channel(); + let (snd, _rcv) = tokio::sync::oneshot::channel(); first .send_command(Broadcast {