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

Handle sp_runtime::ModuleError substrate updates #492

Merged
merged 15 commits into from Mar 31, 2022
Merged

Conversation

lexnv
Copy link
Contributor

@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
    }
}

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 jsdw, dvdplm and ascjones March 28, 2022 16:10
codegen/src/api/errors.rs Outdated Show resolved Hide resolved
codegen/src/api/errors.rs Outdated Show resolved Hide resolved
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>
codegen/src/api/errors.rs Outdated Show resolved Hide resolved
codegen/src/api/errors.rs Outdated Show resolved Hide resolved
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>
subxt/src/error.rs Outdated Show resolved Hide resolved
subxt/src/error.rs Outdated Show resolved Hide resolved
subxt/src/transaction.rs Outdated Show resolved Hide resolved
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 :)

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
Member

@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.
3 participants