diff --git a/common/client-libs/validator-client/src/nymd/fee_helpers.rs b/common/client-libs/validator-client/src/nymd/fee_helpers.rs index 6f5b94e954..21d82ea429 100644 --- a/common/client-libs/validator-client/src/nymd/fee_helpers.rs +++ b/common/client-libs/validator-client/src/nymd/fee_helpers.rs @@ -26,7 +26,9 @@ pub enum Operation { UndelegateFromMixnodeOnBehalf, BondGateway, + BondGatewayOnBehalf, UnbondGateway, + UnbondGatewayOnBehalf, UpdateStateParams, @@ -51,7 +53,9 @@ impl fmt::Display for Operation { Operation::UnbondMixnode => f.write_str("UnbondMixnode"), Operation::UnbondMixnodeOnBehalf => f.write_str("UnbondMixnodeOnBehalf"), Operation::BondGateway => f.write_str("BondGateway"), + Operation::BondGatewayOnBehalf => f.write_str("BondGatewayOnBehalf"), Operation::UnbondGateway => f.write_str("UnbondGateway"), + Operation::UnbondGatewayOnBehalf => f.write_str("UnbondGatewayOnBehalf"), Operation::DelegateToMixnode => f.write_str("DelegateToMixnode"), Operation::DelegateToMixnodeOnBehalf => f.write_str("DelegateToMixnodeOnBehalf"), Operation::UndelegateFromMixnode => f.write_str("UndelegateFromMixnode"), @@ -85,7 +89,9 @@ impl Operation { Operation::UndelegateFromMixnodeOnBehalf => 175_000u64.into(), Operation::BondGateway => 175_000u64.into(), + Operation::BondGatewayOnBehalf => 200_000u64.into(), Operation::UnbondGateway => 175_000u64.into(), + Operation::UnbondGatewayOnBehalf => 200_000u64.into(), Operation::UpdateStateParams => 175_000u64.into(), Operation::BeginMixnodeRewarding => 175_000u64.into(), diff --git a/common/client-libs/validator-client/src/nymd/mod.rs b/common/client-libs/validator-client/src/nymd/mod.rs index 490ac63511..dcb09d8d41 100644 --- a/common/client-libs/validator-client/src/nymd/mod.rs +++ b/common/client-libs/validator-client/src/nymd/mod.rs @@ -654,14 +654,14 @@ impl NymdClient { /// Announce multiple mixnodes on behalf of other owners, paying a fee. pub async fn bond_multiple_mixnodes_on_behalf( &self, - mixnode_bond: Vec, + mixnode_bonds: Vec, ) -> Result where C: SigningCosmWasmClient + Sync, { - let fee = self.get_fee_multiple(Operation::BondMixnodeOnBehalf, mixnode_bond.len() as u64); + let fee = self.get_fee_multiple(Operation::BondMixnodeOnBehalf, mixnode_bonds.len() as u64); - let reqs: Vec<(ExecuteMsg, Vec)> = mixnode_bond + let reqs: Vec<(ExecuteMsg, Vec)> = mixnode_bonds .into_iter() .map(|bond| { ( @@ -856,6 +856,65 @@ impl NymdClient { .await } + /// Announce a gateway on behalf of the owner, paying a fee. + pub async fn bond_gateway_on_behalf( + &self, + gateway: Gateway, + owner: String, + bond: Coin, + ) -> Result + where + C: SigningCosmWasmClient + Sync, + { + let fee = self.get_fee(Operation::BondGatewayOnBehalf); + + let req = ExecuteMsg::BondGatewayOnBehalf { gateway, owner }; + self.client + .execute( + self.address(), + self.mixnet_contract_address()?, + &req, + fee, + "Bonding gateway on behalf from rust!", + vec![cosmwasm_coin_to_cosmos_coin(bond)], + ) + .await + } + + /// Announce multiple gateways on behalf of other owners, paying a fee. + pub async fn bond_multiple_gateways_on_behalf( + &self, + gateway_bonds: Vec, + ) -> Result + where + C: SigningCosmWasmClient + Sync, + { + let fee = self.get_fee_multiple(Operation::BondGatewayOnBehalf, gateway_bonds.len() as u64); + + let reqs: Vec<(ExecuteMsg, Vec)> = gateway_bonds + .into_iter() + .map(|bond| { + ( + ExecuteMsg::BondGatewayOnBehalf { + gateway: bond.gateway, + 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 gateways on behalf from rust!", + ) + .await + } + /// Unbond a gateway, removing it from the network and reclaiming staked coins pub async fn unbond_gateway(&self) -> Result where @@ -876,6 +935,27 @@ impl NymdClient { .await } + /// Unbond a gateway on behalf of the owner, removing it from the + /// network and reclaiming staked coins + pub async fn unbond_gateway_on_behalf(&self, owner: String) -> Result + where + C: SigningCosmWasmClient + Sync, + { + let fee = self.get_fee(Operation::UnbondGatewayOnBehalf); + + let req = ExecuteMsg::UnbondGatewayOnBehalf { owner }; + self.client + .execute( + self.address(), + self.mixnet_contract_address()?, + &req, + fee, + "Unbonding gateway on behalf from rust!", + Vec::new(), + ) + .await + } + pub async fn update_contract_settings( &self, new_params: ContractStateParams,