Skip to content

Commit

Permalink
Support both osmosis and cosmwasm tokenfactory msg standards via feat…
Browse files Browse the repository at this point in the history
…ure flags.
  • Loading branch information
NoahSaso committed Dec 18, 2023
1 parent a3f15d7 commit 66b34c8
Show file tree
Hide file tree
Showing 22 changed files with 855 additions and 54 deletions.
103 changes: 92 additions & 11 deletions Cargo.lock

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

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ overflow-checks = true
[workspace.dependencies]
anyhow = { version = "1.0" }
assert_matches = "1.5"
chrono = "0.4.31"
cosm-orc = { version = "4.0" }
cosm-tome = "0.2"
cosmos-sdk-proto = "0.19"
Expand All @@ -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 = "0.12.3"
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 @@ -85,6 +89,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
19 changes: 14 additions & 5 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,10 +47,12 @@ 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 }

Expand Down
11 changes: 7 additions & 4 deletions contracts/external/cw-tokenfactory-issuer/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cosmwasm_std::{
};
use cosmwasm_std::{CosmosMsg, Reply};
use cw2::{get_contract_version, set_contract_version, ContractVersion};
use osmosis_std::types::osmosis::tokenfactory::v1beta1::{MsgCreateDenom, MsgCreateDenomResponse};
use cw_tokenfactory_types::msg::{msg_create_denom, MsgCreateDenomResponse};
use token_bindings::TokenFactoryMsg;

use crate::error::ContractError;
Expand Down Expand Up @@ -54,10 +54,10 @@ pub fn instantiate(
.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(),
<CosmosMsg<TokenFactoryMsg>>::from(msg_create_denom(
env.contract.address.to_string(),

Check warning on line 58 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#L57-L58

Added lines #L57 - L58 were not covered by tests
subdenom,
}),
)),

Check warning on line 60 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#L60

Added line #L60 was not covered by tests
CREATE_DENOM_REPLY_ID,
),
))
Expand Down Expand Up @@ -92,6 +92,8 @@ pub fn execute(
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 @@ -111,6 +113,7 @@ pub fn execute(
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
Loading

0 comments on commit 66b34c8

Please sign in to comment.