Unverified Commit af1ab521 authored by Andrew Jones's avatar Andrew Jones Committed by GitHub
Browse files

[abi] update to scale-info v0.2 (#454)

* Update to latest scale-info

* scale-info 0.2

* Merge branch 'master' into aj-update-scale-info

# Conflicts:
#	primitives/src/key.rs

* Fmt
parent d095dd07
Pipeline #97182 failed with stages
in 11 minutes and 17 seconds
...@@ -20,7 +20,7 @@ ink_primitives = { version = "2.1.0", path = "../primitives/", default-features ...@@ -20,7 +20,7 @@ ink_primitives = { version = "2.1.0", path = "../primitives/", default-features
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] }
derive_more = { version = "0.99", default-features = false, features = ["from"] } derive_more = { version = "0.99", default-features = false, features = ["from"] }
scale-info = { version = "0.1", default-features = false, features = ["derive"] } scale-info = { version = "0.2", default-features = false, features = ["derive"] }
[dev-dependencies] [dev-dependencies]
serde_json = "1.0" serde_json = "1.0"
......
...@@ -25,9 +25,10 @@ use scale_info::{ ...@@ -25,9 +25,10 @@ use scale_info::{
Form, Form,
MetaForm, MetaForm,
}, },
meta_type,
IntoCompact, IntoCompact,
Metadata,
Registry, Registry,
TypeInfo,
}; };
/// Represents the static storage layout of an ink! smart contract. /// Represents the static storage layout of an ink! smart contract.
...@@ -93,11 +94,11 @@ impl CellLayout { ...@@ -93,11 +94,11 @@ impl CellLayout {
/// Creates a new cell layout. /// Creates a new cell layout.
pub fn new<T>(key: LayoutKey) -> Self pub fn new<T>(key: LayoutKey) -> Self
where where
T: Metadata, T: TypeInfo + 'static,
{ {
Self { Self {
key, key,
ty: <T as Metadata>::meta_type(), ty: meta_type::<T>(),
} }
} }
} }
......
...@@ -28,9 +28,10 @@ use scale_info::{ ...@@ -28,9 +28,10 @@ use scale_info::{
Form, Form,
MetaForm, MetaForm,
}, },
meta_type,
IntoCompact, IntoCompact,
Metadata,
Registry, Registry,
TypeInfo,
}; };
use serde::Serialize; use serde::Serialize;
...@@ -602,7 +603,7 @@ impl TypeSpec { ...@@ -602,7 +603,7 @@ impl TypeSpec {
/// Panics if the given display name is invalid. /// Panics if the given display name is invalid.
pub fn with_name_str<T>(display_name: &'static str) -> Self pub fn with_name_str<T>(display_name: &'static str) -> Self
where where
T: Metadata, T: TypeInfo + 'static,
{ {
Self::with_name_segs::<T, _>(display_name.split("::")) Self::with_name_segs::<T, _>(display_name.split("::"))
} }
...@@ -621,11 +622,11 @@ impl TypeSpec { ...@@ -621,11 +622,11 @@ impl TypeSpec {
/// Panics if the given display name is invalid. /// Panics if the given display name is invalid.
pub fn with_name_segs<T, S>(segments: S) -> Self pub fn with_name_segs<T, S>(segments: S) -> Self
where where
T: Metadata, T: TypeInfo + 'static,
S: IntoIterator<Item = <MetaForm as Form>::String>, S: IntoIterator<Item = <MetaForm as Form>::String>,
{ {
Self { Self {
id: T::meta_type(), id: meta_type::<T>(),
display_name: DisplayName::from_segments(segments) display_name: DisplayName::from_segments(segments)
.expect("display name is invalid"), .expect("display name is invalid"),
} }
...@@ -634,10 +635,10 @@ impl TypeSpec { ...@@ -634,10 +635,10 @@ impl TypeSpec {
/// Creates a new type specification without a display name. /// Creates a new type specification without a display name.
pub fn new<T>() -> Self pub fn new<T>() -> Self
where where
T: Metadata, T: TypeInfo + 'static,
{ {
Self { Self {
id: T::meta_type(), id: meta_type::<T>(),
display_name: DisplayName::default(), display_name: DisplayName::default(),
} }
} }
......
...@@ -39,7 +39,7 @@ blake2 = { version = "0.9", optional = true } ...@@ -39,7 +39,7 @@ blake2 = { version = "0.9", optional = true }
# Sadly couldn't be marked as dev-dependency. # Sadly couldn't be marked as dev-dependency.
# Never use this crate outside of the off-chain environment! # Never use this crate outside of the off-chain environment!
rand = { version = "0.7", default-features = false, features = ["alloc"], optional = true } rand = { version = "0.7", default-features = false, features = ["alloc"], optional = true }
scale-info = { version = "0.1", default-features = false, features = ["derive"], optional = true } scale-info = { version = "0.2", default-features = false, features = ["derive"], optional = true }
[dev-dependencies] [dev-dependencies]
itertools = "0.9" itertools = "0.9"
......
...@@ -46,7 +46,7 @@ use scale::{ ...@@ -46,7 +46,7 @@ use scale::{
Encode, Encode,
}; };
#[cfg(feature = "std")] #[cfg(feature = "std")]
use scale_info::Metadata; use scale_info::TypeInfo;
/// Types that allow for simple arithmetic operations. /// Types that allow for simple arithmetic operations.
/// ///
...@@ -178,7 +178,7 @@ where ...@@ -178,7 +178,7 @@ where
/// The fundamental types of the default configuration. /// The fundamental types of the default configuration.
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Metadata))] #[cfg_attr(feature = "std", derive(TypeInfo))]
pub enum DefaultEnvTypes {} pub enum DefaultEnvTypes {}
impl EnvTypes for DefaultEnvTypes { impl EnvTypes for DefaultEnvTypes {
...@@ -252,7 +252,7 @@ impl scale::Decode for Call { ...@@ -252,7 +252,7 @@ impl scale::Decode for Call {
From, From,
Default, Default,
)] )]
#[cfg_attr(feature = "std", derive(Metadata))] #[cfg_attr(feature = "std", derive(TypeInfo))]
pub struct AccountId([u8; 32]); pub struct AccountId([u8; 32]);
impl<'a> TryFrom<&'a [u8]> for AccountId { impl<'a> TryFrom<&'a [u8]> for AccountId {
...@@ -284,7 +284,7 @@ impl<'a> TryFrom<&'a [u8]> for AccountId { ...@@ -284,7 +284,7 @@ impl<'a> TryFrom<&'a [u8]> for AccountId {
From, From,
Default, Default,
)] )]
#[cfg_attr(feature = "std", derive(Metadata))] #[cfg_attr(feature = "std", derive(TypeInfo))]
pub struct Hash([u8; 32]); pub struct Hash([u8; 32]);
impl<'a> TryFrom<&'a [u8]> for Hash { impl<'a> TryFrom<&'a [u8]> for Hash {
......
...@@ -33,7 +33,7 @@ use ink_primitives::Key; ...@@ -33,7 +33,7 @@ use ink_primitives::Key;
#[derive( #[derive(
Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, scale::Encode, scale::Decode, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, scale::Encode, scale::Decode,
)] )]
#[cfg_attr(feature = "std", derive(scale_info::Metadata))] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub struct DynamicAllocation(pub(super) u32); pub struct DynamicAllocation(pub(super) u32);
impl DynamicAllocation { impl DynamicAllocation {
......
...@@ -19,7 +19,7 @@ use core::ops::{ ...@@ -19,7 +19,7 @@ use core::ops::{
/// Stores the number of set bits for each 256-bits block in a compact `u8`. /// Stores the number of set bits for each 256-bits block in a compact `u8`.
#[derive(Debug, Default, PartialEq, Eq, scale::Encode, scale::Decode)] #[derive(Debug, Default, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::Metadata))] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub struct CountFree { pub struct CountFree {
/// Set bits per 256-bit chunk. /// Set bits per 256-bit chunk.
counts: [u8; 32], counts: [u8; 32],
...@@ -44,7 +44,7 @@ impl IndexMut<u8> for CountFree { ...@@ -44,7 +44,7 @@ impl IndexMut<u8> for CountFree {
} }
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::Metadata))] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub struct FullMask(u32); pub struct FullMask(u32);
impl FullMask { impl FullMask {
......
...@@ -22,7 +22,7 @@ use super::{ ...@@ -22,7 +22,7 @@ use super::{
/// A chunk of 256 bits. /// A chunk of 256 bits.
#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] #[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::Metadata))] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub struct Bits256 { pub struct Bits256 {
bits: [Bits64; 4], bits: [Bits64; 4],
} }
......
...@@ -90,7 +90,7 @@ where ...@@ -90,7 +90,7 @@ where
/// ///
/// Stores the value as well as the index to its associated key. /// Stores the value as well as the index to its associated key.
#[derive(Debug, scale::Encode, scale::Decode)] #[derive(Debug, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::Metadata))] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
struct ValueEntry<V> { struct ValueEntry<V> {
/// The value stored in this entry. /// The value stored in this entry.
value: V, value: V,
......
...@@ -48,12 +48,12 @@ const _: () = { ...@@ -48,12 +48,12 @@ const _: () = {
Layout, Layout,
StructLayout, StructLayout,
}; };
use scale_info::Metadata; use scale_info::TypeInfo;
impl<K, V, H> StorageLayout for StorageHashMap<K, V, H> impl<K, V, H> StorageLayout for StorageHashMap<K, V, H>
where where
K: Metadata + Ord + Clone + PackedLayout + 'static, K: TypeInfo + Ord + Clone + PackedLayout + 'static,
V: Metadata + PackedLayout + 'static, V: TypeInfo + PackedLayout + 'static,
H: LayoutCryptoHasher + Hasher, H: LayoutCryptoHasher + Hasher,
Key: From<<H as Hasher>::Output>, Key: From<<H as Hasher>::Output>,
{ {
......
...@@ -34,11 +34,11 @@ const _: () = { ...@@ -34,11 +34,11 @@ const _: () = {
Layout, Layout,
StructLayout, StructLayout,
}; };
use scale_info::Metadata; use scale_info::TypeInfo;
impl<T, N> StorageLayout for SmallVec<T, N> impl<T, N> StorageLayout for SmallVec<T, N>
where where
T: PackedLayout + Metadata, T: PackedLayout + TypeInfo + 'static,
N: LazyArrayLength<T>, N: LazyArrayLength<T>,
{ {
fn layout(key_ptr: &mut KeyPtr) -> Layout { fn layout(key_ptr: &mut KeyPtr) -> Layout {
......
...@@ -54,7 +54,7 @@ where ...@@ -54,7 +54,7 @@ where
/// Stores general commonly required information about the storage stash. /// Stores general commonly required information about the storage stash.
#[derive(Debug, scale::Encode, scale::Decode)] #[derive(Debug, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::Metadata))] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
struct Header { struct Header {
/// The latest vacant index. /// The latest vacant index.
/// ///
...@@ -76,7 +76,7 @@ struct Header { ...@@ -76,7 +76,7 @@ struct Header {
/// A vacant entry with previous and next vacant indices. /// A vacant entry with previous and next vacant indices.
#[derive(Debug, Copy, Clone, scale::Encode, scale::Decode)] #[derive(Debug, Copy, Clone, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::Metadata))] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub struct VacantEntry { pub struct VacantEntry {
/// The next vacant index. /// The next vacant index.
next: Index, next: Index,
...@@ -89,7 +89,7 @@ pub struct VacantEntry { ...@@ -89,7 +89,7 @@ pub struct VacantEntry {
/// The vacant entries within a storage stash form a doubly linked list of /// The vacant entries within a storage stash form a doubly linked list of
/// vacant entries that is used to quickly re-use their vacant storage. /// vacant entries that is used to quickly re-use their vacant storage.
#[derive(Debug, scale::Encode, scale::Decode)] #[derive(Debug, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::Metadata))] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum Entry<T> { pub enum Entry<T> {
/// A vacant entry that holds the index to the next and previous vacant entry. /// A vacant entry that holds the index to the next and previous vacant entry.
Vacant(VacantEntry), Vacant(VacantEntry),
......
...@@ -45,7 +45,7 @@ const _: () = { ...@@ -45,7 +45,7 @@ const _: () = {
LayoutKey, LayoutKey,
StructLayout, StructLayout,
}; };
use scale_info::Metadata; use scale_info::TypeInfo;
impl StorageLayout for Header { impl StorageLayout for Header {
fn layout(key_ptr: &mut KeyPtr) -> Layout { fn layout(key_ptr: &mut KeyPtr) -> Layout {
...@@ -57,7 +57,7 @@ const _: () = { ...@@ -57,7 +57,7 @@ const _: () = {
impl<T> StorageLayout for StorageStash<T> impl<T> StorageLayout for StorageStash<T>
where where
T: PackedLayout + Metadata + 'static, T: PackedLayout + TypeInfo + 'static,
{ {
fn layout(key_ptr: &mut KeyPtr) -> Layout { fn layout(key_ptr: &mut KeyPtr) -> Layout {
Layout::Struct(StructLayout::new(vec![ Layout::Struct(StructLayout::new(vec![
......
...@@ -35,11 +35,11 @@ const _: () = { ...@@ -35,11 +35,11 @@ const _: () = {
Layout, Layout,
StructLayout, StructLayout,
}; };
use scale_info::Metadata; use scale_info::TypeInfo;
impl<T> StorageLayout for StorageVec<T> impl<T> StorageLayout for StorageVec<T>
where where
T: PackedLayout + Metadata, T: PackedLayout + TypeInfo + 'static,
{ {
fn layout(key_ptr: &mut KeyPtr) -> Layout { fn layout(key_ptr: &mut KeyPtr) -> Layout {
Layout::Struct(StructLayout::new(vec![ Layout::Struct(StructLayout::new(vec![
......
...@@ -96,11 +96,11 @@ const _: () = { ...@@ -96,11 +96,11 @@ const _: () = {
Layout, Layout,
LayoutKey, LayoutKey,
}; };
use scale_info::Metadata; use scale_info::TypeInfo;
impl<T, N> StorageLayout for LazyArray<T, N> impl<T, N> StorageLayout for LazyArray<T, N>
where where
T: Metadata, T: TypeInfo + 'static,
N: LazyArrayLength<T>, N: LazyArrayLength<T>,
{ {
fn layout(key_ptr: &mut KeyPtr) -> Layout { fn layout(key_ptr: &mut KeyPtr) -> Layout {
......
...@@ -160,12 +160,12 @@ const _: () = { ...@@ -160,12 +160,12 @@ const _: () = {
Layout, Layout,
LayoutKey, LayoutKey,
}; };
use scale_info::Metadata; use scale_info::TypeInfo;
impl<K, V, H> StorageLayout for LazyHashMap<K, V, H> impl<K, V, H> StorageLayout for LazyHashMap<K, V, H>
where where
K: Ord + scale::Encode, K: Ord + scale::Encode,
V: Metadata, V: TypeInfo + 'static,
H: Hasher + LayoutCryptoHasher, H: Hasher + LayoutCryptoHasher,
Key: From<<H as Hasher>::Output>, Key: From<<H as Hasher>::Output>,
{ {
......
...@@ -206,11 +206,11 @@ const _: () = { ...@@ -206,11 +206,11 @@ const _: () = {
Layout, Layout,
LayoutKey, LayoutKey,
}; };
use scale_info::Metadata; use scale_info::TypeInfo;
impl<T> StorageLayout for LazyIndexMap<T> impl<T> StorageLayout for LazyIndexMap<T>
where where
T: Metadata, T: TypeInfo + 'static,
{ {
fn layout(key_ptr: &mut KeyPtr) -> Layout { fn layout(key_ptr: &mut KeyPtr) -> Layout {
let capacity = u32::MAX; let capacity = u32::MAX;
......
...@@ -89,11 +89,11 @@ const _: () = { ...@@ -89,11 +89,11 @@ const _: () = {
Layout, Layout,
LayoutKey, LayoutKey,
}; };
use scale_info::Metadata; use scale_info::TypeInfo;
impl<T> StorageLayout for Pack<T> impl<T> StorageLayout for Pack<T>
where where
T: Metadata, T: TypeInfo + 'static,
{ {
fn layout(key_ptr: &mut KeyPtr) -> Layout { fn layout(key_ptr: &mut KeyPtr) -> Layout {
Layout::Cell(CellLayout::new::<T>(LayoutKey::from(key_ptr.advance_by(1)))) Layout::Cell(CellLayout::new::<T>(LayoutKey::from(key_ptr.advance_by(1))))
......
...@@ -41,7 +41,7 @@ use ink_prelude::{ ...@@ -41,7 +41,7 @@ use ink_prelude::{
vec::Vec, vec::Vec,
}; };
use ink_primitives::Key; use ink_primitives::Key;
use scale_info::Metadata; use scale_info::TypeInfo;
macro_rules! impl_storage_layout_for_primitives { macro_rules! impl_storage_layout_for_primitives {
( $($name:ty),* $(,)? ) => { ( $($name:ty),* $(,)? ) => {
...@@ -184,7 +184,7 @@ where ...@@ -184,7 +184,7 @@ where
impl<T> StorageLayout for Vec<T> impl<T> StorageLayout for Vec<T>
where where
T: Metadata + 'static, T: TypeInfo + 'static,
{ {
fn layout(key_ptr: &mut KeyPtr) -> Layout { fn layout(key_ptr: &mut KeyPtr) -> Layout {
Layout::Cell(CellLayout::new::<Self>(LayoutKey::from( Layout::Cell(CellLayout::new::<Self>(LayoutKey::from(
...@@ -195,8 +195,8 @@ where ...@@ -195,8 +195,8 @@ where
impl<K, V> StorageLayout for BTreeMap<K, V> impl<K, V> StorageLayout for BTreeMap<K, V>
where where
K: Metadata + 'static, K: TypeInfo + 'static,
V: Metadata + 'static, V: TypeInfo + 'static,
{ {
fn layout(key_ptr: &mut KeyPtr) -> Layout { fn layout(key_ptr: &mut KeyPtr) -> Layout {
Layout::Cell(CellLayout::new::<Self>(LayoutKey::from( Layout::Cell(CellLayout::new::<Self>(LayoutKey::from(
...@@ -207,7 +207,7 @@ where ...@@ -207,7 +207,7 @@ where
// impl<T> StorageLayout for BinaryHeap<T> // impl<T> StorageLayout for BinaryHeap<T>
// where // where
// T: Metadata + 'static, // T: TypeInfo + 'static,
// { // {
// fn layout(key_ptr: &mut KeyPtr) -> Layout { // fn layout(key_ptr: &mut KeyPtr) -> Layout {
// Layout::Cell(CellLayout::new::<Self>(LayoutKey::from(key_ptr.advance_by(1)))) // Layout::Cell(CellLayout::new::<Self>(LayoutKey::from(key_ptr.advance_by(1))))
...@@ -216,7 +216,7 @@ where ...@@ -216,7 +216,7 @@ where
// impl<T> StorageLayout for BTreeSet<T> // impl<T> StorageLayout for BTreeSet<T>
// where // where
// T: Metadata + 'static, // T: TypeInfo + 'static,
// { // {
// fn layout(key_ptr: &mut KeyPtr) -> Layout { // fn layout(key_ptr: &mut KeyPtr) -> Layout {
// Layout::Cell(CellLayout::new::<Self>(LayoutKey::from(key_ptr.advance_by(1)))) // Layout::Cell(CellLayout::new::<Self>(LayoutKey::from(key_ptr.advance_by(1))))
...@@ -225,7 +225,7 @@ where ...@@ -225,7 +225,7 @@ where
// impl<T> StorageLayout for VecDeque<T> // impl<T> StorageLayout for VecDeque<T>
// where // where
// T: Metadata + 'static, // T: TypeInfo + 'static,
// { // {
// fn layout(key_ptr: &mut KeyPtr) -> Layout { // fn layout(key_ptr: &mut KeyPtr) -> Layout {
// Layout::Cell(CellLayout::new::<Self>(LayoutKey::from(key_ptr.advance_by(1)))) // Layout::Cell(CellLayout::new::<Self>(LayoutKey::from(key_ptr.advance_by(1))))
...@@ -234,7 +234,7 @@ where ...@@ -234,7 +234,7 @@ where
// impl<T> StorageLayout for LinkedList<T> // impl<T> StorageLayout for LinkedList<T>
// where // where
// T: Metadata + 'static, // T: TypeInfo + 'static,
// { // {
// fn layout(key_ptr: &mut KeyPtr) -> Layout { // fn layout(key_ptr: &mut KeyPtr) -> Layout {
// Layout::Cell(CellLayout::new::<Self>(LayoutKey::from(key_ptr.advance_by(1)))) // Layout::Cell(CellLayout::new::<Self>(LayoutKey::from(key_ptr.advance_by(1))))
......
...@@ -15,7 +15,7 @@ scale = { package = "parity-scale-codec", version = "1.3", default-features = fa ...@@ -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"] } 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"] } 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"] } accumulator = { version = "2.1.0", path = "accumulator", default-features = false, features = ["ink-as-dependency"] }
scale-info = { version = "0.1", default-features = false, features = ["derive"], optional = true } scale-info = { version = "0.2", default-features = false, features = ["derive"], optional = true }
[lib] [lib]
name = "delegator"