fuels_programs/calls/traits/
response_parser.rs

1use fuel_tx::Receipt;
2use fuels_core::{
3    codec::DecoderConfig,
4    types::{errors::Result, param_types::ParamType, Token},
5};
6
7use crate::calls::{receipt_parser::ReceiptParser, utils::sealed, ContractCall, ScriptCall};
8
9pub trait ResponseParser: sealed::Sealed {
10    fn parse_call(
11        &self,
12        receipts: &[Receipt],
13        decoder_config: DecoderConfig,
14        param_type: &ParamType,
15    ) -> Result<Token>;
16}
17
18impl ResponseParser for ContractCall {
19    fn parse_call(
20        &self,
21        receipts: &[Receipt],
22        decoder_config: DecoderConfig,
23        param_type: &ParamType,
24    ) -> Result<Token> {
25        ReceiptParser::new(receipts, decoder_config).parse_call(&self.contract_id, param_type)
26    }
27}
28
29impl ResponseParser for ScriptCall {
30    fn parse_call(
31        &self,
32        receipts: &[Receipt],
33        decoder_config: DecoderConfig,
34        param_type: &ParamType,
35    ) -> Result<Token> {
36        ReceiptParser::new(receipts, decoder_config).parse_script(param_type)
37    }
38}