Add gateway bond on behalf functions
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -654,14 +654,14 @@ impl<C> NymdClient<C> {
|
||||
/// Announce multiple mixnodes on behalf of other owners, paying a fee.
|
||||
pub async fn bond_multiple_mixnodes_on_behalf(
|
||||
&self,
|
||||
mixnode_bond: Vec<MixNodeBond>,
|
||||
mixnode_bonds: Vec<MixNodeBond>,
|
||||
) -> Result<ExecuteResult, NymdError>
|
||||
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<CosmosCoin>)> = mixnode_bond
|
||||
let reqs: Vec<(ExecuteMsg, Vec<CosmosCoin>)> = mixnode_bonds
|
||||
.into_iter()
|
||||
.map(|bond| {
|
||||
(
|
||||
@@ -856,6 +856,65 @@ impl<C> NymdClient<C> {
|
||||
.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<ExecuteResult, NymdError>
|
||||
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<GatewayBond>,
|
||||
) -> Result<ExecuteResult, NymdError>
|
||||
where
|
||||
C: SigningCosmWasmClient + Sync,
|
||||
{
|
||||
let fee = self.get_fee_multiple(Operation::BondGatewayOnBehalf, gateway_bonds.len() as u64);
|
||||
|
||||
let reqs: Vec<(ExecuteMsg, Vec<CosmosCoin>)> = 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<ExecuteResult, NymdError>
|
||||
where
|
||||
@@ -876,6 +935,27 @@ impl<C> NymdClient<C> {
|
||||
.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<ExecuteResult, NymdError>
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user