aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src/abi_encoder/evm_data_types/tuple.ts
blob: 4a90e375a62ea5d51d46c2c0fc60a2c9f6cba4f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { DataItem } from 'ethereum-types';

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

export class Tuple extends MemberDataType {
    private readonly _tupleSignature: 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._tupleSignature = this._computeSignatureOfMembers();
    }

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