Skip to content

Commit

Permalink
feat: allow key_format = { type = "cosmos-json" } (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig authored Oct 18, 2021
1 parent 2a76bfa commit 687c163
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
60 changes: 60 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ abscissa_tokio = { version = "=0.6.0-pre.2", optional = true }
bytes_v0_5 = { version = "0.5", package = "bytes" }
bytes = "1"
chrono = "0.4"
cosmrs = "0.2.1"
ed25519-dalek = "1"
eyre = "0.6"
getrandom = "0.1"
Expand Down
6 changes: 6 additions & 0 deletions src/keyring/format.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Chain-specific key configuration
use cosmrs::crypto::PublicKey;
use serde::Deserialize;
use subtle_encoding::bech32;
use tendermint::TendermintKey;
Expand All @@ -18,6 +19,10 @@ pub enum Format {
consensus_key_prefix: String,
},

/// JSON-encoded Cosmos protobuf representation of keys
#[serde(rename = "cosmos-json")]
CosmosJson,

/// Hex is a baseline representation
#[serde(rename = "hex")]
Hex,
Expand All @@ -36,6 +41,7 @@ impl Format {
}
TendermintKey::ConsensusKey(pk) => pk.to_bech32(consensus_key_prefix),
},
Format::CosmosJson => PublicKey::from(*public_key.public_key()).to_json(),
Format::Hex => public_key.to_hex(),
}
}
Expand Down
7 changes: 6 additions & 1 deletion tmkms.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Information about Tendermint blockchain networks this KMS services
#
# - id: The chain ID for this chain
# - key_format: How this chain handles serialization. Type may be "bech32" or "hex"
# - key_format: How this chain handles serialization. Type may be "bech32", "cosmos-json" or "hex"
# - state_file (optional): path to where the state of the last signing operation is persisted
# - state_hook (optional): user-specified command to run on startup to obtain the current height
# of this chain. The command should output JSON which looks like the following:
Expand All @@ -24,6 +24,11 @@ id = "irishub"
key_format = { type = "bech32", account_key_prefix = "iap", consensus_key_prefix = "icp" }
# state_file = "/path/to/irishub_priv_validator_state.json"

[[chain]]
id = "agoricdev-4"
key_format = { type = "cosmos-json" }
# state_file = "/path/to/agoricdev_priv_validator_state.json"

## Validator configuration
[[validator]]
addr = "tcp://[email protected]:26658"
Expand Down

0 comments on commit 687c163

Please sign in to comment.