@@ -5,7 +5,7 @@ use adex_primitives::{
5
5
supermarket:: units_for_slot,
6
6
supermarket:: units_for_slot:: response:: { AdUnit , Campaign } ,
7
7
targeting:: { self , input, Value } ,
8
- BigNum , ChannelId , SpecValidators , IPFS ,
8
+ BigNum , ChannelId , SpecValidators , ValidatorId , IPFS ,
9
9
} ;
10
10
use async_std:: { sync:: RwLock , task:: block_on} ;
11
11
use chrono:: { DateTime , Utc } ;
@@ -42,17 +42,13 @@ lazy_static! {
42
42
43
43
#[ derive( Serialize , Deserialize ) ]
44
44
#[ serde( rename_all = "camelCase" ) ]
45
- // const defaultOpts = {
46
- // marketURL: 'https://market.moonicorn.network',
47
- // whitelistedTokens: ['0x6B175474E89094C44Da98b954EedeAC495271d0F'],
48
- // disableVideo: false,
49
- // }
45
+ // TODO: Add Default Ops somehow?
50
46
pub struct Options {
51
47
// Defaulted via defaultOpts
52
48
#[ serde( rename = "marketURL" ) ]
53
- pub market_url : String ,
49
+ pub market_url : Url ,
54
50
pub market_slot : IPFS ,
55
- pub publisher_addr : String ,
51
+ pub publisher_addr : ValidatorId ,
56
52
// All passed tokens must be of the same price and decimals, so that the amounts can be accurately compared
57
53
pub whitelisted_tokens : Vec < String > ,
58
54
pub width : Option < u64 > ,
@@ -83,7 +79,7 @@ pub struct HistoryEntry {
83
79
struct Event {
84
80
#[ serde( rename = "type" ) ]
85
81
event_type : String ,
86
- publisher : String ,
82
+ publisher : ValidatorId ,
87
83
ad_unit : IPFS ,
88
84
ad_slot : IPFS ,
89
85
#[ serde( rename = "ref" ) ]
@@ -156,7 +152,7 @@ fn is_video(ad_unit: &AdUnit) -> bool {
156
152
ad_unit. media_mime . split ( '/' ) . next ( ) == Some ( "video" )
157
153
}
158
154
159
- /// Does not copy the JS impl, instead it generates the BigNum from the IPFS CID bytes instead
155
+ /// Does not copy the JS impl, instead it generates the BigNum from the IPFS CID bytes
160
156
fn randomized_sort_pos ( ad_unit : & AdUnit , seed : BigNum ) -> BigNum {
161
157
let bytes = ad_unit. id . 0 . to_bytes ( ) ;
162
158
@@ -220,7 +216,7 @@ pub fn get_unit_html_with_events(
220
216
let get_body = |event_type : & str | EventBody {
221
217
events : vec ! [ Event {
222
218
event_type: event_type. to_string( ) ,
223
- publisher: options. publisher_addr. clone ( ) ,
219
+ publisher: options. publisher_addr,
224
220
ad_unit: ad_unit. id. clone( ) ,
225
221
ad_slot: options. market_slot. clone( ) ,
226
222
referrer: "document.referrer" . to_string( ) ,
@@ -405,13 +401,7 @@ impl Manager {
405
401
pub async fn get_market_demand_resp (
406
402
& self ,
407
403
) -> Result < units_for_slot:: response:: Response , Error > {
408
- let pub_prefix: String = self
409
- . options
410
- . publisher_addr
411
- . chars ( )
412
- . skip ( 2 )
413
- . take ( 10 )
414
- . collect ( ) ;
404
+ let pub_prefix: String = self . options . publisher_addr . to_hex_non_prefix_string ( ) ;
415
405
416
406
let deposit_asset = self
417
407
. options
@@ -421,8 +411,10 @@ impl Manager {
421
411
. collect :: < Vec < _ > > ( )
422
412
. join ( "&" ) ;
423
413
414
+
415
+ // Url adds a trailing `/`
424
416
let url = format ! (
425
- "{}/ units-for-slot/{}?pubPrefix={}&{}" ,
417
+ "{}units-for-slot/{}?pubPrefix={}&{}" ,
426
418
self . options. market_url, self . options. market_slot, pub_prefix, deposit_asset
427
419
) ;
428
420
@@ -562,7 +554,7 @@ impl Manager {
562
554
None
563
555
}
564
556
} )
565
- // TODO: Check what should happen here
557
+ // TODO: Check what should happen here if we don't find the Validator
566
558
. unwrap ( ) ;
567
559
568
560
let html = get_unit_html_with_events (
0 commit comments