Repository navigation
feat: export quick regex checks for Chelonia CIDs and contract IDs - #115
Conversation
|
/review AI review started. |
Advanced AI Review
Click to expand reviewCode ReviewBase: SummaryAdds Verification performed (beyond reading the diff): ran the new tests and the full suite (476/476 pass), ran ESLint on both files (clean), and independently probed the regexes against the installed
The implementation is correct and well tested. Only two minor issues below. 1. ⚪ Duplicated SHELTER_CONTRACT_DATA prefix across the two Chelonia regexes
const CONTRACT_ID_PREFIX = 'zLDXeQ2AgfCu'
export const CHELONIA_CID_REGEX = new RegExp(
`^z(?:9brRu3V|yop8PQyp|L(?:7mM9d4Xb4T|AeVmpcc88g|${CONTRACT_ID_PREFIX.slice(1)}|GQo2DimCH8|KHweRGqjMM))${BASE58}{44}$`
)
export const CONTRACT_ID_REGEX = new RegExp(`^${CONTRACT_ID_PREFIX}${BASE58}{44}$`)2. ⚪ "What
|
Closes #114
Adds three exports to
@chelonia/lib/functions, next toparseCID, for when parsing every ID costs too much, like validating route parameters:CHELONIA_CID_REGEX: the shape of every CIDparseCIDaccepts (CIDv1, base58btc, blake2b-256, a codec frommulticodes)CONTRACT_ID_REGEX: Chelonia contract IDs onlyCID_REGEX: any CID thatCID.parsedecodes on its own (CIDv0, or CIDv1 in base32 or base58btc)A match only means the string has the right shape. For a definite answer,
maybeParseCIDis still the one to use.The prefixes were checked against the lowest and highest CID each codec can have, so they hold for every CID, not just the ones tested. A test builds CIDs for every codec in
multicodes, so adding a codec without updating the regex fails it.Testing: lint passes, and all 476 tests pass (4 new).
AI Usage: Claude Opus 5.5 Max
Self review: Approved