aboutsummaryrefslogblamecommitdiffstats
path: root/packages/utils/src/abi_encoder/evm_data_types/tuple.ts
blob: 3802f96c0034918641578700479bd7d061d81eac (plain) (tree)
1
2
3
4
5
6
7

                                          
                                                                            
 
                                                  
                                        
 








                                                                                      
                                                            


                                   
                               

     
import { DataItem } from 'ethereum-types';

import { AbstractDataTypes, DataTypeFactory } from '../abstract_data_types';

export class Tuple extends AbstractDataTypes.Set {
    private readonly _signature: string;

    public static matchType(type: string): boolean {
        return type === 'tuple';
    }

    public constructor(dataItem: DataItem, dataTypeFactory: DataTypeFactory) {
        super(dataItem, dataTypeFactory);
        if (!Tuple.matchType(dataItem.type)) {
            throw new Error(`Tried to instantiate Tuple with bad input: ${dataItem}`);
        }
        this._signature = this._computeSignatureOfMembers();
    }

    public getSignature(): string {
        return this._signature;
    }
}