Skip to content

Commit

Permalink
Merge pull request #2 from CosmWasm/extend-token-factory-bindings
Browse files Browse the repository at this point in the history
Extend token factory bindings
  • Loading branch information
ethanfrey authored Oct 21, 2022
2 parents 8ca5669 + 6d24bc5 commit 0a13213
Show file tree
Hide file tree
Showing 15 changed files with 402 additions and 53 deletions.
38 changes: 33 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ workflows:
version: 2
test:
jobs:
- contract_osmo_reflect
- contract_token_reflect
- contract_tokenfactory
- package_bindings
- package_bindings_test
build:
Expand All @@ -26,7 +27,7 @@ workflows:
ignore: /.*/

jobs:
contract_osmo_reflect:
contract_token_reflect:
docker:
- image: rust:1.64.0
working_directory: ~/project/contracts/reflect
Expand All @@ -38,7 +39,7 @@ jobs:
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-osmo-reflect-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- cargocache-token-reflect-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Unit Tests
environment:
Expand All @@ -51,7 +52,34 @@ jobs:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-osmo-reflect-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}
key: cargocache-token-reflect-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}

contract_tokenfactory:
docker:
- image: rust:1.64.0
working_directory: ~/project/contracts/tokenfactory
steps:
- checkout:
path: ~/project
- run:
name: Version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-tokenfactory-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Unit Tests
environment:
RUST_BACKTRACE: 1
command: cargo test --locked
- run:
name: Build and run schema generator
command: cargo schema --locked
- save_cache:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-tokenfactory-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}

package_bindings:
docker:
Expand Down Expand Up @@ -173,7 +201,7 @@ jobs:
key: cargocache-wasm-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Check wasm contracts
command: cosmwasm-check --available-capabilities osmosis,iterator,staking,stargate,cosmwasm_1_1 ./target/wasm32-unknown-unknown/release/*.wasm
command: cosmwasm-check --available-capabilities token_factory,iterator,staking,stargate,cosmwasm_1_1 ./target/wasm32-unknown-unknown/release/*.wasm

# This job roughly follows the instructions from https://circleci.com/blog/publishing-to-github-releases-via-circleci/
build_and_upload_contracts:
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/reflect/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "token-reflect"
version = "0.7.0"
version = "0.8.0"
authors = ["Ethan Frey <[email protected]>"]
edition = "2018"
description = "Reflect messages to use for test cases - based on cw-mask"
Expand All @@ -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.7.0", path = "../../packages/bindings" }
token-bindings = { version = "0.8.0", path = "../../packages/bindings" }
schemars = "0.8"
serde = { version = "1.0", default-features = false, features = ["derive"] }
thiserror = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions contracts/tokenfactory/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tokenfactory"
version = "0.7.0"
version = "0.8.0"
authors = ["Roman <[email protected]>"]
edition = "2018"

Expand Down Expand Up @@ -44,12 +44,12 @@ cosmwasm-schema = "1.1"
cosmwasm-std = "1.1"
cosmwasm-storage = "1.1"
cw-storage-plus = "0.15"
token-bindings = { version = "0.7.0", path = "../../packages/bindings" }
token-bindings = { version = "0.8.0", path = "../../packages/bindings" }
cw2 = "0.15"
schemars = "0.8"
serde = { version = "1.0", default-features = false, features = ["derive"] }
thiserror = "1.0"

[dev-dependencies]
cw-multi-test = "0.15"
token-bindings-test = { version = "0.7.0", path = "../../packages/bindings-test" }
token-bindings-test = { version = "0.8.0", path = "../../packages/bindings-test" }
7 changes: 6 additions & 1 deletion contracts/tokenfactory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ pub fn create_denom(subdenom: String) -> Result<Response<TokenFactoryMsg>, Token
return Err(TokenFactoryError::InvalidSubdenom { subdenom });
}

let create_denom_msg = TokenMsg::CreateDenom { subdenom };
let create_denom_msg = TokenMsg::CreateDenom {
subdenom,
metadata: None,
};

let res = Response::new()
.add_attribute("method", "create_denom")
Expand Down Expand Up @@ -259,6 +262,7 @@ mod tests {
}
SystemResult::Ok(ContractResult::Ok(binary_request))
}
_ => todo!(),
});
mock_dependencies_with_custom_quierier(custom_querier)
}
Expand Down Expand Up @@ -309,6 +313,7 @@ mod tests {

let expected_message = CosmosMsg::from(TokenMsg::CreateDenom {
subdenom: String::from(DENOM_NAME),
metadata: None,
});
let actual_message = res.messages.get(0).unwrap();
assert_eq!(expected_message, actual_message.msg);
Expand Down
4 changes: 2 additions & 2 deletions packages/bindings-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "token-bindings-test"
version = "0.7.0"
version = "0.8.0"
authors = ["Ethan Frey <[email protected]>"]
edition = "2018"
description = "Multitest (and other test helpers) support for Osmosis-specific contracts"
Expand All @@ -10,7 +10,7 @@ license = "Apache-2.0"

[dependencies]
itertools = "0.10"
token-bindings = { version = "0.7.0", path = "../bindings" }
token-bindings = { version = "0.8.0", path = "../bindings" }
cosmwasm-std = "1.1"
schemars = "0.8"
serde = { version = "1.0", default-features = false, features = ["derive"] }
Expand Down
9 changes: 9 additions & 0 deletions packages/bindings-test/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@ pub enum ContractError {

#[error("Invalid full denom '{full_denom}'")]
InvalidFullDenom { full_denom: String },

#[error("Not admin of token, cannot perfrom action")]
NotTokenAdmin,

#[error("Token denom already exists, cannot create again")]
TokenExists,

#[error("Token denom was never created")]
TokenDoesntExist,
}
Loading

0 comments on commit 0a13213

Please sign in to comment.