Skip to content

Commit 48bb03c

Browse files
committed
formatting
1 parent 7a57ce4 commit 48bb03c

File tree

3 files changed

+75
-27
lines changed

3 files changed

+75
-27
lines changed

primitives/examples/analytics_query.rs

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use primitives::{
2-
analytics::{AnalyticsQuery, Metric, Timeframe, query::{AllowedKey, Time}, OperatingSystem},
3-
sentry::{EventType, DateHour},
4-
Address, CampaignId, ChainId, IPFS
2+
analytics::{
3+
query::{AllowedKey, Time},
4+
AnalyticsQuery, Metric, OperatingSystem, Timeframe,
5+
},
6+
sentry::{DateHour, EventType},
7+
Address, CampaignId, ChainId, IPFS,
58
};
69
use std::str::FromStr;
710

@@ -61,20 +64,56 @@ fn main() {
6164
assert_eq!(query.event_type, EventType::Click);
6265
assert!(matches!(query.metric, Metric::Paid));
6366
assert_eq!(query.segment_by, Some(AllowedKey::Country));
64-
assert_eq!(query.time, Time {
65-
timeframe: Timeframe::Week,
66-
start: DateHour::from_ymdh(2021, 12, 31, 22),
67-
end: None,
68-
});
69-
assert_eq!(query.campaign_id, Some(CampaignId::from_str("0x936da01f9abd4d9d80c702af85c822a8").expect("should be valid")));
70-
assert_eq!(query.ad_unit, Some(IPFS::from_str("Qmasg8FrbuSQpjFu3kRnZF9beg8rEBFrqgi1uXDRwCbX5f").expect("should be valid")));
71-
assert_eq!(query.ad_slot, Some(IPFS::from_str("QmcUVX7fvoLMM93uN2bD3wGTH8MXSxeL8hojYfL2Lhp7mR").expect("should be valid")));
67+
assert_eq!(
68+
query.time,
69+
Time {
70+
timeframe: Timeframe::Week,
71+
start: DateHour::from_ymdh(2021, 12, 31, 22),
72+
end: None,
73+
}
74+
);
75+
assert_eq!(
76+
query.campaign_id,
77+
Some(
78+
CampaignId::from_str("0x936da01f9abd4d9d80c702af85c822a8")
79+
.expect("should be valid")
80+
)
81+
);
82+
assert_eq!(
83+
query.ad_unit,
84+
Some(
85+
IPFS::from_str("Qmasg8FrbuSQpjFu3kRnZF9beg8rEBFrqgi1uXDRwCbX5f")
86+
.expect("should be valid")
87+
)
88+
);
89+
assert_eq!(
90+
query.ad_slot,
91+
Some(
92+
IPFS::from_str("QmcUVX7fvoLMM93uN2bD3wGTH8MXSxeL8hojYfL2Lhp7mR")
93+
.expect("should be valid")
94+
)
95+
);
7296
assert_eq!(query.ad_slot_type, Some("legacy_300x100".to_string()));
73-
assert_eq!(query.advertiser, Some(Address::from_str("0xDd589B43793934EF6Ad266067A0d1D4896b0dff0").expect("should be valid")));
74-
assert_eq!(query.publisher, Some(Address::from_str("0xE882ebF439207a70dDcCb39E13CA8506c9F45fD9").expect("should be valid")));
97+
assert_eq!(
98+
query.advertiser,
99+
Some(
100+
Address::from_str("0xDd589B43793934EF6Ad266067A0d1D4896b0dff0")
101+
.expect("should be valid")
102+
)
103+
);
104+
assert_eq!(
105+
query.publisher,
106+
Some(
107+
Address::from_str("0xE882ebF439207a70dDcCb39E13CA8506c9F45fD9")
108+
.expect("should be valid")
109+
)
110+
);
75111
assert_eq!(query.hostname, Some("localhost".to_string()));
76112
assert_eq!(query.country, Some("Bulgaria".to_string()));
77-
assert_eq!(query.os_name, Some(OperatingSystem::Whitelisted("Windows".to_string())));
113+
assert_eq!(
114+
query.os_name,
115+
Some(OperatingSystem::Whitelisted("Windows".to_string()))
116+
);
78117
assert_eq!(query.chains, vec!(ChainId::new(1), ChainId::new(1337)));
79118
}
80-
}
119+
}

primitives/examples/create_campaign.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use primitives::{sentry::campaign_create::CreateCampaign, test_util::DUMMY_CAMPAIGN, CampaignId};
2-
use std::str::FromStr;
32
use serde_json::json;
3+
use std::str::FromStr;
44

55
fn main() {
66
// CreateCampaign in an HTTP request
@@ -38,16 +38,21 @@ fn main() {
3838
"activeTo":4073414400000_u64
3939
});
4040

41-
let create_campaign_json = serde_json::to_string(&create_campaign_json).expect("should serialize");
42-
let deserialized: CreateCampaign = serde_json::from_str(&create_campaign_json).expect("should deserialize");
41+
let create_campaign_json =
42+
serde_json::to_string(&create_campaign_json).expect("should serialize");
43+
let deserialized: CreateCampaign =
44+
serde_json::from_str(&create_campaign_json).expect("should deserialize");
4345

4446
assert_eq!(create_campaign, deserialized);
4547
}
4648

4749
// CreateCampaign with a provided ID
4850
{
49-
let mut create_campaign = CreateCampaign::from_campaign_erased(DUMMY_CAMPAIGN.clone(), None);
50-
create_campaign.id = Some(CampaignId::from_str("0x936da01f9abd4d9d80c702af85c822a8").expect("Should be valid id"));
51+
let mut create_campaign =
52+
CreateCampaign::from_campaign_erased(DUMMY_CAMPAIGN.clone(), None);
53+
create_campaign.id = Some(
54+
CampaignId::from_str("0x936da01f9abd4d9d80c702af85c822a8").expect("Should be valid id"),
55+
);
5156

5257
let create_campaign_json = json!({
5358
"id":"0x936da01f9abd4d9d80c702af85c822a8",
@@ -80,9 +85,11 @@ fn main() {
8085
"activeTo":4073414400000_u64
8186
});
8287

83-
let create_campaign_json = serde_json::to_string(&create_campaign_json).expect("should serialize");
84-
let deserialized: CreateCampaign = serde_json::from_str(&create_campaign_json).expect("should deserialize");
88+
let create_campaign_json =
89+
serde_json::to_string(&create_campaign_json).expect("should serialize");
90+
let deserialized: CreateCampaign =
91+
serde_json::from_str(&create_campaign_json).expect("should deserialize");
8592

8693
assert_eq!(create_campaign, deserialized);
8794
}
88-
}
95+
}

primitives/examples/modify_campaign.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use primitives::{sentry::campaign_modify::ModifyCampaign, unified_num::FromWhole, UnifiedNum};
2-
use std::str::FromStr;
32
use serde_json::json;
3+
use std::str::FromStr;
44

55
fn main() {
66
{
@@ -24,9 +24,11 @@ fn main() {
2424
"targeting_rules": null,
2525
});
2626

27-
let modify_campaign_json = serde_json::to_string(&modify_campaign_json).expect("should serialize");
28-
let deserialized: ModifyCampaign = serde_json::from_str(&modify_campaign_json).expect("should deserialize");
27+
let modify_campaign_json =
28+
serde_json::to_string(&modify_campaign_json).expect("should serialize");
29+
let deserialized: ModifyCampaign =
30+
serde_json::from_str(&modify_campaign_json).expect("should deserialize");
2931

3032
assert_eq!(modify_campaign, deserialized);
3133
}
32-
}
34+
}

0 commit comments

Comments
 (0)