fuel_streams_core/transactions/
transaction_ext.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
use crate::types::*;

pub trait TransactionExt {
    fn inputs(&self) -> &[Input];
    fn outputs(&self) -> &Vec<Output>;
}

impl TransactionExt for Transaction {
    fn inputs(&self) -> &[Input] {
        match self {
            Transaction::Mint(_) => &[],
            Transaction::Script(tx) => tx.inputs(),
            Transaction::Blob(tx) => tx.inputs(),
            Transaction::Create(tx) => tx.inputs(),
            Transaction::Upload(tx) => tx.inputs(),
            Transaction::Upgrade(tx) => tx.inputs(),
        }
    }

    fn outputs(&self) -> &Vec<Output> {
        match self {
            Transaction::Mint(_) => {
                static NO_OUTPUTS: Vec<Output> = Vec::new();
                &NO_OUTPUTS
            }
            Transaction::Script(tx) => tx.outputs(),
            Transaction::Blob(tx) => tx.outputs(),
            Transaction::Create(tx) => tx.outputs(),
            Transaction::Upload(tx) => tx.outputs(),
            Transaction::Upgrade(tx) => tx.outputs(),
        }
    }
}