mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
catch error
This commit is contained in:
parent
a0d3c365bb
commit
0f65e72690
@ -1,6 +1,6 @@
|
|||||||
import { Dispenser } from '../../@types/schema'
|
import { Dispenser } from '../../@types/schema'
|
||||||
import { getToken } from './tokenUtils'
|
import { getToken } from './tokenUtils'
|
||||||
import { Address } from '@graphprotocol/graph-ts'
|
import { Address, log } from '@graphprotocol/graph-ts'
|
||||||
import { weiToDecimal } from './generic'
|
import { weiToDecimal } from './generic'
|
||||||
import { Dispenser as DispenserContract } from '../../@types/templates/Dispenser/Dispenser'
|
import { Dispenser as DispenserContract } from '../../@types/templates/Dispenser/Dispenser'
|
||||||
|
|
||||||
@ -29,17 +29,24 @@ export function updateDispenserDetails(
|
|||||||
contractAddress: Address,
|
contractAddress: Address,
|
||||||
datatokenAddress: Address
|
datatokenAddress: Address
|
||||||
): void {
|
): void {
|
||||||
const dispenserID = getDispenserGraphID(contractAddress, datatokenAddress)
|
try {
|
||||||
const dispenser = getDispenser(dispenserID)
|
const dispenserID = getDispenserGraphID(contractAddress, datatokenAddress)
|
||||||
const contract = DispenserContract.bind(contractAddress)
|
const dispenser = getDispenser(dispenserID)
|
||||||
const dispenserDetails = contract.try_status(datatokenAddress)
|
const contract = DispenserContract.bind(contractAddress)
|
||||||
if (dispenserDetails == null) return
|
const dispenserDetails = contract.try_status(datatokenAddress)
|
||||||
const token = getToken(datatokenAddress, true)
|
if (dispenserDetails == null) return
|
||||||
dispenser.balance = weiToDecimal(
|
const token = getToken(datatokenAddress, true)
|
||||||
dispenserDetails.value.value5.toBigDecimal(),
|
dispenser.balance = weiToDecimal(
|
||||||
token.decimals
|
dispenserDetails.value.value5.toBigDecimal(),
|
||||||
)
|
token.decimals
|
||||||
dispenser.isMinter = dispenserDetails.value.value2
|
)
|
||||||
dispenser.active = dispenserDetails.value.value0
|
dispenser.isMinter = dispenserDetails.value.value2
|
||||||
dispenser.save()
|
dispenser.active = dispenserDetails.value.value0
|
||||||
|
dispenser.save()
|
||||||
|
} catch (error) {
|
||||||
|
log.error(
|
||||||
|
'Failed to update dispenser details , address: {}, dtAddress: {}',
|
||||||
|
[contractAddress.toHexString(), datatokenAddress.toString()]
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user