Skip to content

Commit

Permalink
Move tokenfactory-issuer to new home in external contracts folder
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell committed Aug 20, 2023
1 parent 388681a commit ceb91f6
Show file tree
Hide file tree
Showing 33 changed files with 696 additions and 300 deletions.
424 changes: 395 additions & 29 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ cosmwasm-schema = { version = "1.2" }
cosmwasm-std = { version = "1.2", features = ["ibc3"] }
cosmwasm-storage = { version = "1.2" }
cw-controllers = "1.1"
# TODO use upstream when PR merged: https://github.com/CosmWasm/cw-multi-test/pull/51
# TODO use upstream when PR merged and new release tagged: https://github.com/CosmWasm/cw-multi-test/pull/51
cw-multi-test = { git = "https://github.com/JakeHartnell/cw-multi-test.git", branch = "bank-supply-support" }
cw-storage-plus = { version = "1.1" }
cw-utils = "1.0"
Expand All @@ -55,17 +55,21 @@ cw721 = "0.18"
cw721-base = "0.18"
env_logger = "0.10"
once_cell = "1.18"
osmosis-std = {git = "https://github.com/osmosis-labs/osmosis-rust", branch = "main"}
proc-macro2 = "1.0"
prost = "0.11"
quote = "1.0"
rand = "0.8"
schemars = "0.8"
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
syn = { version = "1.0", features = ["derive"] }
test-context = "0.1"
thiserror = { version = "1.0" }
token-bindings = { git = "https://github.com/CosmosContracts/token-bindings.git", branch = "update-token-bindings-test" }
token-bindings-test = { git = "https://github.com/CosmosContracts/token-bindings.git", branch = "update-token-bindings-test" }
# TODO use upstream when PR merged
token-bindings = { git = "https://github.com/CosmosContracts/token-bindings.git", branch = "update-token-bindings" }
token-bindings-test = { git = "https://github.com/CosmosContracts/token-bindings.git", branch = "update-token-bindings" }
wynd-utils = "0.4"

# One commit ahead of version 0.3.0. Allows initialization with an
Expand All @@ -78,6 +82,7 @@ cw-hooks = { path = "./packages/cw-hooks", version = "2.2.0" }
cw-wormhole = { path = "./packages/cw-wormhole", version = "2.2.0" }
cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.2.0" }
cw-payroll-factory = { path = "./contracts/external/cw-payroll-factory", version = "2.2.0" }
cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "*" }
cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.2.0" }
cw20-stake = { path = "./contracts/staking/cw20-stake", version = "2.2.0" }
cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.2.0" }
Expand Down
File renamed without changes.
49 changes: 49 additions & 0 deletions contracts/external/cw-tokenfactory-issuer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[package]
authors = ["Maurits Bos <[email protected]>", "Sunny Aggarwal <[email protected]>"]
name = "cw-tokenfactory-issuer"
description = "A CosmWasm contract that issues new Token Factory tokens on supported chains."
version = { workspace = true }
edition = { workspace = true }
repository = { workspace = true }

# This repo was fork from osmosis-labs/cw-tokenfactory-issuer and does not use
# the default DAO DAO license
license = "Apache-2.0"


exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cosmwasm-storage = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
osmosis-std = { workspace = true }
prost = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true, default-features = false, features = ["derive"]}
thiserror = { workspace = true }
token-bindings = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { workspace = true }
cw-multi-test = { workspace = true }
# TODO update to test tube or figure out what to do with tests
osmosis-testing = "0.13.2"
serde_json = { workspace = true }
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::write_api;

use tokenfactory_issuer::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg};
use cw_tokenfactory_issuer::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg};

fn main() {
write_api! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::queries;
use crate::state::{DENOM, IS_FROZEN, OWNER};

// version info for migration info
const CONTRACT_NAME: &str = "crates.io:tokenfactory-issuer";
const CONTRACT_NAME: &str = "crates.io:cw-tokenfactory-issuer";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

const CREATE_DENOM_REPLY_ID: u64 = 1;
Expand Down Expand Up @@ -86,18 +86,20 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result<Response<OsmosisMsg>
let MsgCreateDenomResponse { new_token_denom } = msg.result.try_into()?;
DENOM.save(deps.storage, &new_token_denom)?;

// TODO maybe do error handling for this?
// TODO maybe do error handling for this? Not every chain supports it.
// // set beforesend listener to this contract
// // this will trigger sudo endpoint before any bank send
// // which makes blacklisting / freezing possible
// let msg_set_beforesend_listener: CosmosMsg<OsmosisMsg> = MsgSetBeforeSendHook {
// sender: env.contract.address.to_string(),
// denom: new_token_denom.clone(),
// cosmwasm_address: env.contract.address.to_string(),
// }
// .into();

return Ok(Response::new().add_attribute("denom", new_token_denom));
let msg_set_beforesend_listener: CosmosMsg<OsmosisMsg> = MsgSetBeforeSendHook {
sender: env.contract.address.to_string(),
denom: new_token_denom.clone(),
cosmwasm_address: env.contract.address.to_string(),
}
.into();

return Ok(Response::new()
.add_attribute("denom", new_token_denom)
.add_message(msg_set_beforesend_listener));
}

unreachable!()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use osmosis_testing::{Account, RunnerError};
fn before_send_should_not_block_anything_by_default() {
let env = TestEnv::default();
let owner = &env.test_accs[0];
let denom = env.tokenfactory_issuer.query_denom().unwrap().denom;
let denom = env.cw_tokenfactory_issuer.query_denom().unwrap().denom;

// mint to self
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.set_minter(&owner.address(), 10000, owner)
.unwrap();
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.mint(&owner.address(), 10000, owner)
.unwrap();

Expand All @@ -27,14 +27,14 @@ fn before_send_should_not_block_anything_by_default() {
fn before_send_should_block_on_frozen() {
let env = TestEnv::default();
let owner = &env.test_accs[0];
let denom = env.tokenfactory_issuer.query_denom().unwrap().denom;
let denom = env.cw_tokenfactory_issuer.query_denom().unwrap().denom;

// freeze
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.set_freezer(&owner.address(), true, owner)
.unwrap();

env.tokenfactory_issuer.freeze(true, owner).unwrap();
env.cw_tokenfactory_issuer.freeze(true, owner).unwrap();

// bank send should fail
let err = env
Expand All @@ -53,21 +53,21 @@ fn before_send_should_block_sending_from_blacklisted_address() {
let env = TestEnv::default();
let owner = &env.test_accs[0];
let blacklistee = &env.test_accs[1];
let denom = env.tokenfactory_issuer.query_denom().unwrap().denom;
let denom = env.cw_tokenfactory_issuer.query_denom().unwrap().denom;

// mint to blacklistee
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.set_minter(&owner.address(), 20000, owner)
.unwrap();
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.mint(&blacklistee.address(), 20000, owner)
.unwrap();

// blacklist
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.set_blacklister(&owner.address(), true, owner)
.unwrap();
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.blacklist(&blacklistee.address(), true, owner)
.unwrap();

Expand All @@ -89,21 +89,21 @@ fn before_send_should_block_sending_to_blacklisted_address() {
let env = TestEnv::default();
let owner = &env.test_accs[0];
let blacklistee = &env.test_accs[1];
let denom = env.tokenfactory_issuer.query_denom().unwrap().denom;
let denom = env.cw_tokenfactory_issuer.query_denom().unwrap().denom;

// mint to self
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.set_minter(&owner.address(), 10000, owner)
.unwrap();
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.mint(&owner.address(), 10000, owner)
.unwrap();

// blacklist
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.set_blacklister(&owner.address(), true, owner)
.unwrap();
env.tokenfactory_issuer
env.cw_tokenfactory_issuer
.blacklist(&blacklistee.address(), true, owner)
.unwrap();

Expand Down
Loading

0 comments on commit ceb91f6

Please sign in to comment.