0

Trying to compile a V3 macro style pallet against the latest polkadot (0.9.24) dependencies fails with error:

error[E0277]: the trait bound `<T as frame_system::Config>::AccountId: std::default::Default` is not satisfied
   --> pallet-tft-bridge/src/lib.rs:138:1
    |
138 | / decl_storage! {
139 | |     trait Store for Module<T: Config> as TFTBridgeModule {
140 | |         pub Validators get(fn validator_accounts): Vec<T::AccountId>;
141 | |         pub FeeAccount get(fn fee_account): T::AccountId;
...   |
180 | |     }
181 | | }
    | |_^ the trait `std::default::Default` is not implemented for `<T as frame_system::Config>::AccountId`
    |
    = note: this error originates in the macro `decl_storage` (in Nightly builds, run with -Z macro-backtrace for more info)

Do I need to rewrite my pallet using the new syntax style in 4.0.0-dev?

1
  • 1
    since Default is remove from impl of AccountId, make it return Option<AccountId>
    – Ron
    Jun 22 at 9:50

1 Answer 1

0

In this PR the Default bound on AccountId was removed.

As Ron mentioned, the answer to this is to update your code to:

decl_storage! {
    trait Store for Module<T: Config> as TFTBridgeModule {
        pub Validators get(fn validator_accounts): Vec<T::AccountId>;
        pub FeeAccount get(fn fee_account): Option<T::AccountId>;
    }
}

Where FeeAccount returns an Option rather than directly the T::AccountId type.

Another option is to use the syntax:

decl_storage! {
    trait Store for Module<T: Config> as TFTBridgeModule {
        pub Validators get(fn validator_accounts): Vec<T::AccountId>;
        pub FeeAccount get(fn fee_account): T::AccountId = SomeDefaultAccount;
    }
}

Where you can specify what the default value for this storage should be, which allows you to return a value without an option, but also not depend on the Default trait.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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