Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
refactor: Move cosmos rpc and runtime-api to pallet-cosmos
Browse files Browse the repository at this point in the history
  • Loading branch information
code0xff committed Sep 9, 2024
1 parent 61887c2 commit c542d09
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 19 deletions.
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
resolver = "2"
members = [
"client/rpc",
"frame/accounts",
"frame/cosmos",
"frame/cosmwasm",
Expand All @@ -17,7 +16,6 @@ members = [
"frame/cosmos/x/wasm/types",
"primitives/account",
"primitives/io",
"primitives/rpc",
"template/runtime",
"template/node",
"cosmwasm/std",
Expand Down Expand Up @@ -110,15 +108,15 @@ substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk
fp-self-contained = { git = "https://github.com/polkadot-evm/frontier", branch = "polkadot-v1.9.0", default-features = false }

# Horizon
hc-rpc = { path = "client/rpc" }
hp-account = { path = "primitives/account", default-features = false }
hp-crypto = { path = "primitives/crypto", default-features = false }
hp-io = { path = "primitives/io", default-features = false }
hp-rpc = { path = "primitives/rpc", default-features = false }
pallet-cosmos = { path = "frame/cosmos", default-features = false }
pallet-cosmos-accounts = { path = "frame/accounts", default-features = false }
horizon-template-runtime = { path = "template/runtime", default-features = false }

pallet-cosmos-rpc = { path = "frame/cosmos/rpc" }
pallet-cosmos-runtime-api = { path = "frame/cosmos/runtime-api", default-features = false }
pallet-cosmos-types = { path = "frame/cosmos/types", default-features = false }
pallet-cosmos-x-auth = { path = "frame/cosmos/x/auth", default-features = false }
pallet-cosmos-x-auth-migrations = { path = "frame/cosmos/x/auth/migrations", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/Cargo.toml → frame/cosmos/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "hc-rpc"
name = "pallet-cosmos-rpc"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
Expand All @@ -21,4 +21,4 @@ sp-core = { workspace = true, features = ["std"] }
sp-runtime = { workspace = true, features = ["std"] }

# Horizon
hp-rpc = { workspace = true, features = ["std"] }
pallet-cosmos-runtime-api = { workspace = true, features = ["std"] }
4 changes: 2 additions & 2 deletions client/rpc/src/cosmos.rs → frame/cosmos/rpc/src/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

use crate::internal_error;
use futures::future::TryFutureExt;
use hp_rpc::{CosmosTxRuntimeApi, SimulateError, SimulateResponse};
use jsonrpsee::{
core::{async_trait, RpcResult},
proc_macros::rpc,
};
use pallet_cosmos_runtime_api::{CosmosRuntimeApi, SimulateError, SimulateResponse};
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
Expand Down Expand Up @@ -59,7 +59,7 @@ where
C: Send + Sync + 'static,
C: ProvideRuntimeApi<Block>,
C: HeaderBackend<Block> + 'static,
C::Api: hp_rpc::CosmosTxRuntimeApi<Block>,
C::Api: pallet_cosmos_runtime_api::CosmosRuntimeApi<Block>,
P: TransactionPool<Block = Block> + 'static,
{
async fn broadcast_tx(&self, tx_bytes: Bytes) -> RpcResult<H256> {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "hp-rpc"
name = "pallet-cosmos-runtime-api"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum SimulateError {
}

sp_api::decl_runtime_apis! {
pub trait CosmosTxRuntimeApi {
pub trait CosmosRuntimeApi {
fn convert_tx(tx_bytes: Vec<u8>) -> <Block as BlockT>::Extrinsic;

fn simulate(tx_bytes: Vec<u8>) -> Result<SimulateResponse, SimulateError>;
Expand Down
2 changes: 1 addition & 1 deletion frame/cosmwasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub use pallet::*;
use sp_core::H256;
pub mod crypto;
pub mod dispatchable_call;
pub mod entrypoint;
pub mod ibc;
pub mod instrument;
pub mod pallet_hook;
Expand All @@ -51,7 +52,6 @@ pub mod runtimes;
pub mod types;
pub mod utils;
pub mod weights;
pub mod entrypoint;

const SUBSTRATE_ECDSA_SIGNATURE_LEN: usize = 65;
use crate::{
Expand Down
4 changes: 2 additions & 2 deletions template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ sp-wasm-interface = { workspace = true, features = ["std"] }
substrate-frame-rpc-system = { workspace = true }

# Horizon
hc-rpc = { workspace = true }
hp-account = { workspace = true, features = ["std"] }
hp-io = { workspace = true, features = ["std"] }
hp-rpc = { workspace = true, features = ["std"] }
horizon-template-runtime = { workspace = true, features = ["std"] }
pallet-cosmos-rpc = { workspace = true }
pallet-cosmos-runtime-api = { workspace = true, features = ["std"] }
pallet-cosmos-types = { workspace = true, features = ["std", "with-codec"] }
pallet-cosmos-x-bank-types = { workspace = true, features = [
"std",
Expand Down
4 changes: 2 additions & 2 deletions template/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ where
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
P: TransactionPool<Block = Block> + 'static,
C::Api: hp_rpc::CosmosTxRuntimeApi<Block>,
C::Api: pallet_cosmos_runtime_api::CosmosRuntimeApi<Block>,
C::Api: cosmwasm_runtime_api::CosmwasmRuntimeApi<Block, Vec<u8>>,
{
use cosmwasm_rpc::{Cosmwasm, CosmwasmApiServer};
use hc_rpc::{Cosmos, CosmosApiServer};
use pallet_cosmos_rpc::{Cosmos, CosmosApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};

Expand Down
4 changes: 2 additions & 2 deletions template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ fp-self-contained = { workspace = true, default-features = false, features = [
hp-account = { workspace = true, default-features = false }
hp-crypto = { workspace = true, default-features = false }
hp-io = { workspace = true, default-features = false }
hp-rpc = { workspace = true, default-features = false }
pallet-cosmos = { workspace = true, default-features = false }
pallet-cosmos-accounts = { workspace = true, default-features = false }
pallet-cosmos-runtime-api = { workspace = true, default-features = false }
pallet-cosmos-types = { workspace = true, default-features = false, features = [
"with-codec",
] }
Expand Down Expand Up @@ -113,9 +113,9 @@ std = [
"hp-account/std",
"hp-crypto/std",
"hp-io/std",
"hp-rpc/std",
"pallet-cosmos/std",
"pallet-cosmos-accounts/std",
"pallet-cosmos-runtime-api/std",
"pallet-cosmos-types/std",
"pallet-cosmos-x-auth/std",
"pallet-cosmos-x-auth-migrations/std",
Expand Down
4 changes: 2 additions & 2 deletions template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ use frame_support::{
use frame_system::EnsureRoot;
use hp_account::CosmosSigner;
use hp_crypto::EcdsaExt;
use hp_rpc::{GasInfo, SimulateError, SimulateResponse};
use pallet_cosmos::{
config_preludes::{
AddressPrefix, ChainId, Context, MaxDenomLimit, MaxMemoCharacters, MsgFilter, NativeDenom,
TxSigLimit, WeightToGas,
},
AddressMapping,
};
use pallet_cosmos_runtime_api::{GasInfo, SimulateError, SimulateResponse};
use pallet_cosmos_x_auth::sigverify::SECP256K1_TYPE_URL;
use pallet_cosmos_x_auth_signing::{
sign_mode_handler::SignModeHandler, sign_verifiable_tx::SigVerifiableTx,
Expand Down Expand Up @@ -655,7 +655,7 @@ impl Runtime {
}

impl_runtime_apis! {
impl hp_rpc::CosmosTxRuntimeApi<Block> for Runtime {
impl pallet_cosmos_runtime_api::CosmosRuntimeApi<Block> for Runtime {
fn convert_tx(tx_bytes: Vec<u8>) -> <Block as BlockT>::Extrinsic {
UncheckedExtrinsic::new_unsigned(
pallet_cosmos::Call::<Runtime>::transact { tx_bytes }.into(),
Expand Down

0 comments on commit c542d09

Please sign in to comment.