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

feat: Generic support #253

Merged
merged 15 commits into from
Nov 13, 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
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
run: cargo clippy --all-targets -- -D warnings
- name: Fmt check project
run: cargo fmt --check

- name: Test examples
working-directory: examples
run: cargo test --locked
Expand All @@ -75,6 +76,7 @@ jobs:
- name: Fmt check examples
working-directory: examples
run: cargo fmt --check

- name: Build cw20-base example
working-directory: examples/contracts/cw20-base
run: cargo build --release --target wasm32-unknown-unknown --locked --lib
Expand All @@ -90,10 +92,18 @@ jobs:
- name: Build custom
working-directory: examples/contracts/custom
run: cargo build --release --target wasm32-unknown-unknown --locked --lib
- name: Build generic_contract
working-directory: examples/contracts/generic_contract
run: cargo build --release --target wasm32-unknown-unknown --locked --lib
- name: Build generic_iface_on_contract
working-directory: examples/contracts/generic_iface_on_contract
run: cargo build --release --target wasm32-unknown-unknown --locked --lib

- name: Install cosmwasm-check
run: cargo install cosmwasm-check --force
- name: Check contracts
run: find examples/target/wasm32-unknown-unknown/release/ -type f -name "*.wasm" -exec cosmwasm-check {} \;

- name: Cw1-whitelist schema
working-directory: examples/contracts/cw1-whitelist/
run: cargo schema
Expand All @@ -109,6 +119,13 @@ jobs:
- name: Custom schema
working-directory: examples/contracts/custom
run: cargo schema
- name: Generic_contract schema
working-directory: examples/contracts/generic_contract
run: cargo schema
- name: generic_iface_on_contract schema
working-directory: examples/contracts/generic_iface_on_contract
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 @@ -124,6 +141,13 @@ jobs:
- 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: Generic_contract ts-codegen
working-directory: examples/contracts/generic_contract/
run: cosmwasm-ts-codegen generate --plugin client --schema ./schema --out ./ts --name custom --no-bundle
- name: Generic_iface_on_contract ts-codegen
working-directory: examples/contracts/generic_iface_on_contract
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 @@ -134,6 +158,8 @@ jobs:
examples/contracts/cw20-base/schema/cw20-base.json
examples/contracts/entry-points-overriding/schema/entry-points-overriding.json
examples/contracts/custom/schema/custom.json
examples/contracts/generic_contract/schema/generic_contract.json
examples/contracts/generic_iface_on_contract/schema/generic_iface_on_contract.json

coverage:
name: Code coverage
Expand Down
72 changes: 72 additions & 0 deletions examples/Cargo.lock

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

29 changes: 17 additions & 12 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
[workspace]
members = [
# Contract intefaces
"interfaces/cw1",
"interfaces/cw4",
"interfaces/cw20-allowances",
"interfaces/cw20-minting",
"interfaces/cw20-marketing",
# Contract intefaces
"interfaces/cw1",
"interfaces/whitelist",
"interfaces/cw4",
"interfaces/cw20-allowances",
"interfaces/cw20-minting",
"interfaces/cw20-marketing",
"interfaces/custom-and-generic",
"interfaces/generic",

# Contracts
"contracts/cw1-whitelist",
"contracts/cw1-subkeys",
"contracts/cw20-base",
"contracts/entry-points-overriding",
"contracts/custom",
# Contracts
"contracts/cw1-whitelist",
"contracts/cw1-subkeys",
"contracts/cw20-base",
"contracts/entry-points-overriding",
"contracts/custom",
"contracts/generic_contract",
"contracts/generic_iface_on_contract",
]
resolver = "2"

Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/custom/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::write_api;

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

#[cfg(not(tarpaulin_include))]
fn main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/custom/src/multitest/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sylvia::multitest::App;

use crate::contract::multitest_utils::CodeId;
use crate::contract::sv::multitest_utils::CodeId;

use super::custom_module::CustomModule;

Expand Down
1 change: 1 addition & 0 deletions examples/contracts/cw1-subkeys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cw-multi-test = { version = "0.16.2", optional = true }
cw-storage-plus = "1.0"
cw-utils = "1.0"
cw1 = { path = "../../interfaces/cw1" }
whitelist = { path = "../../interfaces/whitelist" }
cw1-whitelist = { path = "../cw1-whitelist", features = ["library"] }
cw2 = "1.0"
getrandom = { version = "0.2.8", features = ["js"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/cw1-subkeys/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::write_api;

use cw1_subkeys::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
use cw1_subkeys::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};

#[cfg(not(tarpaulin_include))]
fn main() {
Expand Down
1 change: 0 additions & 1 deletion examples/contracts/cw1-subkeys/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use cosmwasm_std::{
StakingMsg, StdResult,
};
use cw1_whitelist::contract::Cw1WhitelistContract;
use cw1_whitelist::whitelist;
use cw2::set_contract_version;
use cw_storage_plus::{Bound, Map};
use cw_utils::Expiration;
Expand Down
4 changes: 2 additions & 2 deletions examples/contracts/cw1-subkeys/src/multitest/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cw2::{query_contract_info, ContractVersion};
use cw_utils::{Expiration, NativeBalance};
use sylvia::multitest::App;

use crate::contract::multitest_utils::CodeId;
use crate::contract::sv::multitest_utils::CodeId;
use crate::contract::{CONTRACT_NAME, CONTRACT_VERSION};

const ATOM: &str = "atom";
Expand Down Expand Up @@ -370,7 +370,7 @@ mod permissions {
}

mod cw1_execute {
use crate::cw1::test_utils::Cw1;
use crate::cw1::sv::test_utils::Cw1;
use cosmwasm_std::BankMsg;

use super::*;
Expand Down
4 changes: 2 additions & 2 deletions examples/contracts/cw1-subkeys/src/whitelist.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cosmwasm_std::{Response, StdResult};
use cw1_whitelist::responses::AdminListResponse;
use cw1_whitelist::whitelist::{self, Whitelist};
use sylvia::contract;
use sylvia::types::{ExecCtx, QueryCtx};
use whitelist::responses::AdminListResponse;
use whitelist::Whitelist;

use crate::contract::Cw1SubkeysContract;
use crate::error::ContractError;
Expand Down
1 change: 1 addition & 0 deletions examples/contracts/cw1-whitelist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cosmwasm-schema = "1.2"
serde = { version = "1.0", default-features = false, features = ["derive"] }
sylvia = { path = "../../../sylvia" }
cw1 = { path = "../../interfaces/cw1" }
whitelist = { path = "../../interfaces/whitelist" }
cw-storage-plus = "1.0"
thiserror = { version = "1.0" }
cw2 = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/cw1-whitelist/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::write_api;

use cw1_whitelist::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
use cw1_whitelist::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};

#[cfg(not(tarpaulin_include))]
fn main() {
Expand Down
Loading
Loading