1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.TupleDataType = void 0;
|
4 | const ethereum_types_1 = require("ethereum-types");
|
5 | const _ = require("lodash");
|
6 | const set_1 = require("../abstract_data_types/types/set");
|
7 | class TupleDataType extends set_1.AbstractSetDataType {
|
8 | static matchType(type) {
|
9 | return type === ethereum_types_1.SolidityTypes.Tuple;
|
10 | }
|
11 | constructor(dataItem, dataTypeFactory) {
|
12 | super(dataItem, dataTypeFactory);
|
13 | if (!TupleDataType.matchType(dataItem.type)) {
|
14 | throw new Error(`Tried to instantiate Tuple with bad input: ${dataItem}`);
|
15 | }
|
16 | }
|
17 | getSignatureType() {
|
18 | return this._computeSignatureOfMembers(false);
|
19 | }
|
20 | getSignature(isDetailed) {
|
21 | if (_.isEmpty(this.getDataItem().name) || !isDetailed) {
|
22 | return this.getSignatureType();
|
23 | }
|
24 | const name = this.getDataItem().name;
|
25 | const lastIndexOfScopeDelimiter = name.lastIndexOf('.');
|
26 | const isScopedName = lastIndexOfScopeDelimiter !== undefined && lastIndexOfScopeDelimiter > 0;
|
27 | const shortName = isScopedName ? name.substr(lastIndexOfScopeDelimiter + 1) : name;
|
28 | const detailedSignature = `${shortName} ${this._computeSignatureOfMembers(isDetailed)}`;
|
29 | return detailedSignature;
|
30 | }
|
31 | }
|
32 | exports.TupleDataType = TupleDataType;
|
33 |
|
\ | No newline at end of file |