2

I am trying to use both the Assets module and Balances module in my runtime. They both export the Trait T::Balance. When I bring the Assets module in scope of my trait like so:

pub trait Trait: assets::Trait + balances::Trait {}

I get the following error:

error[E0221]: ambiguous associated type `Balance` in bounds of `T`
   --> /home/volt/workspaces/lsaether/vyzer/runtime/src/markets.rs:124:42
    |
124 |         ValidityBond get(validity_bond): T::Balance;
    |                                          ^^^^^^^^^^ ambiguous associated type `Balance`
    |
note: associated type `T` could derive from `srml_assets::Trait`
   --> /home/volt/workspaces/lsaether/vyzer/runtime/src/markets.rs:124:42
    |
124 |         ValidityBond get(validity_bond): T::Balance;
    |                                          ^^^^^^^^^^
note: associated type `T` could derive from `srml_balances::Trait`
   --> /home/volt/workspaces/lsaether/vyzer/runtime/src/markets.rs:124:42
    |
124 |         ValidityBond get(validity_bond): T::Balance;
    |                                          ^^^^^^^^^^

Shawn Tabrizi
  • 12,206
  • 1
  • 38
  • 69
Lsaether
  • 238
  • 2
  • 5
  • You tagged your question with `substrate`, would you be interested in a dedicated Stack Exchange Q&A site for Substrate, Polkadot, et al. -- check out the [Area51 Substrate Proposal](https://area51.stackexchange.com/proposals/122626/substrate?referrer=NTUwMTkxYjJjOTJiNjE0YzMxYjgwMGNkZmFlYzdhZTczYjk1ZWY3ZGI4NzJmODUwN2RlYTQ2MTNjZTdkOTZhMAzuL-zybtPN9CHzwE-WUdvBC8WxvPG46b4ayadke6kG0) – q9f Jul 28 '19 at 10:59

1 Answers1

4

Rather than use T::Balance here, you need to be more specific for the Rust compiler.

You can do <T as balances::Trait>::Balance or <T as assets::Trait>::Balance to specify which "Balance" you actually want to use.

Let me know if this helps!

Shawn Tabrizi
  • 12,206
  • 1
  • 38
  • 69