Skip to content

Commit 5a438e7

Browse files
sameh-faroukclaude
andcommitted
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) <noreply@anthropic.com>
1 parent 8ff1cc7 commit 5a438e7

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/mappings/nodes.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ export async function nodeStored(
7272

7373
newNode.created = Number(nodeEvent.created)
7474
newNode.farmingPolicyId = nodeEvent.farmingPolicyId
75-
newNode.certification = NodeCertification.Diy
75+
newNode.certification = NodeCertification.Diy // v9 default; overridden below for v28+
76+
77+
if (node.isV28) {
78+
const nodeAsV28 = node.asV28
79+
newNode.certification = nodeAsV28.certificationType
80+
? parseNodeCertification(nodeAsV28.certificationType.__kind.toString())
81+
: NodeCertification.Diy
82+
}
7683

7784
const newLocation = new Location()
7885
newLocation.id = item.event.id
@@ -103,6 +110,9 @@ export async function nodeStored(
103110
newNode.secure = nodeAsV43.secureBoot ? true : false
104111
newNode.virtualized = nodeAsV43.virtualized ? true : false
105112
newNode.serialNumber = validateString(ctx, nodeAsV43.serialNumber.toString())
113+
newNode.certification = nodeAsV43.certificationType
114+
? parseNodeCertification(nodeAsV43.certificationType.__kind.toString())
115+
: NodeCertification.Diy
106116
}
107117

108118
if (node.isV63 || node.isV105) {
@@ -120,6 +130,9 @@ export async function nodeStored(
120130
newNode.virtualized = nodeEvent.virtualized ? true : false
121131
newNode.serialNumber = validateString(ctx, nodeEvent.serialNumber.toString())
122132
newNode.connectionPrice = nodeEvent.connectionPrice
133+
newNode.certification = nodeEvent.certification
134+
? parseNodeCertification(nodeEvent.certification.__kind.toString())
135+
: NodeCertification.Diy
123136
}
124137

125138
if (node.isV118) {
@@ -130,6 +143,9 @@ export async function nodeStored(
130143
newNode.virtualized = nodeEvent.virtualized ? true : false
131144
newNode.serialNumber = nodeEvent.serialNumber ? validateString(ctx, nodeEvent.serialNumber.toString()) : 'Unknown'
132145
newNode.connectionPrice = nodeEvent.connectionPrice
146+
newNode.certification = nodeEvent.certification
147+
? parseNodeCertification(nodeEvent.certification.__kind.toString())
148+
: NodeCertification.Diy
133149
}
134150

135151
await ctx.store.save<Node>(newNode)

0 commit comments

Comments
 (0)