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