fuels_programs/responses/
call.rs

1use std::fmt::Debug;
2
3use fuel_tx::TxId;
4use fuels_core::{
5    codec::{LogDecoder, LogResult},
6    traits::{Parameterize, Tokenizable},
7    types::{errors::Result, tx_status::Success},
8};
9
10/// [`CallResponse`] is a struct that is returned by a call to the contract or script. Its value
11/// field holds the decoded typed value returned by the contract's method. The other field holds all
12/// the receipts returned by the call.
13#[derive(Clone, Debug)]
14// ANCHOR: call_response
15pub struct CallResponse<D> {
16    pub value: D,
17    pub tx_status: Success,
18    pub tx_id: Option<TxId>,
19    pub log_decoder: LogDecoder,
20}
21// ANCHOR_END: call_response
22
23impl<D> CallResponse<D> {
24    pub fn decode_logs(&self) -> LogResult {
25        self.log_decoder.decode_logs(&self.tx_status.receipts)
26    }
27
28    pub fn decode_logs_with_type<T: Tokenizable + Parameterize + 'static>(&self) -> Result<Vec<T>> {
29        self.log_decoder
30            .decode_logs_with_type::<T>(&self.tx_status.receipts)
31    }
32}