Skip to content

Commit

Permalink
Merge pull request #39 from neutron-org/feat/missing-tokenfactory-bin…
Browse files Browse the repository at this point in the history
…dings

Feat: missing tokenfactory bindings
  • Loading branch information
pr0n00gler authored Feb 13, 2024
2 parents e014008 + e8a13de commit 2ae599d
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 8 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

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

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 = "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 }
Expand Down
40 changes: 36 additions & 4 deletions contracts/reflect/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
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};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
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");

Expand All @@ -30,16 +33,33 @@ pub fn instantiate(
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
Send { to: String, amount: u128 },
ReflectMsg { msgs: Vec<CosmosMsg<NeutronMsg>> },
}

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

#[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<NeutronMsg>> {
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]
Expand All @@ -49,6 +69,18 @@ pub fn query(deps: Deps<InterchainQueries>, env: Env, msg: QueryMsg) -> StdResul
}
}

#[entry_point]
pub fn reply(_deps: DepsMut, _env: Env, msg: Reply) -> StdResult<Response> {
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<InterchainQueries>,
_env: Env,
Expand Down
26 changes: 26 additions & 0 deletions contracts/tokenfactory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
18 changes: 17 additions & 1 deletion contracts/tokenfactory/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::Uint128;
use cosmwasm_std::{DenomUnit, Uint128};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -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<DenomUnit>,
base: String,
display: String,
name: String,
symbol: String,
uri: String,
uri_hash: String,
},
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
Expand Down

0 comments on commit 2ae599d

Please sign in to comment.