1

I have the following struct, where Characters is the newtype idiom around Vec<u8>.

#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
pub struct OperationData {
  config: BTreeMap<Characters, Vec<Characters>>
}

Now, If I submit an extrinsic call to save such structure:

{
  config: { hasher: [ 'Sha2_256', 'Blake3_256' ] },
}

The structure is stored correctly but upon reading (for instance in polkadot ui) I get:

{
  config: {
    0x686173686572: [
      Sha2_256
      Blake3_256
    ]
  }
}

It appears that the call to Struct.toHuman() does not attempt any conversion of the UTF-8 hex-encoded bytes of the key of the map entry:

h  a  s  h  e  r
68 61 73 68 65 72

It does, however, decode the bytes inside the value of the map entry.

Is there a way to indicate the decoder to decode the map entry keys as well? Any good reason why Map keys are disregarded despite their type association?

1 Answer 1

1

The toHuman() output is not configurable. Bear in mind that this is a convenience function, not really meant to be used for anything but simple inspection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.