create new user when processing new datatoken

This commit is contained in:
ssallam 2020-12-02 11:26:50 +01:00
parent 7184969ece
commit d834f6bdfa
2 changed files with 4 additions and 1 deletions

View File

@ -115,7 +115,7 @@ type Datatoken @entity {
cap: BigDecimal! cap: BigDecimal!
supply: BigDecimal! supply: BigDecimal!
minter: User! minter: User!
publisher: User! publisher: String!
holderCount: BigInt! # Number of addresses holding a balance of datatoken holderCount: BigInt! # Number of addresses holding a balance of datatoken
orderCount: BigInt! # Number of orders executed for this dataset orderCount: BigInt! # Number of orders executed for this dataset

View File

@ -3,6 +3,7 @@ import { TokenRegistered } from '../types/DTFactory/DTFactory'
import { DatatokenFactory, Datatoken } from '../types/schema' import { DatatokenFactory, Datatoken } from '../types/schema'
import { Datatoken as DatatokenContract } from '../types/templates' import { Datatoken as DatatokenContract } from '../types/templates'
import { import {
createUserEntity,
tokenToDecimal, tokenToDecimal,
ZERO_BD, ZERO_BD,
} from './helpers' } from './helpers'
@ -29,6 +30,8 @@ export function handleNewToken(event: TokenRegistered): void {
datatoken.address = event.params.tokenAddress.toHexString() datatoken.address = event.params.tokenAddress.toHexString()
datatoken.cap = tokenToDecimal(event.params.tokenCap.toBigDecimal(), 18) datatoken.cap = tokenToDecimal(event.params.tokenCap.toBigDecimal(), 18)
datatoken.supply = ZERO_BD datatoken.supply = ZERO_BD
createUserEntity(event.params.registeredBy.toHex())
datatoken.minter = event.params.registeredBy.toHex() datatoken.minter = event.params.registeredBy.toHex()
datatoken.publisher = event.params.registeredBy.toHex() datatoken.publisher = event.params.registeredBy.toHex()