Skip to content

Commit

Permalink
Bump metadata version to 5 (#2126)
Browse files Browse the repository at this point in the history
* bump metadata version

* add changelog entry

* replace enum with const

* fix

* disable on-chain CI step
  • Loading branch information
Gherman authored Feb 27, 2024
1 parent 12ae9ba commit ae73d0b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ jobs:
INK_STATIC_BUFFER_SIZE=30 cargo test --verbose --manifest-path integration-tests/static-buffer/Cargo.toml --all-features
- name: Run E2E test with on-chain contract
if: false # temporary disable step until new version of `cargo-contract` is released.
env:
# Fix linking of `linkme`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc
Expand Down
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
26 changes: 5 additions & 21 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 All @@ -115,7 +99,7 @@ impl InkProject {
let mut registry = Registry::new();

Self {
version: Default::default(),
version: METADATA_VERSION,
layout: layout.into().into_portable(&mut registry),
spec: spec.into().into_portable(&mut registry),
registry: registry.into(),
Expand All @@ -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 {
&self.version
}

Expand Down

0 comments on commit ae73d0b

Please sign in to comment.