Skip to content

Commit

Permalink
fix: added parsing depending on the block type for ChainFollower.ts (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kammerlo committed Jun 4, 2024
1 parent caa2316 commit 97babf4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ services:
hasura:
build:
context: ./packages/api-cardano-db-hasura/hasura
image: cardanofoundation/cardano-graphql-hasura:${CARDANO_GRAPHQL_VERSION:-8.0.1}
image: cardanofoundation/cardano-graphql-hasura:${CARDANO_GRAPHQL_VERSION:-8.0.3}
ports:
- ${HASURA_PORT:-8090}:8080
depends_on:
Expand All @@ -100,7 +100,7 @@ services:
cache_from: [ cardanofoundation/cardano-graphql-background:latest ]
context: .
target: background
image: cardanofoundation/cardano-graphql-background:${CARDANO_GRAPHQL_VERSION:-8.0.1}-${NETWORK:-mainnet}
image: cardanofoundation/cardano-graphql-background:${CARDANO_GRAPHQL_VERSION:-8.0.3}-${NETWORK:-mainnet}
depends_on:
- "hasura"
- "postgres"
Expand All @@ -126,7 +126,7 @@ services:
cache_from: [ inputoutput/cardano-graphql-server:latest ]
context: .
target: server
image: cardanofoundation/cardano-graphql-server:${CARDANO_GRAPHQL_VERSION:-8.0.1}-${NETWORK:-mainnet}
image: cardanofoundation/cardano-graphql-server:${CARDANO_GRAPHQL_VERSION:-8.0.3}-${NETWORK:-mainnet}
environment:
- ALLOW_INTROSPECTION=true
- CACHE_ENABLED=true
Expand Down
16 changes: 13 additions & 3 deletions packages/api-cardano-db-hasura/src/ChainFollower.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import util, { assetFingerprint, errors, RunnableModuleState } from '@cardano-gr
import PgBoss from 'pg-boss'
import { dummyLogger, Logger } from 'ts-log'
import { createInteractionContextWithLogger } from './util'
import { PointOrOrigin, BlockPraos } from '@cardano-ogmios/schema'
import { PointOrOrigin, BlockPraos, BlockBFT } from '@cardano-ogmios/schema'
import { HasuraBackgroundClient } from './HasuraBackgroundClient'
import { DbConfig } from './typeAliases'
import { ChainSynchronizationClient } from '@cardano-ogmios/client/dist/ChainSynchronization'
Expand Down Expand Up @@ -60,7 +60,17 @@ export class ChainFollower {
requestNext()
},
rollForward: async ({ block }, requestNext) => {
const b = block as BlockPraos
let b
switch (block.type) {
case 'praos':
b = block as BlockPraos
break
case 'bft':
b = block as BlockBFT
break
case 'ebb': // No transaction in there
return
}
if (b !== undefined && b.transactions !== undefined) {
for (const tx of b.transactions) {
if (tx.mint !== undefined) {
Expand Down Expand Up @@ -90,7 +100,7 @@ export class ChainFollower {
this.logger.info({ module: MODULE_NAME }, 'Initialized')
}

async saveAsset (policyId: string, assetName: string | undefined, b: BlockPraos) {
async saveAsset (policyId: string, assetName: string | undefined, b: BlockPraos | BlockBFT) {
const assetId = `${policyId}${assetName !== undefined ? assetName : ''}`
if (!(await this.hasuraClient.hasAsset(assetId))) {
const asset = {
Expand Down

0 comments on commit 97babf4

Please sign in to comment.