Skip to content

Conversation

@lexnv
Copy link
Collaborator

@lexnv lexnv commented Mar 28, 2022

The following change was introduced in substrate via Allow pallet error enum variants to contain fields #10242.

DispatchError::Module ( sp_runtime::ModuleError { index: u8, error: u8 } 

->

DispatchError::Module ( sp_runtime::ModuleError { index: u8, error: [u8; 4] } )

This PR handles the error of type [u8; 4] while maintaining backward compatibility.

Closes #491

Testing Done

  • new substrate binary
fn module_error_indices(&self) -> Option<::subxt::ModuleErrorRaw> {
    if let Self::Module(module_error) = self {
        Some(::subxt::ModuleErrorRaw {
            pallet_index: module_error.index,
            error: module_error.error,
        })
    } else {
        None
    }
}
  • legacy format
fn module_error_indices(&self) -> Option<::subxt::ModuleErrorRaw> {
    if let Self::Module(module_error) = self {
        Some(::subxt::ModuleErrorRaw {
            pallet_index: module_error.index,
            error: [module_error.error, 0, 0, 0],
        })
    } else {
        None
    }
}
  • named format
fn module_error_indices(&self) -> Option<::subxt::ModuleErrorRaw> {
    if let &Self::Module { index, error } = self {
        Some(::subxt::ModuleErrorRaw {
            pallet_index: index,
            error: [error, 0, 0, 0],
        })
    } else {
        None
    }
}

lexnv added 3 commits March 28, 2022 18:24
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv requested review from ascjones, dvdplm and jsdw March 28, 2022 16:10
lexnv added 4 commits March 29, 2022 13:15
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
lexnv added 4 commits March 30, 2022 12:46
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

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

I'm happy for this to merge once @ascjones's comments are addressed :)

lexnv added 3 commits March 31, 2022 11:35
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Copy link
Contributor

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

LGTM

@lexnv lexnv merged commit 9318f62 into master Mar 31, 2022
@lexnv lexnv deleted the 491_module_error branch March 31, 2022 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subxt integration tests failed against latest Substrate build.

4 participants