Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
[metadata] update scale-info, remove string parameterization
  • Loading branch information
ascjones committed Feb 2, 2021
commit 7726b36bd885051298323e969bce10377e932874
26 changes: 9 additions & 17 deletions crates/metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,25 @@ use impl_serde::serialize as serde_hex;

#[cfg(feature = "derive")]
use scale_info::{
form::{
FormString,
PortableForm,
},
form::PortableForm,
IntoPortable as _,
PortableRegistry,
Registry,
};
use serde::{
de::DeserializeOwned,
Deserialize,
Serialize,
};

/// An entire ink! project for metadata file generation purposes.
#[derive(Debug, Serialize, Deserialize)]
#[serde(bound(deserialize = "S: DeserializeOwned"))]
pub struct InkProject<S: FormString = &'static str> {
pub struct InkProject {
#[serde(flatten)]
registry: PortableRegistry<S>,
registry: PortableRegistry,
#[serde(rename = "storage")]
/// The layout of the storage data structure
layout: layout::Layout<PortableForm<S>>,
spec: ContractSpec<PortableForm<S>>,
layout: layout::Layout<PortableForm>,
spec: ContractSpec<PortableForm>,
}

impl InkProject {
Expand All @@ -89,22 +84,19 @@ impl InkProject {
}
}

impl<S> InkProject<S>
where
S: FormString,
{
impl InkProject {
/// Returns a read-only registry of types in the contract.
pub fn registry(&self) -> &PortableRegistry<S> {
pub fn registry(&self) -> &PortableRegistry {
&self.registry
}

/// Returns the storage layout of the contract.
pub fn layout(&self) -> &layout::Layout<PortableForm<S>> {
pub fn layout(&self) -> &layout::Layout<PortableForm> {
&self.layout
}

/// Returns the specification of the contract.
pub fn spec(&self) -> &ContractSpec<PortableForm<S>> {
pub fn spec(&self) -> &ContractSpec<PortableForm> {
&self.spec
}
}
4 changes: 2 additions & 2 deletions crates/metadata/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn spec_constructor_selector_must_serialize_to_hex() {

// when
let json = serde_json::to_value(&portable_spec).unwrap();
let deserialized: ConstructorSpec<PortableForm<String>> =
let deserialized: ConstructorSpec<PortableForm> =
serde_json::from_value(json.clone()).unwrap();

// then
Expand Down Expand Up @@ -183,7 +183,7 @@ fn trim_docs() {

// when
let json = serde_json::to_value(&compact_spec).unwrap();
let deserialized: ConstructorSpec<PortableForm<String>> =
let deserialized: ConstructorSpec<PortableForm> =
serde_json::from_value(json.clone()).unwrap();

// then
Expand Down