Skip to content

Commit

Permalink
add loop for crappy rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcos20 committed Jul 28, 2023
1 parent 340788b commit d9d4209
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/mappings/erc721Factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ export function handleNewToken(event: TokenCreated): void {
token.cap = weiToDecimal(event.params.cap.toBigDecimal(), 18)
// get token id
const contract = ERC20Template.bind(event.params.newTokenAddress)
const contractTemplate = contract.try_getId()
if (!contractTemplate.reverted) {
token.templateId = contractTemplate.value
}
let tries = 0
// protect against crappy rpc
do {
const contractTemplate = contract.try_getId()
if (!contractTemplate.reverted) {
token.templateId = contractTemplate.value
break
}
tries++
} while (tries < 300)
token.save()
addDatatoken()
if (token.templateId == 3) {
Expand Down

0 comments on commit d9d4209

Please sign in to comment.