Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace proto build #NTRN-326 #156

Merged
merged 16 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ incremental = false
overflow-checks = true

[workspace.dependencies]
cosmwasm-std = "2.0.4"
cosmwasm-std = "2.1.0"
cosmwasm-schema = { version = "2.1.0", default-features = false }
cw2 = "2.0.0"
cw-storage-plus = "2.0.0"
schemars = "0.8.15"
serde = { version = "1.0.188", default-features = false }
serde-json-wasm = "1.0.0"
cw-storage-plus = "2.0.0"
cosmwasm-schema = { version = "2.0.4", default-features = false }
base64 = "0.21.7"
prost = "0.12.3"
prost-types = "0.12.1"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ check_contracts:
build: schema clippy test fmt doc compile check_contracts

build-proto:
@cargo run --bin proto-build $(revision)
@cargo run --bin proto-build
pr0n00gler marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 5 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, features = ["stargate"] }
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,6 +24,8 @@ 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 }
Expand Down
13 changes: 12 additions & 1 deletion packages/neutron-sdk/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
#![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;
#[allow(deprecated, clippy::module_inception)]
pub mod proto_types;
pub mod query;
pub mod stargate;
mod serde;
pub mod shim;
pub mod sudo;

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
2 changes: 1 addition & 1 deletion packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a6eae66545df6e128da2c7cac81ff4c1c02deb7b
v4.1.0
1 change: 1 addition & 0 deletions packages/neutron-sdk/src/proto_types/capability/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod v1;
112 changes: 112 additions & 0 deletions packages/neutron-sdk/src/proto_types/capability/v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
use neutron_std_derive::CosmwasmExt;
/// Capability defines an implementation of an object capability. The index
/// provided to a Capability must be globally unique.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/capability.v1.Capability")]
pub struct Capability {
#[prost(uint64, tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
pub index: u64,
}
/// Owner defines a single capability owner. An owner is defined by the name of
/// capability and the module name.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/capability.v1.Owner")]
pub struct Owner {
#[prost(string, tag = "1")]
pub module: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
}
/// CapabilityOwners defines a set of owners of a single Capability. The set of
/// owners must be unique.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/capability.v1.CapabilityOwners")]
pub struct CapabilityOwners {
#[prost(message, repeated, tag = "1")]
pub owners: ::prost::alloc::vec::Vec<Owner>,
}
/// GenesisOwners defines the capability owners with their corresponding index.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/capability.v1.GenesisOwners")]
pub struct GenesisOwners {
/// index is the index of the capability owner.
#[prost(uint64, tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
pub index: u64,
/// index_owners are the owners at the given index.
#[prost(message, optional, tag = "2")]
pub index_owners: ::core::option::Option<CapabilityOwners>,
}
/// GenesisState defines the capability module's genesis state.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/capability.v1.GenesisState")]
pub struct GenesisState {
/// index is the capability global index.
#[prost(uint64, tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
pub index: u64,
/// owners represents a map from index to owners of the capability index
/// index key is string to allow amino marshalling.
#[prost(message, repeated, tag = "2")]
pub owners: ::prost::alloc::vec::Vec<GenesisOwners>,
}
2 changes: 2 additions & 0 deletions packages/neutron-sdk/src/proto_types/cosmos/app/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod runtime;
pub mod v1alpha1;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod v1alpha1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
use neutron_std_derive::CosmwasmExt;
/// Module is the config object for the runtime module.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/cosmos.app.runtime.v1alpha1.Module")]
pub struct Module {
/// app_name is the name of the app.
#[prost(string, tag = "1")]
pub app_name: ::prost::alloc::string::String,
/// begin_blockers specifies the module names of begin blockers
/// to call in the order in which they should be called. If this is left empty
/// no begin blocker will be registered.
#[prost(string, repeated, tag = "2")]
pub begin_blockers: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// end_blockers specifies the module names of the end blockers
/// to call in the order in which they should be called. If this is left empty
/// no end blocker will be registered.
#[prost(string, repeated, tag = "3")]
pub end_blockers: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// init_genesis specifies the module names of init genesis functions
/// to call in the order in which they should be called. If this is left empty
/// no init genesis function will be registered.
#[prost(string, repeated, tag = "4")]
pub init_genesis: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// export_genesis specifies the order in which to export module genesis data.
/// If this is left empty, the init_genesis order will be used for export genesis
/// if it is specified.
#[prost(string, repeated, tag = "5")]
pub export_genesis: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// override_store_keys is an optional list of overrides for the module store keys
/// to be used in keeper construction.
#[prost(message, repeated, tag = "6")]
pub override_store_keys: ::prost::alloc::vec::Vec<StoreKeyConfig>,
/// order_migrations defines the order in which module migrations are performed.
/// If this is left empty, it uses the default migration order.
/// <https://pkg.go.dev/github.com/cosmos/[email protected]/types/module#DefaultMigrationsOrder>
#[prost(string, repeated, tag = "7")]
pub order_migrations: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// precommiters specifies the module names of the precommiters
/// to call in the order in which they should be called. If this is left empty
/// no precommit function will be registered.
#[prost(string, repeated, tag = "8")]
pub precommiters: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// prepare_check_staters specifies the module names of the prepare_check_staters
/// to call in the order in which they should be called. If this is left empty
/// no preparecheckstate function will be registered.
#[prost(string, repeated, tag = "9")]
pub prepare_check_staters: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// StoreKeyConfig may be supplied to override the default module store key, which
/// is the module name.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/cosmos.app.runtime.v1alpha1.StoreKeyConfig")]
pub struct StoreKeyConfig {
/// name of the module to override the store key of
#[prost(string, tag = "1")]
pub module_name: ::prost::alloc::string::String,
/// the kv store key to use instead of the module name.
#[prost(string, tag = "2")]
pub kv_store_key: ::prost::alloc::string::String,
}
Loading
Loading