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

[audit] Update DispatchError to match latest in polkadot-sdk #1442

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions subxt/src/error/dispatch_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ pub enum DispatchError {
"Some resource (e.g. a preimage) is unavailable right now. This might fix itself later."
)]
Unavailable,
/// Root origin is not allowed.
#[error("Root origin is not allowed.")]
RootNotAllowed,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be interesting if we could automatically check that all types we have from substrate are in sync.

I'm not aware of a clean way to do that.
We could probably explore in the future a custom crate that compares the tokens from this type to a github link, or crate version.

#[sync_test(
   git = "https://github.com/paritytech/polkadot-sdk/blob/master/substrate",
   path  = "substrate/primitives/runtime/src/lib.rs"
)
enum SubstrateType {
  ...
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's an interesting idea!

}

/// An error relating to tokens when dispatching a transaction.
Expand Down Expand Up @@ -92,6 +95,9 @@ pub enum TokenError {
/// Withdrawal would cause unwanted loss of account.
#[error("Withdrawal would cause unwanted loss of account.")]
NotExpendable,
/// Account cannot receive the assets.
#[error("Account cannot receive the assets.")]
Blocked,
}

/// An error relating to arithmetic when dispatching a transaction.
Expand Down Expand Up @@ -249,6 +255,7 @@ impl DispatchError {
Exhausted,
Corruption,
Unavailable,
RootNotAllowed,
}

// ModuleError is a bit special; we want to support being decoded from either
Expand Down Expand Up @@ -298,6 +305,7 @@ impl DispatchError {
DecodedDispatchError::Exhausted => DispatchError::Exhausted,
DecodedDispatchError::Corruption => DispatchError::Corruption,
DecodedDispatchError::Unavailable => DispatchError::Unavailable,
DecodedDispatchError::RootNotAllowed => DispatchError::RootNotAllowed,
// But we apply custom logic to transform the module error into the outward facing version:
DecodedDispatchError::Module(module_bytes) => {
let module_bytes = module_bytes.0;
Expand Down
Loading