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

Update to scale-info 1.0 and support new metadata versioning #342

Merged
merged 7 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 5 additions & 15 deletions metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,9 @@ use serde::{Serialize, Serializer};
use serde_json::{Map, Value};
use url::Url;

const METADATA_VERSION: &str = "0.1.0";

/// Smart contract metadata.
#[derive(Clone, Debug, Serialize)]
pub struct ContractMetadata {
#[serde(rename = "metadataVersion")]
metadata_version: semver::Version,
source: Source,
contract: Contract,
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -82,11 +78,7 @@ impl ContractMetadata {
user: Option<User>,
abi: Map<String, Value>,
) -> Self {
let metadata_version = semver::Version::parse(METADATA_VERSION)
.expect("METADATA_VERSION is a valid semver string");

Self {
metadata_version,
source,
contract,
user,
Expand Down Expand Up @@ -561,7 +553,6 @@ mod tests {

let expected = json! {
{
"metadataVersion": "0.1.0",
"source": {
"hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"language": "ink! 2.1.0",
Expand Down Expand Up @@ -626,19 +617,18 @@ mod tests {

let expected = json! {
{
"metadataVersion": "0.1.0",
"source": {
"hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"language": "ink! 2.1.0",
"compiler": "rustc 1.46.0-nightly"
},
"contract": {
"name": "incrementer",
"version": "2.1.0",
"authors": [
"Parity Technologies <[email protected]>"
],
},
"source": {
"hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"language": "ink! 2.1.0",
"compiler": "rustc 1.46.0-nightly"
},
// these fields are part of the flattened raw json for the contract ABI
"spec": {},
"storage": {},
Expand Down
12 changes: 6 additions & 6 deletions templates/new/_Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ edition = "2018"
resolver = "2"

[dependencies]
ink_primitives = { version = "3.0.0-rc5", default-features = false }
ink_metadata = { version = "3.0.0-rc5", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.0.0-rc5", default-features = false }
ink_storage = { version = "3.0.0-rc5", default-features = false }
ink_lang = { version = "3.0.0-rc5", default-features = false }
ink_primitives = { version = "3.0.0-rc6", default-features = false }
ink_metadata = { version = "3.0.0-rc6", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.0.0-rc6", default-features = false }
ink_storage = { version = "3.0.0-rc6", default-features = false }
ink_lang = { version = "3.0.0-rc6", default-features = false }

scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6.0", default-features = false, features = ["derive"], optional = true }
scale-info = { version = "1.0.0", default-features = false, features = ["derive"], optional = true }

[lib]
name = "{{name}}"
Expand Down
2 changes: 1 addition & 1 deletion templates/tools/generate-metadata/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate contract;

extern "Rust" {
fn __ink_generate_metadata() -> ink_metadata::InkProject;
fn __ink_generate_metadata() -> ink_metadata::MetadataVersioned;
}

fn main() -> Result<(), std::io::Error> {
Expand Down