Skip to content

Commit 8694396

Browse files
authored
Feature/completing nymd client api (#732)
* Calculating gas fees * Ability to set custom fees * Added extra test * Removed commented code * Moved all msg types to common contract crate * Temporarily disabling get_tx method * Finishing up nymd client API * Comment fix * Remaining fee values * Some cleanup * Removed needless borrow * Fixed imports in contract tests * Made contract address optional to allow for contract upload and initialisation
1 parent fb253e5 commit 8694396

File tree

19 files changed

+645
-157
lines changed

19 files changed

+645
-157
lines changed

clients/validator/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ export default class ValidatorClient {
505505
}
506506

507507
/**
508-
* Gets list of all delegations towards particular mixnode.
508+
* Gets list of all delegations towards particular gateway.
509509
*
510510
* @param gatewayIdentity identity of the gateway to which the delegation was sent
511511
*/

common/client-libs/validator-client/src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ pub enum ValidatorClientError {
3232
#[error("There was an issue with the validator client - {0}")]
3333
ValidatorError(String),
3434

35+
#[cfg(feature = "nymd-client")]
36+
#[error("No contract address is available to perform the call")]
37+
NoContractAddressAvailable,
38+
3539
#[cfg(feature = "nymd-client")]
3640
#[error("There was an issue with bip32 - {0}")]
3741
Bip32Error(bip32::Error),

common/client-libs/validator-client/src/nymd/cosmwasm_client/client.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use cosmos_sdk::rpc::query::Query;
2222
use cosmos_sdk::rpc::{self, HttpClient, Order};
2323
use cosmos_sdk::tendermint::abci::Transaction;
2424
use cosmos_sdk::tendermint::{abci, block, chain};
25-
use cosmos_sdk::{tx, AccountId, Coin, Denom};
25+
use cosmos_sdk::{AccountId, Coin, Denom};
2626
use prost::Message;
2727
use serde::{Deserialize, Serialize};
2828
use std::convert::{TryFrom, TryInto};
@@ -162,9 +162,12 @@ pub trait CosmWasmClient: rpc::Client {
162162
.map_err(|_| ValidatorClientError::SerializationError("Coins".to_owned()))
163163
}
164164

165-
async fn get_tx(&self, id: tx::Hash) -> Result<TxResponse, ValidatorClientError> {
166-
Ok(self.tx(id, false).await?)
167-
}
165+
// disabled until https://github.com/tendermint/tendermint/issues/6802
166+
// and consequently https://github.com/informalsystems/tendermint-rs/issues/942 is resolved
167+
//
168+
// async fn get_tx(&self, id: tx::Hash) -> Result<TxResponse, ValidatorClientError> {
169+
// Ok(self.tx(id, false).await?)
170+
// }
168171

169172
async fn search_tx(&self, query: Query) -> Result<Vec<TxResponse>, ValidatorClientError> {
170173
// according to https://docs.tendermint.com/master/rpc/#/Info/tx_search

common/client-libs/validator-client/src/nymd/cosmwasm_client/signing_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pub trait SigningCosmWasmClient: CosmWasmClient {
233233
msg: &M,
234234
fee: Fee,
235235
memo: impl Into<String> + Send + 'static,
236-
funds: Option<Vec<Coin>>,
236+
funds: Vec<Coin>,
237237
) -> Result<ExecuteResult, ValidatorClientError>
238238
where
239239
M: ?Sized + Serialize + Sync,
@@ -242,7 +242,7 @@ pub trait SigningCosmWasmClient: CosmWasmClient {
242242
sender: sender_address.clone(),
243243
contract: contract_address.clone(),
244244
msg: serde_json::to_vec(msg)?,
245-
funds: funds.unwrap_or_default(),
245+
funds,
246246
}
247247
.to_msg()
248248
.map_err(|_| ValidatorClientError::SerializationError("MsgExecuteContract".to_owned()))?;

common/client-libs/validator-client/src/nymd/fee_helpers.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ pub enum Operation {
1515
Send,
1616

1717
BondMixnode,
18+
UnbondMixnode,
19+
DelegateToMixnode,
20+
UndelegateFromMixnode,
21+
22+
BondGateway,
23+
UnbondGateway,
24+
DelegateToGateway,
25+
UndelegateFromGateway,
26+
27+
UpdateStateParams,
1828
}
1929

2030
pub(crate) fn calculate_fee(gas_price: &GasPrice, gas_limit: Gas) -> Coin {
@@ -28,6 +38,7 @@ pub(crate) fn calculate_fee(gas_price: &GasPrice, gas_limit: Gas) -> Coin {
2838
}
2939

3040
impl Operation {
41+
// TODO: some value tweaking
3142
pub(crate) fn default_gas_limit(&self) -> Gas {
3243
match self {
3344
Operation::Upload => 2_500_000u64.into(),
@@ -37,6 +48,16 @@ impl Operation {
3748
Operation::Send => 80_000u64.into(),
3849

3950
Operation::BondMixnode => 175_000u64.into(),
51+
Operation::UnbondMixnode => 175_000u64.into(),
52+
Operation::DelegateToMixnode => 175_000u64.into(),
53+
Operation::UndelegateFromMixnode => 175_000u64.into(),
54+
55+
Operation::BondGateway => 175_000u64.into(),
56+
Operation::UnbondGateway => 175_000u64.into(),
57+
Operation::DelegateToGateway => 175_000u64.into(),
58+
Operation::UndelegateFromGateway => 175_000u64.into(),
59+
60+
Operation::UpdateStateParams => 175_000u64.into(),
4061
}
4162
}
4263

common/client-libs/validator-client/src/nymd/gas_price.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ impl Default for GasPrice {
5151
mod tests {
5252
use super::*;
5353

54+
#[test]
55+
fn default_gas_price_is_valid() {
56+
let _ = GasPrice::default();
57+
}
58+
5459
#[test]
5560
fn gas_price_parsing() {
5661
assert_eq!(

0 commit comments

Comments
 (0)