after importing pallet_vesting, one of the pre-built pallets https://docs.substrate.io/rustdocs/latest/pallet_vesting/pallet/enum.Call.html
I have imported sp_runtime
use frame_support::{
pallet_prelude::*,
sp_runtime::traits::{Hash, StaticLookup, Zero},
traits::{Currency, LockableCurrency, ReservableCurrency},
};
use pallet_vesting;
I would like to use the following functions from that pallet_vesting source code:
fn add_vesting_schedule(
who: &T::AccountId,
locked: BalanceOf<T>,
per_block: BalanceOf<T>,
starting_block: T::BlockNumber,
) -> DispatchResult {...}
pub fn vested_transfer(
origin: OriginFor<T>,
target: <T::Lookup as StaticLookup>::Source,
schedule: VestingInfo<BalanceOf<T>, T::BlockNumber>,
) -> DispatchResult {...}
I have figured out those types:
OriginFor<T>
for origin type
BlockNumberFor<T>
, for starting_block T::BlockNumber
type
T::AccountId
, for my target or destination arguments
BalanceOf<T>
for locked type and per_block type
type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
But that T::AccountId
is not compatible with the vested_transfer() function's target type! See the error message below:
type annotations needed
cannot satisfy _: pallet_vesting::Config
rustcE0283
lib.rs(281, 10): required by a bound in pallet_vesting::Pallet::<T>::vested_transfer
how can I import the correct target type?
further digging into the source code, I got this:
use sp_runtime::traits::{StaticLookup, Zero};
...
impl<T: Config> Lookup for ChainContext<T> {
type Source = <T::Lookup as StaticLookup>::Source;
type Target = <T::Lookup as StaticLookup>::Target;
...
}
Please help. Thank you!