From 5a438e76e97ce3efdda91f5fc37bd42cb8991c07 Mon Sep 17 00:00:00 2001 From: Sameh Abouel-saad Date: Wed, 1 Apr 2026 23:07:15 +0200 Subject: [PATCH] fix: read node certification from NodeStored event payload nodeStored hardcoded certification to Diy and never read the actual value from the event payload. Since spec v107, create_node assigns certification from the farming policy (which can be Certified), but the processor ignored it. Nodes created under a Certified farming policy showed as Diy in GraphQL. Now reads certification from the event for all versions that include it: certificationType for v28/v43, certification for v63/v105/v118. The v9 default (Diy) is preserved since v9 Node has no certification field. This matches the pattern already used in nodeUpdated. Fixes: #193 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/mappings/nodes.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mappings/nodes.ts b/src/mappings/nodes.ts index 993119d..550361d 100644 --- a/src/mappings/nodes.ts +++ b/src/mappings/nodes.ts @@ -72,7 +72,14 @@ export async function nodeStored( newNode.created = Number(nodeEvent.created) newNode.farmingPolicyId = nodeEvent.farmingPolicyId - newNode.certification = NodeCertification.Diy + newNode.certification = NodeCertification.Diy // v9 default; overridden below for v28+ + + if (node.isV28) { + const nodeAsV28 = node.asV28 + newNode.certification = nodeAsV28.certificationType + ? parseNodeCertification(nodeAsV28.certificationType.__kind.toString()) + : NodeCertification.Diy + } const newLocation = new Location() newLocation.id = item.event.id @@ -103,6 +110,9 @@ export async function nodeStored( newNode.secure = nodeAsV43.secureBoot ? true : false newNode.virtualized = nodeAsV43.virtualized ? true : false newNode.serialNumber = validateString(ctx, nodeAsV43.serialNumber.toString()) + newNode.certification = nodeAsV43.certificationType + ? parseNodeCertification(nodeAsV43.certificationType.__kind.toString()) + : NodeCertification.Diy } if (node.isV63 || node.isV105) { @@ -120,6 +130,9 @@ export async function nodeStored( newNode.virtualized = nodeEvent.virtualized ? true : false newNode.serialNumber = validateString(ctx, nodeEvent.serialNumber.toString()) newNode.connectionPrice = nodeEvent.connectionPrice + newNode.certification = nodeEvent.certification + ? parseNodeCertification(nodeEvent.certification.__kind.toString()) + : NodeCertification.Diy } if (node.isV118) { @@ -130,6 +143,9 @@ export async function nodeStored( newNode.virtualized = nodeEvent.virtualized ? true : false newNode.serialNumber = nodeEvent.serialNumber ? validateString(ctx, nodeEvent.serialNumber.toString()) : 'Unknown' newNode.connectionPrice = nodeEvent.connectionPrice + newNode.certification = nodeEvent.certification + ? parseNodeCertification(nodeEvent.certification.__kind.toString()) + : NodeCertification.Diy } await ctx.store.save(newNode)