fn transfer<'a, T: Config, V: Vm<T>, L: Loader<T>>(
	cause: TransferCause,
	origin: TransactorKind,
	transactor: &T::AccountId,
	dest: &T::AccountId,
	value: BalanceOf<T>,
	ctx: &mut ExecutionContext<'a, T, V, L>,
) -> Result<(), DispatchError>
where
	T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
{
	use self::TransferCause::*;
	use self::TransactorKind::*;

	// Only seal_terminate is allowed to bring the sender below the subsistence
	// threshold or even existential deposit.
	let existence_requirement = match (cause, origin) {
		(Terminate, _) => ExistenceRequirement::AllowDeath,
		(_, Contract) => {
			ensure!(
				T::Currency::total_balance(transactor).saturating_sub(value) >=
					ctx.config.subsistence_threshold(),
				Error::<T>::BelowSubsistenceThreshold,
			);
			ExistenceRequirement::KeepAlive
		},
		(_, PlainAccount) => ExistenceRequirement::KeepAlive,
	};

	T::Currency::transfer(transactor, dest, value, existence_requirement)
		.map_err(|_| Error::<T>::TransferFailed)?;

	Ok(())
}
/// Transfer some funds from `transactor` to `dest`.
///
/// We only allow allow for draining all funds of the sender if `cause` is
/// is specified as `Terminate`. Otherwise, any transfer that would bring the sender below the
/// subsistence threshold (for contracts) or the existential deposit (for plain accounts)
/// results in an error.
Transfer some funds from `transactor` to `dest`.
We only allow allow for draining all funds of the sender if `cause` is
is specified as `Terminate`. Otherwise, any transfer that would bring the sender below the
subsistence threshold (for contracts) or the existential deposit (for plain accounts)
results in an error.
Transfer some funds from ` transactor ` to ` dest ` . We only allow allow for draining all funds of the sender if ` cause ` is is specified as ` Terminate ` . Otherwise any transfer that would bring the sender below the subsistence threshold ( for contracts ) or the existential deposit ( for plain accounts ) results in an error .
fn transfer<'a, T: Config, V: Vm<T>, L: Loader<T>>(
	cause: TransferCause,
	origin: TransactorKind,
	transactor: &T::AccountId,
	dest: &T::AccountId,
	value: BalanceOf<T>,
	ctx: &mut ExecutionContext<'a, T, V, L>,
) -> Result<(), DispatchError>
where
	T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
{
	use self::TransferCause::*;
	use self::TransactorKind::*;
	// Only seal_terminate is allowed to bring the sender below the subsistence
	// threshold or even existential deposit.
	let existence_requirement = match (cause, origin) {
		(Terminate, _) => ExistenceRequirement::AllowDeath,
		(_, Contract) => {
			ensure!(
				T::Currency::total_balance(transactor).saturating_sub(value) >=
					ctx.config.subsistence_threshold(),
				Error::<T>::BelowSubsistenceThreshold,
			);
			ExistenceRequirement::KeepAlive
		},
		(_, PlainAccount) => ExistenceRequirement::KeepAlive,
	};
	T::Currency::transfer(transactor, dest, value, existence_requirement)
		.map_err(|_| Error::<T>::TransferFailed)?;
	Ok(())
}
fn transfer < ' a , T : Config , V : Vm < T > , L : Loader < T > > ( cause : TransferCause , origin : TransactorKind , transactor : & T :: AccountId , dest : & T :: AccountId , value : BalanceOf < T > , ctx : & mut ExecutionContext < ' a , T , V , L > , ) -> Result < ( ) , DispatchError > where T :: AccountId : UncheckedFrom < T :: Hash > + AsRef < [ u8 ] > , { use self :: TransferCause :: * ; use self :: TransactorKind :: * ; // Only seal_terminate is allowed to bring the sender below the subsistence // threshold or even existential deposit. let existence_requirement = match ( cause , origin ) { ( Terminate , _ ) => ExistenceRequirement :: AllowDeath , ( _ , Contract ) => { ensure ! ( T Currency total_balance ( transactor ) saturating_sub ( value ) ctx config subsistence_threshold ( ) Error T BelowSubsistenceThreshold ) ; ExistenceRequirement :: KeepAlive } , ( _ , PlainAccount ) => ExistenceRequirement :: KeepAlive , } ; T :: Currency :: transfer ( transactor , dest , value , existence_requirement ) . map_err ( | _ | Error :: < T > :: TransferFailed ) ? ; Ok ( ( ) ) }
Transfer some funds from `transactor` to `dest`.
Transfer some funds from ` transactor ` to ` dest ` .
cause
TransferCause
origin
TransactorKind
transactor
&T::AccountId
dest
&T::AccountId
value
BalanceOf<T>
ctx
&mut ExecutionContext<'a, T, V, L>
cause
TransferCause
origin
TransactorKind
transactor
&T::AccountId
dest
&T::AccountId
value
BalanceOf<T>
ctx
&mut ExecutionContext<'a, T, V, L>