Skip to content
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

[metadata] update to scale-info 0.3, removes string interning #467

Merged
merged 43 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a9bc0ad
WIP
ascjones Jun 29, 2020
1906faf
WIP
ascjones Jun 30, 2020
b346f31
Iterating on InkProject types
ascjones Jun 30, 2020
ab620b7
Merge branch 'master' into aj-extra-metadata
ascjones Jul 1, 2020
ea0b84b
Extract InkProject to its own file
ascjones Jul 1, 2020
f315b8a
More iteration on contract metadata
ascjones Jul 1, 2020
13b97f3
Merge branch 'master' into aj-extra-metadata
ascjones Jul 2, 2020
0f5765a
Compiles...ship it
ascjones Jul 2, 2020
3016a3e
Fmt
ascjones Jul 2, 2020
9a460a5
Add optional fields and doc test
ascjones Jul 3, 2020
1c36009
Merge branch 'master' into aj-extra-metadata
ascjones Jul 3, 2020
27fd633
Add custom serializer impls for compiler/lang
ascjones Jul 3, 2020
3698478
Fmt
ascjones Jul 3, 2020
eb1e923
Clippy
ascjones Jul 3, 2020
89eb9f3
Update to scale-info 0.3
ascjones Jul 3, 2020
46f7d60
Use &'static str instead of compact string (scale-info 0.3)
ascjones Jul 3, 2020
9278ea2
Reexport Url and Version
ascjones Jul 3, 2020
3f5d65f
Fix missing semicolon
ascjones Jul 3, 2020
bbc6f23
Fix up metadata exports and codegen
ascjones Jul 3, 2020
29d58c9
Serialize hash as byte string
ascjones Jul 3, 2020
161ae9b
Remove spec nesting
ascjones Jul 3, 2020
c68032e
Remove name from contract spec
ascjones Jul 3, 2020
8832d10
Add name to storage struct
ascjones Jul 6, 2020
f33617c
Flatten SourceCompiler
ascjones Jul 6, 2020
6700528
Implement ToTokens for Extension metadata
ascjones Jul 7, 2020
725b2cd
User and Version
ascjones Jul 7, 2020
8ccdfa2
Fix up builder ToTokens and other errs/warns
ascjones Jul 7, 2020
134bb7b
Fmt
ascjones Jul 7, 2020
41438d1
Url wrapper
ascjones Jul 7, 2020
c4d3015
Comment and Version/Url intos
ascjones Jul 7, 2020
f2d28b8
Fmt
ascjones Jul 7, 2020
71b76b6
Fix U
ascjones Jul 7, 2020
cbc17b4
Promote extension to module dir
ascjones Jul 7, 2020
2cf8ee4
Moved InkProjectExtension to cargo-contract
ascjones Jul 8, 2020
f13b888
Fix doc gen
ascjones Jul 8, 2020
8cd94a3
Merge branch 'master' into aj-extra-metadata
ascjones Jul 8, 2020
ad7e5b4
Fix json tests
ascjones Jul 13, 2020
3d3e7f1
Use pretty assertions and fix layout json tests
ascjones Jul 13, 2020
de7cff1
Remove storage name from layout (ink specific)
ascjones Jul 15, 2020
a32fb3a
StorageLayout -> Layout
ascjones Jul 15, 2020
e6c3587
Remove redundant contract_ident_lit
ascjones Jul 15, 2020
5d6b9b4
Remove redundant dependencies
ascjones Jul 15, 2020
06352f7
Use Self instead of InkProject
ascjones Jul 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ publish-docs:
- git fetch origin gh-pages
# Generating Docs
- time cargo doc --no-deps --all-features
-p scale-info -p ink_metadata -p ink_metadata_derive -p ink_core -p ink_core_derive
-p scale-info -p ink_metadata -p ink_core -p ink_core_derive
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fix the master branch CI

-p ink_primitives -p ink_prelude -p ink_lang -p ink_lang_macro
# saving README and docs
- mv target/doc/ /tmp/
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ blake2 = { version = "0.9", optional = true }
# Sadly couldn't be marked as dev-dependency.
# Never use this crate outside of the off-chain environment!
rand = { version = "0.7", default-features = false, features = ["alloc"], optional = true }
scale-info = { version = "0.2", default-features = false, features = ["derive"], optional = true }
scale-info = { version = "0.3", default-features = false, features = ["derive"], optional = true }

# Workaround: we actually just need criterion as a dev-dependency, but
# there is an issue with a doubly included std lib when executing
Expand Down
2 changes: 1 addition & 1 deletion examples/delegator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ scale = { package = "parity-scale-codec", version = "1.3", default-features = fa
adder = { version = "2.1.0", path = "adder", default-features = false, features = ["ink-as-dependency"] }
subber = { version = "2.1.0", path = "subber", default-features = false, features = ["ink-as-dependency"] }
accumulator = { version = "2.1.0", path = "accumulator", default-features = false, features = ["ink-as-dependency"] }
scale-info = { version = "0.2", default-features = false, features = ["derive"], optional = true }
scale-info = { version = "0.3", default-features = false, features = ["derive"], optional = true }

[lib]
name = "delegator"
Expand Down
2 changes: 1 addition & 1 deletion examples/delegator/accumulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ink_core = { version = "2.1.0", path = "../../../core", default-features = false
ink_lang = { version = "2.1.0", path = "../../../lang", default-features = false }

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

[lib]
name = "accumulator"
Expand Down
2 changes: 1 addition & 1 deletion examples/delegator/adder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ink_lang = { version = "2.1.0", path = "../../../lang", default-features = false
accumulator = { version = "2.1.0", path = "../accumulator", default-features = false, features = ["ink-as-dependency"] }

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

[lib]
name = "adder"
Expand Down
2 changes: 1 addition & 1 deletion examples/delegator/subber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ink_lang = { version = "2.1.0", path = "../../../lang", default-features = false
accumulator = { version = "2.1.0", path = "../accumulator", default-features = false, features = ["ink-as-dependency"] }

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

[lib]
name = "subber"
Expand Down
2 changes: 1 addition & 1 deletion examples/dns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ink_core = { version = "2.1.0", path = "../../core", default-features = false }
ink_lang = { version = "2.1.0", path = "../../lang", default-features = false }

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

[lib]
name = "dns"
Expand Down
2 changes: 1 addition & 1 deletion examples/erc20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ink_core = { version = "2.1.0", path = "../../core", default-features = false }
ink_lang = { version = "2.1.0", path = "../../lang", default-features = false }

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

[lib]
name = "erc20"
Expand Down
2 changes: 1 addition & 1 deletion examples/erc721/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ink_core = { version = "2.1.0", path = "../../core", default-features = false }
ink_lang = { version = "2.1.0", path = "../../lang", default-features = false }

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

[lib]
name = "erc721"
Expand Down
2 changes: 1 addition & 1 deletion examples/flipper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ink_core = { version = "2.1.0", path = "../../core", default-features = false }
ink_lang = { version = "2.1.0", path = "../../lang", default-features = false }

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

[lib]
name = "flipper"
Expand Down
2 changes: 1 addition & 1 deletion examples/incrementer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ink_core = { version = "2.1.0", path = "../../core", default-features = false }
ink_lang = { version = "2.1.0", path = "../../lang", default-features = false }

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

[lib]
name = "incrementer"
Expand Down
2 changes: 1 addition & 1 deletion examples/multisig_plain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ink_lang = { version = "2.1.0", path = "../../lang", default-features = false }
ink_prelude = { version = "2.1.0", path = "../../prelude", default-features = false }

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

[lib]
name = "multisig_plain"
Expand Down
2 changes: 1 addition & 1 deletion examples/runtime-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ink_core = { version = "2.1.0", path = "../../core", default-features = false }
ink_lang = { version = "2.1.0", path = "../../lang", default-features = false }

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

[lib]
name = "runtime_storage"
Expand Down
2 changes: 1 addition & 1 deletion lang/macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ink_lang = { version = "2.1.0", path = ".." }

trybuild = "1.0.24"
pretty_assertions = "0.6.1"
scale-info = { version = "0.2", default-features = false, features = ["derive"] }
scale-info = { version = "0.3", default-features = false, features = ["derive"] }

[lib]
name = "ink_lang_macro"
Expand Down
4 changes: 1 addition & 3 deletions lang/macro/src/codegen/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,13 @@ impl GenerateMetadata<'_> {
}

fn generate_contract(&self) -> TokenStream2 {
let contract_ident_lit = self.contract.ident.to_string();

let constructors = self.generate_constructors();
let messages = self.generate_messages();
let events = self.generate_events();
let docs = self.generate_docs();

quote! {
::ink_metadata::ContractSpec::new(#contract_ident_lit)
::ink_metadata::ContractSpec::new()
.constructors(vec![
#(#constructors ,)*
])
Expand Down
4 changes: 2 additions & 2 deletions metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ ink_primitives = { version = "2.1.0", path = "../primitives/", default-features

serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] }
derive_more = { version = "0.99", default-features = false, features = ["from"] }
scale-info = { version = "0.2", default-features = false, features = ["derive"] }
scale-info = { version = "0.3", default-features = false, features = ["derive"] }

[dev-dependencies]
pretty_assertions = "0.6.1"
serde_json = "1.0"
assert-json-diff = "1.0.1"

[features]
default = [
Expand Down
6 changes: 3 additions & 3 deletions metadata/src/layout2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub struct FieldLayout<F: Form = MetaForm> {
/// The name of the field.
///
/// Can be missing, e.g. in case of an enum tuple struct variant.
name: Option<F::String>,
name: Option<&'static str>,
/// The kind of the field.
///
/// This is either a direct layout bound
Expand All @@ -312,7 +312,7 @@ impl FieldLayout {
/// Creates a new field layout.
pub fn new<N, L>(name: N, layout: L) -> Self
where
N: Into<Option<<MetaForm as Form>::String>>,
N: Into<Option<&'static str>>,
L: Into<Layout>,
{
Self {
Expand All @@ -327,7 +327,7 @@ impl IntoCompact for FieldLayout {

fn into_compact(self, registry: &mut Registry) -> Self::Output {
FieldLayout {
name: self.name.map(|name| registry.register_string(name)),
name: self.name,
layout: self.layout.into_compact(registry),
}
}
Expand Down
9 changes: 5 additions & 4 deletions metadata/src/layout2/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use super::*;
use ink_primitives::KeyPtr;
use pretty_assertions::assert_eq;

#[test]
fn layout_key_works() {
Expand Down Expand Up @@ -60,7 +61,7 @@ fn named_fields_work() {
"ty": 1,
}
},
"name": 1,
"name": "a",
},
{
"layout": {
Expand All @@ -73,7 +74,7 @@ fn named_fields_work() {
"ty": 2,
}
},
"name": 2,
"name": "b",
}
]
}
Expand Down Expand Up @@ -293,7 +294,7 @@ fn mixed_enum_work() {
"ty": 1,
}
},
"name": 1,
"name": "a",
},
{
"layout": {
Expand All @@ -306,7 +307,7 @@ fn mixed_enum_work() {
"ty": 2,
}
},
"name": 2,
"name": "b",
}
],
},
Expand Down
8 changes: 5 additions & 3 deletions metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub use self::specs::{
ReturnTypeSpec,
TypeSpec,
};

#[cfg(feature = "derive")]
use scale_info::{
form::CompactForm,
Expand All @@ -49,24 +50,25 @@ use scale_info::{
};
use serde::Serialize;

/// An entire ink! project for ABI file generation purposes.
/// An entire ink! project for metadata file generation purposes.
#[derive(Debug, Serialize)]
pub struct InkProject {
#[serde(flatten)]
registry: Registry,
#[serde(rename = "storage")]
/// The layout of the storage data structure
layout: layout2::Layout<CompactForm>,
#[serde(rename = "contract")]
spec: ContractSpec<CompactForm>,
}

impl InkProject {
/// Creates a new ink! project.
pub fn new<L, S>(layout: L, spec: S) -> Self
where
L: Into<layout2::Layout>,
S: Into<ContractSpec>,
{
let mut registry = Registry::new();

Self {
layout: layout.into().into_compact(&mut registry),
spec: spec.into().into_compact(&mut registry),
Expand Down
Loading