decode static method
- String cidStr
Decodes a CID from its string representation.
Implementation
static CID decode(String cidStr) {
if (cidStr.isEmpty) {
throw ArgumentError('Empty CID string');
}
// Check if it's a CIDv0 (base58, starts with 'Qm')
if (cidStr.startsWith('Qm')) {
// Decode base58
final decoded = multibaseDecode(
'z$cidStr',
); // Add 'z' prefix for base58btc
return fromBytes(decoded);
}
// CIDv1: multibase encoded
final decoded = multibaseDecode(cidStr);
return fromBytes(decoded);
}