Skip to content

Commit

Permalink
Merge pull request #121 from neutron-org/feat/dex-proto
Browse files Browse the repository at this point in the history
[NTRN-163] add dex stargate helpers
  • Loading branch information
pr0n00gler authored Dec 14, 2023
2 parents 276fc51 + 520022f commit d280443
Show file tree
Hide file tree
Showing 30 changed files with 2,960 additions and 272 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ serde-json-wasm = "1.0.0"
cw-storage-plus = "1.1.0"
cosmwasm-schema = { version = "1.4.0", default-features = false }
base64 = "0.21.4"
prost = "0.12.1"
prost = "0.12.3"
prost-types = "0.12.1"
cosmos-sdk-proto = { version = "0.20.0", default-features = false }
bech32 = "0.9.1"
thiserror = "1.0.49"
protobuf = { version = "3.3.0" }
hex = "0.4.3"
tendermint-proto = "0.34"
speedate = "0.13.0"
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ clippy:
fmt:
@cargo fmt -- --check

build_proto:
@./build_proto.sh

compile:
@./build_release.sh

check_contracts:
@cargo install cosmwasm-check
@cosmwasm-check --available-capabilities iterator,staking,stargate,neutron artifacts/*.wasm

build: build_proto schema clippy test fmt compile check_contracts
build: schema clippy test fmt compile check_contracts
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The Neutron SDK is contained inside `packages` folder and consists of the follow
| Neutron Bindings | https://github.com/neutron-org/neutron-sdk/tree/main/packages/neutron-sdk/src/bindings | Structures and helper methods for interacting with Neutron blockchain |
| Neutron Sudo | https://github.com/neutron-org/neutron-sdk/tree/main/packages/neutron-sdk/src/sudo | Structures for Sudo Contract callbacks from Neutron blockchain |
| Neutron Errors | https://github.com/neutron-org/neutron-sdk/tree/main/packages/neutron-sdk/src/errors | Structures and helpers for Neutron specific error and result types |
| Neutron Proto Types | https://github.com/neutron-org/neutron-sdk/tree/main/packages/neutron-sdk/src/proto_types | Neutron specific protobuf types. |
| Neutron Stargate | https://github.com/neutron-org/neutron-sdk/tree/main/packages/neutron-sdk/src/stargate | Structures and helpers for interacting with Neutron via Stargate |

### Example Contracts

Expand Down
8 changes: 0 additions & 8 deletions build_proto.sh

This file was deleted.

4 changes: 4 additions & 0 deletions packages/neutron-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ bech32 = { workspace = true }
thiserror = { workspace = true }
protobuf = { workspace = true }
cosmwasm-schema = { workspace = true }
prost = { workspace = true }
prost-types = { workspace = true }
tendermint-proto = { workspace = true }
speedate = { workspace = true }

[dev-dependencies]
base64 = { workspace = true }
Expand Down
14 changes: 13 additions & 1 deletion packages/neutron-sdk/src/bindings/query.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::bindings::types::{Failure, InterchainQueryResult, RegisteredQuery};
use cosmwasm_std::{Binary, CustomQuery};
use cosmwasm_std::{Binary, CustomQuery, Uint64};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -90,6 +90,18 @@ pub struct PageRequest {
pub reverse: bool,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct PageResponse {
/// **next_key** is the key to be passed to PageRequest.key to
/// query the next page most efficiently. It will be empty if
/// there are no more results.
pub next_key: Option<Binary>,
/// **total** is total number of results available if PageRequest.count_total
/// was set, its value is undefined otherwise
pub total: Option<Uint64>,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct QueryRegisteredQueriesResponse {
Expand Down
1 change: 1 addition & 0 deletions packages/neutron-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod interchain_queries;
pub mod interchain_txs;
pub mod proto_types;
pub mod query;
pub mod stargate;
pub mod sudo;

pub use errors::error::{NeutronError, NeutronResult};
Expand Down
1 change: 1 addition & 0 deletions packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5845ebddc3f85802fd35661f78efd2c7b61e4724
47 changes: 45 additions & 2 deletions packages/neutron-sdk/src/proto_types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
// @generated
pub mod neutron {
pub mod dex {
include!("neutron.dex.rs");
}

pub mod transfer;
pub mod interchaintxs {
include!("neutron.interchaintxs.rs");
pub mod v1 {
include!("neutron.interchaintxs.v1.rs");
}
}

pub mod feeburner {
include!("neutron.feeburner.rs");
}

pub mod interchainqueries {
include!("neutron.interchainqueries.rs");
}

pub mod cron {
include!("neutron.cron.rs");
}
pub mod transfer {
include!("neutron.transfer.rs");
}

pub mod feerefunder {
include!("neutron.feerefunder.rs");
}

pub mod contractmanager {
include!("neutron.contractmanager.rs");
pub mod v1 {
include!("neutron.contractmanager.v1.rs");
}
}
}

pub mod osmosis {
pub mod tokenfactory {
pub mod v1beta1 {
include!("osmosis.tokenfactory.v1beta1.rs");
}
}
}
89 changes: 89 additions & 0 deletions packages/neutron-sdk/src/proto_types/neutron.contractmanager.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// @generated
/// Failure message contains information about ACK failures and can be used to
/// replay ACK in case of requirement.
/// Note that Failure means that sudo handler to cosmwasm contract failed for some reason
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Failure {
/// Address of the failed contract
#[prost(string, tag = "1")]
pub address: ::prost::alloc::string::String,
/// Id of the failure under specific address
#[prost(uint64, tag = "2")]
pub id: u64,
/// Serialized MessageSudoCallback with Packet and Ack(if exists)
#[prost(bytes = "vec", tag = "3")]
pub sudo_payload: ::prost::alloc::vec::Vec<u8>,
/// Redacted error response of the sudo call. Full error is emitted as an event
#[prost(string, tag = "4")]
pub error: ::prost::alloc::string::String,
}
/// Params defines the parameters for the module.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Params {
#[prost(uint64, tag = "1")]
pub sudo_call_gas_limit: u64,
}
/// GenesisState defines the contractmanager module's genesis state.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenesisState {
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
/// List of the contract failures
///
/// this line is used by starport scaffolding # genesis/proto/state
#[prost(message, repeated, tag = "2")]
pub failures_list: ::prost::alloc::vec::Vec<Failure>,
}
/// QueryParamsRequest is request type for the Query/Params RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsRequest {}
/// QueryParamsResponse is response type for the Query/Params RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsResponse {
/// params holds all the parameters of this module.
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
}
/// QueryFailuresRequest is request type for the Query/Failures RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryFailuresRequest {
/// address of the contract which Sudo call failed.
#[prost(string, tag = "1")]
pub address: ::prost::alloc::string::String,
/// ID of the failure for the given contract.
#[prost(uint64, tag = "2")]
pub failure_id: u64,
#[prost(message, optional, tag = "3")]
pub pagination:
::core::option::Option<cosmos_sdk_proto::cosmos::base::query::v1beta1::PageRequest>,
}
/// QueryFailuresResponse is response type for the Query/Failures RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryFailuresResponse {
#[prost(message, repeated, tag = "1")]
pub failures: ::prost::alloc::vec::Vec<Failure>,
#[prost(message, optional, tag = "2")]
pub pagination:
::core::option::Option<cosmos_sdk_proto::cosmos::base::query::v1beta1::PageResponse>,
}
/// MsgUpdateParams is the MsgUpdateParams request type.
///
/// Since: 0.47
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgUpdateParams {
/// Authority is the address of the governance account.
#[prost(string, tag = "1")]
pub authority: ::prost::alloc::string::String,
/// params defines the x/contractmanager parameters to update.
///
/// NOTE: All parameters must be supplied.
#[prost(message, optional, tag = "2")]
pub params: ::core::option::Option<Params>,
}
/// MsgUpdateParamsResponse defines the response structure for executing a
/// MsgUpdateParams message.
///
/// Since: 0.47
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgUpdateParamsResponse {}
// @@protoc_insertion_point(module)
21 changes: 21 additions & 0 deletions packages/neutron-sdk/src/proto_types/neutron.contractmanager.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @generated
/// Deprecated. Used only for migration purposes.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Failure {
/// ChannelId
#[prost(string, tag = "1")]
pub channel_id: ::prost::alloc::string::String,
/// Address of the failed contract
#[prost(string, tag = "2")]
pub address: ::prost::alloc::string::String,
/// id of the failure under specific address
#[prost(uint64, tag = "3")]
pub id: u64,
/// ACK id to restore
#[prost(uint64, tag = "4")]
pub ack_id: u64,
/// Acknowledgement type
#[prost(string, tag = "5")]
pub ack_type: ::prost::alloc::string::String,
}
// @@protoc_insertion_point(module)
105 changes: 105 additions & 0 deletions packages/neutron-sdk/src/proto_types/neutron.cron.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// @generated
/// Params defines the parameters for the module.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Params {
/// Security address that can remove schedules
#[prost(string, tag = "1")]
pub security_address: ::prost::alloc::string::String,
/// Limit of schedules executed in one block
#[prost(uint64, tag = "2")]
pub limit: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Schedule {
/// Name of schedule
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Period in blocks
#[prost(uint64, tag = "2")]
pub period: u64,
/// Msgs that will be executed every period amount of time
#[prost(message, repeated, tag = "3")]
pub msgs: ::prost::alloc::vec::Vec<MsgExecuteContract>,
/// Last execution's block height
#[prost(uint64, tag = "4")]
pub last_execute_height: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgExecuteContract {
/// Contract is the address of the smart contract
#[prost(string, tag = "1")]
pub contract: ::prost::alloc::string::String,
/// Msg is json encoded message to be passed to the contract
#[prost(string, tag = "2")]
pub msg: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScheduleCount {
/// Count is the number of current schedules
#[prost(int32, tag = "1")]
pub count: i32,
}
/// GenesisState defines the cron module's genesis state.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenesisState {
#[prost(message, repeated, tag = "2")]
pub schedule_list: ::prost::alloc::vec::Vec<Schedule>,
/// this line is used by starport scaffolding # genesis/proto/state
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsResponse {
/// params holds all the parameters of this module.
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryGetScheduleRequest {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryGetScheduleResponse {
#[prost(message, optional, tag = "1")]
pub schedule: ::core::option::Option<Schedule>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QuerySchedulesRequest {
#[prost(message, optional, tag = "1")]
pub pagination:
::core::option::Option<cosmos_sdk_proto::cosmos::base::query::v1beta1::PageRequest>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QuerySchedulesResponse {
#[prost(message, repeated, tag = "1")]
pub schedules: ::prost::alloc::vec::Vec<Schedule>,
#[prost(message, optional, tag = "2")]
pub pagination:
::core::option::Option<cosmos_sdk_proto::cosmos::base::query::v1beta1::PageResponse>,
}
// this line is used by starport scaffolding # proto/tx/message

/// MsgUpdateParams is the MsgUpdateParams request type.
///
/// Since: 0.47
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgUpdateParams {
/// Authority is the address of the governance account.
#[prost(string, tag = "1")]
pub authority: ::prost::alloc::string::String,
/// params defines the x/cron parameters to update.
///
/// NOTE: All parameters must be supplied.
#[prost(message, optional, tag = "2")]
pub params: ::core::option::Option<Params>,
}
/// MsgUpdateParamsResponse defines the response structure for executing a
/// MsgUpdateParams message.
///
/// Since: 0.47
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgUpdateParamsResponse {}
// @@protoc_insertion_point(module)
Loading

0 comments on commit d280443

Please sign in to comment.