Timeline for Can SCALE compact encoding be used with `Option<T>`? If so, how exactly?
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 29, 2022 at 17:24 | vote | accept | mkl | ||
Apr 29, 2022 at 17:23 | comment | added | mkl | Many thanks. That's surprisingly simple. | |
Apr 29, 2022 at 17:17 | comment | added | pepyakin | @mkl I've updated the answer. | |
Apr 29, 2022 at 17:17 | history | edited | pepyakin | CC BY-SA 4.0 |
Change the answer to the updated question
|
Apr 29, 2022 at 11:24 | comment | added | mkl |
Thanks, I know generally how pallet::compact works. It just doesn't seem like it works with Option . Sorry, the question was badly phrased. It's now updated.
|
|
Apr 28, 2022 at 22:20 | comment | added | pepyakin |
Well, in that case, it should be as easy as slapping a pallet::compact attribute to an argument. Here is an example: github.com/paritytech/substrate/blob/…
|
|
Apr 28, 2022 at 21:40 | comment | added | mkl |
I'd like to use a compactly encoded Option as parameter for an extrinsic.
|
|
Apr 28, 2022 at 21:36 | comment | added | pepyakin |
Ok, I see, I misinterpreted you. However, it is still not clear what you are asking. Do you mean you want to know how to, e.g., declare a variable that is an Option with an integer, that when encoded, will be represented in compact encoding when Some ?
|
|
Apr 28, 2022 at 21:29 | comment | added | mkl |
What I meant is: How do I actually do this in substrate (using pallet::compact , for example)?
|
|
Apr 28, 2022 at 21:03 | comment | added | pepyakin |
Well, @mkl, there is no magic. The rule is always either 0 or 1 followed by the encoding of the T type in case of Some , irregardless what type T is. I updated the answer with an example.
|
|
Apr 28, 2022 at 21:01 | history | edited | pepyakin | CC BY-SA 4.0 |
Added a compact example.
|
Apr 28, 2022 at 20:52 | comment | added | mkl |
Ok, I figured as much, but how would using an Option of a compact integer look like in Rust?
|
|
Apr 28, 2022 at 20:31 | history | answered | pepyakin | CC BY-SA 4.0 |