Skip to content

Commit

Permalink
Align example names with integration-tests, fix CI (use-ink#39)
Browse files Browse the repository at this point in the history
* Align contract names with `integration-tests` with hyphens

* Try to get CI running on the PR

* Delete upgradeable-contracts

* Fix set-code-hash

* Fix rand-extension

* Fix vesting
  • Loading branch information
ascjones authored Aug 24, 2023
1 parent 3e95599 commit 616ac4c
Show file tree
Hide file tree
Showing 41 changed files with 69 additions and 485 deletions.
30 changes: 8 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ on:
pull_request:
branches:
- main
paths:
- '.github/workflows/ci.yml'

jobs:
check:
Expand All @@ -30,8 +28,7 @@ jobs:
- test
runs-on: ${{ matrix.platform }}
env:
UPGRADEABLE_CONTRACTS: "forward-calls set-code-hash"
DELEGATOR_SUBCONTRACTS: "accumulator adder subber"
MULTI_CONTRACT_CALLER_SUBCONTRACTS: "accumulator adder subber"
RUST_BACKTRACE: full
steps:

Expand Down Expand Up @@ -103,21 +100,15 @@ jobs:
run: |
$multi_contract_caller_subcontracts = "accumulator","adder","subber"
foreach ($contract in $multi_contract_caller_subcontracts) {
echo "Processing multi_contract_caller contract: $contract";
cargo ${{ matrix.job }} --verbose --manifest-path multi_contract_caller/${contract}/Cargo.toml;
echo "Processing multi-contract-caller contract: $contract";
cargo ${{ matrix.job }} --verbose --manifest-path multi-contract-caller/${contract}/Cargo.toml;
}
$upgradeable_contracts = "forward-calls","set-code-hash"
foreach ($contract in $upgradeable_contracts) {
echo "Processing upgradeable contract: $contract";
cargo ${{ matrix.job }} --verbose --manifest-path upgradeable-contracts/${contract}/Cargo.toml;
}
cargo ${{ matrix.job }} --verbose --manifest-path upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml;
cargo ${{ matrix.job }} --verbose --manifest-path set-code-hash/updated-incrementer/Cargo.toml;
cargo ${{ matrix.job }} --verbose --manifest-path conditional-compilation/Cargo.toml --features foo;
cargo ${{ matrix.job }} --verbose --manifest-path conditional-compilation/Cargo.toml --features bar;
cargo ${{ matrix.job }} --verbose --manifest-path conditional-compilation/Cargo.toml --features "foo, bar";
foreach ($example in Get-ChildItem -Directory "\*") {
if ($example -Match 'upgradeable-contracts') { continue }
if ($example -Match 'artifacts') { continue }
echo "Processing example: $example";
cargo ${{ matrix.job }} --verbose --manifest-path=$example/Cargo.toml;
Expand All @@ -127,21 +118,16 @@ jobs:
- name: ${{ matrix.job }} examples on ${{ matrix.platform }}-${{ matrix.toolchain }}
if: runner.os != 'Windows'
run: |
for contract in ${DELEGATOR_SUBCONTRACTS}; do
echo "Processing multi_contract_caller contract: $contract";
cargo ${{ matrix.job }} --verbose --manifest-path multi_contract_caller/${contract}/Cargo.toml;
done
for contract in ${UPGRADEABLE_CONTRACTS}; do
echo "Processing upgradeable contract: $contract";
cargo ${{ matrix.job }} --verbose --manifest-path=upgradeable-contracts/$contract/Cargo.toml;
for contract in ${MULTI_CONTRACT_CALLER_SUBCONTRACTS}; do
echo "Processing multi-contract-caller contract: $contract";
cargo ${{ matrix.job }} --verbose --manifest-path multi-contract-caller/${contract}/Cargo.toml;
done
cargo ${{ matrix.job }} --verbose --manifest-path=upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml;
cargo ${{ matrix.job }} --verbose --manifest-path=set-code-hash/updated-incrementer/Cargo.toml;
cargo ${{ matrix.job }} --verbose --manifest-path=conditional-compilation/Cargo.toml --features=foo;
cargo ${{ matrix.job }} --verbose --manifest-path=conditional-compilation/Cargo.toml --features=bar;
cargo ${{ matrix.job }} --verbose --manifest-path=conditional-compilation/Cargo.toml --features="foo, bar";
for example in ./*/; do
if [ "$example" = "./upgradeable-contracts/" ]; then continue; fi;
if [ "$example" = "./artifacts/" ]; then continue; fi;
echo "Processing example: $example";
cargo ${{ matrix.job }} --verbose --manifest-path=$example/Cargo.toml;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions ...deable-contracts/forward-calls/Cargo.toml → rand-extension/Cargo.toml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
[package]
name = "forward_calls"
name = "rand_extension"
version = "4.3.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
publish = false

[dependencies]
ink = { version = "4.3", default-features = false }
ink = { version = "4.3.0", 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"], optional = true }

[lib]
name = "forward_calls"
path = "lib.rs"

[features]
Expand Down
26 changes: 0 additions & 26 deletions rand-extension/contract/Cargo.toml

This file was deleted.

37 changes: 34 additions & 3 deletions rand-extension/contract/lib.rs → rand-extension/lib.rs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
#![cfg_attr(not(feature = "std"), no_std, no_main)]

use ink::env::Environment;
use rand_extension::FetchRandom;

/// This is an example of how an ink! contract may call the Substrate
/// runtime function `RandomnessCollectiveFlip::random_seed`. See the
/// file `runtime/chain-extension-example.rs` for that implementation.
///
/// Here we define the operations to interact with the Substrate runtime.
#[ink::chain_extension]
pub trait FetchRandom {
type ErrorCode = RandomReadErr;

/// Note: this gives the operation a corresponding `func_id` (1101 in this case),
/// and the chain-side chain extension will get the `func_id` to do further
/// operations.
#[ink(extension = 1101)]
fn fetch_random(subject: [u8; 32]) -> [u8; 32];
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum RandomReadErr {
FailGetRandomSource,
}

impl ink::env::chain_extension::FromStatusCode for RandomReadErr {
fn from_status_code(status_code: u32) -> Result<(), Self> {
match status_code {
0 => Ok(()),
1 => Err(Self::FailGetRandomSource),
_ => panic!("encountered unknown status code"),
}
}
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
Expand All @@ -21,8 +52,8 @@ impl Environment for CustomEnvironment {
}

#[ink::contract(env = crate::CustomEnvironment)]
mod rand_contract {
use rand_extension::RandomReadErr;
mod rand_extension {
use super::RandomReadErr;

/// Defines the storage of our contract.
///
Expand Down
20 changes: 0 additions & 20 deletions rand-extension/rand_extension/Cargo.toml

This file was deleted.

33 changes: 0 additions & 33 deletions rand-extension/rand_extension/src/lib.rs

This file was deleted.

File renamed without changes.
8 changes: 4 additions & 4 deletions set_code_hash/lib.rs → set-code-hash/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! to swap out the `code_hash` of an on-chain contract.
//!
//! We will swap the code of our `Incrementer` contract with that of the an `Incrementer`
//! found in the `updated_incrementer` folder.
//! found in the `updated-incrementer` folder.
//!
//! See the included End-to-End tests an example update workflow.

Expand Down Expand Up @@ -72,7 +72,7 @@ pub mod incrementer {

type E2EResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;

#[ink_e2e::test(additional_contracts = "./updated_incrementer/Cargo.toml")]
#[ink_e2e::test(additional_contracts = "./updated-incrementer/Cargo.toml")]
async fn set_code_works(mut client: ink_e2e::Client<C, E>) -> E2EResult<()> {
// Given
let constructor = IncrementerRef::new();
Expand Down Expand Up @@ -101,9 +101,9 @@ pub mod incrementer {

// When
let new_code_hash = client
.upload("updated_incrementer", &ink_e2e::alice(), None)
.upload("updated-incrementer", &ink_e2e::alice(), None)
.await
.expect("uploading `updated_incrementer` failed")
.expect("uploading `updated-incrementer` failed")
.code_hash;

let new_code_hash = new_code_hash.as_ref().try_into().unwrap();
Expand Down
File renamed without changes.
29 changes: 0 additions & 29 deletions upgradeable-contracts/README.md

This file was deleted.

9 changes: 0 additions & 9 deletions upgradeable-contracts/forward-calls/.gitignore

This file was deleted.

40 changes: 0 additions & 40 deletions upgradeable-contracts/forward-calls/README.md

This file was deleted.

Loading

0 comments on commit 616ac4c

Please sign in to comment.