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

Feature/ibc testing #13

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
1,186 changes: 1,061 additions & 125 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]
members = ["packages/*"]
members = ["packages/*", "contracts/*"]

resolver = "2"
2 changes: 2 additions & 0 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
45e8a3d5f3fb7c5502178ffb306005e7e37e5dd476aaeb7d17e0b6d9d7cec106 demo_contract.wasm
ca4a5ec2b18e6a15b554fcb4a495562087ab04d54c5531db2ecceb5b76c5da9d ica_demo.wasm
2 changes: 2 additions & 0 deletions artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1231de5e7d029b40017a8f21e1b66449307cfa0f17978bf49d7aa8f603726860 target/wasm32-unknown-unknown/release/demo_contract.wasm
5388f188d031923a0f6a63f46c1ddd811c106aa55e6f22ee3fa38bf06c0ad87c target/wasm32-unknown-unknown/release/ica_demo.wasm
Binary file added artifacts/demo_contract.wasm
Binary file not shown.
Binary file added artifacts/ica_demo.wasm
Binary file not shown.
5 changes: 5 additions & 0 deletions contracts/demo_contract/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --bin schema"
51 changes: 51 additions & 0 deletions contracts/demo_contract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[package]
name = "demo_contract"
version = "0.1.0"
edition = "2021"

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.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

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

[profile.release]
opt-level = 3
debug = false
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = 'abort'
incremental = false
overflow-checks = true

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
-e CARGO_TERM_COLOR=always \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.15.0
"""

[dependencies]
cosmwasm-std = { version = "1.5.0", features = ["stargate", "staking"] }
cw-storage-plus = "1.2.0"
serde = { version = "1.0", default-features = false, features = ["derive"] }
schemars = "~0.8.21"
thiserror = "1.0"

[dev-dependencies]
cosmwasm-schema = "~1.5.0"
1 change: 1 addition & 0 deletions contracts/demo_contract/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
50 changes: 50 additions & 0 deletions contracts/demo_contract/src/contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use cosmwasm_std::{Binary, Deps, DepsMut, entry_point, Env, MessageInfo, Reply, Response, StdResult, SubMsg, SubMsgResult, to_json_binary};
use cw_storage_plus::Item;
use crate::error::ContractError;
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
_deps: DepsMut,
_env: Env,
_info: MessageInfo,
_msg: InstantiateMsg,
) -> Result<Response, ContractError> {
Ok(Response::new()
.add_attribute("action", "instantiate"))
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
_env: Env,
_info: MessageInfo,
msg: ExecuteMsg,
) -> Result<Response, ContractError> {
let mut res = Response::new();
match msg {
ExecuteMsg::CosmosMsg(cosmos_msg) => {
res.messages.push(SubMsg::new(cosmos_msg));
}
ExecuteMsg::Loop(n) => {
let storage = Item::new("demo");
for i in 0..n {
storage.save(deps.storage, &i.to_string())?;
}
}
}
Ok(res)
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(_deps: Deps, _env: Env, _msg: QueryMsg) -> StdResult<Binary> {
Ok(Binary::from(&[]))
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn reply(_deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractError> {
match msg.result {
SubMsgResult::Ok(_) => Ok(Response::default()),
SubMsgResult::Err(_) => Err(ContractError::Unauthorized {}),
}
}
10 changes: 10 additions & 0 deletions contracts/demo_contract/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use cosmwasm_std::StdError;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ContractError {
#[error("{0}")]
Std(#[from] StdError),
#[error("Unauthorized")]
Unauthorized {},
}
3 changes: 3 additions & 0 deletions contracts/demo_contract/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod contract;
pub mod msg;
pub mod error;
17 changes: 17 additions & 0 deletions contracts/demo_contract/src/msg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use cosmwasm_std::CosmosMsg;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
CosmosMsg(CosmosMsg),
Loop(u64)
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {}
5 changes: 5 additions & 0 deletions contracts/ica-demo/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --bin schema"
83 changes: 83 additions & 0 deletions contracts/ica-demo/.github/workflows/Basic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# 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 stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true
profile: minimal

- name: Run unit tests
uses: actions-rs/cargo@v1
with:
command: unit-test
args: --locked
env:
RUST_BACKTRACE: 1

- name: Compile WASM contract
uses: actions-rs/cargo@v1
with:
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:
toolchain: stable
override: true
profile: minimal
components: rustfmt, clippy

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

- name: Generate schema
uses: actions-rs/cargo@v1
with:
command: schema
args: --locked

- name: Verify schema
uses: tj-actions/verify-changed-files@v8
id: verify-schema
with:
files: schema/.*\.json

- name: Display changed schemas
if: steps.verify-schema.outputs.files_changed == 'true'
run: |
echo "The schema files are not in sync with the repository. Please, run 'cargo schema' to generate them again and commit the changes."
exit 1
56 changes: 56 additions & 0 deletions contracts/ica-demo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[package]
name = "ica-demo"
version = "0.1.0"
authors = ["Guy Garcia <[email protected]>"]
edition = "2021"

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.
"artifacts/*",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

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

[profile.release]
codegen-units = 1
debug = false
debug-assertions = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true
panic = 'abort'
rpath = false

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """docker run --rm \
-e CARGO_TERM_COLOR=always \
-v "$(pwd)":/code \
-v "$(basename "$(pwd)")_cache":/code/target \
-v "$(basename "$(pwd)")_registry_cache":/usr/local/cargo/registry \
-v "$(basename "$(pwd)")_cosmwasm_sccache":/root/.cache/sccache \
--name "$(basename "$(pwd)")" \
cosmwasm/rust-optimizer:0.14.0
"""

[dependencies]
archway-bindings = "0.2.1"
pbjson-types = "0.6.0"
cosmwasm-schema = "1.3.1"
cosmwasm-std = { version = "1.3.1", features = ["stargate"] }
cosmwasm-storage = "1.3.1"
cw-storage-plus = "1.1.0"
cw2 = "1.1.0"
schemars = "0.8.12"
serde = { version = "1.0.183", default-features = false, features = ["derive"] }
thiserror = "1.0.44"
archway-proto = { git = "https://github.com/archway-network/arch3.rs.git", branch = "fix/abstract-any-proto-encoding-fix", default-features = false, features = ["abstract-any"] }
Loading