-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
frame/support/test/tests/pallet_ui/storage_result_query_multiple_type_args.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looking good. However, I would pass the Error
explicitly, e.g. Error::SomeVariant
. This makes it easier to know where SomeVariant
is coming from.
bot rebase |
Rebasing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My review of macros was a bit shallow but tests and the new API all look good to me.
Should be documented in at least one more place, and should mention what error types should be used.
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one thing with the syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. One quibble I have is the nesting/indenting gets very very deep at one point in the macro but this can merge regardless of whether that is fixed
@@ -1436,6 +1532,8 @@ fn test_storage_info() { | |||
traits::{StorageInfo, StorageInfoTrait}, | |||
}; | |||
|
|||
// Storage max size is calculated by adding up all the hasher size, the key type size and the | |||
// value type size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bot merge |
Waiting for commit status. |
bot merge |
* Implement ResultQuery * Fix test expectations * Add more tests * Fix test expectations * Clean up some names * Silence warnings * Specify error type when supplying error type to ResultQuery * cargo fmt * Add support for type parameters in parameter_types macro * Reduce deeply indented code * Fixes * Update test expectation * Rewrite and document formula for calculating max storage size * More docs * cargo fmt * formatting Co-authored-by: parity-processbot <>
Fixes #11010.
Adds a new query type called
ResultQuery
to the list of possible query kinds for storage items. We now haveOptionQuery
,ValueQuery
andResultQuery
.To use it properly, one must also declare a pallet error enum, since that is what the
ResultQuery
uses as theErr
type. When specifying the query type asResultQuery
, a type parameter is expected, and instead of providing an actual type to it, the macro expects a type path that points to a variant of an enum that implementsPalletError
, which will be used as theErr
return value when a value is not found under the supplied storage key, i.e.StorageValue<_, u8, ResultQuery<PalletError<T>::EnumVariantName>>
is the correct way to declare aStorageValue
that returns aResult
containing anErr
value ofErr(PalletError::<T>::EnumVariantName)
when a value under the storage key is not found.