Skip to content

Commit

Permalink
upd deps
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Oct 9, 2024
2 parents 64e14e4 + e7c509d commit c9fe6e0
Show file tree
Hide file tree
Showing 19 changed files with 831 additions and 162 deletions.
296 changes: 161 additions & 135 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ incremental = false
overflow-checks = true

[workspace.dependencies]
neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "chore/neutron-std" }
neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "main" }
neutron-std = { package = "neutron-std", git = "https://github.com/neutron-org/neutron-std", branch = "main" }
prost = "0.12.4"
prost-types = "0.12.4"
Expand Down
30 changes: 30 additions & 0 deletions contracts/cron/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "cron"
version = "0.1.0"
authors = ["joldie777 <aleksandr.pismenski@hadronlabs.org>"]
edition = "2021"

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[features]
library = []

[dependencies]
cosmwasm-std = { workspace = true }
cw2 = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
neutron-sdk = { workspace = true }
cw-storage-plus = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { workspace = true }
73 changes: 73 additions & 0 deletions contracts/cron/src/contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use crate::state::{BEGIN_BLOCKER_SHEDULES, END_BLOCKER_SHEDULES};
use cosmwasm_std::{
entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError,
StdResult,
};
use cw2::set_contract_version;

const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME"));
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

const MODULE_ACCOUNT: &str = "neutron1cd6wafvehv79pm2yxth40thpyc7dc0yrqkyk95";

#[entry_point]
pub fn instantiate(
deps: DepsMut,
_env: Env,
_info: MessageInfo,
_msg: InstantiateMsg,
) -> StdResult<Response> {
deps.api.debug("WASMDEBUG: instantiate");
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
Ok(Response::default())
}

#[entry_point]
pub fn execute(deps: DepsMut, _: Env, info: MessageInfo, msg: ExecuteMsg) -> StdResult<Response> {
deps.api
.debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str());

if info.sender.as_str() != MODULE_ACCOUNT {
return Err(StdError::generic_err("Unauthorized"));
}

match msg {
ExecuteMsg::AddBeginBlockerSchedule { name } => {
let counter = BEGIN_BLOCKER_SHEDULES
.may_load(deps.storage, name.clone())?
.unwrap_or_default()
.checked_add(1)
.unwrap_or_default();

BEGIN_BLOCKER_SHEDULES.save(deps.storage, name, &counter)?;

Ok(Response::default())
}
ExecuteMsg::AddEndBlockerSchedule { name } => {
let counter = END_BLOCKER_SHEDULES
.may_load(deps.storage, name.clone())?
.unwrap_or_default()
.checked_add(1)
.unwrap_or_default();

END_BLOCKER_SHEDULES.save(deps.storage, name, &counter)?;

Ok(Response::default())
}
}
}

#[entry_point]
pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::GetBeginBlockerScheduleCounter { name } => {
let res = BEGIN_BLOCKER_SHEDULES.may_load(deps.storage, name)?;
to_json_binary(&res)
}
QueryMsg::GetEndBlockerScheduleCounter { name } => {
let res = END_BLOCKER_SHEDULES.may_load(deps.storage, name)?;
to_json_binary(&res)
}
}
}
19 changes: 19 additions & 0 deletions contracts/cron/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2022 Neutron
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![warn(clippy::unwrap_used, clippy::expect_used)]

pub mod contract;
pub mod msg;
pub mod state;
19 changes: 19 additions & 0 deletions contracts/cron/src/msg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
pub struct InstantiateMsg {}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
AddBeginBlockerSchedule { name: String },
AddEndBlockerSchedule { name: String },
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
GetBeginBlockerScheduleCounter { name: String },
GetEndBlockerScheduleCounter { name: String },
}
4 changes: 4 additions & 0 deletions contracts/cron/src/state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use cw_storage_plus::Map;

pub const BEGIN_BLOCKER_SHEDULES: Map<String, u64> = Map::new("begin_blocker_shedules");
pub const END_BLOCKER_SHEDULES: Map<String, u64> = Map::new("end_blocker_shedules");
20 changes: 13 additions & 7 deletions contracts/dex/schema/dex_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"description": "Additional deposit options",
"type": "array",
"items": {
"$ref": "#/definitions/DepositOption"
"$ref": "#/definitions/DepositOptions"
}
},
"receiver": {
Expand Down Expand Up @@ -322,14 +322,20 @@
}
],
"definitions": {
"DepositOption": {
"DepositOptions": {
"type": "object",
"required": [
"disable_swap"
],
"properties": {
"disable_swap": {
"type": "boolean"
"disable_autoswap": {
"type": [
"boolean",
"null"
]
},
"fail_tx_on_bel": {
"type": [
"boolean",
"null"
]
}
},
"additionalProperties": false
Expand Down
Loading

0 comments on commit c9fe6e0

Please sign in to comment.