diff --git a/common/client-libs/validator-client/src/nymd/mod.rs b/common/client-libs/validator-client/src/nymd/mod.rs index 49f76edb09..490ac63511 100644 --- a/common/client-libs/validator-client/src/nymd/mod.rs +++ b/common/client-libs/validator-client/src/nymd/mod.rs @@ -181,6 +181,16 @@ impl NymdClient { operation.determine_fee(&self.gas_price, gas_limit) } + pub fn get_fee_multiple(&self, operation: Operation, times: u64) -> Fee { + let default_gas_limit = operation.default_gas_limit(); + let gas_limit_unit = self + .custom_gas_limits + .get(&operation) + .unwrap_or(&default_gas_limit); + let gas_limit = Gas::from(gas_limit_unit.value() * times); + Operation::determine_custom_fee(&self.gas_price, gas_limit) + } + pub fn calculate_custom_fee(&self, gas_limit: impl Into) -> Fee { Operation::determine_custom_fee(&self.gas_price, gas_limit.into()) } @@ -641,6 +651,40 @@ impl NymdClient { .await } + /// Announce multiple mixnodes on behalf of other owners, paying a fee. + pub async fn bond_multiple_mixnodes_on_behalf( + &self, + mixnode_bond: Vec, + ) -> Result + where + C: SigningCosmWasmClient + Sync, + { + let fee = self.get_fee_multiple(Operation::BondMixnodeOnBehalf, mixnode_bond.len() as u64); + + let reqs: Vec<(ExecuteMsg, Vec)> = mixnode_bond + .into_iter() + .map(|bond| { + ( + ExecuteMsg::BondMixnodeOnBehalf { + mix_node: bond.mix_node, + owner: bond.owner.to_string(), + }, + vec![cosmwasm_coin_to_cosmos_coin(bond.bond_amount)], + ) + }) + .collect(); + + self.client + .execute_multiple( + self.address(), + self.mixnet_contract_address()?, + reqs, + fee, + "Bonding multiple mixnodes on behalf from rust!", + ) + .await + } + /// Unbond a mixnode, removing it from the network and reclaiming staked coins pub async fn unbond_mixnode(&self) -> Result where