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

Bump metadata version to 5 #2126

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Bump metadata version to 5 [#2126](https://github.com/paritytech/ink/pull/2126)

### Fixed
- Fix alignment in allocator [#2100](https://github.com/paritytech/ink/pull/2100)
Expand Down
24 changes: 4 additions & 20 deletions crates/metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,12 @@ use serde::{
///
/// The serialized metadata format (which this represents) is different from the
/// version of this crate or the contract for Rust semantic versioning purposes.
///
/// # Note
///
/// Versions other than the `Default` are considered deprecated. If you want to
/// deserialize legacy metadata versions you will need to use an old version of
/// this crate.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, JsonSchema)]
pub enum MetadataVersion {
#[serde(rename = "4")]
V4,
}

impl Default for MetadataVersion {
fn default() -> Self {
Self::V4
}
}
const METADATA_VERSION: u64 = 5;

/// An entire ink! project for metadata file generation purposes.
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
pub struct InkProject {
version: MetadataVersion,
version: u64,
#[serde(flatten)]
registry: PortableRegistry,
#[serde(rename = "storage")]
Expand Down Expand Up @@ -131,15 +115,15 @@ impl InkProject {
registry: PortableRegistry,
) -> Self {
Self {
version: Default::default(),
version: METADATA_VERSION,
layout,
spec,
registry,
}
}

/// Returns the metadata version used by the contract.
pub fn version(&self) -> &MetadataVersion {
pub fn version(&self) -> &u64 {
Copy link
Contributor

@peetzweg peetzweg Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this change result in the version being output as a number?

So {version: 5} instead of {version: '5'}?

Would prefer it as a number instead of string for easier version comparison up and down. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this changes the string into the integer. All good there

&self.version
}

Expand Down
Loading