|
| 1 | +# BadgeRegistry V2 Cleanup Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This document outlines the cleanup steps required after full V2 deployment of BadgeRegistry contracts. The current codebase includes retro-compatibility logic to support both V1 and V2 contracts during the migration period. Once all registries are upgraded to V2, this temporary code can be removed. |
| 6 | + |
| 7 | +## Files to Delete |
| 8 | + |
| 9 | +- `frontend/src/lib/utils/abiDetection.ts` - Error-based ABI detection utilities |
| 10 | +- `frontend/src/lib/badges/registryVersion.ts` - Version detection module |
| 11 | + |
| 12 | +## Functions / Logic to Remove |
| 13 | + |
| 14 | +- `detectBadgeRegistryVersion()` - Version detection function |
| 15 | +- `isDecodeError()` - Decode error detection utility |
| 16 | +- `isFunctionSelectorError()` - Function selector error detection utility |
| 17 | +- `buildCreateBadgeArgs()` - Conditional argument builder for V1/V2 differences |
| 18 | +- Any version-probe logic / error-based ABI inference |
| 19 | + |
| 20 | +## Hook Simplifications |
| 21 | + |
| 22 | +### use-create-badge.ts |
| 23 | + |
| 24 | +- Remove version detection and conditional ABI selection |
| 25 | +- Remove `detectBadgeRegistryVersion()` call |
| 26 | +- Always use `badgeRegistryAbiV2` (remove conditional `finalAbiMode === "v2" ? badgeRegistryAbiV2 : badgeRegistryAbiV1`) |
| 27 | +- Always use `bytes` description format: replace `buildCreateBadgeArgs()` with direct `stringToBytes(description)` |
| 28 | +- Remove `badgeRegistryAbiV1` import |
| 29 | +- Remove `detectBadgeRegistryVersion` import |
| 30 | +- Remove `buildCreateBadgeArgs` import |
| 31 | + |
| 32 | +### use-get-badges.ts |
| 33 | + |
| 34 | +- Remove version probing / `abiMode` inference |
| 35 | +- Remove `versionProbeQuery` query |
| 36 | +- Remove `abiMode` useMemo logic |
| 37 | +- Always use `badgeRegistryAbiV2` in `badgeContracts` (remove conditional ABI selection) |
| 38 | +- Always decode description as `bytes` using `bytesToString()` (remove conditional `bytesToString` vs `bytes32ToString`) |
| 39 | +- Remove `isDecodeError` import and usage |
| 40 | +- Remove `badgeRegistryAbiV1` import |
| 41 | + |
| 42 | +## Expected End State |
| 43 | + |
| 44 | +- Only V2 ABI (`badgeRegistryAbiV2`) used throughout the codebase |
| 45 | +- No fallback branches or conditional logic based on contract version |
| 46 | +- No error-based ABI detection or version probing |
| 47 | +- Simpler, more maintainable codebase with reduced complexity |
| 48 | + |
0 commit comments