layer_climb_core/
prelude.rs1pub(crate) use crate::network::apply_grpc_height;
4pub(crate) use anyhow::{anyhow, bail, Context, Result};
5pub(crate) use layer_climb_address::{Address, ConfigAddressExt};
6pub(crate) use layer_climb_config::*;
7pub(crate) use layer_climb_proto::{proto_into_any, proto_into_bytes, Message};
8
9pub use crate::{
11 cache::ClimbCache,
12 contract_helpers::contract_str_to_msg,
13 events::CosmosTxEvents,
14 querier::{Connection, ConnectionMode, QueryClient, QueryRequest},
15 signing::SigningClient,
16 transaction::TxBuilder,
17};
18
19#[cfg(not(target_arch = "wasm32"))]
20pub use crate::pool::*;
21
22pub fn new_coin(amount: impl ToString, denom: impl ToString) -> layer_climb_proto::Coin {
28 layer_climb_proto::Coin {
29 denom: denom.to_string(),
30 amount: amount.to_string(),
31 }
32}
33
34pub fn new_coins(
46 coins: impl IntoIterator<Item = (impl ToString, impl ToString)>,
47) -> Vec<layer_climb_proto::Coin> {
48 coins
49 .into_iter()
50 .map(|(amount, denom)| new_coin(amount, denom))
51 .collect()
52}
53
54pub enum AnyClient {
57 Signing(SigningClient),
58 Query(QueryClient),
59}
60
61impl AnyClient {
62 pub fn as_signing(&self) -> &SigningClient {
65 match self {
66 Self::Signing(client) => client,
67 Self::Query(_) => panic!("Expected SigningClient, got QueryClient"),
68 }
69 }
70
71 pub fn as_querier(&self) -> &QueryClient {
73 match self {
74 Self::Query(client) => client,
75 Self::Signing(client) => &client.querier,
76 }
77 }
78}
79
80impl From<SigningClient> for AnyClient {
81 fn from(client: SigningClient) -> Self {
82 Self::Signing(client)
83 }
84}
85
86impl From<QueryClient> for AnyClient {
87 fn from(client: QueryClient) -> Self {
88 Self::Query(client)
89 }
90}
91
92impl TryFrom<AnyClient> for SigningClient {
93 type Error = anyhow::Error;
94
95 fn try_from(value: AnyClient) -> Result<Self> {
96 match value {
97 AnyClient::Signing(client) => Ok(client),
98 AnyClient::Query(_) => Err(anyhow!("Expected SigningClient, got QueryClient")),
99 }
100 }
101}
102
103impl From<AnyClient> for QueryClient {
104 fn from(client: AnyClient) -> Self {
105 match client {
106 AnyClient::Query(client) => client,
107 AnyClient::Signing(client) => client.querier,
108 }
109 }
110}