Skip to content

Commit

Permalink
Update frame-decode to 0.4.0 (#1833)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdw authored Oct 22, 2024
1 parent ae0fce8 commit c07c760
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ darling = "0.20.10"
derive-where = "1.2.7"
either = { version = "1.13.0", default-features = false }
finito = { version = "0.1.0", default-features = false }
frame-decode = { version = "0.3.0", default-features = false }
frame-decode = { version = "0.4.0", default-features = false }
frame-metadata = { version = "16.0.0", default-features = false }
futures = { version = "0.3.30", default-features = false, features = ["std"] }
getrandom = { version = "0.2", default-features = false }
Expand Down
32 changes: 26 additions & 6 deletions metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ use alloc::string::String;
use alloc::sync::Arc;
use alloc::vec::Vec;
use frame_decode::extrinsics::{
ExtrinsicInfo, ExtrinsicInfoArg, ExtrinsicInfoError, ExtrinsicSignatureInfo,
ExtrinsicCallInfo, ExtrinsicExtensionInfo, ExtrinsicInfoArg, ExtrinsicInfoError,
ExtrinsicSignatureInfo,
};
use hashbrown::HashMap;
use scale_info::{form::PortableForm, PortableRegistry, Variant};
Expand Down Expand Up @@ -70,11 +71,11 @@ pub struct Metadata {
impl frame_decode::extrinsics::ExtrinsicTypeInfo for Metadata {
type TypeId = u32;

fn get_extrinsic_info(
fn get_call_info(
&self,
pallet_index: u8,
call_index: u8,
) -> Result<ExtrinsicInfo<'_, Self::TypeId>, ExtrinsicInfoError<'_>> {
) -> Result<ExtrinsicCallInfo<'_, Self::TypeId>, ExtrinsicInfoError<'_>> {
let pallet = self.pallet_by_index(pallet_index).ok_or({
ExtrinsicInfoError::PalletNotFound {
index: pallet_index,
Expand All @@ -89,7 +90,7 @@ impl frame_decode::extrinsics::ExtrinsicTypeInfo for Metadata {
}
})?;

Ok(ExtrinsicInfo {
Ok(ExtrinsicCallInfo {
pallet_name: Cow::Borrowed(pallet.name()),
call_name: Cow::Borrowed(&call.name),
args: call
Expand All @@ -105,11 +106,30 @@ impl frame_decode::extrinsics::ExtrinsicTypeInfo for Metadata {

fn get_signature_info(
&self,
) -> Result<ExtrinsicSignatureInfo<'_, Self::TypeId>, ExtrinsicInfoError<'_>> {
) -> Result<ExtrinsicSignatureInfo<Self::TypeId>, ExtrinsicInfoError<'_>> {
Ok(ExtrinsicSignatureInfo {
address_id: self.extrinsic().address_ty(),
signature_id: self.extrinsic().signature_ty(),
transaction_extension_ids: self
})
}

fn get_extension_info(
&self,
extension_version: Option<u8>,
) -> Result<ExtrinsicExtensionInfo<'_, Self::TypeId>, ExtrinsicInfoError<'_>> {
// For now, if there exists an extension version that's non-zero, we say we don't know
// how to decode it. When multiple extension versions exist, we may have to tighten up
// on this and require V16 metadata to decode.
if let Some(extension_version) = extension_version {
if extension_version != 0 {
return Err(ExtrinsicInfoError::ExtrinsicExtensionVersionNotSupported {
extension_version,
});
}
}

Ok(ExtrinsicExtensionInfo {
extension_ids: self
.extrinsic()
.signed_extensions()
.iter()
Expand Down

0 comments on commit c07c760

Please sign in to comment.