-
Notifications
You must be signed in to change notification settings - Fork 124
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
support metadata v15 #587
Merged
Merged
support metadata v15 #587
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fdd3029
parameterized test for testing different metadata versions (internall…
masapr b05965c
failing test for supporting metadata v14 and v15
masapr f6a0b40
compatibility with metadata v14 and v15. v14 is always converted to v15
masapr edbd717
cargo fmt
masapr 4a31d23
add license information
masapr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// This file was taken from subxt (Parity Technologies (UK)) | ||
// https://github.com/paritytech/subxt/ | ||
// And was adapted by Supercomputing Systems AG. | ||
// | ||
// Copyright 2019-2023 Parity Technologies (UK) Ltd and Supercomputing Systems AG. | ||
// This file is licensed as Apache-2.0 | ||
// see LICENSE for license details. | ||
|
||
use frame_metadata::{v14, v15}; | ||
masapr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
pub fn v14_to_v15(metadata: v14::RuntimeMetadataV14) -> v15::RuntimeMetadataV15 { | ||
v15::RuntimeMetadataV15 { | ||
types: metadata.types, | ||
pallets: metadata | ||
.pallets | ||
.into_iter() | ||
.map(|pallet| frame_metadata::v15::PalletMetadata { | ||
name: pallet.name, | ||
storage: pallet | ||
.storage | ||
.map(|storage| frame_metadata::v15::PalletStorageMetadata { | ||
prefix: storage.prefix, | ||
entries: storage | ||
.entries | ||
.into_iter() | ||
.map(|entry| { | ||
let modifier = match entry.modifier { | ||
frame_metadata::v14::StorageEntryModifier::Optional => { | ||
frame_metadata::v15::StorageEntryModifier::Optional | ||
} | ||
frame_metadata::v14::StorageEntryModifier::Default => { | ||
frame_metadata::v15::StorageEntryModifier::Default | ||
} | ||
}; | ||
|
||
let ty = match entry.ty { | ||
frame_metadata::v14::StorageEntryType::Plain(ty) => { | ||
frame_metadata::v15::StorageEntryType::Plain(ty) | ||
}, | ||
frame_metadata::v14::StorageEntryType::Map { | ||
hashers, | ||
key, | ||
value, | ||
} => frame_metadata::v15::StorageEntryType::Map { | ||
hashers: hashers.into_iter().map(|hasher| match hasher { | ||
frame_metadata::v14::StorageHasher::Blake2_128 => frame_metadata::v15::StorageHasher::Blake2_128, | ||
frame_metadata::v14::StorageHasher::Blake2_256 => frame_metadata::v15::StorageHasher::Blake2_256, | ||
frame_metadata::v14::StorageHasher::Blake2_128Concat => frame_metadata::v15::StorageHasher::Blake2_128Concat , | ||
frame_metadata::v14::StorageHasher::Twox128 => frame_metadata::v15::StorageHasher::Twox128, | ||
frame_metadata::v14::StorageHasher::Twox256 => frame_metadata::v15::StorageHasher::Twox256, | ||
frame_metadata::v14::StorageHasher::Twox64Concat => frame_metadata::v15::StorageHasher::Twox64Concat, | ||
frame_metadata::v14::StorageHasher::Identity=> frame_metadata::v15::StorageHasher::Identity, | ||
}).collect(), | ||
key, | ||
value, | ||
}, | ||
}; | ||
|
||
frame_metadata::v15::StorageEntryMetadata { | ||
name: entry.name, | ||
modifier, | ||
ty, | ||
default: entry.default, | ||
docs: entry.docs, | ||
} | ||
}) | ||
.collect(), | ||
}), | ||
calls: pallet.calls.map(|calls| frame_metadata::v15::PalletCallMetadata { ty: calls.ty } ), | ||
event: pallet.event.map(|event| frame_metadata::v15::PalletEventMetadata { ty: event.ty } ), | ||
constants: pallet.constants.into_iter().map(|constant| frame_metadata::v15::PalletConstantMetadata { | ||
name: constant.name, | ||
ty: constant.ty, | ||
value: constant.value, | ||
docs: constant.docs, | ||
} ).collect(), | ||
error: pallet.error.map(|error| frame_metadata::v15::PalletErrorMetadata { ty: error.ty } ), | ||
index: pallet.index, | ||
docs: Default::default(), | ||
}) | ||
.collect(), | ||
extrinsic: frame_metadata::v15::ExtrinsicMetadata { | ||
ty: metadata.extrinsic.ty, | ||
version: metadata.extrinsic.version, | ||
signed_extensions: metadata.extrinsic.signed_extensions.into_iter().map(|ext| { | ||
frame_metadata::v15::SignedExtensionMetadata { | ||
identifier: ext.identifier, | ||
ty: ext.ty, | ||
additional_signed: ext.additional_signed, | ||
} | ||
}).collect() | ||
}, | ||
ty: metadata.ty, | ||
apis: Default::default(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! ❤️