Skip to content

Commit

Permalink
move proto generated files inside neutron-sdk package
Browse files Browse the repository at this point in the history
  • Loading branch information
joldie777 committed Jul 18, 2024
1 parent c89d404 commit 8e0c5fe
Show file tree
Hide file tree
Showing 222 changed files with 30 additions and 115 deletions.
1 change: 0 additions & 1 deletion contracts/ibc_transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ serde-json-wasm = { workspace = true }
cw-storage-plus = { workspace = true, features = ["iterator"]}
cosmwasm-schema = { workspace = true }
neutron-sdk = { path = "../../packages/neutron-sdk", default-features = false }
neutron-std = { path = "../../packages/neutron-std", default-features = false }

[dev-dependencies]
cosmwasm-schema = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/ibc_transfer/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use cosmwasm_std::{
};
use cw2::set_contract_version;
use neutron_sdk::interchain_txs::helpers::decode_message_response;
use neutron_sdk::proto_types::neutron::transfer::MsgTransferResponse;
use neutron_sdk::{
bindings::{
msg::{IbcFee, NeutronMsg},
Expand All @@ -13,7 +14,6 @@ use neutron_sdk::{
sudo::msg::{RequestPacket, RequestPacketTimeoutHeight, TransferSudoMsg},
NeutronResult,
};
use neutron_std::types::neutron::transfer::MsgTransferResponse;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down
1 change: 0 additions & 1 deletion contracts/neutron_interchain_txs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ serde-json-wasm = { workspace = true }
cw-storage-plus = { workspace = true }
cosmos-sdk-proto = { workspace = true }
neutron-sdk = { path = "../../packages/neutron-sdk", default-features = false }
neutron-std = { path = "../../packages/neutron-std", default-features = false }
prost-types = { workspace = true }
cosmwasm-schema = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/neutron_interchain_txs/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use serde::{Deserialize, Serialize};

use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use neutron_sdk::bindings::msg::IbcFee;
use neutron_sdk::proto_types::neutron::interchaintxs::v1::MsgSubmitTxResponse;
use neutron_sdk::{
bindings::{
msg::NeutronMsg,
Expand All @@ -25,7 +26,6 @@ use neutron_sdk::{
sudo::msg::{RequestPacket, SudoMsg},
NeutronError, NeutronResult,
};
use neutron_std::types::neutron::interchaintxs::v1::MsgSubmitTxResponse;

use crate::storage::{
add_error_to_queue, read_errors_from_queue, read_reply_payload, read_sudo_payload,
Expand Down
8 changes: 6 additions & 2 deletions packages/neutron-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ homepage = "https://neutron.org"
readme = "README.md"

[dependencies]
cosmwasm-std = { workspace = true }
cosmwasm-std = { workspace = true, features = ["cosmwasm_2_0"] }
cosmos-sdk-proto = { workspace = true }
serde = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde-cw-value = "0.7.0"
schemars = { workspace = true }
serde-json-wasm = { workspace = true }
bech32 = { workspace = true }
Expand All @@ -23,8 +24,11 @@ prost = { workspace = true }
prost-types = { workspace = true }
tendermint-proto = { workspace = true }
speedate = { workspace = true }
chrono = { version = "0.4.22", default-features = false }
neutron-std-derive = { version = "0.20.1", path = "../neutron-std-derive" }

[dev-dependencies]
base64 = { workspace = true }
prost-types = { workspace = true }
hex = { workspace = true }
trybuild = {version = "1.0.63", features = ["diff"]}
15 changes: 15 additions & 0 deletions packages/neutron-sdk/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
#![doc = include_str!("../README.md")]
#![cfg_attr(docsrs, feature(doc_cfg))]
// #![forbid(unsafe_code)]
#![warn(trivial_casts, trivial_numeric_casts, unused_import_braces)]

/// The version (commit hash) of the Cosmos SDK used when generating this library.
pub const NEUTROND_VERSION: &str = include_str!("proto_types/NEUTRON_COMMIT");

pub mod bindings;
mod errors;
pub mod interchain_queries;
pub mod interchain_txs;
pub mod query;
pub mod sudo;

mod serde;
pub mod shim;

#[allow(deprecated)]
pub mod proto_types;

pub use errors::error::{NeutronError, NeutronResult};
pub use shim::{cosmwasm_to_proto_coins, try_proto_to_cosmwasm_coins};

// This is a signal, such that any contract that imports these helpers will only run on the
// neutron blockchain
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 0 additions & 31 deletions packages/neutron-sdk/src/proto_types/osmosis.tokenfactory.rs

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -312,20 +312,20 @@ impl_prost_types_exact_conversion! { Timestamp | seconds, nanos }
impl_prost_types_exact_conversion! { Duration | seconds, nanos }
impl_prost_types_exact_conversion! { Any | type_url, value }

impl From<cosmwasm_std::Coin> for crate::types::cosmos::base::v1beta1::Coin {
impl From<cosmwasm_std::Coin> for crate::proto_types::cosmos::base::v1beta1::Coin {
fn from(cosmwasm_std::Coin { denom, amount }: cosmwasm_std::Coin) -> Self {
crate::types::cosmos::base::v1beta1::Coin {
crate::proto_types::cosmos::base::v1beta1::Coin {
denom,
amount: amount.into(),
}
}
}

impl TryFrom<crate::types::cosmos::base::v1beta1::Coin> for cosmwasm_std::Coin {
impl TryFrom<crate::proto_types::cosmos::base::v1beta1::Coin> for cosmwasm_std::Coin {
type Error = cosmwasm_std::StdError;

fn try_from(
crate::types::cosmos::base::v1beta1::Coin { denom, amount }: crate::types::cosmos::base::v1beta1::Coin,
crate::proto_types::cosmos::base::v1beta1::Coin { denom, amount }: crate::proto_types::cosmos::base::v1beta1::Coin,
) -> cosmwasm_std::StdResult<Self> {
Ok(cosmwasm_std::Coin {
denom,
Expand All @@ -336,15 +336,15 @@ impl TryFrom<crate::types::cosmos::base::v1beta1::Coin> for cosmwasm_std::Coin {

/// Convert a list of `Coin` from generated proto `Coin` type to cosmwasm `Coin` type
pub fn try_proto_to_cosmwasm_coins(
coins: impl IntoIterator<Item = crate::types::cosmos::base::v1beta1::Coin>,
coins: impl IntoIterator<Item = crate::proto_types::cosmos::base::v1beta1::Coin>,
) -> StdResult<Vec<cosmwasm_std::Coin>> {
coins.into_iter().map(|c| c.try_into()).collect()
}

/// Convert a list of `Coin` from cosmwasm `Coin` type to generated proto `Coin` type
pub fn cosmwasm_to_proto_coins(
coins: impl IntoIterator<Item = cosmwasm_std::Coin>,
) -> Vec<crate::types::cosmos::base::v1beta1::Coin> {
) -> Vec<crate::proto_types::cosmos::base::v1beta1::Coin> {
coins.into_iter().map(|c| c.into()).collect()
}

Expand Down
20 changes: 0 additions & 20 deletions packages/neutron-std/Cargo.toml

This file was deleted.

36 changes: 0 additions & 36 deletions packages/neutron-std/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions packages/neutron-std/src/lib.rs

This file was deleted.

2 changes: 1 addition & 1 deletion proto-build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const TMP_REPOS_DIR: &str = "./dependencies/";
/// A temporary directory for proto building
const TMP_BUILD_DIR: &str = "/tmp/tmp-protobuf/";
/// The directory generated cosmos-sdk proto files go into in this repo
const OUT_DIR: &str = "../packages/neutron-std/src/types/";
const OUT_DIR: &str = "../packages/neutron-sdk/src/proto_types/";

pub fn generate() {
let tmp_repos_dir: PathBuf = TMP_REPOS_DIR.parse().unwrap();
Expand Down

0 comments on commit 8e0c5fe

Please sign in to comment.