diff --git a/.cargo/config b/.cargo/config.toml similarity index 67% rename from .cargo/config rename to .cargo/config.toml index 86f292b6..89e26333 100644 --- a/.cargo/config +++ b/.cargo/config.toml @@ -1,3 +1,5 @@ [alias] wasm = "build --release --lib --target wasm32-unknown-unknown" +[env] +RUSTFLAGS = "-C link-arg=-s" \ No newline at end of file diff --git a/.github/workflows/Basic.yml b/.github/workflows/Basic.yml index 849c7423..964ab0b3 100644 --- a/.github/workflows/Basic.yml +++ b/.github/workflows/Basic.yml @@ -5,14 +5,13 @@ on: branches: - main tags: - - 'v*.*.*' + - "v*.*.*" pull_request: name: Basic jobs: - test: name: Test Suite runs-on: ubuntu-latest @@ -35,7 +34,6 @@ jobs: env: RUST_BACKTRACE: 1 - lints: name: Lints runs-on: ubuntu-latest @@ -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)" diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml deleted file mode 100644 index bbf8a95f..00000000 --- a/.github/workflows/Release.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: release wasm - -on: - release: - types: [created] - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - target: wasm32-unknown-unknown - override: true - - name: Compile WASM contract - uses: actions-rs/cargo@v1 - with: - command: wasm - args: --locked - env: - RUSTFLAGS: "-C link-arg=-s" - - name: Get release ID - id: get_release - uses: bruceadams/get-release@v1.2.3 - env: - GITHUB_TOKEN: ${{ github.token }} - - name: Upload optimized wasm - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ github.token }} - file: ./target/wasm32-unknown-unknown/release/*.wasm - tag: ${{ github.ref }} - overwrite: true - file_glob: true diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml new file mode 100644 index 00000000..6ec95f0d --- /dev/null +++ b/.github/workflows/artifacts.yml @@ -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 }} diff --git a/Cargo.toml b/Cargo.toml index 4780c335..c486e37b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"]} \ No newline at end of file diff --git a/contracts/account/examples/schema.rs b/contracts/account/examples/schema.rs new file mode 100644 index 00000000..ba9fd69c --- /dev/null +++ b/contracts/account/examples/schema.rs @@ -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, + } +} diff --git a/contracts/account/src/auth/secp256r1.rs b/contracts/account/src/auth/secp256r1.rs index 6e833c96..afea7fb2 100644 --- a/contracts/account/src/auth/secp256r1.rs +++ b/contracts/account/src/auth/secp256r1.rs @@ -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()) } } diff --git a/contracts/treasury/examples/schema.rs b/contracts/treasury/examples/schema.rs new file mode 100644 index 00000000..f1b74005 --- /dev/null +++ b/contracts/treasury/examples/schema.rs @@ -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, + } +} diff --git a/contracts/treasury/src/lib.rs b/contracts/treasury/src/lib.rs index b7f80b09..2f244676 100644 --- a/contracts/treasury/src/lib.rs +++ b/contracts/treasury/src/lib.rs @@ -4,7 +4,7 @@ extern crate core; pub mod contract; mod error; mod execute; -mod msg; +pub mod msg; mod state; mod grant; diff --git a/scripts/schema.sh b/scripts/schema.sh new file mode 100755 index 00000000..65db05e1 --- /dev/null +++ b/scripts/schema.sh @@ -0,0 +1,20 @@ +START_DIR=$(pwd) + +# ${f <-- from variable f +# ## <-- greedy front trim +# * <-- matches anything +# / <-- until the last '/' +# } +# + +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" \ No newline at end of file