@yoroi/portfolio
Version:
The Portfolio package of Yoroi SDK
35 lines (34 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.infoExtractName = infoExtractName;
var _common = require("@yoroi/common");
var _types = require("@yoroi/types");
// max name length is 50 and ticker is 9 in CIP26
// if the data is in metadatum there is "no limit"
function infoExtractName(info) {
let {
mode = 'name',
maxLength = mode === 'name' ? 25 : 9
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (mode === 'name') {
if (info.type === _types.Portfolio.Token.Type.FT) {
return (0, _common.truncateString)({
value: info.ticker || info.name || info.fingerprint,
maxLength
});
} else {
// NFTs without names usually are the "header" of collection
return (0, _common.truncateString)({
value: info.name || info.fingerprint,
maxLength
});
}
}
return (0, _common.truncateString)({
value: info.ticker,
maxLength
});
}
//# sourceMappingURL=info-extract-name.js.map