pub fn call(
		&mut self,
		dest: T::AccountId,
		value: BalanceOf<T>,
		gas_meter: &mut GasMeter<T>,
		input_data: &[u8],
		empty_output_buf: EmptyOutputBuf,
	) -> Result<CallReceipt, &'static str> {
		if self.depth == self.config.max_depth as usize {
			return Err("reached maximum depth, cannot make a call");
		}

		if gas_meter
			.charge(self.config, ExecFeeToken::Call)
			.is_out_of_gas()
		{
			return Err("not enough gas to pay base call fee");
		}

		let dest_code_hash = self.overlay.get_code(&dest);
		let mut output_data = Vec::new();

		let (change_set, events, calls) = {
			let mut nested = self.nested(
				OverlayAccountDb::new(&self.overlay),
				dest.clone()
			);

			if value > BalanceOf::<T>::zero() {
				transfer(
					gas_meter,
					TransferCause::Call,
					&self.self_account,
					&dest,
					value,
					&mut nested,
				)?;
			}

			if let Some(dest_code_hash) = dest_code_hash {
				let executable = self.loader.load_main(&dest_code_hash)?;
				output_data = self
					.vm
					.execute(
						&executable,
						&mut CallContext {
							ctx: &mut nested,
							caller: self.self_account.clone(),
							value_transferred: value,
							timestamp: timestamp::Module::<T>::now(),
							random_seed: system::Module::<T>::random_seed(),
						},
						input_data,
						empty_output_buf,
						gas_meter,
					)
					.into_result()?;
			}

			(nested.overlay.into_change_set(), nested.events, nested.calls)
		};

		self.overlay.commit(change_set);
		self.events.extend(events);
		self.calls.extend(calls);

		Ok(CallReceipt { output_data })
	}
/// Make a call to the specified address, optionally transfering some funds.
Make a call to the specified address, optionally transfering some funds.
Make a call to the specified address optionally transfering some funds .
pub fn call(
		&mut self,
		dest: T::AccountId,
		value: BalanceOf<T>,
		gas_meter: &mut GasMeter<T>,
		input_data: &[u8],
		empty_output_buf: EmptyOutputBuf,
	) -> Result<CallReceipt, &'static str> {
		if self.depth == self.config.max_depth as usize {
			return Err("reached maximum depth, cannot make a call");
		}
		if gas_meter
			.charge(self.config, ExecFeeToken::Call)
			.is_out_of_gas()
		{
			return Err("not enough gas to pay base call fee");
		}
		let dest_code_hash = self.overlay.get_code(&dest);
		let mut output_data = Vec::new();
		let (change_set, events, calls) = {
			let mut nested = self.nested(
				OverlayAccountDb::new(&self.overlay),
				dest.clone()
			);
			if value > BalanceOf::<T>::zero() {
				transfer(
					gas_meter,
					TransferCause::Call,
					&self.self_account,
					&dest,
					value,
					&mut nested,
				)?;
			}
			if let Some(dest_code_hash) = dest_code_hash {
				let executable = self.loader.load_main(&dest_code_hash)?;
				output_data = self
					.vm
					.execute(
						&executable,
						&mut CallContext {
							ctx: &mut nested,
							caller: self.self_account.clone(),
							value_transferred: value,
							timestamp: timestamp::Module::<T>::now(),
							random_seed: system::Module::<T>::random_seed(),
						},
						input_data,
						empty_output_buf,
						gas_meter,
					)
					.into_result()?;
			}
			(nested.overlay.into_change_set(), nested.events, nested.calls)
		};
		self.overlay.commit(change_set);
		self.events.extend(events);
		self.calls.extend(calls);
		Ok(CallReceipt { output_data })
	}
pub fn call ( & mut self , dest : T :: AccountId , value : BalanceOf < T > , gas_meter : & mut GasMeter < T > , input_data : & [ u8 ] , empty_output_buf : EmptyOutputBuf , ) -> Result < CallReceipt , & ' static str > { if self . depth == self . config . max_depth as usize { return Err ( " " ) ; } if gas_meter . charge ( self . config , ExecFeeToken :: Call ) . is_out_of_gas ( ) { return Err ( " " ) ; } let dest_code_hash = self . overlay . get_code ( & dest ) ; let mut output_data = Vec :: new ( ) ; let ( change_set , events , calls ) = { let mut nested = self . nested ( OverlayAccountDb :: new ( & self . overlay ) , dest . clone ( ) ) ; if value > BalanceOf :: < T > :: zero ( ) { transfer ( gas_meter , TransferCause :: Call , & self . self_account , & dest , value , & mut nested , ) ? ; } if let Some ( dest_code_hash ) = dest_code_hash { let executable = self . loader . load_main ( & dest_code_hash ) ? ; output_data = self . vm . execute ( & executable , & mut CallContext { ctx : & mut nested , caller : self . self_account . clone ( ) , value_transferred : value , timestamp : timestamp :: Module :: < T > :: now ( ) , random_seed : system :: Module :: < T > :: random_seed ( ) , } , input_data , empty_output_buf , gas_meter , ) . into_result ( ) ? ; } ( nested . overlay . into_change_set ( ) , nested . events , nested . calls ) } ; self . overlay . commit ( change_set ) ; self . events . extend ( events ) ; self . calls . extend ( calls ) ; Ok ( CallReceipt { output_data } ) }
Make a call to the specified address, optionally transfering some funds.
Make a call to the specified address optionally transfering some funds .
&mut self
dest
T::AccountId
value
BalanceOf<T>
gas_meter
&mut GasMeter<T>
input_data
&[u8]
empty_output_buf
EmptyOutputBuf
&mut self
dest
T::AccountId
value
BalanceOf<T>
gas_meter
&mut GasMeter<T>
input_data
&[u8]
empty_output_buf
EmptyOutputBuf