Skip to content

Commit

Permalink
Merge pull request #144 from threefoldtech/master_fix_node_country_de…
Browse files Browse the repository at this point in the history
…coding

fix node country decoding
  • Loading branch information
MarioBassem authored Dec 14, 2023
2 parents 64469ac + 1b7380e commit 4990d79
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 4990d79

Please sign in to comment.