Skip to content

Commit

Permalink
feat: split out tm lc, bera lc, cometbft rpc, and galois rpc types
Browse files Browse the repository at this point in the history
  • Loading branch information
benluelo committed Oct 24, 2024
1 parent f9134e3 commit d8e244d
Show file tree
Hide file tree
Showing 133 changed files with 3,226 additions and 3,265 deletions.
52 changes: 52 additions & 0 deletions Cargo.lock

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

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ members = [

"lib/beacon-api",
"lib/cometbft-rpc",
"lib/cometbft-types",

"lib/chain-utils",
"lib/gnark-key-parser",
Expand All @@ -44,6 +45,8 @@ members = [
"lib/zktrie-rs",
"lib/voyager-message",
"lib/voyager-core",
"lib/galois-rpc",
"lib/ibc-events",

"lib/near/near-ibc",
"lib/near/near-light-client",
Expand Down Expand Up @@ -127,6 +130,8 @@ members = [
"lib/reconnecting-jsonrpc-ws-client",
"lib/voyager-core",
"lib/subset-of",
"lib/cometbft-types",
"lib/galois-rpc",
]

[workspace.package]
Expand All @@ -152,6 +157,7 @@ aptos-verifier = { path = "lib/aptos-verifier", default-features = false }
beacon-api = { path = "lib/beacon-api", default-features = false }
chain-utils = { path = "lib/chain-utils", default-features = false }
cometbft-rpc = { path = "lib/cometbft-rpc", default-features = false }
cometbft-types = { path = "lib/cometbft-types", default-features = false }

arbitrum-light-client-types = { path = "light-clients/arbitrum-light-client/types", default-features = false }
arbitrum-verifier = { path = "lib/arbitrum-verifier", default-features = false }
Expand Down Expand Up @@ -205,6 +211,8 @@ ucs01-relay-api = { path = "cosmwasm/ucs01-relay-api", default-features = fals
unionlabs = { path = "lib/unionlabs", default-features = false }
zktrie = { path = "lib/zktrie-rs", default-features = false }

galois-rpc = { path = "lib/galois-rpc", default-features = false }

voyager-core = { path = "lib/voyager-core", default-features = false }
voyager-message = { path = "lib/voyager-message", default-features = false }
voyager-vm = { path = "lib/voyager-vm", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion lib/cometbft-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ workspace = true

[dependencies]
base64 = { workspace = true }
cometbft-types = { workspace = true, features = ["proto"] }
hex = { workspace = true }
jsonrpsee = { workspace = true, features = ["tracing", "ws-client", "http-client"] }
macros = { workspace = true }
protos = { workspace = true }
protos = { workspace = true, features = ["serde", "tendermint+abci", "tendermint+blocksync", "tendermint+consensus", "tendermint+crypto", "tendermint+libs+bits", "tendermint+mempool", "tendermint+p2p", "tendermint+privval", "tendermint+rpc+grpc", "tendermint+state", "tendermint+statesync", "tendermint+store", "tendermint+types", "tendermint+version"] }
reconnecting-jsonrpc-ws-client = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde-utils = { workspace = true }
Expand Down
18 changes: 9 additions & 9 deletions lib/cometbft-rpc/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use std::num::NonZeroU64;

use cometbft_types::{
abci::{exec_tx_result::ExecTxResult, response_query::ResponseQuery},
crypto::public_key::PublicKey,
p2p::default_node_info::DefaultNodeInfo,
types::{
block::Block, block_id::BlockId, signed_header::SignedHeader, tx_proof::TxProof,
validator::Validator,
},
};
use serde::{Deserialize, Serialize};
use unionlabs::{
bounded::BoundedU8,
google::protobuf::timestamp::Timestamp,
hash::{hash_v2::HexUnprefixed, H160, H256},
tendermint::{
abci::{exec_tx_result::ExecTxResult, response_query::ResponseQuery},
crypto::public_key::PublicKey,
p2p::default_node_info::DefaultNodeInfo,
types::{
block::Block, block_id::BlockId, signed_header::SignedHeader, tx_proof::TxProof,
validator::Validator,
},
},
};

use crate::serde::{serde_as, serde_as_list, serde_as_opt};
Expand Down
29 changes: 29 additions & 0 deletions lib/cometbft-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
edition.workspace = true
license-file.workspace = true
name = "cometbft-types"
repository.workspace = true
version = "0.1.0"

[lints]
workspace = true

[dependencies]
prost = { workspace = true, optional = true }
protos = { workspace = true, features = ["tendermint+abci", "tendermint+blocksync", "tendermint+consensus", "tendermint+crypto", "tendermint+p2p", "tendermint+privval", "tendermint+statesync", "tendermint+store", "tendermint+types", "tendermint+version"], optional = true }
serde-utils.workspace = true
serde.workspace = true
sha2 = { workspace = true, optional = true }
thiserror.workspace = true
unionlabs = { workspace = true }

[dev-dependencies]
cometbft-types = { workspace = true, features = ["proto"] }
hex-literal.workspace = true
serde_json = { workspace = true }
unionlabs = { workspace = true, features = ["test_utils"] }

[features]
default = ["proto", "hash"]
hash = ["dep:sha2", "dep:prost"]
proto = ["dep:protos"]
File renamed without changes.
32 changes: 32 additions & 0 deletions lib/cometbft-types/src/abci/event.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use serde::{Deserialize, Serialize};

use crate::abci::event_attribute::EventAttribute;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Event {
pub ty: String,
pub attributes: Vec<EventAttribute>,
}

#[cfg(feature = "proto")]
pub mod proto {
use crate::abci::event::Event;

impl From<protos::tendermint::abci::Event> for Event {
fn from(value: protos::tendermint::abci::Event) -> Self {
Self {
ty: value.r#type,
attributes: value.attributes.into_iter().map(Into::into).collect(),
}
}
}

impl From<Event> for protos::tendermint::abci::Event {
fn from(value: Event) -> Self {
Self {
r#type: value.ty,
attributes: value.attributes.into_iter().map(Into::into).collect(),
}
}
}
}
34 changes: 34 additions & 0 deletions lib/cometbft-types/src/abci/event_attribute.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EventAttribute {
pub key: String,
pub value: String,
/// nondeterministic
pub index: bool,
}

#[cfg(feature = "proto")]
pub mod proto {
use crate::abci::event_attribute::EventAttribute;

impl From<protos::tendermint::abci::EventAttribute> for EventAttribute {
fn from(value: protos::tendermint::abci::EventAttribute) -> Self {
Self {
key: value.key,
value: value.value,
index: value.index,
}
}
}

impl From<EventAttribute> for protos::tendermint::abci::EventAttribute {
fn from(value: EventAttribute) -> Self {
Self {
key: value.key,
value: value.value,
index: value.index,
}
}
}
}
Loading

0 comments on commit d8e244d

Please sign in to comment.