Shared Libraries Documentation
Overview
The repository uses small shared libraries and centralized custom errors to keep validation behavior consistent across contracts.
Libraries
AddressExtensions
Provides assertAddressNotZero(address).
Behavior:
- Reverts with
ZeroAddress()when the address is zero - Used by dependency wiring and role-management helpers
StringExtensions
Provides fixed-length ASCII conversion helpers used by registry logic.
Core helpers:
_isinToBytes12(string memory isin): Converts an exact 12-byte ISIN string tobytes12; positions0..1must beA-Z, positions2..10must beA-Zor0-9, and position11must be0-9; checksum validation is not performed_currencyToBytes3(string memory currency): Converts an exact 3-byte uppercase currency code (A-Z) tobytes3_stringToFixedBytes(string memory input, uint256 expectedLength): Validates exact length and printable ASCII bytes (0x20..0x7E) before packing intobytes32
Errors:
StringExtensions__InvalidBytesLength(): Input length does not match the expected byte length, or the expected length is greater than 32.StringExtensions__NonAsciiCharacter(): Input contains a byte outside 7-bit ASCII.StringExtensions__InvalidCharacter(): Input contains an ASCII byte outside the required printable/domain-specific character set.
Errors
src/libs/Errors.sol centralizes custom errors for the protocol.
Important Notes:
- Contracts should reuse shared errors instead of introducing ad hoc revert strings
- Several utility-level checks use shared errors such as
ZeroAddress()andEmptyString() - Contract-specific errors are grouped by protocol area inside the same file
Trust and Security Notes
- These helpers are pure validation utilities and do not hold state.
- Changes to shared errors or library validation semantics can affect multiple protocol surfaces and should be reviewed with all call sites.