Skip to content

Commit

Permalink
Rework new_change_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Jan 8, 2024
1 parent 28ba246 commit 8362f07
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 17 deletions.
48 changes: 48 additions & 0 deletions sdk/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,54 @@ impl<C: NamadaTypes> MetaDataChange<C> {
..self
}
}

/// New validator email
pub fn email(self, email: String) -> Self {
Self {
email: Some(email),
..self
}
}

/// New validator description
pub fn description(self, description: String) -> Self {
Self {
description: Some(description),
..self
}
}

/// New validator website
pub fn website(self, website: String) -> Self {
Self {
website: Some(website),
..self
}
}

/// New validator discord handle
pub fn discord_handle(self, discord_handle: String) -> Self {
Self {
discord_handle: Some(discord_handle),
..self
}
}

/// New validator avatar url
pub fn avatar(self, avatar: String) -> Self {
Self {
avatar: Some(avatar),
..self
}
}

/// New validator commission rate
pub fn commission_rate(self, commission_rate: Dec) -> Self {
Self {
commission_rate: Some(commission_rate),
..self
}
}
}

impl MetaDataChange {
Expand Down
24 changes: 7 additions & 17 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,25 +338,15 @@ pub trait Namada: Sized + MaybeSync + MaybeSend {

/// Make a CommissionRateChange builder from the given minimum set of
/// arguments
#[allow(clippy::too_many_arguments)]
fn new_change_metadata(
&self,
validator: Address,
email: Option<String>,
description: Option<String>,
website: Option<String>,
discord_handle: Option<String>,
avatar: Option<String>,
commission_rate: Option<Dec>,
) -> args::MetaDataChange {
fn new_change_metadata(&self, validator: Address) -> args::MetaDataChange {
args::MetaDataChange {
validator,
email,
description,
website,
discord_handle,
avatar,
commission_rate,
email: None,
description: None,
website: None,
discord_handle: None,
avatar: None,
commission_rate: None,
tx_code_path: PathBuf::from(TX_CHANGE_METADATA_WASM),
tx: self.tx_builder(),
}
Expand Down

0 comments on commit 8362f07

Please sign in to comment.