Skip to content

Commit

Permalink
fix all build errors left
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Oct 15, 2024
1 parent d5a5258 commit 31b5fcb
Show file tree
Hide file tree
Showing 26 changed files with 413 additions and 352 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion contracts/dex_grpc/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use cosmwasm_std::{
};
use cw2::set_contract_version;
use neutron_sdk::sudo::msg::SudoMsg;
use neutron_std::types::neutron::dex::{DexQuerier, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, MsgWithdrawFilledLimitOrder, MsgWithdrawal};
use neutron_std::types::neutron::dex::{
DexQuerier, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder,
MsgWithdrawFilledLimitOrder, MsgWithdrawal,
};

const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME"));
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -96,6 +99,7 @@ pub fn execute(
order_type,
expiration_time,
max_amount_out,
min_average_sell_price: "".to_string(), // TODO
})),
),
ExecuteMsg::WithdrawFilledLimitOrder { tranche_key } => Ok(Response::new().add_message(
Expand Down
5 changes: 4 additions & 1 deletion contracts/dex_grpc/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use neutron_std::shim::Timestamp;
use neutron_std::types::cosmos::base::query::v1beta1::PageRequest;
use neutron_std::types::neutron::dex::{DepositOptions, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, MsgWithdrawFilledLimitOrder, MsgWithdrawal, MultiHopRoute};
use neutron_std::types::neutron::dex::{
DepositOptions, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder,
MsgWithdrawFilledLimitOrder, MsgWithdrawal, MultiHopRoute,
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down
12 changes: 7 additions & 5 deletions contracts/grpc_querier/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ use cosmwasm_std::{
entry_point, to_json_binary, Binary, ContractResult, Deps, DepsMut, Empty, Env, MessageInfo,
QueryRequest, Response, StdError, StdResult, SystemResult,
};
use std::str::from_utf8;
use crate::grpc;
use cw2::set_contract_version;
use neutron_std::types::cosmos::auth::v1beta1::AuthQuerier;
use neutron_std::types::cosmos::bank::v1beta1::BankQuerier;
use neutron_std::types::ibc::applications::transfer::v1::TransferQuerier;
use neutron_std::types::ibc::core::client::v1::ClientQuerier;
use neutron_std::types::ibc::core::connection::v1::ConnectionQuerier;
use neutron_std::types::neutron::contractmanager::QueryFailuresRequest;
use neutron_std::types::neutron::feeburner::FeeburnerQuerier;
use neutron_std::types::neutron::interchainqueries::InterchainqueriesQuerier;
use neutron_std::types::neutron::interchaintxs::v1::InterchaintxsQuerier;
use neutron_std::types::osmosis::tokenfactory::v1beta1::TokenfactoryQuerier;
use prost::Message;
use serde_json_wasm::to_vec;
use std::str::from_utf8;

const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME"));
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -137,7 +137,10 @@ pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> StdResult<Binary> {

// Can be refactored after https://hadronlabs.atlassian.net/browse/NTRN-359 is done
fn query_contractmanager_query_address_failures(deps: Deps, address: String) -> StdResult<Binary> {
let msg = grpc::contractmanager::QueryAddressFailuresRequest { address };
let msg = QueryFailuresRequest {
address,
pagination: None,
};
let mut bytes = Vec::new();
Message::encode(&msg, &mut bytes).map_err(|_| StdError::generic_err("cannot encode proto"))?;

Expand All @@ -150,9 +153,8 @@ fn query_contractmanager_query_address_failures(deps: Deps, address: String) ->
to_json_binary(&resp)
}

// Can be refactored after https://hadronlabs.atlassian.net/browse/NTRN-359 is done
fn query_contractmanager_query_failures(deps: Deps, address: String) -> StdResult<Binary> {
let msg = grpc::contractmanager::QueryFailuresRequest {
let msg = QueryFailuresRequest {
address,
pagination: None,
};
Expand Down
17 changes: 0 additions & 17 deletions contracts/grpc_querier/src/grpc.rs

This file was deleted.

1 change: 0 additions & 1 deletion contracts/grpc_querier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
#![warn(clippy::unwrap_used, clippy::expect_used)]

pub mod contract;
mod grpc;
pub mod msg;
60 changes: 28 additions & 32 deletions contracts/ibc_transfer/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
use crate::state::{
read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, IBC_FEE,
IBC_SUDO_ID_RANGE_END, IBC_SUDO_ID_RANGE_START, TEST_COUNTER_ITEM,
};
use cosmwasm_std::{
coin, entry_point, Binary, Coin, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response,
StdError, StdResult, SubMsg, Uint128,
entry_point, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError,
StdResult, SubMsg, Uint128,
};
use cw2::set_contract_version;
use neutron_sdk::interchain_txs::helpers::decode_message_response;
use neutron_sdk::{
sudo::msg::{RequestPacket, RequestPacketTimeoutHeight, TransferSudoMsg},
};
use neutron_sdk::sudo::msg::{RequestPacket, TransferSudoMsg};
use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin;
use neutron_std::types::ibc::core::client::v1::Height;
use neutron_std::types::neutron::contractmanager::MsgResubmitFailure;
use neutron_std::types::neutron::feerefunder::Fee;
use neutron_std::types::neutron::transfer::{MsgTransfer, MsgTransferResponse};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin;
use neutron_std::types::ibc::core::client::v1::Height;
use neutron_std::types::neutron::contractmanager::MsgResubmitFailure;
use crate::state::{
read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, IBC_FEE,
IBC_SUDO_ID_RANGE_END, IBC_SUDO_ID_RANGE_START, TEST_COUNTER_ITEM,
};

use crate::{
integration_tests_mock_handlers::{set_sudo_failure_mock, unset_sudo_failure_mock},
Expand Down Expand Up @@ -76,12 +74,7 @@ pub enum ExecuteMsg {
}

#[entry_point]
pub fn execute(
deps: DepsMut,
env: Env,
_: MessageInfo,
msg: ExecuteMsg,
) -> StdResult<Response> {
pub fn execute(deps: DepsMut, env: Env, _: MessageInfo, msg: ExecuteMsg) -> StdResult<Response> {
deps.api
.debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str());
match msg {
Expand All @@ -103,7 +96,9 @@ pub fn execute(
denom,
} => execute_set_fees(deps, recv_fee, ack_fee, timeout_fee, denom),

ExecuteMsg::ResubmitFailure { failure_id } => execute_resubmit_failure(deps, env, failure_id),
ExecuteMsg::ResubmitFailure { failure_id } => {
execute_resubmit_failure(deps, env, failure_id)
}

// Used only in integration tests framework to simulate failures.
// After executing this message, contract fail, all of this happening
Expand Down Expand Up @@ -189,7 +184,7 @@ fn get_fee_item(denom: String, amount: Uint128) -> Vec<StdCoin> {
} else {
let coin = StdCoin {
amount: amount.to_string(),
denom
denom,
};
vec![coin]
}
Expand Down Expand Up @@ -225,7 +220,7 @@ fn execute_send(
let fee = IBC_FEE.load(deps.storage)?;
let coin1 = StdCoin {
amount: amount.to_string(),
denom: denom.clone()
denom: denom.clone(),
};
let msg1 = MsgTransfer {
source_port: "transfer".to_string(),
Expand All @@ -242,21 +237,21 @@ fn execute_send(
memo: "".to_string(),
};
let coin2 = StdCoin {
amount: (2 * amount).to_string(),
denom: denom.clone()
amount: (amount * Uint128::new(2)).to_string(),
denom: denom.clone(),
};
let msg2 = MsgTransfer {
source_port: "transfer".to_string(),
source_channel: channel,
sender: env.contract.address.to_string(),
receiver: to,
token: coin2,
timeout_height: RequestPacketTimeoutHeight {
revision_number: Some(2),
revision_height: timeout_height.or(Some(DEFAULT_TIMEOUT_HEIGHT)),
},
token: Some(coin2),
timeout_height: Some(Height {
revision_number: 2,
revision_height: timeout_height.unwrap_or(DEFAULT_TIMEOUT_HEIGHT),
}),
timeout_timestamp: 0,
fee,
fee: Some(fee),
memo: "".to_string(),
};
let submsg1 = msg_with_sudo_callback(
Expand All @@ -282,11 +277,12 @@ fn execute_send(
Ok(Response::default().add_submessages(vec![submsg1, submsg2]))
}

fn execute_resubmit_failure(deps: DepsMut, env: Env, failure_id: u64) -> StdResult<Response> {
let msg = MsgResubmitFailure{
fn execute_resubmit_failure(_: DepsMut, env: Env, failure_id: u64) -> StdResult<Response> {
let msg: CosmosMsg = MsgResubmitFailure {
sender: env.contract.address.to_string(),
failure_id,
}.into();
}
.into();
Ok(Response::default().add_message(msg))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::state::{IntegrationTestsSudoFailureMock, INTEGRATION_TESTS_SUDO_FAILURE_MOCK};
use cosmwasm_std::{DepsMut, Response, StdResult};
use neutron_sdk::bindings::msg::NeutronMsg;

pub fn set_sudo_failure_mock(
deps: DepsMut,
Expand Down
18 changes: 5 additions & 13 deletions contracts/marketmap/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::query::QueryMsg;
use cosmwasm_std::{
entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult,
};
use cw2::set_contract_version;
use neutron_std::types::slinky::marketmap::v1::MarketmapQuerier;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::query::QueryMsg;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
pub struct InstantiateMsg {}
Expand Down Expand Up @@ -47,17 +47,9 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
fn query_marketmap(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
let querier = MarketmapQuerier::new(&deps.querier);
match msg {
QueryMsg::Params { .. } => {
to_json_binary(&querier.params()?)
}
QueryMsg::LastUpdated { .. } => {
to_json_binary(&querier.last_updated()?)
}
QueryMsg::MarketMap { .. } => {
to_json_binary(&querier.market_map()?)
}
QueryMsg::Market { currency_pair } => {
to_json_binary(&querier.market(Some(currency_pair))?)
}
QueryMsg::Params { .. } => to_json_binary(&querier.params()?),
QueryMsg::LastUpdated { .. } => to_json_binary(&querier.last_updated()?),
QueryMsg::MarketMap { .. } => to_json_binary(&querier.market_map()?),
QueryMsg::Market { currency_pair } => to_json_binary(&querier.market(Some(currency_pair))?),
}
}
12 changes: 5 additions & 7 deletions contracts/marketmap/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Params { },
LastUpdated { },
MarketMap { },
Market {
currency_pair: CurrencyPair,
},
}
Params {},
LastUpdated {},
MarketMap {},
Market { currency_pair: CurrencyPair },
}
12 changes: 3 additions & 9 deletions contracts/msg_receiver/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use cosmwasm_std::{
};

use cw2::set_contract_version;
use neutron_sdk::bindings::msg::NeutronMsg;

use crate::state::TEST_ARGS;

Expand All @@ -25,12 +24,7 @@ pub fn instantiate(
}

#[entry_point]
pub fn execute(
deps: DepsMut,
_: Env,
info: MessageInfo,
msg: ExecuteMsg,
) -> StdResult<Response<NeutronMsg>> {
pub fn execute(deps: DepsMut, _: Env, info: MessageInfo, msg: ExecuteMsg) -> StdResult<Response> {
deps.api
.debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str());
match msg {
Expand All @@ -55,7 +49,7 @@ fn execute_test_arg(
info: MessageInfo,
return_err: bool,
arg: String,
) -> StdResult<Response<NeutronMsg>> {
) -> StdResult<Response> {
if return_err {
return Err(StdError::generic_err("return error"));
}
Expand All @@ -76,7 +70,7 @@ fn execute_test_arg(
Ok(Response::default().add_attribute("arg", arg))
}

fn execute_call_staking(deps: DepsMut) -> StdResult<Response<NeutronMsg>> {
fn execute_call_staking(deps: DepsMut) -> StdResult<Response> {
deps.querier.query_bonded_denom()?; // should fail since Neutron does not have staking module
Ok(Response::default())
}
Expand Down
Loading

0 comments on commit 31b5fcb

Please sign in to comment.