Skip to content

Commit

Permalink
fix node country decoding
Browse files Browse the repository at this point in the history
Signed-off-by: mario <[email protected]>
  • Loading branch information
MarioBassem committed Dec 14, 2023
1 parent 64469ac commit 1b7380e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/mappings/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Node, Location, PublicConfig, NodeCertification, Interfaces, UptimeEvent, NodeResourcesTotal, NodePower, PowerState, Power } from "../model";
import {
TfgridModuleNodeCertificationSetEvent, TfgridModuleNodeDeletedEvent,
TfgridModuleNodePublicConfigStoredEvent, TfgridModuleNodeStoredEvent,
TfgridModuleNodeUpdatedEvent, TfgridModuleNodeUptimeReportedEvent,
import {
TfgridModuleNodeCertificationSetEvent, TfgridModuleNodeDeletedEvent,
TfgridModuleNodePublicConfigStoredEvent, TfgridModuleNodeStoredEvent,
TfgridModuleNodeUpdatedEvent, TfgridModuleNodeUptimeReportedEvent,
TfgridModulePowerStateChangedEvent, TfgridModulePowerTargetChangedEvent,
SmartContractModuleNodeExtraFeeSetEvent
} from "../types/events";
Expand Down Expand Up @@ -77,6 +77,13 @@ export async function nodeStored(

newNode.location = newLocation

if (newNode.country?.toString().startsWith('0x')) {
newNode.country = ""
}
if (newNode.city?.toString().startsWith('0x')) {
newNode.city = ""
}

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

const pubConfig = getNodePublicConfig(node)
Expand Down Expand Up @@ -126,6 +133,13 @@ export async function nodeStored(
newNode.connectionPrice = nodeEvent.connectionPrice
}

if (newNode.country?.toString().startsWith('0x')) {
newNode.country = ""
}
if (newNode.city?.toString().startsWith('0x')) {
newNode.city = ""
}

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

const resourcesTotal = new NodeResourcesTotal()
Expand Down

0 comments on commit 1b7380e

Please sign in to comment.