@yoroi/portfolio
Version:
The Portfolio package of Yoroi SDK
30 lines (29 loc) • 882 B
JavaScript
import { truncateString } from '@yoroi/common';
import { Portfolio } from '@yoroi/types';
// max name length is 50 and ticker is 9 in CIP26
// if the data is in metadatum there is "no limit"
export 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 === Portfolio.Token.Type.FT) {
return truncateString({
value: info.ticker || info.name || info.fingerprint,
maxLength
});
} else {
// NFTs without names usually are the "header" of collection
return truncateString({
value: info.name || info.fingerprint,
maxLength
});
}
}
return truncateString({
value: info.ticker,
maxLength
});
}
//# sourceMappingURL=info-extract-name.js.map