convertToTokenInfo function
Implementation
types.TokenInfo convertToTokenInfo(pb.TokenInfo tokenInfo) {
if (!tokenInfo.hasTokenType()) {
throw Exception(
'chronik returned undefined tokenInfo.tokenType for tokenId "${tokenInfo.tokenId}',
);
}
if (!tokenInfo.hasGenesisInfo()) {
throw Exception(
'chronik returned undefined tokenInfo.genesisInfo for tokenId "${tokenInfo.tokenId}',
);
}
final tokenType = _convertToTokenType(tokenInfo.tokenType);
return types.TokenInfo(
tokenId: tokenInfo.tokenId,
tokenType: tokenType,
timeFirstSeen: tokenInfo.timeFirstSeen.toInt(),
genesisInfo: convertToGenesisInfo(tokenInfo.genesisInfo, tokenType),
block: tokenInfo.hasBlock()
? _convertToBlockMetadata(tokenInfo.block)
: null,
);
}