Skip to content

Commit fea273c

Browse files
committed
switch to scale-info
1 parent 48e8316 commit fea273c

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

primitive-types/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ uint = { version = "0.8.1", path = "../uint", default-features = false }
1313
impl-serde = { version = "0.3.0", path = "impls/serde", default-features = false, optional = true }
1414
impl-codec = { version = "0.4.1", path = "impls/codec", default-features = false, optional = true }
1515
impl-rlp = { version = "0.2", path = "impls/rlp", default-features = false, optional = true }
16-
# type-metadata = { version = "0.1", features = ["derive"], default-features = false, optional = true }
17-
type-metadata = { git = "https://github.com/type-metadata/type-metadata", default-features = false, features = ["derive"], optional = true }
16+
# scale-info = { version = "0.1", features = ["derive"], default-features = false, optional = true }
17+
scale-info = { git = "https://github.com/paritytech/scale-info", default-features = false, features = ["derive"], optional = true }
1818

1919
[features]
2020
default = ["std"]
@@ -27,5 +27,5 @@ codec = ["impl-codec"]
2727
rlp = ["impl-rlp"]
2828

2929
[[test]]
30-
name = "type_metadata"
31-
required-features = ["type-metadata"]
30+
name = "scale_info"
31+
required-features = ["scale-info"]

primitive-types/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
use core::convert::TryFrom;
1818
use fixed_hash::{construct_fixed_hash, impl_fixed_hash_conversions};
19-
#[cfg(feature = "type-metadata")]
20-
use type_metadata::Metadata;
19+
#[cfg(feature = "scale-info")]
20+
use scale_info::Metadata;
2121
use uint::{construct_uint, uint_full_mul_reg};
2222

2323
/// Error type for conversion.
@@ -29,33 +29,33 @@ pub enum Error {
2929

3030
construct_uint! {
3131
/// 128-bit unsigned integer.
32-
#[cfg_attr(feature = "type-metadata", derive(Metadata))]
32+
#[cfg_attr(feature = "scale-info", derive(Metadata))]
3333
pub struct U128(2);
3434
}
3535
construct_uint! {
3636
/// 256-bit unsigned integer.
37-
#[cfg_attr(feature = "type-metadata", derive(Metadata))]
37+
#[cfg_attr(feature = "scale-info", derive(Metadata))]
3838
pub struct U256(4);
3939
}
4040
construct_uint! {
4141
/// 512-bits unsigned integer.
42-
#[cfg_attr(feature = "type-metadata", derive(Metadata))]
42+
#[cfg_attr(feature = "scale-info", derive(Metadata))]
4343
pub struct U512(8);
4444
}
4545

4646
construct_fixed_hash! {
4747
/// Fixed-size uninterpreted hash type with 20 bytes (160 bits) size.
48-
#[cfg_attr(feature = "type-metadata", derive(Metadata))]
48+
#[cfg_attr(feature = "scale-info", derive(Metadata))]
4949
pub struct H160(20);
5050
}
5151
construct_fixed_hash! {
5252
/// Fixed-size uninterpreted hash type with 32 bytes (256 bits) size.
53-
#[cfg_attr(feature = "type-metadata", derive(Metadata))]
53+
#[cfg_attr(feature = "scale-info", derive(Metadata))]
5454
pub struct H256(32);
5555
}
5656
construct_fixed_hash! {
5757
/// Fixed-size uninterpreted hash type with 64 bytes (512 bits) size.
58-
#[cfg_attr(feature = "type-metadata", derive(Metadata))]
58+
#[cfg_attr(feature = "scale-info", derive(Metadata))]
5959
pub struct H512(64);
6060
}
6161

primitive-types/tests/scale_info.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2020 Parity Technologies
2+
//
3+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6+
// option. This file may not be copied, modified, or distributed
7+
// except according to those terms.
8+
9+
//! Tests for scale-info feature of primitive-types.
10+
11+
use primitive_types::{H256, U256};
12+
use scale_info::{Fields, Path, TypeComposite, TypeInfo};
13+
14+
#[test]
15+
fn u256_scale_info() {
16+
let r#type = TypeComposite::new()
17+
.path(Path::new("U256", "primitive_types"))
18+
.fields(Fields::unnamed().field_of::<[u64; 4]>());
19+
20+
assert_eq!(U256::type_info(), r#type.into());
21+
}
22+
23+
#[test]
24+
fn h256_scale_info() {
25+
let r#type = TypeComposite::new()
26+
.path(Path::new("H256", "primitive_types"))
27+
.fields(Fields::unnamed().field_of::<[u8; 32]>());
28+
29+
assert_eq!(H256::type_info(), r#type.into());
30+
}

primitive-types/tests/type_metadata.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)