Skip to content

Commit caea80a

Browse files
authored
support kujira's /kujira.denom... tokenfactory fork (#816)
1 parent d59c282 commit caea80a

File tree

17 files changed

+418
-155
lines changed

17 files changed

+418
-155
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ cw-hooks = { path = "./packages/cw-hooks", version = "2.4.1" }
8686
cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.4.1" }
8787
cw-payroll-factory = { path = "./contracts/external/cw-payroll-factory", version = "2.4.1" }
8888
cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.4.1" }
89-
cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "2.4.1" }
89+
cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "2.4.1", default-features = false }
9090
cw-tokenfactory-types = { path = "./packages/cw-tokenfactory-types", version = "2.4.1", default-features = false }
9191
cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.4.1" }
9292
cw-wormhole = { path = "./packages/cw-wormhole", version = "2.4.1" }

contracts/external/cw-tokenfactory-issuer/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ test-tube = ["osmosis_tokenfactory"]
3939
# standard in types library
4040
osmosis_tokenfactory = ["cw-tokenfactory-types/osmosis_tokenfactory"]
4141
cosmwasm_tokenfactory = ["cw-tokenfactory-types/cosmwasm_tokenfactory"]
42+
kujira_tokenfactory = ["cw-tokenfactory-types/kujira_tokenfactory"]
4243

4344
[dependencies]
4445
cosmwasm-schema = { workspace = true }

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ pub fn execute(
112112
ExecuteMsg::SetBeforeSendHook { cosmwasm_address } => {
113113
execute::set_before_send_hook(deps, env, info, cosmwasm_address)
114114
}
115+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
115116
ExecuteMsg::SetDenomMetadata { metadata } => {
116117
execute::set_denom_metadata(deps, env, info, metadata)
117118
}

contracts/external/cw-tokenfactory-issuer/src/execute.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use cosmwasm_std::{coins, BankMsg, CosmosMsg, DepsMut, Env, MessageInfo, Response, Uint128};
22

3-
use cw_tokenfactory_types::msg::{msg_burn, msg_change_admin, msg_mint, msg_set_denom_metadata};
3+
use cw_tokenfactory_types::msg::{msg_burn, msg_change_admin, msg_mint};
44
#[cfg(feature = "osmosis_tokenfactory")]
55
use cw_tokenfactory_types::msg::{msg_force_transfer, msg_set_before_send_hook};
6-
7-
use dao_interface::token::Metadata;
6+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
7+
use {cw_tokenfactory_types::msg::msg_set_denom_metadata, dao_interface::token::Metadata};
88

99
use crate::error::ContractError;
1010
use crate::helpers::{check_before_send_hook_features_enabled, check_is_not_frozen};
@@ -177,6 +177,7 @@ pub fn update_tokenfactory_admin(
177177
/// Sets metadata related to the Token Factory denom.
178178
///
179179
/// Must be the contract owner to call this method.
180+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
180181
pub fn set_denom_metadata(
181182
deps: DepsMut,
182183
env: Env,

contracts/external/cw-tokenfactory-issuer/src/msg.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::state::BeforeSendHookInfo;
22
use cosmwasm_schema::{cw_serde, QueryResponses};
33
use cosmwasm_std::{Coin, Uint128};
44

5+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
56
pub use dao_interface::token::{DenomUnit, Metadata};
67

78
/// The message used to create a new instance of this smart contract.
@@ -78,6 +79,7 @@ pub enum ExecuteMsg {
7879
SetBurnerAllowance { address: String, allowance: Uint128 },
7980

8081
/// Set denom metadata. see: https://docs.cosmos.network/main/modules/bank#denom-metadata.
82+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
8183
SetDenomMetadata { metadata: Metadata },
8284

8385
/// Grant/revoke mint allowance.

contracts/external/cw-tokenfactory-issuer/tests/cases/denom_metadata.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use cw_tokenfactory_issuer::{msg::InstantiateMsg, ContractError};
22

33
use crate::test_env::{TestEnv, TokenfactoryIssuer};
44

5+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
56
#[test]
67
fn set_denom_metadata_by_contract_owner_should_work() {
78
let subdenom = "usthb".to_string();
@@ -35,6 +36,7 @@ fn set_denom_metadata_by_contract_owner_should_work() {
3536
.unwrap();
3637
}
3738

39+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
3840
#[test]
3941
fn set_denom_metadata_by_contract_non_owner_should_fail() {
4042
let subdenom = "usthb".to_string();
@@ -78,6 +80,7 @@ fn set_denom_metadata_by_contract_non_owner_should_fail() {
7880
)
7981
}
8082

83+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
8184
#[test]
8285
fn set_denom_metadata_with_base_denom_unit_should_overides_default_base_denom_unit() {
8386
let subdenom = "usthb".to_string();

contracts/external/cw-tokenfactory-issuer/tests/test_env.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
use cosmwasm_std::Uint128;
77
use cosmwasm_std::{Addr, Coin};
88

9-
use cw_tokenfactory_issuer::msg::{AllowlistResponse, DenylistResponse, Metadata, MigrateMsg};
9+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
10+
use cw_tokenfactory_issuer::msg::Metadata;
11+
12+
use cw_tokenfactory_issuer::msg::{AllowlistResponse, DenylistResponse, MigrateMsg};
1013
use cw_tokenfactory_issuer::{
1114
msg::{
1215
AllowanceResponse, AllowancesResponse, DenomResponse, ExecuteMsg, InstantiateMsg,
@@ -204,6 +207,7 @@ impl TokenfactoryIssuer {
204207
)
205208
}
206209

210+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
207211
pub fn set_denom_metadata(
208212
&self,
209213
metadata: Metadata,

contracts/test/dao-test-custom-factory/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ thiserror = { workspace = true }
2929
dao-dao-macros = { workspace = true }
3030
dao-interface = { workspace = true }
3131
dao-voting = { workspace = true }
32-
cw-tokenfactory-issuer = { workspace = true, features = ["library"] }
32+
cw-tokenfactory-issuer = { workspace = true, features = [
33+
"library",
34+
"osmosis_tokenfactory",
35+
] }
3336

3437
[dev-dependencies]
3538
cw-multi-test = { workspace = true }

contracts/voting/dao-voting-token-staked/Cargo.toml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
[package]
22
name = "dao-voting-token-staked"
3-
authors = ["Callum Anderson <[email protected]>", "Noah Saso <[email protected]>", "Jake Hartnell <[email protected]>"]
3+
authors = [
4+
"Callum Anderson <[email protected]>",
5+
"Noah Saso <[email protected]>",
6+
"Jake Hartnell <[email protected]>",
7+
]
48
description = "A DAO DAO voting module based on staked token factory or native tokens. Only works with chains that support Token Factory."
59
edition = { workspace = true }
610
license = { workspace = true }
@@ -11,6 +15,7 @@ version = { workspace = true }
1115
crate-type = ["cdylib", "rlib"]
1216

1317
[features]
18+
default = ["osmosis_tokenfactory"]
1419
# for more explicit tests, cargo test --features=backtraces
1520
backtraces = ["cosmwasm-std/backtraces"]
1621
# use library feature to disable all instantiate/execute/query exports
@@ -20,9 +25,14 @@ library = []
2025
test-tube = []
2126
# when writing tests you may wish to enable test-tube as a default feature
2227
# default = ["test-tube"]
28+
# different tokenfactory cosmos sdk module standards. enable corresponding
29+
# standard in types library
30+
osmosis_tokenfactory = ["cw-tokenfactory-issuer/osmosis_tokenfactory"]
31+
cosmwasm_tokenfactory = ["cw-tokenfactory-issuer/cosmwasm_tokenfactory"]
32+
kujira_tokenfactory = ["cw-tokenfactory-issuer/kujira_tokenfactory"]
2333

2434
[dependencies]
25-
cosmwasm-std = { workspace = true, features = ["cosmwasm_1_1"] }
35+
cosmwasm-std = { workspace = true, features = ["cosmwasm_1_1"] }
2636
cosmwasm-schema = { workspace = true }
2737
cw-ownable = { workspace = true }
2838
cw-storage-plus = { workspace = true }
@@ -35,12 +45,13 @@ dao-dao-macros = { workspace = true }
3545
dao-hooks = { workspace = true }
3646
dao-interface = { workspace = true }
3747
dao-voting = { workspace = true }
38-
cw-tokenfactory-issuer = { workspace = true, features = ["library"] }
48+
cw-tokenfactory-issuer = { workspace = true, default-features = false, features = [
49+
"library",
50+
] }
3951

4052
[dev-dependencies]
4153
anyhow = { workspace = true }
4254
cw-multi-test = { workspace = true }
43-
cw-tokenfactory-issuer = { workspace = true }
4455
dao-proposal-single = { workspace = true }
4556
dao-proposal-hook-counter = { workspace = true }
4657
dao-test-custom-factory = { workspace = true }

contracts/voting/dao-voting-token-staked/src/contract.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ use cw2::{get_contract_version, set_contract_version, ContractVersion};
99
use cw_controllers::ClaimsResponse;
1010
use cw_storage_plus::Bound;
1111
use cw_tokenfactory_issuer::msg::{
12-
DenomUnit, ExecuteMsg as IssuerExecuteMsg, InstantiateMsg as IssuerInstantiateMsg, Metadata,
12+
ExecuteMsg as IssuerExecuteMsg, InstantiateMsg as IssuerInstantiateMsg,
1313
};
14+
15+
#[cfg(any(feature = "osmosis_tokenfactory", feature = "cosmwasm_tokenfactory"))]
16+
use cw_tokenfactory_issuer::msg::{DenomUnit, Metadata};
17+
1418
use cw_utils::{
1519
maybe_addr, must_pay, parse_reply_execute_data, parse_reply_instantiate_data, Duration,
1620
};
@@ -627,6 +631,10 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result<Response, ContractEr
627631
});
628632

629633
// If metadata, set it by calling the contract
634+
#[cfg(any(
635+
feature = "osmosis_tokenfactory",
636+
feature = "cosmwasm_tokenfactory"
637+
))]
630638
if let Some(metadata) = token.metadata {
631639
// The first denom_unit must be the same as the tf and base denom.
632640
// It must have an exponent of 0. This the smallest unit of the token.

0 commit comments

Comments
 (0)