Skip to content

Commit b6226d6

Browse files
committed
Merge branch 'aip-61-adex-v5' into remove_create2
2 parents 0435725 + fb34b48 commit b6226d6

File tree

19 files changed

+1377
-467
lines changed

19 files changed

+1377
-467
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ members = [
1111
"test_harness",
1212
]
1313

14-
[patch.crates-io]
15-
postgres-types = { git = "https://github.com/elpiel/rust-postgres", branch = "boxed-dyn-ToSql"}
14+
# [patch.crates-io]
15+
# postgres-types = { git = "https://github.com/elpiel/rust-postgres", branch = "boxed-dyn-ToSql"}

adapter/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ thiserror = "1"
3030

3131
# Time handling
3232
chrono = "0.4"
33-
serde = { version = "^1.0", features = ["derive"] }
33+
serde = { version = "1.0", features = ["derive"] }
3434
serde_json = "1.0"
3535
hex = "0.4"
3636
base64 = "0.13"
37-
once_cell = "^1.8"
37+
once_cell = "1.8"
3838
# Macro for easier derive of Display & FromStr
39-
parse-display = "^0.5.0"
39+
parse-display = "0.5"
4040

4141
[dev-dependencies]
42-
byteorder = "^1.4"
43-
tokio = { version = "^1", features = ["macros", "rt-multi-thread"] }
42+
byteorder = "1.4"
43+
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
4444
pretty_assertions = "1"

adview-manager/Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ name = "adview-manager"
55
version = "0.1.0"
66
license = "AGPL-3.0"
77

8+
[package.metadata.docs.rs]
9+
all-features = true
10+
rustdoc-args = ["--cfg", "docsrs"]
11+
812
[dependencies]
913
# Domain
1014
adex_primitives = { path = "../primitives", package = "primitives", features = [
@@ -13,19 +17,15 @@ adex_primitives = { path = "../primitives", package = "primitives", features = [
1317
chrono = "0.4"
1418
num-integer = "0.1"
1519
# (De)Serialization & Http requests
16-
serde = { version = "^1.0", features = ["derive"] }
17-
serde_json = "^1.0"
20+
serde = { version = "1", features = ["derive"] }
21+
serde_json = "1"
1822
reqwest = { version = "0.11", features = ["json"] }
19-
url = { version = "^2.1", features = ["serde"] }
23+
url = { version = "2", features = ["serde"] }
2024
# Logging
2125
log = "0.4"
2226
# Async
23-
async-std = "^1.8"
27+
async-std = "1"
2428
# Other
25-
once_cell = "^1.8"
26-
thiserror = "^1.0"
27-
rand = "^0.8"
28-
29-
[package.metadata.docs.rs]
30-
all-features = true
31-
rustdoc-args = ["--cfg", "docsrs"]
29+
once_cell = "1"
30+
thiserror = "1"
31+
rand = "0.8"

primitives/Cargo.toml

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,70 +10,77 @@ authors = [
1010
edition = "2021"
1111
license = "AGPL-3.0"
1212

13+
[package.metadata.docs.rs]
14+
all-features = true
15+
rustdoc-args = ["--cfg", "docsrs"]
16+
1317
[features]
1418
postgres = ["bytes", "tokio-postgres", "deadpool-postgres"]
1519
# Enables the testing utilities like addresses, dummy Campaigns, Validators, IPFSes, AdUnits, etc.
1620
# All Addresses and keystore files exist in the ganache-cli setup for testing with the EthereumAdapter
1721
test-util = []
1822

23+
[[example]]
24+
name = "channel_list_query"
25+
required-features = ["test-util"]
26+
27+
[[example]]
28+
name = "campaign_list_query"
29+
required-features = ["test-util"]
30+
31+
[[example]]
32+
name = "campaign_list_response"
33+
required-features = ["test-util"]
34+
1935
[dependencies]
2036
# (De)Serialization
21-
serde = { version = "^1.0", features = ['derive'] }
37+
serde = { version = "1.0", features = ["derive"] }
2238
serde_json = "1.0"
2339
# TODO: Remove once we change `ChannelId` Serialize impl
24-
serde-hex = "0.1.0"
25-
serde_millis = "0.1.1"
40+
serde-hex = "0.1"
41+
serde_millis = "0.1"
2642
# Used prefixes on field for targeting::Input, and `campaign::Active`
27-
serde_with = "1.9"
43+
serde_with = "1"
2844
# Configuration
2945
toml = "0.5"
3046
# Logging
31-
slog = { version = "^2.5.2", features = ["max_level_trace"] }
32-
slog-term = "^2.4.2"
33-
slog-async = "^2.3.0"
47+
slog = { version = "2", features = ["max_level_trace"] }
48+
slog-term = "2"
49+
slog-async = "2"
3450
# Domain
35-
thiserror = "^1.0"
51+
thiserror = "1"
3652
chrono = { version = "0.4", features = ["serde"] }
37-
# time = "0.1.42"
38-
uuid = { version = "0.8", features = ["v4"] }
53+
uuid = { version = "1", features = ["v4"] }
3954
# For encoding the Channel to a ChannelId
40-
ethabi = "14.0.0"
55+
ethabi = "17"
4156
# For the nonce U256
42-
ethereum-types = "0.11"
57+
ethereum-types = "0.13"
4358
# Macro for easier derive of Display & FromStr
44-
parse-display = "^0.5.0"
59+
parse-display = "0.5"
4560
# CID & multihash / multibase
4661
cid = "0.8"
4762
hex = "0.4"
48-
merkletree = "0.10.0"
49-
tiny-keccak = { version = "^2.0", features = ["keccak"] }
50-
url = { version = "=2.2", features = ["serde"] }
63+
merkletree = "0.10"
64+
tiny-keccak = { version = "2", features = ["keccak"] }
65+
url = { version = "2", features = ["serde"] }
5166
# Numbers - BigNum, Numbers, Traits and Derives
5267
num = { version = "0.4", features = ["serde", "num-bigint"] }
5368
num-traits = "0.2"
5469
num-derive = "0.3"
55-
# Fixtures
56-
rand = "^0.8"
5770
# postgres feature
58-
bytes = { version = "^1", optional = true }
71+
bytes = { version = "1", optional = true }
5972
tokio-postgres = { version = "0.7", optional = true, features = [
6073
"with-chrono-0_4",
6174
"with-serde_json-1",
6275
] }
6376
# testing FromSql & ToSql implementation of structs
6477
deadpool-postgres = { version = "0.10", optional = true }
6578

66-
# Futures
67-
futures = "0.3"
6879
async-trait = "0.1"
6980
# Other
70-
once_cell = "^1.8"
81+
once_cell = "1"
7182

7283
[dev-dependencies]
7384
pretty_assertions = "1"
7485
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
75-
serde_qs = "^0.9"
76-
77-
[package.metadata.docs.rs]
78-
all-features = true
79-
rustdoc-args = ["--cfg", "docsrs"]
86+
serde_qs = "0.9"
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
use chrono::{TimeZone, Utc};
2+
use primitives::{
3+
sentry::campaign_list::{CampaignListQuery, ValidatorParam},
4+
test_util::{ADVERTISER, FOLLOWER, IDS, LEADER},
5+
};
6+
7+
fn main() {
8+
// Empty query - default values only
9+
{
10+
let empty_query = "";
11+
let query: CampaignListQuery = serde_qs::from_str(empty_query).unwrap();
12+
13+
assert_eq!(0, query.page);
14+
assert!(
15+
Utc::now() >= query.active_to_ge,
16+
"By default `activeTo` is set to `Utc::now()`"
17+
);
18+
assert!(query.creator.is_none());
19+
assert!(query.validator.is_none());
20+
}
21+
22+
// In the following examples we always use `activeTo`
23+
// as it makes simpler examples for assertions rather than using the default `Utc::now()`
24+
25+
// Query with `activeTo` only
26+
{
27+
let active_to_query = "activeTo=1624192200";
28+
let active_to = CampaignListQuery {
29+
page: 0,
30+
active_to_ge: Utc.ymd(2021, 6, 20).and_hms(12, 30, 0),
31+
creator: None,
32+
validator: None,
33+
};
34+
35+
assert_eq!(active_to, serde_qs::from_str(active_to_query).unwrap());
36+
}
37+
38+
// Query with `page` & `activeTo`
39+
{
40+
let with_page_query = "page=14&activeTo=1624192200";
41+
let with_page = CampaignListQuery {
42+
page: 14,
43+
active_to_ge: Utc.ymd(2021, 6, 20).and_hms(12, 30, 0),
44+
creator: None,
45+
validator: None,
46+
};
47+
48+
assert_eq!(with_page, serde_qs::from_str(with_page_query).unwrap());
49+
}
50+
51+
// Query with `creator`
52+
{
53+
let with_creator_query =
54+
"activeTo=1624192200&creator=0xDd589B43793934EF6Ad266067A0d1D4896b0dff0";
55+
56+
let with_creator = CampaignListQuery {
57+
page: 0,
58+
active_to_ge: Utc.ymd(2021, 6, 20).and_hms(12, 30, 0),
59+
creator: Some(*ADVERTISER),
60+
validator: None,
61+
};
62+
63+
assert_eq!(
64+
with_creator,
65+
serde_qs::from_str(with_creator_query).unwrap()
66+
);
67+
}
68+
69+
// Query with `validator`
70+
// You can either have `leader` or `validator` but not both!
71+
{
72+
let with_creator_validator_query =
73+
"activeTo=1624192200&validator=0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7";
74+
let with_creator_validator = CampaignListQuery {
75+
page: 0,
76+
active_to_ge: Utc.ymd(2021, 6, 20).and_hms(12, 30, 0),
77+
creator: None,
78+
validator: Some(ValidatorParam::Validator(IDS[&FOLLOWER])),
79+
};
80+
81+
assert_eq!(
82+
with_creator_validator,
83+
serde_qs::from_str(with_creator_validator_query).unwrap()
84+
);
85+
}
86+
87+
// Query with `leader`
88+
// You can either have `leader` or `validator` but not both!
89+
{
90+
let with_leader_query =
91+
"activeTo=1624192200&leader=0x80690751969B234697e9059e04ed72195c3507fa";
92+
93+
let with_leader = CampaignListQuery {
94+
page: 0,
95+
active_to_ge: Utc.ymd(2021, 6, 20).and_hms(12, 30, 0),
96+
creator: None,
97+
validator: Some(ValidatorParam::Leader(IDS[&LEADER])),
98+
};
99+
100+
assert_eq!(with_leader, serde_qs::from_str(with_leader_query).unwrap());
101+
}
102+
103+
// Query with all parameters and `validator`
104+
// You can either have `leader` or `validator` but not both!
105+
{
106+
let full_query = "page=14&activeTo=1624192200&creator=0xDd589B43793934EF6Ad266067A0d1D4896b0dff0&validator=0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7";
107+
let full_expected = CampaignListQuery {
108+
page: 14,
109+
active_to_ge: Utc.ymd(2021, 6, 20).and_hms(12, 30, 0),
110+
creator: Some(*ADVERTISER),
111+
validator: Some(ValidatorParam::Validator(IDS[&FOLLOWER])),
112+
};
113+
114+
assert_eq!(full_expected, serde_qs::from_str(full_query).unwrap());
115+
}
116+
}

0 commit comments

Comments
 (0)