You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow-up to #208 (bug fixes) and #210 (logic issues). During the same audit, several code quality improvements were identified. None affect runtime behavior — these are cleanup items.
Unused imports
I1nodes.ts:16 — import { allowedNodeEnvironmentFlags } from "process" — never used
I2tftPrice.ts:1,5 — Store from @subsquid/typeorm-store and In from typeorm — never used
Unused debug variables
I3nodes.ts:672-673 — Variables h and r in getNodePublicConfig() are assigned but never read (leftover debug code)
Dead functions
I5twins.ts:57-119 — twinCreateOrUpdateOrDelete() is never called from processor.ts. The processor uses twinStored, twinUpdated, twinDeleted individually instead. The function also contains a dormant bug (L5 from Logic issues in event mapping handlers #210 context: misses accountID update on same-batch create+update), but since it's never called, the bug never fires.
I6contracts.ts:375-405 — contractBilled() is never called. collectContractBillReports() performs the same work and is the function actually used by the processor.
Duplicated certification parsing
I8 7 identical switch blocks parsing certification.__kind (Diy/Certified) across nodes.ts (4 occurrences in nodeUpdated, 1 in nodeCertificationSet) and policies.ts (2 occurrences). Should be extracted to a shared helper function.
Dead OneToMany array pushes
These push to @OneToMany relation arrays on the "one" side, which has no effect in TypeORM — the relationship is owned by the "many" side's @ManyToOne foreign key. The pushes modify in-memory arrays but are never persisted.
I9nodes.ts:340 — savedNode.interfaces.push(newInterface) in nodeUpdated()
I10nodes.ts:140 — newNode.interfaces = [] in nodeStored() (initialization for an array that's never used)
I11farms.ts:71 — newFarm.publicIPs?.push(newIP) in farmStored()
I12farms.ts:189 — savedFarm.publicIPs.push(newIP) in farmUpdated()
Confirmed by model inspection: Both Node.interfaces and Farm.publicIPs are @OneToMany_ relations. The FK lives on Interfaces.node and PublicIp.farm respectively.
Context
Follow-up to #208 (bug fixes) and #210 (logic issues). During the same audit, several code quality improvements were identified. None affect runtime behavior — these are cleanup items.
Unused imports
nodes.ts:16—import { allowedNodeEnvironmentFlags } from "process"— never usedtftPrice.ts:1,5—Storefrom@subsquid/typeorm-storeandInfromtypeorm— never usedUnused debug variables
nodes.ts:672-673— VariableshandringetNodePublicConfig()are assigned but never read (leftover debug code)Dead functions
twins.ts:57-119—twinCreateOrUpdateOrDelete()is never called fromprocessor.ts. The processor usestwinStored,twinUpdated,twinDeletedindividually instead. The function also contains a dormant bug (L5 from Logic issues in event mapping handlers #210 context: missesaccountIDupdate on same-batch create+update), but since it's never called, the bug never fires.contracts.ts:375-405—contractBilled()is never called.collectContractBillReports()performs the same work and is the function actually used by the processor.Duplicated certification parsing
switchblocks parsingcertification.__kind(Diy/Certified) acrossnodes.ts(4 occurrences innodeUpdated, 1 innodeCertificationSet) andpolicies.ts(2 occurrences). Should be extracted to a shared helper function.Dead OneToMany array pushes
These push to
@OneToManyrelation arrays on the "one" side, which has no effect in TypeORM — the relationship is owned by the "many" side's@ManyToOneforeign key. The pushes modify in-memory arrays but are never persisted.nodes.ts:340—savedNode.interfaces.push(newInterface)innodeUpdated()nodes.ts:140—newNode.interfaces = []innodeStored()(initialization for an array that's never used)farms.ts:71—newFarm.publicIPs?.push(newIP)infarmStored()farms.ts:189—savedFarm.publicIPs.push(newIP)infarmUpdated()Confirmed by model inspection: Both
Node.interfacesandFarm.publicIPsare@OneToMany_relations. The FK lives onInterfaces.nodeandPublicIp.farmrespectively.Related: #208 (bug fixes), #210 (logic issues), PR #209