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/workflow #33

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .cargo/config → .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"

[env]
RUSTFLAGS = "-C link-arg=-s"
18 changes: 14 additions & 4 deletions .github/workflows/Basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ on:
branches:
- main
tags:
- 'v*.*.*'
- "v*.*.*"

pull_request:

name: Basic

jobs:

test:
name: Test Suite
runs-on: ubuntu-latest
Expand All @@ -35,7 +34,6 @@ jobs:
env:
RUST_BACKTRACE: 1


lints:
name: Lints
runs-on: ubuntu-latest
Expand All @@ -54,11 +52,23 @@ jobs:
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
toolchain: stable
command: fmt
args: --all -- --check

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

- name: Generate Schema
run: ./scripts/schema.sh

- name: Show Schema changes
run: git status --porcelain

- name: Schema Changes
# fails if any changes not committed
run: chmod +x ./scripts/schema.sh && test -z "$(git status --porcelain)"
39 changes: 0 additions & 39 deletions .github/workflows/Release.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Builds and commits the artifacts whenever a change is pushed to main.
name: artifact compiler

permissions:
contents: write

on:
push:
tags:
- "v*"
branches:
- main

jobs:
release-artifacts:
runs-on: ubuntu-latest
container: cosmwasm/workspace-optimizer:0.15.1
steps:
- uses: actions/checkout@v3

# tar is required for cargo cache
- run: apk add --no-cache tar curl

- name: Set up cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Compile contracts
timeout-minutes: 30
run: optimize.sh .

- name: Upload contracts
uses: actions/upload-artifact@v4
with:
name: contracts
path: artifacts/

- name: release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: artifacts/*
env:
GITHUB_TOKEN: ${{ github.token }}
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ rsa = { version = "0.9.2" }
getrandom = { version = "0.2.10", features = ["custom"] }
p256 = {version = "0.13.2", features = ["ecdsa-core", "arithmetic", "serde"]}
prost = {version = "0.11.2", default-features = false, features = ["prost-derive"]}
cosmos-sdk-proto = {git = "https://github.com/burnt-labs/cosmos-rust.git", rev = "75e72f446629f98330e209e2f6268250d325cccb", default-features = false, features = ["std", "cosmwasm", "xion", "serde"]}
osmosis-std-derive = "0.13.2"
cosmos-sdk-proto = {git = "https://github.com/burnt-labs/cosmos-rust.git", rev = "75e72f446629f98330e209e2f6268250d325cccb", default-features = false, features = ["std", "cosmwasm", "xion", "serde"]}
10 changes: 10 additions & 0 deletions contracts/account/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use ::account::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use cosmwasm_schema::write_api;

fn main() {
write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
execute: ExecuteMsg,
}
}
21 changes: 7 additions & 14 deletions contracts/account/src/auth/secp256r1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,16 @@ mod tests {
let verifying_key_binary = Binary::from(verifying_key_bytes.to_vec());
println!("verifying key: {}", hex::encode(verifying_key_bytes));

assert_eq!(
true,
verify(
&test_value.to_vec(),
signature_bytes.as_slice(),
&verifying_key_binary,
)
.unwrap()
);
assert!(verify(
test_value,
signature_bytes.as_slice(),
&verifying_key_binary,
)
.unwrap());

// test with invalid msg
let bad_value = "invalid starting msg".as_bytes();
let result = verify(
&bad_value.to_vec(),
signature_bytes.as_slice(),
&verifying_key_binary,
);
let result = verify(bad_value, signature_bytes.as_slice(), &verifying_key_binary);
assert!(result.is_err())
}
}
10 changes: 10 additions & 0 deletions contracts/treasury/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use ::treasury::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use cosmwasm_schema::write_api;

fn main() {
write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
execute: ExecuteMsg,
}
}
2 changes: 1 addition & 1 deletion contracts/treasury/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern crate core;
pub mod contract;
mod error;
mod execute;
mod msg;
pub mod msg;
mod state;

mod grant;
Expand Down
20 changes: 20 additions & 0 deletions scripts/schema.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
START_DIR=$(pwd)

# ${f <-- from variable f
# ## <-- greedy front trim
# * <-- matches anything
# / <-- until the last '/'
# }
# <https://stackoverflow.com/a/3162500>

echo "generating schema for account contract"
cd contracts/account
cargo run --example schema > /dev/null
rm -rf ./schema/raw
cd "$START_DIR"

echo "generating schema for treasury contract"
cd contracts/treasury
cargo run --example schema > /dev/null
rm -rf ./schema/raw
cd "$START_DIR"
Loading