Skip to content

Commit

Permalink
Implemented 'keys add' and 'keys list' commmands (#408)
Browse files Browse the repository at this point in the history
* Added logic to generate GRPC client from cosmos.auth proto (#337)

* Adding logic to use GRPC client (#337)

* Grpc client connection retrieves account sequence (#337)

* Removed the account sequence flag from the tx raw commands (#337)

* Removed instructions to query and specify account sequence from tx raw command (#337)

* Logic to fetch GRPC endpoint address from config (#337)

* Fixing tests (#361)

* Logic to use the address from the key seed (#337)

* Added boilerplate code for a keys add command to the relayer (#363)

* Removing key flag from tx cmds

* Adding logic to get key specified in the config

* Logic to get the key specified in the config (#363)

* Removed the -k flag from the tx raw commands (#363)

* More logic to add key command (#363)

* key add command for memory store working (#363)

* Added logic to persist key seed in 'home' folder (#363)

* Changes implemented (#363):
- Added a new test keyring backend to support adding keys to file system (under home folder)
- Refactored logic to add key to be part of the keystore and not the command
- Switched the keybase on a chain to use the test keyring
- Key seed file is saved in the test keystore default folder (/home/andy/.rrly)

* Logic to use the key_name parameter from the config to add key. Removed name parameter from keys add cmd (#363)

* Changed the logic to get the key from the test keyring file store (#363)

* Implemented changes: (#363)
- Clean up remaining key_seed flag for tx cmds
- Refactored keybase to include chain config
- Refactoring keyring methods to use chain config
- Logic to use configured key to sign tx

* Updated the README instructions (#363)

* Disable the 'keys restore' command for now (#363)

* Added 'keys list' command to show key added on a chain (#363)

* Added entry for issue #363 (PR #408)

* Refactored the bound variables to use the full name per comment suggestion (#408)

* Move key retrieval, memo and timeout height inside send_tx

Co-authored-by: Anca Zamfir <[email protected]>
  • Loading branch information
andynog and ancazamfir authored Nov 24, 2020
1 parent 5f71413 commit a3303c3
Show file tree
Hide file tree
Showing 59 changed files with 1,460 additions and 1,082 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Special thanks to external contributors for this release: @CharlyCst ([#347]).
- CLI for client update message ([#277])
- Implement the relayer CLI for connection handshake messages ([#358], [#359], [#360])
- Implement the relayer CLI for channel handshake messages ([#371], [#372], [#373], [#374])
- Implement commands to add and list keys for a chain ([#363])
- [proto-compiler]
- Refactor and allow specifying a commit at which the Cosmos SDK should be checked out ([#366])
- Add a `--tag` option to the `clone-sdk` command to check out a tag instead of a commit ([#369])
Expand All @@ -38,6 +39,7 @@ Special thanks to external contributors for this release: @CharlyCst ([#347]).
[#358]: https://github.com/informalsystems/ibc-rs/issues/358
[#358]: https://github.com/informalsystems/ibc-rs/issues/359
[#358]: https://github.com/informalsystems/ibc-rs/issues/360
[#363]: https://github.com/informalsystems/ibc-rs/issues/363
[#366]: https://github.com/informalsystems/ibc-rs/issues/366
[#368]: https://github.com/informalsystems/ibc-rs/issues/368
[#369]: https://github.com/informalsystems/ibc-rs/pulls/369
Expand Down
112 changes: 94 additions & 18 deletions proto/src/prost/cosmos.auth.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,138 @@
/// type for additional functionality (e.g. vesting).
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BaseAccount {
#[prost(string, tag="1")]
#[prost(string, tag = "1")]
pub address: std::string::String,
#[prost(message, optional, tag="2")]
#[prost(message, optional, tag = "2")]
pub pub_key: ::std::option::Option<::prost_types::Any>,
#[prost(uint64, tag="3")]
#[prost(uint64, tag = "3")]
pub account_number: u64,
#[prost(uint64, tag="4")]
#[prost(uint64, tag = "4")]
pub sequence: u64,
}
/// ModuleAccount defines an account for modules that holds coins on a pool.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModuleAccount {
#[prost(message, optional, tag="1")]
#[prost(message, optional, tag = "1")]
pub base_account: ::std::option::Option<BaseAccount>,
#[prost(string, tag="2")]
#[prost(string, tag = "2")]
pub name: std::string::String,
#[prost(string, repeated, tag="3")]
#[prost(string, repeated, tag = "3")]
pub permissions: ::std::vec::Vec<std::string::String>,
}
/// Params defines the parameters for the auth module.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Params {
#[prost(uint64, tag="1")]
#[prost(uint64, tag = "1")]
pub max_memo_characters: u64,
#[prost(uint64, tag="2")]
#[prost(uint64, tag = "2")]
pub tx_sig_limit: u64,
#[prost(uint64, tag="3")]
#[prost(uint64, tag = "3")]
pub tx_size_cost_per_byte: u64,
#[prost(uint64, tag="4")]
#[prost(uint64, tag = "4")]
pub sig_verify_cost_ed25519: u64,
#[prost(uint64, tag="5")]
#[prost(uint64, tag = "5")]
pub sig_verify_cost_secp256k1: u64,
}
/// QueryAccountRequest is the request type for the Query/Account RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryAccountRequest {
/// address defines the address to query for.
#[prost(string, tag="1")]
#[prost(string, tag = "1")]
pub address: std::string::String,
}
/// QueryAccountResponse is the response type for the Query/Account RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryAccountResponse {
/// account defines the account of the corresponding address.
#[prost(message, optional, tag="1")]
#[prost(message, optional, tag = "1")]
pub account: ::std::option::Option<::prost_types::Any>,
}
/// QueryParamsRequest is the request type for the Query/Params RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsRequest {
}
pub struct QueryParamsRequest {}
/// QueryParamsResponse is the response type for the Query/Params RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsResponse {
/// params defines the parameters of the module.
#[prost(message, optional, tag="1")]
#[prost(message, optional, tag = "1")]
pub params: ::std::option::Option<Params>,
}
# [doc = r" Generated client implementations."] pub mod query_client { # ! [allow (unused_variables , dead_code , missing_docs)] use tonic :: codegen :: * ; # [doc = " Query defines the gRPC querier service."] pub struct QueryClient < T > { inner : tonic :: client :: Grpc < T > , } impl QueryClient < tonic :: transport :: Channel > { # [doc = r" Attempt to create a new client by connecting to a given endpoint."] pub async fn connect < D > (dst : D) -> Result < Self , tonic :: transport :: Error > where D : std :: convert :: TryInto < tonic :: transport :: Endpoint > , D :: Error : Into < StdError > , { let conn = tonic :: transport :: Endpoint :: new (dst) ? . connect () . await ? ; Ok (Self :: new (conn)) } } impl < T > QueryClient < T > where T : tonic :: client :: GrpcService < tonic :: body :: BoxBody > , T :: ResponseBody : Body + HttpBody + Send + 'static , T :: Error : Into < StdError > , < T :: ResponseBody as HttpBody > :: Error : Into < StdError > + Send , { pub fn new (inner : T) -> Self { let inner = tonic :: client :: Grpc :: new (inner) ; Self { inner } } pub fn with_interceptor (inner : T , interceptor : impl Into < tonic :: Interceptor >) -> Self { let inner = tonic :: client :: Grpc :: with_interceptor (inner , interceptor) ; Self { inner } } # [doc = " Account returns account details based on address."] pub async fn account (& mut self , request : impl tonic :: IntoRequest < super :: QueryAccountRequest > ,) -> Result < tonic :: Response < super :: QueryAccountResponse > , tonic :: Status > { self . inner . ready () . await . map_err (| e | { tonic :: Status :: new (tonic :: Code :: Unknown , format ! ("Service was not ready: {}" , e . into ())) }) ? ; let codec = tonic :: codec :: ProstCodec :: default () ; let path = http :: uri :: PathAndQuery :: from_static ("/cosmos.auth.v1beta1.Query/Account") ; self . inner . unary (request . into_request () , path , codec) . await } # [doc = " Params queries all parameters."] pub async fn params (& mut self , request : impl tonic :: IntoRequest < super :: QueryParamsRequest > ,) -> Result < tonic :: Response < super :: QueryParamsResponse > , tonic :: Status > { self . inner . ready () . await . map_err (| e | { tonic :: Status :: new (tonic :: Code :: Unknown , format ! ("Service was not ready: {}" , e . into ())) }) ? ; let codec = tonic :: codec :: ProstCodec :: default () ; let path = http :: uri :: PathAndQuery :: from_static ("/cosmos.auth.v1beta1.Query/Params") ; self . inner . unary (request . into_request () , path , codec) . await } } impl < T : Clone > Clone for QueryClient < T > { fn clone (& self) -> Self { Self { inner : self . inner . clone () , } } } impl < T > std :: fmt :: Debug for QueryClient < T > { fn fmt (& self , f : & mut std :: fmt :: Formatter < '_ >) -> std :: fmt :: Result { write ! (f , "QueryClient {{ ... }}") } } }
#[doc = r" Generated client implementations."]
pub mod query_client {
#![allow(unused_variables, dead_code, missing_docs)]
use tonic::codegen::*;
#[doc = " Query defines the gRPC querier service."]
pub struct QueryClient<T> {
inner: tonic::client::Grpc<T>,
}
impl QueryClient<tonic::transport::Channel> {
#[doc = r" Attempt to create a new client by connecting to a given endpoint."]
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: std::convert::TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> QueryClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
T::Error: Into<StdError>,
<T::ResponseBody as HttpBody>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_interceptor(inner: T, interceptor: impl Into<tonic::Interceptor>) -> Self {
let inner = tonic::client::Grpc::with_interceptor(inner, interceptor);
Self { inner }
}
#[doc = " Account returns account details based on address."]
pub async fn account(
&mut self,
request: impl tonic::IntoRequest<super::QueryAccountRequest>,
) -> Result<tonic::Response<super::QueryAccountResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/cosmos.auth.v1beta1.Query/Account");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " Params queries all parameters."]
pub async fn params(
&mut self,
request: impl tonic::IntoRequest<super::QueryParamsRequest>,
) -> Result<tonic::Response<super::QueryParamsResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/cosmos.auth.v1beta1.Query/Params");
self.inner.unary(request.into_request(), path, codec).await
}
}
impl<T: Clone> Clone for QueryClient<T> {
fn clone(&self) -> Self {
Self {
inner: self.inner.clone(),
}
}
}
impl<T> std::fmt::Debug for QueryClient<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "QueryClient {{ ... }}")
}
}
}
70 changes: 35 additions & 35 deletions proto/src/prost/cosmos.base.abci.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,144 +3,144 @@
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TxResponse {
/// The block height
#[prost(int64, tag="1")]
#[prost(int64, tag = "1")]
pub height: i64,
/// The transaction hash.
#[prost(string, tag="2")]
#[prost(string, tag = "2")]
pub txhash: std::string::String,
/// Namespace for the Code
#[prost(string, tag="3")]
#[prost(string, tag = "3")]
pub codespace: std::string::String,
/// Response code.
#[prost(uint32, tag="4")]
#[prost(uint32, tag = "4")]
pub code: u32,
/// Result bytes, if any.
#[prost(string, tag="5")]
#[prost(string, tag = "5")]
pub data: std::string::String,
/// The output of the application's logger (raw string). May be
/// non-deterministic.
#[prost(string, tag="6")]
#[prost(string, tag = "6")]
pub raw_log: std::string::String,
/// The output of the application's logger (typed). May be non-deterministic.
#[prost(message, repeated, tag="7")]
#[prost(message, repeated, tag = "7")]
pub logs: ::std::vec::Vec<AbciMessageLog>,
/// Additional information. May be non-deterministic.
#[prost(string, tag="8")]
#[prost(string, tag = "8")]
pub info: std::string::String,
/// Amount of gas requested for transaction.
#[prost(int64, tag="9")]
#[prost(int64, tag = "9")]
pub gas_wanted: i64,
/// Amount of gas consumed by transaction.
#[prost(int64, tag="10")]
#[prost(int64, tag = "10")]
pub gas_used: i64,
/// The request transaction bytes.
#[prost(message, optional, tag="11")]
#[prost(message, optional, tag = "11")]
pub tx: ::std::option::Option<::prost_types::Any>,
/// Time of the previous block. For heights > 1, it's the weighted median of
/// the timestamps of the valid votes in the block.LastCommit. For height == 1,
/// it's genesis time.
#[prost(string, tag="12")]
#[prost(string, tag = "12")]
pub timestamp: std::string::String,
}
/// ABCIMessageLog defines a structure containing an indexed tx ABCI message log.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AbciMessageLog {
#[prost(uint32, tag="1")]
#[prost(uint32, tag = "1")]
pub msg_index: u32,
#[prost(string, tag="2")]
#[prost(string, tag = "2")]
pub log: std::string::String,
/// Events contains a slice of Event objects that were emitted during some
/// execution.
#[prost(message, repeated, tag="3")]
#[prost(message, repeated, tag = "3")]
pub events: ::std::vec::Vec<StringEvent>,
}
/// StringEvent defines en Event object wrapper where all the attributes
/// contain key/value pairs that are strings instead of raw bytes.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StringEvent {
#[prost(string, tag="1")]
#[prost(string, tag = "1")]
pub r#type: std::string::String,
#[prost(message, repeated, tag="2")]
#[prost(message, repeated, tag = "2")]
pub attributes: ::std::vec::Vec<Attribute>,
}
/// Attribute defines an attribute wrapper where the key and value are
/// strings instead of raw bytes.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Attribute {
#[prost(string, tag="1")]
#[prost(string, tag = "1")]
pub key: std::string::String,
#[prost(string, tag="2")]
#[prost(string, tag = "2")]
pub value: std::string::String,
}
/// GasInfo defines tx execution gas context.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GasInfo {
/// GasWanted is the maximum units of work we allow this tx to perform.
#[prost(uint64, tag="1")]
#[prost(uint64, tag = "1")]
pub gas_wanted: u64,
/// GasUsed is the amount of gas actually consumed.
#[prost(uint64, tag="2")]
#[prost(uint64, tag = "2")]
pub gas_used: u64,
}
/// Result is the union of ResponseFormat and ResponseCheckTx.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Result {
/// Data is any data returned from message or handler execution. It MUST be
/// length prefixed in order to separate data from multiple message executions.
#[prost(bytes, tag="1")]
#[prost(bytes, tag = "1")]
pub data: std::vec::Vec<u8>,
/// Log contains the log information from message or handler execution.
#[prost(string, tag="2")]
#[prost(string, tag = "2")]
pub log: std::string::String,
/// Events contains a slice of Event objects that were emitted during message
/// or handler execution.
#[prost(message, repeated, tag="3")]
#[prost(message, repeated, tag = "3")]
pub events: ::std::vec::Vec<::tendermint_proto::abci::Event>,
}
/// SimulationResponse defines the response generated when a transaction is
/// successfully simulated.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SimulationResponse {
#[prost(message, optional, tag="1")]
#[prost(message, optional, tag = "1")]
pub gas_info: ::std::option::Option<GasInfo>,
#[prost(message, optional, tag="2")]
#[prost(message, optional, tag = "2")]
pub result: ::std::option::Option<Result>,
}
/// MsgData defines the data returned in a Result object during message
/// execution.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgData {
#[prost(string, tag="1")]
#[prost(string, tag = "1")]
pub msg_type: std::string::String,
#[prost(bytes, tag="2")]
#[prost(bytes, tag = "2")]
pub data: std::vec::Vec<u8>,
}
/// TxMsgData defines a list of MsgData. A transaction will have a MsgData object
/// for each message.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TxMsgData {
#[prost(message, repeated, tag="1")]
#[prost(message, repeated, tag = "1")]
pub data: ::std::vec::Vec<MsgData>,
}
/// SearchTxsResult defines a structure for querying txs pageable
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SearchTxsResult {
/// Count of all txs
#[prost(uint64, tag="1")]
#[prost(uint64, tag = "1")]
pub total_count: u64,
/// Count of txs in current page
#[prost(uint64, tag="2")]
#[prost(uint64, tag = "2")]
pub count: u64,
/// Index of current page, start from 1
#[prost(uint64, tag="3")]
#[prost(uint64, tag = "3")]
pub page_number: u64,
/// Count of total pages
#[prost(uint64, tag="4")]
#[prost(uint64, tag = "4")]
pub page_total: u64,
/// Max count txs per page
#[prost(uint64, tag="5")]
#[prost(uint64, tag = "5")]
pub limit: u64,
/// List of txs in current page
#[prost(message, repeated, tag="6")]
#[prost(message, repeated, tag = "6")]
pub txs: ::std::vec::Vec<TxResponse>,
}
6 changes: 3 additions & 3 deletions proto/src/prost/cosmos.base.kv.v1beta1.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/// Pairs defines a repeated slice of Pair objects.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Pairs {
#[prost(message, repeated, tag="1")]
#[prost(message, repeated, tag = "1")]
pub pairs: ::std::vec::Vec<Pair>,
}
/// Pair defines a key/value bytes tuple.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Pair {
#[prost(bytes, tag="1")]
#[prost(bytes, tag = "1")]
pub key: std::vec::Vec<u8>,
#[prost(bytes, tag="2")]
#[prost(bytes, tag = "2")]
pub value: std::vec::Vec<u8>,
}
Loading

0 comments on commit a3303c3

Please sign in to comment.