Skip to content

Commit f67d93b

Browse files
V-Vaaljoelamouche
authored andcommitted
docs: document post-V2 cleanup for BadgeRegistry retro-compat
1 parent d1c05ae commit f67d93b

5 files changed

Lines changed: 56 additions & 0 deletions

File tree

frontend/docs/V2_CLEANUP.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+

frontend/src/hooks/badges/use-create-badge.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function useCreateBadge() {
3939
});
4040
const currentCount = Number(totalBadgesResult ?? 0n);
4141

42+
// TODO(cleanup-after-v2): Remove V1 fallback logic after V2 full deployment. Always use V2 ABI. See docs/V2_CLEANUP.md.
4243
const finalAbiMode = await detectBadgeRegistryVersion(
4344
config,
4445
account as `0x${string}`,

frontend/src/hooks/badges/use-get-badges.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function useGetBadges(): {
2929

3030
const count = Number((totalBadgesQuery.data as bigint | undefined) ?? 0n);
3131

32+
// TODO(cleanup-after-v2): Remove V1 fallback logic after V2 full deployment. Always use V2 ABI. See docs/V2_CLEANUP.md.
3233
// TODO(cleanup): Remove version probe after V2 full deployment
3334
// Probe version with single getBadgeAt(0) call
3435
// This probe runs once per address and is cached forever

frontend/src/lib/badges/registryVersion.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* TODO(cleanup-after-v2): Remove this entire module after V2 full deployment. See docs/V2_CLEANUP.md for details.
3+
*/
4+
15
import type { Config } from "wagmi";
26
import { simulateContract, readContract } from "@wagmi/core";
37
import { BADGE_REGISTRY_ADDRESS } from "@/lib/constants/blockchainConstants";

frontend/src/lib/utils/abiDetection.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* TODO(cleanup-after-v2): Remove this entire module after V2 full deployment. See docs/V2_CLEANUP.md for details.
3+
*
24
* ABI version detection utilities for BadgeRegistry contracts.
35
*
46
* These functions detect contract version (V1 vs V2) by analyzing error messages

0 commit comments

Comments
 (0)