From 678e560ea4c32bf5e7ba4c551eb35a553698057f Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Thu, 17 Aug 2023 12:07:14 -0700 Subject: [PATCH 1/9] Upgrade dependencies in bindings-test package, add basic readme --- Cargo.lock | 80 ++++++++----------------------- packages/bindings-test/Cargo.toml | 17 ++++--- packages/bindings-test/README.md | 3 ++ packages/bindings/Cargo.toml | 2 +- 4 files changed, 33 insertions(+), 69 deletions(-) create mode 100644 packages/bindings-test/README.md diff --git a/Cargo.lock b/Cargo.lock index 2411ff9..6d5e048 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,25 +205,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "cw-multi-test" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e81b4a7821d5eeba0d23f737c16027b39a600742ca8c32eb980895ffd270f4" -dependencies = [ - "anyhow", - "cosmwasm-std", - "cosmwasm-storage", - "cw-storage-plus 0.15.1", - "cw-utils 0.15.1", - "derivative", - "itertools", - "prost", - "schemars", - "serde", - "thiserror", -] - [[package]] name = "cw-multi-test" version = "0.16.5" @@ -233,9 +214,9 @@ dependencies = [ "anyhow", "cosmwasm-std", "cw-storage-plus 1.1.0", - "cw-utils 1.0.1", + "cw-utils", "derivative", - "itertools", + "itertools 0.10.5", "k256", "prost", "schemars", @@ -245,9 +226,9 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6cf70ef7686e2da9ad7b067c5942cd3e88dd9453f7af42f54557f8af300fb0" +checksum = "d9b6f91c0b94481a3e9ef1ceb183c37d00764f8751e39b45fc09f4d9b970d469" dependencies = [ "cosmwasm-std", "schemars", @@ -265,21 +246,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cw-utils" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ae0b69fa7679de78825b4edeeec045066aa2b2c4b6e063d80042e565bb4da5c" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw2 0.15.1", - "schemars", - "semver", - "serde", - "thiserror", -] - [[package]] name = "cw-utils" version = "1.0.1" @@ -288,26 +254,13 @@ checksum = "c80e93d1deccb8588db03945016a292c3c631e6325d349ebb35d2db6f4f946f7" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw2 1.1.0", + "cw2", "schemars", "semver", "serde", "thiserror", ] -[[package]] -name = "cw2" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5abb8ecea72e09afff830252963cb60faf945ce6cef2c20a43814516082653da" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 0.15.1", - "schemars", - "serde", -] - [[package]] name = "cw2" version = "1.1.0" @@ -503,6 +456,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" @@ -575,7 +537,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" dependencies = [ "anyhow", - "itertools", + "itertools 0.10.5", "proc-macro2", "quote", "syn 1.0.109", @@ -821,13 +783,13 @@ dependencies = [ [[package]] name = "token-bindings-test" -version = "0.8.0" +version = "0.9.0" dependencies = [ "anyhow", "cosmwasm-std", - "cw-multi-test 0.15.1", - "cw-storage-plus 0.15.1", - "itertools", + "cw-multi-test", + "cw-storage-plus 0.16.0", + "itertools 0.11.0", "schemars", "serde", "thiserror", @@ -854,9 +816,9 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-multi-test 0.16.5", + "cw-multi-test", "cw-storage-plus 1.1.0", - "cw2 1.1.0", + "cw2", "schemars", "serde", "thiserror", diff --git a/packages/bindings-test/Cargo.toml b/packages/bindings-test/Cargo.toml index 067d536..e131a26 100644 --- a/packages/bindings-test/Cargo.toml +++ b/packages/bindings-test/Cargo.toml @@ -1,20 +1,19 @@ [package] name = "token-bindings-test" -version = "0.8.0" -authors = ["Ethan Frey "] -edition = "2018" -description = "Multitest (and other test helpers) support for Osmosis-specific contracts" -repository = "https://github.com/confio/osmosis-bindings" -homepage = "https://osmosis.zone" +version = "0.9.0" +authors = ["Ethan Frey ", "Jake Hartnell "] +edition = "2021" +description = "Multitest (and other test helpers) support for Token factory contracts" +repository = "https://github.com/CosmosContracts/token-bindings" license = "Apache-2.0" [dependencies] -itertools = "0.10" +itertools = "0.11" token-bindings = { version = "0.10.3", path = "../bindings" } cosmwasm-std = "1.1" schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -cw-multi-test = "0.15" -cw-storage-plus = "0.15" +cw-multi-test = "0.16" +cw-storage-plus = "0.16" anyhow = "1" thiserror = "1.0" diff --git a/packages/bindings-test/README.md b/packages/bindings-test/README.md new file mode 100644 index 0000000..6519b3d --- /dev/null +++ b/packages/bindings-test/README.md @@ -0,0 +1,3 @@ +# token-bindings-test + +Use this as a drop in replacement for `cw-multi-test` if you are working with contracts leveraging Token Factory. diff --git a/packages/bindings/Cargo.toml b/packages/bindings/Cargo.toml index d89df90..32b6143 100644 --- a/packages/bindings/Cargo.toml +++ b/packages/bindings/Cargo.toml @@ -3,7 +3,7 @@ name = "token-bindings" version = "0.10.3" authors = ["Ethan Frey ", "Reece Williams "] edition = "2018" -description = "Bindings for CustomMsg and CustomQuery for the Juno blockchain" +description = "Bindings for CustomMsg and CustomQuery for blockchains supporting Token Factory." repository = "https://github.com/CosmosContracts/token-bindings" homepage = "https://junonetwork.io" license = "Apache-2.0" From 9c16f5fb2fa1beb6c85b27982adc7520017f7426 Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Thu, 17 Aug 2023 13:55:11 -0700 Subject: [PATCH 2/9] Temp fixup for DAO DAO tests --- Cargo.lock | 22 ++++++++++++++++++++-- packages/bindings-test/Cargo.toml | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d5e048..e0f8e4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,6 +224,24 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw-multi-test" +version = "0.16.5" +source = "git+https://github.com/JakeHartnell/cw-multi-test.git?branch=bank-supply-support#e601da7975cbbb731402ae967590d3655bb9f390" +dependencies = [ + "anyhow", + "cosmwasm-std", + "cw-storage-plus 1.1.0", + "cw-utils", + "derivative", + "itertools 0.10.5", + "k256", + "prost", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "cw-storage-plus" version = "0.16.0" @@ -787,7 +805,7 @@ version = "0.9.0" dependencies = [ "anyhow", "cosmwasm-std", - "cw-multi-test", + "cw-multi-test 0.16.5 (git+https://github.com/JakeHartnell/cw-multi-test.git?branch=bank-supply-support)", "cw-storage-plus 0.16.0", "itertools 0.11.0", "schemars", @@ -816,7 +834,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-multi-test", + "cw-multi-test 0.16.5 (registry+https://github.com/rust-lang/crates.io-index)", "cw-storage-plus 1.1.0", "cw2", "schemars", diff --git a/packages/bindings-test/Cargo.toml b/packages/bindings-test/Cargo.toml index e131a26..33dfc4c 100644 --- a/packages/bindings-test/Cargo.toml +++ b/packages/bindings-test/Cargo.toml @@ -13,7 +13,8 @@ token-bindings = { version = "0.10.3", path = "../bindings" } cosmwasm-std = "1.1" schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } -cw-multi-test = "0.16" +# TODO use upstream when PR merged: 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 = "0.16" anyhow = "1" thiserror = "1.0" From 8e361f3fa429dd33eecf14a2d50b06376e7683dd Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Sat, 19 Aug 2023 18:51:56 -0700 Subject: [PATCH 3/9] Make interface more consistent with OsmosisMsg for better reuse --- contracts/reflect/src/contract.rs | 16 +++++------ contracts/reflect/src/msg.rs | 14 +++------- contracts/tokenfactory/src/contract.rs | 36 ++++++++++++------------- packages/bindings-test/src/multitest.rs | 26 +++++++++--------- packages/bindings/examples/schema.rs | 4 +-- packages/bindings/src/lib.rs | 4 +-- packages/bindings/src/msg.rs | 23 +++++----------- packages/bindings/src/querier.rs | 4 +-- packages/bindings/src/query.rs | 16 ++--------- 9 files changed, 56 insertions(+), 87 deletions(-) diff --git a/contracts/reflect/src/contract.rs b/contracts/reflect/src/contract.rs index 0270de4..b5a5a9f 100644 --- a/contracts/reflect/src/contract.rs +++ b/contracts/reflect/src/contract.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{ entry_point, to_binary, to_vec, ContractResult, CosmosMsg, Deps, DepsMut, Env, MessageInfo, QueryRequest, QueryResponse, Reply, Response, StdError, StdResult, SubMsg, SystemResult, }; -use token_bindings::{TokenFactoryMsg, TokenFactoryQuery}; +use token_bindings::{TokenFactoryQuery, TokenMsg}; use crate::errors::ReflectError; use crate::msg::{ChainResponse, ExecuteMsg, InstantiateMsg, OwnerResponse, QueryMsg}; @@ -14,7 +14,7 @@ pub fn instantiate( _env: Env, info: MessageInfo, _msg: InstantiateMsg, -) -> StdResult> { +) -> StdResult> { let state = State { owner: info.sender }; config(deps.storage).save(&state)?; Ok(Response::default()) @@ -26,7 +26,7 @@ pub fn execute( env: Env, info: MessageInfo, msg: ExecuteMsg, -) -> Result, ReflectError> { +) -> Result, ReflectError> { match msg { ExecuteMsg::ReflectMsg { msgs } => execute_reflect(deps, env, info, msgs), ExecuteMsg::ReflectSubMsg { msgs } => execute_reflect_subcall(deps, env, info, msgs), @@ -38,8 +38,8 @@ pub fn execute_reflect( deps: DepsMut, _env: Env, info: MessageInfo, - msgs: Vec>, -) -> Result, ReflectError> { + msgs: Vec>, +) -> Result, ReflectError> { let state = config(deps.storage).load()?; if info.sender != state.owner { @@ -62,8 +62,8 @@ pub fn execute_reflect_subcall( deps: DepsMut, _env: Env, info: MessageInfo, - msgs: Vec>, -) -> Result, ReflectError> { + msgs: Vec>, +) -> Result, ReflectError> { let state = config(deps.storage).load()?; if info.sender != state.owner { return Err(ReflectError::NotCurrentOwner { @@ -86,7 +86,7 @@ pub fn execute_change_owner( _env: Env, info: MessageInfo, new_owner: String, -) -> Result, ReflectError> { +) -> Result, ReflectError> { let api = deps.api; config(deps.storage).update(|mut state| { if info.sender != state.owner { diff --git a/contracts/reflect/src/msg.rs b/contracts/reflect/src/msg.rs index 65ee248..53fdd89 100644 --- a/contracts/reflect/src/msg.rs +++ b/contracts/reflect/src/msg.rs @@ -1,22 +1,16 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{Binary, CosmosMsg, QueryRequest, SubMsg}; -use token_bindings::{TokenFactoryMsg, TokenFactoryQuery}; +use token_bindings::{TokenFactoryQuery, TokenMsg}; #[cw_serde] pub struct InstantiateMsg {} #[cw_serde] pub enum ExecuteMsg { - ReflectMsg { - msgs: Vec>, - }, - ReflectSubMsg { - msgs: Vec>, - }, - ChangeOwner { - owner: String, - }, + ReflectMsg { msgs: Vec> }, + ReflectSubMsg { msgs: Vec> }, + ChangeOwner { owner: String }, } #[cw_serde] diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index ea997c3..e8c2fb3 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -8,7 +8,7 @@ use cw2::set_contract_version; use crate::error::TokenFactoryError; use crate::msg::{ExecuteMsg, GetDenomResponse, InstantiateMsg, QueryMsg}; use crate::state::{State, STATE}; -use token_bindings::{TokenFactoryMsg, TokenFactoryQuery, TokenMsg, TokenQuerier}; +use token_bindings::{TokenFactoryQuery, TokenMsg, TokenQuerier}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:tokenfactory-demo"; @@ -38,7 +38,7 @@ pub fn execute( _env: Env, _info: MessageInfo, msg: ExecuteMsg, -) -> Result, TokenFactoryError> { +) -> Result, TokenFactoryError> { match msg { ExecuteMsg::CreateDenom { subdenom } => create_denom(subdenom), ExecuteMsg::ChangeAdmin { @@ -64,7 +64,7 @@ pub fn execute( } } -pub fn create_denom(subdenom: String) -> Result, TokenFactoryError> { +pub fn create_denom(subdenom: String) -> Result, TokenFactoryError> { if subdenom.eq("") { return Err(TokenFactoryError::InvalidSubdenom { subdenom }); } @@ -85,7 +85,7 @@ pub fn change_admin( deps: DepsMut, denom: String, new_admin_address: String, -) -> Result, TokenFactoryError> { +) -> Result, TokenFactoryError> { deps.api.addr_validate(&new_admin_address)?; validate_denom(deps, denom.clone())?; @@ -107,7 +107,7 @@ pub fn mint_tokens( denom: String, amount: Uint128, mint_to_address: String, -) -> Result, TokenFactoryError> { +) -> Result, TokenFactoryError> { deps.api.addr_validate(&mint_to_address)?; if amount.eq(&Uint128::new(0_u128)) { @@ -130,7 +130,7 @@ pub fn burn_tokens( denom: String, amount: Uint128, burn_from_address: String, -) -> Result, TokenFactoryError> { +) -> Result, TokenFactoryError> { if amount.eq(&Uint128::new(0_u128)) { return Result::Err(TokenFactoryError::ZeroAmount {}); } @@ -152,7 +152,7 @@ pub fn force_transfer( amount: Uint128, from_address: String, to_address: String, -) -> Result, TokenFactoryError> { +) -> Result, TokenFactoryError> { if amount.eq(&Uint128::new(0_u128)) { return Result::Err(TokenFactoryError::ZeroAmount {}); } @@ -243,7 +243,7 @@ mod tests { SystemError, SystemResult, }; use std::marker::PhantomData; - use token_bindings::TokenQuery; + use token_bindings::TokenFactoryQuery; use token_bindings_test::TokenFactoryApp; const DENOM_NAME: &str = "mydenom"; @@ -264,10 +264,10 @@ mod tests { ) -> OwnedDeps, TokenFactoryQuery> { let custom_querier: MockQuerier = MockQuerier::new(&[(MOCK_CONTRACT_ADDR, &[])]).with_custom_handler(|a| match a { - TokenFactoryQuery::Token(TokenQuery::FullDenom { + TokenFactoryQuery::FullDenom { creator_addr, subdenom, - }) => { + } => { let binary_request = to_binary(a).unwrap(); if creator_addr.eq("") { @@ -576,8 +576,8 @@ mod tests { burn_from_address: String::from(BURN_FROM_ADDR), amount: burn_amount, }; - let err = execute(deps.as_mut(), mock_env(), info, msg).is_err(); - assert_eq!(err, false) + let err = execute(deps.as_mut(), mock_env(), info, msg).is_err(); + assert!(err) } #[test] @@ -593,15 +593,15 @@ mod tests { let info = mock_info("creator", &coins(2, "token")); - let msg = ExecuteMsg::ForceTransfer { - denom: String::from(full_denom_name), - amount: transfer_amount, - from_address: TRANSFER_FROM_ADDR.to_string(), + let msg = ExecuteMsg::ForceTransfer { + denom: String::from(full_denom_name), + amount: transfer_amount, + from_address: TRANSFER_FROM_ADDR.to_string(), to_address: TRANSFER_TO_ADDR.to_string(), }; - let err = execute(deps.as_mut(), mock_env(), info, msg).is_err(); - assert_eq!(err, false) + let err = execute(deps.as_mut(), mock_env(), info, msg).is_err(); + assert!(err) } #[test] diff --git a/packages/bindings-test/src/multitest.rs b/packages/bindings-test/src/multitest.rs index c3e6748..892ec08 100644 --- a/packages/bindings-test/src/multitest.rs +++ b/packages/bindings-test/src/multitest.rs @@ -18,7 +18,7 @@ use cw_storage_plus::Map; use token_bindings::{ AdminResponse, CreateDenomResponse, DenomsByCreatorResponse, FullDenomResponse, Metadata, - MetadataResponse, TokenFactoryMsg, TokenFactoryQuery, TokenMsg, TokenQuery, + MetadataResponse, TokenFactoryQuery, TokenMsg, }; use crate::error::ContractError; @@ -57,7 +57,7 @@ impl TokenFactoryModule { } impl Module for TokenFactoryModule { - type ExecT = TokenFactoryMsg; + type ExecT = TokenMsg; type QueryT = TokenFactoryQuery; type SudoT = Empty; @@ -69,13 +69,12 @@ impl Module for TokenFactoryModule { router: &dyn CosmosRouter, block: &BlockInfo, sender: Addr, - msg: TokenFactoryMsg, + msg: TokenMsg, ) -> AnyResult where ExecC: Debug + Clone + PartialEq + JsonSchema + DeserializeOwned + 'static, QueryC: CustomQuery + DeserializeOwned + 'static, { - let TokenFactoryMsg::Token(msg) = msg; match msg { TokenMsg::CreateDenom { subdenom, metadata } => { let new_token_denom = self.build_denom(&sender, &subdenom)?; @@ -189,9 +188,8 @@ impl Module for TokenFactoryModule { _block: &BlockInfo, request: TokenFactoryQuery, ) -> anyhow::Result { - let TokenFactoryQuery::Token(query) = request; - match query { - TokenQuery::FullDenom { + match request { + TokenFactoryQuery::FullDenom { creator_addr, subdenom, } => { @@ -200,22 +198,22 @@ impl Module for TokenFactoryModule { let res = FullDenomResponse { denom }; Ok(to_binary(&res)?) } - TokenQuery::Metadata { denom } => { + TokenFactoryQuery::Metadata { denom } => { let metadata = METADATA.may_load(storage, &denom)?; Ok(to_binary(&MetadataResponse { metadata })?) } - TokenQuery::Admin { denom } => { + TokenFactoryQuery::Admin { denom } => { let admin = ADMIN.load(storage, &denom)?.to_string(); Ok(to_binary(&AdminResponse { admin })?) } - TokenQuery::DenomsByCreator { creator } => { + TokenFactoryQuery::DenomsByCreator { creator } => { let creator = api.addr_validate(&creator)?; let denoms = DENOMS_BY_CREATOR .may_load(storage, &creator)? .unwrap_or_default(); Ok(to_binary(&DenomsByCreatorResponse { denoms })?) } - TokenQuery::Params {} => todo!(), + TokenFactoryQuery::Params {} => todo!(), } } } @@ -235,7 +233,7 @@ pub type TokenFactoryAppWrapped = App< MockApi, MockStorage, TokenFactoryModule, - WasmKeeper, + WasmKeeper, >; pub struct TokenFactoryApp(TokenFactoryAppWrapped); @@ -269,7 +267,7 @@ impl Default for TokenFactoryApp { impl TokenFactoryApp { pub fn new() -> Self { Self( - BasicAppBuilder::::new_custom() + BasicAppBuilder::::new_custom() .with_custom(TokenFactoryModule {}) .build(|_router, _, _storage| { // router.custom.set_owner(storage, &owner).unwrap(); @@ -328,7 +326,7 @@ mod tests { let FullDenomResponse { denom } = app .wrap() .query( - &TokenQuery::FullDenom { + &TokenFactoryQuery::FullDenom { creator_addr: contract.to_string(), subdenom: subdenom.to_string(), } diff --git a/packages/bindings/examples/schema.rs b/packages/bindings/examples/schema.rs index 6f51086..223d4be 100644 --- a/packages/bindings/examples/schema.rs +++ b/packages/bindings/examples/schema.rs @@ -5,7 +5,7 @@ use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use token_bindings::{ AdminResponse, DenomsByCreatorResponse, FullDenomResponse, MetadataResponse, ParamsResponse, - TokenFactoryMsg, TokenFactoryQuery, + TokenFactoryQuery, TokenMsg, }; fn main() { @@ -14,7 +14,7 @@ fn main() { create_dir_all(&out_dir).unwrap(); remove_schemas(&out_dir).unwrap(); - export_schema(&schema_for!(TokenFactoryMsg), &out_dir); + export_schema(&schema_for!(TokenMsg), &out_dir); export_schema(&schema_for!(TokenFactoryQuery), &out_dir); export_schema(&schema_for!(AdminResponse), &out_dir); export_schema(&schema_for!(DenomsByCreatorResponse), &out_dir); diff --git a/packages/bindings/src/lib.rs b/packages/bindings/src/lib.rs index 2a7a75f..f479713 100644 --- a/packages/bindings/src/lib.rs +++ b/packages/bindings/src/lib.rs @@ -3,10 +3,10 @@ mod querier; mod query; mod types; -pub use msg::{CreateDenomResponse, TokenFactoryMsg, TokenMsg}; +pub use msg::{CreateDenomResponse, TokenMsg}; pub use querier::TokenQuerier; pub use query::{ AdminResponse, DenomsByCreatorResponse, FullDenomResponse, MetadataResponse, ParamsResponse, - TokenFactoryQuery, TokenQuery, + TokenFactoryQuery, }; pub use types::{DenomUnit, Metadata, Params}; diff --git a/packages/bindings/src/msg.rs b/packages/bindings/src/msg.rs index c001949..b565dd6 100644 --- a/packages/bindings/src/msg.rs +++ b/packages/bindings/src/msg.rs @@ -2,14 +2,6 @@ use crate::types::Metadata; use cosmwasm_schema::cw_serde; use cosmwasm_std::{Binary, CosmosMsg, CustomMsg, StdResult, Uint128}; -/// A top-level Custom message for the token factory. -/// It is embedded like this to easily allow adding other variants that are custom -/// to your chain, or other "standardized" extensions along side it. -#[cw_serde] -pub enum TokenFactoryMsg { - Token(TokenMsg), -} - /// Special messages to be supported by any chain that supports token_factory #[cw_serde] pub enum TokenMsg { @@ -25,6 +17,7 @@ pub enum TokenMsg { /// to calling SetMetadata directly on the returned denom. CreateDenom { subdenom: String, + // TODO investigate if this is interoperable with Osmosis metadata: Option, }, /// ChangeAdmin changes the admin for a factory denom. @@ -71,11 +64,7 @@ impl TokenMsg { } } - pub fn burn_contract_tokens( - denom: String, - amount: Uint128, - burn_from_address: String, - ) -> Self { + pub fn burn_contract_tokens(denom: String, amount: Uint128, burn_from_address: String) -> Self { TokenMsg::BurnTokens { denom, amount, @@ -98,13 +87,13 @@ impl TokenMsg { } } -impl From for CosmosMsg { - fn from(msg: TokenMsg) -> CosmosMsg { - CosmosMsg::Custom(TokenFactoryMsg::Token(msg)) +impl From for CosmosMsg { + fn from(msg: TokenMsg) -> CosmosMsg { + CosmosMsg::Custom(msg) } } -impl CustomMsg for TokenFactoryMsg {} +impl CustomMsg for TokenMsg {} /// This is in the data field in the reply from a TokenMsg::CreateDenom SubMsg /// Custom code to parse from protobuf with minimal wasm bytecode bloat diff --git a/packages/bindings/src/querier.rs b/packages/bindings/src/querier.rs index 502e866..fbbac37 100644 --- a/packages/bindings/src/querier.rs +++ b/packages/bindings/src/querier.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{QuerierWrapper, StdResult}; -use crate::query::{FullDenomResponse, TokenFactoryQuery, TokenQuery}; +use crate::query::{FullDenomResponse, TokenFactoryQuery}; /// This is a helper wrapper to easily use our custom queries pub struct TokenQuerier<'a> { @@ -17,7 +17,7 @@ impl<'a> TokenQuerier<'a> { creator_addr: String, subdenom: String, ) -> StdResult { - let full_denom_query = TokenQuery::FullDenom { + let full_denom_query = TokenFactoryQuery::FullDenom { creator_addr, subdenom, }; diff --git a/packages/bindings/src/query.rs b/packages/bindings/src/query.rs index db14534..d9d5524 100644 --- a/packages/bindings/src/query.rs +++ b/packages/bindings/src/query.rs @@ -1,16 +1,10 @@ use crate::types::{Metadata, Params}; use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{CustomQuery, QueryRequest}; - -#[cw_serde] -pub enum TokenFactoryQuery { - // Note: embded enums don't work with QueryResponses currently - Token(TokenQuery), -} +use cosmwasm_std::CustomQuery; #[cw_serde] #[derive(QueryResponses)] -pub enum TokenQuery { +pub enum TokenFactoryQuery { /// Given a subdenom created by the address `creator_addr` via `OsmosisMsg::CreateDenom`, /// returns the full denom as used by `BankMsg::Send`. /// You may call `FullDenom { creator_addr: env.contract.address, subdenom }` to find the denom issued @@ -41,12 +35,6 @@ pub enum TokenQuery { impl CustomQuery for TokenFactoryQuery {} -impl From for QueryRequest { - fn from(query: TokenQuery) -> Self { - QueryRequest::Custom(TokenFactoryQuery::Token(query)) - } -} - #[cw_serde] pub struct FullDenomResponse { pub denom: String, From 834bb36573fb21c74f8e78207308d9001df127a2 Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Sat, 19 Aug 2023 19:23:48 -0700 Subject: [PATCH 4/9] TokenMsg -> TokenFactoryMsg A bit more clear IMO --- contracts/reflect/src/contract.rs | 16 ++++++------- contracts/reflect/src/msg.rs | 14 +++++++---- contracts/tokenfactory/src/contract.rs | 32 ++++++++++++------------- packages/bindings-test/src/multitest.rs | 26 ++++++++++---------- packages/bindings/examples/schema.rs | 4 ++-- packages/bindings/src/lib.rs | 2 +- packages/bindings/src/msg.rs | 20 ++++++++-------- 7 files changed, 60 insertions(+), 54 deletions(-) diff --git a/contracts/reflect/src/contract.rs b/contracts/reflect/src/contract.rs index b5a5a9f..0270de4 100644 --- a/contracts/reflect/src/contract.rs +++ b/contracts/reflect/src/contract.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{ entry_point, to_binary, to_vec, ContractResult, CosmosMsg, Deps, DepsMut, Env, MessageInfo, QueryRequest, QueryResponse, Reply, Response, StdError, StdResult, SubMsg, SystemResult, }; -use token_bindings::{TokenFactoryQuery, TokenMsg}; +use token_bindings::{TokenFactoryMsg, TokenFactoryQuery}; use crate::errors::ReflectError; use crate::msg::{ChainResponse, ExecuteMsg, InstantiateMsg, OwnerResponse, QueryMsg}; @@ -14,7 +14,7 @@ pub fn instantiate( _env: Env, info: MessageInfo, _msg: InstantiateMsg, -) -> StdResult> { +) -> StdResult> { let state = State { owner: info.sender }; config(deps.storage).save(&state)?; Ok(Response::default()) @@ -26,7 +26,7 @@ pub fn execute( env: Env, info: MessageInfo, msg: ExecuteMsg, -) -> Result, ReflectError> { +) -> Result, ReflectError> { match msg { ExecuteMsg::ReflectMsg { msgs } => execute_reflect(deps, env, info, msgs), ExecuteMsg::ReflectSubMsg { msgs } => execute_reflect_subcall(deps, env, info, msgs), @@ -38,8 +38,8 @@ pub fn execute_reflect( deps: DepsMut, _env: Env, info: MessageInfo, - msgs: Vec>, -) -> Result, ReflectError> { + msgs: Vec>, +) -> Result, ReflectError> { let state = config(deps.storage).load()?; if info.sender != state.owner { @@ -62,8 +62,8 @@ pub fn execute_reflect_subcall( deps: DepsMut, _env: Env, info: MessageInfo, - msgs: Vec>, -) -> Result, ReflectError> { + msgs: Vec>, +) -> Result, ReflectError> { let state = config(deps.storage).load()?; if info.sender != state.owner { return Err(ReflectError::NotCurrentOwner { @@ -86,7 +86,7 @@ pub fn execute_change_owner( _env: Env, info: MessageInfo, new_owner: String, -) -> Result, ReflectError> { +) -> Result, ReflectError> { let api = deps.api; config(deps.storage).update(|mut state| { if info.sender != state.owner { diff --git a/contracts/reflect/src/msg.rs b/contracts/reflect/src/msg.rs index 53fdd89..65ee248 100644 --- a/contracts/reflect/src/msg.rs +++ b/contracts/reflect/src/msg.rs @@ -1,16 +1,22 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{Binary, CosmosMsg, QueryRequest, SubMsg}; -use token_bindings::{TokenFactoryQuery, TokenMsg}; +use token_bindings::{TokenFactoryMsg, TokenFactoryQuery}; #[cw_serde] pub struct InstantiateMsg {} #[cw_serde] pub enum ExecuteMsg { - ReflectMsg { msgs: Vec> }, - ReflectSubMsg { msgs: Vec> }, - ChangeOwner { owner: String }, + ReflectMsg { + msgs: Vec>, + }, + ReflectSubMsg { + msgs: Vec>, + }, + ChangeOwner { + owner: String, + }, } #[cw_serde] diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index e8c2fb3..e25f629 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -8,7 +8,7 @@ use cw2::set_contract_version; use crate::error::TokenFactoryError; use crate::msg::{ExecuteMsg, GetDenomResponse, InstantiateMsg, QueryMsg}; use crate::state::{State, STATE}; -use token_bindings::{TokenFactoryQuery, TokenMsg, TokenQuerier}; +use token_bindings::{TokenFactoryMsg, TokenFactoryQuery, TokenQuerier}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:tokenfactory-demo"; @@ -38,7 +38,7 @@ pub fn execute( _env: Env, _info: MessageInfo, msg: ExecuteMsg, -) -> Result, TokenFactoryError> { +) -> Result, TokenFactoryError> { match msg { ExecuteMsg::CreateDenom { subdenom } => create_denom(subdenom), ExecuteMsg::ChangeAdmin { @@ -64,12 +64,12 @@ pub fn execute( } } -pub fn create_denom(subdenom: String) -> Result, TokenFactoryError> { +pub fn create_denom(subdenom: String) -> Result, TokenFactoryError> { if subdenom.eq("") { return Err(TokenFactoryError::InvalidSubdenom { subdenom }); } - let create_denom_msg = TokenMsg::CreateDenom { + let create_denom_msg = TokenFactoryMsg::CreateDenom { subdenom, metadata: None, }; @@ -85,12 +85,12 @@ pub fn change_admin( deps: DepsMut, denom: String, new_admin_address: String, -) -> Result, TokenFactoryError> { +) -> Result, TokenFactoryError> { deps.api.addr_validate(&new_admin_address)?; validate_denom(deps, denom.clone())?; - let change_admin_msg = TokenMsg::ChangeAdmin { + let change_admin_msg = TokenFactoryMsg::ChangeAdmin { denom, new_admin_address, }; @@ -107,7 +107,7 @@ pub fn mint_tokens( denom: String, amount: Uint128, mint_to_address: String, -) -> Result, TokenFactoryError> { +) -> Result, TokenFactoryError> { deps.api.addr_validate(&mint_to_address)?; if amount.eq(&Uint128::new(0_u128)) { @@ -116,7 +116,7 @@ pub fn mint_tokens( validate_denom(deps, denom.clone())?; - let mint_tokens_msg = TokenMsg::mint_contract_tokens(denom, amount, mint_to_address); + let mint_tokens_msg = TokenFactoryMsg::mint_contract_tokens(denom, amount, mint_to_address); let res = Response::new() .add_attribute("method", "mint_tokens") @@ -130,14 +130,14 @@ pub fn burn_tokens( denom: String, amount: Uint128, burn_from_address: String, -) -> Result, TokenFactoryError> { +) -> Result, TokenFactoryError> { if amount.eq(&Uint128::new(0_u128)) { return Result::Err(TokenFactoryError::ZeroAmount {}); } validate_denom(deps, denom.clone())?; - let burn_token_msg = TokenMsg::burn_contract_tokens(denom, amount, burn_from_address); + let burn_token_msg = TokenFactoryMsg::burn_contract_tokens(denom, amount, burn_from_address); let res = Response::new() .add_attribute("method", "burn_tokens") @@ -152,14 +152,14 @@ pub fn force_transfer( amount: Uint128, from_address: String, to_address: String, -) -> Result, TokenFactoryError> { +) -> Result, TokenFactoryError> { if amount.eq(&Uint128::new(0_u128)) { return Result::Err(TokenFactoryError::ZeroAmount {}); } validate_denom(deps, denom.clone())?; - let force_msg = TokenMsg::force_transfer_tokens(denom, amount, from_address, to_address); + let force_msg = TokenFactoryMsg::force_transfer_tokens(denom, amount, from_address, to_address); let res = Response::new() .add_attribute("method", "force_transfer_tokens") @@ -333,7 +333,7 @@ mod tests { assert_eq!(1, res.messages.len()); - let expected_message = CosmosMsg::from(TokenMsg::CreateDenom { + let expected_message = CosmosMsg::from(TokenFactoryMsg::CreateDenom { subdenom: String::from(DENOM_NAME), metadata: None, }); @@ -385,7 +385,7 @@ mod tests { assert_eq!(1, res.messages.len()); - let expected_message = CosmosMsg::from(TokenMsg::ChangeAdmin { + let expected_message = CosmosMsg::from(TokenFactoryMsg::ChangeAdmin { denom: String::from(full_denom_name), new_admin_address: String::from(NEW_ADMIN_ADDR), }); @@ -483,7 +483,7 @@ mod tests { assert_eq!(1, res.messages.len()); - let expected_message = CosmosMsg::from(TokenMsg::MintTokens { + let expected_message = CosmosMsg::from(TokenFactoryMsg::MintTokens { denom: String::from(full_denom_name), amount: mint_amount, mint_to_address: String::from(NEW_ADMIN_ADDR), @@ -543,7 +543,7 @@ mod tests { let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); assert_eq!(1, res.messages.len()); - let expected_message = CosmosMsg::from(TokenMsg::BurnTokens { + let expected_message = CosmosMsg::from(TokenFactoryMsg::BurnTokens { denom: String::from(full_denom_name), amount: mint_amount, burn_from_address: String::from(""), diff --git a/packages/bindings-test/src/multitest.rs b/packages/bindings-test/src/multitest.rs index 892ec08..02ff6d6 100644 --- a/packages/bindings-test/src/multitest.rs +++ b/packages/bindings-test/src/multitest.rs @@ -18,7 +18,7 @@ use cw_storage_plus::Map; use token_bindings::{ AdminResponse, CreateDenomResponse, DenomsByCreatorResponse, FullDenomResponse, Metadata, - MetadataResponse, TokenFactoryQuery, TokenMsg, + MetadataResponse, TokenFactoryMsg, TokenFactoryQuery, }; use crate::error::ContractError; @@ -57,7 +57,7 @@ impl TokenFactoryModule { } impl Module for TokenFactoryModule { - type ExecT = TokenMsg; + type ExecT = TokenFactoryMsg; type QueryT = TokenFactoryQuery; type SudoT = Empty; @@ -69,14 +69,14 @@ impl Module for TokenFactoryModule { router: &dyn CosmosRouter, block: &BlockInfo, sender: Addr, - msg: TokenMsg, + msg: TokenFactoryMsg, ) -> AnyResult where ExecC: Debug + Clone + PartialEq + JsonSchema + DeserializeOwned + 'static, QueryC: CustomQuery + DeserializeOwned + 'static, { match msg { - TokenMsg::CreateDenom { subdenom, metadata } => { + TokenFactoryMsg::CreateDenom { subdenom, metadata } => { let new_token_denom = self.build_denom(&sender, &subdenom)?; // errors if the denom was already created @@ -104,7 +104,7 @@ impl Module for TokenFactoryModule { events: vec![], }) } - TokenMsg::MintTokens { + TokenFactoryMsg::MintTokens { denom, amount, mint_to_address, @@ -123,18 +123,18 @@ impl Module for TokenFactoryModule { router.sudo(api, storage, block, mint.into())?; Ok(AppResponse::default()) } - TokenMsg::BurnTokens { + TokenFactoryMsg::BurnTokens { denom: _, amount: _, burn_from_address: _, } => todo!(), - TokenMsg::ForceTransfer { + TokenFactoryMsg::ForceTransfer { denom: _, amount: _, from_address: _, to_address: _, } => todo!(), - TokenMsg::ChangeAdmin { + TokenFactoryMsg::ChangeAdmin { denom, new_admin_address, } => { @@ -150,7 +150,7 @@ impl Module for TokenFactoryModule { ADMIN.save(storage, &denom, &new_admin)?; Ok(AppResponse::default()) } - TokenMsg::SetMetadata { denom, metadata } => { + TokenFactoryMsg::SetMetadata { denom, metadata } => { // ensure we are admin of this denom (and it exists) let admin = ADMIN .may_load(storage, &denom)? @@ -233,7 +233,7 @@ pub type TokenFactoryAppWrapped = App< MockApi, MockStorage, TokenFactoryModule, - WasmKeeper, + WasmKeeper, >; pub struct TokenFactoryApp(TokenFactoryAppWrapped); @@ -267,7 +267,7 @@ impl Default for TokenFactoryApp { impl TokenFactoryApp { pub fn new() -> Self { Self( - BasicAppBuilder::::new_custom() + BasicAppBuilder::::new_custom() .with_custom(TokenFactoryModule {}) .build(|_router, _, _storage| { // router.custom.set_owner(storage, &owner).unwrap(); @@ -338,7 +338,7 @@ mod tests { // prepare to mint let amount = Uint128::new(1234567); - let msg = TokenMsg::MintTokens { + let msg = TokenFactoryMsg::MintTokens { denom: denom.to_string(), amount, mint_to_address: rcpt.to_string(), @@ -354,7 +354,7 @@ mod tests { ); // create the token now - let create = TokenMsg::CreateDenom { + let create = TokenFactoryMsg::CreateDenom { subdenom: subdenom.to_string(), metadata: Some(Metadata { description: Some("Awesome token, get it now!".to_string()), diff --git a/packages/bindings/examples/schema.rs b/packages/bindings/examples/schema.rs index 223d4be..6f51086 100644 --- a/packages/bindings/examples/schema.rs +++ b/packages/bindings/examples/schema.rs @@ -5,7 +5,7 @@ use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use token_bindings::{ AdminResponse, DenomsByCreatorResponse, FullDenomResponse, MetadataResponse, ParamsResponse, - TokenFactoryQuery, TokenMsg, + TokenFactoryMsg, TokenFactoryQuery, }; fn main() { @@ -14,7 +14,7 @@ fn main() { create_dir_all(&out_dir).unwrap(); remove_schemas(&out_dir).unwrap(); - export_schema(&schema_for!(TokenMsg), &out_dir); + export_schema(&schema_for!(TokenFactoryMsg), &out_dir); export_schema(&schema_for!(TokenFactoryQuery), &out_dir); export_schema(&schema_for!(AdminResponse), &out_dir); export_schema(&schema_for!(DenomsByCreatorResponse), &out_dir); diff --git a/packages/bindings/src/lib.rs b/packages/bindings/src/lib.rs index f479713..4ce759b 100644 --- a/packages/bindings/src/lib.rs +++ b/packages/bindings/src/lib.rs @@ -3,7 +3,7 @@ mod querier; mod query; mod types; -pub use msg::{CreateDenomResponse, TokenMsg}; +pub use msg::{CreateDenomResponse, TokenFactoryMsg}; pub use querier::TokenQuerier; pub use query::{ AdminResponse, DenomsByCreatorResponse, FullDenomResponse, MetadataResponse, ParamsResponse, diff --git a/packages/bindings/src/msg.rs b/packages/bindings/src/msg.rs index b565dd6..5f7efde 100644 --- a/packages/bindings/src/msg.rs +++ b/packages/bindings/src/msg.rs @@ -4,7 +4,7 @@ use cosmwasm_std::{Binary, CosmosMsg, CustomMsg, StdResult, Uint128}; /// Special messages to be supported by any chain that supports token_factory #[cw_serde] -pub enum TokenMsg { +pub enum TokenFactoryMsg { /// CreateDenom creates a new factory denom, of denomination: /// factory/{creating contract bech32 address}/{Subdenom} /// Subdenom can be of length at most 44 characters, in [0-9a-zA-Z./] @@ -35,7 +35,7 @@ pub enum TokenMsg { mint_to_address: String, }, /// Contracts can burn native tokens for an existing factory denom - /// that they are the admin of. + /// tshat they are the admin of. BurnTokens { denom: String, amount: Uint128, @@ -55,9 +55,9 @@ pub enum TokenMsg { }, } -impl TokenMsg { +impl TokenFactoryMsg { pub fn mint_contract_tokens(denom: String, amount: Uint128, mint_to_address: String) -> Self { - TokenMsg::MintTokens { + TokenFactoryMsg::MintTokens { denom, amount, mint_to_address, @@ -65,7 +65,7 @@ impl TokenMsg { } pub fn burn_contract_tokens(denom: String, amount: Uint128, burn_from_address: String) -> Self { - TokenMsg::BurnTokens { + TokenFactoryMsg::BurnTokens { denom, amount, burn_from_address, @@ -78,7 +78,7 @@ impl TokenMsg { from_address: String, to_address: String, ) -> Self { - TokenMsg::ForceTransfer { + TokenFactoryMsg::ForceTransfer { denom, amount, from_address, @@ -87,15 +87,15 @@ impl TokenMsg { } } -impl From for CosmosMsg { - fn from(msg: TokenMsg) -> CosmosMsg { +impl From for CosmosMsg { + fn from(msg: TokenFactoryMsg) -> CosmosMsg { CosmosMsg::Custom(msg) } } -impl CustomMsg for TokenMsg {} +impl CustomMsg for TokenFactoryMsg {} -/// This is in the data field in the reply from a TokenMsg::CreateDenom SubMsg +/// This is in the data field in the reply from a TokenFactoryMsg::CreateDenom SubMsg /// Custom code to parse from protobuf with minimal wasm bytecode bloat pub struct CreateDenomResponse { pub new_token_denom: String, From 68e6081d0cc66ea6e682645113f676caa35908b3 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Tue, 22 Aug 2023 11:21:40 -0500 Subject: [PATCH 5/9] Patch test, bump to 0.11.0 --- Cargo.lock | 2 +- contracts/tokenfactory/src/contract.rs | 4 ++-- packages/bindings/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0f8e4b..e09f37b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -791,7 +791,7 @@ dependencies = [ [[package]] name = "token-bindings" -version = "0.10.3" +version = "0.10.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index e25f629..d91ff1f 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -576,7 +576,7 @@ mod tests { burn_from_address: String::from(BURN_FROM_ADDR), amount: burn_amount, }; - let err = execute(deps.as_mut(), mock_env(), info, msg).is_err(); + let err = execute(deps.as_mut(), mock_env(), info, msg).is_ok(); assert!(err) } @@ -600,7 +600,7 @@ mod tests { to_address: TRANSFER_TO_ADDR.to_string(), }; - let err = execute(deps.as_mut(), mock_env(), info, msg).is_err(); + let err = execute(deps.as_mut(), mock_env(), info, msg).is_ok(); assert!(err) } diff --git a/packages/bindings/Cargo.toml b/packages/bindings/Cargo.toml index 32b6143..2d4eed1 100644 --- a/packages/bindings/Cargo.toml +++ b/packages/bindings/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "token-bindings" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey ", "Reece Williams "] edition = "2018" description = "Bindings for CustomMsg and CustomQuery for blockchains supporting Token Factory." From dee756344819f98801235c08554b90b7363badce Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Tue, 22 Aug 2023 13:53:44 -0700 Subject: [PATCH 6/9] Fix package versions accross workspace --- Cargo.lock | 72 +++++++++++++++---------------- contracts/reflect/Cargo.toml | 2 +- contracts/tokenfactory/Cargo.toml | 2 +- packages/bindings-test/Cargo.toml | 2 +- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e09f37b..893b5ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,9 +15,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "base16ct" @@ -81,15 +81,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "const-oid" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "cosmwasm-crypto" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e272708a9745dad8b591ef8a718571512130f2b39b33e3d7a27c558e3069394" +checksum = "871ce1d5a4b00ed1741f84b377eec19fadd81a904a227bc1e268d76539d26f5e" dependencies = [ "digest 0.10.7", "ed25519-zebra", @@ -100,18 +100,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "296db6a3caca5283425ae0cf347f4e46999ba3f6620dbea8939a0e00347831ce" +checksum = "7ce8b44b45a7c8c6d6f770cd0a51458c2445c7c15b6115e1d215fa35c77b305c" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63c337e097a089e5b52b5d914a7ff6613332777f38ea6d9d36e1887cd0baa72e" +checksum = "99222fa0401ee36389550d8a065700380877a2299c3043d24c38d705708c9d9d" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -122,9 +122,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "766cc9e7c1762d8fc9c0265808910fcad755200cd0e624195a491dd885a61169" +checksum = "4b74eaf9e585ef8e5e3486b240b13ee593cb0f658b5879696937d8c22243d4fb" dependencies = [ "proc-macro2", "quote", @@ -133,9 +133,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5e05a95fd2a420cca50f4e94eb7e70648dac64db45e90403997ebefeb143bd" +checksum = "da78abcf059181e8cb01e95e5003cf64fe95dde6c72b3fe37e5cabc75cdba32a" dependencies = [ "base64", "bnum", @@ -153,9 +153,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "800aaddd70ba915e19bf3d2d992aa3689d8767857727fdd3b414df4fd52d2aa1" +checksum = "b52be0d56b78f502f3acb75e40908a0d04d9f265b6beb0f86b36ec2ece048748" dependencies = [ "cosmwasm-std", "serde", @@ -227,7 +227,7 @@ dependencies = [ [[package]] name = "cw-multi-test" version = "0.16.5" -source = "git+https://github.com/JakeHartnell/cw-multi-test.git?branch=bank-supply-support#e601da7975cbbb731402ae967590d3655bb9f390" +source = "git+https://github.com/JakeHartnell/cw-multi-test.git?branch=bank-supply-support#8c618c8dcc014dacf2cc10627805b36bbc0bfc6e" dependencies = [ "anyhow", "cosmwasm-std", @@ -336,9 +336,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" +checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" [[package]] name = "ecdsa" @@ -563,9 +563,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -648,9 +648,9 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.180" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed" +checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" dependencies = [ "serde_derive", ] @@ -666,13 +666,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.180" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e744d7782b686ab3b73267ef05697159cc0e5abbed3f47f9933165e5219036" +checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -688,9 +688,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa", "ryu", @@ -760,9 +760,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -771,27 +771,27 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] name = "token-bindings" -version = "0.10.4" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/reflect/Cargo.toml b/contracts/reflect/Cargo.toml index 23ace63..52a5201 100644 --- a/contracts/reflect/Cargo.toml +++ b/contracts/reflect/Cargo.toml @@ -20,7 +20,7 @@ backtraces = ["cosmwasm-std/backtraces"] cosmwasm-schema = "1.1" cosmwasm-std = { version = "1.1", features = ["staking", "stargate"] } cosmwasm-storage = "1.1" -token-bindings = { version = "0.10.3", path = "../../packages/bindings" } +token-bindings = { version = "0.11.0", path = "../../packages/bindings" } schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } thiserror = "1.0" diff --git a/contracts/tokenfactory/Cargo.toml b/contracts/tokenfactory/Cargo.toml index c530c8e..fb2e14a 100644 --- a/contracts/tokenfactory/Cargo.toml +++ b/contracts/tokenfactory/Cargo.toml @@ -44,7 +44,7 @@ cosmwasm-schema = "1.1" cosmwasm-std = "1.2.3" cosmwasm-storage = "1.1" cw-storage-plus = "1.0.1" -token-bindings = { version = "0.10.3", path = "../../packages/bindings" } +token-bindings = { version = "0.11.0", path = "../../packages/bindings" } cw2 = "1.0.1" schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } diff --git a/packages/bindings-test/Cargo.toml b/packages/bindings-test/Cargo.toml index 33dfc4c..68aece8 100644 --- a/packages/bindings-test/Cargo.toml +++ b/packages/bindings-test/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0" [dependencies] itertools = "0.11" -token-bindings = { version = "0.10.3", path = "../bindings" } +token-bindings = { version = "0.11.0", path = "../bindings" } cosmwasm-std = "1.1" schemars = "0.8" serde = { version = "1.0", default-features = false, features = ["derive"] } From db231f5e51ce51ce8de1bdeb9c1772872ba5a2a0 Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Tue, 22 Aug 2023 13:55:43 -0700 Subject: [PATCH 7/9] Add basic CI --- .github/workflows/ci.yml | 78 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a049e4a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,78 @@ +# Based on https://github.com/actions-rs/example/blob/master/.github/workflows/quickstart.yml + +on: [push, pull_request] + +name: Basic + +jobs: + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install latest stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: wasm32-unknown-unknown + override: true + + - name: Run tests + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: all-test + args: --locked + env: + RUST_BACKTRACE: 1 + + # - name: Compile WASM contract + # uses: actions-rs/cargo@v1 + # with: + # toolchain: stable + # command: wasm + # args: --locked + # env: + # RUSTFLAGS: "-C link-arg=-s" + + lints: + name: Lints + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, clippy + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: fmt + args: --all -- --check + + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: clippy + args: --all-targets -- -D warnings + + # - name: Generate Schema + # run: ./scripts/schema.sh + + # - name: Show Schema changes + # run: git status --porcelain + + # - name: Schema Changes + # # fails if any changes not committed + # run: test -z "$(git status --porcelain)" From 35d64e34317668cbc07f5e7f00bf4f076a90dda6 Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Tue, 22 Aug 2023 14:12:13 -0700 Subject: [PATCH 8/9] Set up proper workspace --- Cargo.lock | 31 +++++------------------- Cargo.toml | 40 ++++++++++++++++++++++++------- contracts/reflect/Cargo.toml | 22 +++++++++-------- contracts/tokenfactory/Cargo.toml | 29 ++++++++++++---------- packages/bindings-test/Cargo.toml | 31 ++++++++++++------------ packages/bindings/Cargo.toml | 21 ++++++++-------- 6 files changed, 92 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 893b5ce..34cb856 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,25 +205,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "cw-multi-test" -version = "0.16.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "127c7bb95853b8e828bdab97065c81cb5ddc20f7339180b61b2300565aaa99d1" -dependencies = [ - "anyhow", - "cosmwasm-std", - "cw-storage-plus 1.1.0", - "cw-utils", - "derivative", - "itertools 0.10.5", - "k256", - "prost", - "schemars", - "serde", - "thiserror", -] - [[package]] name = "cw-multi-test" version = "0.16.5" @@ -801,11 +782,11 @@ dependencies = [ [[package]] name = "token-bindings-test" -version = "0.9.0" +version = "0.11.0" dependencies = [ "anyhow", "cosmwasm-std", - "cw-multi-test 0.16.5 (git+https://github.com/JakeHartnell/cw-multi-test.git?branch=bank-supply-support)", + "cw-multi-test", "cw-storage-plus 0.16.0", "itertools 0.11.0", "schemars", @@ -816,7 +797,7 @@ dependencies = [ [[package]] name = "token-reflect" -version = "0.9.0" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -829,13 +810,13 @@ dependencies = [ [[package]] name = "tokenfactory" -version = "0.9.0" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-multi-test 0.16.5 (registry+https://github.com/rust-lang/crates.io-index)", - "cw-storage-plus 1.1.0", + "cw-multi-test", + "cw-storage-plus 0.16.0", "cw2", "schemars", "serde", diff --git a/Cargo.toml b/Cargo.toml index 00fc9e4..161cbe0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,18 +2,40 @@ members = ["packages/*", "contracts/*"] resolver = "2" -[profile.release.package.token-reflect] -codegen-units = 1 -incremental = false +[workspace.package] +edition = "2021" +license = "Apache-2.0" +homepage = "https://junonetwork.io" +repository = "https://github.com/CosmosContracts/token-bindings" +version = "0.11.0" -[profile.release.package.tokenfactory] -codegen-units = 1 -incremental = false [profile.release] -rpath = false -lto = true -overflow-checks = true +codegen-units = 1 opt-level = 3 debug = false +rpath = false +lto = true debug-assertions = false +panic = 'abort' +incremental = false +# Please do not disable these. Doing so will cause overflow checks in +# all workspace members to stop working. Overflows should be errors. +overflow-checks = true + +[workspace.dependencies] +cosmwasm-schema = "1.1" +cosmwasm-std = "1.1" +cosmwasm-storage = "1.1" +schemars = "0.8" +serde = "1.0" +itertools = "0.11" +cw-storage-plus = "0.16" +anyhow = "1" +thiserror = "1.0" +cw2 = "1.0.1" + +# TODO use upstream when PR merged: 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" } +token-bindings = { path = "./packages/bindings", version = "0.11.0" } +token-bindings-test = { path = "./packages/bindings-test", version = "0.11.0" } diff --git a/contracts/reflect/Cargo.toml b/contracts/reflect/Cargo.toml index 52a5201..57572c6 100644 --- a/contracts/reflect/Cargo.toml +++ b/contracts/reflect/Cargo.toml @@ -1,10 +1,12 @@ [package] name = "token-reflect" -version = "0.9.0" +version = { workspace = true } authors = ["Ethan Frey "] -edition = "2018" description = "Reflect messages to use for test cases - based on cw-mask" -license = "Apache-2.0" + +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -17,12 +19,12 @@ crate-type = ["cdylib", "rlib"] backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cosmwasm-schema = "1.1" -cosmwasm-std = { version = "1.1", features = ["staking", "stargate"] } -cosmwasm-storage = "1.1" -token-bindings = { version = "0.11.0", path = "../../packages/bindings" } -schemars = "0.8" -serde = { version = "1.0", default-features = false, features = ["derive"] } -thiserror = "1.0" +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true, features = ["staking", "stargate"] } +cosmwasm-storage = { workspace = true } +token-bindings = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true, default-features = false, features = ["derive"] } +thiserror = { workspace = true } [dev-dependencies] diff --git a/contracts/tokenfactory/Cargo.toml b/contracts/tokenfactory/Cargo.toml index fb2e14a..e861142 100644 --- a/contracts/tokenfactory/Cargo.toml +++ b/contracts/tokenfactory/Cargo.toml @@ -1,8 +1,11 @@ [package] name = "tokenfactory" -version = "0.9.0" +version = { workspace = true } authors = ["Roman "] -edition = "2018" + +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } 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. @@ -40,16 +43,16 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -cosmwasm-schema = "1.1" -cosmwasm-std = "1.2.3" -cosmwasm-storage = "1.1" -cw-storage-plus = "1.0.1" -token-bindings = { version = "0.11.0", path = "../../packages/bindings" } -cw2 = "1.0.1" -schemars = "0.8" -serde = { version = "1.0", default-features = false, features = ["derive"] } -thiserror = { version = "1.0" } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cosmwasm-storage = { workspace = true } +cw2 = { workspace = true } +cw-storage-plus = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true, default-features = false, features = ["derive"] } +thiserror = { workspace = true } +token-bindings = { workspace = true } [dev-dependencies] -cw-multi-test = "0.16.2" -token-bindings-test = { path = "../../packages/bindings-test" } +cw-multi-test = { workspace = true } +token-bindings-test = { workspace = true } diff --git a/packages/bindings-test/Cargo.toml b/packages/bindings-test/Cargo.toml index 68aece8..10a6776 100644 --- a/packages/bindings-test/Cargo.toml +++ b/packages/bindings-test/Cargo.toml @@ -1,20 +1,21 @@ [package] name = "token-bindings-test" -version = "0.9.0" -authors = ["Ethan Frey ", "Jake Hartnell "] -edition = "2021" +version = { workspace = true } +authors = ["Ethan Frey ", "Jake Hartnell "] description = "Multitest (and other test helpers) support for Token factory contracts" -repository = "https://github.com/CosmosContracts/token-bindings" -license = "Apache-2.0" + +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +repository = { workspace = true } [dependencies] -itertools = "0.11" -token-bindings = { version = "0.11.0", path = "../bindings" } -cosmwasm-std = "1.1" -schemars = "0.8" -serde = { version = "1.0", default-features = false, features = ["derive"] } -# TODO use upstream when PR merged: 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 = "0.16" -anyhow = "1" -thiserror = "1.0" +anyhow = { workspace = true } +cosmwasm-std = { workspace = true } +cw-multi-test = { workspace = true } +cw-storage-plus = { workspace = true } +itertools = { workspace = true } +token-bindings = { workspace = true, path = "../bindings" } +schemars = { workspace = true } +serde = { workspace = true, default-features = false, features = ["derive"] } +thiserror = { workspace = true } diff --git a/packages/bindings/Cargo.toml b/packages/bindings/Cargo.toml index 2d4eed1..a159721 100644 --- a/packages/bindings/Cargo.toml +++ b/packages/bindings/Cargo.toml @@ -1,19 +1,20 @@ [package] name = "token-bindings" -version = "0.11.0" -authors = ["Ethan Frey ", "Reece Williams "] -edition = "2018" +version = { workspace = true } +authors = ["Ethan Frey ", "Reece Williams ", "Jake Hartnell "] description = "Bindings for CustomMsg and CustomQuery for blockchains supporting Token Factory." -repository = "https://github.com/CosmosContracts/token-bindings" -homepage = "https://junonetwork.io" -license = "Apache-2.0" keywords = ["juno", "blockchain", "token-factory", "osmosis"] readme = "../../README.md" +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +repository = { workspace = true } + [dependencies] -cosmwasm-schema = "1.1" -cosmwasm-std = "1.1" -schemars = "0.8" -serde = { version = "1.0", default-features = false, features = ["derive"] } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true, default-features = false, features = ["derive"] } [dev-dependencies] From ea4fb3ef44775949bd05f00eda2d88758d6434b3 Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Tue, 22 Aug 2023 14:13:37 -0700 Subject: [PATCH 9/9] Fix CI test command --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a049e4a..23b1455 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: uses: actions-rs/cargo@v1 with: toolchain: stable - command: all-test + command: test args: --locked env: RUST_BACKTRACE: 1