Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port cw1155 from cw-plus #122

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
80 changes: 78 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ workflows:
- contract_cw721_metadata_onchain
- contract_cw721_fixed_price
- package_cw721
- contract_cw1155_base
- package_cw1155
- lint
- wasm-build
deploy:
Expand Down Expand Up @@ -127,6 +129,43 @@ jobs:
- target
key: cargocache-cw721-fixed-price-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }}

contract_cw1155_base:
docker:
- image: rust:1.65.0
working_directory: ~/project/contracts/cw1155-base
steps:
- checkout:
path: ~/project
- run:
name: Version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-cw1155-base-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Unit Tests
environment:
RUST_BACKTRACE: 1
command: cargo unit-test --locked
- run:
name: Build and run schema generator
command: cargo schema --locked
- run:
name: Ensure checked-in schemas are up-to-date
command: |
CHANGES_IN_REPO=$(git status --porcelain | grep -v '/schema/raw/' || true)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 1
fi
- save_cache:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-cw1155-base-rust:1.65.0-{{ checksum "~/project/Cargo.lock" }}


package_cw721:
docker:
- image: rust:1.65.0
Expand All @@ -139,7 +178,44 @@ jobs:
command: rustc --version; cargo --version; rustup --version; rustup target list --installed
- restore_cache:
keys:
- cargocache-v2-cw721:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- cargocache-v2-cw721:1.65.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Build library for native target
command: cargo build --locked
- run:
name: Run unit tests
command: cargo test --locked
- run:
name: Build and run schema generator
command: cargo schema --locked
- run:
name: Ensure schemas are up-to-date
command: |
CHANGES_IN_REPO=$(git status --porcelain | grep -v '/schema/raw/' || true)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 1
fi
- save_cache:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-v2-cw721:1.65.0-{{ checksum "~/project/Cargo.lock" }}

package_cw1155:
docker:
- image: rust:1.65.0
working_directory: ~/project/packages/cw1155
steps:
- checkout:
path: ~/project
- run:
name: Version information
command: rustc --version; cargo --version; rustup --version; rustup target list --installed
- restore_cache:
keys:
- cargocache-v2-cw1155:1.65.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Build library for native target
command: cargo build --locked
Expand All @@ -162,7 +238,7 @@ jobs:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-v2-cw721:1.64.0-{{ checksum "~/project/Cargo.lock" }}
key: cargocache-v2-cw721:1.65.0-{{ checksum "~/project/Cargo.lock" }}

lint:
docker:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ target/
hash.txt
contracts.txt
artifacts/
**/schema/raw/*

# code coverage
tarpaulin-report.*
tarpaulin-report.*
26 changes: 26 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cosmwasm-std = "1.2.1"
cw2 = { git = "https://github.com/mars-protocol/cw-plus", rev = "1a3a944" }
cw20 = "1.0.1"
cw721 = { version = "0.17.0", path = "./packages/cw721" }
cw1155 = { version = "0.17.0", path = "./packages/cw1155" }
cw721-base = { version = "0.17.0", path = "./contracts/cw721-base" }
cw721-base-016 = { version = "0.16.0", package = "cw721-base" }
cw-multi-test = "0.16.2"
Expand Down
5 changes: 5 additions & 0 deletions contracts/cw1155-base/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --example schema"
29 changes: 29 additions & 0 deletions contracts/cw1155-base/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "cw1155-base"
description = "Basic implementation of cw1155 multiple tokens contract"
authors = ["Huang Yi <huang@crypto.com>"]
version = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
documentation = { workspace = true }

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

[features]
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all init/handle/query exports
library = []

[dependencies]
cw-utils = { workspace = true }
cw2 = { workspace = true }
cw1155 = { workspace = true }
cw-storage-plus = { workspace = true }
cosmwasm-std = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
cosmwasm-schema = { workspace = true }
12 changes: 12 additions & 0 deletions contracts/cw1155-base/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use cosmwasm_schema::write_api;

use cw1155::{Cw1155ExecuteMsg, Cw1155QueryMsg};
use cw1155_base::msg::InstantiateMsg;

fn main() {
write_api! {
instantiate: InstantiateMsg,
execute: Cw1155ExecuteMsg,
query: Cw1155QueryMsg,
}
}