mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 07:47:57 +00:00
Add ext_transfer call (#5169)
* contracts: Add ext_transfer call This call allows contracts to send balance to any account contract or not. Previously, the only way to do that was though ext_call. * Apply suggestions from code review Co-Authored-By: Nikolay Volf <nikvolf@gmail.com> * The define_env! macro does not allow for trailing comma * Update frame/contracts/src/exec.rs Co-Authored-By: Nikolay Volf <nikvolf@gmail.com> * Bump spec version * Do not use nested gas meter * Use explicit 0 or 1 as return value * Remove superflous intermediate binding Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
committed by
GitHub
parent
7e2cd0edee
commit
b817763ea9
@@ -120,6 +120,14 @@ pub trait Ext {
|
||||
input_data: Vec<u8>,
|
||||
) -> Result<(AccountIdOf<Self::T>, ExecReturnValue), ExecError>;
|
||||
|
||||
/// Transfer some amount of funds into the specified account.
|
||||
fn transfer(
|
||||
&mut self,
|
||||
to: &AccountIdOf<Self::T>,
|
||||
value: BalanceOf<Self::T>,
|
||||
gas_meter: &mut GasMeter<Self::T>,
|
||||
) -> Result<(), DispatchError>;
|
||||
|
||||
/// Call (possibly transferring some amount of funds) into the specified account.
|
||||
fn call(
|
||||
&mut self,
|
||||
@@ -331,6 +339,23 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Transfer balance to `dest` without calling any contract code.
|
||||
pub fn transfer(
|
||||
&mut self,
|
||||
dest: T::AccountId,
|
||||
value: BalanceOf<T>,
|
||||
gas_meter: &mut GasMeter<T>
|
||||
) -> Result<(), DispatchError> {
|
||||
transfer(
|
||||
gas_meter,
|
||||
TransferCause::Call,
|
||||
&self.self_account.clone(),
|
||||
&dest,
|
||||
value,
|
||||
self,
|
||||
)
|
||||
}
|
||||
|
||||
/// Make a call to the specified address, optionally transferring some funds.
|
||||
pub fn call(
|
||||
&mut self,
|
||||
@@ -706,6 +731,15 @@ where
|
||||
self.ctx.instantiate(endowment, gas_meter, code_hash, input_data)
|
||||
}
|
||||
|
||||
fn transfer(
|
||||
&mut self,
|
||||
to: &T::AccountId,
|
||||
value: BalanceOf<T>,
|
||||
gas_meter: &mut GasMeter<T>,
|
||||
) -> Result<(), DispatchError> {
|
||||
self.ctx.transfer(to.clone(), value, gas_meter)
|
||||
}
|
||||
|
||||
fn call(
|
||||
&mut self,
|
||||
to: &T::AccountId,
|
||||
|
||||
Reference in New Issue
Block a user