Unverified Commit 5c5d17df authored by Hero Bird's avatar Hero Bird Committed by GitHub

ink! abi followup (#168)

* [examples] remove unneeded dependencies

* [cli] template: remove unneeded dependencies

* [*] make test-env a default feature

* [core] no longer export impl_empty_flush_for macro

* [scripts] add usage docs to check-workspace

* [readme] add section about scripts

* [core] add lib.rs docs

* [core] simple Cargo.toml formatting

* [ci] use latest nightly-2019-08-13

* [ci] upload kcov results after workspace checks

* [scripts] fix the banner not being printed

* Update README.md
Co-Authored-By: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>

* Update core/src/lib.rs
Co-Authored-By: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>
parent fa6b0065
......@@ -7,7 +7,7 @@ rust:
# - stable
# - beta
- nightly
- nightly-2019-08-09
- nightly-2019-08-13
matrix:
allow_failures:
......@@ -65,16 +65,19 @@ script:
./scripts/check-workspace.sh
check_workspace=$?
./scripts/check-examples.sh
check_examples=$?
if [ $check_examples -eq 0 ] && [ $check_workspace -eq 0 ]
if [ $check_workspace -eq 0 ]
then
# Execute and upload kcov results
cargo kcov --verbose --coveralls --all --no-clean-rebuild
kcov=$?
bash <(curl -s https://codecov.io/bash)
fi
./scripts/check-examples.sh
check_examples=$?
if [ $check_examples -eq 0 ] && [ $check_workspace -eq 0 ]
then
echo "All checks have passed!"
exit 0
else
......
......@@ -35,6 +35,15 @@ ink! is an [eDSL](https://wiki.haskell.org/Embedded_domain_specific_language) to
|-----------|------------|-------------|
| [![][H1]][H2] | [![][F1]][F2] | [![][G1]][G2] |
### Scripts
Use the scripts provided under `scripts` directory in order to run checks on either the workspace or all examples. Please do this before pushing work in a PR.
### Testing
Off-chain testing is done by `cargo test`.
If you want to test all workspace crates, do `cargo test --all`.
## Example
Below is an example using ink! demonstrating a simple Flipper smart contract
......@@ -44,7 +53,7 @@ that has a boolean state that can be flipped or returned.
contract! {
/// Specify concrete implementation of contract environment types
#![env = ink_core::env::DefaultSrmlTypes]
/// Flips its state between `true` and `false`.
struct Flipper {
/// The current state of our flag.
......
......@@ -11,7 +11,6 @@ ink_model = { git = "https://github.com/paritytech/ink", package = "ink_model",
ink_lang = { git = "https://github.com/paritytech/ink", package = "ink_lang", default-features = false }
scale = { package = "parity-scale-codec", version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"], optional = true }
[lib]
......@@ -42,8 +41,6 @@ test-env = [
ink-generate-abi = [
"std",
"ink_abi",
"serde",
"serde_json",
"type-metadata",
"ink_core/ink-generate-abi",
]
......
......@@ -21,12 +21,12 @@ include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
ink_abi = { path = "../abi/", default-features = false, features = ["derive"], optional = true }
ink_alloc = { path = "../alloc/", default-features = false }
ink_utils = { path = "../utils/", default-features = false }
scale = { package = "parity-scale-codec", version = "1.0", default-features = false, features = ["derive", "full"] }
scale = { package = "parity-scale-codec", version = "1.0", default-features = false, features = ["derive", "full"] }
type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"], optional = true }
[features]
default = ["std"]
default = ["test-env"]
test-env = ["std"]
std = [
"ink_abi/std",
......
......@@ -21,7 +21,6 @@ use core::{
use crate::{
env::EnvTypes,
impl_empty_flush_for,
storage::Flush,
};
use scale::{
......@@ -116,4 +115,10 @@ pub type Moment = u64;
/// The default SRML blocknumber type.
pub type BlockNumber = u64;
impl_empty_flush_for!(AccountId, Hash);
impl Flush for AccountId {
fn flush(&mut self) {}
}
impl Flush for Hash {
fn flush(&mut self) {}
}
......@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
//! The `ink_core` utilities used by all ink! smart contracts.
//!
//! Mainly provides entities to work on a contract's storage
//! as well as high-level collections on top of those.
//! Also provides environmental utilities, such as storage allocators,
//! FFI to interface with SRML contracts and a primitive blockchain
//! emulator for simple off-chain testing.
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(
bad_style,
......
......@@ -42,7 +42,6 @@ pub trait Flush {
fn flush(&mut self);
}
#[macro_export]
macro_rules! impl_empty_flush_for {
( $($ty:ty),* ) => {
$(
......
......@@ -11,7 +11,6 @@ ink_model = { path = "../../../model", default-features = false }
ink_lang = { path = "../../../lang", default-features = false }
scale = { package = "parity-scale-codec", version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"], optional = true }
[lib]
......@@ -32,7 +31,6 @@ std = [
"ink_lang/std",
"type-metadata/std",
"scale/std",
"serde/std",
]
test-env = [
"std",
......@@ -43,7 +41,6 @@ test-env = [
ink-generate-abi = [
"std",
"ink_abi",
"serde",
"type-metadata",
"ink_core/ink-generate-abi",
]
......
......@@ -11,8 +11,6 @@ ink_model = { path = "../../../model", default-features = false }
ink_lang = { path = "../../../lang", default-features = false }
scale = { package = "parity-scale-codec", version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
serde_json = { version = "1.0", default-features = false, optional = true }
type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"], optional = true }
[lib]
......@@ -32,7 +30,6 @@ std = [
"ink_model/std",
"ink_lang/std",
"scale/std",
"serde/std",
"type-metadata/std",
]
test-env = [
......@@ -44,8 +41,6 @@ test-env = [
ink-generate-abi = [
"std",
"ink_abi",
"serde",
"serde_json",
"type-metadata",
"ink_core/ink-generate-abi",
]
......
......@@ -11,8 +11,6 @@ ink_model = { path = "../../../model", default-features = false }
ink_lang = { path = "../../../lang", default-features = false }
scale = { package = "parity-scale-codec", version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
serde_json = { version = "1.0", default-features = false, optional = true }
type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"], optional = true }
[lib]
......@@ -32,7 +30,6 @@ std = [
"ink_model/std",
"ink_lang/std",
"scale/std",
"serde/std",
"type-metadata/std",
]
test-env = [
......@@ -44,8 +41,6 @@ test-env = [
ink-generate-abi = [
"std",
"ink_abi",
"serde",
"serde_json",
"type-metadata",
"ink_core/ink-generate-abi",
]
......
......@@ -11,8 +11,6 @@ ink_model = { path = "../../../model", default-features = false }
ink_lang = { path = "../../../lang", default-features = false }
scale = { package = "parity-scale-codec", version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
serde_json = { version = "1.0", default-features = false, optional = true }
type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"], optional = true }
[lib]
......@@ -32,7 +30,6 @@ std = [
"ink_model/std",
"ink_lang/std",
"scale/std",
"serde/std",
"type-metadata/std",
]
test-env = [
......@@ -44,8 +41,6 @@ test-env = [
ink-generate-abi = [
"std",
"ink_abi",
"serde",
"serde_json",
"type-metadata",
"ink_core/ink-generate-abi",
]
......
......@@ -39,7 +39,7 @@ name = "ink_lang"
proc-macro = true
[features]
default = ["std"]
default = ["test-env"]
std = [
"ink_utils/std",
"ink_model/std",
......@@ -49,5 +49,6 @@ std = [
"serde/std",
]
test-env = [
"std",
"ink_model/test-env",
]
\ No newline at end of file
]
......@@ -18,7 +18,7 @@ ink_core = { path = "../core", default-features = false }
scale = { package = "parity-scale-codec", version = "1.0", default-features = false, features = ["derive", "full"] }
[features]
default = ["std"]
default = ["test-env"]
test-env = [
"std",
"ink_core/test-env",
......
......@@ -48,8 +48,9 @@ for example in $(ls examples/lang); do
fi
done
banner="---------------"
echo "Example Results"
echo "---------------"
echo "$banner"
for entry in ${!results_wasm[@]}; do
echo "- $entry (wasm): ${results_wasm[$entry]}"
echo "- $entry (test): ${results_test[$entry]}"
......@@ -59,9 +60,10 @@ echo ""
if [ $all_checks_passed -eq 0 ]
then
echo "examples: All checks passed"
echo "$banner"
exit 0
else
echo "examples: Some checks failed"
echo "$banner"
exit 1
fi
echo "---------------"
#!/bin/bash
# Run this script from the workspace root!
#
# This script iterates through all crates in the workspace and runs
# the most important actions to verify integrity and control quality.
#
# - compile under different setups
# - check formatting according to our house rules
# - run a linter (clippy) under different setups
# - run all tests
# - build Wasm blobs
#
# Afterwards the script prints out a summary report.
#
# Exits with `0` if all tests completed successfully or `1` otherwise.
declare -A results
cargo check --verbose --all --all-features
......@@ -24,9 +39,10 @@ cargo build --verbose --all --no-default-features --release --target=wasm32-unkn
results["build_wasm"]=$?
all_checks_passed=0
banner="-----------------"
echo "Workspace Results"
echo "-----------------"
echo "$banner"
for entry in ${!results[@]}; do
result_str=""
if [ ${results[$entry]} -eq 0 ]
......@@ -42,9 +58,10 @@ echo ""
if [ $all_checks_passed -eq 0 ]
then
echo "workspace: All checks passed"
echo "$banner"
exit 0
else
echo "workspace: Some checks failed"
echo "$banner"
exit 1
fi
echo "-----------------"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment