0

i gonna add pallet-assets in my project but i faced this error :

error[E0046]: not all trait items implemented, missing: RemoveItemsLimit, AssetIdParameter, CreateOrigin, CallbackHandle --> /home/kianoush/projects/substrate_dex/runtime/src/lib.rs:289:1 | 289 | impl pallet_assets::Config for Runtime { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing RemoveItemsLimit, AssetIdParameter, CreateOrigin, CallbackHandle in implementation | = help: implement the missing item: type RemoveItemsLimit = Type; = help: implement the missing item: type AssetIdParameter = Type; = help: implement the missing item: type CreateOrigin = Type; = help: implement the missing item: type CallbackHandle = Type;

Repository

i did these steps :

1 - Add pallet-assets in Cargo.toml :

pallet-assets = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }

2 - Add this Config in runtime.rs :

   pub type AssetBalance = Balance;
pub type AssetId = u32;

impl pallet_assets::Config for Runtime {
    type RuntimeEvent = RuntimeEvent;
    type Balance = AssetBalance;
    type AssetId = AssetId;
    type Currency = Balances;
    type ForceOrigin = EnsureRoot<AccountId>;
    type AssetDeposit = ConstU128<1>;
    type AssetAccountDeposit = ConstU128<10>;
    type MetadataDepositBase = ConstU128<1>;
    type MetadataDepositPerByte = ConstU128<1>;
    type ApprovalDeposit = ConstU128<1>;
    type StringLimit = ConstU32<50>;
    type Freezer = ();
    type Extra = ();
    type WeightInfo = ();
}

whats the problem ? how can i solve this problem ?

2
  • Can you include the entire error message, if too big, the top most error message? Jan 13 at 17:59
  • @Purple_Turtle questoin is edited , please check the error message
    – Mr Coder
    Jan 13 at 18:02

2 Answers 2

1

Just reading the error, it seems you have incomplete configuration of pallet-assets. Here's what the pallet needs:

pub trait Config<I: 'static = ()>: Config {
    type RuntimeEvent: From<Event<Self, I>> + IsType<<Self as Config>::RuntimeEvent>;
    type Balance: Member + Parameter + AtLeast32BitUnsigned + Default + Copy + MaybeSerializeDeserialize + MaxEncodedLen + TypeInfo;
    type RemoveItemsLimit: Get<u32>;
    type AssetId: Member + Parameter + Copy + MaybeSerializeDeserialize + MaxEncodedLen;
    type AssetIdParameter: Parameter + Copy + From<Self::AssetId> + Into<Self::AssetId> + MaxEncodedLen;
    type Currency: ReservableCurrency<Self::AccountId>;
    type CreateOrigin: EnsureOriginWithArg<Self::RuntimeOrigin, Self::AssetId, Success = Self::AccountId>;
    type ForceOrigin: EnsureOrigin<Self::RuntimeOrigin>;
    type AssetDeposit: Get<<<Self as Config<I>>::Currency as Currency<<Self as SystemConfig>::AccountId>>::Balance>;
    type AssetAccountDeposit: Get<<<Self as Config<I>>::Currency as Currency<<Self as SystemConfig>::AccountId>>::Balance>;
    type MetadataDepositBase: Get<<<Self as Config<I>>::Currency as Currency<<Self as SystemConfig>::AccountId>>::Balance>;
    type MetadataDepositPerByte: Get<<<Self as Config<I>>::Currency as Currency<<Self as SystemConfig>::AccountId>>::Balance>;
    type ApprovalDeposit: Get<<<Self as Config<I>>::Currency as Currency<<Self as SystemConfig>::AccountId>>::Balance>;
    type StringLimit: Get<u32>;
    type Freezer: FrozenBalance<Self::AssetId, Self::AccountId, Self::Balance>;
    type Extra: Member + Parameter + Default + MaxEncodedLen;
    type CallbackHandle: AssetsCallback<Self::AssetId, Self::AccountId>;
    type WeightInfo: WeightInfo;
    type BenchmarkHelper: BenchmarkHelper<Self::AssetIdParameter>;
}

However, that said, if you switch your pallet-assets to use polkadot-v0.9.32, you don't need to provide the extra configuration and this should work with it.

0
1

This error means there are some trait items not implemented. The pallet_assets::Config is the trait being implemented on the runtime type. For example something like this

trait Foo {
    fn foo();
}

struct Bar;

impl Foo for Bar {}
// error: not all trait items implemented, missing: `foo`
```


as you can see when implementing the trait for the struct it doesn't contain the trait itemfn foo(). The solution would be to add fn foo() like

trait Foo {
    fn foo();
}

struct Bar;

impl Foo for Bar {
    fn foo() {} // ok!
}

So in your case the trait items not implemented are included in the error and the solution would be to add type RemoveItemsLimit = ();, type AssetIdParameter = ();, type CreateOrigin = ();, type CallbackHandle = (); to your trait implementation like:

 pub type AssetBalance = Balance;
pub type AssetId = u32;

impl pallet_assets::Config for Runtime {
    type RuntimeEvent = RuntimeEvent;
    type Balance = AssetBalance;
    type RemoveItemsLimit = ();
    type AssetId = AssetId;
    type AssetIdParameter = ();
    type Currency = Balances;
    type CreateOrigin = ();
    type ForceOrigin = EnsureRoot<AccountId>;
    type AssetDeposit = ConstU128<1>;
    type AssetAccountDeposit = ConstU128<10>;
    type MetadataDepositBase = ConstU128<1>;
    type MetadataDepositPerByte = ConstU128<1>;
    type ApprovalDeposit = ConstU128<1>;
    type StringLimit = ConstU32<50>;
    type Freezer = ();
    type Extra = ();
    type CallbackHandle = ();
    type WeightInfo = ();
}

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.