diff --git a/Cargo.lock b/Cargo.lock index a36c959..85e0dd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -594,8 +594,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f60e477bd71007d9ff78ae020ec1c6b3b47798578af6151429434d86472efc" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#398d4624976eb44f8573c0ecf698b9e0b0e41b00" dependencies = [ "bech32", "cosmos-sdk-proto 0.20.0", diff --git a/Cargo.toml b/Cargo.toml index 1546b3e..f38050e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ incremental = false overflow-checks = true [workspace.dependencies] -neutron-sdk = "0.8.0" +neutron-sdk = { git = "https://github.com/neutron-org/neutron-sdk", branch = "main" } prost = "0.12.1" prost-types = "0.12.1" cosmos-sdk-proto = { version = "0.20.0", default-features = false } diff --git a/contracts/reflect/src/contract.rs b/contracts/reflect/src/contract.rs index 0f9f74c..bf888b4 100644 --- a/contracts/reflect/src/contract.rs +++ b/contracts/reflect/src/contract.rs @@ -1,9 +1,10 @@ use crate::query::{ChainResponse, InterchainQueries, QueryMsg}; use cosmwasm_std::{ - entry_point, to_json_binary, to_json_vec, Binary, ContractResult, Deps, DepsMut, Env, - MessageInfo, QueryRequest, Response, StdError, StdResult, SystemResult, + entry_point, to_json_binary, to_json_vec, Binary, ContractResult, CosmosMsg, Deps, DepsMut, + Env, MessageInfo, QueryRequest, Reply, Response, StdError, StdResult, SubMsg, SystemResult, }; use cw2::set_contract_version; +use neutron_sdk::bindings::msg::NeutronMsg; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -11,6 +12,8 @@ use serde::{Deserialize, Serialize}; pub struct InstantiateMsg {} use neutron_sdk::sudo::msg::SudoMsg; +const REFLECT_REPLY_ID: u64 = 0; + const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -30,16 +33,33 @@ pub fn instantiate( #[serde(rename_all = "snake_case")] pub enum ExecuteMsg { Send { to: String, amount: u128 }, + ReflectMsg { msgs: Vec> }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct MigrateMsg {} #[entry_point] -pub fn execute(deps: DepsMut, _env: Env, _: MessageInfo, msg: ExecuteMsg) -> StdResult { +pub fn execute( + deps: DepsMut, + _env: Env, + _: MessageInfo, + msg: ExecuteMsg, +) -> StdResult> { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); - Ok(Response::default()) + match msg { + ExecuteMsg::Send { .. } => { + unimplemented!() + } + ExecuteMsg::ReflectMsg { msgs } => { + let submsgs = msgs + .into_iter() + .map(|m| SubMsg::reply_on_success(m, REFLECT_REPLY_ID)); + + Ok(Response::default().add_submessages(submsgs)) + } + } } #[entry_point] @@ -49,6 +69,18 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResul } } +#[entry_point] +pub fn reply(_deps: DepsMut, _env: Env, msg: Reply) -> StdResult { + match msg.id { + REFLECT_REPLY_ID => { + Ok(Response::default().set_data(msg.result.unwrap().data.unwrap_or_default())) + } + _ => { + unimplemented!() + } + } +} + fn query_with_payload( deps: Deps, _env: Env, diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index cfb7a30..c66085b 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -52,6 +52,32 @@ pub fn execute( amount: coins(amount.u128(), denom), } .into(), + ExecuteMsg::ForceTransfer { + denom, + amount, + from, + to, + } => NeutronMsg::submit_force_transfer(denom, amount, from, to).into(), + ExecuteMsg::SetDenomMetadata { + description, + denom_units, + base, + display, + name, + symbol, + uri, + uri_hash, + } => NeutronMsg::submit_set_denom_metadata( + description, + denom_units, + base, + display, + name, + symbol, + uri, + uri_hash, + ) + .into(), }; Ok(Response::new().add_message(msg)) } diff --git a/contracts/tokenfactory/src/msg.rs b/contracts/tokenfactory/src/msg.rs index eb3d9c3..e163c28 100644 --- a/contracts/tokenfactory/src/msg.rs +++ b/contracts/tokenfactory/src/msg.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::Uint128; +use cosmwasm_std::{DenomUnit, Uint128}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -32,6 +32,22 @@ pub enum ExecuteMsg { denom: String, contract_addr: String, }, + ForceTransfer { + denom: String, + amount: Uint128, + from: String, + to: String, + }, + SetDenomMetadata { + description: String, + denom_units: Vec, + base: String, + display: String, + name: String, + symbol: String, + uri: String, + uri_hash: String, + }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]