Skip to content

Commit a620dc0

Browse files
authored
Merge pull request #455 from AmbireTech/rust-1-56
Rust 1.56 & edition 2021 - run rustfmt & clippy --fix
2 parents db78289 + 1d89991 commit a620dc0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+304
-234
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adapter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [
66
"Lachezar Lechev <[email protected]>",
77
"Omidiora Samuel <[email protected]>",
88
]
9-
edition = "2018"
9+
edition = "2021"
1010

1111
[features]
1212

adapter/src/dummy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ mod test {
182182
#[tokio::test]
183183
async fn test_deposits_calls() {
184184
let config = DEVELOPMENT_CONFIG.clone();
185-
let channel = DUMMY_CAMPAIGN.channel.clone();
185+
let channel = DUMMY_CAMPAIGN.channel;
186186
let adapter = DummyAdapter::init(
187187
DummyAdapterOptions {
188188
dummy_identity: IDS["leader"],

adapter/src/ethereum.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use primitives::{
1515
use reqwest::Client;
1616
use serde::{Deserialize, Serialize};
1717
use serde_json::Value;
18-
use std::{convert::TryFrom, fs, str::FromStr};
18+
use std::{fs, str::FromStr};
1919
use thiserror::Error;
2020
use tiny_keccak::Keccak;
2121
use web3::{
@@ -502,7 +502,6 @@ mod test {
502502
use super::*;
503503
use chrono::Utc;
504504
use primitives::{config::DEVELOPMENT_CONFIG, util::tests::prep_db::IDS};
505-
use std::convert::TryFrom;
506505
use web3::{transports::Http, Web3};
507506
use wiremock::{
508507
matchers::{method, path},
@@ -543,15 +542,15 @@ mod test {
543542
ValidatorId::try_from("2892f6C41E0718eeeDd49D98D648C789668cA67d")
544543
.expect("Failed to parse id"),
545544
"8bc45d8eb27f4c98cab35d17b0baecc2a263d6831ef0800f4c190cbfac6d20a3",
546-
&signature,
545+
signature,
547546
)
548547
.expect("Failed to verify signatures");
549548

550549
let signature2 = "0x9fa5852041b9818021323aff8260624fd6998c52c95d9ad5036e0db6f2bf2b2d48a188ec1d638581ff56b0a2ecceca6d3880fc65030558bd8f68b154e7ebf80f1b";
551550
let message2 = "1648231285e69677531ffe70719f67a07f3d4393b8425a5a1c84b0c72434c77b";
552551

553552
let verify2 = eth_adapter
554-
.verify(IDS["leader"], message2, &signature2)
553+
.verify(IDS["leader"], message2, signature2)
555554
.expect("Failed to verify signatures");
556555

557556
assert!(verify, "invalid signature 1 verification");
@@ -635,7 +634,7 @@ mod test {
635634

636635
#[tokio::test]
637636
async fn get_deposit_and_count_create2_when_min_tokens_received() {
638-
let web3 = Web3::new(Http::new(&GANACHE_URL).expect("failed to init transport"));
637+
let web3 = Web3::new(Http::new(GANACHE_URL).expect("failed to init transport"));
639638

640639
let leader_account = GANACHE_ADDRESSES["leader"];
641640

adapter/src/ethereum/test_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use once_cell::sync::Lazy;
2-
use std::{collections::HashMap, convert::TryFrom, env::current_dir, num::NonZeroU8};
2+
use std::{collections::HashMap, env::current_dir, num::NonZeroU8};
33
use web3::{
44
contract::{Contract, Options},
55
ethabi::Token,

adapter/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ pub fn get_balance_leaf(
7171

7272
#[cfg(test)]
7373
mod test {
74-
use std::convert::TryFrom;
75-
7674
use byteorder::{BigEndian, ByteOrder};
7775
use chrono::{TimeZone, Utc};
7876

adview-manager/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
authors = ["Ambire <[email protected]>", "Lachezar Lechev <[email protected]>"]
3-
edition = "2018"
3+
edition = "2021"
44
name = "adview-manager"
55
version = "0.1.0"
66

adview-manager/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use slog::{error, Logger};
1919
use std::{
2020
cmp::Ordering,
2121
collections::VecDeque,
22-
convert::TryFrom,
2322
ops::{Add, Mul},
2423
sync::Arc,
2524
};
@@ -601,7 +600,7 @@ mod test {
601600

602601
fn get_ad_unit(media_mime: &str) -> AdUnit {
603602
AdUnit {
604-
id: DUMMY_IPFS[0].clone(),
603+
id: DUMMY_IPFS[0],
605604
media_url: "".to_string(),
606605
media_mime: media_mime.to_string(),
607606
target_url: "".to_string(),
@@ -610,8 +609,8 @@ mod test {
610609

611610
#[test]
612611
fn test_is_video() {
613-
assert_eq!(true, is_video(&get_ad_unit("video/avi")));
614-
assert_eq!(false, is_video(&get_ad_unit("image/jpeg")));
612+
assert!(is_video(&get_ad_unit("video/avi")));
613+
assert!(!is_video(&get_ad_unit("image/jpeg")));
615614
}
616615

617616
#[test]
@@ -634,7 +633,7 @@ mod test {
634633
#[test]
635634
fn test_randomized_position() {
636635
let ad_unit = AdUnit {
637-
id: DUMMY_IPFS[0].clone(),
636+
id: DUMMY_IPFS[0],
638637
media_url: "ipfs://QmWWQSuPMS6aXCbZKpEjPHPUZN2NjB3YrhJTHsV4X3vb2t".to_string(),
639638
media_mime: "image/jpeg".to_string(),
640639
target_url: "https://google.com".to_string(),

primitives/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ authors = [
66
"Lachezar Lechev <[email protected]>",
77
"Omidiora Samuel <[email protected]>",
88
]
9-
edition = "2018"
9+
edition = "2021"
1010

1111
[features]
12-
postgres = ["postgres-types", "bytes", "tokio-postgres", "deadpool-postgres"]
12+
postgres = ["bytes", "tokio-postgres", "deadpool-postgres"]
1313

1414
[dependencies]
1515
# (De)Serialization
@@ -50,7 +50,6 @@ num-derive = "0.3"
5050
fake = { version = "^1.3", features = ["chrono"] }
5151
rand = "^0.8"
5252
# postgres feature
53-
postgres-types = { version = "0.2.0", features = ["with-serde_json-1"], optional = true }
5453
bytes = { version = "^1", optional = true }
5554
tokio-postgres = { version = "0.7", optional = true, features = [
5655
"with-chrono-0_4",
@@ -63,7 +62,6 @@ deadpool-postgres = { version = "0.9.0", optional = true }
6362
futures = "0.3"
6463
async-trait = "0.1"
6564
# Other
66-
lazy_static = "1.4.0"
6765
once_cell = "^1.8"
6866

6967
[dev-dependencies]

primitives/src/ad_unit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ mod postgres {
5858
use super::AdUnit;
5959

6060
use bytes::BytesMut;
61-
use postgres_types::{accepts, to_sql_checked, FromSql, IsNull, Json, ToSql, Type};
6261
use std::error::Error;
62+
use tokio_postgres::types::{accepts, to_sql_checked, FromSql, IsNull, Json, ToSql, Type};
6363
impl<'a> FromSql<'a> for AdUnit {
6464
fn from_sql(ty: &Type, raw: &'a [u8]) -> Result<Self, Box<dyn Error + Sync + Send>> {
6565
let json = <Json<Self> as FromSql>::from_sql(ty, raw)?;

primitives/src/address.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use hex::{FromHex, FromHexError};
22
use serde::{Deserialize, Serialize, Serializer};
3-
use std::{convert::TryFrom, fmt, str::FromStr};
3+
use std::{fmt, str::FromStr};
44
use thiserror::Error;
55

66
use crate::{targeting::Value, DomainError, ToETHChecksum, ToHex};
@@ -177,8 +177,8 @@ pub mod postgres {
177177
use super::Address;
178178
use crate::ToETHChecksum;
179179
use bytes::BytesMut;
180-
use postgres_types::{FromSql, IsNull, ToSql, Type};
181180
use std::error::Error;
181+
use tokio_postgres::types::{FromSql, IsNull, ToSql, Type};
182182

183183
impl<'a> FromSql<'a> for Address {
184184
fn from_sql(ty: &Type, raw: &'a [u8]) -> Result<Self, Box<dyn Error + Sync + Send>> {

primitives/src/balances.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{convert::TryFrom, marker::PhantomData};
1+
use std::marker::PhantomData;
22

33
use crate::{Address, UnifiedMap, UnifiedNum};
44
use serde::{de::DeserializeOwned, Deserialize, Serialize};

primitives/src/big_num.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::{
2-
convert::TryFrom,
32
fmt,
43
iter::Sum,
54
ops::{Add, AddAssign, Div, Mul, Sub},
@@ -323,13 +322,11 @@ where
323322
pub mod postgres {
324323
use super::BigNum;
325324
use bytes::BytesMut;
326-
use postgres_types::{FromSql, IsNull, ToSql, Type};
327325
use std::error::Error;
326+
use tokio_postgres::types::{FromSql, IsNull, ToSql, Type};
328327

329328
impl<'a> FromSql<'a> for BigNum {
330329
fn from_sql(ty: &Type, raw: &'a [u8]) -> Result<BigNum, Box<dyn Error + Sync + Send>> {
331-
use std::convert::TryInto;
332-
333330
let str_slice = <&str as FromSql>::from_sql(ty, raw)?;
334331

335332
Ok(str_slice.try_into()?)

primitives/src/campaign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ mod postgres {
375375

376376
use super::{Active, Campaign, CampaignId, PricingBounds, Validators};
377377
use bytes::BytesMut;
378-
use postgres_types::{accepts, to_sql_checked, FromSql, IsNull, Json, ToSql, Type};
379378
use std::error::Error;
379+
use tokio_postgres::types::{accepts, to_sql_checked, FromSql, IsNull, Json, ToSql, Type};
380380
use tokio_postgres::Row;
381381

382382
impl From<&Row> for Campaign {

primitives/src/chain.rs

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
1-
use lazy_static::lazy_static;
1+
use once_cell::sync::Lazy;
22
use serde::{Deserialize, Serialize};
33
use std::{collections::HashMap, fmt};
44

5-
lazy_static! {
6-
pub static ref CHAINS: HashMap<ChainId, Chain> = {
7-
let mut map = HashMap::new();
8-
map.insert(
9-
ChainId(1),
10-
Chain {
11-
chain_id: ChainId(1),
12-
name: "Ethereum Mainnet",
13-
short: "eth",
14-
network: "mainnet",
15-
},
16-
);
5+
pub static CHAINS: Lazy<HashMap<ChainId, Chain>> = Lazy::new(|| {
6+
let mut map = HashMap::new();
7+
map.insert(
8+
ChainId(1),
9+
Chain {
10+
chain_id: ChainId(1),
11+
name: "Ethereum Mainnet",
12+
short: "eth",
13+
network: "mainnet",
14+
},
15+
);
1716

18-
map.insert(
19-
ChainId(5),
20-
Chain {
21-
chain_id: ChainId(5),
22-
name: "Ethereum Testnet Görli",
23-
short: "gor",
24-
network: "goerli",
25-
},
26-
);
17+
map.insert(
18+
ChainId(5),
19+
Chain {
20+
chain_id: ChainId(5),
21+
name: "Ethereum Testnet Görli",
22+
short: "gor",
23+
network: "goerli",
24+
},
25+
);
2726

28-
map.insert(
29-
ChainId(100),
30-
Chain {
31-
chain_id: ChainId(100),
32-
name: "xDAI Chain",
33-
short: "xdai",
34-
network: "mainnet",
35-
},
36-
);
27+
map.insert(
28+
ChainId(100),
29+
Chain {
30+
chain_id: ChainId(100),
31+
name: "xDAI Chain",
32+
short: "xdai",
33+
network: "mainnet",
34+
},
35+
);
3736

38-
map
39-
};
40-
}
37+
map
38+
});
4139

4240
/// Ethereum Virtual Machine Chain
4341
/// see https://chainid.network

primitives/src/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ pub mod postgres {
298298
use super::{Channel, ChannelId, Nonce};
299299
use bytes::BytesMut;
300300
use hex::FromHex;
301-
use postgres_types::{accepts, to_sql_checked, FromSql, IsNull, ToSql, Type};
302301
use std::error::Error;
302+
use tokio_postgres::types::{accepts, to_sql_checked, FromSql, IsNull, ToSql, Type};
303303
use tokio_postgres::Row;
304304

305305
impl<'a> FromSql<'a> for ChannelId {

primitives/src/event_submission.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ mod postgres {
3232
use super::EventSubmission;
3333

3434
use bytes::BytesMut;
35-
use postgres_types::{accepts, to_sql_checked, FromSql, IsNull, Json, ToSql, Type};
3635
use std::error::Error;
36+
use tokio_postgres::types::{accepts, to_sql_checked, FromSql, IsNull, Json, ToSql, Type};
3737

3838
impl<'a> FromSql<'a> for EventSubmission {
3939
fn from_sql(ty: &Type, raw: &'a [u8]) -> Result<Self, Box<dyn Error + Sync + Send>> {

primitives/src/ipfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use serde::{Deserialize, Serialize};
22

3-
use std::{convert::TryFrom, fmt, str::FromStr};
3+
use std::{fmt, str::FromStr};
44
use thiserror::Error;
55

66
const URL_PREFIX: &str = "ipfs://";

primitives/src/sentry.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct MessageResponse<T: MessageType> {
3535
}
3636

3737
pub mod message {
38-
use std::{convert::TryFrom, ops::Deref};
38+
use std::ops::Deref;
3939

4040
use crate::validator::messages::*;
4141
use serde::{Deserialize, Serialize};
@@ -608,10 +608,11 @@ mod postgres {
608608
validator::{messages::Type as MessageType, MessageTypes},
609609
};
610610
use bytes::BytesMut;
611-
use postgres_types::{accepts, to_sql_checked, IsNull, Json, ToSql, Type};
612611
use serde::Deserialize;
613-
use std::convert::TryFrom;
614-
use tokio_postgres::{Error, Row};
612+
use tokio_postgres::{
613+
types::{accepts, to_sql_checked, IsNull, Json, ToSql, Type},
614+
Error, Row,
615+
};
615616

616617
impl From<&Row> for EventAggregate {
617618
fn from(row: &Row) -> Self {

primitives/src/targeting/eval.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::UnifiedNum;
22
use serde::{Deserialize, Serialize};
33
use serde_json::{value::Value as SerdeValue, Number};
44
use std::{
5-
convert::TryFrom,
65
fmt,
76
ops::{Add, Div, Mul, Rem, Sub},
87
str::FromStr,
@@ -1228,8 +1227,8 @@ fn math_operator(lhs: Number, rhs: Number, ops: MathOperator) -> Result<Number,
12281227
pub mod postgres {
12291228
use super::*;
12301229
use bytes::BytesMut;
1231-
use postgres_types::{accepts, to_sql_checked, FromSql, IsNull, Json, ToSql, Type};
12321230
use std::error::Error;
1231+
use tokio_postgres::types::{accepts, to_sql_checked, FromSql, IsNull, Json, ToSql, Type};
12331232

12341233
impl ToSql for Rules {
12351234
fn to_sql(

primitives/src/targeting/input/field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use parse_display::{Display as DeriveDisplay, FromStr as DeriveFromStr};
22
use serde::{Deserialize, Serialize};
3-
use std::{convert::TryFrom, str::FromStr};
3+
use std::str::FromStr;
44

55
use crate::targeting::Error;
66

0 commit comments

Comments
 (0)