Skip to content

Commit

Permalink
Merge pull request #99 from osmosis-labs/fix/account-query
Browse files Browse the repository at this point in the history
Any serialization for account query
  • Loading branch information
iboss-ptk authored Oct 17, 2023
2 parents 6d1390f + e7e6302 commit d64174e
Show file tree
Hide file tree
Showing 38 changed files with 478 additions and 425 deletions.
22 changes: 22 additions & 0 deletions packages/osmosis-std/src/serde/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,25 @@ pub mod as_str_vec {
vec_of_strings.serialize(serializer)
}
}

pub mod as_base64_encoded_string {
use cosmwasm_std::Binary;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};

pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
where
D: Deserializer<'de>,
{
let encoded_string = String::deserialize(deserializer)?;
Binary::from_base64(&encoded_string)
.map(|b| b.to_vec())
.map_err(de::Error::custom)
}

pub fn serialize<S>(values: &[u8], serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
Binary(values.to_vec()).to_base64().serialize(serializer)
}
}
8 changes: 4 additions & 4 deletions packages/osmosis-std/src/types/cosmos/base/abci/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ pub struct Result {
/// length prefixed in order to separate data from multiple message executions.
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub data: ::prost::alloc::vec::Vec<u8>,
/// Log contains the log information from message or handler execution.
Expand Down Expand Up @@ -243,8 +243,8 @@ pub struct MsgData {
pub msg_type: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub data: ::prost::alloc::vec::Vec<u8>,
}
Expand Down
8 changes: 4 additions & 4 deletions packages/osmosis-std/src/types/cosmos/base/kv/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ pub struct Pairs {
pub struct Pair {
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub value: ::prost::alloc::vec::Vec<u8>,
}
8 changes: 4 additions & 4 deletions packages/osmosis-std/src/types/cosmos/base/query/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub struct PageRequest {
/// should be set.
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub key: ::prost::alloc::vec::Vec<u8>,
/// offset is a numeric offset that can be used when key is unavailable.
Expand Down Expand Up @@ -81,8 +81,8 @@ pub struct PageResponse {
/// query the next page most efficiently
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub next_key: ::prost::alloc::vec::Vec<u8>,
/// total is total number of results available if PageRequest.count_total
Expand Down
16 changes: 8 additions & 8 deletions packages/osmosis-std/src/types/cosmos/base/snapshots/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ pub struct Snapshot {
pub chunks: u32,
#[prost(bytes = "vec", tag = "4")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub hash: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "5")]
Expand Down Expand Up @@ -136,14 +136,14 @@ pub struct SnapshotStoreItem {
pub struct SnapshotIavlItem {
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub value: ::prost::alloc::vec::Vec<u8>,
/// version is block height
Expand Down Expand Up @@ -200,8 +200,8 @@ pub struct SnapshotExtensionMeta {
pub struct SnapshotExtensionPayload {
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub payload: ::prost::alloc::vec::Vec<u8>,
}
Expand Down
12 changes: 6 additions & 6 deletions packages/osmosis-std/src/types/cosmos/base/store/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ pub struct CommitId {
pub version: i64,
#[prost(bytes = "vec", tag = "2")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub hash: ::prost::alloc::vec::Vec<u8>,
}
Expand Down Expand Up @@ -100,14 +100,14 @@ pub struct StoreKvPair {
pub delete: bool,
#[prost(bytes = "vec", tag = "3")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "4")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub value: ::prost::alloc::vec::Vec<u8>,
}
8 changes: 4 additions & 4 deletions packages/osmosis-std/src/types/cosmos/crypto/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use osmosis_std_derive::CosmwasmExt;
pub struct PubKey {
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub key: ::prost::alloc::vec::Vec<u8>,
}
Expand All @@ -41,8 +41,8 @@ pub struct PubKey {
pub struct PrivKey {
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub key: ::prost::alloc::vec::Vec<u8>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pub struct CompactBitArray {
pub extra_bits_stored: u32,
#[prost(bytes = "vec", tag = "2")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub elems: ::prost::alloc::vec::Vec<u8>,
}
8 changes: 4 additions & 4 deletions packages/osmosis-std/src/types/cosmos/crypto/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use osmosis_std_derive::CosmwasmExt;
pub struct PubKey {
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub key: ::prost::alloc::vec::Vec<u8>,
}
Expand All @@ -40,8 +40,8 @@ pub struct PubKey {
pub struct PrivKey {
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub key: ::prost::alloc::vec::Vec<u8>,
}
8 changes: 4 additions & 4 deletions packages/osmosis-std/src/types/cosmos/crypto/secp256r1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub struct PubKey {
/// 4.3.6 of ANSI X9.62: <https://webstore.ansi.org/standards/ascx9/ansix9621998>
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub key: ::prost::alloc::vec::Vec<u8>,
}
Expand All @@ -39,8 +39,8 @@ pub struct PrivKey {
/// secret number serialized using big-endian encoding
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub secret: ::prost::alloc::vec::Vec<u8>,
}
8 changes: 4 additions & 4 deletions packages/osmosis-std/src/types/cosmos/evidence/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ pub struct QueryEvidenceRequest {
/// evidence_hash defines the hash of the requested evidence.
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub evidence_hash: ::prost::alloc::vec::Vec<u8>,
}
Expand Down Expand Up @@ -175,8 +175,8 @@ pub struct MsgSubmitEvidenceResponse {
/// hash defines the hash of the evidence.
#[prost(bytes = "vec", tag = "4")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub hash: ::prost::alloc::vec::Vec<u8>,
}
Expand Down
20 changes: 10 additions & 10 deletions packages/osmosis-std/src/types/cosmos/gov/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,37 +246,37 @@ pub struct TallyParams {
/// considered valid.
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub quorum: ::prost::alloc::vec::Vec<u8>,
/// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
#[prost(bytes = "vec", tag = "2")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub threshold: ::prost::alloc::vec::Vec<u8>,
/// Minimum value of Veto votes to Total votes ratio for proposal to be
/// vetoed. Default value: 1/3.
#[prost(bytes = "vec", tag = "3")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub veto_threshold: ::prost::alloc::vec::Vec<u8>,
/// Minimum proportion of Yes votes for an expedited proposal to pass. Default value: 0.67.
#[prost(bytes = "vec", tag = "4")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub expedited_threshold: ::prost::alloc::vec::Vec<u8>,
/// Minimum proportion of Yes votes for an expedited proposal to reach quorum. Default value: 0.67.
#[prost(bytes = "vec", tag = "5")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub expedited_quorum: ::prost::alloc::vec::Vec<u8>,
}
Expand Down
8 changes: 4 additions & 4 deletions packages/osmosis-std/src/types/cosmos/mint/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ pub struct QueryInflationResponse {
/// inflation is the current minting inflation value.
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub inflation: ::prost::alloc::vec::Vec<u8>,
}
Expand Down Expand Up @@ -192,8 +192,8 @@ pub struct QueryAnnualProvisionsResponse {
/// annual_provisions is the current minting annual provisions value.
#[prost(bytes = "vec", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub annual_provisions: ::prost::alloc::vec::Vec<u8>,
}
Expand Down
12 changes: 6 additions & 6 deletions packages/osmosis-std/src/types/cosmos/slashing/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ pub struct Params {
pub signed_blocks_window: i64,
#[prost(bytes = "vec", tag = "2")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub min_signed_per_window: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "3")]
pub downtime_jail_duration: ::core::option::Option<crate::shim::Duration>,
#[prost(bytes = "vec", tag = "4")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub slash_fraction_double_sign: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "5")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub slash_fraction_downtime: ::prost::alloc::vec::Vec<u8>,
}
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/src/types/cosmos/staking/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,8 @@ pub struct GenesisState {
/// the previous end block.
#[prost(bytes = "vec", tag = "2")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub last_total_power: ::prost::alloc::vec::Vec<u8>,
/// last_validator_powers is a special index that provides a historical list
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/src/types/cosmos/tx/signing/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ pub mod signature_descriptor {
/// signature is the raw signature bytes
#[prost(bytes = "vec", tag = "2")]
#[serde(
serialize_with = "crate::serde::as_str_vec::serialize",
deserialize_with = "crate::serde::as_str_vec::deserialize"
serialize_with = "crate::serde::as_base64_encoded_string::serialize",
deserialize_with = "crate::serde::as_base64_encoded_string::deserialize"
)]
pub signature: ::prost::alloc::vec::Vec<u8>,
}
Expand Down
Loading

0 comments on commit d64174e

Please sign in to comment.