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

Cast deps to empty #214

Merged
merged 4 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.66.0
toolchain: 1.70.0
target: wasm32-unknown-unknown
profile: minimal
override: true
Expand Down Expand Up @@ -87,6 +87,9 @@ jobs:
- name: Build entry-points-overriding
working-directory: examples/contracts/entry-points-overriding
run: cargo build --release --target wasm32-unknown-unknown --locked --lib
- name: Build custom
working-directory: examples/contracts/custom
run: cargo build --release --target wasm32-unknown-unknown --locked --lib
- name: Install cosmwasm-check
run: cargo install cosmwasm-check --force
- name: Check contracts
Expand All @@ -103,6 +106,9 @@ jobs:
- name: Entry-points-overriding schema
working-directory: examples/contracts/entry-points-overriding
run: cargo schema
- name: Custom schema
working-directory: examples/contracts/custom
run: cargo schema
- name: Cw1-whitelist ts-codegen
working-directory: examples/contracts/cw1-whitelist/
run: cosmwasm-ts-codegen generate --plugin client --schema ./schema --out ./ts --name cw1-whitelist --no-bundle
Expand All @@ -115,6 +121,9 @@ jobs:
- name: Entry-points-overriding ts-codegen
working-directory: examples/contracts/entry-points-overriding
run: cosmwasm-ts-codegen generate --plugin client --schema ./schema --out ./ts --name entry-points-overriding --no-bundle
- name: Custom ts-codegen
working-directory: examples/contracts/custom/
run: cosmwasm-ts-codegen generate --plugin client --schema ./schema --out ./ts --name custom --no-bundle
- name: Archive schema artifats
uses: actions/upload-artifact@v3
with:
Expand All @@ -124,6 +133,7 @@ jobs:
examples/contracts/cw1-whitelist/schema/cw1-whitelist.json
examples/contracts/cw20-base/schema/cw20-base.json
examples/contracts/entry-points-overriding/schema/entry-points-overriding.json
examples/contracts/custom/schema/custom.json

coverage:
name: Code coverage
Expand All @@ -146,7 +156,7 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Generate code coverage
run: |
cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml --engine llvm
cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out xml --engine llvm
- name: Upload to codecov.io
uses: codecov/codecov-action@v2
with:
Expand Down
44 changes: 13 additions & 31 deletions Cargo.lock

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

57 changes: 26 additions & 31 deletions examples/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 examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"contracts/cw1-subkeys",
"contracts/cw20-base",
"contracts/entry-points-overriding",
"contracts/custom",
]
resolver = "2"

Expand Down
6 changes: 6 additions & 0 deletions examples/contracts/custom/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown --lib"
wasm-debug = "build --target wasm32-unknown-unknown --lib"
unit-test = "test --lib"
integration-test = "test --test integration"
schema = "run --bin schema"
28 changes: 28 additions & 0 deletions examples/contracts/custom/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "custom"
version = { workspace = true }
authors = ["Jan Woźniak <[email protected]>"]
edition = { workspace = true }
description = "Example of custom message usage."
license = "Apache-2.0"
repository = "https://github.com/CosmWasm/sylvia"
homepage = "https://cosmwasm.com"

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

[features]
library = []
mt = ["library"]

[dependencies]
cosmwasm-schema = "1.2"
cosmwasm-std = { version = "1.3", features = ["staking"] }
cw-storage-plus = "1.0"
serde = { version = "1.0", default-features = false, features = ["derive"] }
sylvia = { path = "../../../sylvia" }

[dev-dependencies]
anyhow = "1.0"
cw-multi-test = "0.16"
sylvia = { path = "../../../sylvia", features = ["mt"] }
12 changes: 12 additions & 0 deletions examples/contracts/custom/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use cosmwasm_schema::write_api;

use custom::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};

#[cfg(not(tarpaulin_include))]
fn main() {
write_api! {
instantiate: InstantiateMsg,
execute: ContractExecMsg,
query: ContractQueryMsg,
}
}
41 changes: 41 additions & 0 deletions examples/contracts/custom/src/contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use cosmwasm_std::{CosmosMsg, QueryRequest, Response, StdResult};
use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx};
use sylvia::{contract, entry_points, schemars};

use crate::messages::{CountResponse, CounterMsg, CounterQuery};

pub struct CustomContract;

#[cfg_attr(not(feature = "mt"), entry_points)]
#[contract]
#[sv::custom(query=CounterQuery, msg=CounterMsg)]
impl CustomContract {
pub const fn new() -> Self {
Self
}

#[msg(instantiate)]
pub fn instantiate(
&self,
_ctx: InstantiateCtx<CounterQuery>,
) -> StdResult<Response<CounterMsg>> {
Ok(Response::default())
}

#[msg(exec)]
pub fn send_custom(&self, _ctx: ExecCtx<CounterQuery>) -> StdResult<Response<CounterMsg>> {
let msg = CosmosMsg::Custom(CounterMsg::Increment {});
let resp = Response::default().add_message(msg);
Ok(resp)
}

#[msg(query)]
pub fn query_custom(&self, ctx: QueryCtx<CounterQuery>) -> StdResult<CountResponse> {
let resp = ctx
.deps
.querier
.query::<CountResponse>(&QueryRequest::Custom(CounterQuery::Count {}))?;

Ok(resp)
}
}
4 changes: 4 additions & 0 deletions examples/contracts/custom/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod contract;
pub mod messages;
#[cfg(any(test, feature = "mt"))]
pub mod multitest;
Loading
Loading