2

I'm uncertain how I can structure the generic variant of a polkadotjs type for an on-chain Enum that looks sort of like this:

#[derive(TypeInfo, Debug, Clone, Encode, Decode, PartialEq)]
pub enum MyEnum<T: Codec> {
    OptionA,
    OptionB(T),
}

I get down to my polkadotjs types and:

...
  MyEnum: {
    _enum: {
      OptionA: null,
      OptionB: '...???',
    },
  },

What should go in OptionB to represent the generic portion?

1 Answer 1

1

IIRC, there shouldn't be any generic. (I didn't use this anymore since metadata 14)

It must be an exact type.

"Balance": "u128"

You can't write "Balance": "T". Unless you tell it "T": "u128".

So, you need to check what is your T on the runtime level.

e.g. https://github.com/darwinia-network/darwinia/blob/85bfeda3161bafb6a42f63b57b169265820972a1/runtime/crab/types.json#L9-L14

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.