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

pallet assets: Fix errors #4118

Merged
merged 5 commits into from
Apr 15, 2024
Merged

Conversation

gui1117
Copy link
Contributor

@gui1117 gui1117 commented Apr 15, 2024

LiveAsset is an error to be returned when an asset is not supposed to be live.
And AssetNotLive is an error to be returned when an asset is supposed to be live, I don't think frozen qualifies as live.

@gui1117 gui1117 requested a review from a team as a code owner April 15, 2024 00:52
@gui1117 gui1117 closed this Apr 15, 2024
@gui1117 gui1117 reopened this Apr 15, 2024
@@ -491,7 +491,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
let d = Asset::<T, I>::get(&id).ok_or(Error::<T, I>::Unknown)?;
ensure!(
d.status == AssetStatus::Live || d.status == AssetStatus::Frozen,
Error::<T, I>::AssetNotLive
Error::<T, I>::IncorrectStatus
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we say AssetNotLiveOrFrozen? Not sure if IncorrectStatus is much helpful.

Copy link
Contributor

@liamaharon liamaharon Apr 15, 2024

Choose a reason for hiding this comment

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

I'm personally fine with IncorrectStatus. It's non-ambiguous since it's only used in one context, and allows for us to add new statuses in the future without needing to update the error.

Copy link
Contributor Author

@gui1117 gui1117 Apr 15, 2024

Choose a reason for hiding this comment

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

AssetNotLiveNorFrozen or AssetNotLiveOrFrozen ?
I will do.

Copy link
Contributor

Choose a reason for hiding this comment

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

allows for us to add new statuses in the future without needing to update the error.

Yeah, it helps us, but not sure someone using a UI would get any info with the IncorrectStatus error. Either ways, its fine but I would prefer the errors to be more meaningful for the users.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think Rust enum errors are supposed to be shown directly to end-users in UIs? I always understood them as more for developers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some UI might show the doc: /// The asset status is not the expected status.

Considering there is 3 status I think it is ok

@liamaharon liamaharon added the T2-pallets This PR/Issue is related to a particular pallet. label Apr 15, 2024
@liamaharon
Copy link
Contributor

@thiolliere could you please add a prdoc?

@gui1117
Copy link
Contributor Author

gui1117 commented Apr 15, 2024

I updated the minor version of pallet assets, I don't know if it is wanted.

Some calls in pallet assets have better errors. No new error is introduced, only more sensible choice are made.
- audience: Runtime User
description: |
Some calls in pallet assets have better errors. No new error is introduced, only more sensible choice are made.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel information is not useful, but in theory it impacts both dev for maybe test to udpate and frontend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in theory it is kind of a major breaking change :-(

@bkchr bkchr added this pull request to the merge queue Apr 15, 2024
Merged via the queue into paritytech:master with commit a8f4f4f Apr 15, 2024
133 of 137 checks passed
@gui1117 gui1117 deleted the gui-fix-errors-assets branch April 16, 2024 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants