Skip to content

Replace public_key_registry from cis3_sponsored_transaction with corresponding smart contract features #1179

Replace public_key_registry from cis3_sponsored_transaction with corresponding smart contract features

Replace public_key_registry from cis3_sponsored_transaction with corresponding smart contract features #1179

Workflow file for this run

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
name: Clippy & fmt
env:
RUST_FMT: nightly-2023-04-01
RUST_VERSION: "1.65"
jobs:
rustfmt:
name: Format
runs-on: ubuntu-latest
strategy:
matrix:
crates:
- concordium-std/Cargo.toml
- concordium-cis2/Cargo.toml
- examples/voting/Cargo.toml
- examples/eSealing/Cargo.toml
- examples/auction/Cargo.toml
- examples/cis2-multi/Cargo.toml
- examples/cis2-multi-royalties/Cargo.toml
- examples/cis2-nft/Cargo.toml
- examples/cis3-nft-sponsored-txs/Cargo.toml
- examples/cis2-wccd/Cargo.toml
- examples/credential-registry/Cargo.toml
- examples/fib/Cargo.toml
- examples/icecream/Cargo.toml
- examples/memo/Cargo.toml
- examples/nametoken/Cargo.toml
- examples/piggy-bank/part1/Cargo.toml
- examples/piggy-bank/part2/Cargo.toml
- examples/proxy/Cargo.toml
- examples/recorder/Cargo.toml
- examples/signature-verifier/Cargo.toml
- examples/transfer-policy-check/Cargo.toml
- examples/two-step-transfer/Cargo.toml
- examples/smart-contract-upgrade/contract-version1/Cargo.toml
- examples/smart-contract-upgrade/contract-version2/Cargo.toml
- examples/offchain-transfers/Cargo.toml
- examples/credential-registry-storage-contract/Cargo.toml
- examples/account-signature-checks/Cargo.toml
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install nightly toolchain with rustfmt available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_FMT }}
override: true
components: rustfmt
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path=${{ matrix.crates }} -- --check
# All templates are generated with the `cargo-generate` command and it is checked that the 'cargo test' command
# can be executed without errors on the generated smart contracts.
cargo-generate-templates:
name: Smart contract template generation
runs-on: ubuntu-latest
strategy:
matrix:
crates:
- templates/default
- templates/cis2-nft
env:
PROJECT_NAME: my-project
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Run cargo-generate
uses: cargo-generate/cargo-generate-action@v0.16.0
with:
name: ${{ env.PROJECT_NAME }}
template: ${{ matrix.crates }}
other: "-d description=myProject -d tokenMetadataBaseURL=https://some.example/token/"
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
# we need to move the generated project to a temp folder, away from the template project
# otherwise `cargo` runs would fail
# see https://github.com/rust-lang/cargo/issues/9922
# Run all tests, including doc tests.
- name: Run cargo test
run: |
mv $PROJECT_NAME ${{ runner.temp }}/
cd ${{ runner.temp }}/$PROJECT_NAME
cargo test
# All templates are generated with the `cargo-generate` command
# and it is checked that the schemas can be built as part of the 'clippy' command.
clippy-template:
name: Clippy on smart contract templates
runs-on: ubuntu-latest
needs: rustfmt
strategy:
matrix:
target:
- wasm32-unknown-unknown
crates:
- templates/default
- templates/cis2-nft
env:
PROJECT_NAME: cis2-nft
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Run cargo-generate
uses: cargo-generate/cargo-generate-action@v0.16.0
with:
name: ${{ env.PROJECT_NAME }}
template: ${{ matrix.crates }}
other: "-d description=cis2-nft-project -d tokenMetadataBaseURL=https://some.example/token/"
- name: Install toolchain with clippy available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
override: true
components: clippy
# we need to move the generated project to a temp folder, away from the template project
# otherwise `cargo` runs would fail
# see https://github.com/rust-lang/cargo/issues/9922
- name: Run clippy with build-schema
run: |
mv $PROJECT_NAME ${{ runner.temp }}/
cd ${{ runner.temp }}/$PROJECT_NAME
rustup target add wasm32-unknown-unknown
cargo clippy --manifest-path ./Cargo.toml --target=${{ matrix.target }} --features concordium-std/build-schema -- -D warnings
# The cis2-nft template is generated with the `cargo-generate` command
# and it is checked that the code is equivalent to the cis2-nft smart contract in the example folder.
cargo-generate-templates-comparison:
name: Smart contract template comparison
runs-on: ubuntu-latest
strategy:
matrix:
crates:
- templates/cis2-nft
env:
PROJECT_NAME: cis2-nft
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Run cargo-generate
uses: cargo-generate/cargo-generate-action@v0.16.0
with:
name: ${{ env.PROJECT_NAME }}
template: ${{ matrix.crates }}
other: "-d description=cis2-nft-project -d tokenMetadataBaseURL=https://some.example/token/"
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
# Run diff to check if there are any differences between the generated smart contracts
# and the example smart contracts. The templates have hardcoded versions of `concordium-std`
# and `concordium-cis2` which need to be replaced with the paths used in the smart contract example folder.
# This CI pipeline uses `root` as the author which needs to be replaced with the author
# `Concordium <developers@concordium.com>` of the smart contract examples.
- name: Run diff
run: |
mv $PROJECT_NAME ${{ runner.temp }}/
sed -i "s/root/Concordium <developers@concordium.com>/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
sed -i "s/{version = \"7.0\", default-features = false}/{path = \"..\/..\/concordium-std\", default-features = false}/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
sed -i "s/{version = \"4.0\", default-features = false}/{path = \"..\/..\/concordium-cis2\", default-features = false}/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
diff ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml examples/cis2-nft/Cargo.toml
diff ${{ runner.temp }}/$PROJECT_NAME/src/lib.rs examples/cis2-nft/src/lib.rs
clippy-cis2:
name: Clippy
runs-on: ubuntu-latest
needs: rustfmt
strategy:
matrix:
target:
- wasm32-unknown-unknown
- x86_64-unknown-linux-gnu
lib-crates:
- concordium-cis2/Cargo.toml
features:
-
- u256_amount
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install toolchain with clippy available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
override: true
components: clippy
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path ${{ matrix.lib-crates }} --target=${{ matrix.target }} --features=${{ matrix.features }} -- -D warnings
clippy:
name: Clippy
runs-on: ubuntu-latest
needs: rustfmt
strategy:
matrix:
target:
- wasm32-unknown-unknown
- x86_64-unknown-linux-gnu
lib-crates:
- concordium-std/Cargo.toml
features:
-
- build-schema
- concordium-quickcheck
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install toolchain with clippy available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
override: true
components: clippy
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path ${{ matrix.lib-crates }} --target=${{ matrix.target }} --features=${{ matrix.features }} -- -D warnings
clippy-crypto-primitives:
name: Clippy concordium-std with crypto-primitives
runs-on: ubuntu-latest
needs: rustfmt
strategy:
matrix:
target:
- wasm32-unknown-unknown
- x86_64-unknown-linux-gnu
lib-crates:
- concordium-std/Cargo.toml
features:
- crypto-primitives
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install toolchain with clippy available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
override: true
components: clippy
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path ${{ matrix.lib-crates }} --target=${{ matrix.target }} --features=${{ matrix.features }} -- -D warnings
clippy-wasm32-only:
name: Clippy Wasm32
runs-on: ubuntu-latest
needs: rustfmt
strategy:
matrix:
target:
- wasm32-unknown-unknown
lib-crates:
- concordium-std/Cargo.toml
features:
- wasm-test
- wasm-test,build-schema
- wasm-test,concordium-quickcheck
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install toolchain with clippy available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
override: true
components: clippy
- name: Run cargo clippy, but only for wasm32 target
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path ${{ matrix.lib-crates }} --target=${{ matrix.target }} --features=${{ matrix.features }} -- -D warnings
check-std-no-std:
name: Build on nightly,
runs-on: ubuntu-latest
needs: rustfmt
strategy:
matrix:
target:
- wasm32-unknown-unknown
crates:
- concordium-std/Cargo.toml
- concordium-cis2/Cargo.toml
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install nightly toolchain with check available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
target: ${{ matrix.target }}
override: true
- name: Run cargo check with no-std
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path ${{ matrix.crates }} --target=${{ matrix.target }} --no-default-features
check-no-std-examples:
name: Build on nightly,
runs-on: ubuntu-latest
needs: rustfmt
strategy:
matrix:
target:
- wasm32-unknown-unknown
crates:
- examples/two-step-transfer/Cargo.toml
- examples/cis2-wccd/Cargo.toml
- examples/cis2-nft/Cargo.toml
- examples/cis2-multi/Cargo.toml
- examples/cis2-multi-royalties/Cargo.toml
- examples/nametoken/Cargo.toml
- examples/credential-registry-storage-contract/Cargo.toml
- examples/account-signature-checks/Cargo.toml
features:
-
- concordium-std/build-schema
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install nightly toolchain with check available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
target: ${{ matrix.target }}
override: true
- name: Run cargo check with no-std
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path ${{ matrix.crates }} --target=${{ matrix.target }} --no-default-features --features=${{ matrix.features }} --features wee_alloc
check-crypto-examples:
name: Check crypto examples
runs-on: ubuntu-latest
needs: [rustfmt, clippy-schema]
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- wasm32-unknown-unknown
features:
- crypto-primitives
crates:
- examples/nametoken/Cargo.toml
- examples/signature-verifier/Cargo.toml
- examples/cis3-nft-sponsored-txs/Cargo.toml
- examples/credential-registry/Cargo.toml
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
override: true
- name: Run cargo build with crypto-primitives feature
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path ${{ matrix.crates }} --target=${{ matrix.target }} --features=${{ matrix.features }} --lib
clippy-schema:
name: Clippy on examples
runs-on: ubuntu-latest
needs: rustfmt
strategy:
matrix:
target:
- wasm32-unknown-unknown
crates:
- examples/voting/Cargo.toml
- examples/eSealing/Cargo.toml
- examples/auction/Cargo.toml
- examples/cis2-multi/Cargo.toml
- examples/cis2-multi-royalties/Cargo.toml
- examples/cis2-nft/Cargo.toml
- examples/cis3-nft-sponsored-txs/Cargo.toml
- examples/cis2-wccd/Cargo.toml
- examples/credential-registry/Cargo.toml
- examples/fib/Cargo.toml
- examples/icecream/Cargo.toml
- examples/memo/Cargo.toml
- examples/nametoken/Cargo.toml
- examples/piggy-bank/part1/Cargo.toml
- examples/piggy-bank/part2/Cargo.toml
- examples/proxy/Cargo.toml
- examples/recorder/Cargo.toml
- examples/signature-verifier/Cargo.toml
- examples/transfer-policy-check/Cargo.toml
- examples/two-step-transfer/Cargo.toml
- examples/smart-contract-upgrade/contract-version1/Cargo.toml
- examples/smart-contract-upgrade/contract-version2/Cargo.toml
- examples/offchain-transfers/Cargo.toml
- examples/credential-registry-storage-contract/Cargo.toml
- examples/account-signature-checks/Cargo.toml
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install toolchain with clippy available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
override: true
components: clippy
- name: Run cargo clippy with schema and tests
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path ${{ matrix.crates }} --target=${{ matrix.target }} --features concordium-std/build-schema --features concordium-std/wasm-test -- -D warnings
test:
name: Test the library
runs-on: ubuntu-latest
needs: [rustfmt, clippy]
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
lib-crates:
- concordium-std/Cargo.toml
- concordium-cis2/Cargo.toml
features:
-
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
# Run all tests, including doc tests.
args: --manifest-path ${{ matrix.lib-crates }} --target=${{ matrix.target }} --features=${{ matrix.features }}
test-cis2-with-256:
name: Test the library
runs-on: ubuntu-latest
needs: [rustfmt, clippy]
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
lib-crates:
- concordium-cis2/Cargo.toml
features:
- u256_amount
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
# Run all tests, including doc tests.
args: --manifest-path ${{ matrix.lib-crates }} --target=${{ matrix.target }} --features=${{ matrix.features }}
test-examples:
name: Test examples
runs-on: ubuntu-latest
needs: [rustfmt, clippy-schema]
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
crates:
- examples/voting/Cargo.toml
- examples/eSealing/Cargo.toml
- examples/auction/Cargo.toml
- examples/cis2-multi/Cargo.toml
- examples/cis2-multi-royalties/Cargo.toml
- examples/cis2-nft/Cargo.toml
- examples/cis3-nft-sponsored-txs/Cargo.toml
- examples/cis2-wccd/Cargo.toml
- examples/credential-registry/Cargo.toml
- examples/fib/Cargo.toml
- examples/icecream/Cargo.toml
- examples/memo/Cargo.toml
- examples/nametoken/Cargo.toml
- examples/piggy-bank/part1/Cargo.toml
- examples/piggy-bank/part2/Cargo.toml
- examples/proxy/Cargo.toml
- examples/recorder/Cargo.toml
- examples/signature-verifier/Cargo.toml
- examples/transfer-policy-check/Cargo.toml
- examples/two-step-transfer/Cargo.toml
- examples/smart-contract-upgrade/contract-version1/Cargo.toml
- examples/smart-contract-upgrade/contract-version2/Cargo.toml
- examples/offchain-transfers/Cargo.toml
- examples/credential-registry-storage-contract/Cargo.toml
- examples/account-signature-checks/Cargo.toml
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
# only run the library tests, no doc tests
args: --manifest-path ${{ matrix.crates }} --target=${{ matrix.target }} --lib