@@ -139,6 +139,18 @@ where
139
139
deserializer. deserialize_any ( DurationVisitor )
140
140
}
141
141
142
+ fn deserialize_option_string < ' de , D > ( deserializer : D ) -> Result < Option < String > , D :: Error >
143
+ where
144
+ D : Deserializer < ' de > ,
145
+ {
146
+ let s = String :: deserialize ( deserializer) ?;
147
+ if s. is_empty ( ) {
148
+ Ok ( None )
149
+ } else {
150
+ Ok ( Some ( s) )
151
+ }
152
+ }
153
+
142
154
pub fn missing_string_value ( ) -> String {
143
155
MISSING_VALUE . to_string ( )
144
156
}
@@ -380,6 +392,11 @@ impl Config {
380
392
self
381
393
}
382
394
395
+ pub fn with_incentives_address < S : Into < String > > ( mut self , incentives_address : S ) -> Self {
396
+ self . gateway . incentives_address = Some ( incentives_address. into ( ) ) ;
397
+ self
398
+ }
399
+
383
400
// getters
384
401
pub fn get_config_file_save_location ( & self ) -> PathBuf {
385
402
self . config_directory ( ) . join ( Self :: config_file_name ( ) )
@@ -464,6 +481,10 @@ impl Config {
464
481
pub fn get_version ( & self ) -> & str {
465
482
& self . gateway . version
466
483
}
484
+
485
+ pub fn get_incentives_address ( & self ) -> Option < String > {
486
+ self . gateway . incentives_address . clone ( )
487
+ }
467
488
}
468
489
469
490
#[ derive( Debug , Deserialize , PartialEq , Serialize ) ]
@@ -500,6 +521,10 @@ pub struct Gateway {
500
521
/// nym_home_directory specifies absolute path to the home nym gateways directory.
501
522
/// It is expected to use default value and hence .toml file should not redefine this field.
502
523
nym_root_directory : PathBuf ,
524
+
525
+ /// Optional, if participating in the incentives program, payment address.
526
+ #[ serde( deserialize_with = "deserialize_option_string" ) ]
527
+ incentives_address : Option < String > ,
503
528
}
504
529
505
530
impl Gateway {
@@ -536,6 +561,7 @@ impl Default for Gateway {
536
561
public_sphinx_key_file : Default :: default ( ) ,
537
562
validator_rest_url : DEFAULT_VALIDATOR_REST_ENDPOINT . to_string ( ) ,
538
563
nym_root_directory : Config :: default_root_directory ( ) ,
564
+ incentives_address : None ,
539
565
}
540
566
}
541
567
}
0 commit comments