Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into range
Browse files Browse the repository at this point in the history
  • Loading branch information
NYBACHOK committed Oct 9, 2024
2 parents fc84882 + 2c3049c commit 4ed5fcb
Show file tree
Hide file tree
Showing 55 changed files with 1,873 additions and 741 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ members = [
"x/ibc-rs",
"x/slashing",
"x/staking",
"x/genutil",
"x/genutil", "x/upgrade",

# new unsorted
]
Expand Down
1 change: 0 additions & 1 deletion gaia-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pub mod config;
pub mod genesis;
pub mod message;
pub mod modules;
pub mod params;
pub mod query;
pub mod rest;
pub mod store_keys;
Expand Down
168 changes: 0 additions & 168 deletions gaia-rs/src/params.rs

This file was deleted.

4 changes: 2 additions & 2 deletions gears/src/application/handlers/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ pub trait TxHandler {

/// Handles query request, serialization and displaying it as `String`
pub trait QueryHandler {
/// Query request which contains all information needed for request
type QueryRequest: Query;
/// Additional context to use. \
/// In most cases you would expect this to be some sort of cli command
type QueryCommands;
/// Query request which contains all information needed for request
type QueryRequest: Query;
/// Serialized response from query request
type QueryResponse: Serialize;

Expand Down
2 changes: 1 addition & 1 deletion gears/src/application/handlers/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tendermint::types::{
};
use thiserror::Error;

pub trait ModuleInfo {
pub trait ModuleInfo: Clone + Sync + Send + 'static {
const NAME: &'static str;
}

Expand Down
25 changes: 25 additions & 0 deletions gears/src/baseapp/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::types::{address::AccAddress, base::coins::UnsignedCoins};
use serde::{de::DeserializeOwned, Serialize};

pub use null_genesis::NullGenesis;

#[derive(Debug, Clone, thiserror::Error)]
#[error("cannot add account at existing address {0}")]
pub struct GenesisError(pub AccAddress);
Expand All @@ -15,3 +17,26 @@ pub trait Genesis:
coins: UnsignedCoins,
) -> Result<(), GenesisError>;
}

mod null_genesis {
use super::*;

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct NullGenesis();

impl Default for NullGenesis {
fn default() -> Self {
Self()
}
}

impl Genesis for NullGenesis {
fn add_genesis_account(
&mut self,
_: AccAddress,
_: UnsignedCoins,
) -> Result<(), GenesisError> {
Ok(())
}
}
}
23 changes: 19 additions & 4 deletions gears/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ use core_types::errors::CoreError;
use cosmwasm_std::Decimal256RangeExceeded;
use tendermint::{error::Error as TendermintError, types::time::timestamp::NewTimestampError};

use crate::types::{
base::errors::{CoinError, CoinsError},
errors::DenomError,
tx::metadata::MetadataParseError,
use crate::{
params::SubspaceParseError,
types::{
base::errors::{CoinError, CoinsError},
errors::DenomError,
tx::metadata::MetadataParseError,
},
};

pub const POISONED_LOCK: &str = "poisoned lock";
Expand Down Expand Up @@ -73,3 +76,15 @@ impl From<std::convert::Infallible> for ProtobufError {
unreachable!("who would return infallible error?")
}
}

impl From<std::num::TryFromIntError> for ProtobufError {
fn from(value: std::num::TryFromIntError) -> Self {
Self::Custom(anyhow::anyhow!("{value}"))
}
}

impl From<SubspaceParseError> for ProtobufError {
fn from(value: SubspaceParseError) -> Self {
Self::Core(CoreError::DecodeGeneral(value.to_string()))
}
}
6 changes: 3 additions & 3 deletions gears/src/params/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ pub fn infallible_subspace_mut<
#[error("error parsing subpsace: {0}")]
pub struct SubspaceParseError(pub String);

pub trait ParamsSubspaceKey: Hash + Eq + Clone + Send + Sync + 'static {
fn name(&self) -> &'static str;
pub trait ParamsSubspaceKey: std::fmt::Debug + Hash + Eq + Clone + Send + Sync + 'static {
fn name(&self) -> String;

fn from_subspace_str(val: &str) -> Result<Self, SubspaceParseError>;
fn from_subspace_str(val: impl AsRef<str>) -> Result<Self, SubspaceParseError>;
}

// TODO:LATER For PR with xmod to change any params
Expand Down
11 changes: 6 additions & 5 deletions macros/key-derive/src/params_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,26 @@ pub fn expand_params(input: DeriveInput) -> syn::Result<TokenStream> {

let _ = set.insert(to_string.clone());

enum_variants.push(quote! { Self::#ident => #to_string });
enum_variants
.push(quote! { Self::#ident => ::std::borrow::ToOwned::to_owned(#to_string) });
from_str_impls.push(quote! { #to_string => Self::#ident });
}

let result = quote! {
impl #crate_prefix ::params::ParamsSubspaceKey for #ident
{
fn name(&self) -> &'static str
fn name(&self) -> String
{
match self{
#(#enum_variants),*
}
}

fn from_subspace_str(val: &str) -> ::std::result::Result<Self, #crate_prefix::params::SubspaceParseError> {
let result = match val
fn from_subspace_str(val: impl ::std::convert::AsRef<str>) -> ::std::result::Result<Self, #crate_prefix::params::SubspaceParseError> {
let result = match ::std::convert::AsRef::as_ref(&val)
{
#(#from_str_impls),*
, _ => ::std::result::Result::Err(#crate_prefix::params::SubspaceParseError(::std::format!("missing valid key: {val} not found")))?,
, _ => ::std::result::Result::Err(#crate_prefix::params::SubspaceParseError(::std::format!("missing valid key: {} not found", ::std::convert::AsRef::as_ref(&val) )))?,
};

::std::result::Result::Ok(result)
Expand Down
6 changes: 5 additions & 1 deletion macros/protobuf-derive/proto.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ _Example_: `RawProto` or `inner::RawProto`
**name** : _optional_, name of field that you want to use in raw structure.
If not specified tries to use structure with name `Raw{NameOfStructure}` \
**optional** : _flag_ indicates that raw structure field type of `Option<T>`. Exclusive to `repeated` flag. \
**repeated** : _flag_ indicates that raw structure filed type of `Vec<T>`. Exclusive to `optional` flag.
**repeated** : _flag_ indicates that raw structure filed type of `Vec<T>`. Exclusive to `optional` flag. \
**from** : _optional_ path to `fn` use to parse value *from* raw. \
**from_ref** : _optional_ indicates that value should be passed by ref to parsing `fn`. Note makes no sense without `from` flag. \
**into** : _optional_ path to `fn` use to parse value *into* raw. \
**into_ref** : _optional_ indicates that value should be passed by ref to parsing `fn`. Note makes no sense without `into` flag.

## Example

Expand Down
Loading

0 comments on commit 4ed5fcb

Please sign in to comment.