UNPKG

1.4 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.TupleDataType = void 0;
4const ethereum_types_1 = require("ethereum-types");
5const _ = require("lodash");
6const set_1 = require("../abstract_data_types/types/set");
7class 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}
32exports.TupleDataType = TupleDataType;
33//# sourceMappingURL=tuple.js.map
\No newline at end of file