Skip to content

Commit

Permalink
debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
upalinski committed Oct 23, 2024
1 parent f79abf6 commit 7d57db4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {DdcCustomerDepositsProcessor} from "./processors/ddcCustomerDepositsProc
import {DdcCustomerChargesProcessor} from "./processors/ddcCustomerChargesProcessor";

processor.run(new TypeormDatabase({ supportHotBlocks: true }), async (ctx) => {
console.log("Got " + ctx.blocks.length + " blocks")
const logger = ctx.log

// set up processors
const cereBalancesProcessor = new CereBalancesProcessor()
const ddcBalancesProcessor = new DdcBalancesProcessor()
Expand Down Expand Up @@ -307,6 +307,7 @@ processor.run(new TypeormDatabase({ supportHotBlocks: true }), async (ctx) => {
amount: deposit.amount
}))
})
console.log("Storing customer deposits " + ddcCustomerDepositEntities.length)
await ctx.store.insert(ddcCustomerDepositEntities)

const ddcCustomerChargeEntities: DdcCustomerCharge[] = []
Expand All @@ -318,5 +319,6 @@ processor.run(new TypeormDatabase({ supportHotBlocks: true }), async (ctx) => {
amount: charge.amount
}))
})
console.log("Storing customer charges " + ddcCustomerChargeEntities.length)
await ctx.store.insert(ddcCustomerChargeEntities)
})
3 changes: 3 additions & 0 deletions src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {
} from '@subsquid/substrate-processor'
import { events } from './types'

console.info("Start squid indexer")


export const processor = new SubstrateBatchProcessor()
.setRpcEndpoint({
url: assertNotNull(process.env.RPC_CERE_HTTP, 'No RPC endpoint supplied'),
Expand Down
4 changes: 4 additions & 0 deletions src/processors/ddcCustomerChargesProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ export class DdcCustomerChargesProcessor extends BaseProcessor<State> {

switch (event.name) {
case events.ddcCustomers.charged.name: {
console.log("Got customer charged event")
if (events.ddcCustomers.charged.v48013.is(event)) {
console.log("Event version v48013")
// unsupported version, just skip
} else if (events.ddcCustomers.charged.v48014.is(event)) {
console.log("Event version v48014")
const decoded = events.ddcCustomers.charged.v48014.decode(event)
const accountId = decoded[0]
const amount = decoded[1]
Expand All @@ -36,6 +39,7 @@ export class DdcCustomerChargesProcessor extends BaseProcessor<State> {
amount: amount
})
} else if (events.ddcCustomers.charged.v48800.is(event)) {
console.log("Event version v48800")
const decoded = events.ddcCustomers.charged.v48800.decode(event)
const accountId = decoded.ownerId
const amount = decoded.charged
Expand Down
3 changes: 3 additions & 0 deletions src/processors/ddcCustomerDepositsProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export class DdcCustomerDepositsProcessor extends BaseProcessor<State> {

switch (event.name) {
case events.ddcCustomers.deposited.name: {
console.log("Got customer deposited event")
if (events.ddcCustomers.deposited.v48013.is(event)) {
console.log("Event version v48013")
const decoded = events.ddcCustomers.deposited.v48013.decode(event)
const accountId = decoded[0]
const amount = decoded[1]
Expand All @@ -34,6 +36,7 @@ export class DdcCustomerDepositsProcessor extends BaseProcessor<State> {
amount: amount
})
} else if (events.ddcCustomers.deposited.v48800.is(event)) {
console.log("Event version v48800")
const decoded = events.ddcCustomers.deposited.v48800.decode(event)
const accountId = decoded.ownerId
const amount = decoded.amount
Expand Down

0 comments on commit 7d57db4

Please sign in to comment.