From b234debefa9d45d95233b766426201b14d842656 Mon Sep 17 00:00:00 2001 From: gui Date: Mon, 15 Apr 2024 09:48:57 +0900 Subject: [PATCH 1/5] fix errors --- substrate/frame/assets/src/functions.rs | 2 +- substrate/frame/assets/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/assets/src/functions.rs b/substrate/frame/assets/src/functions.rs index 8791aaa736b3..4a5fb06ee2c8 100644 --- a/substrate/frame/assets/src/functions.rs +++ b/substrate/frame/assets/src/functions.rs @@ -491,7 +491,7 @@ impl, I: 'static> Pallet { let d = Asset::::get(&id).ok_or(Error::::Unknown)?; ensure!( d.status == AssetStatus::Live || d.status == AssetStatus::Frozen, - Error::::AssetNotLive + Error::::IncorrectStatus ); let actual = Self::decrease_balance(id.clone(), target, amount, f, |actual, details| { diff --git a/substrate/frame/assets/src/lib.rs b/substrate/frame/assets/src/lib.rs index 6891f04dfb51..6217416f07a0 100644 --- a/substrate/frame/assets/src/lib.rs +++ b/substrate/frame/assets/src/lib.rs @@ -1113,7 +1113,7 @@ pub mod pallet { Asset::::try_mutate(id.clone(), |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::Unknown)?; - ensure!(details.status == AssetStatus::Live, Error::::LiveAsset); + ensure!(details.status == AssetStatus::Live, Error::::AssetNotLive); ensure!(origin == details.owner, Error::::NoPermission); if details.owner == owner { return Ok(()) From c3b8297394cf3361c599595f1060dab7c21b6636 Mon Sep 17 00:00:00 2001 From: gui Date: Mon, 15 Apr 2024 12:31:11 +0900 Subject: [PATCH 2/5] More fix --- substrate/frame/assets/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/assets/src/lib.rs b/substrate/frame/assets/src/lib.rs index 6217416f07a0..c6b379e1d060 100644 --- a/substrate/frame/assets/src/lib.rs +++ b/substrate/frame/assets/src/lib.rs @@ -987,7 +987,7 @@ pub mod pallet { let d = Asset::::get(&id).ok_or(Error::::Unknown)?; ensure!( d.status == AssetStatus::Live || d.status == AssetStatus::Frozen, - Error::::AssetNotLive + Error::::IncorrectStatus ); ensure!(origin == d.freezer, Error::::NoPermission); let who = T::Lookup::lookup(who)?; @@ -1024,7 +1024,7 @@ pub mod pallet { let details = Asset::::get(&id).ok_or(Error::::Unknown)?; ensure!( details.status == AssetStatus::Live || details.status == AssetStatus::Frozen, - Error::::AssetNotLive + Error::::IncorrectStatus ); ensure!(origin == details.admin, Error::::NoPermission); let who = T::Lookup::lookup(who)?; @@ -1669,7 +1669,7 @@ pub mod pallet { let d = Asset::::get(&id).ok_or(Error::::Unknown)?; ensure!( d.status == AssetStatus::Live || d.status == AssetStatus::Frozen, - Error::::AssetNotLive + Error::::IncorrectStatus ); ensure!(origin == d.freezer, Error::::NoPermission); let who = T::Lookup::lookup(who)?; From 208231ee2f5a3adc44c2f199e109eae6a5d0b952 Mon Sep 17 00:00:00 2001 From: gui Date: Mon, 15 Apr 2024 17:53:33 +0900 Subject: [PATCH 3/5] Pr doc and version bump --- Cargo.lock | 2 +- prdoc/pr_4118.prdoc | 10 ++++++++++ substrate/frame/assets/Cargo.toml | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 prdoc/pr_4118.prdoc diff --git a/Cargo.lock b/Cargo.lock index 27cb7af04d63..0df1ff9383aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9571,7 +9571,7 @@ dependencies = [ [[package]] name = "pallet-assets" -version = "29.0.0" +version = "29.1.0" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/prdoc/pr_4118.prdoc b/prdoc/pr_4118.prdoc new file mode 100644 index 000000000000..8df43c43193b --- /dev/null +++ b/prdoc/pr_4118.prdoc @@ -0,0 +1,10 @@ +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. + +crates: + - name: pallet-assets + bump: minor diff --git a/substrate/frame/assets/Cargo.toml b/substrate/frame/assets/Cargo.toml index 3b95750c14c8..ed6df77e1523 100644 --- a/substrate/frame/assets/Cargo.toml +++ b/substrate/frame/assets/Cargo.toml @@ -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" From 1f2e74e688e44e9ef6d768297a6c081e29955b89 Mon Sep 17 00:00:00 2001 From: gui Date: Mon, 15 Apr 2024 18:05:17 +0900 Subject: [PATCH 4/5] Fix --- prdoc/pr_4118.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_4118.prdoc b/prdoc/pr_4118.prdoc index 8df43c43193b..b24c96eabdab 100644 --- a/prdoc/pr_4118.prdoc +++ b/prdoc/pr_4118.prdoc @@ -1,4 +1,4 @@ -title: pallet assets: minor improvement on errors returned for some calls +title: "pallet assets: minor improvement on errors returned for some calls" doc: - audience: Runtime Dev From 9fd423af236a70b9419d024c876a3478a6c4483f Mon Sep 17 00:00:00 2001 From: gui Date: Mon, 15 Apr 2024 19:11:34 +0900 Subject: [PATCH 5/5] Better message --- prdoc/pr_4118.prdoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prdoc/pr_4118.prdoc b/prdoc/pr_4118.prdoc index b24c96eabdab..20f36c1b0a37 100644 --- a/prdoc/pr_4118.prdoc +++ b/prdoc/pr_4118.prdoc @@ -4,6 +4,9 @@ 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