fuels_programs/calls/traits/
response_parser.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use fuel_tx::Receipt;
use fuels_core::{
    codec::DecoderConfig,
    types::{errors::Result, param_types::ParamType, Token},
};

use crate::calls::{receipt_parser::ReceiptParser, utils::sealed, ContractCall, ScriptCall};

pub trait ResponseParser: sealed::Sealed {
    fn parse_call(
        &self,
        receipts: &[Receipt],
        decoder_config: DecoderConfig,
        param_type: &ParamType,
    ) -> Result<Token>;
}

impl ResponseParser for ContractCall {
    fn parse_call(
        &self,
        receipts: &[Receipt],
        decoder_config: DecoderConfig,
        param_type: &ParamType,
    ) -> Result<Token> {
        ReceiptParser::new(receipts, decoder_config).parse_call(&self.contract_id, param_type)
    }
}

impl ResponseParser for ScriptCall {
    fn parse_call(
        &self,
        receipts: &[Receipt],
        decoder_config: DecoderConfig,
        param_type: &ParamType,
    ) -> Result<Token> {
        ReceiptParser::new(receipts, decoder_config).parse_script(param_type)
    }
}