Skip to content

Introduce entrance crate #1223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 62 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
08abcab
Add ink entrance crate
ascjones Apr 22, 2022
97ad149
Use entrance crate from lang codegen
ascjones Apr 22, 2022
2c3fa98
Use entrance crate for ink_storage
ascjones Apr 22, 2022
48093c4
Update primitives and storage
ascjones Apr 22, 2022
80b734b
Fix primitive macro
ascjones Apr 22, 2022
ef47e73
Move unique_topics test to ink crate
ascjones May 3, 2022
7837470
Merge branch 'master' into aj/ink_crate
ascjones Sep 7, 2022
14d97cf
Update ink crate versions
ascjones Sep 7, 2022
b9795be
Use umbrella crate in ink primitives macro
ascjones Sep 7, 2022
69287ea
Use umbrella crate in storage derive macros
ascjones Sep 7, 2022
1d4df5b
Use umbrella crate in storage doc tests
ascjones Sep 7, 2022
0f0cfc7
Use umbrella crate in lang codegen
ascjones Sep 7, 2022
cd01574
Fix storage doc tests
ascjones Sep 7, 2022
df60392
Update erc20 example
ascjones Sep 7, 2022
4ecf551
Remove scale libs from entrance crate
ascjones Sep 7, 2022
ee819ed
Rename ink_lang crate to ink
ascjones Sep 7, 2022
6f321c5
Reexport sub crates from main ink crate
ascjones Sep 7, 2022
ce6c0fc
Metadata std
ascjones Sep 7, 2022
90c9465
Fix up some examples
ascjones Sep 7, 2022
5658f6e
Fix up delegator example
ascjones Sep 7, 2022
dc9c098
Fix up more examples
ascjones Sep 8, 2022
92e904c
Fix up more examples
ascjones Sep 8, 2022
64827dc
Fix up more examples
ascjones Sep 8, 2022
8b24da7
Remove some ink_lang as ink from tests
ascjones Sep 8, 2022
a25068f
Update env_access docs
ascjones Sep 8, 2022
e2799ee
Fix up more doc examples
ascjones Sep 8, 2022
6dabd38
Remove ink_lang import from some tests
ascjones Sep 8, 2022
93e69e9
UI tests
ascjones Sep 8, 2022
c8c8ee8
Fix UI tests
ascjones Sep 8, 2022
73600ee
Remove more ink_lang aliases
ascjones Sep 8, 2022
0d23e2e
Fix contract-terminate tests
ascjones Sep 8, 2022
58dfca7
Fmt
ascjones Sep 8, 2022
d2b4a04
Attempt to fix CI and ARCHITECTURE doc
ascjones Sep 8, 2022
e5456db
Update crates list
ascjones Sep 8, 2022
893ac29
Restore unique_topics test
ascjones Sep 8, 2022
53e23d3
Remove ink_lang from unique_topics test
ascjones Sep 8, 2022
01b77ef
Merge branch 'master' into aj/ink_crate
ascjones Sep 14, 2022
279d391
Fix typo
ascjones Sep 14, 2022
dae2853
UI tests
ascjones Sep 15, 2022
9ec9898
Merge branch 'master' into aj/ink_crate
ascjones Sep 15, 2022
e757e46
UI tests
ascjones Sep 15, 2022
c832c5e
Fmt examples
ascjones Sep 15, 2022
063d657
Fmt UI tests
ascjones Sep 15, 2022
26b63ee
More fmt UI tests
ascjones Sep 15, 2022
23b7dc0
Fix storage tests
ascjones Sep 15, 2022
4012149
Fix example tests
ascjones Sep 15, 2022
8e43dfe
Fix examplesl
ascjones Sep 15, 2022
a5bb59b
Fix example test
ascjones Sep 15, 2022
bab514b
Examples fmt
ascjones Sep 15, 2022
1602558
Fix erc20
ascjones Sep 15, 2022
e012496
Fmt erc20
ascjones Sep 15, 2022
fcc8fc1
Fix doc test
ascjones Sep 15, 2022
bc61621
Move unique_topics test
ascjones Sep 15, 2022
702272c
Fix UI tests
ascjones Sep 15, 2022
6d78718
Revert CHANGELOG.md
ascjones Sep 15, 2022
d26e1b1
Use cargo-contract branch in examples-contract-build
ascjones Sep 15, 2022
bbd7688
Add ink-debug feature to top level ink crate
ascjones Sep 15, 2022
27bf307
Update CHANGELOG.md
ascjones Sep 15, 2022
9cd7f4f
Rename all ink_lang_* crates to ink_*
ascjones Sep 15, 2022
b60bb60
Replace remaining ink_lang_macro refs
ascjones Sep 15, 2022
8ad695f
Update CHANGELOG.md
ascjones Sep 15, 2022
f523263
Update CHANGELOG
ascjones Sep 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ variables:
# CI_IMAGE is changed to "-:staging" when the CI image gets rebuilt
# read more https://github.com/paritytech/scripts/pull/244
CI_IMAGE: "paritytech/ink-ci-linux:production"
PURELY_STD_CRATES: "lang/codegen storage/traits/codegen metadata engine"
ALSO_WASM_CRATES: "env storage storage/traits storage/traits/derive allocator prelude primitives lang lang/macro lang/ir"
PURELY_STD_CRATES: "ink/codegen storage/traits/codegen metadata engine"
ALSO_WASM_CRATES: "env storage storage/traits storage/traits/derive allocator prelude primitives ink ink/macro ink/ir"
ALL_CRATES: "${PURELY_STD_CRATES} ${ALSO_WASM_CRATES}"
DELEGATOR_SUBCONTRACTS: "accumulator adder subber"
UPGRADEABLE_CONTRACTS: "forward-calls set-code-hash"
Expand Down Expand Up @@ -112,8 +112,8 @@ fmt:
script:
- cargo +nightly fmt --verbose --all -- --check
# For the UI tests we need to disable the license check
- cargo +nightly fmt --verbose --all -- --check ./crates/lang/tests/ui/contract/{pass,fail}/*.rs
- cargo +nightly fmt --verbose --all -- --check ./crates/lang/tests/ui/trait_def/{pass,fail}/*.rs
- cargo +nightly fmt --verbose --all -- --check ./crates/ink/tests/ui/contract/{pass,fail}/*.rs
- cargo +nightly fmt --verbose --all -- --check ./crates/ink/tests/ui/trait_def/{pass,fail}/*.rs
allow_failure: true

examples-fmt:
Expand Down Expand Up @@ -289,7 +289,7 @@ docs:
-p scale-info -p ink_metadata -p ink_env
-p ink_storage -p ink_storage_traits -p ink_storage_codegen -p ink_storage_derive
-p ink_primitives -p ink_prelude
-p ink_lang -p ink_lang_macro -p ink_lang_ir -p ink_lang_codegen
-p ink -p ink_macro -p ink_ir -p ink_codegen
- mv ${CARGO_TARGET_DIR}/doc ./crate-docs
# FIXME: remove me after CI image gets nonroot
- chown -R nonroot:nonroot ./crate-docs
Expand Down Expand Up @@ -367,7 +367,7 @@ examples-contract-build:
<<: *test-refs
script:
- rustup component add rust-src --toolchain stable
- cargo install cargo-contract --version 2.0.0-alpha.1 --force
- cargo install cargo-contract --git https://github.com/paritytech/cargo-contract --branch aj/ink_crate --force
- cargo contract -V
- for example in examples/*/; do
if [ "$example" = "examples/upgradeable-contracts/" ]; then continue; fi;
Expand Down
10 changes: 5 additions & 5 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can find the crate documentation on docs.rs or for our
ink! is composed of a number of crates that are all found in the
`crates/` folder. On a high-level those can be grouped as:

* [`lang`](https://github.com/paritytech/ink/tree/master/crates/lang):
* [`ink`](https://github.com/paritytech/ink/tree/master/crates/ink):
The ink! language itself.
* [`allocator`](https://github.com/paritytech/ink/tree/master/crates/allocator):
The allocator used for dynamic memory allocation in a contract.
Expand Down Expand Up @@ -70,11 +70,11 @@ The central delegating crate for the ink! eDSL is `ink_lang`.
In the `crates/lang/` folder you'll find three separate
crates on which `ink_lang` relies heavily:

* `ink_lang_macro`: The procedural macros, they take code annotated with e.g.
`[ink::contract]` and forwards it to `ink_lang_ir`.
* `ink_lang_ir`: Defines everything the procedural macro needs in order to
* `ink_macro`: The procedural macros, they take code annotated with e.g.
`[ink::contract]` and forwards it to `ink_ir`.
* `ink_ir`: Defines everything the procedural macro needs in order to
parse, analyze and generate code for ink! smart contracts.
* `ink_lang_codegen`: Generates Rust code from the ink! IR.
* `ink_codegen`: Generates Rust code from the ink! IR.

## Building ink! contracts

Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Breaking Changes

#### New `ink` crate
The `ink_lang` crate has been replaced in [#1223](https://github.com/paritytech/ink/pull/1223) by a new top level `ink`
crate. All existing sub-crates are reexported and should be used via the new `ink` crate, so e.g. `ink::env` instead of
`ink_env`. Contract authors should now import the top level `ink` crate instead of the individual crates.

##### Migration
- In `Cargo.toml` Replace all individual `ink_*` crate dependencies with the `ink` crate.
- In the contract source:
- Remove the commonly used `use ink_lang as ink` idiom.
- Replace all usages of individual crates with reexports, e.g. `ink_env` ➜ `ink::env`.

## Version 4.0.0-alpha.1

### Compatibility
Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[workspace]
resolver = "2"
members = [
"crates/ink",
"crates/metadata",
"crates/allocator",
"crates/lang",
"crates/lang/macro",
"crates/lang/ir",
"crates/lang/codegen",
"crates/lang/macro",
"crates/ink",
"crates/ink/macro",
"crates/ink/ir",
"crates/ink/codegen",
"crates/ink/macro",
"crates/prelude",
"crates/primitives",
"crates/engine",
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ It provides methods to
Below you can see the code using the `ink_lang` version of ink!.

```rust
use ink_lang as ink;

#[ink::contract]
mod flipper {
/// The storage of the flipper contract.
Expand Down Expand Up @@ -164,8 +162,7 @@ mod flipper {
#[cfg(test)]
mod tests {
use super::*;
use ink_lang as ink;


#[ink::test]
fn it_works() {
let mut flipper = Flipper::new(false);
Expand Down
2 changes: 1 addition & 1 deletion crates/env/src/call/create_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub mod state {
/// # Note
///
/// This is needed because of conflicting implementations of `From<T> for T`
/// in the generated code of `ink_lang`.
/// in the generated code of `ink`.
pub trait FromAccountId<T>
where
T: Environment,
Expand Down
2 changes: 1 addition & 1 deletion crates/env/src/chain_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! Definitions and utilities for calling chain extension methods.
//!
//! Users should not use these types and definitions directly but rather use the provided
//! `#[ink::chain_extension]` procedural macro defined in the `ink_lang` crate.
//! `#[ink::chain_extension]` procedural macro defined in the `ink` crate.

use crate::{
backend::EnvBackend,
Expand Down
12 changes: 8 additions & 4 deletions crates/lang/Cargo.toml → crates/ink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ink_lang"
name = "ink"
version = "4.0.0-alpha.1"
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
edition = "2021"
Expand All @@ -20,13 +20,13 @@ ink_storage = { version = "4.0.0-alpha.1", path = "../storage", default-features
ink_primitives = { version = "4.0.0-alpha.1", path = "../primitives", default-features = false }
ink_metadata = { version = "4.0.0-alpha.1", path = "../metadata", default-features = false, optional = true }
ink_prelude = { version = "4.0.0-alpha.1", path = "../prelude", default-features = false }
ink_lang_macro = { version = "4.0.0-alpha.1", path = "macro", default-features = false }
ink_macro = { version = "4.0.0-alpha.1", path = "macro", default-features = false }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] }
derive_more = { version = "0.99", default-features = false, features = ["from"] }

[dev-dependencies]
ink_lang_ir = { path = "./ir" }
ink_ir = { path = "./ir" }
ink_metadata = { path = "../metadata", default-features = false }

trybuild = { version = "1.0.60", features = ["diff"] }
Expand All @@ -41,7 +41,11 @@ std = [
"ink_primitives/std",
"ink_env/std",
"ink_storage/std",
"ink_lang_macro/std",
"ink_macro/std",
"scale/std",
]
# Enable contract debug messages via `debug_print!` and `debug_println!`.
ink-debug = [
"ink_env/ink-debug",
]
show-codegen-docs = []
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
[package]
name = "ink_lang_codegen"
name = "ink_codegen"
version = "4.0.0-alpha.1"
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
edition = "2021"

license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/paritytech/ink"
documentation = "https://docs.rs/ink_lang_codegen/"
documentation = "https://docs.rs/ink_codegen/"
homepage = "https://www.parity.io/"
description = "data structures and algorithms for generating ink! IR code"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
categories = ["no-std", "embedded"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]

[lib]
name = "ink_lang_codegen"
name = "ink_codegen"

[dependencies]
ink_primitives = { version = "4.0.0-alpha.1", path = "../../primitives" }
ir = { version = "4.0.0-alpha.1", package = "ink_lang_ir", path = "../ir", default-features = false }
ir = { version = "4.0.0-alpha.1", package = "ink_ir", path = "../ir", default-features = false }
quote = "1"
syn = { version = "1.0", features = ["parsing", "full", "extra-traits"] }
proc-macro2 = "1.0"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ where
{
use syn::spanned::Spanned as _;
args.into_iter().fold(
quote! { ::ink_env::call::utils::EmptyArgumentList },
quote! { ::ink::env::call::utils::EmptyArgumentList },
|rest, arg| {
let span = arg.span();
quote_spanned!(span=>
::ink_env::call::utils::ArgumentList<::ink_env::call::utils::Argument<#arg>, #rest>
::ink::env::call::utils::ArgumentList<::ink::env::call::utils::Argument<#arg>, #rest>
)
}
)
Expand All @@ -98,7 +98,7 @@ pub fn generate_reference_to_trait_info(
trait_path: &syn::Path,
) -> TokenStream2 {
quote_spanned!(span=>
<<::ink_lang::reflect::TraitDefinitionRegistry<Environment>
as #trait_path>::__ink_TraitInfo as ::ink_lang::reflect::TraitInfo>::ID
<<::ink::reflect::TraitDefinitionRegistry<Environment>
as #trait_path>::__ink_TraitInfo as ::ink::reflect::TraitInfo>::ID
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl CallBuilder<'_> {
/// This identifier must not be used outside of the generated `const`
/// block in which the call builder type is going to be defined.
/// In order to refer to the call builder of an ink! smart contract
/// use the [`ink_lang::TraitCallBuilder`] trait implementation.
/// use the [`ink::TraitCallBuilder`] trait implementation.
fn call_builder_ident() -> syn::Ident {
format_ident!("CallBuilder")
}
Expand All @@ -84,7 +84,7 @@ impl CallBuilder<'_> {
#[repr(transparent)]
#[cfg_attr(feature = "std", derive(
::scale_info::TypeInfo,
::ink_storage::traits::StorageLayout,
::ink::storage::traits::StorageLayout,
))]
#[derive(
::core::fmt::Debug,
Expand All @@ -100,12 +100,12 @@ impl CallBuilder<'_> {
}

const _: () = {
impl ::ink_lang::codegen::ContractCallBuilder for #storage_ident {
impl ::ink::codegen::ContractCallBuilder for #storage_ident {
type Type = #cb_ident;
}

impl ::ink_lang::reflect::ContractEnv for #cb_ident {
type Env = <#storage_ident as ::ink_lang::reflect::ContractEnv>::Env;
impl ::ink::reflect::ContractEnv for #cb_ident {
type Env = <#storage_ident as ::ink::reflect::ContractEnv>::Env;
}
};
)
Expand All @@ -119,14 +119,14 @@ impl CallBuilder<'_> {
let span = self.contract.module().storage().span();
let cb_ident = Self::call_builder_ident();
quote_spanned!(span=>
impl ::ink_env::call::FromAccountId<Environment> for #cb_ident {
impl ::ink::env::call::FromAccountId<Environment> for #cb_ident {
#[inline]
fn from_account_id(account_id: AccountId) -> Self {
Self { account_id }
}
}

impl ::ink_lang::ToAccountId<Environment> for #cb_ident {
impl ::ink::ToAccountId<Environment> for #cb_ident {
#[inline]
fn to_account_id(&self) -> AccountId {
<AccountId as ::core::clone::Clone>::clone(&self.account_id)
Expand Down Expand Up @@ -183,8 +183,8 @@ impl CallBuilder<'_> {
let trait_info_id = generator::generate_reference_to_trait_info(span, trait_path);
quote_spanned!(span=>
#[doc(hidden)]
impl ::ink_lang::codegen::TraitCallForwarderFor<{#trait_info_id}> for #cb_ident {
type Forwarder = <<Self as #trait_path>::__ink_TraitInfo as ::ink_lang::codegen::TraitCallForwarder>::Forwarder;
impl ::ink::codegen::TraitCallForwarderFor<{#trait_info_id}> for #cb_ident {
type Forwarder = <<Self as #trait_path>::__ink_TraitInfo as ::ink::codegen::TraitCallForwarder>::Forwarder;

#[inline]
fn forward(&self) -> &Self::Forwarder {
Expand Down Expand Up @@ -213,18 +213,18 @@ impl CallBuilder<'_> {
}

#[inline]
fn build(&self) -> &<Self::Forwarder as ::ink_lang::codegen::TraitCallBuilder>::Builder {
<_ as ::ink_lang::codegen::TraitCallBuilder>::call(
<Self as ::ink_lang::codegen::TraitCallForwarderFor<{#trait_info_id}>>::forward(self)
fn build(&self) -> &<Self::Forwarder as ::ink::codegen::TraitCallBuilder>::Builder {
<_ as ::ink::codegen::TraitCallBuilder>::call(
<Self as ::ink::codegen::TraitCallForwarderFor<{#trait_info_id}>>::forward(self)
)
}

#[inline]
fn build_mut(&mut self)
-> &mut <Self::Forwarder as ::ink_lang::codegen::TraitCallBuilder>::Builder
-> &mut <Self::Forwarder as ::ink::codegen::TraitCallBuilder>::Builder
{
<_ as ::ink_lang::codegen::TraitCallBuilder>::call_mut(
<Self as ::ink_lang::codegen::TraitCallForwarderFor<{#trait_info_id}>>::forward_mut(self)
<_ as ::ink::codegen::TraitCallBuilder>::call_mut(
<Self as ::ink::codegen::TraitCallForwarderFor<{#trait_info_id}>>::forward_mut(self)
)
}
}
Expand All @@ -244,7 +244,7 @@ impl CallBuilder<'_> {
.map(|message| self.generate_ink_trait_impl_for_message(trait_path, message));
quote_spanned!(span=>
impl #trait_path for #cb_ident {
type __ink_TraitInfo = <::ink_lang::reflect::TraitDefinitionRegistry<Environment>
type __ink_TraitInfo = <::ink::reflect::TraitDefinitionRegistry<Environment>
as #trait_path>::__ink_TraitInfo;

#( #messages )*
Expand Down Expand Up @@ -285,8 +285,8 @@ impl CallBuilder<'_> {
quote_spanned!(span=>
type #output_ident = <<<
Self
as ::ink_lang::codegen::TraitCallForwarderFor<{#trait_info_id}>>::Forwarder
as ::ink_lang::codegen::TraitCallBuilder>::Builder
as ::ink::codegen::TraitCallForwarderFor<{#trait_info_id}>>::Forwarder
as ::ink::codegen::TraitCallBuilder>::Builder
as #trait_path>::#output_ident;

#[inline]
Expand All @@ -296,7 +296,7 @@ impl CallBuilder<'_> {
#( , #input_bindings: #input_types )*
) -> Self::#output_ident {
<_ as #trait_path>::#message_ident(
<Self as ::ink_lang::codegen::TraitCallForwarderFor<{#trait_info_id}>>::#build_cmd(self)
<Self as ::ink::codegen::TraitCallForwarderFor<{#trait_info_id}>>::#build_cmd(self)
#( , #input_bindings )*
)
}
Expand Down Expand Up @@ -374,11 +374,11 @@ impl CallBuilder<'_> {
output.map_or_else(|| quote! { () }, |output| quote! { #output });
let output_span = output.span();
let output_type = quote_spanned!(output_span=>
::ink_env::call::CallBuilder<
::ink::env::call::CallBuilder<
Environment,
::ink_env::call::utils::Set< ::ink_env::call::Call< Environment > >,
::ink_env::call::utils::Set< ::ink_env::call::ExecutionInput<#arg_list> >,
::ink_env::call::utils::Set< ::ink_env::call::utils::ReturnType<#return_type> >,
::ink::env::call::utils::Set< ::ink::env::call::Call< Environment > >,
::ink::env::call::utils::Set< ::ink::env::call::ExecutionInput<#arg_list> >,
::ink::env::call::utils::Set< ::ink::env::call::utils::ReturnType<#return_type> >,
>
);
quote_spanned!(span=>
Expand All @@ -389,11 +389,11 @@ impl CallBuilder<'_> {
& #mut_tok self
#( , #input_bindings : #input_types )*
) -> #output_type {
::ink_env::call::build_call::<Environment>()
.call_type(::ink_env::call::Call::new().callee(::ink_lang::ToAccountId::to_account_id(self)))
::ink::env::call::build_call::<Environment>()
.call_type(::ink::env::call::Call::new().callee(::ink::ToAccountId::to_account_id(self)))
.exec_input(
::ink_env::call::ExecutionInput::new(
::ink_env::call::Selector::new([ #( #selector_bytes ),* ])
::ink::env::call::ExecutionInput::new(
::ink::env::call::Selector::new([ #( #selector_bytes ),* ])
)
#(
.push_arg(#input_bindings)
Expand Down
Loading