Skip to content

Commit

Permalink
if rabbit claims AS uses references it could be right :D
Browse files Browse the repository at this point in the history
Signed-off-by: stadolf <[email protected]>
  • Loading branch information
elmariachi111 committed Oct 8, 2024
1 parent bd86bfe commit c952a3e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions subgraph/src/ipnftMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,16 @@ export function handleReservation(event: ReservedEvent): void {
reservation.save()
}

function updateIpnftMetadata(ipnft: Ipnft, uri: string, timestamp: BigInt): Ipnft {
function updateIpnftMetadata(ipnft: Ipnft, uri: string, timestamp: BigInt): void {
let ipfsLocation = uri.replace('ipfs://', '');
if (!ipfsLocation || ipfsLocation == uri) {
log.error("Invalid URI format for tokenId {}: {}", [ipnft.id, uri]);
return ipnft;
}

ipnft.tokenURI = uri;
ipnft.metadata = ipfsLocation;
ipnft.updatedAtTimestamp = timestamp;
IpnftMetadataTemplate.create(ipfsLocation);

return ipnft;
}

//the underlying parameter arrays are misaligned, hence we cannot cast or unify both events
Expand All @@ -96,7 +93,7 @@ export function handleMint(event: IPNFTMintedEvent): void {
ipnft.owner = event.params.owner
ipnft.createdAt = event.block.timestamp
ipnft.symbol = event.params.symbol
ipnft = updateIpnftMetadata(ipnft, event.params.tokenURI, event.block.timestamp)
updateIpnftMetadata(ipnft, event.params.tokenURI, event.block.timestamp)
store.remove('Reservation', event.params.tokenId.toString())
ipnft.save()

Expand All @@ -116,7 +113,7 @@ export function handleMetadataUpdated(event: MetadataUpdateEvent): void {
log.debug("no new uri found for token, likely just minted {}", [event.params._tokenId.toString()])
return
}
ipnft = updateIpnftMetadata(ipnft, newUri, event.block.timestamp)
updateIpnftMetadata(ipnft, newUri, event.block.timestamp)
ipnft.save()
}

0 comments on commit c952a3e

Please sign in to comment.