Skip to content

Commit 2f2bcae

Browse files
authored
Merge pull request #297 from AdExNetwork/issue-296-aip-31-targeting
Issue #296 AIP#31 Targeting eval()
2 parents e566cb8 + dd83bcf commit 2f2bcae

File tree

6 files changed

+791
-15
lines changed

6 files changed

+791
-15
lines changed

Cargo.lock

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

primitives/src/big_num.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ impl TryFrom<&str> for BigNum {
197197
}
198198
}
199199

200+
impl FromStr for BigNum {
201+
type Err = super::DomainError;
202+
203+
fn from_str(s: &str) -> Result<Self, Self::Err> {
204+
BigNum::try_from(s)
205+
}
206+
}
207+
200208
impl ToString for BigNum {
201209
fn to_string(&self) -> String {
202210
self.0.to_str_radix(10)

primitives/src/channel.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ pub struct PricingBounds {
102102
pub click: Option<Pricing>,
103103
}
104104

105+
impl PricingBounds {
106+
pub fn to_vec(&self) -> Vec<(&str, Pricing)> {
107+
let mut vec = Vec::new();
108+
109+
if let Some(pricing) = self.impression.as_ref() {
110+
vec.push(("IMPRESSION", pricing.clone()));
111+
}
112+
113+
if let Some(pricing) = self.click.as_ref() {
114+
vec.push(("CLICK", pricing.clone()))
115+
}
116+
117+
vec
118+
}
119+
}
120+
105121
#[derive(Serialize, Deserialize, Debug, Clone)]
106122
#[serde(rename_all = "camelCase")]
107123
pub struct ChannelSpec {

primitives/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub mod event_submission;
1515
pub mod market;
1616
pub mod merkle_tree;
1717
pub mod sentry;
18+
pub mod targeting;
1819
pub mod targeting_tag;
1920
pub mod util {
2021
pub mod tests {

0 commit comments

Comments
 (0)