Skip to content

Commit

Permalink
Merge pull request #115 from Brushfam/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemka374 authored Jul 19, 2023
2 parents 44a7d7b + 718f1bc commit 2324ac8
Show file tree
Hide file tree
Showing 317 changed files with 11,356 additions and 8,517 deletions.
170 changes: 104 additions & 66 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI/CD

on:
pull_request:
branches: [ main ]
branches: [ main, develop ]

jobs:
rustfmt:
Expand All @@ -12,37 +12,38 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install specific nightly
- name: Install nightly
# we use nightly because of nice formatting option :)
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-01-01
toolchain: nightly
override: true
components: rustfmt
default: true

- name: Rustfmt check
run: cargo +nightly-2023-01-01 fmt --all -- --check
run: cargo +nightly fmt --all -- --check
unit-test:
concurrency:
group: unit-test-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install specific nightly
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-01-01
toolchain: 1.69
override: true
components: rustfmt, clippy
default: true

- name: Build & Run all default unit tests
run: |
RUSTFLAGS="-D warnings" cargo +nightly-2023-01-01 test --workspace --features test-all -- --test-threads=10
RUSTFLAGS="-D warnings" cargo test --workspace --features test-all -- --test-threads=10
- name: Build & Run pallet unit tests
run: |
RUSTFLAGS="-D warnings" cargo +nightly-2023-01-01 test --workspace --features psp22_pallet -- --test-threads=10
RUSTFLAGS="-D warnings" cargo test --workspace --features psp22_pallet -- --test-threads=10
examples-builds:
concurrency:
group: examples-builds-${{ github.ref }}
Expand All @@ -58,6 +59,14 @@ jobs:
with:
node-version: '16.x'
- uses: actions/checkout@v3
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: 1.69
override: true
default: true
target: wasm32-unknown-unknown
components: rust-src
- name: NPM install dependencies
run: |
npm i
Expand All @@ -79,7 +88,7 @@ jobs:
path: artifacts
key: cache-contract-artifacts-${{ github.sha }}

- name: Typechain Сompile examples
- name: Typechain Compile examples
run: |
chown -R root .
chmod -R a+rwx .
Expand Down Expand Up @@ -113,7 +122,6 @@ jobs:
options: --user root
env:
CARGO_TARGET_DIR: /usr/local/cache/target
if: false
steps:
- uses: actions/setup-node@v1
with:
Expand All @@ -128,6 +136,15 @@ jobs:
key: cache-rust-artifacts-${{ hashFiles('Cargo.toml') }}-${{ github.ref }}
restore-keys: |
cache-rust-artifacts-${{ hashFiles('Cargo.toml') }}
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: 1.69
override: true
default: true
target: wasm32-unknown-unknown
components: rust-src

- name: Find contract data for source branch
id: find-data-source
Expand All @@ -151,6 +168,15 @@ jobs:
npm i
npm i ts-node
- name: Install nightly for destination branch
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-01-01
override: true
default: true
target: wasm32-unknown-unknown
components: rust-src

- name: Cache rust artifacts for destination branch
id: cache-rust-artifacts-destination
uses: actions/cache@v3
Expand Down Expand Up @@ -218,63 +244,75 @@ jobs:
with:
node-version: '16.x'
- uses: actions/checkout@v3
- name: NPM install dependencies
run: |
npm i
npm i ts-node
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: 1.69
override: true
default: true
target: wasm32-unknown-unknown
components: rust-src

- name: Run Test
run: |
./e2e-tests.sh ./examples/** ./examples
# typechain-e2e-tests:
# concurrency:
# group: typechain-e2e-tests-${{ github.ref }}
# cancel-in-progress: true
# runs-on: ubuntu-latest
# needs: examples-builds
# container:
# image: ghcr.io/brushfam/openbrush-contracts-ci
# options: --user root
# env:
# CARGO_TARGET_DIR: /usr/local/cache/target
# steps:
# - uses: actions/setup-node@v1
# with:
# node-version: '16.x'
# - uses: actions/checkout@v3
# - name: NPM install dependencies
# run: |
# npm i
# npm i ts-node
#
# - name: Cache contract artifacts
# id: cache-contract-artifacts
# uses: actions/cache@v3
# with:
# path: artifacts
# key: cache-contract-artifacts-${{ github.sha }}
#
# - name: Generate Typechain code
# run:
# npm run build:release:no-compile
#
# - name: Run Test Mocha
# run: |
# for test in $(find tests -type f -regex ".*\.ts"); do
# has_timeout=true
# while $has_timeout
# do
# substrate-contracts-node --tmp --dev & P1=$!;
# set +e;
# output=$(npm run test:mocha-single ./$test || true);
# set -e;
# if echo $output | grep -q 'For async tests and hooks, ensure "done()" is called'; then
# echo $output;
# has_timeout=true
# else
# npm run test:mocha-single ./$test
# has_timeout=false
# fi
# kill $P1;
# done
# done
typechain-e2e-tests:
concurrency:
group: typechain-e2e-tests-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
needs: examples-builds
container:
image: ghcr.io/brushfam/openbrush-contracts-ci
options: --user root
env:
CARGO_TARGET_DIR: /usr/local/cache/target
steps:
- uses: actions/setup-node@v1
with:
node-version: '16.x'
- uses: actions/checkout@v3
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: 1.69
override: true
default: true
target: wasm32-unknown-unknown
components: rust-src
- name: Yarn install dependencies
run: |
yarn
yarn add ts-node
- name: Cache contract artifacts
id: cache-contract-artifacts
uses: actions/cache@v3
with:
path: artifacts
key: cache-contract-artifacts-${{ github.sha }}

- name: Generate Typechain code
run:
yarn build:release:no-compile

- name: Run Test Mocha
run: |
for test in $(find tests -type f -regex ".*\.ts"); do
has_timeout=true
while $has_timeout
do
substrate-contracts-node --tmp --dev & P1=$!;
set +e;
output=$(yarn test:mocha-single ./$test || true);
set -e;
if echo $output | grep -q 'For async tests and hooks, ensure "done()" is called'; then
echo $output;
has_timeout=true
else
yarn test:mocha-single ./$test
has_timeout=false
fi
kill $P1;
done
done
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ package-lock.json
yarn.lock
.cargo/config.toml

typechain-generated/
typechain-generated/

clean.sh
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased v4.0.0]

### Added
- [*BREAKING*] `implementation`, `override` macros: [78](https://github.com/Brushfam/openbrush-contracts/pull/78)
- [*BREAKING*] `storage_item` macro, new OB feature: `Upgradeable`, which implements `set_code_hash` functionality [99](https://github.com/Brushfam/openbrush-contracts/pull/99)
- `UI` tests [77](https://github.com/Brushfam/openbrush-contracts/pull/77)
- `openbrush::accessors` macro for automatic generation of getters/setters for storage items: [66](https://github.com/Brushfam/openbrush-contracts/pull/66) and [61](https://github.com/Brushfam/openbrush-contracts/pull/61)

### Removed
- [*BREAKING*] `min_specilization`, now openbrush is `stable`: [78](https://github.com/Brushfam/openbrush-contracts/pull/78)
- `ZERO_ADDRESS`, now using `Option<AccountId>` instead: [98](https://github.com/Brushfam/openbrush-contracts/pull/98)

### Fixed
- Fixed reentrancy guard problem: [#88](https://github.com/Brushfam/openbrush-contracts/pull/88)
17 changes: 10 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ exclude = [

[package]
name = "openbrush"
version = "3.1.1"
version= "4.0.0-beta"
authors = ["Brushfam <green@727.ventures>"]
edition = "2018"

license = "MIT"
readme = "README.md"
repository = "https://github.com/727-Ventures/openbrush-contracts"
repository = "https://github.com/Brushfam/openbrush-contracts"
documentation = "https://docs.openbrush.io"
homepage = "https://727.ventures"
description = "OpenBrush library for smart contract development on ink!."
Expand All @@ -26,12 +26,12 @@ categories = ["no-std", "embedded"]
include = ["Cargo.toml", "src/**/*.rs"]

[dependencies]
ink = { version = "4.1.0", default-features = false}
ink = { version = "4.2.1", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
scale-info = { version = "2.6", default-features = false, features = ["derive"] }

openbrush_contracts = { version = "~3.1.1", path = "contracts", default-features = false }
openbrush_lang = { version = "~3.1.1", path = "lang", default-features = false }
openbrush_contracts = { version = "~4.0.0-beta", path = "contracts", default-features = false }
openbrush_lang = { version = "~4.0.0-beta", path = "lang", default-features = false }

[lib]
name = "openbrush"
Expand All @@ -41,7 +41,9 @@ crate-type = [
]

[dev-dependencies]
ink_e2e = "4.1.0"
ink_env = "4.2.1"
trybuild = "1.0.80"
ink_e2e = "4.2.1"

[features]
default = ["std"]
Expand All @@ -64,6 +66,7 @@ pausable = ["openbrush_contracts/pausable"]
timelock_controller = ["openbrush_contracts/timelock_controller"]
proxy = ["openbrush_contracts/proxy"]
diamond = ["openbrush_contracts/diamond"]
upgradeable = ["openbrush_contracts/upgradeable"]

test-all = [
"psp22",
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ RUN npm install -g n && \
npm install -g yarn && \
n stable

RUN curl -sSf https://sh.rustup.rs/ | sh -s -- --default-toolchain nightly-2023-03-19 -y
RUN curl -sSf https://sh.rustup.rs/ | sh

RUN rustup component add rust-src --toolchain nightly-2023-01-01-x86_64-unknown-linux-gnu
RUN rustup component add rust-src
RUN rustup target add wasm32-unknown-unknown

RUN cargo install cargo-dylint dylint-link

RUN cargo install cargo-contract --version 2.0.1 --force && \
RUN cargo install cargo-contract --version 3.0.0 --force && \
cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force --locked
Loading

0 comments on commit 2324ac8

Please sign in to comment.