import { ApiPromise } from '@polkadot/api' ; import { BlockNumber , Hash } from '@polkadot/types/interfaces' ; import { logger } from '@polkadot/util' ; import { prisma } from '../generated/prisma-client' ; import { Cached , NomidotTotalIssuance , Task } from './types' ; const l = logger ( 'Task: TotalIssuance' ) ; const createTotalIssuance = { name : 'createTotalIssuance' , read : async ( blockHash , _cached , api ) : Promise < NomidotTotalIssuance > => { const amount = await api . query . balances . totalIssuance . at ( blockHash ) ; const result = { amount , } ; l . log ( `Total Issuance: ${ JSON . stringify ( result ) }` ) ; return result ; } , write : async ( blockNumber , value ) => { await prisma . createTotalIssuance ( { amount : value . amount . toHex ( ) , blockNumber : { connect : { number : blockNumber . toNumber ( ) , } , } , } ) ; } , } ; export default createTotalIssuance ;