Skip to content

Commit

Permalink
fmt: fix inconsistent use of spaces in indentation (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
sameh-farouk authored May 13, 2024
1 parent 9e8000a commit 78e0955
Show file tree
Hide file tree
Showing 20 changed files with 2,426 additions and 2,426 deletions.
874 changes: 437 additions & 437 deletions src/mappings/contracts.ts

Large diffs are not rendered by default.

636 changes: 318 additions & 318 deletions src/mappings/farms.ts

Large diffs are not rendered by default.

1,214 changes: 607 additions & 607 deletions src/mappings/nodes.ts

Large diffs are not rendered by default.

306 changes: 153 additions & 153 deletions src/mappings/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,187 +3,187 @@ import { Ctx } from "../processor";
import { EventItem } from '@subsquid/substrate-processor/lib/interfaces/dataSelection'

import {
PricingPolicy, FarmingPolicy,
Policy, FarmCertification,
NodeCertification
PricingPolicy, FarmingPolicy,
Policy, FarmCertification,
NodeCertification
} from "../model";
import {
TfgridModulePricingPolicyStoredEvent, TfgridModuleFarmingPolicyStoredEvent,
TfgridModuleFarmingPolicyUpdatedEvent
TfgridModulePricingPolicyStoredEvent, TfgridModuleFarmingPolicyStoredEvent,
TfgridModuleFarmingPolicyUpdatedEvent
} from "../types/events";
import { validateString } from "./nodes"

export async function pricingPolicyStored(
ctx: Ctx,
item: EventItem<'TfgridModule.PricingPolicyStored', { event: { args: true } }>,
ctx: Ctx,
item: EventItem<'TfgridModule.PricingPolicyStored', { event: { args: true } }>,
) {
let pricingPolicyEvent = new TfgridModulePricingPolicyStoredEvent(ctx, item.event)
let pricingPolicyEvent = new TfgridModulePricingPolicyStoredEvent(ctx, item.event)

let pricingPolicyEventParsed
let pricingPolicyEventParsed

if (pricingPolicyEvent.isV49) {
pricingPolicyEventParsed = pricingPolicyEvent.asV49
} else if (pricingPolicyEvent.isV51) {
pricingPolicyEventParsed = pricingPolicyEvent.asV51
} else if (pricingPolicyEvent.isV101) {
pricingPolicyEventParsed = pricingPolicyEvent.asV101
}
if (pricingPolicyEvent.isV49) {
pricingPolicyEventParsed = pricingPolicyEvent.asV49
} else if (pricingPolicyEvent.isV51) {
pricingPolicyEventParsed = pricingPolicyEvent.asV51
} else if (pricingPolicyEvent.isV101) {
pricingPolicyEventParsed = pricingPolicyEvent.asV101
}

if (!pricingPolicyEventParsed) return
if (!pricingPolicyEventParsed) return

let pricingPolicy = new PricingPolicy()
pricingPolicy.id = item.event.id
let pricingPolicy = new PricingPolicy()
pricingPolicy.id = item.event.id

const savedPolicy = await ctx.store.get(PricingPolicy, { where: { pricingPolicyID: pricingPolicyEventParsed.id } })
if (savedPolicy) {
pricingPolicy = savedPolicy
}
const savedPolicy = await ctx.store.get(PricingPolicy, { where: { pricingPolicyID: pricingPolicyEventParsed.id } })
if (savedPolicy) {
pricingPolicy = savedPolicy
}

pricingPolicy.gridVersion = pricingPolicyEventParsed.version
pricingPolicy.pricingPolicyID = pricingPolicyEventParsed.id
pricingPolicy.name = validateString(ctx, pricingPolicyEventParsed.name.toString())
pricingPolicy.dedicatedNodeDiscount = 0
pricingPolicy.gridVersion = pricingPolicyEventParsed.version
pricingPolicy.pricingPolicyID = pricingPolicyEventParsed.id
pricingPolicy.name = validateString(ctx, pricingPolicyEventParsed.name.toString())
pricingPolicy.dedicatedNodeDiscount = 0

const foundationAccount = ss58.codec("substrate").encode(pricingPolicyEventParsed.foundationAccount);
const certifiedSalesAccount = ss58.codec("substrate").encode(pricingPolicyEventParsed.certifiedSalesAccount);
const foundationAccount = ss58.codec("substrate").encode(pricingPolicyEventParsed.foundationAccount);
const certifiedSalesAccount = ss58.codec("substrate").encode(pricingPolicyEventParsed.certifiedSalesAccount);

pricingPolicy.foundationAccount = foundationAccount
pricingPolicy.certifiedSalesAccount = certifiedSalesAccount
pricingPolicy.foundationAccount = foundationAccount
pricingPolicy.certifiedSalesAccount = certifiedSalesAccount

const suPolicy = new Policy()
suPolicy.value = pricingPolicyEventParsed.su.value
suPolicy.unit = validateString(ctx, pricingPolicyEventParsed.su.unit.toString())
const suPolicy = new Policy()
suPolicy.value = pricingPolicyEventParsed.su.value
suPolicy.unit = validateString(ctx, pricingPolicyEventParsed.su.unit.toString())

const nuPolicy = new Policy()
nuPolicy.value = pricingPolicyEventParsed.nu.value
nuPolicy.unit = validateString(ctx, pricingPolicyEventParsed.nu.unit.toString())
const nuPolicy = new Policy()
nuPolicy.value = pricingPolicyEventParsed.nu.value
nuPolicy.unit = validateString(ctx, pricingPolicyEventParsed.nu.unit.toString())

const cuPolicy = new Policy()
cuPolicy.value = pricingPolicyEventParsed.cu.value
cuPolicy.unit = validateString(ctx, pricingPolicyEventParsed.cu.unit.toString())
const cuPolicy = new Policy()
cuPolicy.value = pricingPolicyEventParsed.cu.value
cuPolicy.unit = validateString(ctx, pricingPolicyEventParsed.cu.unit.toString())

const IpuPolicy = new Policy()
IpuPolicy.value = pricingPolicyEventParsed.ipu.value
IpuPolicy.unit = validateString(ctx, pricingPolicyEventParsed.ipu.unit.toString())
const IpuPolicy = new Policy()
IpuPolicy.value = pricingPolicyEventParsed.ipu.value
IpuPolicy.unit = validateString(ctx, pricingPolicyEventParsed.ipu.unit.toString())

pricingPolicy.su = suPolicy
pricingPolicy.cu = cuPolicy
pricingPolicy.nu = nuPolicy
pricingPolicy.ipu = IpuPolicy
pricingPolicy.su = suPolicy
pricingPolicy.cu = cuPolicy
pricingPolicy.nu = nuPolicy
pricingPolicy.ipu = IpuPolicy

if (pricingPolicyEvent.isV51) {
let policyAsV50 = pricingPolicyEvent.asV51
pricingPolicy.dedicatedNodeDiscount = policyAsV50.discountForDedicatedNodes
}
if (pricingPolicyEvent.isV51) {
let policyAsV50 = pricingPolicyEvent.asV51
pricingPolicy.dedicatedNodeDiscount = policyAsV50.discountForDedicatedNodes
}

await ctx.store.save<PricingPolicy>(pricingPolicy)
await ctx.store.save<PricingPolicy>(pricingPolicy)
}

export async function farmingPolicyStored(
ctx: Ctx,
item: EventItem<'TfgridModule.FarmingPolicyStored', { event: { args: true } }>,
ctx: Ctx,
item: EventItem<'TfgridModule.FarmingPolicyStored', { event: { args: true } }>,
) {
const farmingPolicyEvent = new TfgridModuleFarmingPolicyStoredEvent(ctx, item.event)

if (!farmingPolicyEvent.isV63) {
return
}

const farmingPolicyStoredEvent = farmingPolicyEvent.asV63

const newFarmingPolicy = new FarmingPolicy()
newFarmingPolicy.id = item.event.id
newFarmingPolicy.gridVersion = farmingPolicyStoredEvent.version
newFarmingPolicy.farmingPolicyID = farmingPolicyStoredEvent.id
newFarmingPolicy.name = validateString(ctx, farmingPolicyStoredEvent.name.toString())

newFarmingPolicy.cu = farmingPolicyStoredEvent.cu
newFarmingPolicy.su = farmingPolicyStoredEvent.su
newFarmingPolicy.nu = farmingPolicyStoredEvent.nu
newFarmingPolicy.ipv4 = farmingPolicyStoredEvent.ipv4
newFarmingPolicy.policyCreated = farmingPolicyStoredEvent.policyCreated
newFarmingPolicy.policyEnd = farmingPolicyStoredEvent.policyEnd
newFarmingPolicy.immutable = farmingPolicyStoredEvent.immutable
newFarmingPolicy.default = farmingPolicyStoredEvent.default

const certificationTypeAsString = farmingPolicyStoredEvent.nodeCertification.__kind.toString()
let nodeCertType = NodeCertification.Diy
switch (certificationTypeAsString) {
case 'Diy':
nodeCertType = NodeCertification.Diy
break
case 'Certified':
nodeCertType = NodeCertification.Certified
break
}
newFarmingPolicy.nodeCertification = nodeCertType

const farmCertificationTypeAsString = farmingPolicyStoredEvent.farmCertification.__kind.toString()
let farmCertType = FarmCertification.NotCertified
switch (farmCertificationTypeAsString) {
case 'NotCertified':
farmCertType = FarmCertification.NotCertified
break
case 'Gold':
farmCertType = FarmCertification.Gold
break
}
newFarmingPolicy.farmCertification = farmCertType

await ctx.store.save<FarmingPolicy>(newFarmingPolicy)
const farmingPolicyEvent = new TfgridModuleFarmingPolicyStoredEvent(ctx, item.event)

if (!farmingPolicyEvent.isV63) {
return
}

const farmingPolicyStoredEvent = farmingPolicyEvent.asV63

const newFarmingPolicy = new FarmingPolicy()
newFarmingPolicy.id = item.event.id
newFarmingPolicy.gridVersion = farmingPolicyStoredEvent.version
newFarmingPolicy.farmingPolicyID = farmingPolicyStoredEvent.id
newFarmingPolicy.name = validateString(ctx, farmingPolicyStoredEvent.name.toString())

newFarmingPolicy.cu = farmingPolicyStoredEvent.cu
newFarmingPolicy.su = farmingPolicyStoredEvent.su
newFarmingPolicy.nu = farmingPolicyStoredEvent.nu
newFarmingPolicy.ipv4 = farmingPolicyStoredEvent.ipv4
newFarmingPolicy.policyCreated = farmingPolicyStoredEvent.policyCreated
newFarmingPolicy.policyEnd = farmingPolicyStoredEvent.policyEnd
newFarmingPolicy.immutable = farmingPolicyStoredEvent.immutable
newFarmingPolicy.default = farmingPolicyStoredEvent.default

const certificationTypeAsString = farmingPolicyStoredEvent.nodeCertification.__kind.toString()
let nodeCertType = NodeCertification.Diy
switch (certificationTypeAsString) {
case 'Diy':
nodeCertType = NodeCertification.Diy
break
case 'Certified':
nodeCertType = NodeCertification.Certified
break
}
newFarmingPolicy.nodeCertification = nodeCertType

const farmCertificationTypeAsString = farmingPolicyStoredEvent.farmCertification.__kind.toString()
let farmCertType = FarmCertification.NotCertified
switch (farmCertificationTypeAsString) {
case 'NotCertified':
farmCertType = FarmCertification.NotCertified
break
case 'Gold':
farmCertType = FarmCertification.Gold
break
}
newFarmingPolicy.farmCertification = farmCertType

await ctx.store.save<FarmingPolicy>(newFarmingPolicy)
}

export async function farmingPolicyUpdated(
ctx: Ctx,
item: EventItem<'TfgridModule.FarmingPolicyUpdated', { event: { args: true } }>,
ctx: Ctx,
item: EventItem<'TfgridModule.FarmingPolicyUpdated', { event: { args: true } }>,
) {
const farmingPolicyEvent = new TfgridModuleFarmingPolicyUpdatedEvent(ctx, item.event)

if (!farmingPolicyEvent.isV63) {
return
}

const farmingPolicyUpdatedEvent = farmingPolicyEvent.asV63

const savedPolicy = await ctx.store.get(FarmingPolicy, { where: { farmingPolicyID: farmingPolicyUpdatedEvent.id } })
if (!savedPolicy) return

savedPolicy.gridVersion = farmingPolicyUpdatedEvent.version
savedPolicy.farmingPolicyID = farmingPolicyUpdatedEvent.id
savedPolicy.name = validateString(ctx, farmingPolicyUpdatedEvent.name.toString())

savedPolicy.cu = farmingPolicyUpdatedEvent.cu
savedPolicy.su = farmingPolicyUpdatedEvent.su
savedPolicy.nu = farmingPolicyUpdatedEvent.nu
savedPolicy.ipv4 = farmingPolicyUpdatedEvent.ipv4
savedPolicy.policyCreated = farmingPolicyUpdatedEvent.policyCreated
savedPolicy.policyEnd = farmingPolicyUpdatedEvent.policyEnd
savedPolicy.immutable = farmingPolicyUpdatedEvent.immutable
savedPolicy.default = farmingPolicyUpdatedEvent.default

const certificationTypeAsString = farmingPolicyUpdatedEvent.nodeCertification.__kind.toString()
let nodeCertType = NodeCertification.Diy
switch (certificationTypeAsString) {
case 'Diy':
nodeCertType = NodeCertification.Diy
break
case 'Certified':
nodeCertType = NodeCertification.Certified
break
}
savedPolicy.nodeCertification = nodeCertType

const farmCertificationTypeAsString = farmingPolicyUpdatedEvent.farmCertification.__kind.toString()
let farmCertType = FarmCertification.NotCertified
switch (farmCertificationTypeAsString) {
case 'NotCertified':
farmCertType = FarmCertification.NotCertified
break
case 'Gold':
farmCertType = FarmCertification.Gold
break
}
savedPolicy.farmCertification = farmCertType

await ctx.store.save<FarmingPolicy>(savedPolicy)
const farmingPolicyEvent = new TfgridModuleFarmingPolicyUpdatedEvent(ctx, item.event)

if (!farmingPolicyEvent.isV63) {
return
}

const farmingPolicyUpdatedEvent = farmingPolicyEvent.asV63

const savedPolicy = await ctx.store.get(FarmingPolicy, { where: { farmingPolicyID: farmingPolicyUpdatedEvent.id } })
if (!savedPolicy) return

savedPolicy.gridVersion = farmingPolicyUpdatedEvent.version
savedPolicy.farmingPolicyID = farmingPolicyUpdatedEvent.id
savedPolicy.name = validateString(ctx, farmingPolicyUpdatedEvent.name.toString())

savedPolicy.cu = farmingPolicyUpdatedEvent.cu
savedPolicy.su = farmingPolicyUpdatedEvent.su
savedPolicy.nu = farmingPolicyUpdatedEvent.nu
savedPolicy.ipv4 = farmingPolicyUpdatedEvent.ipv4
savedPolicy.policyCreated = farmingPolicyUpdatedEvent.policyCreated
savedPolicy.policyEnd = farmingPolicyUpdatedEvent.policyEnd
savedPolicy.immutable = farmingPolicyUpdatedEvent.immutable
savedPolicy.default = farmingPolicyUpdatedEvent.default

const certificationTypeAsString = farmingPolicyUpdatedEvent.nodeCertification.__kind.toString()
let nodeCertType = NodeCertification.Diy
switch (certificationTypeAsString) {
case 'Diy':
nodeCertType = NodeCertification.Diy
break
case 'Certified':
nodeCertType = NodeCertification.Certified
break
}
savedPolicy.nodeCertification = nodeCertType

const farmCertificationTypeAsString = farmingPolicyUpdatedEvent.farmCertification.__kind.toString()
let farmCertType = FarmCertification.NotCertified
switch (farmCertificationTypeAsString) {
case 'NotCertified':
farmCertType = FarmCertification.NotCertified
break
case 'Gold':
farmCertType = FarmCertification.Gold
break
}
savedPolicy.farmCertification = farmCertType

await ctx.store.save<FarmingPolicy>(savedPolicy)
}
Loading

0 comments on commit 78e0955

Please sign in to comment.