fuels_programs/responses/
submit.rsuse std::fmt::Debug;
use fuel_types::Bytes32;
use fuels_accounts::Account;
use fuels_core::{
traits::{Parameterize, Tokenizable},
types::errors::Result,
};
use crate::{
calls::{
traits::{ContractDependencyConfigurator, ResponseParser, TransactionTuner},
CallHandler, ContractCall,
},
responses::CallResponse,
};
#[derive(Debug)]
pub struct SubmitResponse<A, C, T> {
tx_id: Bytes32,
call_handler: CallHandler<A, C, T>,
}
impl<A, C, T> SubmitResponse<A, C, T>
where
A: Account,
C: ContractDependencyConfigurator + TransactionTuner + ResponseParser,
T: Tokenizable + Parameterize + Debug,
{
pub fn new(tx_id: Bytes32, call_handler: CallHandler<A, C, T>) -> Self {
Self {
tx_id,
call_handler,
}
}
pub async fn response(self) -> Result<CallResponse<T>> {
let provider = self.call_handler.account.try_provider()?;
let receipts = provider
.tx_status(&self.tx_id)
.await?
.take_receipts_checked(Some(&self.call_handler.log_decoder))?;
self.call_handler.get_response(receipts)
}
pub fn tx_id(&self) -> Bytes32 {
self.tx_id
}
}
impl<A: Account> SubmitResponse<A, Vec<ContractCall>, ()> {
pub fn new(tx_id: Bytes32, call_handler: CallHandler<A, Vec<ContractCall>, ()>) -> Self {
Self {
tx_id,
call_handler,
}
}
pub async fn response<T: Tokenizable + Debug>(self) -> Result<CallResponse<T>> {
let provider = self.call_handler.account.try_provider()?;
let receipts = provider
.tx_status(&self.tx_id)
.await?
.take_receipts_checked(Some(&self.call_handler.log_decoder))?;
self.call_handler.get_response(receipts)
}
pub fn tx_id(&self) -> Bytes32 {
self.tx_id
}
}