pallet assets: Fix errors (#4118)

`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.
This commit is contained in:
gui
2024-04-16 03:45:44 +09:00
committed by GitHub
parent 0c9ad5306c
commit a8f4f4f00f
5 changed files with 20 additions and 7 deletions
Generated
+1 -1
View File
@@ -9571,7 +9571,7 @@ dependencies = [
[[package]]
name = "pallet-assets"
version = "29.0.0"
version = "29.1.0"
dependencies = [
"frame-benchmarking",
"frame-support",
+13
View File
@@ -0,0 +1,13 @@
title: "pallet assets: minor improvement on errors returned for some calls"
doc:
- audience: Runtime Dev
description: |
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.
crates:
- name: pallet-assets
bump: minor
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "pallet-assets"
version = "29.0.0"
version = "29.1.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
+1 -1
View File
@@ -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
);
let actual = Self::decrease_balance(id.clone(), target, amount, f, |actual, details| {
+4 -4
View File
@@ -987,7 +987,7 @@ pub mod pallet {
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
);
ensure!(origin == d.freezer, Error::<T, I>::NoPermission);
let who = T::Lookup::lookup(who)?;
@@ -1024,7 +1024,7 @@ pub mod pallet {
let details = Asset::<T, I>::get(&id).ok_or(Error::<T, I>::Unknown)?;
ensure!(
details.status == AssetStatus::Live || details.status == AssetStatus::Frozen,
Error::<T, I>::AssetNotLive
Error::<T, I>::IncorrectStatus
);
ensure!(origin == details.admin, Error::<T, I>::NoPermission);
let who = T::Lookup::lookup(who)?;
@@ -1113,7 +1113,7 @@ pub mod pallet {
Asset::<T, I>::try_mutate(id.clone(), |maybe_details| {
let details = maybe_details.as_mut().ok_or(Error::<T, I>::Unknown)?;
ensure!(details.status == AssetStatus::Live, Error::<T, I>::LiveAsset);
ensure!(details.status == AssetStatus::Live, Error::<T, I>::AssetNotLive);
ensure!(origin == details.owner, Error::<T, I>::NoPermission);
if details.owner == owner {
return Ok(())
@@ -1669,7 +1669,7 @@ pub mod pallet {
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
);
ensure!(origin == d.freezer, Error::<T, I>::NoPermission);
let who = T::Lookup::lookup(who)?;