Skip to content

Commit

Permalink
Merge pull request #141 from Supercolony-net/feature/release-v2.1.0
Browse files Browse the repository at this point in the history
Updated ink! to 3.3.0 and OpenBrush to 2.1.0
  • Loading branch information
xgreenx authored Jun 23, 2022
2 parents 9a780b1 + d0d09fe commit f07bce2
Show file tree
Hide file tree
Showing 96 changed files with 1,309 additions and 710 deletions.
120 changes: 95 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
name: CI/CD

on:
pull_request:
branches: [ main ]

jobs:
rustfmt:
concurrency:
group: rustfmt-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
container:
image: ghcr.io/supercolony-net/openbrush-contracts-ci
options: --user root
env:
CARGO_TARGET_DIR: /usr/local/cache/target
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt

- name: Rustfmt check
run: cargo 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
container:
image: ghcr.io/supercolony-net/openbrush-contracts-ci
options: --user root
env:
CARGO_TARGET_DIR: /usr/local/cache/target
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy

- name: Build & Run cargo tests
run: |
RUSTFLAGS="-D warnings" cargo test --all-features --workspace -- --test-threads=10
RUSTFLAGS="-D warnings" cargo +nightly test --all-features --workspace -- --test-threads=10
examples-builds:
concurrency:
group: examples-builds-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
container:
image: ghcr.io/supercolony-net/openbrush-contracts-ci
Expand All @@ -37,18 +52,57 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: '16.x'
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Yarn install dependencies
run: |
yarn
yarn add ts-node
- name: Cache rust artifacts
id: cache-rust-artifacts
uses: actions/cache@v3
with:
path: /usr/local/cache/target
key: cache-rust-artifacts-${{ hashFiles('Cargo.toml') }}-${{ github.ref }}
restore-keys: |
cache-rust-artifacts-${{ hashFiles('Cargo.toml') }}
- name: Cache contract artifacts
id: cache-contract-artifacts
uses: actions/cache@v3
with:
path: artifacts
key: cache-contract-artifacts-${{ github.sha }}

- name: Redspot Сompile examples
run: |
chown -R root .
chmod -R a+rwx .
RUSTFLAGS="-D warnings" yarn build:release
yarn build:release
caching-artifacts:
concurrency:
group: caching-artifacts-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
needs: examples-builds
container:
image: ghcr.io/supercolony-net/openbrush-contracts-ci
options: --user root
steps:
- uses: actions/checkout@v3

- name: Copy rust artifacts
id: cache-rust-artifacts
uses: actions/cache@v3
with:
path: /usr/local/cache/target
key: cache-rust-artifacts-${{ hashFiles('Cargo.toml') }}
integration-tests:
concurrency:
group: integration-tests-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
needs: examples-builds
container:
image: ghcr.io/supercolony-net/openbrush-contracts-ci
options: --user root
Expand All @@ -58,20 +112,36 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: '16.x'
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Yarn install dependencies
run: |
yarn
yarn add ts-node
- name: Redspot Сompile
run: |
chown -R root .
chmod -R a+rwx .
yarn build:release
- name: Cache contract artifacts
id: cache-contract-artifacts
uses: actions/cache@v3
with:
path: artifacts
key: cache-contract-artifacts-${{ github.sha }}

- name: Run Test Mocha
run: |
for test in $(find tests -type f -regex ".*\.ts"); do
substrate-contracts-node --tmp --dev & P1=$!;
yarn test:mocha-single ./$test;
kill $P1;
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
2 changes: 1 addition & 1 deletion .github/workflows/github_pages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: documentation
name: Documentation

on:
pull_request:
Expand Down
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exclude = [

[package]
name = "openbrush"
version = "2.0.0"
version = "2.1.0"
authors = ["Supercolony <green.baneling@supercolony.net>"]
edition = "2018"

Expand All @@ -27,19 +27,19 @@ categories = ["no-std", "embedded"]
include = ["Cargo.toml", "src/**/*.rs"]

[dependencies]
ink_primitives = { version = "~3.2.0", default-features = false }
ink_metadata = { version = "~3.2.0", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "~3.2.0", default-features = false }
ink_storage = { version = "~3.2.0", default-features = false }
ink_lang = { version = "~3.2.0", default-features = false }
ink_prelude = { version = "~3.2.0", default-features = false }
ink_engine = { version = "~3.2.0", default-features = false, optional = true }
ink_primitives = { version = "~3.3.0", default-features = false }
ink_metadata = { version = "~3.3.0", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "~3.3.0", default-features = false }
ink_storage = { version = "~3.3.0", default-features = false }
ink_lang = { version = "~3.3.0", default-features = false }
ink_prelude = { version = "~3.3.0", default-features = false }
ink_engine = { version = "~3.3.0", default-features = false, optional = true }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }

openbrush_contracts = { version = "~2.0.0", path = "contracts", default-features = false }
openbrush_lang = { version = "~2.0.0", path = "lang", default-features = false }
openbrush_contracts = { version = "~2.1.0", path = "contracts", default-features = false }
openbrush_lang = { version = "~2.1.0", path = "lang", default-features = false }

[lib]
name = "openbrush"
Expand All @@ -61,11 +61,11 @@ std = [
"openbrush_contracts/std",
"openbrush_lang/std",
]
access_control = ["openbrush_contracts/access_control"]
psp22 = ["openbrush_contracts/psp22"]
psp34 = ["openbrush_contracts/psp34"]
psp35 = ["openbrush_contracts/psp35"]
ownable = ["openbrush_contracts/ownable"]
access_control = ["openbrush_contracts/access_control"]
payment_splitter = ["openbrush_contracts/payment_splitter"]
reentrancy_guard = ["openbrush_contracts/reentrancy_guard"]
pausable = ["openbrush_contracts/pausable"]
Expand Down
20 changes: 10 additions & 10 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "openbrush_contracts"
version = "2.0.0"
version = "2.1.0"
authors = ["Supercolony <green.baneling@supercolony.net>"]
edition = "2021"

Expand All @@ -15,19 +15,19 @@ categories = ["no-std", "embedded"]
include = ["Cargo.toml", "src/**/*.rs"]

[dependencies]
ink_primitives = { version = "~3.2.0", default-features = false }
ink_metadata = { version = "~3.2.0", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "~3.2.0", default-features = false }
ink_storage = { version = "~3.2.0", default-features = false }
ink_lang = { version = "~3.2.0", default-features = false }
ink_prelude = { version = "~3.2.0", default-features = false }
ink_engine = { version = "~3.2.0", default-features = false, optional = true }
ink_primitives = { version = "~3.3.0", default-features = false }
ink_metadata = { version = "~3.3.0", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "~3.3.0", default-features = false }
ink_storage = { version = "~3.3.0", default-features = false }
ink_lang = { version = "~3.3.0", default-features = false }
ink_prelude = { version = "~3.3.0", default-features = false }
ink_engine = { version = "~3.3.0", default-features = false, optional = true }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }

derive = { package = "openbrush_contracts_derive", version = "~2.0.0", path = "derive" }
openbrush = { version = "~2.0.0", package = "openbrush_lang", path = "../lang", default-features = false }
derive = { package = "openbrush_contracts_derive", version = "~2.1.0", path = "derive" }
openbrush = { version = "~2.1.0", package = "openbrush_lang", path = "../lang", default-features = false }

[lib]
name = "openbrush_contracts"
Expand Down
4 changes: 2 additions & 2 deletions contracts/derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "openbrush_contracts_derive"
version = "2.0.0"
version = "2.1.0"
authors = ["Supercolony <green.baneling@supercolony.net>"]
edition = "2021"

Expand All @@ -17,7 +17,7 @@ include = ["Cargo.toml", "lib.rs"]
syn = { version = "1.0" }
quote = "1.0"
proc-macro2 = "1"
openbrush = { package = "openbrush_lang", version = "~2.0.0", path = "../../lang" }
openbrush = { package = "openbrush_lang", version = "~2.1.0", path = "../../lang" }

[lib]
name = "openbrush_contracts_derive"
Expand Down
10 changes: 5 additions & 5 deletions contracts/src/access/access_control/extensions/enumerable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

pub use crate::{
access_control::*,
traits::access_control_enumerable::*,
traits::access_control::extensions::enumerable::*,
};
pub use derive::AccessControlEnumerableStorage;
use openbrush::{
Expand Down Expand Up @@ -77,11 +77,11 @@ impl<T> AccessControlEnumerable for T
where
T: AccessControlEnumerableMembersStorage<Data = EnumerableMembers> + AccessControl,
{
default fn get_role_member(&self, role: RoleType, index: u128) -> Option<AccountId> {
self.get().role_members.get_value(role, &index)
default fn get_role_member(&self, role: RoleType, index: u32) -> Option<AccountId> {
self.get().role_members.get_value(role, &(index as u128))
}

default fn get_role_member_count(&self, role: RoleType) -> u128 {
self.get().role_members.count(role)
default fn get_role_member_count(&self, role: RoleType) -> u32 {
self.get().role_members.count(role) as u32
}
}
1 change: 1 addition & 0 deletions contracts/src/access/access_control/members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub const MEMBERS_KEY: [u8; 32] = ink_lang::blake2x256!("openbrush::AccessContro
#[openbrush::storage(MEMBERS_KEY)]
pub struct Members {
pub members: Mapping<(RoleType, AccountId), (), MembersKey>,
pub _reserved: Option<()>,
}

pub struct MembersKey;
Expand Down
Loading

0 comments on commit f07bce2

Please sign in to comment.