Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support both osmosis and CW tokenfactory msg standards #788

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 38 additions & 25 deletions Cargo.lock

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

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"packages/*",
"ci/*",
]
resolver = "2"

[workspace.package]
edition = "2021"
Expand Down Expand Up @@ -55,13 +56,16 @@ cw721-base = "0.18"
env_logger = "0.10"
once_cell = "1.18"
osmosis-std = "0.20.1"
osmosis-std-derive = "0.20.1"
osmosis-test-tube = "20.1.1"
proc-macro2 = "1.0"
prost = "0.11"
prost = { version = "0.12.3", features = ["prost-derive"] }
prost-types = { version = "0.12.3", default-features = false }
quote = "1.0"
rand = "0.8"
schemars = "0.8"
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde-cw-value = "0.7"
serde_json = "1.0"
serde_yaml = "0.9"
sg-multi-test = "3.1.0"
Expand All @@ -71,7 +75,6 @@ sg721-base = "3.1.0"
syn = { version = "1.0", features = ["derive"] }
test-context = "0.1"
thiserror = { version = "1.0" }
token-bindings = "0.11.0"
wynd-utils = "0.4"

# One commit ahead of version 0.3.0. Allows initialization with an
Expand All @@ -85,6 +88,7 @@ cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.4.
cw-payroll-factory = { path = "./contracts/external/cw-payroll-factory", version = "2.4.0" }
cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.4.0" }
cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "2.4.0" }
cw-tokenfactory-types = { path = "./packages/cw-tokenfactory-types", version = "2.4.0", default-features = false }
cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.4.0" }
cw-wormhole = { path = "./packages/cw-wormhole", version = "2.4.0" }
cw20-stake = { path = "./contracts/staking/cw20-stake", version = "2.4.0" }
Expand Down
20 changes: 14 additions & 6 deletions contracts/external/cw-tokenfactory-issuer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[package]
authors = ["Maurits Bos <[email protected]>", "Sunny Aggarwal <[email protected]>", "Jake Hartnell <[email protected]>"]
authors = [
"Maurits Bos <[email protected]>",
"Sunny Aggarwal <[email protected]>",
"Jake Hartnell <[email protected]>",
]
name = "cw-tokenfactory-issuer"
description = "A CosmWasm contract that issues new Token Factory tokens on supported chains."
version = { workspace = true }
Expand All @@ -23,15 +27,18 @@ exclude = [
crate-type = ["cdylib", "rlib"]

[features]
default = ["osmosis_tokenfactory"]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []
# use test tube feature to enable test-tube integration tests, for example
# cargo test --features "test-tube"
test-tube = []
# when writing tests you may wish to enable test-tube as a default feature
# default = ["test-tube"]
test-tube = ["osmosis_tokenfactory"]
# different tokenfactory cosmos sdk module standards. enable corresponding
# standard in types library
osmosis_tokenfactory = ["cw-tokenfactory-types/osmosis_tokenfactory"]
cosmwasm_tokenfactory = ["cw-tokenfactory-types/cosmwasm_tokenfactory"]

[dependencies]
cosmwasm-schema = { workspace = true }
Expand All @@ -40,12 +47,13 @@ cosmwasm-storage = { workspace = true }
cw2 = { workspace = true }
cw-ownable = { workspace = true }
cw-storage-plus = { workspace = true }
cw-tokenfactory-types = { workspace = true, default-features = false }
dao-interface = { workspace = true }
osmosis-std = { workspace = true }
prost = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true, default-features = false, features = ["derive"]}
serde = { workspace = true, default-features = false, features = ["derive"] }
thiserror = { workspace = true }
token-bindings = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { workspace = true }
Expand Down
26 changes: 10 additions & 16 deletions contracts/external/cw-tokenfactory-issuer/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, SubMsg,
to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, SubMsg,
};
use cosmwasm_std::{CosmosMsg, Reply};
use cw2::{get_contract_version, set_contract_version, ContractVersion};
use osmosis_std::types::osmosis::tokenfactory::v1beta1::{MsgCreateDenom, MsgCreateDenomResponse};
use token_bindings::TokenFactoryMsg;
use cw_tokenfactory_types::msg::{msg_create_denom, MsgCreateDenomResponse};

use crate::error::ContractError;
use crate::execute;
Expand All @@ -29,7 +27,7 @@
env: Env,
info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response<TokenFactoryMsg>, ContractError> {
) -> Result<Response, ContractError> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

// Owner is the sender of the initial InstantiateMsg
Expand All @@ -54,10 +52,7 @@
.add_submessage(
// Create new denom, denom info is saved in the reply
SubMsg::reply_on_success(
<CosmosMsg<TokenFactoryMsg>>::from(MsgCreateDenom {
sender: env.contract.address.to_string(),
subdenom,
}),
msg_create_denom(env.contract.address.to_string(), subdenom),

Check warning on line 55 in contracts/external/cw-tokenfactory-issuer/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/external/cw-tokenfactory-issuer/src/contract.rs#L55

Added line #L55 was not covered by tests
CREATE_DENOM_REPLY_ID,
),
))
Expand All @@ -79,7 +74,7 @@
env: Env,
info: MessageInfo,
msg: ExecuteMsg,
) -> Result<Response<TokenFactoryMsg>, ContractError> {
) -> Result<Response, ContractError> {

Check warning on line 77 in contracts/external/cw-tokenfactory-issuer/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/external/cw-tokenfactory-issuer/src/contract.rs#L77

Added line #L77 was not covered by tests
match msg {
// Executive Functions
ExecuteMsg::Mint { to_address, amount } => {
Expand All @@ -92,6 +87,8 @@
ExecuteMsg::Deny { address, status } => execute::deny(deps, env, info, address, status),
ExecuteMsg::Allow { address, status } => execute::allow(deps, info, address, status),
ExecuteMsg::Freeze { status } => execute::freeze(deps, env, info, status),

#[cfg(feature = "osmosis_tokenfactory")]
ExecuteMsg::ForceTransfer {
amount,
from_address,
Expand All @@ -100,7 +97,7 @@

// Admin functions
ExecuteMsg::UpdateTokenFactoryAdmin { new_admin } => {
execute::update_tokenfactory_admin(deps, info, new_admin)
execute::update_tokenfactory_admin(deps, env, info, new_admin)

Check warning on line 100 in contracts/external/cw-tokenfactory-issuer/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/external/cw-tokenfactory-issuer/src/contract.rs#L100

Added line #L100 was not covered by tests
}
ExecuteMsg::UpdateOwnership(action) => {
execute::update_contract_owner(deps, env, info, action)
Expand All @@ -111,6 +108,7 @@
ExecuteMsg::SetBurnerAllowance { address, allowance } => {
execute::set_burner(deps, info, address, allowance)
}
#[cfg(feature = "osmosis_tokenfactory")]
ExecuteMsg::SetBeforeSendHook { cosmwasm_address } => {
execute::set_before_send_hook(deps, env, info, cosmwasm_address)
}
Expand Down Expand Up @@ -177,11 +175,7 @@
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn reply(
deps: DepsMut,
_env: Env,
msg: Reply,
) -> Result<Response<TokenFactoryMsg>, ContractError> {
pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractError> {

Check warning on line 178 in contracts/external/cw-tokenfactory-issuer/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/external/cw-tokenfactory-issuer/src/contract.rs#L178

Added line #L178 was not covered by tests
match msg.id {
CREATE_DENOM_REPLY_ID => {
let MsgCreateDenomResponse { new_token_denom } = msg.result.try_into()?;
Expand Down
Loading
Loading