0

Hi I am currently upgrading our runtime to Polkadot 1.0 but when I try to build it get the following errors

error[E0277]: the trait bound `MintingRateInfo: Deserialize<'_>` is not satisfied
     --> /home/aibrayanov/Blockchain/metaverse_network/dev/pallets/estate/src/lib.rs:249:3
      |
  249 |         pub minting_rate_config: MintingRateInfo,
      |         ^^^ the trait `Deserialize<'_>` is not implemented for `MintingRateInfo`

  error[E0277]: the trait bound `MintingRateInfo: Serialize` is not satisfied
      --> /home/aibrayanov/Blockchain/metaverse_network/dev/pallets/estate/src/lib.rs:61:1
       |
  61   | #[frame_support::pallet]
       | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Serialize` is not implemented for `MintingRateInfo`

This error occurs despite that both Serialize and Deserialize are enabled for MintingRateInfo type. The code can be found here

5
  • 1
    Perhaps you could give a more precise link to the snipper of code where Serialize and Deserialize are implemented on MintingRateInfo?
    – jsdw
    Commented Aug 7, 2023 at 8:47
  • @jsdw here is the implementation of MintingRateInfo github.com/chexware/Bit-Country-Blockchain/blob/runtime-upgrade/…
    – chexware
    Commented Aug 7, 2023 at 13:39
  • I can see that the "std" feature is required for Serialize and Deserialize, and presumably the pallet will be compiled without "std", so perhaps that's the issue?
    – jsdw
    Commented Aug 8, 2023 at 15:26
  • @jsdw Yeah it was working fine with this configuration until at least serde version 1.0.136. For some reason the Serialization/Deserialization seems to not be supported for the type after.
    – chexware
    Commented Aug 8, 2023 at 16:45
  • I'm afraid I'll have to see what somebody with more experience compiling pallets chime in then. As an experiment, you could try removing the cfg(feature = "std") stuff from the Serialize/Deserialize derives and see what errors come back, because that's the only thing that I can see that would lead to your error message.
    – jsdw
    Commented Aug 11, 2023 at 8:59

1 Answer 1

0

The problem came from defining the Serialize and Deserialize features for the types I replaced the macros

#[derive(
    Encode,
    Decode,
    Eq,
    PartialEq,
    Copy,
    Clone,
    RuntimeDebug,
    MaxEncodedLen,
    PartialOrd,
    Ord,
    TypeInfo,
)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]

with

#[derive(
    Encode,
    Decode,
    Eq,
    PartialEq,
    Copy,
    Clone,
    RuntimeDebug,
    MaxEncodedLen,
    PartialOrd,
    Ord,
    TypeInfo,
    Serialize,
    Deserialize,
)]

Also replaced

[features]
std = [
"serde",
 ...
]

with

[features]
 std = [
    "serde/std",
     ...
    ]

Also, enabled the derive and alloc features of serde and the problem was resolved.

Your Answer

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

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