Skip to content

Commit 94fdaf4

Browse files
sameh-faroukclaude
andcommitted
fix: patch dedicatedFarm field for pre-V14 Farm event decoding
Existing indexer snapshots on all networks were built with an old typesBundle that had a typo: "dedicatedFarm:" (trailing colon) in the Farm struct. The stored JSON has "dedicatedFarm:" as the key, but the processor expects "dedicatedFarm" (no colon) after the typesBundle was corrected. This causes an assertion failure when decoding pre-V14 FarmStored/FarmUpdated events (specs 63-70). Patch the raw event args by reading the actual value from the colon key (falling back to the normal key for corrected indexers, then false for versions that lack the field entirely), instead of hardcoding false which discarded the real on-chain value. Also read dedicatedFarm from the parsed event in farmStored instead of hardcoding false, so farms created as dedicated are recorded correctly. Production 2.12.3 had the workaround in the isV101 branch, which was removed by the typegen automation when relabeling the hash as isV63. Remove this workaround after all indexers are resynced with the corrected typesBundle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 01e6b28 commit 94fdaf4

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/mappings/farms.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ export async function farmStored(
3030
} else if (farmStoredEvent.isV50) {
3131
farmStoredEventParsed = farmStoredEvent.asV50
3232
} else if (farmStoredEvent.isV63) {
33+
// Workaround: existing indexer snapshots were built with an old typesBundle
34+
// that had a typo "dedicatedFarm:" (trailing colon) in the Farm struct.
35+
// The stored JSON has "dedicatedFarm:" as the key, but the processor expects
36+
// "dedicatedFarm" (no colon). Patch with the actual value from the colon key.
37+
// Remove this after all indexers are resynced with the corrected typesBundle.
38+
const rawArgs = item.event.args as any
39+
rawArgs.dedicatedFarm = rawArgs['dedicatedFarm:'] ?? rawArgs.dedicatedFarm ?? false
3340
farmStoredEventParsed = farmStoredEvent.asV63
3441
}
3542

@@ -46,7 +53,9 @@ export async function farmStored(
4653
newFarm.name = validateString(ctx, farmStoredEventParsed.name.toString())
4754
newFarm.twinID = farmStoredEventParsed.twinId
4855
newFarm.pricingPolicyID = farmStoredEventParsed.pricingPolicyId
49-
newFarm.dedicatedFarm = false
56+
newFarm.dedicatedFarm = 'dedicatedFarm' in farmStoredEventParsed
57+
? (farmStoredEventParsed as any).dedicatedFarm
58+
: false
5059
newFarm.certification = FarmCertification.NotCertified
5160

5261
newFarm.publicIPs = []
@@ -133,6 +142,9 @@ export async function farmUpdated(
133142
} else if (farmUpdatedEvent.isV50) {
134143
farmUpdatedEventParsed = farmUpdatedEvent.asV50
135144
} else if (farmUpdatedEvent.isV63) {
145+
// Workaround: see comment in farmStored above for the dedicatedFarm colon typo.
146+
const rawArgs = item.event.args as any
147+
rawArgs.dedicatedFarm = rawArgs['dedicatedFarm:'] ?? rawArgs.dedicatedFarm ?? false
136148
farmUpdatedEventParsed = farmUpdatedEvent.asV63
137149
switch (farmUpdatedEvent.asV63.certification.__kind) {
138150
case "Gold": {

0 commit comments

Comments
 (0)